2
0
Эх сурвалжийг харах

- print_* function don't use stdout anymore

Jan Janak 22 жил өмнө
parent
commit
1c6135b667

+ 8 - 9
parser/contact/contact.c

@@ -31,7 +31,6 @@
  *  2003-03-25 Adapted to use new parameter parser (janakj)
  *  2003-03-25 Adapted to use new parameter parser (janakj)
  */
  */
 
 
-#include <stdio.h>         /* printf */
 #include <string.h>        /* memset */
 #include <string.h>        /* memset */
 #include "../../mem/mem.h" /* pkg_malloc, pkg_free */
 #include "../../mem/mem.h" /* pkg_malloc, pkg_free */
 #include "../../dprint.h"
 #include "../../dprint.h"
@@ -224,22 +223,22 @@ void free_contacts(contact_t** _c)
 /*
 /*
  * Print list of contacts, just for debugging
  * Print list of contacts, just for debugging
  */
  */
-void print_contacts(contact_t* _c)
+void print_contacts(FILE* _o, contact_t* _c)
 {
 {
 	contact_t* ptr;
 	contact_t* ptr;
 
 
 	ptr = _c;
 	ptr = _c;
 
 
 	while(ptr) {
 	while(ptr) {
-		printf("---Contact---\n");
-		printf("URI    : \'%.*s\'\n", ptr->uri.len, ptr->uri.s);
-		printf("q      : %p\n", ptr->q);
-		printf("expires: %p\n", ptr->expires);
-		printf("method : %p\n", ptr->method);
+		fprintf(_o, "---Contact---\n");
+		fprintf(_o, "URI    : \'%.*s\'\n", ptr->uri.len, ptr->uri.s);
+		fprintf(_o, "q      : %p\n", ptr->q);
+		fprintf(_o, "expires: %p\n", ptr->expires);
+		fprintf(_o, "method : %p\n", ptr->method);
 		if (ptr->params) {
 		if (ptr->params) {
-			print_params(ptr->params);
+			print_params(_o, ptr->params);
 		}
 		}
-		printf("---/Contact---\n");
+		fprintf(_o, "---/Contact---\n");
 		ptr = ptr->next;
 		ptr = ptr->next;
 	}
 	}
 }
 }

+ 2 - 1
parser/contact/contact.h

@@ -35,6 +35,7 @@
 #ifndef CONTACT_H
 #ifndef CONTACT_H
 #define CONTACT_H
 #define CONTACT_H
 
 
+#include <stdio.h>
 #include "../../str.h"
 #include "../../str.h"
 #include "../parse_param.h"
 #include "../parse_param.h"
 
 
@@ -68,7 +69,7 @@ void free_contacts(contact_t** _c);
 /*
 /*
  * Print list of contacts, just for debugging
  * Print list of contacts, just for debugging
  */
  */
-void print_contacts(contact_t* _c);
+void print_contacts(FILE* _o, contact_t* _c);
 
 
 
 
 #endif /* CONTACT_H */
 #endif /* CONTACT_H */

+ 5 - 6
parser/contact/parse_contact.c

@@ -31,7 +31,6 @@
  *  2003-03-25 Adapted to use new parameter parser (janakj)
  *  2003-03-25 Adapted to use new parameter parser (janakj)
  */
  */
 
 
-#include <stdio.h>           /* printf */
 #include <string.h>          /* memset */
 #include <string.h>          /* memset */
 #include "../hf.h"     
 #include "../hf.h"     
 #include "../../mem/mem.h"   /* pkg_malloc, pkg_free */
 #include "../../mem/mem.h"   /* pkg_malloc, pkg_free */
@@ -115,10 +114,10 @@ void free_contact(contact_body_t** _c)
 /*
 /*
  * Print structure, for debugging only
  * Print structure, for debugging only
  */
  */
-void print_contact(contact_body_t* _c)
+void print_contact(FILE* _o, contact_body_t* _c)
 {
 {
-	printf("===Contact body===\n");
-	printf("star: %d\n", _c->star);
-	print_contacts(_c->contacts);
-	printf("===/Contact body===\n");
+	fprintf(_o, "===Contact body===\n");
+	fprintf(_o, "star: %d\n", _c->star);
+	print_contacts(_o, _c->contacts);
+	fprintf(_o, "===/Contact body===\n");
 }
 }

+ 2 - 1
parser/contact/parse_contact.h

@@ -35,6 +35,7 @@
 #ifndef PARSE_CONTACT_H
 #ifndef PARSE_CONTACT_H
 #define PARSE_CONTACT_H
 #define PARSE_CONTACT_H
 
 
+#include <stdio.h>
 #include "../hf.h"
 #include "../hf.h"
 #include "../../str.h"
 #include "../../str.h"
 #include "contact.h"
 #include "contact.h"
@@ -61,7 +62,7 @@ void free_contact(contact_body_t** _c);
 /*
 /*
  * Print structure, for debugging only
  * Print structure, for debugging only
  */
  */
-void print_contact(contact_body_t* _c);
+void print_contact(FILE* _o, contact_body_t* _c);
 
 
 
 
 #endif /* PARSE_CONTACT_H */
 #endif /* PARSE_CONTACT_H */

+ 5 - 6
parser/parse_nameaddr.c

@@ -29,7 +29,6 @@
  * 2003-03-24 Created by janakj
  * 2003-03-24 Created by janakj
  */
  */
 
 
-#include <stdio.h>
 #include <string.h>
 #include <string.h>
 #include "../dprint.h"
 #include "../dprint.h"
 #include "parse_nameaddr.h"
 #include "parse_nameaddr.h"
@@ -79,10 +78,10 @@ int parse_nameaddr(str* _s, name_addr_t* _a)
 /*
 /*
  * Print a name-addr structure, just for debugging
  * Print a name-addr structure, just for debugging
  */
  */
-void print_nameaddr(name_addr_t* _a)
+void print_nameaddr(FILE* _o, name_addr_t* _a)
 {
 {
-	printf("---name-addr---\n");
-	printf("name: '%.*s'\n", _a->name.len, _a->name.s);
-	printf("uri : '%.*s'\n", _a->uri.len, _a->uri.s);
-	printf("---/name-addr---\n");
+	fprintf(_o, "---name-addr---\n");
+	fprintf(_o, "name: '%.*s'\n", _a->name.len, _a->name.s);
+	fprintf(_o, "uri : '%.*s'\n", _a->uri.len, _a->uri.s);
+	fprintf(_o, "---/name-addr---\n");
 }
 }

+ 2 - 1
parser/parse_nameaddr.h

@@ -32,6 +32,7 @@
 #ifndef PARSE_NAMEADDR_H
 #ifndef PARSE_NAMEADDR_H
 #define PARSE_NAMEADDR_H
 #define PARSE_NAMEADDR_H
 
 
+#include <stdio.h>
 #include "../str.h"
 #include "../str.h"
 
 
 /*
 /*
@@ -54,7 +55,7 @@ int parse_nameaddr(str* _s, name_addr_t* _a);
 /*
 /*
  * Print a name-addr structure, just for debugging
  * Print a name-addr structure, just for debugging
  */
  */
-void print_nameaddr(name_addr_t* _a);
+void print_nameaddr(FILE* _o, name_addr_t* _a);
 
 
 
 
 #endif /* PARSE_NAMEADDR_H */
 #endif /* PARSE_NAMEADDR_H */

+ 9 - 10
parser/parse_param.c

@@ -33,7 +33,6 @@
  * 2003-04-07 URI class added (janakj)
  * 2003-04-07 URI class added (janakj)
  */
  */
 
 
-#include <stdio.h>
 #include <string.h>
 #include <string.h>
 #include "../str.h"
 #include "../str.h"
 #include "../ut.h"
 #include "../ut.h"
@@ -422,11 +421,11 @@ void shm_free_params(param_t* _p)
 /*
 /*
  * Print a parameter structure, just for debugging
  * Print a parameter structure, just for debugging
  */
  */
-static inline void print_param(param_t* _p)
+static inline void print_param(FILE* _o, param_t* _p)
 {
 {
 	char* type;
 	char* type;
 
 
-	printf("---param(%p)---\n", _p);
+	fprintf(_o, "---param(%p)---\n", _p);
 	
 	
 	switch(_p->type) {
 	switch(_p->type) {
 	case P_OTHER:     type = "P_OTHER";     break;
 	case P_OTHER:     type = "P_OTHER";     break;
@@ -440,24 +439,24 @@ static inline void print_param(param_t* _p)
 	default:          type = "UNKNOWN";     break;
 	default:          type = "UNKNOWN";     break;
 	}
 	}
 	
 	
-	printf("type: %s\n", type);
-	printf("name: \'%.*s\'\n", _p->name.len, _p->name.s);
-	printf("body: \'%.*s\'\n", _p->body.len, _p->body.s);
-	printf("len : %d\n", _p->len);
-	printf("---/param---\n");
+	fprintf(_o, "type: %s\n", type);
+	fprintf(_o, "name: \'%.*s\'\n", _p->name.len, _p->name.s);
+	fprintf(_o, "body: \'%.*s\'\n", _p->body.len, _p->body.s);
+	fprintf(_o, "len : %d\n", _p->len);
+	fprintf(_o, "---/param---\n");
 }
 }
 
 
 
 
 /*
 /*
  * Print linked list of parameters, just for debugging
  * Print linked list of parameters, just for debugging
  */
  */
-void print_params(param_t* _p)
+void print_params(FILE* _o, param_t* _p)
 {
 {
 	param_t* ptr;
 	param_t* ptr;
 	
 	
 	ptr = _p;
 	ptr = _p;
 	while(ptr) {
 	while(ptr) {
-		print_param(ptr);
+		print_param(_o, ptr);
 		ptr = ptr->next;
 		ptr = ptr->next;
 	}
 	}
 }
 }

+ 3 - 3
parser/parse_param.h

@@ -36,6 +36,8 @@
 #ifndef PARSE_PARAM_H
 #ifndef PARSE_PARAM_H
 #define PARSE_PARAM_H
 #define PARSE_PARAM_H
 
 
+#include <stdio.h>
+
 
 
 /*
 /*
  * Supported types of parameters
  * Supported types of parameters
@@ -129,12 +131,10 @@ void free_params(param_t* _p);
 void shm_free_params(param_t* _p);
 void shm_free_params(param_t* _p);
 
 
 
 
-
-
 /*
 /*
  * Print linked list of parameters, just for debugging
  * Print linked list of parameters, just for debugging
  */
  */
-void print_params(param_t* _p);
+void print_params(FILE* _o, param_t* _p);
 
 
 
 
 /*
 /*

+ 6 - 7
parser/parse_rr.c

@@ -27,7 +27,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  */
 
 
-#include <stdio.h>
 #include <string.h>
 #include <string.h>
 #include "parse_rr.h"
 #include "parse_rr.h"
 #include "../mem/mem.h"
 #include "../mem/mem.h"
@@ -181,20 +180,20 @@ void shm_free_rr(rr_t** _r)
 /*
 /*
  * Print list of RRs, just for debugging
  * Print list of RRs, just for debugging
  */
  */
-void print_rr(rr_t* _r)
+void print_rr(FILE* _o, rr_t* _r)
 {
 {
 	rr_t* ptr;
 	rr_t* ptr;
 
 
 	ptr = _r;
 	ptr = _r;
 
 
 	while(ptr) {
 	while(ptr) {
-		printf("---RR---\n");
-		print_nameaddr(&ptr->nameaddr);
-		printf("r2 : %p\n", ptr->r2);
+		fprintf(_o, "---RR---\n");
+		print_nameaddr(_o, &ptr->nameaddr);
+		fprintf(_o, "r2 : %p\n", ptr->r2);
 		if (ptr->params) {
 		if (ptr->params) {
-			print_params(ptr->params);
+			print_params(_o, ptr->params);
 		}
 		}
-		printf("---/RR---\n");
+		fprintf(_o, "---/RR---\n");
 		ptr = ptr->next;
 		ptr = ptr->next;
 	}
 	}
 }
 }

+ 2 - 1
parser/parse_rr.h

@@ -31,6 +31,7 @@
 #ifndef PARSE_RR_H
 #ifndef PARSE_RR_H
 #define PARSE_RR_H
 #define PARSE_RR_H
 
 
+#include <stdio.h>
 #include "msg_parser.h"
 #include "msg_parser.h"
 #include "parse_nameaddr.h"
 #include "parse_nameaddr.h"
 #include "parse_param.h"
 #include "parse_param.h"
@@ -72,7 +73,7 @@ void shm_free_rr(rr_t** _r);
 /*
 /*
  * Print list of rrs, just for debugging
  * Print list of rrs, just for debugging
  */
  */
-void print_rr(rr_t* _r);
+void print_rr(FILE* _o, rr_t* _r);
 
 
 
 
 /*
 /*