Changeset 1954 for pjproject/trunk/pjsip/src/pjsip/sip_msg.c
- Timestamp:
- May 13, 2008 9:38:50 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 ///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.