Browse code

Small clean-ups

Jan Janak authored on 31/03/2003 09:37:23
Showing 3 changed files
... ...
@@ -64,19 +64,27 @@ float def_q;                /* default_q converted to float in mod_init */
64 64
  */
65 65
 int (*sl_reply)(struct sip_msg* _m, char* _s1, char* _s2);
66 66
 
67
-static cmd_export_t cmds[]={
67
+
68
+/*
69
+ * Exported functions
70
+ */
71
+static cmd_export_t cmds[] = {
68 72
 	{"save",         save,         1, domain_fixup, REQUEST_ROUTE},
69 73
 	{"save_noreply", save_noreply, 1, domain_fixup, REQUEST_ROUTE},
70 74
 	{"lookup",       lookup,       1, domain_fixup, REQUEST_ROUTE},
71 75
 	{0,0,0,0,0}
72 76
 };
73 77
 
74
-static param_export_t params[]={
75
-	{"default_expires",  INT_PARAM, &default_expires},
76
-	{"default_q",        INT_PARAM, &default_q},
77
-	{"append_branches",  INT_PARAM, &append_branches},
78
-	{"use_domain",       INT_PARAM, &use_domain},
79
-	{"case_sensitive",   INT_PARAM, &case_sensitive},
78
+
79
+/*
80
+ * Exported parameters
81
+ */
82
+static param_export_t params[] = {
83
+	{"default_expires", INT_PARAM, &default_expires},
84
+	{"default_q",       INT_PARAM, &default_q      },
85
+	{"append_branches", INT_PARAM, &append_branches},
86
+	{"use_domain",      INT_PARAM, &use_domain     },
87
+	{"case_sensitive",  INT_PARAM, &case_sensitive },
80 88
 	{0,0,0}
81 89
 };
82 90
 
... ...
@@ -101,7 +109,7 @@ struct module_exports exports = {
101 101
  */
102 102
 static int mod_init(void)
103 103
 {
104
-	printf( "Initializing registrar module\n");
104
+	DBG("registrar - initializing\n");
105 105
 
106 106
              /*
107 107
               * We will need sl_send_reply from stateless
... ...
@@ -109,12 +117,12 @@ static int mod_init(void)
109 109
 	      */
110 110
         sl_reply = find_export("sl_send_reply", 2, 0);
111 111
 	if (!sl_reply) {
112
-		LOG(L_ERR, "This module requires sl module\n");
112
+		LOG(L_ERR, "registrar: This module requires sl module\n");
113 113
 		return -1;
114 114
 	}
115 115
 	
116 116
 	if (bind_usrloc() < 0) {
117
-		LOG(L_ERR, "Can't find usrloc module\n");
117
+		LOG(L_ERR, "registar: Can't find usrloc module\n");
118 118
 		return -1;
119 119
 	}
120 120
 
... ...
@@ -30,7 +30,7 @@
30 30
  * ----------
31 31
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
32 32
  * 2003-02-28 scratcpad compatibility abandoned (jiri)
33
- * 2003-03-21  save_noreply added, provided by Maxim Sobolev <sobomax@portaone.com> (janakj)
33
+ * 2003-03-21  save_noreply added, patch provided by Maxim Sobolev <sobomax@portaone.com> (janakj)
34 34
  */
35 35
 
36 36
 
... ...
@@ -153,7 +153,7 @@ static inline int insert(struct sip_msg* _m, contact_t* _c, udomain_t* _d, str*
153 153
 		trim_trailing(&callid);
154 154
 		
155 155
 		     /* Get CSeq number of the message */
156
-		if (str2int(&(((struct cseq_body*)_m->cseq->parsed)->number), &cseq) < 0) {
156
+		if (str2int(&get_cseq(_m)->number, &cseq) < 0) {
157 157
 			rerrno = R_INV_CSEQ;
158 158
 			LOG(L_ERR, "insert(): Error while converting cseq number\n");
159 159
 			ul_delete_urecord(_d, _a);
... ...
@@ -320,7 +320,7 @@ static inline int contacts(struct sip_msg* _m, contact_t* _c, udomain_t* _d, str
320 320
 /*
321 321
  * Process REGISTER request and save it's contacts
322 322
  */
323
-int save_real(struct sip_msg* _m, char* _t, char* _s, int doreply)
323
+static inline int save_real(struct sip_msg* _m, udomain_t* _t, char* _s, int doreply)
324 324
 {
325 325
 	contact_t* c;
326 326
 	int st;
... ...
@@ -346,12 +346,12 @@ int save_real(struct sip_msg* _m, char* _t, char* _s, int doreply)
346 346
 
347 347
 	if (c == 0) {
348 348
 		if (st) {
349
-			if (star((udomain_t*)_t, &aor) < 0) goto error;
349
+			if (star(_t, &aor) < 0) goto error;
350 350
 		} else {
351
-			if (no_contacts((udomain_t*)_t, &aor) < 0) goto error;
351
+			if (no_contacts(_t, &aor) < 0) goto error;
352 352
 		}
353 353
 	} else {
354
-		if (contacts(_m, c, (udomain_t*)_t, &aor) < 0) goto error;
354
+		if (contacts(_m, c, _t, &aor) < 0) goto error;
355 355
 	}
356 356
 
357 357
 	if (doreply && (send_reply(_m) < 0)) return -1;
... ...
@@ -368,7 +368,7 @@ int save_real(struct sip_msg* _m, char* _t, char* _s, int doreply)
368 368
  */
369 369
 int save(struct sip_msg* _m, char* _t, char* _s)
370 370
 {
371
-	return save_real(_m, _t, _s, 1);
371
+	return save_real(_m, (udomain_t*)_t, _s, 1);
372 372
 }
373 373
 
374 374
 
... ...
@@ -377,5 +377,5 @@ int save(struct sip_msg* _m, char* _t, char* _s)
377 377
  */
378 378
 int save_noreply(struct sip_msg* _m, char* _t, char* _s)
379 379
 {
380
-	return save_real(_m, _t, _s, 0);
380
+	return save_real(_m, (udomain_t*)_t, _s, 0);
381 381
 }
... ...
@@ -221,7 +221,7 @@ contact_t* get_next_contact(contact_t* _c)
221 221
  */
222 222
 int calc_contact_expires(struct sip_msg* _m, param_t* _ep, int* _e)
223 223
 {
224
-	if (!_ep || (_ep->body.len == 0)) {
224
+	if (!_ep || !_ep->body.len) {
225 225
 		*_e = get_expires_hf(_m);
226 226
 	} else {
227 227
 		if (str2int(&_ep->body, _e) < 0) {