Browse code

- sun cc compile fixes (all the files not mentioned explicitly) - fixed a bug in build_res_buf_with_body_from_sip_req (bad len computations when via was not crlf terminated, e.g only lf) - Makefile.def: sun cc modules compilations options updated (it seems tm uses too many symbols for the default small memory model) - lock_ops.h: lock set support added also for PTHREAD_MUTEX & POSIX_SEM - route.c: updated to the new module exports format - sr_module.[hc]: changed module exports interface: added struct cmd_export and param_export, updated find_export, find_export_param, find_module

Andrei Pelinescu-Onciul authored on 10/03/2003 22:24:14
Showing 16 changed files
... ...
@@ -2,6 +2,7 @@
2 2
 #
3 3
 # makefile defs (CC, LD,a.s.o)
4 4
 #
5
+#
5 6
 # History:
6 7
 # --------
7 8
 #              created by andrei
... ...
@@ -9,13 +10,15 @@
9 9
 #               by Maxim Sobolev <sobomax@FreeBSD.org>
10 10
 #  2003-02-25  added -DDISABLE_NAGLE
11 11
 #  2003-03-02  added -DDIGEST_DOMAIN (janakj)
12
+#  2003-03-10  added -xcode=pic32 for module compilation w/ sun cc
13
+#              (too many symbols for pic13)  (andrei)
12 14
 
13 15
 
14 16
 #version number
15 17
 VERSION = 0
16 18
 PATCHLEVEL = 8
17 19
 SUBLEVEL =   11
18
-EXTRAVERSION = pre6-tcp10-lck
20
+EXTRAVERSION = pre7
19 21
 
20 22
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
21 23
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -195,7 +198,10 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
195 195
 	 #-DNO_LOG
196 196
 
197 197
 #PROFILE=  -pg #set this if you want profiling
198
-mode = debug
198
+
199
+# WARNING: do not add mode=debug or mode=release anymore in the Makefile,
200
+# use make mode=debug all instead. Anyway no by default ser is  compiled w/ 
201
+# debugging symbols in all cases (-g). --andrei
199 202
 ifeq ($(mode),)
200 203
 	mode = release
201 204
 endif
... ...
@@ -366,7 +372,7 @@ endif			# CC_SHORTVER, 3.0
366 366
 
367 367
 else		# CC_NAME, gcc
368 368
 ifeq		($(CC_NAME), icc)
369
-			CFLAGS=-O3  -ipo -ipo_obj -unroll  $(PROFILE) \
369
+			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
370 370
 					 -tpp6 -xK  #-openmp  #optimize for PIII 
371 371
 				# -prefetch doesn't seem to work
372 372
 				#( ty to inline acroos files, unroll loops,prefetch,
... ...
@@ -424,7 +430,7 @@ endif			#CC_SHORTVER, 3.0
424 424
 
425 425
 else		#CC_NAME, gcc
426 426
 ifeq		($(CC_NAME), suncc)
427
-			CFLAGS+=-xO5 -fast -native -xarch=v8plusa -xCC \
427
+			CFLAGS+=-g -xO5 -fast -native -xarch=v8plusa -xCC \
428 428
 					-xc99 # C99 support
429 429
 			# -Dinline="" # add this if cc < 5.3 (define inline as null)
430 430
 else
... ...
@@ -537,7 +543,7 @@ ifeq	($(CC_NAME), icc)
537 537
 MOD_CFLAGS=-Kpic $(CFLAGS)
538 538
 endif
539 539
 ifeq	($(CC_NAME), suncc)
540
-MOD_CFLAGS=-Kpic  $(CFLAGS)
540
+MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
541 541
 endif
542 542
 
543 543
 ifeq ($(LEX),)
... ...
@@ -93,8 +93,8 @@ struct socket_info{
93 93
 struct receive_info{
94 94
 	struct ip_addr src_ip;
95 95
 	struct ip_addr dst_ip;
96
-	short src_port;
97
-	short dst_port;
96
+	unsigned short src_port;
97
+	unsigned short dst_port;
98 98
 	int proto;
99 99
 	int proto_reserved1; /* tcp stores the connection id here */
100 100
 	int proto_reserved2;
... ...
@@ -37,6 +37,8 @@
37 37
  *  2003-03-06  removed *_alloc,*_dealloc & moved them to lock_alloc.h
38 38
  *              renamed locking.h to lock_ops.h (all this to solve
39 39
  *              the locking.h<->shm_mem.h interdependency) (andrei)
40
+ *  2003-03-10  lock set support added also for PTHREAD_MUTEX & POSIX_SEM
41
+ *               (andrei)
40 42
  *
41 43
 Implements:
42 44
 
... ...
@@ -66,11 +68,6 @@ WARNING: signals are not treated! (some locks are "awakened" by the signals)
66 66
 
67 67
 typedef fl_lock_t gen_lock_t;
68 68
 
69
-struct lock_set_t_ {
70
-	long size;
71
-	gen_lock_t* locks;
72
-}; /* must be  aligned (32 bits or 64 depending on the arch)*/
73
-typedef struct lock_set_t_ lock_set_t;
74 69
 
75 70
 #define lock_destroy(lock) /* do nothing */ 
76 71
 
... ...
@@ -83,21 +80,6 @@ inline static gen_lock_t* lock_init(gen_lock_t* lock)
83 83
 #define lock_get(lock) get_lock(lock)
84 84
 #define lock_release(lock) release_lock(lock)
85 85
 
86
-/* lock sets */
87
-
88
-#define lock_set_destroy(lock_set) /* do nothing */
89
-
90
-inline static lock_set_t* lock_set_init(lock_set_t* s)
91
-{
92
-	int r;
93
-	for (r=0; r<s->size; r++) lock_init(&s->locks[r]);
94
-	return s;
95
-}
96
-
97
-/* WARNING: no boundary checks!*/
98
-#define lock_set_get(set, i) lock_get(&set->locks[i])
99
-#define lock_set_release(set, i) lock_release(&set->locks[i])
100
-
101 86
 #elif defined USE_PTHREAD_MUTEX
102 87
 #include <pthread.h>
103 88
 
... ...
@@ -152,11 +134,6 @@ inline static gen_lock_t* lock_init(gen_lock_t* lock)
152 152
 
153 153
 typedef int gen_lock_t;
154 154
 
155
-struct lock_set_t_ {
156
-	int size;
157
-	int semid;
158
-};
159
-typedef struct lock_set_t_ lock_set_t;
160 155
 
161 156
 
162 157
 
... ...
@@ -200,8 +177,45 @@ inline static void lock_release(gen_lock_t* lock)
200 200
 	semop(*lock, &sop, 1);
201 201
 }
202 202
 
203
+
204
+#else
205
+#error "no locking method selected"
206
+#endif
207
+
208
+
203 209
 /* lock sets */
204 210
 
211
+#if defined(FAST_LOCK) || defined(USE_PTHREAD_MUTEX) || defined(USE_POSIX_SEM)
212
+
213
+struct lock_set_t_ {
214
+	long size;
215
+	gen_lock_t* locks;
216
+}; /* must be  aligned (32 bits or 64 depending on the arch)*/
217
+typedef struct lock_set_t_ lock_set_t;
218
+
219
+
220
+#define lock_set_destroy(lock_set) /* do nothing */
221
+
222
+inline static lock_set_t* lock_set_init(lock_set_t* s)
223
+{
224
+	int r;
225
+	for (r=0; r<s->size; r++) if (lock_init(&s->locks[r])==0) return 0;
226
+	return s;
227
+}
228
+
229
+/* WARNING: no boundary checks!*/
230
+#define lock_set_get(set, i) lock_get(&set->locks[i])
231
+#define lock_set_release(set, i) lock_release(&set->locks[i])
232
+
233
+#elif defined(USE_SYSV_SEM)
234
+
235
+struct lock_set_t_ {
236
+	int size;
237
+	int semid;
238
+};
239
+
240
+
241
+typedef struct lock_set_t_ lock_set_t;
205 242
 inline static lock_set_t* lock_set_init(lock_set_t* s)
206 243
 {
207 244
 	union semun su;
... ...
@@ -247,9 +261,8 @@ inline static void lock_set_release(lock_set_t* s, int n)
247 247
 	sop.sem_flg=0;
248 248
 	semop(s->semid, &sop, 1);
249 249
 }
250
-
251
-#else
252
-#error "no locking method selected"
250
+#else 
251
+#error "no lock set method selected"
253 252
 #endif
254 253
 
255 254
 
... ...
@@ -26,6 +26,12 @@
26 26
  * along with this program; if not, write to the Free Software 
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 28
  */
29
+/*
30
+ * History:
31
+ * --------
32
+ *  2003-03-10  __FUNCTION__ is a gcc-ism, defined it to "" for sun cc
33
+ *               (andrei)
34
+ */
29 35
 
30 36
 
31 37
 
... ...
@@ -50,6 +56,9 @@
50 50
 
51 51
 
52 52
 #	ifdef DBG_QM_MALLOC
53
+#ifdef __SUNPRO_C
54
+		#define __FUNCTION__ ""  /* gcc specific */
55
+#endif
53 56
 #		ifdef VQ_MALLOC
54 57
 #			define pkg_malloc(s) vqm_malloc(mem_block, (s),__FILE__, \
55 58
 				__FUNCTION__, __LINE__)
... ...
@@ -88,6 +88,11 @@ void shm_mem_destroy();
88 88
 
89 89
 #ifdef DBG_QM_MALLOC
90 90
 
91
+#ifdef __SUNPRO_C
92
+		#define __FUNCTION__ ""  /* gcc specific */
93
+#endif
94
+
95
+
91 96
 #define shm_malloc_unsafe(_size ) \
92 97
 	MY_MALLOC(shm_block, (_size), __FILE__, __FUNCTION__, __LINE__ )
93 98
 
... ...
@@ -38,7 +38,7 @@
38 38
  *             modified via_builder params (andrei)
39 39
  * 2003-01-27 more rport fixes (make use of new via_param->start)  (andrei)
40 40
  * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
41
- * 2003-01-29 scrathcpad removed (jiri)
41
+ * 2003-01-29 scratchpad removed (jiri)
42 42
  *
43 43
  */
44 44
 
... ...
@@ -220,7 +220,7 @@ char* received_builder(struct sip_msg *msg, unsigned int *received_len)
220 220
 	}
221 221
 	
222 222
 	memcpy(buf+RECEIVED_LEN+extra_len, tmp, tmp_len);
223
-	buf[len+1]=0; /*null terminate it */
223
+	buf[len]=0; /*null terminate it */
224 224
 
225 225
 	*received_len = len;
226 226
 	return buf;
... ...
@@ -237,8 +237,8 @@ char* rport_builder(struct sip_msg *msg, unsigned int *rport_len)
237 237
 	
238 238
 	tmp_len=0;
239 239
 	tmp=int2str(ntohs(msg->rcv.src_port), &tmp_len);
240
-	len=RPORT_LEN+tmp_len; /* space for null term */
241
-	buf=pkg_malloc(sizeof(char)*(len+1));
240
+	len=RPORT_LEN+tmp_len;
241
+	buf=pkg_malloc(sizeof(char)*(len+1));/* space for null term */
242 242
 	if (buf==0){
243 243
 		ser_error=E_OUT_OF_MEM;
244 244
 		LOG(L_ERR, "ERROR: rport_builder: out of memory\n");
... ...
@@ -246,7 +246,7 @@ char* rport_builder(struct sip_msg *msg, unsigned int *rport_len)
246 246
 	}
247 247
 	memcpy(buf, RPORT, RPORT_LEN);
248 248
 	memcpy(buf+RPORT_LEN, tmp, tmp_len);
249
-	buf[len+1]=0; /*null terminate it*/
249
+	buf[len]=0; /*null terminate it*/
250 250
 	
251 251
 	*rport_len=len;
252 252
 	return buf;
... ...
@@ -269,8 +269,8 @@ char* id_builder(struct sip_msg* msg, unsigned int *id_len)
269 269
 		return 0;
270 270
 	}
271 271
 	value_len=p-&revhex[0];
272
-	len=ID_PARAM_LEN+value_len; /* place for ending \0 */
273
-	buf=pkg_malloc(sizeof(char)*(len+1));
272
+	len=ID_PARAM_LEN+value_len; 
273
+	buf=pkg_malloc(sizeof(char)*(len+1));/* place for ending \0 */
274 274
 	if (buf==0){
275 275
 		ser_error=E_OUT_OF_MEM;
276 276
 		LOG(L_ERR, "ERROR: rport_builder: out of memory\n");
... ...
@@ -278,7 +278,7 @@ char* id_builder(struct sip_msg* msg, unsigned int *id_len)
278 278
 	}
279 279
 	memcpy(buf, ID_PARAM, ID_PARAM_LEN);
280 280
 	memcpy(buf+ID_PARAM_LEN, revhex, value_len);
281
-	buf[len+1]=0; /* null terminate it */
281
+	buf[len]=0; /* null terminate it */
282 282
 	*id_len=len;
283 283
 	return buf;
284 284
 }
... ...
@@ -316,7 +316,7 @@ char* clen_builder(struct sip_msg* msg, unsigned int *clen_len)
316 316
 	memcpy(buf, CONTENT_LENGTH, CONTENT_LENGTH_LEN);
317 317
 	memcpy(buf+CONTENT_LENGTH_LEN, value_s, value_len);
318 318
 	memcpy(buf+CONTENT_LENGTH_LEN+value_len, CRLF, CRLF_LEN);
319
-	buf[len+1]=0; /* null terminate it */
319
+	buf[len]=0; /* null terminate it */
320 320
 	*clen_len=len;
321 321
 	return buf;
322 322
 }
... ...
@@ -522,9 +522,9 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,
522 522
 	
523 523
 #ifdef USE_TCP
524 524
 	char* id_buf;
525
-	int id_len;
525
+	unsigned int id_len;
526 526
 	char* clen_buf;
527
-	int clen_len;
527
+	unsigned int clen_len;
528 528
 	
529 529
 	
530 530
 	id_buf=0;
... ...
@@ -727,7 +727,7 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
727 727
 #ifdef USE_TCP
728 728
 	struct lump* anchor;
729 729
 	char* clen_buf;
730
-	int clen_len;
730
+	unsigned int clen_len;
731 731
 	
732 732
 	clen_buf=0;
733 733
 	clen_len=0;
... ...
@@ -932,7 +932,10 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
932 932
 				continue;
933 933
 			}
934 934
 		} else if (hdr->type==HDR_VIA) {
935
+				/* we always add CRLF to via*/
936
+				len+=(hdr->body.s+hdr->body.len)-hdr->name.s+CRLF_LEN;
935 937
 				if (hdr==msg->h_via1) len += received_len+rport_len;
938
+				continue;
936 939
 		} else if (hdr->type==HDR_RECORDROUTE) {
937 940
 				/* RR only for 1xx and 2xx replies */
938 941
 				if (code<180 || code>=300) continue;
... ...
@@ -941,7 +944,8 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
941 941
 					|| hdr->type==HDR_CSEQ)) {
942 942
 			continue;
943 943
 		}
944
-		len += hdr->len;
944
+		len += hdr->len; /* we keep the original termination for these 
945
+							headers*/
945 946
 	}
946 947
 	len-=delete_len;
947 948
 	/*lumps length*/
... ...
@@ -1015,21 +1019,23 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
1015 1015
 											msg->via1->rport->size, msg);
1016 1016
 					}else{
1017 1017
 						/* normal whole via copy */
1018
-						append_str_trans( p, hdr->name.s ,
1019
-							((hdr->body.s+hdr->body.len )-hdr->name.s ), msg);
1018
+						append_str_trans( p, hdr->name.s , 
1019
+								(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
1020 1020
 					}
1021 1021
 					if (received_buf)
1022 1022
 						append_str( p, received_buf, received_len);
1023 1023
 				}else{
1024 1024
 					/* normal whole via copy */
1025
-					append_str_trans( p, hdr->name.s ,
1026
-						((hdr->body.s+hdr->body.len )-hdr->name.s ),msg);
1025
+					append_str_trans( p, hdr->name.s,
1026
+							(hdr->body.s+hdr->body.len)-hdr->name.s, msg);
1027 1027
 				}
1028 1028
 				append_str( p, CRLF,CRLF_LEN);
1029 1029
 				break;
1030 1030
 			case HDR_RECORDROUTE:
1031 1031
 				/* RR only for 1xx and 2xx replies */
1032 1032
 				if (code<180 || code>=300) break;
1033
+				append_str(p, hdr->name.s, hdr->len);
1034
+				break;
1033 1035
 			case HDR_TO:
1034 1036
 				if (new_tag){
1035 1037
 					if (to_tag.s ) { /* replacement */
... ...
@@ -1078,7 +1084,6 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
1078 1078
 		memcpy( p, CRLF, CRLF_LEN );
1079 1079
 		p+=CRLF_LEN;
1080 1080
 	}
1081
-
1082 1081
 	
1083 1082
 	if (body_len) {
1084 1083
 		memcpy(p, CONTENT_LENGTH, CONTENT_LENGTH_LEN );
... ...
@@ -1113,6 +1118,9 @@ char * build_res_buf_with_body_from_sip_req( unsigned int code, char *text ,
1113 1113
 	}
1114 1114
 	*(p) = 0;
1115 1115
 	*returned_len = len;
1116
+	DBG("build_*: len=%d, diff=%d\n", len, p-buf);
1117
+	DBG("build_*: rport_len=%d, delete_len=%d\n", rport_len, delete_len);
1118
+	DBG("build_*: message=\n%.*s\n", len, buf);
1116 1119
 	/* in req2reply, received_buf is not introduced to lumps and
1117 1120
 	   needs to be deleted here
1118 1121
 	*/
... ...
@@ -71,12 +71,12 @@
71 71
  * Format: name':' body 
72 72
  */
73 73
 struct hdr_field {   
74
-	int type;                /* Header field type */
75
-	str name;                /* Header field name */
76
-	str body;                /* Header field body */
77
-	int len;				 /* length from body until EoHF (incl. CRLF) */
78
-	void* parsed;            /* Parsed data structures */
79
-	struct hdr_field* next;  /* Next header field in the list */
74
+	int type;               /* Header field type */
75
+	str name;               /* Header field name */
76
+	str body;               /* Header field body (may not include CRLF) */
77
+	int len;				/* length from hdr start until EoHF (incl.CRLF) */
78
+	void* parsed;           /* Parsed data structures */
79
+	struct hdr_field* next; /* Next header field in the list */
80 80
 };
81 81
 
82 82
 
... ...
@@ -41,11 +41,11 @@
41 41
  */
42 42
 typedef struct type_node_s {
43 43
 	char c;                      /* char contained by this node */
44
-	unsigned char final;         /* says what to be done if the mached string
44
+	char final;                 /* says what to be done if the matched string
45 45
 	                              * ends at this node: -1-> dead end (unknown
46 46
 	                              * type) or the index of the sub-type that
47
-	                              * follows (for types) or the  final type (for
48
-	                              * sub-types)*/
47
+	                              * follows (for types) or the  final type 
48
+	                              * (for sub-types)*/
49 49
 	unsigned char nr_sons;       /* the number of sub-nodes */
50 50
 	int next;                    /* the next sibling node */
51 51
 }type_node_t;
... ...
@@ -906,7 +906,9 @@ normal_exit:
906 906
 	*pstate=state;
907 907
 	*psaved_state=saved_state;
908 908
 	DBG("Found param type %d, <%.*s> = <%.*s>; state=%d\n", param->type,
909
-			param->name.len, param->name.s, param->value.len, param->value.s, state);
909
+			param->name.len, param->name.s, 
910
+			(param->value.len?param->value.len:3),
911
+			(param->value.len?param->value.s:"n/a"), state);
910 912
 	return tmp;
911 913
 	
912 914
  end_via:
... ...
@@ -1863,7 +1865,7 @@ endofpacket:
1863 1863
 	vb->error=PARSE_OK;
1864 1864
 	vb->bsize=tmp-buffer;
1865 1865
 	if (vb->port_str.s){
1866
-		vb->port=str2s((unsigned char*)vb->port_str.s, vb->port_str.len, &err);
1866
+		vb->port=str2s(vb->port_str.s, vb->port_str.len, &err);
1867 1867
 		if (err){
1868 1868
 					LOG(L_ERR, "ERROR: parse_via: invalid port number <%.*s>\n",
1869 1869
 						vb->port_str.len, vb->port_str.s);
... ...
@@ -1876,7 +1878,7 @@ nextvia:
1876 1876
 	vb->error=PARSE_OK;
1877 1877
 	vb->bsize=tmp-buffer;
1878 1878
 	if (vb->port_str.s){
1879
-		vb->port=str2s((unsigned char*)vb->port_str.s, vb->port_str.len, &err);
1879
+		vb->port=str2s(vb->port_str.s, vb->port_str.len, &err);
1880 1880
 		if (err){
1881 1881
 					LOG(L_ERR, "ERROR: parse_via: invalid port number <%.*s>\n",
1882 1882
 						vb->port_str.len, vb->port_str.s);
... ...
@@ -134,12 +134,12 @@ static inline struct ip_addr* str2ip(str* st)
134 134
 	static struct ip_addr ip;
135 135
 	unsigned char* s;
136 136
 
137
-	s = st->s;
137
+	s=(unsigned char*)st->s;
138 138
 
139 139
 	/*init*/
140 140
 	ip.u.addr32[0]=0;
141 141
 	i=0;
142
-	limit=st->s + st->len;
142
+	limit=(unsigned char*)(st->s + st->len);
143 143
 
144 144
 	for(;s<limit ;s++){
145 145
 		if (*s=='.'){
... ...
@@ -187,7 +187,7 @@ static inline struct ip_addr* str2ip6(str* st)
187 187
 	unsigned char* s;
188 188
 	
189 189
 	/* init */
190
-	s=st->s;
190
+	s=(unsigned char*)st->s;
191 191
 	i=idx1=rest=0;
192 192
 	double_colon=0;
193 193
 	no_colons=0;
... ...
@@ -195,7 +195,7 @@ static inline struct ip_addr* str2ip6(str* st)
195 195
 	ip.len=16;
196 196
 	addr_start=ip.u.addr16;
197 197
 	addr=addr_start;
198
-	limit=st->s+st->len;
198
+	limit=(unsigned char*)(st->s+st->len);
199 199
 	memset(addr_start, 0 , 8*sizeof(unsigned short));
200 200
 	memset(addr_end, 0 , 8*sizeof(unsigned short));
201 201
 	for (; s<limit; s++){
... ...
@@ -29,8 +29,9 @@
29 29
  *
30 30
  * History:
31 31
  * --------
32
- * 2003-02-28 scratchpad compatibility abandoned (jiri)
33
- * 2003-01-28 scratchpad removed, src_port introduced (jiri)
32
+ * 2003-02-28  scratchpad compatibility abandoned (jiri)
33
+ * 2003-01-28  scratchpad removed, src_port introduced (jiri)
34
+ * 2003-03-10  updated to the new module exports format (andrei)
34 35
  */
35 36
 
36 37
  
... ...
@@ -141,6 +142,7 @@ static int fix_actions(struct action* a)
141 141
 	struct proxy_l* p;
142 142
 	char *tmp;
143 143
 	int ret,r;
144
+	cmd_export_t* cmd;
144 145
 	struct sr_module* mod;
145 146
 	str s;
146 147
 	
... ...
@@ -215,19 +217,16 @@ static int fix_actions(struct action* a)
215 215
 				}
216 216
 				break;
217 217
 			case MODULE_T:
218
-				if ((mod=find_module(t->p1.data, &r))!=0){
219
-					DBG("fixing %s %s\n", mod->path,
220
-							mod->exports->cmd_names[r]);
221
-					if (mod->exports->fixup_pointers[r]){
222
-						if (mod->exports->param_no[r]>0){
223
-							ret=mod->exports->fixup_pointers[r](&t->p2.data,
224
-																1);
218
+				if ((mod=find_module(t->p1.data, &cmd))!=0){
219
+					DBG("fixing %s %s\n", mod->path, cmd->name);
220
+					if (cmd->fixup){
221
+						if (cmd->param_no>0){
222
+							ret=cmd->fixup(&t->p2.data, 1);
225 223
 							t->p2_type=MODFIXUP_ST;
226 224
 							if (ret<0) return ret;
227 225
 						}
228
-						if (mod->exports->param_no[r]>1){
229
-							ret=mod->exports->fixup_pointers[r](&t->p3.data,
230
-																2);
226
+						if (cmd->param_no>1){
227
+							ret=cmd->fixup(&t->p3.data, 2);
231 228
 							t->p3_type=MODFIXUP_ST;
232 229
 							if (ret<0) return ret;
233 230
 						}
... ...
@@ -23,6 +23,12 @@
23 23
  * along with this program; if not, write to the Free Software 
24 24
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25 25
  */
26
+/*
27
+ * History:
28
+ * --------
29
+ *  2003-03-10  switched to new module_exports format: updated find_export,
30
+ *               find_export_param, find_module (andrei)
31
+ */
26 32
 
27 33
 
28 34
 #include "sr_module.h"
... ...
@@ -191,15 +197,15 @@ skip:
191 191
 cmd_function find_export(char* name, int param_no)
192 192
 {
193 193
 	struct sr_module* t;
194
-	int r;
194
+	cmd_export_t* cmd;
195 195
 
196 196
 	for(t=modules;t;t=t->next){
197
-		for(r=0;r<t->exports->cmd_no;r++){
198
-			if((strcmp(name, t->exports->cmd_names[r])==0)&&
199
-				(t->exports->param_no[r]==param_no) ){
197
+		for(cmd=t->exports->cmds; cmd && cmd->name; cmd++){
198
+			if((strcmp(name, cmd->name)==0)&&
199
+				(cmd->param_no==param_no) ){
200 200
 				DBG("find_export: found <%s> in module %s [%s]\n",
201 201
 						name, t->exports->name, t->path);
202
-				return t->exports->cmd_pointers[r];
202
+				return cmd->function;
203 203
 			}
204 204
 		}
205 205
 	}
... ...
@@ -211,16 +217,16 @@ cmd_function find_export(char* name, int param_no)
211 211
 void* find_param_export(char* mod, char* name, modparam_t type)
212 212
 {
213 213
 	struct sr_module* t;
214
-	int r;
214
+	param_export_t* param;
215 215
 
216 216
 	for(t = modules; t; t = t->next) {
217 217
 		if (strcmp(mod, t->exports->name) == 0) {
218
-			for(r = 0; r < t->exports->par_no; r++) {
219
-				if ((strcmp(name, t->exports->param_names[r]) == 0) &&
220
-				    (t->exports->param_types[r] == type)) {
218
+			for(param=t->exports->params;param && param->name ; param++) {
219
+				if ((strcmp(name, param->name) == 0) &&
220
+				    (param->type == type)) {
221 221
 					DBG("find_param_export: found <%s> in module %s [%s]\n",
222 222
 					    name, t->exports->name, t->path);
223
-					return t->exports->param_pointers[r];
223
+					return param->param_pointer;
224 224
 				}
225 225
 			}
226 226
 		}
... ...
@@ -233,15 +239,17 @@ void* find_param_export(char* mod, char* name, modparam_t type)
233 233
 
234 234
 
235 235
 /* finds a module, given a pointer to a module function *
236
- * returns pointer to module, & if i i!=0, *i=the function index */
237
-struct sr_module* find_module(void* f, int *i)
236
+ * returns pointer to module, & if  c!=0, *c=pointer to the
237
+ * function cmd_export structure*/
238
+struct sr_module* find_module(void* f, cmd_export_t  **c)
238 239
 {
239 240
 	struct sr_module* t;
240
-	int r;
241
+	cmd_export_t* cmd;
242
+	
241 243
 	for (t=modules;t;t=t->next){
242
-		for(r=0;r<t->exports->cmd_no;r++) 
243
-			if (f==(void*)t->exports->cmd_pointers[r]) {
244
-				if (i) *i=r;
244
+		for(cmd=t->exports->cmds; cmd && cmd->name; cmd++) 
245
+			if (f==(void*)cmd->function) {
246
+				if (c) *c=cmd;
245 247
 				return t;
246 248
 			}
247 249
 	}
... ...
@@ -26,6 +26,12 @@
26 26
  * along with this program; if not, write to the Free Software 
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 28
  */
29
+/*
30
+ * History:
31
+ * --------
32
+ *  2003-03-10  changed module exports interface: added struct cmd_export
33
+ *               and param_export (andrei)
34
+ */
29 35
 
30 36
 
31 37
 #ifndef sr_module_h
... ...
@@ -49,49 +55,63 @@ typedef enum {
49 49
 } modparam_t;       /* Allowed types of parameters */
50 50
 
51 51
 
52
+struct cmd_export_ {
53
+	char* name;             /* null terminated command name */
54
+	cmd_function function;  /* pointer to the corresponding function */
55
+	int param_no;           /* number of parameters used by the function */
56
+	fixup_function fixup;   /* pointer to the function called to "fix" the
57
+							   parameters */
58
+};
59
+
60
+
61
+struct param_export_ {
62
+	char* name;             /* null terminated param. name */
63
+	modparam_t type;        /* param. type */
64
+	void* param_pointer;    /* pointer to the param. memory location */
65
+};
66
+
67
+
68
+typedef struct cmd_export_ cmd_export_t;
69
+typedef struct param_export_ param_export_t;
70
+
52 71
 struct module_exports{
53 72
 	char* name;                     /* null terminated module name */
54
-	char** cmd_names;               /* cmd names registered by this modules */
55
-	cmd_function* cmd_pointers;     /* pointers to the corresponding
56
-									   functions */
57
-	int* param_no;                  /* number of parameters used
58
-									   by the function */
59
-	fixup_function* fixup_pointers; /* pointers to functions called to "fix"
60
-										the params, e.g: precompile a re */
61
-	int cmd_no;                     /* number of registered commands
62
-										(size of cmd_{names,pointers} */
63
-
64
-	char** param_names;    /* parameter names registered by this modules */
65
-	modparam_t* param_types; /* Type of parameters */
66
-	void** param_pointers; /* Pointers to the corresponding memory locations */
67
-	int par_no;            /* number of registered parameters */
68
-
69
-
70
-	init_function init_f;         /* Initilization function */
71
-	response_function response_f; /* function used for responses,
72
-									returns yes or no; can be null */
73
-	destroy_function destroy_f;  /* function called when the module should
74
-									be "destroyed", e.g: on ser exit;
75
-									can be null */
73
+	
74
+	cmd_export_t* cmds;             /* null terminated array of the exported
75
+									   commands */
76
+	param_export_t* params;         /* null terminated array of the exported
77
+									   module parameters */
78
+
79
+	init_function init_f;           /* Initilization function */
80
+	response_function response_f;   /* function used for responses,
81
+									   returns yes or no; can be null */
82
+	destroy_function destroy_f;     /* function called when the module should
83
+									   be "destroyed", e.g: on ser exit;
84
+									   can be null */
76 85
 	onbreak_function onbreak_f;
77 86
 	child_init_function init_child_f;  /* function called by all processes
78 87
 										  after the fork */
79 88
 };
80 89
 
90
+
91
+
92
+
93
+
81 94
 struct sr_module{
82 95
 	char* path;
83 96
 	void* handle;
84 97
 	struct module_exports* exports;
85 98
 	struct sr_module* next;
86 99
 };
87
- 
100
+
101
+
88 102
 struct sr_module* modules; /* global module list*/
89 103
 
90 104
 int register_builtin_modules();
91 105
 int register_module(struct module_exports*, char*,  void*);
92 106
 int load_module(char* path);
93 107
 cmd_function find_export(char* name, int param_no);
94
-struct sr_module* find_module(void *f, int* r);
108
+struct sr_module* find_module(void *f, cmd_export_t** cmd);
95 109
 void destroy_modules();
96 110
 int init_child(int rank);
97 111
 int init_modules(void);
... ...
@@ -515,7 +515,6 @@ static int send2child(struct tcp_connection* tcpconn)
515 515
 			idx=i;
516 516
 			min_busy=0;
517 517
 			break;
518
-			return 0;
519 518
 		}else if (min_busy>tcp_children[i].busy){
520 519
 			min_busy=tcp_children[i].busy;
521 520
 			idx=i;
... ...
@@ -5,10 +5,10 @@
5 5
 #
6 6
 
7 7
 
8
-debug=3          # debug level (cmd line: -dddddddddd)
8
+#debug=3          # debug level (cmd line: -dddddddddd)
9 9
 #fork=yes          # (cmd. line: -D)
10 10
 #fork=no
11
-log_stderror=yes # (cmd line: -E)
11
+#log_stderror=yes # (cmd line: -E)
12 12
 #log_stderror=no	# (cmd line: -E)
13 13
 
14 14
 
... ...
@@ -94,15 +94,17 @@ static char fourbits2char[16] = { '0', '1', '2', '3', '4', '5',
94 94
 /* converts a str to an u. short, returns the u. short and sets *err on
95 95
  * error and if err!=null
96 96
   */
97
-static inline unsigned short str2s(unsigned char* str, unsigned int len,
97
+static inline unsigned short str2s(char* s, unsigned int len,
98 98
 									int *err)
99 99
 {
100 100
 	unsigned short ret;
101 101
 	int i;
102 102
 	unsigned char *limit;
103 103
 	unsigned char *init;
104
+	unsigned char* str;
104 105
 
105 106
 	/*init*/
107
+	str=(unsigned char*)s;
106 108
 	ret=i=0;
107 109
 	limit=str+len;
108 110
 	init=str;
... ...
@@ -147,7 +149,7 @@ static inline int btostr( char *p,  unsigned char val)
147 147
 
148 148
 
149 149
 
150
-/* returns a pointer to a static buffer containint l in asciiz & sets len */
150
+/* returns a pointer to a static buffer containing l in asciiz & sets len */
151 151
 static inline char* int2str(unsigned int l, int* len)
152 152
 {
153 153
 	static char r[11]; /* 10 digits + 0 */