Changeset 1954 for pjproject/trunk
- Timestamp:
- May 13, 2008 9:38:50 AM (17 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_msg.h
r1748 r1954 1650 1650 * Retry-After header. 1651 1651 */ 1652 typedef pjsip_generic_int_hdr pjsip_retry_after_hdr; 1652 typedef struct pjsip_retry_after_hdr 1653 { 1654 /** Standard header field. */ 1655 PJSIP_DECL_HDR_MEMBER(struct pjsip_retry_after_hdr); 1656 pj_int32_t ivalue; /**< Retry-After value */ 1657 pjsip_param param; /**< Optional parameters */ 1658 pj_str_t comment; /**< Optional comments. */ 1659 } pjsip_retry_after_hdr; 1660 1653 1661 1654 1662 /** -
pjproject/trunk/pjsip/src/pjsip/sip_msg.c
r1610 r1954 1645 1645 * Retry-After header. 1646 1646 */ 1647 static int pjsip_retry_after_hdr_print(pjsip_retry_after_hdr *r, 1648 char *buf, pj_size_t size ); 1649 static pjsip_retry_after_hdr* pjsip_retry_after_hdr_clone(pj_pool_t *pool, 1650 const pjsip_retry_after_hdr *r); 1651 static pjsip_retry_after_hdr* 1652 pjsip_retry_after_hdr_shallow_clone(pj_pool_t *pool, 1653 const pjsip_retry_after_hdr *r ); 1654 1655 static pjsip_hdr_vptr retry_after_hdr_vptr = 1656 { 1657 (pjsip_hdr_clone_fptr) &pjsip_retry_after_hdr_clone, 1658 (pjsip_hdr_clone_fptr) &pjsip_retry_after_hdr_shallow_clone, 1659 (pjsip_hdr_print_fptr) &pjsip_retry_after_hdr_print, 1660 }; 1661 1662 1647 1663 PJ_DEF(pjsip_retry_after_hdr*) pjsip_retry_after_hdr_init( pj_pool_t *pool, 1648 1664 void *mem, … … 1653 1669 PJ_UNUSED_ARG(pool); 1654 1670 1655 init_hdr(hdr, PJSIP_H_RETRY_AFTER, & generic_int_hdr_vptr);1671 init_hdr(hdr, PJSIP_H_RETRY_AFTER, &retry_after_hdr_vptr); 1656 1672 hdr->ivalue = value; 1673 pj_list_init(&hdr->param); 1657 1674 return hdr; 1658 1675 } … … 1665 1682 } 1666 1683 1684 1685 static int pjsip_retry_after_hdr_print(pjsip_retry_after_hdr *hdr, 1686 char *buf, pj_size_t size) 1687 { 1688 char *p = buf; 1689 char *endbuf = buf + size; 1690 const pj_str_t *hname = &hdr->name; 1691 const pjsip_parser_const_t *pc = pjsip_parser_const(); 1692 int printed; 1693 1694 if ((pj_ssize_t)size < hdr->name.slen + 2+11) 1695 return -1; 1696 1697 pj_memcpy(p, hdr->name.ptr, hdr->name.slen); 1698 p += hname->slen; 1699 *p++ = ':'; 1700 *p++ = ' '; 1701 1702 p += pj_utoa(hdr->ivalue, p); 1703 1704 if (hdr->comment.slen) { 1705 pj_bool_t enclosed; 1706 1707 if (endbuf-p < hdr->comment.slen + 3) 1708 return -1; 1709 1710 enclosed = (*hdr->comment.ptr == '('); 1711 if (!enclosed) 1712 *p++ = '('; 1713 pj_memcpy(p, hdr->comment.ptr, hdr->comment.slen); 1714 p += hdr->comment.slen; 1715 if (!enclosed) 1716 *p++ = ')'; 1717 1718 if (!pj_list_empty(&hdr->param)) 1719 *p++ = ' '; 1720 } 1721 1722 printed = pjsip_param_print_on(&hdr->param, p, endbuf-p, 1723 &pc->pjsip_TOKEN_SPEC, 1724 &pc->pjsip_TOKEN_SPEC, 1725 ';'); 1726 if (printed < 0) 1727 return printed; 1728 1729 p += printed; 1730 1731 return p - buf; 1732 } 1733 1734 static pjsip_retry_after_hdr* pjsip_retry_after_hdr_clone(pj_pool_t *pool, 1735 const pjsip_retry_after_hdr *rhs) 1736 { 1737 pjsip_retry_after_hdr *hdr = pjsip_retry_after_hdr_create(pool, rhs->ivalue); 1738 pj_strdup(pool, &hdr->comment, &rhs->comment); 1739 pjsip_param_clone(pool, &hdr->param, &rhs->param); 1740 return hdr; 1741 } 1742 1743 static pjsip_retry_after_hdr* 1744 pjsip_retry_after_hdr_shallow_clone(pj_pool_t *pool, 1745 const pjsip_retry_after_hdr *rhs) 1746 { 1747 pjsip_retry_after_hdr *hdr = PJ_POOL_ALLOC_T(pool, pjsip_retry_after_hdr); 1748 pj_memcpy(hdr, rhs, sizeof(*hdr)); 1749 pjsip_param_shallow_clone(pool, &hdr->param, &rhs->param); 1750 return hdr; 1751 } 1667 1752 1668 1753 /////////////////////////////////////////////////////////////////////////////// -
pjproject/trunk/pjsip/src/pjsip/sip_parser.c
r1610 r1954 1826 1826 { 1827 1827 pjsip_retry_after_hdr *hdr; 1828 pj_scanner *scanner = ctx->scanner; 1829 pj_str_t tmp; 1830 1828 1831 hdr = pjsip_retry_after_hdr_create(ctx->pool, 0); 1829 parse_generic_int_hdr(hdr, ctx->scanner); 1832 1833 pj_scan_get(scanner, &pconst.pjsip_DIGIT_SPEC, &tmp); 1834 hdr->ivalue = pj_strtoul(&tmp); 1835 1836 while (!pj_scan_is_eof(scanner) && *scanner->curptr!='\r' && 1837 *scanner->curptr=='\n') 1838 { 1839 if (*scanner->curptr=='(') { 1840 pj_scan_get_quote(scanner, '(', ')', &hdr->comment); 1841 } else if (*scanner->curptr==';') { 1842 pjsip_param *prm = PJ_POOL_ALLOC_T(ctx->pool, pjsip_param); 1843 int_parse_param(scanner, ctx->pool, &prm->name, &prm->value, 0); 1844 pj_list_push_back(&hdr->param, prm); 1845 } 1846 } 1847 1848 parse_hdr_end(scanner); 1830 1849 return (pjsip_hdr*)hdr; 1831 1850 }
Note: See TracChangeset
for help on using the changeset viewer.