Ignore:
Timestamp:
Aug 5, 2008 7:28:17 PM (16 years ago)
Author:
bennylp
Message:

Implement ticket #551: Generic URI scheme handler (thanks Juri Glaß for the patch)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_parser.c

    r2039 r2193  
    4848#define HNV_UNRESERVED      "[]/?:+$" 
    4949#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   "#?;:@&=+-_.!~*'()%$,/" "%" 
    5055 
    5156#define PJSIP_VERSION           "SIP/2.0" 
     
    153158                    int_parse_name_addr( pj_scanner *scanner,  
    154159                                         pj_pool_t *pool ); 
     160static void*        int_parse_other_uri(pj_scanner *scanner,  
     161                                        pj_pool_t *pool, 
     162                                        pj_bool_t parse_params); 
    155163static void         parse_hdr_end( pj_scanner *scanner ); 
    156164 
     
    377385    pj_cis_invert(&pconst.pjsip_DISPLAY_SPEC); 
    378386 
     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 
    379391    /* 
    380392     * Register URI parsers. 
     
    691703            return uri_handler[i].parse; 
    692704    } 
    693     return NULL; 
     705    return &int_parse_other_uri; 
    694706} 
    695707 
     
    14641476 
    14651477 
     1478/* Parse other URI */ 
     1479static 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 
    14661505/* Parse SIP request line. */ 
    14671506static void int_parse_req_line( pj_scanner *scanner, pj_pool_t *pool, 
Note: See TracChangeset for help on using the changeset viewer.