Changeset 77
- Timestamp:
- Nov 22, 2005 11:51:50 PM (19 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/build/pjlib_util.dsp
r73 r77 42 42 # PROP Target_Dir "" 43 43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /O b2 /I "../include" /I "../../pjlib/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /c44 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /Oy /Ob2 /I "../include" /I "../../pjlib/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /c 45 45 # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 46 # ADD RSC /l 0x409 /d "NDEBUG" -
pjproject/trunk/pjlib-util/include/pjlib-util.h
- Property svn:keywords set to Id
-
pjproject/trunk/pjlib-util/include/pjlib-util/scanner.h
r73 r77 194 194 typedef struct pj_scanner 195 195 { 196 char *begin; /**< Start of input buffer. 197 char *end; /**< End of input buffer. 198 char *curptr; /**< Current pointer. 199 int line; /**< Current line.*/200 int col; /**< Current column.*/201 int skip_ws; /**< Skip whitespace flag.*/196 char *begin; /**< Start of input buffer. */ 197 char *end; /**< End of input buffer. */ 198 char *curptr; /**< Current pointer. */ 199 int line; /**< Current line. */ 200 char *start_line; /**< Where current line starts. */ 201 int skip_ws; /**< Skip whitespace flag. */ 202 202 pj_syn_err_func_ptr callback; /**< Syntax error callback. */ 203 203 } pj_scanner; … … 211 211 { 212 212 char *curptr; /**< Current scanner's pointer. */ 213 int line; /**< Current line. 214 int col; /**< Current column.*/213 int line; /**< Current line. */ 214 char *start_line; /**< Start of current line. */ 215 215 } pj_scan_state; 216 216 … … 326 326 /** 327 327 * Get characters between quotes. If current input doesn't match begin_quote, 328 * syntax error will be thrown. 328 * syntax error will be thrown. Note that the resulting string will contain 329 * the enclosing quote. 329 330 * 330 331 * @param scanner The scanner. … … 334 335 */ 335 336 PJ_DECL(void) pj_scan_get_quote( pj_scanner *scanner, 336 337 337 int begin_quote, int end_quote, 338 pj_str_t *out); 338 339 339 340 /** … … 356 357 */ 357 358 PJ_DECL(int) pj_scan_get_char( pj_scanner *scanner ); 358 359 360 /**361 * Get a newline from the scanner. A newline is defined as '\\n', or '\\r', or362 * "\\r\\n". If current input is not newline, syntax error will be thrown.363 *364 * @param scanner The scanner.365 */366 PJ_DECL(void) pj_scan_get_newline( pj_scanner *scanner );367 359 368 360 … … 439 431 PJ_DECL(int) pj_scan_stricmp( pj_scanner *scanner, const char *s, int len); 440 432 433 /** 434 * Perform case insensitive string comparison of string in current position, 435 * knowing that the string to compare only consists of alphanumeric 436 * characters. 437 * 438 * Note that unlike #pj_scan_stricmp, this function can only return zero or 439 * -1. 440 * 441 * @param scanner The scanner. 442 * @param s The string to compare with. 443 * @param len Length of the string to compare with. 444 * 445 * @return zero if equal or -1. 446 * 447 * @see strnicmp_alnum, pj_stricmp_alnum 448 */ 449 PJ_DECL(int) pj_scan_stricmp_alnum( pj_scanner *scanner, const char *s, 450 int len); 451 452 453 /** 454 * Get a newline from the scanner. A newline is defined as '\\n', or '\\r', or 455 * "\\r\\n". If current input is not newline, syntax error will be thrown. 456 * 457 * @param scanner The scanner. 458 */ 459 PJ_DECL(void) pj_scan_get_newline( pj_scanner *scanner ); 460 441 461 442 462 /** … … 448 468 PJ_DECL(void) pj_scan_skip_whitespace( pj_scanner *scanner ); 449 469 470 471 /** 472 * Skip current line. 473 * 474 * @param scanner The scanner. 475 */ 476 PJ_DECL(void) pj_scan_skip_line( pj_scanner *scanner ); 450 477 451 478 /** … … 470 497 471 498 /** 499 * Get current column position. 500 * 501 * @param scanner The scanner. 502 * 503 * @return The column position. 504 */ 505 PJ_INLINE(int) pj_scan_get_col( pj_scanner *scanner ) 506 { 507 return scanner->curptr - scanner->start_line; 508 } 509 510 /** 472 511 * @} 473 512 */ -
pjproject/trunk/pjlib-util/src/pjlib-util/scanner.c
r73 r77 24 24 #include <pj/assert.h> 25 25 26 #define PJ_SCAN_IS_SPACE(c) ((c)==' ' || (c)=='\t') 27 #define PJ_SCAN_IS_NEWLINE(c) ((c)=='\r' || (c)=='\n') 28 #define PJ_SCAN_CHECK_EOF(s) (s != end) 26 #define PJ_SCAN_IS_SPACE(c) ((c)==' ' || (c)=='\t') 27 #define PJ_SCAN_IS_NEWLINE(c) ((c)=='\r' || (c)=='\n') 28 #define PJ_SCAN_IS_PROBABLY_SPACE(c) ((c) <= 32) 29 #define PJ_SCAN_CHECK_EOF(s) (*s) 29 30 30 31 … … 108 109 scanner->end = bufstart + buflen; 109 110 scanner->line = 1; 110 scanner-> col = 1;111 scanner->start_line = scanner->begin; 111 112 scanner->callback = callback; 112 113 scanner->skip_ws = options; … … 114 115 if (scanner->skip_ws) 115 116 pj_scan_skip_whitespace(scanner); 116 117 scanner->col = scanner->curptr - scanner->begin + 1;118 117 } 119 118 … … 129 128 register char *s = scanner->curptr; 130 129 131 PJ_CHECK_STACK();132 133 130 while (PJ_SCAN_IS_SPACE(*s)) { 134 131 ++s; 135 132 } 136 133 137 if ( (scanner->skip_ws & PJ_SCAN_AUTOSKIP_NEWLINE) && PJ_SCAN_IS_NEWLINE(*s)) {134 if (PJ_SCAN_IS_NEWLINE(*s) && (scanner->skip_ws & PJ_SCAN_AUTOSKIP_NEWLINE)) { 138 135 for (;;) { 139 136 if (*s == '\r') { … … 141 138 if (*s == '\n') ++s; 142 139 ++scanner->line; 143 scanner->col = 1; 144 scanner->curptr = s; 140 scanner->curptr = scanner->start_line = s; 145 141 } else if (*s == '\n') { 146 142 ++s; 147 143 ++scanner->line; 148 scanner->col = 1; 149 scanner->curptr = s; 144 scanner->curptr = scanner->start_line = s; 150 145 } else if (PJ_SCAN_IS_SPACE(*s)) { 151 146 do { … … 160 155 if (PJ_SCAN_IS_NEWLINE(*s) && (scanner->skip_ws & PJ_SCAN_AUTOSKIP_WS_HEADER)==PJ_SCAN_AUTOSKIP_WS_HEADER) { 161 156 /* Check for header continuation. */ 162 scanner->col += s - scanner->curptr;163 157 scanner->curptr = s; 164 158 … … 169 163 ++s; 170 164 } 165 scanner->start_line = s; 166 171 167 if (PJ_SCAN_IS_SPACE(*s)) { 172 168 register char *t = s; … … 176 172 177 173 ++scanner->line; 178 scanner->col = t-s;179 174 scanner->curptr = t; 180 175 } 181 176 } else { 182 scanner->col += s - scanner->curptr;183 177 scanner->curptr = s; 178 } 179 } 180 181 PJ_DEF(void) pj_scan_skip_line( pj_scanner *scanner ) 182 { 183 char *s = pj_native_strchr(scanner->curptr, '\n'); 184 if (!s) { 185 scanner->curptr = scanner->end; 186 } else { 187 scanner->curptr = scanner->start_line = s+1; 188 scanner->line++; 189 if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) { 190 pj_scan_skip_whitespace(scanner); 191 } 184 192 } 185 193 } … … 189 197 { 190 198 register char *s = scanner->curptr; 191 register char *end = scanner->end; 192 193 PJ_CHECK_STACK(); 194 195 if (pj_scan_is_eof(scanner)) { 199 200 if (s >= scanner->end) { 196 201 pj_scan_syntax_err(scanner); 197 202 return -1; 198 203 } 199 204 200 while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s)) 201 ++s; 202 203 pj_strset3(out, scanner->curptr, s); 204 return s < scanner->end ? *s : 0; 205 /* Don't need to check EOF with PJ_SCAN_CHECK_EOF(s) */ 206 while (pj_cis_match(spec, *s)) 207 ++s; 208 209 pj_strset3(out, scanner->curptr, s); 210 return *s; 205 211 } 206 212 … … 210 216 { 211 217 char *endpos = scanner->curptr + len; 212 213 PJ_CHECK_STACK();214 218 215 219 if (endpos > scanner->end) { … … 228 232 { 229 233 register char *s = scanner->curptr; 230 register char *end = scanner->end; 231 232 PJ_CHECK_STACK(); 233 234 if (pj_scan_is_eof(scanner)) { 234 235 if (s >= scanner->end) { 235 236 pj_scan_syntax_err(scanner); 236 237 return -1; … … 241 242 242 243 pj_strset3(out, scanner->curptr, s); 243 return s!=scanner->end ? *s : 0;244 return *s; 244 245 } 245 246 … … 249 250 { 250 251 register char *s = scanner->curptr; 251 register char *end = scanner->end;252 char *start = s;253 254 PJ_CHECK_STACK();255 252 256 253 pj_assert(pj_cis_match(spec,0)==0); 257 254 258 if (pj_scan_is_eof(scanner) || !pj_cis_match(spec, *s)) { 255 /* EOF is detected implicitly */ 256 if (!pj_cis_match(spec, *s)) { 259 257 pj_scan_syntax_err(scanner); 260 258 return; … … 271 269 pj_strset3(out, scanner->curptr, s); 272 270 273 scanner->col += (s - start);274 271 scanner->curptr = s; 275 272 276 if ( scanner->skip_ws) {273 if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) { 277 274 pj_scan_skip_whitespace(scanner); 278 275 } … … 285 282 { 286 283 register char *s = scanner->curptr; 287 register char *end = scanner->end;288 char *start = s;289 284 290 PJ_CHECK_STACK();291 292 285 /* Check and eat the begin_quote. */ 293 286 if (*s != begin_quote) { … … 301 294 do { 302 295 /* loop until end_quote is found. */ 303 do{296 while (*s && *s != '\n' && *s != end_quote) { 304 297 ++s; 305 } while (s != end && *s != '\n' && *s != end_quote);298 } 306 299 307 300 /* check that no backslash character precedes the end_quote. */ … … 319 312 /* break from main loop if we have odd number of backslashes */ 320 313 if (((unsigned)(q-r) & 0x01) == 1) { 314 ++s; 321 315 break; 322 316 } 317 ++s; 323 318 } 324 319 } else { … … 341 336 pj_strset3(out, scanner->curptr, s); 342 337 343 scanner->col += (s - start);344 338 scanner->curptr = s; 345 339 346 if ( scanner->skip_ws) {340 if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) { 347 341 pj_scan_skip_whitespace(scanner); 348 342 } … … 350 344 351 345 PJ_DEF(void) pj_scan_get_n( pj_scanner *scanner, 352 unsigned N, pj_str_t *out) 353 { 354 register char *s = scanner->curptr; 355 char *start = scanner->curptr; 356 357 PJ_CHECK_STACK(); 358 346 unsigned N, pj_str_t *out) 347 { 359 348 if (scanner->curptr + N > scanner->end) { 360 349 pj_scan_syntax_err(scanner); … … 362 351 } 363 352 364 pj_strset(out, s , N);353 pj_strset(out, scanner->curptr, N); 365 354 366 s += N; 367 scanner->col += (s - start); 368 scanner->curptr = s; 369 370 if (scanner->skip_ws) { 355 scanner->curptr += N; 356 357 if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) { 371 358 pj_scan_skip_whitespace(scanner); 372 359 } … … 376 363 PJ_DEF(int) pj_scan_get_char( pj_scanner *scanner ) 377 364 { 378 char *start = scanner->curptr; 379 int chr = *start; 380 381 PJ_CHECK_STACK(); 382 383 if (pj_scan_is_eof(scanner)) { 365 int chr = *scanner->curptr; 366 367 if (!chr) { 384 368 pj_scan_syntax_err(scanner); 385 369 return 0; … … 387 371 388 372 ++scanner->curptr; 389 scanner->col += (scanner->curptr - start); 390 391 if (scanner->skip_ws) { 373 374 if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) { 392 375 pj_scan_skip_whitespace(scanner); 393 376 } … … 398 381 PJ_DEF(void) pj_scan_get_newline( pj_scanner *scanner ) 399 382 { 400 PJ_CHECK_STACK();401 402 383 if (!PJ_SCAN_IS_NEWLINE(*scanner->curptr)) { 403 384 pj_scan_syntax_err(scanner); … … 413 394 414 395 ++scanner->line; 415 scanner-> col = 1;416 417 if ( scanner->skip_ws) {396 scanner->start_line = scanner->curptr; 397 398 if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) { 418 399 pj_scan_skip_whitespace(scanner); 419 400 } … … 425 406 { 426 407 register char *s = scanner->curptr; 427 register char *end = scanner->end; 428 char *start = s; 429 430 PJ_CHECK_STACK(); 431 432 if (pj_scan_is_eof(scanner)) { 408 409 if (s >= scanner->end) { 433 410 pj_scan_syntax_err(scanner); 434 411 return; … … 441 418 pj_strset3(out, scanner->curptr, s); 442 419 443 scanner->col += (s - start);444 420 scanner->curptr = s; 445 421 446 if ( scanner->skip_ws) {422 if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) { 447 423 pj_scan_skip_whitespace(scanner); 448 424 } … … 454 430 { 455 431 register char *s = scanner->curptr; 456 register char *end = scanner->end; 457 char *start = s; 458 459 PJ_CHECK_STACK(); 460 461 if (pj_scan_is_eof(scanner)) { 432 433 if (s >= scanner->end) { 462 434 pj_scan_syntax_err(scanner); 463 435 return; … … 470 442 pj_strset3(out, scanner->curptr, s); 471 443 472 scanner->col += (s - start);473 444 scanner->curptr = s; 474 445 475 if ( scanner->skip_ws) {446 if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) { 476 447 pj_scan_skip_whitespace(scanner); 477 448 } … … 483 454 { 484 455 register char *s = scanner->curptr; 485 register char *end = scanner->end; 486 char *start = scanner->curptr; 487 488 PJ_CHECK_STACK(); 489 490 if (pj_scan_is_eof(scanner)) { 491 pj_scan_syntax_err(scanner); 492 return; 493 } 494 495 while (PJ_SCAN_CHECK_EOF(s) && !strchr(until_spec, *s)) { 496 ++s; 497 } 498 499 pj_strset3(out, scanner->curptr, s); 500 501 scanner->col += (s - start); 456 int speclen; 457 458 if (s >= scanner->end) { 459 pj_scan_syntax_err(scanner); 460 return; 461 } 462 463 speclen = strlen(until_spec); 464 while (PJ_SCAN_CHECK_EOF(s) && !memchr(until_spec, *s, speclen)) { 465 ++s; 466 } 467 468 pj_strset3(out, scanner->curptr, s); 469 502 470 scanner->curptr = s; 503 471 504 if ( scanner->skip_ws) {472 if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) { 505 473 pj_scan_skip_whitespace(scanner); 506 474 } … … 512 480 char *start = scanner->curptr; 513 481 514 PJ_CHECK_STACK();515 516 482 if (scanner->curptr + N > scanner->end) { 517 483 pj_scan_syntax_err(scanner); … … 520 486 521 487 scanner->curptr += N; 522 scanner->col += (scanner->curptr - start); 523 524 if (skip_ws) { 488 489 if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && skip_ws) { 525 490 pj_scan_skip_whitespace(scanner); 526 491 } … … 547 512 } 548 513 514 PJ_DEF(int) pj_scan_stricmp_alnum( pj_scanner *scanner, const char *s, 515 int len) 516 { 517 if (scanner->curptr + len > scanner->end) { 518 pj_scan_syntax_err(scanner); 519 return -1; 520 } 521 return strnicmp_alnum(scanner->curptr, s, len); 522 } 549 523 550 524 PJ_DEF(void) pj_scan_save_state( pj_scanner *scanner, pj_scan_state *state) 551 525 { 552 PJ_CHECK_STACK();553 554 526 state->curptr = scanner->curptr; 555 527 state->line = scanner->line; 556 state-> col = scanner->col;528 state->start_line = scanner->start_line; 557 529 } 558 530 … … 561 533 pj_scan_state *state) 562 534 { 563 PJ_CHECK_STACK();564 565 535 scanner->curptr = state->curptr; 566 536 scanner->line = state->line; 567 scanner-> col = state->col;568 } 569 570 537 scanner->start_line = state->start_line; 538 } 539 540 -
pjproject/trunk/pjlib-util/src/pjlib-util/xml.c
r73 r77 174 174 PJ_CATCH_ANY { 175 175 PJ_LOG(4,(THIS_FILE, "Syntax error parsing XML in line %d column %d", 176 scanner.line, scanner.col));176 scanner.line, pj_scan_get_col(&scanner))); 177 177 } 178 178 PJ_END; -
pjproject/trunk/pjlib/include/pj/string.h
r72 r77 343 343 * Perform lowercase comparison to the strings which consists of only 344 344 * alnum characters. More over, it will only return non-zero if both 345 * strings are not equal, and is not able to detect which string is 346 * 'less'. 345 * strings are not equal, not the usual negative or positive value. 347 346 * 348 347 * If non-alnum inputs are given, then the function may mistakenly 349 * treat two strings as equal while they're not. 348 * treat two strings as equal. 349 * 350 * @param str1 The string to compare. 351 * @param str2 The string to compare. 352 * @param len The length to compare. 353 * 354 * @return 355 * - 0 if str1 is equal to str2 356 * - (-1) if not equal. 357 */ 358 PJ_IDECL(int) strnicmp_alnum(const char *str1, const char *str2, 359 int len); 360 361 /** 362 * Perform lowercase comparison to the strings which consists of only 363 * alnum characters. More over, it will only return non-zero if both 364 * strings are not equal, not the usual negative or positive value. 365 * 366 * If non-alnum inputs are given, then the function may mistakenly 367 * treat two strings as equal. 350 368 * 351 369 * @param str1 The string to compare. -
pjproject/trunk/pjlib/include/pj/string_i.h
r72 r77 170 170 } 171 171 172 PJ_IDEF(int) strnicmp_alnum( const char *str1, const char *str2, 173 int len) 174 { 175 if (len==0) 176 return 0; 177 else { 178 register const pj_uint32_t *p1 = (pj_uint32_t*)str1, 179 *p2 = (pj_uint32_t*)str2; 180 while (len > 3 && (*p1 & 0x5F5F5F5F)==(*p2 & 0x5F5F5F5F)) 181 ++p1, ++p2, len-=4; 182 183 if (len > 3) 184 return -1; 185 #if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0 186 else if (len==3) 187 return ((*p1 & 0x005F5F5F)==(*p2 & 0x005F5F5F)) ? 0 : -1; 188 else if (len==2) 189 return ((*p1 & 0x00005F5F)==(*p2 & 0x00005F5F)) ? 0 : -1; 190 else if (len==1) 191 return ((*p1 & 0x0000005F)==(*p2 & 0x0000005F)) ? 0 : -1; 192 #else 193 else if (len==3) 194 return ((*p1 & 0x5F5F5F00)==(*p2 & 0x5F5F5F00)) ? 0 : -1; 195 else if (len==2) 196 return ((*p1 & 0x5F5F0000)==(*p2 & 0x5F5F0000)) ? 0 : -1; 197 else if (len==1) 198 return ((*p1 & 0x5F000000)==(*p2 & 0x5F000000)) ? 0 : -1; 199 #endif 200 else 201 return 0; 202 } 203 } 204 172 205 PJ_IDEF(int) pj_stricmp_alnum(const pj_str_t *str1, const pj_str_t *str2) 173 206 { … … 181 214 register const pj_uint32_t *p1 = (pj_uint32_t*)str1->ptr, 182 215 *p2 = (pj_uint32_t*)str2->ptr; 183 while (len > 3 && (*p1 & 0x 1F1F1F1F)==(*p2 & 0x1F1F1F1F))216 while (len > 3 && (*p1 & 0x5F5F5F5F)==(*p2 & 0x5F5F5F5F)) 184 217 ++p1, ++p2, len-=4; 185 218 … … 188 221 #if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0 189 222 else if (len==3) 190 return ((*p1 & 0x00 1F1F1F)==(*p2 & 0x001F1F1F)) ? 0 : -1;191 else if (len==2) 192 return ((*p1 & 0x0000 1F1F)==(*p2 & 0x00001F1F)) ? 0 : -1;193 else if (len==1) 194 return ((*p1 & 0x000000 1F)==(*p2 & 0x0000001F)) ? 0 : -1;223 return ((*p1 & 0x005F5F5F)==(*p2 & 0x005F5F5F)) ? 0 : -1; 224 else if (len==2) 225 return ((*p1 & 0x00005F5F)==(*p2 & 0x00005F5F)) ? 0 : -1; 226 else if (len==1) 227 return ((*p1 & 0x0000005F)==(*p2 & 0x0000005F)) ? 0 : -1; 195 228 #else 196 229 else if (len==3) 197 return ((*p1 & 0x 1F1F1F00)==(*p2 & 0x1F1F1F00)) ? 0 : -1;198 else if (len==2) 199 return ((*p1 & 0x 1F1F0000)==(*p2 & 0x1F1F0000)) ? 0 : -1;200 else if (len==1) 201 return ((*p1 & 0x 1F000000)==(*p2 & 0x1F000000)) ? 0 : -1;230 return ((*p1 & 0x5F5F5F00)==(*p2 & 0x5F5F5F00)) ? 0 : -1; 231 else if (len==2) 232 return ((*p1 & 0x5F5F0000)==(*p2 & 0x5F5F0000)) ? 0 : -1; 233 else if (len==1) 234 return ((*p1 & 0x5F000000)==(*p2 & 0x5F000000)) ? 0 : -1; 202 235 #endif 203 236 else -
pjproject/trunk/pjlib/src/pjlib-test/string.c
r72 r77 104 104 STRTEST( 0, "a",buf+0,-510); 105 105 STRTEST( 0, "a",buf+1,-512); 106 STRTEST( -1, "0", "P", -514); 106 107 107 108 /* equal, length=2 -
pjproject/trunk/pjsip/build/pjsip_core.dsp
r65 r77 42 42 # PROP Target_Dir "" 43 43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 # ADD CPP /nologo /MD /W4 /Zi /O2 / I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /c44 # ADD CPP /nologo /MD /W4 /Zi /O2 /Oy /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /c 45 45 # SUBTRACT CPP /YX 46 46 # ADD BASE RSC /l 0x409 /d "NDEBUG" -
pjproject/trunk/pjsip/include/pjsip/print_util.h
r65 r77 20 20 #define __PJSIP_PRINT_H__ 21 21 22 /* Minimum space left in the buffer */23 #define MIN_SPACE 1024 25 22 #define copy_advance_check(buf,str) \ 26 23 do { \ 27 if ((str).slen +MIN_SPACE>= (endbuf-buf)) return -1; \24 if ((str).slen >= (endbuf-buf)) return -1; \ 28 25 pj_memcpy(buf, (str).ptr, (str).slen); \ 29 26 buf += (str).slen; \ 30 27 } while (0) 31 32 /*33 static char *imp_copy_advance_pair(char *buf, char *endbuf, const char *str1, int len1, const pj_str_t *str2)34 {35 if (str2->slen) {36 int printed = len1+str2->slen;37 if (printed+MIN_SPACE >= (endbuf-buf)) return NULL;38 pj_memcpy(buf,str1,len1);39 pj_memcpy(buf+len1, str2->ptr, str2->slen);40 return buf + printed;41 } else42 return buf;43 }44 */45 28 46 29 #define copy_advance_pair_check(buf,str1,len1,str2) \ … … 48 31 if (str2.slen) { \ 49 32 printed = len1+str2.slen; \ 50 if (printed +MIN_SPACE>= (endbuf-buf)) return -1; \33 if (printed >= (endbuf-buf)) return -1; \ 51 34 pj_memcpy(buf,str1,len1); \ 52 35 pj_memcpy(buf+len1, str2.ptr, str2.slen); \ … … 54 37 } \ 55 38 } while (0) 56 /*57 #define copy_advance_pair(buf,str1,len1,str2) \58 do { \59 buf = imp_copy_advance_pair(buf, endbuf, str1, len1, &str2); \60 if (buf == NULL) return -1; \61 } while (0)62 */63 39 64 40 #define copy_advance_pair_quote_check(buf,str1,len1,str2,quotebegin,quoteend) \ … … 66 42 if (str2.slen) { \ 67 43 printed = len1+str2.slen+2; \ 68 if (printed +MIN_SPACE>= (endbuf-buf)) return -1; \44 if (printed >= (endbuf-buf)) return -1; \ 69 45 pj_memcpy(buf,str1,len1); \ 70 46 *(buf+len1)=quotebegin; \ … … 77 53 #define copy_advance_pair_escape(buf,str1,len1,str2,unres) \ 78 54 do { \ 79 if (str2.slen) { \ 80 pj_ssize_t esc_len; \ 81 if (len1+str2.slen+MIN_SPACE >= (endbuf-buf)) return -1; \ 82 pj_memcpy(buf,str1,len1); \ 83 buf += len1; \ 84 esc_len=pj_strncpy2_escape(buf, &str2, (endbuf-buf), &unres); \ 85 if (esc_len < 0) return -1; \ 86 buf += esc_len; \ 87 if (endbuf-buf < MIN_SPACE) return -1; \ 88 } \ 55 if (str2.slen) { \ 56 if (len1+str2.slen >= (endbuf-buf)) return -1; \ 57 pj_memcpy(buf,str1,len1); \ 58 printed=pj_strncpy2_escape(buf,&str2,(endbuf-buf-len1),&unres);\ 59 if (printed < 0) return -1; \ 60 buf += (printed+len1); \ 61 } \ 89 62 } while (0) 90 63 … … 98 71 #define copy_advance_escape(buf,str,unres) \ 99 72 do { \ 100 p j_ssize_t len= \73 printed = \ 101 74 pj_strncpy2_escape(buf, &(str), (endbuf-buf), &(unres)); \ 102 if (len < 0) return -1; \ 103 buf += len; \ 104 if (endbuf-buf < MIN_SPACE) return -1; \ 75 if (printed < 0) return -1; \ 76 buf += printed; \ 105 77 } while (0) 106 78 … … 118 90 #define copy_advance_pair_quote_cond(buf,str1,len1,str2,quotebegin,quoteend) \ 119 91 do { \ 120 121 122 123 92 if (str2.slen && *str2.ptr!=quotebegin) \ 93 copy_advance_pair_quote(buf,str1,len1,str2,quotebegin,quoteend); \ 94 else \ 95 copy_advance_pair(buf,str1,len1,str2); \ 124 96 } while (0) 125 97 -
pjproject/trunk/pjsip/include/pjsip/sip_parser.h
r76 r77 308 308 pjsip_PASSWD_SPEC, /**< Password. */ 309 309 pjsip_USER_SPEC, /**< User */ 310 pjsip_NEWLINE_OR_EOF_SPEC, /**< For eating up header.*/ 311 pjsip_DISPLAY_SCAN_SPEC; /**< Used when searching for display name. */ 310 pjsip_NOT_NEWLINE, /**< For eating up header, basicly any chars 311 except newlines or zero. */ 312 pjsip_NOT_COMMA_OR_NEWLINE, /**< Array elements. */ 313 pjsip_DISPLAY_SPEC; /**< Used when searching for display name. */ 312 314 313 315 /* -
pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
r65 r77 105 105 pj_status_t, pjsip_rx_data*); 106 106 107 void init_sip_parser(void); 107 108 108 109 /* … … 373 374 endpt->pool = pool; 374 375 endpt->pf = pf; 376 377 /* Init parser. */ 378 init_sip_parser(); 375 379 376 380 /* Get name. */ -
pjproject/trunk/pjsip/src/pjsip/sip_parser.c
r76 r77 66 66 static int parser_is_initialized; 67 67 68 69 68 /* 70 69 * Global vars (also extern). … … 102 101 pjsip_PASSWD_SPEC, /* Password. */ 103 102 pjsip_USER_SPEC, /* User */ 104 pjsip_ ARRAY_ELEMENTS,/* Array separator. */105 pjsip_N EWLINE_OR_EOF_SPEC,/* For eating up header.*/106 pjsip_DISPLAY_S CAN_SPEC;/* Used when searching for display name103 pjsip_NOT_COMMA_OR_NEWLINE, /* Array separator. */ 104 pjsip_NOT_NEWLINE, /* For eating up header.*/ 105 pjsip_DISPLAY_SPEC; /* Used when searching for display name 107 106 * in URL. */ 108 107 … … 259 258 pj_cis_add_num( &pjsip_ALNUM_SPEC ); 260 259 261 status = pj_cis_init(&cis_buf, &pjsip_NEWLINE_OR_EOF_SPEC); 262 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 263 pj_cis_add_str(&pjsip_NEWLINE_OR_EOF_SPEC, "\r\n"); 264 //pj_cs_set(pjsip_NEWLINE_OR_EOF_SPEC, 0); 265 266 status = pj_cis_init(&cis_buf, &pjsip_ARRAY_ELEMENTS); 267 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 268 pj_cis_add_str( &pjsip_ARRAY_ELEMENTS, ",\r\n"); 260 status = pj_cis_init(&cis_buf, &pjsip_NOT_NEWLINE); 261 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 262 pj_cis_add_str(&pjsip_NOT_NEWLINE, "\r\n"); 263 pj_cis_invert(&pjsip_NOT_NEWLINE); 264 265 status = pj_cis_init(&cis_buf, &pjsip_NOT_COMMA_OR_NEWLINE); 266 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 267 pj_cis_add_str( &pjsip_NOT_COMMA_OR_NEWLINE, ",\r\n"); 268 pj_cis_invert(&pjsip_NOT_COMMA_OR_NEWLINE); 269 269 270 270 status = pj_cis_dup(&pjsip_TOKEN_SPEC, &pjsip_ALNUM_SPEC); … … 301 301 pj_cis_invert( &pjsip_PROBE_USER_HOST_SPEC ); 302 302 303 status = pj_cis_init(&cis_buf, &pjsip_DISPLAY_SCAN_SPEC); 304 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 305 pj_cis_add_str( &pjsip_DISPLAY_SCAN_SPEC, ":\r\n<"); 303 status = pj_cis_init(&cis_buf, &pjsip_DISPLAY_SPEC); 304 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 305 pj_cis_add_str( &pjsip_DISPLAY_SPEC, ":\r\n<"); 306 pj_cis_invert(&pjsip_DISPLAY_SPEC); 306 307 307 308 status = pjsip_register_hdr_parser( "Accept", NULL, &parse_hdr_accept); … … 375 376 } 376 377 377 staticvoid init_sip_parser(void)378 void init_sip_parser(void) 378 379 { 379 380 if (!parser_is_initialized) { … … 393 394 * - >0 if handler is 'greater' than header name. 394 395 */ 395 static intcompare_handler( const handler_rec *r1,396 PJ_INLINE(int) compare_handler( const handler_rec *r1, 396 397 const char *name, 397 398 pj_size_t name_len, 398 399 pj_uint32_t hash ) 399 400 { 401 PJ_UNUSED_ARG(name_len); 402 403 /* Compare hashed value. */ 404 if (r1->hname_hash < hash) 405 return -1; 406 if (r1->hname_hash > hash) 407 return 1; 408 400 409 /* Compare length. */ 410 /* 401 411 if (r1->hname_len < name_len) 402 412 return -1; 403 413 if (r1->hname_len > name_len) 404 414 return 1; 405 406 /* Length is equal, compare hashed value. */ 407 if (r1->hname_hash < hash) 408 return -1; 409 if (r1->hname_hash > hash) 410 return 1; 415 */ 411 416 412 417 /* Equal length and equal hash. compare the strings. */ … … 610 615 611 616 /* Find the end of header area by finding an empty line. */ 612 if ((pos = pj_native_strstr(buf, "\n\r\n")) == NULL) { 617 pos = pj_native_strstr(buf, "\n\r\n"); 618 if (pos == NULL) { 613 619 return PJSIP_EPARTIALMSG; 614 620 } 615 621 616 622 hdr_end = pos+1; 617 623 body_start = pos+3; … … 619 625 /* Find "Content-Length" header the hard way. */ 620 626 line = pj_native_strchr(buf, '\n'); 621 while (line && line < hdr_end -14) {627 while (line && line < hdr_end) { 622 628 ++line; 623 629 if ( ((*line=='C' || *line=='c') && 624 pj_native_strncasecmp(line, "Content-Length", 14) == 0) ||630 strnicmp_alnum(line, "Content-Length", 14) == 0) || 625 631 ((*line=='l' || *line=='L') && 626 632 (*(line+1)==' ' || *(line+1)=='\t' || *(line+1)==':'))) … … 745 751 pjsip_parser_err_report *err_list) 746 752 { 747 int ch;748 753 pjsip_msg *msg; 754 pj_str_t hname; 749 755 pjsip_ctype_hdr *ctype_hdr = NULL; 750 756 pj_scanner *scanner = ctx->scanner; … … 753 759 754 760 /* Skip leading newlines. */ 755 ch = *scanner->curptr; 756 while (ch=='\r' || ch=='\n') { 757 pj_scan_get_char(scanner); 758 ch = *scanner->curptr; 761 while (*scanner->curptr=='\r' || *scanner->curptr=='\n') { 762 pj_scan_get_newline(scanner); 759 763 } 760 764 761 765 /* Parse request or status line */ 762 if (pj_scan_stricmp ( scanner, PJSIP_VERSION, 7) == 0) {766 if (pj_scan_stricmp_alnum( scanner, PJSIP_VERSION, 7) == 0) { 763 767 msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG); 764 768 int_parse_status_line( scanner, &msg->line.status ); … … 769 773 770 774 /* Parse headers. */ 771 do { 772 pj_str_t hname; 773 pjsip_parse_hdr_func * handler; 774 pjsip_hdr *hdr = NULL; 775 776 /* Get hname. */ 777 pj_scan_get( scanner, &pjsip_TOKEN_SPEC, &hname); 778 ch = pj_scan_get_char( scanner ); 779 if (ch != ':') { 780 PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); 781 } 782 783 /* Find handler. */ 784 handler = find_handler(&hname); 785 786 PJ_TRY { 775 parse_headers: 776 777 PJ_TRY 778 { 779 do { 780 pjsip_parse_hdr_func * handler; 781 pjsip_hdr *hdr = NULL; 782 783 /* Get hname. */ 784 pj_scan_get( scanner, &pjsip_TOKEN_SPEC, &hname); 785 if (pj_scan_get_char( scanner ) != ':') { 786 PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); 787 } 788 789 /* Find handler. */ 790 handler = find_handler(&hname); 791 787 792 /* Call the handler if found. 788 793 * If no handler is found, then treat the header as generic … … 796 801 hdr->name = hdr->sname = hname; 797 802 } 798 803 799 804 /* Check if we've just parsed a Content-Type header. 800 * We will check for a message body if we've got Content-Type header. 805 * We will check for a message body if we've got Content-Type 806 * header. 801 807 */ 802 808 if (hdr->type == PJSIP_H_CONTENT_TYPE) { 803 809 ctype_hdr = (pjsip_ctype_hdr*)hdr; 804 810 } 805 806 }807 PJ_CATCH_ANY {808 /* Exception was thrown during parsing.809 * Skip until newline, and parse next header.810 */811 pj_str_t token;812 hdr = NULL;813 814 //PJ_LOG(4,("sipparser",815 // "Syntax error in line %d col %d (hname=%.*s)",816 // scanner->line, scanner->col, hname.slen, hname.ptr));817 818 if (err_list) {819 pjsip_parser_err_report *err_info;820 811 821 err_info = pj_pool_alloc(pool, sizeof(*err_info));822 err_info->except_code = PJ_GET_EXCEPTION();823 err_info->line = scanner->line;824 err_info->col = scanner->col;825 err_info->hname = hname;826 827 pj_list_insert_before(err_list, err_info);828 }829 830 if (!pj_scan_is_eof(scanner)) {831 pj_scan_get_until(scanner, &pjsip_NEWLINE_OR_EOF_SPEC, &token);832 parse_hdr_end(scanner);833 }834 }835 PJ_END;836 837 if (hdr) {838 812 /* Single parse of header line can produce multiple headers. 839 813 * For example, if one Contact: header contains Contact list … … 843 817 */ 844 818 pj_list_insert_nodes_before(&msg->hdr, hdr); 845 } 846 847 /* Parse until EOF or an empty line is found. */ 848 } while (!pj_scan_is_eof(scanner) && 849 *scanner->curptr != '\r' && *scanner->curptr != '\n'); 819 820 /* Parse until EOF or an empty line is found. */ 821 } while (!pj_scan_is_eof(scanner) && 822 *scanner->curptr != '\r' && *scanner->curptr != '\n'); 823 824 } 825 PJ_CATCH_ANY 826 { 827 /* Exception was thrown during parsing. 828 * Skip until newline, and parse next header. 829 */ 830 pj_str_t token; 831 832 if (err_list) { 833 pjsip_parser_err_report *err_info; 834 835 err_info = pj_pool_alloc(pool, sizeof(*err_info)); 836 err_info->except_code = PJ_GET_EXCEPTION(); 837 err_info->line = scanner->line; 838 err_info->col = pj_scan_get_col(scanner); 839 err_info->hname = hname; 840 841 pj_list_insert_before(err_list, err_info); 842 } 843 844 if (!pj_scan_is_eof(scanner)) { 845 pj_scan_get(scanner, &pjsip_NOT_NEWLINE, &token); 846 parse_hdr_end(scanner); 847 } 848 849 if (!pj_scan_is_eof(scanner) && 850 *scanner->curptr != '\r' && *scanner->curptr != '\n'); 851 { 852 goto parse_headers; 853 } 854 } 855 PJ_END; 856 850 857 851 858 /* If empty line is found, eat it. */ … … 859 866 if (ctype_hdr && scanner->curptr!=scanner->end) { 860 867 pjsip_msg_body *body = pj_pool_alloc(pool, sizeof(pjsip_msg_body)); 861 pj_strdup(pool, &body->content_type.type, &ctype_hdr->media.type); 862 pj_strdup(pool, &body->content_type.subtype, &ctype_hdr->media.subtype); 863 pj_strdup(pool, &body->content_type.param, &ctype_hdr->media.param); 868 body->content_type.type = ctype_hdr->media.type; 869 body->content_type.subtype = ctype_hdr->media.subtype; 870 body->content_type.param = ctype_hdr->media.param; 871 864 872 body->data = scanner->curptr; 865 873 body->len = scanner->end - scanner->curptr; … … 1002 1010 is_name_addr = 1; 1003 1011 } else { 1004 pj_scan_state backtrack;1005 1012 pj_str_t scheme; 1006 int colon; 1007 1008 pj_scan_save_state( scanner, &backtrack); 1009 pj_scan_get( scanner, &pjsip_TOKEN_SPEC, &scheme); 1010 colon = pj_scan_get_char( scanner ); 1011 pj_scan_restore_state( scanner, &backtrack); 1012 1013 if (colon==':' && 1013 int next_ch; 1014 1015 next_ch = pj_scan_peek( scanner, &pjsip_DISPLAY_SPEC, &scheme); 1016 1017 if (next_ch==':' && 1014 1018 (parser_stricmp(scheme, pjsip_SIP_STR)==0 || 1015 1019 parser_stricmp(scheme, pjsip_SIPS_STR)==0)) … … 1019 1023 (opt & PJSIP_PARSE_URI_IN_FROM_TO_HDR)== 0); 1020 1024 1021 } else if ( colon==':' && parser_stricmp( scheme, pjsip_TEL_STR)==0) {1025 } else if (next_ch==':') { 1022 1026 1023 1027 /* Not supported. */ … … 1190 1194 * will be parser later. 1191 1195 */ 1192 next = pj_scan_peek _until(scanner, &pjsip_DISPLAY_SCAN_SPEC, &dummy);1196 next = pj_scan_peek(scanner, &pjsip_DISPLAY_SPEC, &dummy); 1193 1197 if (next == '<') { 1194 1198 /* Ok, this is what we're looking for, a display name. */ … … 1206 1210 pj_scan_get_char(scanner); 1207 1211 name_addr->uri = int_parse_uri( scanner, pool, PJ_TRUE ); 1208 if (has_bracket) 1209 pj_scan_get_char(scanner); 1212 if (has_bracket) { 1213 if (pj_scan_get_char(scanner) != '>') 1214 PJ_THROW( PJSIP_SYN_ERR_EXCEPTION); 1215 } 1210 1216 1211 1217 return name_addr; … … 1223 1229 1224 1230 req_line->uri = int_parse_uri(scanner, pool, PJ_TRUE); 1225 if (pj_scan_stricmp ( scanner, PJSIP_VERSION, 7) != 0)1231 if (pj_scan_stricmp_alnum( scanner, PJSIP_VERSION, 7) != 0) 1226 1232 PJ_THROW( PJSIP_SYN_ERR_EXCEPTION); 1227 1233 pj_scan_advance_n (scanner, 7, 1); … … 1235 1241 pj_str_t token; 1236 1242 1237 if (pj_scan_stricmp (scanner, PJSIP_VERSION, 7) != 0)1243 if (pj_scan_stricmp_alnum(scanner, PJSIP_VERSION, 7) != 0) 1238 1244 PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); 1239 1245 pj_scan_advance_n( scanner, 7, 1); … … 1241 1247 pj_scan_get( scanner, &pjsip_DIGIT_SPEC, &token); 1242 1248 status_line->code = pj_strtoul(&token); 1243 pj_scan_get_until( scanner, &pjsip_NEWLINE_OR_EOF_SPEC, 1244 &status_line->reason); 1249 pj_scan_get( scanner, &pjsip_NOT_NEWLINE, &status_line->reason); 1245 1250 pj_scan_get_newline( scanner ); 1246 1251 } … … 1268 1273 pj_scanner *scanner) 1269 1274 { 1270 pj_scan_get _until( scanner, &pjsip_ARRAY_ELEMENTS, &hdr->values[0]);1275 pj_scan_get( scanner, &pjsip_NOT_COMMA_OR_NEWLINE, &hdr->values[0]); 1271 1276 hdr->count++; 1272 1277 1273 1278 while (*scanner->curptr == ',') { 1274 1279 pj_scan_get_char(scanner); 1275 pj_scan_get _until( scanner, &pjsip_ARRAY_ELEMENTS,1276 1280 pj_scan_get( scanner, &pjsip_NOT_COMMA_OR_NEWLINE, 1281 &hdr->values[hdr->count]); 1277 1282 hdr->count++; 1278 1283 } … … 1284 1289 pj_scanner *scanner ) 1285 1290 { 1286 pj_scan_get_until( scanner, &pjsip_NEWLINE_OR_EOF_SPEC, &hdr->hvalue); 1291 if (pj_cis_match(&pjsip_NOT_NEWLINE, *scanner->curptr)) 1292 pj_scan_get( scanner, &pjsip_NOT_NEWLINE, &hdr->hvalue); 1293 else 1294 hdr->hvalue.slen = 0; 1295 1287 1296 parse_hdr_end(scanner); 1288 1297 } … … 1293 1302 { 1294 1303 pj_str_t tmp; 1295 pj_scan_get _until( scanner, &pjsip_NEWLINE_OR_EOF_SPEC, &tmp);1304 pj_scan_get( scanner, &pjsip_DIGIT_SPEC, &tmp); 1296 1305 hdr->ivalue = pj_strtoul(&tmp); 1297 1306 parse_hdr_end(scanner); … … 1319 1328 { 1320 1329 pjsip_cid_hdr *hdr = pjsip_cid_hdr_create(ctx->pool); 1321 pj_scan_get _until( ctx->scanner, &pjsip_NEWLINE_OR_EOF_SPEC, &hdr->id);1330 pj_scan_get( ctx->scanner, &pjsip_NOT_NEWLINE, &hdr->id); 1322 1331 parse_hdr_end(ctx->scanner); 1323 1332 … … 1701 1710 pj_list_insert_before(first, hdr); 1702 1711 1703 if (pj_scan_stricmp ( scanner, PJSIP_VERSION "/", 8) != 0)1712 if (pj_scan_stricmp_alnum( scanner, PJSIP_VERSION "/", 8) != 0) 1704 1713 PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); 1705 1714 -
pjproject/trunk/pjsip/src/pjsip/sip_uri.c
r74 r77 90 90 int sep) 91 91 { 92 const pjsip_param *p = param_list->next; 93 char *startbuf = buf; 94 char *endbuf = buf + size; 95 96 while (p != param_list) { 92 const pjsip_param *p; 93 char *startbuf; 94 char *endbuf; 95 int printed; 96 97 p = param_list->next; 98 if (p == param_list) 99 return 0; 100 101 startbuf = buf; 102 endbuf = buf + size; 103 104 do { 97 105 *buf++ = (char)sep; 98 106 copy_advance_escape(buf, p->name, pjsip_PARAM_CHAR_SPEC); … … 102 110 } 103 111 p = p->next; 104 } 112 } while (p != param_list); 113 105 114 return buf-startbuf; 106 115 } … … 249 258 //PJ_TODO(SHOULD_DISALLOW_URI_PORT_IN_FROM_TO_HEADER) 250 259 if (url->port && context != PJSIP_URI_IN_FROMTO_HDR) { 260 if (endbuf - buf < 10) 261 return -1; 262 251 263 *buf++ = ':'; 252 264 printed = pj_utoa(url->port, buf); … … 271 283 /* TTL param is not allowed in From, To, Route, and Record-Route header. */ 272 284 if (url->ttl_param >= 0 && context != PJSIP_URI_IN_FROMTO_HDR && 273 context != PJSIP_URI_IN_ROUTING_HDR && (endbuf-buf) > 15)285 context != PJSIP_URI_IN_ROUTING_HDR) 274 286 { 287 if (endbuf - buf < 15) 288 return -1; 275 289 pj_memcpy(buf, ";ttl=", 5); 276 290 printed = pj_utoa(url->ttl_param, buf+5); … … 289 303 { 290 304 pj_str_t lr = { ";lr", 3 }; 305 if (endbuf - buf < 3) 306 return -1; 291 307 copy_advance_check(buf, lr); 292 308 } … … 301 317 param = url->header_param.next; 302 318 while (param != &url->header_param) { 319 if (endbuf - buf < param->name.slen+2) 320 return -1; 303 321 *buf++ = hparam_char; 304 322 copy_advance_escape(buf, param->name, pjsip_HDR_CHAR_SPEC); -
pjproject/trunk/pjsip/src/test-pjsip/main.c
- Property svn:keywords set to Id
-
pjproject/trunk/pjsip/src/test-pjsip/msg.c
- Property svn:keywords set to Id
r76 r77 35 35 #define FLAG_PRINT_ONLY 8 36 36 37 static int flag = FLAG_PARSE_ONLY;37 static int flag = 0; 38 38 39 39 struct test_msg … … 106 106 { 107 107 pjsip_msg *parsed_msg, *ref_msg; 108 static pjsip_msg *print_msg; 108 109 pj_status_t status = PJ_SUCCESS; 109 110 int len; … … 115 116 char msgbuf1[PJSIP_MAX_PKT_LEN]; 116 117 char msgbuf2[PJSIP_MAX_PKT_LEN]; 117 118 118 enum { BUFLEN = 512 }; 119 119 … … 122 122 if (flag & FLAG_PARSE_ONLY) 123 123 goto parse_msg; 124 if (flag & FLAG_PRINT_ONLY) 124 125 if (flag & FLAG_PRINT_ONLY) { 126 if (print_msg == NULL) 127 print_msg = entry->creator(pool); 125 128 goto print_msg; 129 } 126 130 127 131 /* Detect message. */ … … 145 149 pj_add_timestamp(&detect_time, &t2); 146 150 147 if (flag & FLAG_ PARSE_ONLY)151 if (flag & FLAG_DETECT_ONLY) 148 152 return PJ_SUCCESS; 149 153 … … 303 307 print_len = print_len + entry->len; 304 308 pj_get_timestamp(&t1); 305 len = pjsip_msg_print(parsed_msg, msgbuf1, PJSIP_MAX_PKT_LEN); 309 if (flag && FLAG_PRINT_ONLY) 310 ref_msg = print_msg; 311 len = pjsip_msg_print(ref_msg, msgbuf1, PJSIP_MAX_PKT_LEN); 306 312 if (len < 1) { 307 313 status = -150; -
pjproject/trunk/pjsip/src/test-pjsip/test.c
- Property svn:keywords set to Id
r76 r77 82 82 PJ_LOG(3,("","")); 83 83 84 //DO_TEST(uri_test());85 DO_TEST(msg_test());84 DO_TEST(uri_test()); 85 //DO_TEST(msg_test()); 86 86 87 87 on_return: -
pjproject/trunk/pjsip/src/test-pjsip/test.h
- Property svn:keywords set to Id
-
pjproject/trunk/pjsip/src/test-pjsip/uri.c
- Property svn:keywords set to Id
Note: See TracChangeset
for help on using the changeset viewer.