Changeset 2193 for pjproject/trunk/pjsip/src/pjsip/sip_uri.c
- Timestamp:
- Aug 5, 2008 7:28:17 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.