Browse code

ZSW introduced to deal with solaris printf("%.*s",0,0) SF

Jiri Kuthan authored on 26/04/2003 20:28:46
Showing 10 changed files
... ...
@@ -27,6 +27,7 @@
27 27
  * History:
28 28
  * -------
29 29
  * 2003-03-26 Frees also hdr->parsed for Route & Record-Route (janakj)
30
+ * 2003-04-26 ZSW (jiri)
30 31
  */
31 32
 
32 33
 
... ...
@@ -42,6 +43,7 @@
42 43
 #include "parse_expires.h"
43 44
 #include "parse_rr.h"
44 45
 #include "contact/parse_contact.h"
46
+#include "../ut.h"
45 47
 
46 48
 
47 49
 /* 
... ...
@@ -122,8 +124,8 @@ void dump_hdr_field( struct hdr_field* hf )
122 124
 {
123 125
 	LOG(L_ERR, "DEBUG: dump_hdr_field: type=%d, name=%.*s, "
124 126
 		"body=%.*s, parsed=%p, next=%p\n",
125
-		hf->type, hf->name.len, hf->name.s,
126
-		hf->body.len, hf->body.s,
127
+		hf->type, hf->name.len, ZSW(hf->name.s),
128
+		hf->body.len, ZSW(hf->body.s),
127 129
 		hf->parsed, hf->next );
128 130
 }
129 131
 
... ...
@@ -33,6 +33,7 @@
33 33
  *  2003-01-29  scrathcpad removed (jiri)
34 34
  *  2003-01-27  next baby-step to removing ZT - PRESERVE_ZT (jiri)
35 35
  *  2003-03-31  removed msg->repl_add_rm (andrei)
36
+ *  2003-04-26 ZSW (jiri)
36 37
  */
37 38
 
38 39
 
... ...
@@ -139,8 +140,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
139 140
 			hdr->parsed=cseq_b;
140 141
 			hdr->body.len=tmp-hdr->body.s;
141 142
 			DBG("get_hdr_field: cseq <%.*s>: <%.*s> <%.*s>\n",
142
-					hdr->name.len, hdr->name.s, 
143
-					cseq_b->number.len, cseq_b->number.s, 
143
+					hdr->name.len, ZSW(hdr->name.s), 
144
+					cseq_b->number.len, ZSW(cseq_b->number.s), 
144 145
 					cseq_b->method.len, cseq_b->method.s);
145 146
 			break;
146 147
 		case HDR_TO:
... ...
@@ -160,9 +161,10 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
160 161
 			hdr->parsed=to_b;
161 162
 			hdr->body.len=tmp-hdr->body.s;
162 163
 			DBG("DEBUG: get_hdr_field: <%.*s> [%d]; uri=[%.*s] \n",
163
-				hdr->name.len, hdr->name.s, 
164
-				hdr->body.len, to_b->uri.len,to_b->uri.s);
165
-			DBG("DEBUG: to body [%.*s]\n",to_b->body.len,to_b->body.s);
164
+				hdr->name.len, ZSW(hdr->name.s), 
165
+				hdr->body.len, to_b->uri.len,ZSW(to_b->uri.s));
166
+			DBG("DEBUG: to body [%.*s]\n",to_b->body.len,
167
+				ZSW(to_b->body.s));
166 168
 			break;
167 169
 		case HDR_CONTENTLENGTH:
168 170
 			hdr->body.s=tmp;
... ...
@@ -398,8 +400,8 @@ int parse_headers(struct sip_msg* msg, int flags, int next)
398 400
 #ifdef EXTRA_DEBUG
399 401
 		DBG("header field type %d, name=<%.*s>, body=<%.*s>\n",
400 402
 			hf->type, 
401
-			hf->name.len, hf->name.s, 
402
-			hf->body.len, hf->body.s);
403
+			hf->name.len, ZSW(hf->name.s), 
404
+			hf->body.len, ZSW(hf->body.s));
403 405
 #endif
404 406
 		tmp=rest;
405 407
 	}
... ...
@@ -449,21 +451,21 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
449 451
 		case SIP_REQUEST:
450 452
 			DBG("SIP Request:\n");
451 453
 			DBG(" method:  <%.*s>\n",fl->u.request.method.len,
452
-				fl->u.request.method.s);
454
+				ZSW(fl->u.request.method.s));
453 455
 			DBG(" uri:     <%.*s>\n",fl->u.request.uri.len,
454
-				fl->u.request.uri.s);
456
+				ZSW(fl->u.request.uri.s));
455 457
 			DBG(" version: <%.*s>\n",fl->u.request.version.len,
456
-				fl->u.request.version.s);
458
+				ZSW(fl->u.request.version.s));
457 459
 			flags=HDR_VIA;
458 460
 			break;
459 461
 		case SIP_REPLY:
460 462
 			DBG("SIP Reply  (status):\n");
461 463
 			DBG(" version: <%.*s>\n",fl->u.reply.version.len,
462
-					fl->u.reply.version.s);
464
+					ZSW(fl->u.reply.version.s));
463 465
 			DBG(" status:  <%.*s>\n", fl->u.reply.status.len,
464
-					fl->u.reply.status.s);
466
+					ZSW(fl->u.reply.status.s));
465 467
 			DBG(" reason:  <%.*s>\n", fl->u.reply.reason.len,
466
-					fl->u.reply.reason.s);
468
+					ZSW(fl->u.reply.reason.s));
467 469
 			/* flags=HDR_VIA | HDR_VIA2; */
468 470
 			/* we don't try to parse VIA2 for local messages; -Jiri */
469 471
 			flags=HDR_VIA;
... ...
@@ -483,40 +485,40 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
483 485
 	if (msg->via1){
484 486
 		DBG(" first  via: <%.*s/%.*s/%.*s> <%.*s:%.*s(%d)>",
485 487
 			msg->via1->name.len, 
486
-			msg->via1->name.s, 
488
+			ZSW(msg->via1->name.s), 
487 489
 			msg->via1->version.len,
488
-			msg->via1->version.s,
490
+			ZSW(msg->via1->version.s),
489 491
 			msg->via1->transport.len,
490
-			msg->via1->transport.s, 
492
+			ZSW(msg->via1->transport.s), 
491 493
 			msg->via1->host.len,
492
-			msg->via1->host.s,
494
+			ZSW(msg->via1->host.s),
493 495
 			msg->via1->port_str.len, 
494
-			msg->via1->port_str.s, 
496
+			ZSW(msg->via1->port_str.s), 
495 497
 			msg->via1->port);
496 498
 		if (msg->via1->params.s)  DBG(";<%.*s>", 
497
-				msg->via1->params.len, msg->via1->params.s);
499
+				msg->via1->params.len, ZSW(msg->via1->params.s));
498 500
 		if (msg->via1->comment.s) 
499 501
 				DBG(" <%.*s>", 
500
-					msg->via1->comment.len, msg->via1->comment.s);
502
+					msg->via1->comment.len, ZSW(msg->via1->comment.s));
501 503
 		DBG ("\n");
502 504
 	}
503 505
 	if (msg->via2){
504 506
 		DBG(" first  via: <%.*s/%.*s/%.*s> <%.*s:%.*s(%d)>",
505 507
 			msg->via2->name.len, 
506
-			msg->via2->name.s, 
508
+			ZSW(msg->via2->name.s), 
507 509
 			msg->via2->version.len,
508
-			msg->via2->version.s,
510
+			ZSW(msg->via2->version.s),
509 511
 			msg->via2->transport.len, 
510
-			msg->via2->transport.s, 
512
+			ZSW(msg->via2->transport.s), 
511 513
 			msg->via2->host.len,
512
-			msg->via2->host.s,
514
+			ZSW(msg->via2->host.s),
513 515
 			msg->via2->port_str.len, 
514
-			msg->via2->port_str.s, 
516
+			ZSW(msg->via2->port_str.s), 
515 517
 			msg->via2->port);
516 518
 		if (msg->via2->params.s)  DBG(";<%.*s>", 
517
-				msg->via2->params.len, msg->via2->params.s);
519
+				msg->via2->params.len, ZSW(msg->via2->params.s));
518 520
 		if (msg->via2->comment.s) DBG(" <%.*s>", 
519
-				msg->via2->comment.len, msg->via2->comment.s);
521
+				msg->via2->comment.len, ZSW(msg->via2->comment.s));
520 522
 		DBG ("\n");
521 523
 	}
522 524
 #endif
... ...
@@ -530,7 +532,8 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
530 532
 	
531 533
 error:
532 534
 	/* more debugging, msg->orig is/should be null terminated*/
533
-	LOG(L_ERR, "ERROR: parse_msg: message=<%.*s>\n", (int)msg->len, msg->buf);
535
+	LOG(L_ERR, "ERROR: parse_msg: message=<%.*s>\n", 
536
+			(int)msg->len, ZSW(msg->buf));
534 537
 	return -1;
535 538
 }
536 539
 
... ...
@@ -29,6 +29,10 @@
29 29
  * You should have received a copy of the GNU General Public License 
30 30
  * along with this program; if not, write to the Free Software 
31 31
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
32
+ *
33
+ * History:
34
+ * --------
35
+ * 2003-04-26 ZSW (jiri)
32 36
  */
33 37
 
34 38
 
... ...
@@ -38,6 +42,7 @@
38 42
 #include <string.h>        /* memset */
39 43
 #include "../trim.h"       /* trim_leading */
40 44
 #include <stdio.h>         /* printf */
45
+#include "../ut.h"
41 46
 
42 47
 
43 48
 #define PRES_STR "presence"
... ...
@@ -142,7 +147,7 @@ void free_event(event_t** _e)
142 147
 void print_event(event_t* _e)
143 148
 {
144 149
 	printf("===Event===\n");
145
-	printf("text  : \'%.*s\'\n", _e->text.len, _e->text.s);
150
+	printf("text  : \'%.*s\'\n", _e->text.len, ZSW(_e->text.s));
146 151
 	printf("parsed: %s\n", 
147 152
 	       (_e->parsed == EVENT_PRESENCE) ? ("EVENT_PRESENCE") : ("EVENT_OTHER"));
148 153
 	printf("===/Event===\n");
... ...
@@ -25,6 +25,10 @@
25 25
  * You should have received a copy of the GNU General Public License 
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
+ *
29
+ * History:
30
+ * --------
31
+ * 2003-04-26 ZSW (jiri)
28 32
  */
29 33
 
30 34
 
... ...
@@ -34,6 +38,7 @@
34 38
 #include "../dprint.h"
35 39
 #include "../trim.h"        /* trim_leading */
36 40
 #include <string.h>         /* memset */
41
+#include "../ut.h"
37 42
 
38 43
 
39 44
 static inline int expires_parser(char* _s, int _l, exp_body_t* _e)
... ...
@@ -134,7 +139,7 @@ void free_expires(exp_body_t** _e)
134 139
 void print_expires(exp_body_t* _e)
135 140
 {
136 141
 	printf("===Expires===\n");
137
-	printf("text: \'%.*s\'\n", _e->text.len, _e->text.s);
142
+	printf("text: \'%.*s\'\n", _e->text.len, ZSW(_e->text.s));
138 143
 	printf("val : %d\n", _e->val);
139 144
 	printf("===/Expires===\n");
140 145
 }
... ...
@@ -31,6 +31,7 @@
31 31
  * ---------
32 32
  * 2003-02-28 scratchpad compatibility abandoned (jiri)
33 33
  * 2003-01-28: removed 0-terminators from first line (jiri)
34
+ * 2003-04-26 ZSW (jiri)
34 35
  */
35 36
 
36 37
 
... ...
@@ -39,6 +40,7 @@
39 40
 #include "msg_parser.h"
40 41
 #include "parser_f.h"
41 42
 #include "../mem/mem.h"
43
+#include "../ut.h"
42 44
 
43 45
 /* grammar:
44 46
 	request  =  method SP uri SP version CRLF
... ...
@@ -1242,7 +1244,7 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
1242 1244
 	if (fl->type==SIP_REPLY) {
1243 1245
 		if (fl->u.request.uri.len!=3) {
1244 1246
 			LOG(L_INFO, "ERROR:parse_first_line: len(status code)!=3: %.*s\n",
1245
-				fl->u.request.uri.len, second );
1247
+				fl->u.request.uri.len, ZSW(second) );
1246 1248
 			goto error;
1247 1249
 		}
1248 1250
 		s1=*second; s2=*(second+1);s3=*(second+2);
... ...
@@ -1252,7 +1254,7 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
1252 1254
 			fl->u.reply.statuscode=(s1-'0')*100+10*(s2-'0')+(s3-'0');
1253 1255
 		} else {
1254 1256
 			LOG(L_INFO, "ERROR:parse_first_line: status_code non-numerical: %.*s\n",
1255
-				fl->u.request.uri.len, second );
1257
+				fl->u.request.uri.len, ZSW(second) );
1256 1258
 			goto error;
1257 1259
 		}
1258 1260
 	}
... ...
@@ -1298,7 +1300,7 @@ error:
1298 1300
 		for (t=0; t<offset; t++)
1299 1301
 			if (*(buffer+t)) *(prn+t)=*(buffer+t);
1300 1302
 			else *(prn+t)='�';
1301
-		LOG(L_INFO, "ERROR: parsed so far: %.*s\n", offset, prn );
1303
+		LOG(L_INFO, "ERROR: parsed so far: %.*s\n", offset, ZSW(prn) );
1302 1304
 		pkg_free( prn );
1303 1305
 	};
1304 1306
 error1:
... ...
@@ -27,12 +27,14 @@
27 27
  * History
28 28
  * --------
29 29
  * 2003-03-24 Created by janakj
30
+ * 2003-04-26 ZSW (jiri)
30 31
  */
31 32
 
32 33
 #include <string.h>
33 34
 #include "../dprint.h"
34 35
 #include "parse_nameaddr.h"
35 36
 #include "parser_f.h"
37
+#include "../ut.h"
36 38
 
37 39
 
38 40
 /*
... ...
@@ -81,7 +83,7 @@ int parse_nameaddr(str* _s, name_addr_t* _a)
81 83
 void print_nameaddr(FILE* _o, name_addr_t* _a)
82 84
 {
83 85
 	fprintf(_o, "---name-addr---\n");
84
-	fprintf(_o, "name: '%.*s'\n", _a->name.len, _a->name.s);
85
-	fprintf(_o, "uri : '%.*s'\n", _a->uri.len, _a->uri.s);
86
+	fprintf(_o, "name: '%.*s'\n", _a->name.len, ZSW(_a->name.s));
87
+	fprintf(_o, "uri : '%.*s'\n", _a->uri.len, ZSW(_a->uri.s));
86 88
 	fprintf(_o, "---/name-addr---\n");
87 89
 }
... ...
@@ -23,6 +23,10 @@
23 23
  * You should have received a copy of the GNU General Public License 
24 24
  * along with this program; if not, write to the Free Software 
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
+ *
27
+ * History:
28
+ * ---------
29
+ * 2003-04-26 ZSW (jiri)
26 30
  */
27 31
 
28 32
 
... ...
@@ -51,8 +55,8 @@ enum {
51 55
 
52 56
 #define add_param( _param , _body ) \
53 57
 	do{\
54
-		DBG("DEBUG: add_param: %.*s=%.*s\n",param->name.len,param->name.s,\
55
-			param->value.len,param->value.s);\
58
+		DBG("DEBUG: add_param: %.*s=%.*s\n",param->name.len,ZSW(param->name.s),\
59
+			param->value.len,ZSW(param->value.s));\
56 60
 		if (!(_body)->param_lst)  (_body)->param_lst=(_param);\
57 61
 		else (_body)->last_param->next=(_param);\
58 62
 		(_body)->last_param =(_param);\
... ...
@@ -140,7 +144,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
140 144
 					default:
141 145
 						LOG( L_ERR , "ERROR: parse_to_param : "
142 146
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
143
-							*tmp,status, (int)(tmp-buffer), buffer);
147
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
144 148
 				}
145 149
 				break;
146 150
 			case '\r':
... ...
@@ -176,7 +180,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
176 180
 					default:
177 181
 						LOG( L_ERR , "ERROR: parse_to_param : "
178 182
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
179
-							*tmp,status, (int)(tmp-buffer), buffer);
183
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
180 184
 						goto error;
181 185
 				}
182 186
 				break;
... ...
@@ -204,7 +208,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
204 208
 					default:
205 209
 						LOG( L_ERR , "ERROR: parse_to_param : "
206 210
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
207
-							*tmp,status, (int)(tmp-buffer), buffer);
211
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
208 212
 						goto error;
209 213
 				}
210 214
 				break;
... ...
@@ -223,7 +227,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
223 227
 					default:
224 228
 						LOG( L_ERR , "ERROR: parse_to_param : "
225 229
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
226
-							*tmp,status, (int)(tmp-buffer), buffer);
230
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
227 231
 						goto error;
228 232
 				}
229 233
 				break;
... ...
@@ -247,7 +251,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
247 251
 					default:
248 252
 						LOG( L_ERR , "ERROR: parse_to_param :"
249 253
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
250
-							*tmp,status,(int)(tmp-buffer), buffer);
254
+							*tmp,status,(int)(tmp-buffer), ZSW(buffer));
251 255
 						goto error;
252 256
 				}
253 257
 				break;
... ...
@@ -267,7 +271,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
267 271
 						else {
268 272
 							LOG( L_ERR , "ERROR: parse_to_param : unexpected "
269 273
 								"char [%c] in status %d: <<%.*s>> .\n",
270
-								*tmp,status, (int)(tmp-buffer), buffer);
274
+								*tmp,status, (int)(tmp-buffer), ZSW(buffer));
271 275
 							goto error;
272 276
 						}
273 277
 #endif
... ...
@@ -294,7 +298,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
294 298
 					default:
295 299
 						LOG( L_ERR , "ERROR: parse_to_param :"
296 300
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
297
-							*tmp,status, (int)(tmp-buffer), buffer);
301
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
298 302
 						goto error;
299 303
 				}
300 304
 				break;
... ...
@@ -327,7 +331,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
327 331
 					default:
328 332
 						LOG( L_ERR , "ERROR: parse_to_param :"
329 333
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
330
-							*tmp,status, (int)(tmp-buffer), buffer);
334
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
331 335
 						goto error;
332 336
 				}
333 337
 				break;
... ...
@@ -362,7 +366,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
362 366
 					default:
363 367
 						LOG( L_ERR , "ERROR: parse_to_param : "
364 368
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
365
-							*tmp,status, (int)(tmp-buffer), buffer);
369
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
366 370
 						goto error;
367 371
 				}
368 372
 				break;
... ...
@@ -397,7 +401,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
397 401
 					default:
398 402
 						LOG( L_ERR , "ERROR: parse_to_param : "
399 403
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
400
-							*tmp,status, (int)(tmp-buffer), buffer);
404
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
401 405
 						goto error;
402 406
 				}
403 407
 				break;
... ...
@@ -425,7 +429,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
425 429
 					default:
426 430
 						LOG( L_ERR , "ERROR: parse_to_param : "
427 431
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
428
-							*tmp,status, (int)(tmp-buffer), buffer);
432
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
429 433
 						goto error;
430 434
 				}
431 435
 				break;
... ...
@@ -545,7 +549,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
545 549
 					default:
546 550
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
547 551
 							"in status %d: <<%.*s>> .\n",
548
-							*tmp,status, (int)(tmp-buffer), buffer);
552
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
549 553
 				}
550 554
 				break;
551 555
 			case '\r':
... ...
@@ -569,7 +573,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
569 573
 					default:
570 574
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
571 575
 							"in status %d: <<%.*s>> .\n",
572
-							*tmp,status, (int)(tmp-buffer), buffer);
576
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
573 577
 						goto error;
574 578
 				}
575 579
 				break;
... ...
@@ -585,7 +589,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
585 589
 					default:
586 590
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
587 591
 							"in status %d: <<%.*s>> .\n",
588
-							*tmp,status, (int)(tmp-buffer), buffer);
592
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
589 593
 						goto error;
590 594
 				}
591 595
 				break;
... ...
@@ -604,7 +608,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
604 608
 					default:
605 609
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
606 610
 							"in status %d: <<%.*s>> .\n",
607
-							*tmp,status, (int)(tmp-buffer), buffer);
611
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
608 612
 						goto error;
609 613
 				}
610 614
 				break;
... ...
@@ -631,7 +635,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
631 635
 					default:
632 636
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
633 637
 							"in status %d: <<%.*s>> .\n",
634
-							*tmp,status, (int)(tmp-buffer), buffer);
638
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
635 639
 						goto error;
636 640
 				}
637 641
 				break;
... ...
@@ -654,7 +658,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
654 658
 					default:
655 659
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
656 660
 							"in status %d: <<%.*s>> .\n",
657
-							*tmp,status, (int)(tmp-buffer), buffer);
661
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
658 662
 						goto error;
659 663
 				}
660 664
 				break;
... ...
@@ -31,15 +31,16 @@
31 31
  * 2003-04-11  new parse_uri introduced (better, parses also some parameters,
32 32
  *              works in one pass) (andrei)
33 33
  * 2003-04-11  ser_error is now set in parse_uri (andrei)
34
+ * 2003-04-26 ZSW (jiri)
34 35
  */
35 36
 
36 37
 
37 38
 #include "parse_uri.h"
38 39
 #include <string.h>
39 40
 #include "../dprint.h"
40
-#ifdef PARSE_URI_OLD
41
+/* #ifdef PARSE_URI_OLD */ /* ZSW */
41 42
 #include "../ut.h"   /* q_memchr */
42
-#endif
43
+/* #endif */
43 44
 #include "../error.h"
44 45
 
45 46
 /* buf= pointer to begining of uri (sip:x@foo.bar:5060;a=b?h=i)
... ...
@@ -875,70 +876,70 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
875 876
 	/* do stuff */
876 877
 	DBG("parsed uri:\n user=<%.*s>(%d)\n passwd=<%.*s>(%d)\n host=<%.*s>(%d)\n"
877 878
 			" port=<%.*s>(%d): %d\n params=<%.*s>(%d)\n headers=<%.*s>(%d)\n",
878
-			uri->user.len, uri->user.s, uri->user.len,
879
-			uri->passwd.len, uri->passwd.s, uri->passwd.len,
880
-			uri->host.len, uri->host.s, uri->host.len,
881
-			uri->port.len, uri->port.s, uri->port.len, uri->port_no,
882
-			uri->params.len, uri->params.s, uri->params.len,
883
-			uri->headers.len, uri->headers.s, uri->headers.len
879
+			uri->user.len, ZSW(uri->user.s), uri->user.len,
880
+			uri->passwd.len, ZSW(uri->passwd.s), uri->passwd.len,
881
+			uri->host.len, ZSW(uri->host.s), uri->host.len,
882
+			uri->port.len, ZSW(uri->port.s), uri->port.len, uri->port_no,
883
+			uri->params.len, ZSW(uri->params.s), uri->params.len,
884
+			uri->headers.len, ZSW(uri->headers.s), uri->headers.len
884 885
 		);
885 886
 	DBG(" uri params:\n   transport=<%.*s>, val=<%.*s>, proto=%d\n",
886
-			uri->transport.len, uri->transport.s, uri->transport_val.len,
887
+			uri->transport.len, ZSW(uri->transport.s), uri->transport_val.len,
887 888
 			uri->transport_val.s, uri->proto);
888 889
 	DBG("   user-param=<%.*s>, val=<%.*s>\n",
889
-			uri->user_param.len, uri->user_param.s, uri->user_param_val.len,
890
-			uri->user_param_val.s);
890
+			uri->user_param.len, ZSW(uri->user_param.s), 
891
+			uri->user_param_val.len, ZSW(uri->user_param_val.s));
891 892
 	DBG("   method=<%.*s>, val=<%.*s>\n",
892
-			uri->method.len, uri->method.s, uri->method_val.len,
893
-			uri->method_val.s);
893
+			uri->method.len, ZSW(uri->method.s), 
894
+			uri->method_val.len, ZSW(uri->method_val.s));
894 895
 	DBG("   ttl=<%.*s>, val=<%.*s>\n",
895
-			uri->ttl.len, uri->ttl.s, uri->ttl_val.len,
896
-			uri->ttl_val.s);
896
+			uri->ttl.len, ZSW(uri->ttl.s), 
897
+			uri->ttl_val.len, ZSW(uri->ttl_val.s));
897 898
 	DBG("   maddr=<%.*s>, val=<%.*s>\n",
898
-			uri->maddr.len, uri->maddr.s, uri->maddr_val.len,
899
-			uri->maddr_val.s);
900
-	DBG("   lr=<%.*s>\n", uri->lr.len, uri->lr.s); 
899
+			uri->maddr.len, ZSW(uri->maddr.s), 
900
+			uri->maddr_val.len, ZSW(uri->maddr_val.s));
901
+	DBG("   lr=<%.*s>\n", uri->lr.len, ZSW(uri->lr.s)); 
901 902
 	return 0;
902 903
 	
903 904
 error_too_short:
904 905
 	LOG(L_ERR, "ERROR: parse_uri: uri too short: <%.*s> (%d)\n",
905
-			len, buf, len);
906
+			len, ZSW(buf), len);
906 907
 	ser_error=E_BAD_URI;
907 908
 	return E_BAD_URI;
908 909
 error_bad_char:
909 910
 	LOG(L_ERR, "ERROR: parse_uri: bad char '%c' in state %d"
910 911
 			" parsed: <%.*s> (%d) / <%.*s> (%d)\n",
911
-			*p, state, (int)(p-buf), buf, (int)(p-buf), len, buf, len);
912
+			*p, state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
912 913
 	return E_BAD_URI;
913 914
 error_bad_host:
914 915
 	LOG(L_ERR, "ERROR: parse_uri: bad host in uri (error at char %c in"
915 916
 			" state %d) parsed: <%.*s>(%d) /<%.*s> (%d)\n",
916
-			*p, state, (int)(p-buf), buf, (int)(p-buf), len, buf, len);
917
+			*p, state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
917 918
 	ser_error=E_BAD_URI;
918 919
 	return E_BAD_URI;
919 920
 error_bad_port:
920 921
 	LOG(L_ERR, "ERROR: parse_uri: bad port in uri (error at char %c in"
921 922
 			" state %d) parsed: <%.*s>(%d) /<%.*s> (%d)\n",
922
-			*p, state, (int)(p-buf), buf, (int)(p-buf), len, buf, len);
923
+			*p, state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
923 924
 	ser_error=E_BAD_URI;
924 925
 	return E_BAD_URI;
925 926
 error_bad_uri:
926 927
 	LOG(L_ERR, "ERROR: parse_uri: bad uri,  state %d"
927 928
 			" parsed: <%.*s> (%d) / <%.*s> (%d)\n",
928
-			 state, (int)(p-buf), buf, (int)(p-buf), len, buf, len);
929
+			 state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
929 930
 	ser_error=E_BAD_URI;
930 931
 	return E_BAD_URI;
931 932
 error_headers:
932 933
 	LOG(L_ERR, "ERROR: parse_uri: bad uri headers: <%.*s>(%d)"
933 934
 			" / <%.*s>(%d)\n",
934
-			uri->headers.len, uri->headers.s, uri->headers.len,
935
-			len, buf, len);
935
+			uri->headers.len, ZSW(uri->headers.s), uri->headers.len,
936
+			len, ZSW(buf), len);
936 937
 	ser_error=E_BAD_URI;
937 938
 	return E_BAD_URI;
938 939
 error_bug:
939 940
 	LOG(L_CRIT, "BUG: parse_uri: bad  state %d"
940 941
 			" parsed: <%.*s> (%d) / <%.*s> (%d)\n",
941
-			 state, (int)(p-buf), buf, (int)(p-buf), len, buf, len);
942
+			 state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
942 943
 	ser_error=E_BAD_URI;
943 944
 	return E_BAD_URI;
944 945
 }
... ...
@@ -1073,7 +1074,7 @@ int parse_uri(char *buf, int len, struct sip_uri* uri)
1073 1074
 	if (uri->port.s) uri->port_no=str2s(uri->port.s, uri->port.len, &err);
1074 1075
 	if (err){
1075 1076
 		LOG(L_DBG, "ERROR: parse_uri: bad port number in sip uri: %.*s\n",
1076
-				uri->port.len, uri->port.s);
1077
+				uri->port.len, ZSW(uri->port.s));
1077 1078
 		ser_error=ret=E_BAD_URI;
1078 1079
 		return ret;
1079 1080
 	}
... ...
@@ -1092,7 +1093,7 @@ static inline int _parse_ruri(str *uri,
1092 1093
 
1093 1094
 	if (parse_uri(uri->s, uri->len, parsed_uri)<0) {
1094 1095
 		LOG(L_ERR, "ERROR: _parse_ruri: bad uri <%.*s>\n", 
1095
-				uri->len, uri->s);
1096
+				uri->len, ZSW(uri->s));
1096 1097
 		*status=0;
1097 1098
 		return -1;
1098 1099
 	}
... ...
@@ -41,6 +41,7 @@
41 41
  *               via->params.s (andrei)
42 42
  *  2003-01-28  zero-terminations replaced with VIA_ZT (jiri)
43 43
  *  2003-02-28 scratchpad compatibility abandoned (jiri)
44
+ *  2003-04-26 ZSW (jiri)
44 45
  */
45 46
 
46 47
 
... ...
@@ -906,7 +907,7 @@ normal_exit:
906 907
 	*pstate=state;
907 908
 	*psaved_state=saved_state;
908 909
 	DBG("Found param type %d, <%.*s> = <%.*s>; state=%d\n", param->type,
909
-			param->name.len, param->name.s, 
910
+			param->name.len, ZSW(param->name.s), 
910 911
 			(param->value.len?param->value.len:3),
911 912
 			(param->value.len?param->value.s:"n/a"), state);
912 913
 	return tmp;
... ...
@@ -925,7 +926,7 @@ normal_exit:
925 926
 	*pstate=state;
926 927
 	*psaved_state=saved_state;
927 928
 	DBG("Error on  param type %d, <%.*s>, state=%d, saved_state=%d\n",
928
-		param->type, param->name.len, param->name.s, state, saved_state);
929
+		param->type, param->name.len, ZSW(param->name.s), state, saved_state);
929 930
 
930 931
  error:
931 932
 	LOG(L_ERR, "error: parse_via_param\n");
... ...
@@ -1868,7 +1869,7 @@ endofpacket:
1868 1869
 		vb->port=str2s(vb->port_str.s, vb->port_str.len, &err);
1869 1870
 		if (err){
1870 1871
 					LOG(L_ERR, "ERROR: parse_via: invalid port number <%.*s>\n",
1871
-						vb->port_str.len, vb->port_str.s);
1872
+						vb->port_str.len, ZSW(vb->port_str.s));
1872 1873
 					goto error;
1873 1874
 		}
1874 1875
 	}
... ...
@@ -1881,7 +1882,7 @@ nextvia:
1881 1882
 		vb->port=str2s(vb->port_str.s, vb->port_str.len, &err);
1882 1883
 		if (err){
1883 1884
 					LOG(L_ERR, "ERROR: parse_via: invalid port number <%.*s>\n",
1884
-						vb->port_str.len, vb->port_str.s);
1885
+						vb->port_str.len, ZSW(vb->port_str.s));
1885 1886
 					goto error;
1886 1887
 		}
1887 1888
 	}
... ...
@@ -1897,11 +1898,11 @@ nextvia:
1897 1898
 
1898 1899
 error:
1899 1900
 	if (end>buffer){
1900
-		LOG(L_ERR, "ERROR: parse_via on: <%.*s>\n", (int)(end-buffer), buffer);
1901
+		LOG(L_ERR, "ERROR: parse_via on: <%.*s>\n", (int)(end-buffer), ZSW(buffer));
1901 1902
 	}
1902 1903
 	if ((tmp>buffer)&&(tmp<end)){
1903 1904
 		LOG(L_ERR, "ERROR: parse_via parse error, parsed so far:<%.*s>\n",
1904
-				(int)(tmp-buffer), buffer );
1905
+				(int)(tmp-buffer), ZSW(buffer) );
1905 1906
 	}else{
1906 1907
 		LOG(L_ERR, "ERROR: parse_via: via parse error\n");
1907 1908
 	}
... ...
@@ -28,13 +28,14 @@
28 28
  *
29 29
  * History
30 30
  * ------
31
- * 2003-03-30 str2int and str2float added (janakj)
32
- * 2003-02-28 scratchpad compatibility abandoned (jiri)
33
- * 2003-02-13 strlower added (janakj)
34
- * 2003-01-29 pathmax added (jiri)
35
- * 2003-01-28 scratchpad removed (jiri)
36 31
  * 2003-01-18 un_escape function introduced for convenience of code needing
37 32
  *            the complex&slow feature of unescaping
33
+ * 2003-01-28 scratchpad removed (jiri)
34
+ * 2003-01-29 pathmax added (jiri)
35
+ * 2003-02-13 strlower added (janakj)
36
+ * 2003-02-28 scratchpad compatibility abandoned (jiri)
37
+ * 2003-03-30 str2int and str2float added (janakj)
38
+ * 2003-04-26 ZSW (jiri)
38 39
  */
39 40
 
40 41
 
... ...
@@ -56,6 +57,9 @@
56 57
 
57 58
 struct sip_msg;
58 59
 
60
+/* zero-string wrapper */
61
+#define ZSW(_c) ((_c)?(_c):"")
62
+
59 63
 /* returns string beginning and length without insignificant chars */
60 64
 #define trim_len( _len, _begin, _mystr ) \
61 65
 	do{ 	static char _c; \