Browse code

- textops subst_uri added (like subst but works on uris)

Andrei Pelinescu-Onciul authored on 20/08/2003 18:21:12
Showing 5 changed files
... ...
@@ -272,7 +272,8 @@ DEFS+= $(extra_defs) \
272 272
 	 -DUSE_IPV6 \
273 273
 	 -DUSE_TCP \
274 274
 	 -DDISABLE_NAGLE \
275
-	 -DF_MALLOC \
275
+	 -DDBG_QM_MALLOC \
276
+	# -DF_MALLOC \
276 277
 	# -DDBG_F_MALLOC \
277 278
 	# -DDBG_QM_MALLOC \
278 279
 	 #-DF_MALLOC \
... ...
@@ -3,6 +3,13 @@ Release notes for SIP Express Router (ser)
3 3
 
4 4
 $Id$
5 5
 
6
+0.8.12 changes
7
+
8
+texops:
9
+ - subst('s/re/repl/flags') support
10
+
11
+
12
+
6 13
 ***********************************************
7 14
 * Changes introduced in 0.8.11
8 15
 ***********************************************
... ...
@@ -11,6 +11,8 @@ $Id$
11 11
 - port receive.c pre_script_cb fix from stable
12 12
 - extend alias to include port numbers :
13 13
     something like alias= foo1.bar:5080 foo2.bar foo3.bar:*
14
+- extend listen and alias to include port numbers and protocol:
15
+       tcp foo.bar:5063, udp foo.bar:5062, foo2.bar
14 16
 
15 17
 release:
16 18
 - change tcp timeouts to 2 or 3 min?
... ...
@@ -451,7 +451,8 @@ error:
451 451
 
452 452
 
453 453
 
454
-/* return the substitution result in a str, input must be 0 term */ 
454
+/* returns the substitution result in a str, input must be 0 term
455
+ *  0 on no match or malloc error */ 
455 456
 str* subst_str(char *input, struct sip_msg* msg, struct subst_expr* se)
456 457
 {
457 458
 	str* res;
... ...
@@ -468,14 +469,23 @@ str* subst_str(char *input, struct sip_msg* msg, struct subst_expr* se)
468 468
 	len=strlen(input);
469 469
 	end=input+len;
470 470
 	lst=subst_run(se, input, msg);
471
-	for (l=lst; l; l=l->next)
471
+	if (lst==0){
472
+		DBG("subst_str: no match\n");
473
+		return 0;
474
+	}
475
+	DBG("subst_str: orig len: %d\n", len);
476
+	for (l=lst; l; l=l->next){
477
+		DBG("subst_str: len+=%d (size=%d)\n", l->rpl.len-l->size, l->size );
472 478
 		len+=(int)(l->rpl.len)-l->size;
479
+	}
480
+	DBG("subst_str: new len: %d\n", len);
473 481
 	res=pkg_malloc(sizeof(str));
474 482
 	if (res==0){
475 483
 		LOG(L_ERR, "ERROR: subst_str: mem. allocation error\n");
476 484
 		goto error;
477 485
 	}
478
-	res->s=pkg_malloc(len);
486
+	res->s=pkg_malloc(len+1); /* space for null termination */
487
+	res->s[len]=0;
479 488
 	if (res->s==0){
480 489
 		LOG(L_ERR, "ERROR: subst_str: mem. allocation error (res->s)\n");
481 490
 		goto error;
... ...
@@ -487,8 +497,8 @@ str* subst_str(char *input, struct sip_msg* msg, struct subst_expr* se)
487 487
 	p=input;
488 488
 	for(l=lst; l; l=l->next){
489 489
 		size=l->offset+input-p;
490
-		memcpy(dest, p, size);
491
-		p+=size;
490
+		memcpy(dest, p, size); /* copy till offset */
491
+		p+=size + l->size; /* skip l->size bytes */
492 492
 		dest+=size;
493 493
 		if (l->rpl.len){
494 494
 			memcpy(dest, l->rpl.s, l->rpl.len);
... ...
@@ -170,7 +170,7 @@ static inline int version_control(void *handle, char *path)
170 170
 	}
171 171
 	if (strcmp(VERSION,*m_ver)==0)
172 172
 		return 1;
173
-	LOG(L_ERR, "ERRO: module version mismatch for %s; "
173
+	LOG(L_ERR, "ERROR: module version mismatch for %s; "
174 174
 		"core: %s; module: %s\n", path, VERSION, *m_ver );
175 175
 	return 0;
176 176
 }