Browse code

- lots of fixes (alignments, casts, warnings) - it compiles cleanly now wit sun cc and intel icc. - slight api change for param_func_t (it takes a void* now instead of a param_func_param_t)

Andrei Pelinescu-Onciul authored on 03/12/2004 19:09:31
Showing 14 changed files
... ...
@@ -50,7 +50,7 @@ MAIN_NAME=ser
50 50
 VERSION = 0
51 51
 PATCHLEVEL = 8
52 52
 SUBLEVEL =   99
53
-EXTRAVERSION = -dev22
53
+EXTRAVERSION = -dev23
54 54
 
55 55
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
56 56
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -101,7 +101,7 @@ error:
101 101
 
102 102
 
103 103
 
104
-inline void free_lump_rpl(struct lump_rpl* lump)
104
+void free_lump_rpl(struct lump_rpl* lump)
105 105
 {
106 106
 	if (lump) {
107 107
 		if (!((lump->flags)&LUMP_RPL_NOFREE) && ((lump->flags)&LUMP_RPL_NODUP)
... ...
@@ -383,9 +383,9 @@ static inline int get_avps( FILE *fifo , db_key_t *keys, db_op_t *ops,
383 383
 		/* we have a new avp */
384 384
 		if (*nr<max_nr) {
385 385
 			/* parse the line key|op|val */
386
-			c = line.s;
386
+			c = (unsigned char*)line.s;
387 387
 			/* parse the key name */
388
-			for( key.s=c ; *c && (isalnum((int)*c)||*c=='_') ; c++ );
388
+			for( key.s=(char*)c ; *c && (isalnum((int)*c)||*c=='_') ; c++ );
389 389
 			if (!*c) goto parse_error;
390 390
 			key.len = (char*)c-key.s;
391 391
 			if (key.len==0) goto parse_error;
... ...
@@ -393,7 +393,7 @@ static inline int get_avps( FILE *fifo , db_key_t *keys, db_op_t *ops,
393 393
 			for( sp_found=0 ; *c && isspace((int)*c) ; c++,sp_found=1 );
394 394
 			if (!*c) goto parse_error;
395 395
 			/* parse the operator */
396
-			op.s = c;
396
+			op.s = (char*)c;
397 397
 			switch (*c) {
398 398
 				case '<':
399 399
 				case '>':
... ...
@@ -417,24 +417,24 @@ static inline int get_avps( FILE *fifo , db_key_t *keys, db_op_t *ops,
417 417
 			for( ; *c && isspace((int)*c) ; c++ );
418 418
 			if (!*c) goto parse_error;
419 419
 			/* get value */
420
-			val.s = c;
420
+			val.s = (char*)c;
421 421
 			val.len = line.len - ((char*)c-line.s);
422 422
 			if (val.len==0) goto parse_error;
423 423
 			if (parse_db_value( &val, &vals[*nr], &p_val)!=0)
424 424
 				goto error;
425 425
 			/* duplicate the avp -> make all null terminated */
426
-			c = (char*)pkg_malloc(key.len+op.len+2+(p_val?p_val->len+1:0));
426
+			c = pkg_malloc(key.len+op.len+2+(p_val?p_val->len+1:0));
427 427
 			if (c==0) {
428 428
 				semidouble_log("no more pkg memory");
429 429
 				goto error;
430 430
 			}
431 431
 			/*copy the key */
432
-			keys[*nr] = c;
432
+			keys[*nr] = (char*)c;
433 433
 			memcpy( c, key.s, key.len);
434 434
 			c[key.len] = 0;
435 435
 			c += key.len + 1;
436 436
 			/*copy the op */
437
-			ops[*nr] = c;
437
+			ops[*nr] = (char*)c;
438 438
 			memcpy( c, op.s, op.len);
439 439
 			c[op.len] = 0;
440 440
 			c += op.len + 1;
... ...
@@ -442,7 +442,7 @@ static inline int get_avps( FILE *fifo , db_key_t *keys, db_op_t *ops,
442 442
 			if (p_val) {
443 443
 				memcpy( c, p_val->s, p_val->len);
444 444
 				c[p_val->len] = 0;
445
-				p_val->s = c;
445
+				p_val->s = (char*)c;
446 446
 			}
447 447
 			/* done */
448 448
 			(*nr)++;
... ...
@@ -186,7 +186,8 @@ int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, in
186 186
  */
187 187
 char* print_dset(struct sip_msg* msg, int* len) 
188 188
 {
189
-	int cnt, i, qlen;
189
+	int cnt, i;
190
+	unsigned int qlen;
190 191
 	qvalue_t q;
191 192
 	str uri;
192 193
 	char* p, *qbuf;
... ...
@@ -757,7 +757,7 @@ static int parse_phostport(char* s, char** host, int* hlen, int* port,
757 757
 		return 0;
758 758
 	}
759 759
 	if (second){ /* 2 ':' found => check if valid */
760
-		if (parse_proto(s, first-s, proto)<0) goto error_proto;
760
+		if (parse_proto((unsigned char*)s, first-s, proto)<0) goto error_proto;
761 761
 		*port=strtol(second+1, &tmp, 10);
762 762
 		if ((tmp==0)||(*tmp)||(tmp==second+1)) goto error_port;
763 763
 		*host=first+1;
... ...
@@ -768,7 +768,7 @@ static int parse_phostport(char* s, char** host, int* hlen, int* port,
768 768
 	*port=strtol(first+1, &tmp, 10);
769 769
 	if ((tmp==0)||(*tmp)||(tmp==first+1)){
770 770
 		/* invalid port => it's proto:host */
771
-		if (parse_proto(s, first-s, proto)<0) goto error_proto;
771
+		if (parse_proto((unsigned char*)s, first-s, proto)<0) goto error_proto;
772 772
 		*port=0;
773 773
 		*host=first+1;
774 774
 		*hlen=(int)(p-*host);
... ...
@@ -115,8 +115,7 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
115 115
 						name, t->exports->name, t->path);
116 116
 
117 117
 					if (param->type&USE_FUNC_PARAM) {
118
-						n = ((param_func_t)(param->param_pointer))
119
-							(type, (param_func_param_t)(char*)val );
118
+						n = ((param_func_t)(param->param_pointer))(type, val );
120 119
 						if (n<0)
121 120
 							return -4;
122 121
 					} else {
... ...
@@ -182,7 +182,7 @@ static void print_tw_append( struct tw_append *append)
182 182
  * tw_append = name:element[;element]
183 183
  * element   = [title=]value 
184 184
  * value     = avp[avp_spec] | hdr[hdr_name] | msg[body] */
185
-int parse_tw_append( modparam_t type, param_func_param_t param_val)
185
+int parse_tw_append( modparam_t type, void* val)
186 186
 {
187 187
 	struct hdr_field hdr;
188 188
 	struct hdr_avp *last;
... ...
@@ -194,9 +194,9 @@ int parse_tw_append( modparam_t type, param_func_param_t param_val)
194 194
 	str foo;
195 195
 	int n;
196 196
 	
197
-	if (param_val.string==0 || param_val.string[0]==0)
197
+	if (val==0 || ((char*)val)[0]==0)
198 198
 		return 0;
199
-	s = param_val.string;
199
+	s = (char*)val;
200 200
 
201 201
 	/* start parsing - first the name */
202 202
 	while( *s && isspace((int)*s) )  s++;
... ...
@@ -405,11 +405,11 @@ int parse_tw_append( modparam_t type, param_func_param_t param_val)
405 405
 
406 406
 	print_tw_append( app );
407 407
 	/* free the old string */
408
-	pkg_free( param_val.string );
408
+	pkg_free(val);
409 409
 	return 0;
410 410
 parse_error:
411 411
 	LOG(L_ERR,"ERROR:tm:parse_tw_append: parse error in <%s> around "
412
-		"position %ld\n", param_val.string, (long)(s-param_val.string));
412
+		"position %ld\n", (char*)val, (long)(s-(char*)val));
413 413
 error:
414 414
 	return -1;
415 415
 }
... ...
@@ -580,6 +580,7 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
580 580
 	struct hdr_field *hdr;
581 581
 	struct usr_avp   *avp;
582 582
 	int_str          avp_val;
583
+	int_str          avp_name;
583 584
 	char  *end;
584 585
 	str   foo;
585 586
 	int   msg_parsed;
... ...
@@ -591,11 +592,11 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
591 591
 		if (ha->type==ELEM_IS_AVP) {
592 592
 			/* search for the AVP */
593 593
 			if (ha->sval.s) {
594
-				avp = search_first_avp( AVP_NAME_STR, (int_str)&ha->sval,
595
-					&avp_val);
594
+				avp_name.s=&ha->sval;
595
+				avp = search_first_avp( AVP_NAME_STR, avp_name, &avp_val);
596 596
 			} else {
597
-				avp = search_first_avp( 0, (int_str)ha->ival,
598
-					&avp_val);
597
+				avp_name.n=ha->ival;
598
+				avp = search_first_avp( 0, avp_name, &avp_val);
599 599
 			}
600 600
 			if (avp) {
601 601
 				if (avp->flags&AVP_VAL_STR) {
... ...
@@ -42,7 +42,7 @@ extern int tm_unix_tx_timeout;
42 42
 
43 43
 int fixup_t_write( void** param, int param_no);
44 44
 
45
-int parse_tw_append( modparam_t type, param_func_param_t param_val);
45
+int parse_tw_append( modparam_t type, void* val);
46 46
 
47 47
 int init_twrite_lines();
48 48
 
... ...
@@ -347,7 +347,7 @@ void init_avp_params(void)
347 347
 /*
348 348
  * Get the FR_{INV}_TIMER from corresponding AVP
349 349
  */
350
-int avp2timer(int* timer, int_str param)
350
+int avp2timer(unsigned int* timer, int_str param)
351 351
 {
352 352
 	struct usr_avp *avp;
353 353
 	int_str val_istr;
... ...
@@ -115,12 +115,12 @@ int send_pr_buffer( struct retr_buf *rb, void *buf, int len);
115 115
 /*
116 116
  * Get the FR_{INV}_TIMER from corresponding AVP
117 117
  */
118
-int avp2timer(int* timer, int_str param);
118
+int avp2timer(unsigned int* timer, int_str param);
119 119
 
120 120
 
121 121
 static void inline _set_fr_retr( struct retr_buf *rb, int retr )
122 122
 {
123
-	int timer;
123
+	unsigned int timer;
124 124
 
125 125
 	if (retr) {
126 126
 		rb->retr_list=RT_T1_TO_1;
... ...
@@ -84,7 +84,7 @@ void destroy_tmcb_lists()
84 84
 }
85 85
 
86 86
 
87
-inline int insert_tmcb(struct tmcb_head_list *cb_list, int types,
87
+static inline int insert_tmcb(struct tmcb_head_list *cb_list, int types,
88 88
 									transaction_cb f, void *param )
89 89
 {
90 90
 	struct tm_callback *cbp;
... ...
@@ -1208,7 +1208,7 @@ int reply_received( struct sip_msg  *p_msg )
1208 1208
 	struct cell *t;
1209 1209
 	str next_hop;
1210 1210
 	struct usr_avp **backup_list;
1211
-	int timer;
1211
+	unsigned int timer;
1212 1212
 
1213 1213
 	/* make sure we know the associated transaction ... */
1214 1214
 	if (t_check( p_msg  , &branch )==-1)
... ...
@@ -36,6 +36,8 @@
36 36
  *  2004-03-12  extra flag USE_FUNC_PARAM added to modparam type -
37 37
  *              instead of copying the param value, a func is called (bogdan)
38 38
  *  2004-09-19  switched to version.h for the module versions checks (andrei)
39
+ *  2004-12-03  changed param_func_t to (modparam_t, void*), killed
40
+ *               param_func_param_t   (andrei)
39 41
  */
40 42
 
41 43
 
... ...
@@ -55,19 +57,14 @@ typedef int (*init_function)(void);
55 55
 typedef int (*child_init_function)(int rank);
56 56
 
57 57
 
58
-#define STR_PARAM        (1<<0)  /* String parameter type */
59
-#define INT_PARAM        (1<<1)  /* Integer parameter type */
60
-#define USE_FUNC_PARAM   (1<<(8*sizeof(int)-1))
58
+#define STR_PARAM        (1U<<0)  /* String parameter type */
59
+#define INT_PARAM        (1U<<1)  /* Integer parameter type */
60
+#define USE_FUNC_PARAM   (1U<<(8*sizeof(int)-1))
61 61
 #define PARAM_TYPE_MASK(_x)   ((_x)&(~USE_FUNC_PARAM))
62 62
 
63
-typedef int modparam_t;
63
+typedef unsigned int modparam_t;
64 64
 
65
-typedef union {
66
-	int integer;
67
-	char *string;
68
-} param_func_param_t;
69
-
70
-typedef int (*param_func_t)( modparam_t type, param_func_param_t param_val);
65
+typedef int (*param_func_t)( modparam_t type, void* val);
71 66
 
72 67
 #define REQUEST_ROUTE 1  /* Function can be used in request route blocks */
73 68
 #define FAILURE_ROUTE 2  /* Function can be used in reply route blocks */
... ...
@@ -82,7 +82,7 @@ static struct unixsock_cmd* cmd_list = 0;
82 82
 static char reply_buf[UNIXSOCK_BUF_SIZE];
83 83
 static str reply_pos;
84 84
 static struct sockaddr_un reply_addr;
85
-static int reply_addr_len;
85
+static unsigned int reply_addr_len;
86 86
 
87 87
 static time_t up_since;
88 88
 static char up_since_ctime[MAX_CTIME_LEN];