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 223
 /*
225 224
  * Print list of contacts, just for debugging
226 225
  */
227
-void print_contacts(contact_t* _c)
226
+void print_contacts(FILE* _o, contact_t* _c)
228 227
 {
229 228
 	contact_t* ptr;
230 229
 
231 230
 	ptr = _c;
232 231
 
233 232
 	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);
233
+		fprintf(_o, "---Contact---\n");
234
+		fprintf(_o, "URI    : \'%.*s\'\n", ptr->uri.len, ptr->uri.s);
235
+		fprintf(_o, "q      : %p\n", ptr->q);
236
+		fprintf(_o, "expires: %p\n", ptr->expires);
237
+		fprintf(_o, "method : %p\n", ptr->method);
239 238
 		if (ptr->params) {
240
-			print_params(ptr->params);
239
+			print_params(_o, ptr->params);
241 240
 		}
242
-		printf("---/Contact---\n");
241
+		fprintf(_o, "---/Contact---\n");
243 242
 		ptr = ptr->next;
244 243
 	}
245 244
 }
... ...
@@ -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 69
 /*
69 70
  * Print list of contacts, just for debugging
70 71
  */
71
-void print_contacts(contact_t* _c);
72
+void print_contacts(FILE* _o, contact_t* _c);
72 73
 
73 74
 
74 75
 #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 114
 /*
116 115
  * Print structure, for debugging only
117 116
  */
118
-void print_contact(contact_body_t* _c)
117
+void print_contact(FILE* _o, contact_body_t* _c)
119 118
 {
120
-	printf("===Contact body===\n");
121
-	printf("star: %d\n", _c->star);
122
-	print_contacts(_c->contacts);
123
-	printf("===/Contact body===\n");
119
+	fprintf(_o, "===Contact body===\n");
120
+	fprintf(_o, "star: %d\n", _c->star);
121
+	print_contacts(_o, _c->contacts);
122
+	fprintf(_o, "===/Contact body===\n");
124 123
 }
... ...
@@ -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 62
 /*
62 63
  * Print structure, for debugging only
63 64
  */
64
-void print_contact(contact_body_t* _c);
65
+void print_contact(FILE* _o, contact_body_t* _c);
65 66
 
66 67
 
67 68
 #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 78
 /*
80 79
  * Print a name-addr structure, just for debugging
81 80
  */
82
-void print_nameaddr(name_addr_t* _a)
81
+void print_nameaddr(FILE* _o, name_addr_t* _a)
83 82
 {
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");
83
+	fprintf(_o, "---name-addr---\n");
84
+	fprintf(_o, "name: '%.*s'\n", _a->name.len, _a->name.s);
85
+	fprintf(_o, "uri : '%.*s'\n", _a->uri.len, _a->uri.s);
86
+	fprintf(_o, "---/name-addr---\n");
88 87
 }
... ...
@@ -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 55
 /*
55 56
  * Print a name-addr structure, just for debugging
56 57
  */
57
-void print_nameaddr(name_addr_t* _a);
58
+void print_nameaddr(FILE* _o, name_addr_t* _a);
58 59
 
59 60
 
60 61
 #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 421
 /*
423 422
  * Print a parameter structure, just for debugging
424 423
  */
425
-static inline void print_param(param_t* _p)
424
+static inline void print_param(FILE* _o, param_t* _p)
426 425
 {
427 426
 	char* type;
428 427
 
429
-	printf("---param(%p)---\n", _p);
428
+	fprintf(_o, "---param(%p)---\n", _p);
430 429
 	
431 430
 	switch(_p->type) {
432 431
 	case P_OTHER:     type = "P_OTHER";     break;
... ...
@@ -440,24 +439,24 @@ static inline void print_param(param_t* _p)
440 439
 	default:          type = "UNKNOWN";     break;
441 440
 	}
442 441
 	
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");
442
+	fprintf(_o, "type: %s\n", type);
443
+	fprintf(_o, "name: \'%.*s\'\n", _p->name.len, _p->name.s);
444
+	fprintf(_o, "body: \'%.*s\'\n", _p->body.len, _p->body.s);
445
+	fprintf(_o, "len : %d\n", _p->len);
446
+	fprintf(_o, "---/param---\n");
448 447
 }
449 448
 
450 449
 
451 450
 /*
452 451
  * Print linked list of parameters, just for debugging
453 452
  */
454
-void print_params(param_t* _p)
453
+void print_params(FILE* _o, param_t* _p)
455 454
 {
456 455
 	param_t* ptr;
457 456
 	
458 457
 	ptr = _p;
459 458
 	while(ptr) {
460
-		print_param(ptr);
459
+		print_param(_o, ptr);
461 460
 		ptr = ptr->next;
462 461
 	}
463 462
 }
... ...
@@ -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 131
 void shm_free_params(param_t* _p);
130 132
 
131 133
 
132
-
133
-
134 134
 /*
135 135
  * Print linked list of parameters, just for debugging
136 136
  */
137
-void print_params(param_t* _p);
137
+void print_params(FILE* _o, param_t* _p);
138 138
 
139 139
 
140 140
 /*
... ...
@@ -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 180
 /*
182 181
  * Print list of RRs, just for debugging
183 182
  */
184
-void print_rr(rr_t* _r)
183
+void print_rr(FILE* _o, rr_t* _r)
185 184
 {
186 185
 	rr_t* ptr;
187 186
 
188 187
 	ptr = _r;
189 188
 
190 189
 	while(ptr) {
191
-		printf("---RR---\n");
192
-		print_nameaddr(&ptr->nameaddr);
193
-		printf("r2 : %p\n", ptr->r2);
190
+		fprintf(_o, "---RR---\n");
191
+		print_nameaddr(_o, &ptr->nameaddr);
192
+		fprintf(_o, "r2 : %p\n", ptr->r2);
194 193
 		if (ptr->params) {
195
-			print_params(ptr->params);
194
+			print_params(_o, ptr->params);
196 195
 		}
197
-		printf("---/RR---\n");
196
+		fprintf(_o, "---/RR---\n");
198 197
 		ptr = ptr->next;
199 198
 	}
200 199
 }
... ...
@@ -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 73
 /*
73 74
  * Print list of rrs, just for debugging
74 75
  */
75
-void print_rr(rr_t* _r);
76
+void print_rr(FILE* _o, rr_t* _r);
76 77
 
77 78
 
78 79
 /*