Changeset 80


Ignore:
Timestamp:
Nov 23, 2005 11:25:17 AM (18 years ago)
Author:
bennylp
Message:

Fixed warnings when logging is disabled and small opt in msg parser

Location:
pjproject/trunk/pjsip/src/pjsip
Files:
3 edited

Legend:

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

    r77 r80  
    998998                                     ... ) 
    999999{ 
     1000#if PJ_LOG_MAX_LEVEL > 0 
    10001001    char newformat[256]; 
    10011002    int len; 
     
    10271028 
    10281029    va_end(marker); 
     1030#else 
     1031    PJ_UNUSED_ARG(format); 
     1032    PJ_UNUSED_ARG(error_code); 
     1033    PJ_UNUSED_ARG(sender); 
     1034    PJ_UNUSED_ARG(endpt); 
     1035#endif 
    10291036} 
    10301037 
     
    11111118    pj_mutex_unlock(endpt->mutex); 
    11121119#else 
     1120    PJ_UNUSED_ARG(endpt); 
     1121    PJ_UNUSED_ARG(detail); 
    11131122    PJ_LOG(3,(THIS_FILE, "pjsip_end_dump: can't dump because it's disabled.")); 
    11141123#endif 
  • pjproject/trunk/pjsip/src/pjsip/sip_parser.c

    r77 r80  
    5353 
    5454#define UNREACHED(expr) 
     55 
     56//#define IS_NEWLINE(c) ((c)=='\r' || (c)=='\n') 
     57#define IS_NEWLINE(c)   ((c)=='\r') 
     58#define IS_SPACE(c)     ((c)==' ' || (c)=='\t') 
    5559 
    5660typedef struct handler_rec 
     
    543547    pj_scanner scanner; 
    544548    pjsip_parse_ctx context; 
    545     PJ_USE_EXCEPTION; 
    546549 
    547550    init_sip_parser(); 
     
    554557    context.rdata = NULL; 
    555558 
    556     PJ_TRY { 
    557         msg = int_parse_msg(&context, err_list); 
    558     }  
    559     PJ_CATCH_ANY { 
    560         msg = NULL; 
    561     } 
    562     PJ_END 
     559    msg = int_parse_msg(&context, err_list); 
    563560 
    564561    pj_scan_fini(&scanner); 
     
    572569    pj_scanner scanner; 
    573570    pjsip_parse_ctx context; 
    574     PJ_USE_EXCEPTION; 
    575571 
    576572    init_sip_parser(); 
     
    583579    context.rdata = rdata; 
    584580 
    585     PJ_TRY { 
    586         rdata->msg_info.msg = int_parse_msg(&context, &rdata->msg_info.parse_err); 
    587     }  
    588     PJ_CATCH_ANY { 
    589         rdata->msg_info.msg = NULL; 
    590     } 
    591     PJ_END 
     581    rdata->msg_info.msg = int_parse_msg(&context, &rdata->msg_info.parse_err); 
    592582 
    593583    pj_scan_fini(&scanner); 
     
    719709 
    720710    /* Must have exhausted all inputs. */ 
    721     if (pj_scan_is_eof(&scanner) || *scanner.curptr=='\r' ||  
    722                        *scanner.curptr=='\n')  
    723     { 
     711    if (pj_scan_is_eof(&scanner) || IS_NEWLINE(*scanner.curptr)) { 
    724712        /* Success. */ 
    725713        pj_scan_fini(&scanner); 
     
    751739                                 pjsip_parser_err_report *err_list) 
    752740{ 
    753     pjsip_msg *msg; 
     741    pj_bool_t parsing_headers; 
     742    pjsip_msg *msg = NULL; 
    754743    pj_str_t hname; 
    755744    pjsip_ctype_hdr *ctype_hdr = NULL; 
     
    758747    PJ_USE_EXCEPTION; 
    759748 
    760     /* Skip leading newlines. */ 
    761     while (*scanner->curptr=='\r' || *scanner->curptr=='\n') { 
    762         pj_scan_get_newline(scanner); 
    763     } 
    764  
    765     /* Parse request or status line */ 
    766     if (pj_scan_stricmp_alnum( scanner, PJSIP_VERSION, 7) == 0) { 
    767         msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG); 
    768         int_parse_status_line( scanner, &msg->line.status ); 
    769     } else { 
    770         msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG); 
    771         int_parse_req_line(scanner, pool, &msg->line.req ); 
    772     } 
    773  
    774     /* Parse headers. */ 
    775 parse_headers: 
     749    parsing_headers = PJ_FALSE; 
    776750 
    777751    PJ_TRY  
    778752    { 
     753        if (parsing_headers) 
     754            goto parse_headers; 
     755 
     756        /* Skip leading newlines. */ 
     757        while (IS_NEWLINE(*scanner->curptr)) { 
     758            pj_scan_get_newline(scanner); 
     759        } 
     760 
     761        /* Parse request or status line */ 
     762        if (pj_scan_stricmp_alnum( scanner, PJSIP_VERSION, 7) == 0) { 
     763            msg = pjsip_msg_create(pool, PJSIP_RESPONSE_MSG); 
     764            int_parse_status_line( scanner, &msg->line.status ); 
     765        } else { 
     766            msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG); 
     767            int_parse_req_line(scanner, pool, &msg->line.req ); 
     768        } 
     769 
     770        parsing_headers = PJ_TRUE; 
     771 
     772parse_headers: 
     773        /* Parse headers. */ 
    779774        do { 
    780775            pjsip_parse_hdr_func * handler; 
     
    796791            if (handler) { 
    797792                hdr = (*handler)(ctx); 
     793 
     794                /* Check if we've just parsed a Content-Type header.  
     795                 * We will check for a message body if we've got Content-Type  
     796                 * header. 
     797                 */ 
     798                if (hdr->type == PJSIP_H_CONTENT_TYPE) { 
     799                    ctype_hdr = (pjsip_ctype_hdr*)hdr; 
     800                } 
     801 
    798802            } else { 
    799803                hdr = parse_hdr_generic_string(ctx); 
    800                 hdr->type = PJSIP_H_OTHER; 
    801804                hdr->name = hdr->sname = hname; 
    802805            } 
    803806             
    804             /* Check if we've just parsed a Content-Type header.  
    805              * We will check for a message body if we've got Content-Type  
    806              * header. 
    807              */ 
    808             if (hdr->type == PJSIP_H_CONTENT_TYPE) { 
    809                 ctype_hdr = (pjsip_ctype_hdr*)hdr; 
    810             } 
    811                  
     807         
    812808            /* Single parse of header line can produce multiple headers. 
    813809             * For example, if one Contact: header contains Contact list 
     
    819815             
    820816            /* Parse until EOF or an empty line is found. */ 
    821         } while (!pj_scan_is_eof(scanner) &&  
    822                   *scanner->curptr != '\r' && *scanner->curptr != '\n'); 
     817        } while (!pj_scan_is_eof(scanner) && !IS_NEWLINE(*scanner->curptr)); 
    823818         
     819        parsing_headers = PJ_FALSE; 
     820 
     821        /* If empty line is found, eat it. */ 
     822        if (!pj_scan_is_eof(scanner)) { 
     823            if (IS_NEWLINE(*scanner->curptr)) { 
     824                pj_scan_get_newline(scanner); 
     825            } 
     826        } 
     827 
     828        /* If we have Content-Type header, treat the rest of the message  
     829         * as body. 
     830         */ 
     831        if (ctype_hdr && scanner->curptr!=scanner->end) { 
     832            pjsip_msg_body *body = pj_pool_alloc(pool, sizeof(pjsip_msg_body)); 
     833            body->content_type.type = ctype_hdr->media.type; 
     834            body->content_type.subtype = ctype_hdr->media.subtype; 
     835            body->content_type.param = ctype_hdr->media.param; 
     836 
     837            body->data = scanner->curptr; 
     838            body->len = scanner->end - scanner->curptr; 
     839            body->print_body = &generic_print_body; 
     840 
     841            msg->body = body; 
     842        } 
    824843    } 
    825844    PJ_CATCH_ANY  
     
    828847         * Skip until newline, and parse next header.  
    829848         */ 
    830         pj_str_t token; 
    831          
    832849        if (err_list) { 
    833850            pjsip_parser_err_report *err_info; 
     
    837854            err_info->line = scanner->line; 
    838855            err_info->col = pj_scan_get_col(scanner); 
    839             err_info->hname = hname; 
     856            if (parsing_headers) 
     857                err_info->hname = hname; 
     858            else 
     859                err_info->hname.slen = 0; 
    840860             
    841861            pj_list_insert_before(err_list, err_info); 
    842862        } 
    843863         
    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         } 
     864        if (parsing_headers) { 
     865            if (!pj_scan_is_eof(scanner)) { 
     866                /* Skip until next line. 
     867                 * Watch for header continuation. 
     868                 */ 
     869                do { 
     870                    pj_scan_skip_line(scanner); 
     871                } while (IS_SPACE(*scanner->curptr)); 
     872            } 
     873 
     874            if (!pj_scan_is_eof(scanner) && !IS_NEWLINE(*scanner->curptr)) { 
     875                goto parse_headers; 
     876            } 
     877        } 
     878 
     879        msg = NULL; 
    854880    } 
    855881    PJ_END; 
    856  
    857  
    858     /* If empty line is found, eat it. */ 
    859     if (!pj_scan_is_eof(scanner)) { 
    860         if (*scanner->curptr=='\r' || *scanner->curptr=='\n') { 
    861             pj_scan_get_newline(scanner); 
    862         } 
    863     } 
    864  
    865     /* If we have Content-Type header, treat the rest of the message as body.*/ 
    866     if (ctype_hdr && scanner->curptr!=scanner->end) { 
    867         pjsip_msg_body *body = pj_pool_alloc(pool, sizeof(pjsip_msg_body)); 
    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  
    872         body->data = scanner->curptr; 
    873         body->len = scanner->end - scanner->curptr; 
    874         body->print_body = &generic_print_body; 
    875  
    876         msg->body = body; 
    877     } 
    878882 
    879883    return msg; 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport.c

    r65 r80  
    839839 
    840840    pj_lock_release(mgr->lock); 
     841#else 
     842    PJ_UNUSED_ARG(mgr); 
    841843#endif 
    842844} 
Note: See TracChangeset for help on using the changeset viewer.