Ticket #832: ticket832.2.patch

File ticket832.2.patch, 3.9 KB (added by nanang, 15 years ago)

Another version: instead of manual param parsing (as in ticket832.patch), param 'hide' existance is checked directly from the hdr->other_param structure.

  • pjsip/src/test/msg_test.c

     
    365365    hdr2 = ref_msg->hdr.next; 
    366366 
    367367    while (hdr1 != &parsed_msg->hdr && hdr2 != &ref_msg->hdr) { 
    368         len = hdr1->vptr->print_on(hdr1, str1.ptr, BUFLEN); 
    369         if (len < 1) { 
     368        len = pjsip_hdr_print_on(hdr1, str1.ptr, BUFLEN); 
     369        if (len < 0) { 
    370370            status = -40; 
    371371            goto on_return; 
    372372        } 
    373373        str1.ptr[len] = '\0'; 
    374374        str1.slen = len; 
    375375 
    376         len = hdr2->vptr->print_on(hdr2, str2.ptr, BUFLEN); 
    377         if (len < 1) { 
     376        len = pjsip_hdr_print_on(hdr2, str2.ptr, BUFLEN); 
     377        if (len < 0) { 
    378378            status = -50; 
    379379            goto on_return; 
    380380        } 
     
    19371937        /* Print the parsed header*/ 
    19381938        output = (char*) pj_pool_alloc(pool, 1024); 
    19391939        len = pjsip_hdr_print_on(parsed_hdr1, output, 1024); 
    1940         if (len < 1 || len >= 1024) { 
     1940        if (len < 0 || len >= 1024) { 
    19411941            PJ_LOG(3,(THIS_FILE, "    header too long: %s: %s", test->hname, test->hcontent)); 
    19421942            return -530; 
    19431943        } 
  • pjsip/src/pjsip/sip_msg.c

     
    456456 
    457457    /* Print each of the headers. */ 
    458458    for (hdr=msg->hdr.next; hdr!=&msg->hdr; hdr=hdr->next) { 
    459         len = (*hdr->vptr->print_on)(hdr, p, end-p); 
    460         if (len < 1) 
     459        len = pjsip_hdr_print_on(hdr, p, end-p); 
     460        if (len < 0) 
    461461            return -1; 
    462         p += len; 
    463462 
    464         if (p+3 >= end) 
    465             return -1; 
     463        if (len > 0) { 
     464            p += len; 
     465            if (p+3 >= end) 
     466                return -1; 
    466467 
    467         *p++ = '\r'; 
    468         *p++ = '\n'; 
     468            *p++ = '\r'; 
     469            *p++ = '\n'; 
     470        } 
    469471    } 
    470472 
    471473    /* Process message body. */ 
     
    16011603    char *startbuf = buf; 
    16021604    char *endbuf = buf + size; 
    16031605    const pjsip_parser_const_t *pc = pjsip_parser_const(); 
     1606    pjsip_sip_uri *sip_uri; 
     1607    pjsip_param *p; 
     1608 
     1609    /* Check the proprietary param 'hide', don't print this header  
     1610     * if it exists in the route URI. 
     1611     */ 
     1612    sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(hdr->name_addr.uri); 
     1613    p = sip_uri->other_param.next; 
     1614    while (p != &sip_uri->other_param) { 
     1615        const pj_str_t st_hide = {"hide", 4}; 
     1616 
     1617        if (pj_stricmp(&p->name, &st_hide) == 0) { 
     1618            /* Check if param 'hide' is specified without 'lr'. */ 
     1619            pj_assert(sip_uri->lr_param != 0); 
     1620            return 0; 
     1621        } 
     1622        p = p->next; 
     1623    } 
     1624 
    16041625    /* Route and Record-Route don't compact forms */ 
    16051626 
    16061627    copy_advance(buf, hdr->name); 
  • pjsip/src/pjsip/sip_ua_layer.c

     
    907907    char userinfo[128]; 
    908908 
    909909    len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); 
    910     if (len < 1) 
     910    if (len < 0) 
    911911        pj_ansi_strcpy(userinfo, "<--uri too long-->"); 
    912912    else 
    913913        userinfo[len] = '\0'; 
  • pjsip/src/pjsua-lib/pjsua_call.c

     
    26942694    /* Dump invite sesion info. */ 
    26952695 
    26962696    len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); 
    2697     if (len < 1) 
     2697    if (len < 0) 
    26982698        pj_ansi_strcpy(userinfo, "<--uri too long-->"); 
    26992699    else 
    27002700        userinfo[len] = '\0'; 
  • pjsip-apps/src/samples/siprtp_report.c

     
    7777 
    7878    /* Call identification */ 
    7979    len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); 
    80     if (len < 1) 
     80    if (len < 0) 
    8181        pj_ansi_strcpy(userinfo, "<--uri too long-->"); 
    8282    else 
    8383        userinfo[len] = '\0';