Browse code

- print_* function don't use stdout anymore

Jan Janak authored on 10/04/2003 12:38:18
Showing 10 changed files
... ...
@@ -31,7 +31,6 @@
31 31
  *  2003-03-25 Adapted to use new parameter parser (janakj)
32 32
  */
33 33
 
34
-#include <stdio.h>         /* printf */
35 34
 #include <string.h>        /* memset */
36 35
 #include "../../mem/mem.h" /* pkg_malloc, pkg_free */
37 36
 #include "../../dprint.h"
... ...
@@ -224,22 +223,22 @@ void free_contacts(contact_t** _c)
224 224
 /*
225 225
  * Print list of contacts, just for debugging
226 226
  */
227
-void print_contacts(contact_t* _c)
227
+void print_contacts(FILE* _o, contact_t* _c)
228 228
 {
229 229
 	contact_t* ptr;
230 230
 
231 231
 	ptr = _c;
232 232
 
233 233
 	while(ptr) {
234
-		printf("---Contact---\n");
235
-		printf("URI    : \'%.*s\'\n", ptr->uri.len, ptr->uri.s);
236
-		printf("q      : %p\n", ptr->q);
237
-		printf("expires: %p\n", ptr->expires);
238
-		printf("method : %p\n", ptr->method);
234
+		fprintf(_o, "---Contact---\n");
235
+		fprintf(_o, "URI    : \'%.*s\'\n", ptr->uri.len, ptr->uri.s);
236
+		fprintf(_o, "q      : %p\n", ptr->q);
237
+		fprintf(_o, "expires: %p\n", ptr->expires);
238
+		fprintf(_o, "method : %p\n", ptr->method);
239 239
 		if (ptr->params) {
240
-			print_params(ptr->params);
240
+			print_params(_o, ptr->params);
241 241
 		}
242
-		printf("---/Contact---\n");
242
+		fprintf(_o, "---/Contact---\n");
243 243
 		ptr = ptr->next;
244 244
 	}
245 245
 }
... ...
@@ -35,6 +35,7 @@
35 35
 #ifndef CONTACT_H
36 36
 #define CONTACT_H
37 37
 
38
+#include <stdio.h>
38 39
 #include "../../str.h"
39 40
 #include "../parse_param.h"
40 41
 
... ...
@@ -68,7 +69,7 @@ void free_contacts(contact_t** _c);
68 68
 /*
69 69
  * Print list of contacts, just for debugging
70 70
  */
71
-void print_contacts(contact_t* _c);
71
+void print_contacts(FILE* _o, contact_t* _c);
72 72
 
73 73
 
74 74
 #endif /* CONTACT_H */
... ...
@@ -31,7 +31,6 @@
31 31
  *  2003-03-25 Adapted to use new parameter parser (janakj)
32 32
  */
33 33
 
34
-#include <stdio.h>           /* printf */
35 34
 #include <string.h>          /* memset */
36 35
 #include "../hf.h"     
37 36
 #include "../../mem/mem.h"   /* pkg_malloc, pkg_free */
... ...
@@ -115,10 +114,10 @@ void free_contact(contact_body_t** _c)
115 115
 /*
116 116
  * Print structure, for debugging only
117 117
  */
118
-void print_contact(contact_body_t* _c)
118
+void print_contact(FILE* _o, contact_body_t* _c)
119 119
 {
120
-	printf("===Contact body===\n");
121
-	printf("star: %d\n", _c->star);
122
-	print_contacts(_c->contacts);
123
-	printf("===/Contact body===\n");
120
+	fprintf(_o, "===Contact body===\n");
121
+	fprintf(_o, "star: %d\n", _c->star);
122
+	print_contacts(_o, _c->contacts);
123
+	fprintf(_o, "===/Contact body===\n");
124 124
 }
... ...
@@ -35,6 +35,7 @@
35 35
 #ifndef PARSE_CONTACT_H
36 36
 #define PARSE_CONTACT_H
37 37
 
38
+#include <stdio.h>
38 39
 #include "../hf.h"
39 40
 #include "../../str.h"
40 41
 #include "contact.h"
... ...
@@ -61,7 +62,7 @@ void free_contact(contact_body_t** _c);
61 61
 /*
62 62
  * Print structure, for debugging only
63 63
  */
64
-void print_contact(contact_body_t* _c);
64
+void print_contact(FILE* _o, contact_body_t* _c);
65 65
 
66 66
 
67 67
 #endif /* PARSE_CONTACT_H */
... ...
@@ -29,7 +29,6 @@
29 29
  * 2003-03-24 Created by janakj
30 30
  */
31 31
 
32
-#include <stdio.h>
33 32
 #include <string.h>
34 33
 #include "../dprint.h"
35 34
 #include "parse_nameaddr.h"
... ...
@@ -79,10 +78,10 @@ int parse_nameaddr(str* _s, name_addr_t* _a)
79 79
 /*
80 80
  * Print a name-addr structure, just for debugging
81 81
  */
82
-void print_nameaddr(name_addr_t* _a)
82
+void print_nameaddr(FILE* _o, name_addr_t* _a)
83 83
 {
84
-	printf("---name-addr---\n");
85
-	printf("name: '%.*s'\n", _a->name.len, _a->name.s);
86
-	printf("uri : '%.*s'\n", _a->uri.len, _a->uri.s);
87
-	printf("---/name-addr---\n");
84
+	fprintf(_o, "---name-addr---\n");
85
+	fprintf(_o, "name: '%.*s'\n", _a->name.len, _a->name.s);
86
+	fprintf(_o, "uri : '%.*s'\n", _a->uri.len, _a->uri.s);
87
+	fprintf(_o, "---/name-addr---\n");
88 88
 }
... ...
@@ -32,6 +32,7 @@
32 32
 #ifndef PARSE_NAMEADDR_H
33 33
 #define PARSE_NAMEADDR_H
34 34
 
35
+#include <stdio.h>
35 36
 #include "../str.h"
36 37
 
37 38
 /*
... ...
@@ -54,7 +55,7 @@ int parse_nameaddr(str* _s, name_addr_t* _a);
54 54
 /*
55 55
  * Print a name-addr structure, just for debugging
56 56
  */
57
-void print_nameaddr(name_addr_t* _a);
57
+void print_nameaddr(FILE* _o, name_addr_t* _a);
58 58
 
59 59
 
60 60
 #endif /* PARSE_NAMEADDR_H */
... ...
@@ -33,7 +33,6 @@
33 33
  * 2003-04-07 URI class added (janakj)
34 34
  */
35 35
 
36
-#include <stdio.h>
37 36
 #include <string.h>
38 37
 #include "../str.h"
39 38
 #include "../ut.h"
... ...
@@ -422,11 +421,11 @@ void shm_free_params(param_t* _p)
422 422
 /*
423 423
  * Print a parameter structure, just for debugging
424 424
  */
425
-static inline void print_param(param_t* _p)
425
+static inline void print_param(FILE* _o, param_t* _p)
426 426
 {
427 427
 	char* type;
428 428
 
429
-	printf("---param(%p)---\n", _p);
429
+	fprintf(_o, "---param(%p)---\n", _p);
430 430
 	
431 431
 	switch(_p->type) {
432 432
 	case P_OTHER:     type = "P_OTHER";     break;
... ...
@@ -440,24 +439,24 @@ static inline void print_param(param_t* _p)
440 440
 	default:          type = "UNKNOWN";     break;
441 441
 	}
442 442
 	
443
-	printf("type: %s\n", type);
444
-	printf("name: \'%.*s\'\n", _p->name.len, _p->name.s);
445
-	printf("body: \'%.*s\'\n", _p->body.len, _p->body.s);
446
-	printf("len : %d\n", _p->len);
447
-	printf("---/param---\n");
443
+	fprintf(_o, "type: %s\n", type);
444
+	fprintf(_o, "name: \'%.*s\'\n", _p->name.len, _p->name.s);
445
+	fprintf(_o, "body: \'%.*s\'\n", _p->body.len, _p->body.s);
446
+	fprintf(_o, "len : %d\n", _p->len);
447
+	fprintf(_o, "---/param---\n");
448 448
 }
449 449
 
450 450
 
451 451
 /*
452 452
  * Print linked list of parameters, just for debugging
453 453
  */
454
-void print_params(param_t* _p)
454
+void print_params(FILE* _o, param_t* _p)
455 455
 {
456 456
 	param_t* ptr;
457 457
 	
458 458
 	ptr = _p;
459 459
 	while(ptr) {
460
-		print_param(ptr);
460
+		print_param(_o, ptr);
461 461
 		ptr = ptr->next;
462 462
 	}
463 463
 }
... ...
@@ -36,6 +36,8 @@
36 36
 #ifndef PARSE_PARAM_H
37 37
 #define PARSE_PARAM_H
38 38
 
39
+#include <stdio.h>
40
+
39 41
 
40 42
 /*
41 43
  * Supported types of parameters
... ...
@@ -129,12 +131,10 @@ void free_params(param_t* _p);
129 129
 void shm_free_params(param_t* _p);
130 130
 
131 131
 
132
-
133
-
134 132
 /*
135 133
  * Print linked list of parameters, just for debugging
136 134
  */
137
-void print_params(param_t* _p);
135
+void print_params(FILE* _o, param_t* _p);
138 136
 
139 137
 
140 138
 /*
... ...
@@ -27,7 +27,6 @@
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 28
  */
29 29
 
30
-#include <stdio.h>
31 30
 #include <string.h>
32 31
 #include "parse_rr.h"
33 32
 #include "../mem/mem.h"
... ...
@@ -181,20 +180,20 @@ void shm_free_rr(rr_t** _r)
181 181
 /*
182 182
  * Print list of RRs, just for debugging
183 183
  */
184
-void print_rr(rr_t* _r)
184
+void print_rr(FILE* _o, rr_t* _r)
185 185
 {
186 186
 	rr_t* ptr;
187 187
 
188 188
 	ptr = _r;
189 189
 
190 190
 	while(ptr) {
191
-		printf("---RR---\n");
192
-		print_nameaddr(&ptr->nameaddr);
193
-		printf("r2 : %p\n", ptr->r2);
191
+		fprintf(_o, "---RR---\n");
192
+		print_nameaddr(_o, &ptr->nameaddr);
193
+		fprintf(_o, "r2 : %p\n", ptr->r2);
194 194
 		if (ptr->params) {
195
-			print_params(ptr->params);
195
+			print_params(_o, ptr->params);
196 196
 		}
197
-		printf("---/RR---\n");
197
+		fprintf(_o, "---/RR---\n");
198 198
 		ptr = ptr->next;
199 199
 	}
200 200
 }
... ...
@@ -31,6 +31,7 @@
31 31
 #ifndef PARSE_RR_H
32 32
 #define PARSE_RR_H
33 33
 
34
+#include <stdio.h>
34 35
 #include "msg_parser.h"
35 36
 #include "parse_nameaddr.h"
36 37
 #include "parse_param.h"
... ...
@@ -72,7 +73,7 @@ void shm_free_rr(rr_t** _r);
72 72
 /*
73 73
  * Print list of rrs, just for debugging
74 74
  */
75
-void print_rr(rr_t* _r);
75
+void print_rr(FILE* _o, rr_t* _r);
76 76
 
77 77
 
78 78
 /*