Browse code

*** empty log message ***

Jan Janak authored on 27/08/2002 13:31:25
Showing 10 changed files
... ...
@@ -144,18 +144,18 @@ void free_all_udomains(void)
144 144
 /*
145 145
  * Just for debugging
146 146
  */
147
-void print_all_udomains(void)
147
+void print_all_udomains(FILE* _f)
148 148
 {
149 149
 	dlist_t* ptr;
150 150
 	
151 151
 	ptr = root;
152 152
 
153
-	printf("===Domain list===\n");
153
+	fprintf(_f, "===Domain list===\n");
154 154
 	while(ptr) {
155
-		print_udomain(ptr->d);
155
+		print_udomain(_f, ptr->d);
156 156
 		ptr = ptr->next;
157 157
 	}
158
-	printf("===/Domain list===\n");
158
+	fprintf(_f, "===/Domain list===\n");
159 159
 }
160 160
 
161 161
 
... ...
@@ -7,6 +7,7 @@
7 7
 #ifndef DLIST_H
8 8
 #define DLIST_H
9 9
 
10
+#include <stdio.h>
10 11
 #include "udomain.h"
11 12
 #include "../../str.h"
12 13
 
... ...
@@ -41,7 +42,7 @@ void free_all_udomains(void);
41 42
 /*
42 43
  * Just for debugging
43 44
  */
44
-void print_all_udomains(void);
45
+void print_all_udomains(FILE* _f);
45 46
 
46 47
 
47 48
 /*
... ...
@@ -7,7 +7,6 @@
7 7
 
8 8
 #include "ucontact.h"
9 9
 #include <string.h>             /* memcpy */
10
-#include <stdio.h>              /* printf */
11 10
 #include "../../mem/shm_mem.h"
12 11
 #include "../../dprint.h"
13 12
 #include "../../db/db.h"
... ...
@@ -75,7 +74,7 @@ void free_ucontact(ucontact_t* _c)
75 74
 /*
76 75
  * Print contact, for debugging purposes only
77 76
  */
78
-void print_ucontact(ucontact_t* _c)
77
+void print_ucontact(FILE* _f, ucontact_t* _c)
79 78
 {
80 79
 	time_t t = time(0);
81 80
 	char* st;
... ...
@@ -87,18 +86,18 @@ void print_ucontact(ucontact_t* _c)
87 86
 	default:       st = "CS_UNKNOWN"; break;
88 87
 	}
89 88
 
90
-	printf("~~~Contact(%p)~~~\n", _c);
91
-	printf("domain : \'%.*s\'\n", _c->domain->len, _c->domain->s);
92
-	printf("aor    : \'%.*s\'\n", _c->aor->len, _c->aor->s);
93
-	printf("Contact: \'%.*s\'\n", _c->c.len, _c->c.s);
94
-	printf("Expires: %lu\n", (unsigned int)(_c->expires) - t);
95
-	printf("q      : %10.2f\n", _c->q);
96
-	printf("Call-ID: \'%.*s\'\n", _c->callid.len, _c->callid.s);
97
-	printf("CSeq   : %d\n", _c->cseq);
98
-	printf("State  : %s\n", st);
99
-	printf("next   : %p\n", _c->next);
100
-	printf("prev   : %p\n", _c->prev);
101
-	printf("~~~/Contact~~~~\n");
89
+	fprintf(_f, "~~~Contact(%p)~~~\n", _c);
90
+	fprintf(_f, "domain : \'%.*s\'\n", _c->domain->len, _c->domain->s);
91
+	fprintf(_f, "aor    : \'%.*s\'\n", _c->aor->len, _c->aor->s);
92
+	fprintf(_f, "Contact: \'%.*s\'\n", _c->c.len, _c->c.s);
93
+	fprintf(_f, "Expires: %lu\n", (unsigned int)(_c->expires) - t);
94
+	fprintf(_f, "q      : %10.2f\n", _c->q);
95
+	fprintf(_f, "Call-ID: \'%.*s\'\n", _c->callid.len, _c->callid.s);
96
+	fprintf(_f, "CSeq   : %d\n", _c->cseq);
97
+	fprintf(_f, "State  : %s\n", st);
98
+	fprintf(_f, "next   : %p\n", _c->next);
99
+	fprintf(_f, "prev   : %p\n", _c->prev);
100
+	fprintf(_f, "~~~/Contact~~~~\n");
102 101
 }
103 102
 
104 103
 
... ...
@@ -8,6 +8,7 @@
8 8
 #define UCONTACT_H
9 9
 
10 10
 
11
+#include <stdio.h>
11 12
 #include <time.h>
12 13
 #include "../../str.h"
13 14
 
... ...
@@ -49,7 +50,7 @@ void free_ucontact(ucontact_t* _c);
49 50
 /*
50 51
  * Print contact, for debugging purposes only
51 52
  */
52
-void print_ucontact(ucontact_t* _c);
53
+void print_ucontact(FILE* _f, ucontact_t* _c);
53 54
 
54 55
 
55 56
 /*
... ...
@@ -3,7 +3,6 @@
3 3
  */
4 4
 
5 5
 #include "udomain.h"
6
-#include <stdio.h>
7 6
 #include <string.h>
8 7
 #include "../../mem/shm_mem.h"
9 8
 #include "../../dprint.h"
... ...
@@ -141,31 +140,31 @@ void free_udomain(udomain_t* _d)
141 140
 /*
142 141
  * Just for debugging
143 142
  */
144
-void print_udomain(udomain_t* _d)
143
+void print_udomain(FILE* _f, udomain_t* _d)
145 144
 {
146 145
 	struct urecord* r;
147
-	printf("---Domain---\n");
148
-	printf("name : \'%.*s\'\n", _d->name->len, _d->name->s);
149
-	printf("size : %d\n", _d->size);
150
-	printf("table: %p\n", _d->table);
151
-	printf("d_ll {\n");
152
-	printf("    n    : %d\n", _d->d_ll.n);
153
-	printf("    first: %p\n", _d->d_ll.first);
154
-	printf("    last : %p\n", _d->d_ll.last);
155
-	printf("}\n");
156
-	printf("lock : %d\n", _d->lock);
146
+	fprintf(_f, "---Domain---\n");
147
+	fprintf(_f, "name : \'%.*s\'\n", _d->name->len, _d->name->s);
148
+	fprintf(_f, "size : %d\n", _d->size);
149
+	fprintf(_f, "table: %p\n", _d->table);
150
+	fprintf(_f, "d_ll {\n");
151
+	fprintf(_f, "    n    : %d\n", _d->d_ll.n);
152
+	fprintf(_f, "    first: %p\n", _d->d_ll.first);
153
+	fprintf(_f, "    last : %p\n", _d->d_ll.last);
154
+	fprintf(_f, "}\n");
155
+	fprintf(_f, "lock : %d\n", _d->lock);
157 156
 	if (_d->d_ll.n > 0) {
158
-		printf("\n");
157
+		fprintf(_f, "\n");
159 158
 		r = _d->d_ll.first;
160 159
 		while(r) {
161
-			print_urecord(r);
160
+			print_urecord(_f, r);
162 161
 			r = r->d_ll.next;
163 162
 		}
164 163
 
165 164
 
166
-		printf("\n");
165
+		fprintf(_f, "\n");
167 166
 	}
168
-	printf("---/Domain---\n");
167
+	fprintf(_f, "---/Domain---\n");
169 168
 }
170 169
 
171 170
 
... ...
@@ -8,6 +8,7 @@
8 8
 #define UDOMAIN_H
9 9
 
10 10
 
11
+#include <stdio.h>
11 12
 #include "../../fastlock.h"
12 13
 #include "../../str.h"
13 14
 #include "urecord.h"
... ...
@@ -57,7 +58,7 @@ void free_udomain(udomain_t* _d);
57 58
 /*
58 59
  * Just for debugging
59 60
  */
60
-void print_udomain(udomain_t* _d);
61
+void print_udomain(FILE* _f, udomain_t* _d);
61 62
 
62 63
 
63 64
 /*
... ...
@@ -47,6 +47,28 @@ int static ul_stats_cmd( FILE *pipe, char *response_file )
47 47
 	return 1;
48 48
 }
49 49
 
50
+
51
+int static ul_dump(FILE* pipe, char* response_file)
52
+{
53
+	FILE* reply_file;
54
+
55
+	reply_file=open_reply_pipe(response_file);
56
+	if (reply_file==0) {
57
+		LOG(L_ERR, "ERROR: ul_dump: file not opened\n");
58
+		return -1;
59
+	}
60
+	print_all_udomains(reply_file);
61
+	fclose(reply_file);
62
+	return 1;
63
+}
64
+
65
+int static ul_flush(FILE* pipe, char* response_file)
66
+{
67
+	timer_handler();
68
+	return 1;
69
+}
70
+
71
+
50 72
 int static ul_rm( FILE *pipe, char *response_file )
51 73
 {
52 74
 	char table[MAX_TABLE];
... ...
@@ -119,5 +141,13 @@ int init_ul_fifo( void )
119 141
 		LOG(L_CRIT, "cannot register ul_rm\n");
120 142
 		return -1;
121 143
 	}
144
+	if (register_fifo_cmd(ul_dump, UL_DUMP, 0)<0) {
145
+		LOG(L_CRIT, "cannot register ul_dump\n");
146
+		return -1;
147
+	}
148
+	if (register_fifo_cmd(ul_flush, UL_FLUSH, 0)<0) {
149
+		LOG(L_CRIT, "cannot register ul_flush\n");
150
+		return -1;
151
+	}
122 152
 	return 1;
123 153
 }
... ...
@@ -11,6 +11,8 @@
11 11
 /* FIFO commands */
12 12
 #define UL_STATS	"ul_stats"
13 13
 #define UL_RM		"ul_rm"
14
+#define UL_DUMP         "ul_dump"
15
+#define UL_FLUSH        "ul_flush"
14 16
 
15 17
 /* buffer dimensions */
16 18
 #define MAX_TABLE 128
... ...
@@ -6,7 +6,6 @@
6 6
 
7 7
 
8 8
 #include "urecord.h"
9
-#include <stdio.h>
10 9
 #include <string.h>
11 10
 #include "../../mem/shm_mem.h"
12 11
 #include "../../dprint.h"
... ...
@@ -63,23 +62,23 @@ void free_urecord(urecord_t* _r)
63 62
 /*
64 63
  * Print a record
65 64
  */
66
-void print_urecord(urecord_t* _r)
65
+void print_urecord(FILE* _f, urecord_t* _r)
67 66
 {
68 67
 	ucontact_t* ptr;
69 68
 
70
-	printf("...Record(%p)...\n", _r);
71
-	printf("domain: \'%.*s\'\n", _r->domain->len, _r->domain->s);
72
-	printf("aor   : \'%.*s\'\n", _r->aor.len, _r->aor.s);
69
+	fprintf(_f, "...Record(%p)...\n", _r);
70
+	fprintf(_f, "domain: \'%.*s\'\n", _r->domain->len, _r->domain->s);
71
+	fprintf(_f, "aor   : \'%.*s\'\n", _r->aor.len, _r->aor.s);
73 72
 	
74 73
 	if (_r->contacts) {
75 74
 		ptr = _r->contacts;
76 75
 		while(ptr) {
77
-			print_ucontact(ptr);
76
+			print_ucontact(_f, ptr);
78 77
 			ptr = ptr->next;
79 78
 		}
80 79
 	}
81 80
 
82
-	printf(".../Record...\n");
81
+	fprintf(_f, ".../Record...\n");
83 82
 }
84 83
 
85 84
 
... ...
@@ -8,6 +8,7 @@
8 8
 #define URECORD_H
9 9
 
10 10
 
11
+#include <stdio.h>
11 12
 #include <time.h>
12 13
 #include "hslot.h"
13 14
 #include "../../str.h"
... ...
@@ -48,7 +49,7 @@ void free_urecord(urecord_t* _r);
48 49
 /*
49 50
  * Print an element, for debugging purposes only
50 51
  */
51
-void print_urecord(urecord_t* _r);
52
+void print_urecord(FILE* _f, urecord_t* _r);
52 53
 
53 54
 
54 55
 /*