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 42
 #include "parse_expires.h"
43 43
 #include "parse_rr.h"
44 44
 #include "contact/parse_contact.h"
45
+#include "../ut.h"
45 46
 
46 47
 
47 48
 /* 
... ...
@@ -122,8 +124,8 @@ void dump_hdr_field( struct hdr_field* hf )
122 122
 {
123 123
 	LOG(L_ERR, "DEBUG: dump_hdr_field: type=%d, name=%.*s, "
124 124
 		"body=%.*s, parsed=%p, next=%p\n",
125
-		hf->type, hf->name.len, hf->name.s,
126
-		hf->body.len, hf->body.s,
125
+		hf->type, hf->name.len, ZSW(hf->name.s),
126
+		hf->body.len, ZSW(hf->body.s),
127 127
 		hf->parsed, hf->next );
128 128
 }
129 129
 
... ...
@@ -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 139
 			hdr->parsed=cseq_b;
140 140
 			hdr->body.len=tmp-hdr->body.s;
141 141
 			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, 
142
+					hdr->name.len, ZSW(hdr->name.s), 
143
+					cseq_b->number.len, ZSW(cseq_b->number.s), 
144 144
 					cseq_b->method.len, cseq_b->method.s);
145 145
 			break;
146 146
 		case HDR_TO:
... ...
@@ -160,9 +161,10 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
160 160
 			hdr->parsed=to_b;
161 161
 			hdr->body.len=tmp-hdr->body.s;
162 162
 			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);
163
+				hdr->name.len, ZSW(hdr->name.s), 
164
+				hdr->body.len, to_b->uri.len,ZSW(to_b->uri.s));
165
+			DBG("DEBUG: to body [%.*s]\n",to_b->body.len,
166
+				ZSW(to_b->body.s));
166 167
 			break;
167 168
 		case HDR_CONTENTLENGTH:
168 169
 			hdr->body.s=tmp;
... ...
@@ -398,8 +400,8 @@ int parse_headers(struct sip_msg* msg, int flags, int next)
398 398
 #ifdef EXTRA_DEBUG
399 399
 		DBG("header field type %d, name=<%.*s>, body=<%.*s>\n",
400 400
 			hf->type, 
401
-			hf->name.len, hf->name.s, 
402
-			hf->body.len, hf->body.s);
401
+			hf->name.len, ZSW(hf->name.s), 
402
+			hf->body.len, ZSW(hf->body.s));
403 403
 #endif
404 404
 		tmp=rest;
405 405
 	}
... ...
@@ -449,21 +451,21 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
449 449
 		case SIP_REQUEST:
450 450
 			DBG("SIP Request:\n");
451 451
 			DBG(" method:  <%.*s>\n",fl->u.request.method.len,
452
-				fl->u.request.method.s);
452
+				ZSW(fl->u.request.method.s));
453 453
 			DBG(" uri:     <%.*s>\n",fl->u.request.uri.len,
454
-				fl->u.request.uri.s);
454
+				ZSW(fl->u.request.uri.s));
455 455
 			DBG(" version: <%.*s>\n",fl->u.request.version.len,
456
-				fl->u.request.version.s);
456
+				ZSW(fl->u.request.version.s));
457 457
 			flags=HDR_VIA;
458 458
 			break;
459 459
 		case SIP_REPLY:
460 460
 			DBG("SIP Reply  (status):\n");
461 461
 			DBG(" version: <%.*s>\n",fl->u.reply.version.len,
462
-					fl->u.reply.version.s);
462
+					ZSW(fl->u.reply.version.s));
463 463
 			DBG(" status:  <%.*s>\n", fl->u.reply.status.len,
464
-					fl->u.reply.status.s);
464
+					ZSW(fl->u.reply.status.s));
465 465
 			DBG(" reason:  <%.*s>\n", fl->u.reply.reason.len,
466
-					fl->u.reply.reason.s);
466
+					ZSW(fl->u.reply.reason.s));
467 467
 			/* flags=HDR_VIA | HDR_VIA2; */
468 468
 			/* we don't try to parse VIA2 for local messages; -Jiri */
469 469
 			flags=HDR_VIA;
... ...
@@ -483,40 +485,40 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
483 483
 	if (msg->via1){
484 484
 		DBG(" first  via: <%.*s/%.*s/%.*s> <%.*s:%.*s(%d)>",
485 485
 			msg->via1->name.len, 
486
-			msg->via1->name.s, 
486
+			ZSW(msg->via1->name.s), 
487 487
 			msg->via1->version.len,
488
-			msg->via1->version.s,
488
+			ZSW(msg->via1->version.s),
489 489
 			msg->via1->transport.len,
490
-			msg->via1->transport.s, 
490
+			ZSW(msg->via1->transport.s), 
491 491
 			msg->via1->host.len,
492
-			msg->via1->host.s,
492
+			ZSW(msg->via1->host.s),
493 493
 			msg->via1->port_str.len, 
494
-			msg->via1->port_str.s, 
494
+			ZSW(msg->via1->port_str.s), 
495 495
 			msg->via1->port);
496 496
 		if (msg->via1->params.s)  DBG(";<%.*s>", 
497
-				msg->via1->params.len, msg->via1->params.s);
497
+				msg->via1->params.len, ZSW(msg->via1->params.s));
498 498
 		if (msg->via1->comment.s) 
499 499
 				DBG(" <%.*s>", 
500
-					msg->via1->comment.len, msg->via1->comment.s);
500
+					msg->via1->comment.len, ZSW(msg->via1->comment.s));
501 501
 		DBG ("\n");
502 502
 	}
503 503
 	if (msg->via2){
504 504
 		DBG(" first  via: <%.*s/%.*s/%.*s> <%.*s:%.*s(%d)>",
505 505
 			msg->via2->name.len, 
506
-			msg->via2->name.s, 
506
+			ZSW(msg->via2->name.s), 
507 507
 			msg->via2->version.len,
508
-			msg->via2->version.s,
508
+			ZSW(msg->via2->version.s),
509 509
 			msg->via2->transport.len, 
510
-			msg->via2->transport.s, 
510
+			ZSW(msg->via2->transport.s), 
511 511
 			msg->via2->host.len,
512
-			msg->via2->host.s,
512
+			ZSW(msg->via2->host.s),
513 513
 			msg->via2->port_str.len, 
514
-			msg->via2->port_str.s, 
514
+			ZSW(msg->via2->port_str.s), 
515 515
 			msg->via2->port);
516 516
 		if (msg->via2->params.s)  DBG(";<%.*s>", 
517
-				msg->via2->params.len, msg->via2->params.s);
517
+				msg->via2->params.len, ZSW(msg->via2->params.s));
518 518
 		if (msg->via2->comment.s) DBG(" <%.*s>", 
519
-				msg->via2->comment.len, msg->via2->comment.s);
519
+				msg->via2->comment.len, ZSW(msg->via2->comment.s));
520 520
 		DBG ("\n");
521 521
 	}
522 522
 #endif
... ...
@@ -530,7 +532,8 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
530 530
 	
531 531
 error:
532 532
 	/* more debugging, msg->orig is/should be null terminated*/
533
-	LOG(L_ERR, "ERROR: parse_msg: message=<%.*s>\n", (int)msg->len, msg->buf);
533
+	LOG(L_ERR, "ERROR: parse_msg: message=<%.*s>\n", 
534
+			(int)msg->len, ZSW(msg->buf));
534 535
 	return -1;
535 536
 }
536 537
 
... ...
@@ -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 38
 #include <string.h>        /* memset */
39 39
 #include "../trim.h"       /* trim_leading */
40 40
 #include <stdio.h>         /* printf */
41
+#include "../ut.h"
41 42
 
42 43
 
43 44
 #define PRES_STR "presence"
... ...
@@ -142,7 +147,7 @@ void free_event(event_t** _e)
142 142
 void print_event(event_t* _e)
143 143
 {
144 144
 	printf("===Event===\n");
145
-	printf("text  : \'%.*s\'\n", _e->text.len, _e->text.s);
145
+	printf("text  : \'%.*s\'\n", _e->text.len, ZSW(_e->text.s));
146 146
 	printf("parsed: %s\n", 
147 147
 	       (_e->parsed == EVENT_PRESENCE) ? ("EVENT_PRESENCE") : ("EVENT_OTHER"));
148 148
 	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 34
 #include "../dprint.h"
35 35
 #include "../trim.h"        /* trim_leading */
36 36
 #include <string.h>         /* memset */
37
+#include "../ut.h"
37 38
 
38 39
 
39 40
 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 134
 void print_expires(exp_body_t* _e)
135 135
 {
136 136
 	printf("===Expires===\n");
137
-	printf("text: \'%.*s\'\n", _e->text.len, _e->text.s);
137
+	printf("text: \'%.*s\'\n", _e->text.len, ZSW(_e->text.s));
138 138
 	printf("val : %d\n", _e->val);
139 139
 	printf("===/Expires===\n");
140 140
 }
... ...
@@ -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 39
 #include "msg_parser.h"
40 40
 #include "parser_f.h"
41 41
 #include "../mem/mem.h"
42
+#include "../ut.h"
42 43
 
43 44
 /* grammar:
44 45
 	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 1242
 	if (fl->type==SIP_REPLY) {
1243 1243
 		if (fl->u.request.uri.len!=3) {
1244 1244
 			LOG(L_INFO, "ERROR:parse_first_line: len(status code)!=3: %.*s\n",
1245
-				fl->u.request.uri.len, second );
1245
+				fl->u.request.uri.len, ZSW(second) );
1246 1246
 			goto error;
1247 1247
 		}
1248 1248
 		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 1252
 			fl->u.reply.statuscode=(s1-'0')*100+10*(s2-'0')+(s3-'0');
1253 1253
 		} else {
1254 1254
 			LOG(L_INFO, "ERROR:parse_first_line: status_code non-numerical: %.*s\n",
1255
-				fl->u.request.uri.len, second );
1255
+				fl->u.request.uri.len, ZSW(second) );
1256 1256
 			goto error;
1257 1257
 		}
1258 1258
 	}
... ...
@@ -1298,7 +1300,7 @@ error:
1298 1298
 		for (t=0; t<offset; t++)
1299 1299
 			if (*(buffer+t)) *(prn+t)=*(buffer+t);
1300 1300
 			else *(prn+t)='�';
1301
-		LOG(L_INFO, "ERROR: parsed so far: %.*s\n", offset, prn );
1301
+		LOG(L_INFO, "ERROR: parsed so far: %.*s\n", offset, ZSW(prn) );
1302 1302
 		pkg_free( prn );
1303 1303
 	};
1304 1304
 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 81
 void print_nameaddr(FILE* _o, name_addr_t* _a)
82 82
 {
83 83
 	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);
84
+	fprintf(_o, "name: '%.*s'\n", _a->name.len, ZSW(_a->name.s));
85
+	fprintf(_o, "uri : '%.*s'\n", _a->uri.len, ZSW(_a->uri.s));
86 86
 	fprintf(_o, "---/name-addr---\n");
87 87
 }
... ...
@@ -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 51
 
52 52
 #define add_param( _param , _body ) \
53 53
 	do{\
54
-		DBG("DEBUG: add_param: %.*s=%.*s\n",param->name.len,param->name.s,\
55
-			param->value.len,param->value.s);\
54
+		DBG("DEBUG: add_param: %.*s=%.*s\n",param->name.len,ZSW(param->name.s),\
55
+			param->value.len,ZSW(param->value.s));\
56 56
 		if (!(_body)->param_lst)  (_body)->param_lst=(_param);\
57 57
 		else (_body)->last_param->next=(_param);\
58 58
 		(_body)->last_param =(_param);\
... ...
@@ -140,7 +144,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
140 140
 					default:
141 141
 						LOG( L_ERR , "ERROR: parse_to_param : "
142 142
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
143
-							*tmp,status, (int)(tmp-buffer), buffer);
143
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
144 144
 				}
145 145
 				break;
146 146
 			case '\r':
... ...
@@ -176,7 +180,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
176 176
 					default:
177 177
 						LOG( L_ERR , "ERROR: parse_to_param : "
178 178
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
179
-							*tmp,status, (int)(tmp-buffer), buffer);
179
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
180 180
 						goto error;
181 181
 				}
182 182
 				break;
... ...
@@ -204,7 +208,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
204 204
 					default:
205 205
 						LOG( L_ERR , "ERROR: parse_to_param : "
206 206
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
207
-							*tmp,status, (int)(tmp-buffer), buffer);
207
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
208 208
 						goto error;
209 209
 				}
210 210
 				break;
... ...
@@ -223,7 +227,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
223 223
 					default:
224 224
 						LOG( L_ERR , "ERROR: parse_to_param : "
225 225
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
226
-							*tmp,status, (int)(tmp-buffer), buffer);
226
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
227 227
 						goto error;
228 228
 				}
229 229
 				break;
... ...
@@ -247,7 +251,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
247 247
 					default:
248 248
 						LOG( L_ERR , "ERROR: parse_to_param :"
249 249
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
250
-							*tmp,status,(int)(tmp-buffer), buffer);
250
+							*tmp,status,(int)(tmp-buffer), ZSW(buffer));
251 251
 						goto error;
252 252
 				}
253 253
 				break;
... ...
@@ -267,7 +271,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
267 267
 						else {
268 268
 							LOG( L_ERR , "ERROR: parse_to_param : unexpected "
269 269
 								"char [%c] in status %d: <<%.*s>> .\n",
270
-								*tmp,status, (int)(tmp-buffer), buffer);
270
+								*tmp,status, (int)(tmp-buffer), ZSW(buffer));
271 271
 							goto error;
272 272
 						}
273 273
 #endif
... ...
@@ -294,7 +298,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
294 294
 					default:
295 295
 						LOG( L_ERR , "ERROR: parse_to_param :"
296 296
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
297
-							*tmp,status, (int)(tmp-buffer), buffer);
297
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
298 298
 						goto error;
299 299
 				}
300 300
 				break;
... ...
@@ -327,7 +331,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
327 327
 					default:
328 328
 						LOG( L_ERR , "ERROR: parse_to_param :"
329 329
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
330
-							*tmp,status, (int)(tmp-buffer), buffer);
330
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
331 331
 						goto error;
332 332
 				}
333 333
 				break;
... ...
@@ -362,7 +366,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
362 362
 					default:
363 363
 						LOG( L_ERR , "ERROR: parse_to_param : "
364 364
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
365
-							*tmp,status, (int)(tmp-buffer), buffer);
365
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
366 366
 						goto error;
367 367
 				}
368 368
 				break;
... ...
@@ -397,7 +401,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
397 397
 					default:
398 398
 						LOG( L_ERR , "ERROR: parse_to_param : "
399 399
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
400
-							*tmp,status, (int)(tmp-buffer), buffer);
400
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
401 401
 						goto error;
402 402
 				}
403 403
 				break;
... ...
@@ -425,7 +429,7 @@ static /*inline*/ char* parse_to_param(char *buffer, char *end,
425 425
 					default:
426 426
 						LOG( L_ERR , "ERROR: parse_to_param : "
427 427
 							"unexpected char [%c] in status %d: <<%.*s>> .\n",
428
-							*tmp,status, (int)(tmp-buffer), buffer);
428
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
429 429
 						goto error;
430 430
 				}
431 431
 				break;
... ...
@@ -545,7 +549,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
545 545
 					default:
546 546
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
547 547
 							"in status %d: <<%.*s>> .\n",
548
-							*tmp,status, (int)(tmp-buffer), buffer);
548
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
549 549
 				}
550 550
 				break;
551 551
 			case '\r':
... ...
@@ -569,7 +573,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
569 569
 					default:
570 570
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
571 571
 							"in status %d: <<%.*s>> .\n",
572
-							*tmp,status, (int)(tmp-buffer), buffer);
572
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
573 573
 						goto error;
574 574
 				}
575 575
 				break;
... ...
@@ -585,7 +589,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
585 585
 					default:
586 586
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
587 587
 							"in status %d: <<%.*s>> .\n",
588
-							*tmp,status, (int)(tmp-buffer), buffer);
588
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
589 589
 						goto error;
590 590
 				}
591 591
 				break;
... ...
@@ -604,7 +608,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
604 604
 					default:
605 605
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
606 606
 							"in status %d: <<%.*s>> .\n",
607
-							*tmp,status, (int)(tmp-buffer), buffer);
607
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
608 608
 						goto error;
609 609
 				}
610 610
 				break;
... ...
@@ -631,7 +635,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
631 631
 					default:
632 632
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
633 633
 							"in status %d: <<%.*s>> .\n",
634
-							*tmp,status, (int)(tmp-buffer), buffer);
634
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
635 635
 						goto error;
636 636
 				}
637 637
 				break;
... ...
@@ -654,7 +658,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
654 654
 					default:
655 655
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
656 656
 							"in status %d: <<%.*s>> .\n",
657
-							*tmp,status, (int)(tmp-buffer), buffer);
657
+							*tmp,status, (int)(tmp-buffer), ZSW(buffer));
658 658
 						goto error;
659 659
 				}
660 660
 				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 875
 	/* do stuff */
876 876
 	DBG("parsed uri:\n user=<%.*s>(%d)\n passwd=<%.*s>(%d)\n host=<%.*s>(%d)\n"
877 877
 			" 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
878
+			uri->user.len, ZSW(uri->user.s), uri->user.len,
879
+			uri->passwd.len, ZSW(uri->passwd.s), uri->passwd.len,
880
+			uri->host.len, ZSW(uri->host.s), uri->host.len,
881
+			uri->port.len, ZSW(uri->port.s), uri->port.len, uri->port_no,
882
+			uri->params.len, ZSW(uri->params.s), uri->params.len,
883
+			uri->headers.len, ZSW(uri->headers.s), uri->headers.len
884 884
 		);
885 885
 	DBG(" uri params:\n   transport=<%.*s>, val=<%.*s>, proto=%d\n",
886
-			uri->transport.len, uri->transport.s, uri->transport_val.len,
886
+			uri->transport.len, ZSW(uri->transport.s), uri->transport_val.len,
887 887
 			uri->transport_val.s, uri->proto);
888 888
 	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);
889
+			uri->user_param.len, ZSW(uri->user_param.s), 
890
+			uri->user_param_val.len, ZSW(uri->user_param_val.s));
891 891
 	DBG("   method=<%.*s>, val=<%.*s>\n",
892
-			uri->method.len, uri->method.s, uri->method_val.len,
893
-			uri->method_val.s);
892
+			uri->method.len, ZSW(uri->method.s), 
893
+			uri->method_val.len, ZSW(uri->method_val.s));
894 894
 	DBG("   ttl=<%.*s>, val=<%.*s>\n",
895
-			uri->ttl.len, uri->ttl.s, uri->ttl_val.len,
896
-			uri->ttl_val.s);
895
+			uri->ttl.len, ZSW(uri->ttl.s), 
896
+			uri->ttl_val.len, ZSW(uri->ttl_val.s));
897 897
 	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); 
898
+			uri->maddr.len, ZSW(uri->maddr.s), 
899
+			uri->maddr_val.len, ZSW(uri->maddr_val.s));
900
+	DBG("   lr=<%.*s>\n", uri->lr.len, ZSW(uri->lr.s)); 
901 901
 	return 0;
902 902
 	
903 903
 error_too_short:
904 904
 	LOG(L_ERR, "ERROR: parse_uri: uri too short: <%.*s> (%d)\n",
905
-			len, buf, len);
905
+			len, ZSW(buf), len);
906 906
 	ser_error=E_BAD_URI;
907 907
 	return E_BAD_URI;
908 908
 error_bad_char:
909 909
 	LOG(L_ERR, "ERROR: parse_uri: bad char '%c' in state %d"
910 910
 			" parsed: <%.*s> (%d) / <%.*s> (%d)\n",
911
-			*p, state, (int)(p-buf), buf, (int)(p-buf), len, buf, len);
911
+			*p, state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
912 912
 	return E_BAD_URI;
913 913
 error_bad_host:
914 914
 	LOG(L_ERR, "ERROR: parse_uri: bad host in uri (error at char %c in"
915 915
 			" state %d) parsed: <%.*s>(%d) /<%.*s> (%d)\n",
916
-			*p, state, (int)(p-buf), buf, (int)(p-buf), len, buf, len);
916
+			*p, state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
917 917
 	ser_error=E_BAD_URI;
918 918
 	return E_BAD_URI;
919 919
 error_bad_port:
920 920
 	LOG(L_ERR, "ERROR: parse_uri: bad port in uri (error at char %c in"
921 921
 			" state %d) parsed: <%.*s>(%d) /<%.*s> (%d)\n",
922
-			*p, state, (int)(p-buf), buf, (int)(p-buf), len, buf, len);
922
+			*p, state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
923 923
 	ser_error=E_BAD_URI;
924 924
 	return E_BAD_URI;
925 925
 error_bad_uri:
926 926
 	LOG(L_ERR, "ERROR: parse_uri: bad uri,  state %d"
927 927
 			" parsed: <%.*s> (%d) / <%.*s> (%d)\n",
928
-			 state, (int)(p-buf), buf, (int)(p-buf), len, buf, len);
928
+			 state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
929 929
 	ser_error=E_BAD_URI;
930 930
 	return E_BAD_URI;
931 931
 error_headers:
932 932
 	LOG(L_ERR, "ERROR: parse_uri: bad uri headers: <%.*s>(%d)"
933 933
 			" / <%.*s>(%d)\n",
934
-			uri->headers.len, uri->headers.s, uri->headers.len,
935
-			len, buf, len);
934
+			uri->headers.len, ZSW(uri->headers.s), uri->headers.len,
935
+			len, ZSW(buf), len);
936 936
 	ser_error=E_BAD_URI;
937 937
 	return E_BAD_URI;
938 938
 error_bug:
939 939
 	LOG(L_CRIT, "BUG: parse_uri: bad  state %d"
940 940
 			" parsed: <%.*s> (%d) / <%.*s> (%d)\n",
941
-			 state, (int)(p-buf), buf, (int)(p-buf), len, buf, len);
941
+			 state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
942 942
 	ser_error=E_BAD_URI;
943 943
 	return E_BAD_URI;
944 944
 }
... ...
@@ -1073,7 +1074,7 @@ int parse_uri(char *buf, int len, struct sip_uri* uri)
1073 1073
 	if (uri->port.s) uri->port_no=str2s(uri->port.s, uri->port.len, &err);
1074 1074
 	if (err){
1075 1075
 		LOG(L_DBG, "ERROR: parse_uri: bad port number in sip uri: %.*s\n",
1076
-				uri->port.len, uri->port.s);
1076
+				uri->port.len, ZSW(uri->port.s));
1077 1077
 		ser_error=ret=E_BAD_URI;
1078 1078
 		return ret;
1079 1079
 	}
... ...
@@ -1092,7 +1093,7 @@ static inline int _parse_ruri(str *uri,
1092 1092
 
1093 1093
 	if (parse_uri(uri->s, uri->len, parsed_uri)<0) {
1094 1094
 		LOG(L_ERR, "ERROR: _parse_ruri: bad uri <%.*s>\n", 
1095
-				uri->len, uri->s);
1095
+				uri->len, ZSW(uri->s));
1096 1096
 		*status=0;
1097 1097
 		return -1;
1098 1098
 	}
... ...
@@ -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 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, 
909
+			param->name.len, ZSW(param->name.s), 
910 910
 			(param->value.len?param->value.len:3),
911 911
 			(param->value.len?param->value.s:"n/a"), state);
912 912
 	return tmp;
... ...
@@ -925,7 +926,7 @@ normal_exit:
925 925
 	*pstate=state;
926 926
 	*psaved_state=saved_state;
927 927
 	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);
928
+		param->type, param->name.len, ZSW(param->name.s), state, saved_state);
929 929
 
930 930
  error:
931 931
 	LOG(L_ERR, "error: parse_via_param\n");
... ...
@@ -1868,7 +1869,7 @@ endofpacket:
1868 1868
 		vb->port=str2s(vb->port_str.s, vb->port_str.len, &err);
1869 1869
 		if (err){
1870 1870
 					LOG(L_ERR, "ERROR: parse_via: invalid port number <%.*s>\n",
1871
-						vb->port_str.len, vb->port_str.s);
1871
+						vb->port_str.len, ZSW(vb->port_str.s));
1872 1872
 					goto error;
1873 1873
 		}
1874 1874
 	}
... ...
@@ -1881,7 +1882,7 @@ nextvia:
1881 1881
 		vb->port=str2s(vb->port_str.s, vb->port_str.len, &err);
1882 1882
 		if (err){
1883 1883
 					LOG(L_ERR, "ERROR: parse_via: invalid port number <%.*s>\n",
1884
-						vb->port_str.len, vb->port_str.s);
1884
+						vb->port_str.len, ZSW(vb->port_str.s));
1885 1885
 					goto error;
1886 1886
 		}
1887 1887
 	}
... ...
@@ -1897,11 +1898,11 @@ nextvia:
1897 1897
 
1898 1898
 error:
1899 1899
 	if (end>buffer){
1900
-		LOG(L_ERR, "ERROR: parse_via on: <%.*s>\n", (int)(end-buffer), buffer);
1900
+		LOG(L_ERR, "ERROR: parse_via on: <%.*s>\n", (int)(end-buffer), ZSW(buffer));
1901 1901
 	}
1902 1902
 	if ((tmp>buffer)&&(tmp<end)){
1903 1903
 		LOG(L_ERR, "ERROR: parse_via parse error, parsed so far:<%.*s>\n",
1904
-				(int)(tmp-buffer), buffer );
1904
+				(int)(tmp-buffer), ZSW(buffer) );
1905 1905
 	}else{
1906 1906
 		LOG(L_ERR, "ERROR: parse_via: via parse error\n");
1907 1907
 	}
... ...
@@ -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 56
 
57 57
 struct sip_msg;
58 58
 
59
+/* zero-string wrapper */
60
+#define ZSW(_c) ((_c)?(_c):"")
61
+
59 62
 /* returns string beginning and length without insignificant chars */
60 63
 #define trim_len( _len, _begin, _mystr ) \
61 64
 	do{ 	static char _c; \