Changeset 266 for pjproject/trunk
- Timestamp:
- Mar 2, 2006 9:16:00 PM (19 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_msg.h
r212 r266 611 611 * @return PJ_SUCCESS on success. 612 612 */ 613 PJ_DECL(pj_status_t) pjsip_msg_body_c lone(pj_pool_t *pool,613 PJ_DECL(pj_status_t) pjsip_msg_body_copy( pj_pool_t *pool, 614 614 pjsip_msg_body *dst_body, 615 615 const pjsip_msg_body *src_body ); 616 616 617 618 /** 619 * Create cloned message body. This will duplicate the contents of the message 620 * body using the \a clone_data member of the source message body. 621 * 622 * @param pool Pool to use to duplicate the message body. 623 * @param body Source message body to duplicate. 624 * 625 * @return The cloned message body on successfull. 626 */ 627 PJ_DECL(pjsip_msg_body*) pjsip_msg_body_clone( pj_pool_t *pool, 628 const pjsip_msg_body *body ); 629 630 631 /** 632 * Create a text message body. Use this function to create message body when 633 * the content is a simple text. For non-text message body (e.g. 634 * pjmedia_sdp_session or pj_xml_node), application must construct the message 635 * manually. 636 * 637 * @param pool Pool to allocate message body and its contents. 638 * @param type MIME type (e.g. "text"). 639 * @param subtype MIME subtype (e.g. "plain"). 640 * @param text The text content to be put in the message body. 641 * 642 * @return A new message body with the specified Content-Type and 643 * text. 644 */ 645 PJ_DECL(pjsip_msg_body*) pjsip_msg_body_create( pj_pool_t *pool, 646 const pj_str_t *type, 647 const pj_str_t *subtype, 648 const pj_str_t *text ); 617 649 618 650 /** -
pjproject/trunk/pjsip/src/pjsip/sip_msg.c
r212 r266 1759 1759 } 1760 1760 1761 PJ_DEF(pj_status_t) pjsip_msg_body_c lone( pj_pool_t *pool,1762 1763 1761 PJ_DEF(pj_status_t) pjsip_msg_body_copy( pj_pool_t *pool, 1762 pjsip_msg_body *dst_body, 1763 const pjsip_msg_body *src_body ) 1764 1764 { 1765 1765 /* First check if clone_data field is initialized. */ … … 1788 1788 } 1789 1789 1790 1791 PJ_DEF(pjsip_msg_body*) pjsip_msg_body_clone( pj_pool_t *pool, 1792 const pjsip_msg_body *body ) 1793 { 1794 pjsip_msg_body *new_body; 1795 pj_status_t status; 1796 1797 new_body = pj_pool_alloc(pool, sizeof(pjsip_msg_body)); 1798 PJ_ASSERT_RETURN(new_body, NULL); 1799 1800 status = pjsip_msg_body_copy(pool, new_body, body); 1801 1802 return (status==PJ_SUCCESS) ? new_body : NULL; 1803 } 1804 1805 1806 PJ_DEF(pjsip_msg_body*) pjsip_msg_body_create( pj_pool_t *pool, 1807 const pj_str_t *type, 1808 const pj_str_t *subtype, 1809 const pj_str_t *text ) 1810 { 1811 pjsip_msg_body *body; 1812 1813 PJ_ASSERT_RETURN(pool && type && subtype && text, NULL); 1814 1815 body = pj_pool_zalloc(pool, sizeof(pjsip_msg_body)); 1816 PJ_ASSERT_RETURN(body != NULL, NULL); 1817 1818 pj_strdup(pool, &body->content_type.type, type); 1819 pj_strdup(pool, &body->content_type.subtype, subtype); 1820 body->content_type.param.slen = 0; 1821 1822 body->data = pj_pool_alloc(pool, text->slen); 1823 pj_memcpy(body->data, text->ptr, text->slen); 1824 body->len = text->slen; 1825 1826 body->clone_data = &pjsip_clone_text_data; 1827 body->print_body = &pjsip_print_text_body; 1828 1829 return body; 1830 } 1831 -
pjproject/trunk/pjsip/src/pjsip/sip_util.c
r175 r266 1236 1236 /* Add the message body, if any. */ 1237 1237 if (body) { 1238 tdata->msg->body = pj_pool_alloc(tdata->pool, sizeof(pjsip_msg_body)); 1239 status = pjsip_msg_body_clone( tdata->pool, tdata->msg->body, body ); 1240 if (status != PJ_SUCCESS) { 1238 tdata->msg->body = pjsip_msg_body_clone( tdata->pool, body ); 1239 if (tdata->msg->body == NULL) { 1241 1240 pjsip_tx_data_dec_ref(tdata); 1242 1241 return status; … … 1296 1295 /* Add the message body, if any. */ 1297 1296 if (body) { 1298 tdata->msg->body = pj_pool_alloc(tdata->pool, sizeof(pjsip_msg_body)); 1299 status = pjsip_msg_body_clone( tdata->pool, tdata->msg->body, body ); 1300 if (status != PJ_SUCCESS) { 1297 tdata->msg->body = pjsip_msg_body_clone( tdata->pool, body ); 1298 if (tdata->msg->body == NULL) { 1301 1299 pjsip_tx_data_dec_ref(tdata); 1302 1300 return status; … … 1318 1316 if (status != PJ_SUCCESS) { 1319 1317 pjsip_tx_data_dec_ref(tdata); 1320 } else {1318 } else if (p_tsx) { 1321 1319 *p_tsx = tsx; 1322 1320 }
Note: See TracChangeset
for help on using the changeset viewer.