Changeset 2193 for pjproject/trunk
- Timestamp:
- Aug 5, 2008 7:28:17 PM (16 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_parser.h
r2039 r2193 359 359 pj_cis_t pjsip_DISPLAY_SPEC; /**< Used when searching for display 360 360 name. */ 361 pj_cis_t pjsip_OTHER_URI_CONTENT; /**< Generic URI content. */ 361 362 362 363 } pjsip_parser_const_t; -
pjproject/trunk/pjsip/include/pjsip/sip_uri.h
r2103 r2193 415 415 const pjsip_name_addr *rhs); 416 416 417 418 419 420 417 /** 421 418 * @} 422 419 */ 423 420 421 /** 422 * @defgroup PJSIP_OTHER_URI Other URI schemes 423 * @ingroup PJSIP_URI 424 * @brief Container for non SIP/tel URI scheme (e.g. "http:", "mailto:") 425 * @{ 426 */ 427 428 /** 429 * Generic URI container for non SIP/tel URI scheme. 430 */ 431 typedef struct pjsip_other_uri 432 { 433 pjsip_uri_vptr *vptr; /**< Pointer to virtual function table. */ 434 pj_str_t scheme; /**< The URI scheme (e.g. "mailto") */ 435 pj_str_t content; /**< The whole URI content */ 436 } pjsip_other_uri; 437 438 439 /** 440 * Create a generic URI object. 441 * 442 * @param pool The pool to allocate memory from. 443 * 444 * @return The URI instance. 445 */ 446 PJ_DECL(pjsip_other_uri*) pjsip_other_uri_create(pj_pool_t *pool); 447 448 449 /** 450 * @} 451 */ 452 424 453 PJ_END_DECL 425 454 -
pjproject/trunk/pjsip/src/pjsip/sip_parser.c
r2039 r2193 48 48 #define HNV_UNRESERVED "[]/?:+$" 49 49 #define HDR_CHAR HNV_UNRESERVED UNRESERVED ESCAPED 50 51 /* A generic URI can consist of (For a complete BNF see RFC 2396): 52 #?;:@&=+-_.!~*'()%$,/ 53 */ 54 #define GENERIC_URI_CHARS "#?;:@&=+-_.!~*'()%$,/" "%" 50 55 51 56 #define PJSIP_VERSION "SIP/2.0" … … 153 158 int_parse_name_addr( pj_scanner *scanner, 154 159 pj_pool_t *pool ); 160 static void* int_parse_other_uri(pj_scanner *scanner, 161 pj_pool_t *pool, 162 pj_bool_t parse_params); 155 163 static void parse_hdr_end( pj_scanner *scanner ); 156 164 … … 377 385 pj_cis_invert(&pconst.pjsip_DISPLAY_SPEC); 378 386 387 status = pj_cis_dup(&pconst.pjsip_OTHER_URI_CONTENT, &pconst.pjsip_ALNUM_SPEC); 388 PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 389 pj_cis_add_str( &pconst.pjsip_OTHER_URI_CONTENT, GENERIC_URI_CHARS); 390 379 391 /* 380 392 * Register URI parsers. … … 691 703 return uri_handler[i].parse; 692 704 } 693 return NULL;705 return &int_parse_other_uri; 694 706 } 695 707 … … 1464 1476 1465 1477 1478 /* Parse other URI */ 1479 static void* int_parse_other_uri(pj_scanner *scanner, 1480 pj_pool_t *pool, 1481 pj_bool_t parse_params) 1482 { 1483 pjsip_other_uri *uri = 0; 1484 const pjsip_parser_const_t *pc = pjsip_parser_const(); 1485 int skip_ws = scanner->skip_ws; 1486 1487 PJ_UNUSED_ARG(parse_params); 1488 1489 scanner->skip_ws = 0; 1490 1491 uri = pjsip_other_uri_create(pool); 1492 1493 pj_scan_get(scanner, &pc->pjsip_TOKEN_SPEC, &uri->scheme); 1494 if (pj_scan_get_char(scanner) != ':') { 1495 PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); 1496 } 1497 1498 pj_scan_get(scanner, &pc->pjsip_OTHER_URI_CONTENT, &uri->content); 1499 scanner->skip_ws = skip_ws; 1500 1501 return uri; 1502 } 1503 1504 1466 1505 /* Parse SIP request line. */ 1467 1506 static void int_parse_req_line( pj_scanner *scanner, pj_pool_t *pool, -
pjproject/trunk/pjsip/src/pjsip/sip_uri.c
r2039 r2193 618 618 } 619 619 620 /////////////////////////////////////////////////////////////////////////////// 621 622 static const pj_str_t *other_uri_get_scheme( const pjsip_other_uri*); 623 static void *other_uri_get_uri( pjsip_other_uri*); 624 static pj_ssize_t other_uri_print( pjsip_uri_context_e context, 625 const pjsip_other_uri *url, 626 char *buf, pj_size_t size); 627 static int other_uri_cmp( pjsip_uri_context_e context, 628 const pjsip_other_uri *url1, 629 const pjsip_other_uri *url2); 630 static pjsip_other_uri* other_uri_clone( pj_pool_t *pool, 631 const pjsip_other_uri *rhs); 632 633 static pjsip_uri_vptr other_uri_vptr = 634 { 635 (P_GET_SCHEME) &other_uri_get_scheme, 636 (P_GET_URI) &other_uri_get_uri, 637 (P_PRINT_URI) &other_uri_print, 638 (P_CMP_URI) &other_uri_cmp, 639 (P_CLONE) &other_uri_clone 640 }; 641 642 643 PJ_DEF(pjsip_other_uri*) pjsip_other_uri_create(pj_pool_t *pool) 644 { 645 pjsip_other_uri *uri = PJ_POOL_ZALLOC_T(pool, pjsip_other_uri); 646 uri->vptr = &other_uri_vptr; 647 return uri; 648 } 649 650 static const pj_str_t *other_uri_get_scheme( const pjsip_other_uri *uri ) 651 { 652 return &uri->scheme; 653 } 654 655 static void *other_uri_get_uri( pjsip_other_uri *uri ) 656 { 657 return uri; 658 } 659 660 static pj_ssize_t other_uri_print(pjsip_uri_context_e context, 661 const pjsip_other_uri *uri, 662 char *buf, pj_size_t size) 663 { 664 char *startbuf = buf; 665 char *endbuf = buf + size; 666 667 PJ_UNUSED_ARG(context); 668 669 if (uri->scheme.slen + uri->content.slen + 1 > (int)size) 670 return -1; 671 672 /* Print scheme. */ 673 copy_advance(buf, uri->scheme); 674 *buf++ = ':'; 675 676 /* Print content. */ 677 copy_advance(buf, uri->content); 678 679 return (buf - startbuf); 680 } 681 682 static int other_uri_cmp(pjsip_uri_context_e context, 683 const pjsip_other_uri *uri1, 684 const pjsip_other_uri *uri2) 685 { 686 PJ_UNUSED_ARG(context); 687 688 /* Scheme must match. */ 689 if (pj_stricmp(&uri1->scheme, &uri2->scheme) != 0) { 690 return PJSIP_ECMPSCHEME; 691 } 692 693 /* Content must match. */ 694 if(pj_stricmp(&uri1->content, &uri2->content) != 0) { 695 return -1; 696 } 697 698 /* Equal. */ 699 return 0; 700 } 701 702 /* Clone *: URI */ 703 static pjsip_other_uri* other_uri_clone(pj_pool_t *pool, 704 const pjsip_other_uri *rhs) 705 { 706 pjsip_other_uri *uri = pjsip_other_uri_create(pool); 707 pj_strdup(pool, &uri->scheme, &rhs->scheme); 708 pj_strdup(pool, &uri->content, &rhs->content); 709 710 return uri; 711 } 712
Note: See TracChangeset
for help on using the changeset viewer.