Group PJSIP_MULTIPART¶
- group PJSIP_MULTIPART
Support for multipart message bodies.
Functions
-
pjsip_msg_body *pjsip_multipart_create(pj_pool_t *pool, const pjsip_media_type *ctype, const pj_str_t *boundary)¶
Create an empty multipart body.
- Parameters
pool – Memory pool to allocate memory from.
ctype – Optional MIME media type of the multipart bodies. If not specified, “multipart/mixed” will be used.
boundary – Optional string to be set as part boundary. The boundary string excludes the leading hyphens. If this parameter is NULL or empty, a random boundary will be generated.
- Returns
Multipart body instance with no part.
-
pjsip_multipart_part *pjsip_multipart_create_part(pj_pool_t *pool)¶
Create an empty multipart part.
- Parameters
pool – The memory pool.
- Returns
The multipart part.
-
pjsip_multipart_part *pjsip_multipart_clone_part(pj_pool_t *pool, const pjsip_multipart_part *part)¶
Perform a deep clone to a multipart part.
- Parameters
pool – The memory pool.
part – The part to be duplicated.
- Returns
Copy of the multipart part.
-
pj_status_t pjsip_multipart_add_part(pj_pool_t *pool, pjsip_msg_body *mp, pjsip_multipart_part *part)¶
Add a part into multipart bodies.
- Parameters
pool – The memory pool.
mp – The multipart bodies.
part – The part to be added into the bodies.
- Returns
PJ_SUCCESS on success.
-
pjsip_multipart_part *pjsip_multipart_get_first_part(const pjsip_msg_body *mp)¶
Get the first part of multipart bodies.
- Parameters
mp – The multipart bodies.
- Returns
The first part, or NULL if the multipart bodies currently doesn’t hold any elements.
-
pjsip_multipart_part *pjsip_multipart_get_next_part(const pjsip_msg_body *mp, pjsip_multipart_part *part)¶
Get the next part after the specified part.
- Parameters
mp – The multipart bodies.
part – The part.
- Returns
The next part, or NULL if there is no other part after the part.
-
pjsip_multipart_part *pjsip_multipart_find_part(const pjsip_msg_body *mp, const pjsip_media_type *content_type, const pjsip_multipart_part *start)¶
Find a body inside multipart bodies which has the specified content type.
- Parameters
mp – The multipart body.
content_type – Content type to find.
start – If specified, the search will begin at start->next. Otherwise it will begin at the first part in the multipart bodies.
- Returns
The first part with the specified content type if found, or NULL.
-
pjsip_multipart_part *pjsip_multipart_find_part_by_header(pj_pool_t *pool, const pjsip_msg_body *mp, void *search_hdr, const pjsip_multipart_part *start)¶
Find a body inside multipart bodies which has a header matching the supplied one. Most useful for finding a part with a specific Content-ID.
- Parameters
pool – Memory pool to use for temp space.
mp – The multipart body.
search_hdr – Header to search for.
start – If specified, the search will begin at start->next part. Otherwise it will begin at the first part in the multipart bodies.
- Returns
The first part which has a header matching the specified one, or NULL if not found.
-
pjsip_multipart_part *pjsip_multipart_find_part_by_header_str(pj_pool_t *pool, const pjsip_msg_body *mp, const pj_str_t *hdr_name, const pj_str_t *hdr_value, const pjsip_multipart_part *start)¶
Find a body inside multipart bodies which has a header matching the supplied name and value. Most useful for finding a part with a specific Content-ID.
- Parameters
pool – Memory pool to use for temp space.
mp – The multipart body.
hdr_name – Header name to search for.
hdr_value – Header value search for.
start – If specified, the search will begin at start->next part. Otherwise it will begin at the first part in the multipart bodies.
- Returns
The first part which has a header matching the specified one, or NULL if not found.
-
pjsip_multipart_part *pjsip_multipart_find_part_by_cid_str(pj_pool_t *pool, const pjsip_msg_body *mp, pj_str_t *cid)¶
Find a body inside multipart bodies which has a Content-ID value matching the supplied “cid” URI in pj_str form. The “cid:” scheme will be assumed if the URL doesn’t start with it. Enclosing angle brackets will also be handled correctly if they exist.
See also
RFC2392 Content-ID and Message-ID Uniform Resource Locators
- Parameters
pool – Memory pool to use for temp space.
mp – The multipart body.
cid – The “cid” URI to search for in pj_str form.
- Returns
The first part which has a Content-ID header matching the specified “cid” URI. or NULL if not found.
-
pjsip_multipart_part *pjsip_multipart_find_part_by_cid_uri(pj_pool_t *pool, const pjsip_msg_body *mp, pjsip_other_uri *cid_uri)¶
Find a body inside multipart bodies which has a Content-ID value matching the supplied “cid” URI.
See also
RFC2392 Content-ID and Message-ID Uniform Resource Locators
- Parameters
pool – Memory pool to use for temp space.
mp – The multipart body.
cid – The “cid” URI to search for.
- Returns
The first part which had a Content-ID header matching the specified “cid” URI. or NULL if not found.
-
pjsip_msg_body *pjsip_multipart_parse(pj_pool_t *pool, char *buf, pj_size_t len, const pjsip_media_type *ctype, unsigned options)¶
Parse multipart message.
- Parameters
pool – Memory pool.
buf – Input buffer.
len – The buffer length.
ctype – Content type of the multipart body.
options – Parsing options, must be zero for now.
- Returns
Multipart message body.
-
pj_status_t pjsip_multipart_get_raw(pjsip_msg_body *mp, pj_str_t *boundary, pj_str_t *raw_data)¶
Get the boundary string and the raw message body of the specified multipart message body. Note that raw message body will only be available if the multipart message body is generated by pjsip_multipart_parse().
- Parameters
mp – The multipart message body.
boundary – Optional parameter to receive the boundary string.
raw_data – Optional parameter to receive the raw message body.
- Returns
PJ_SUCCESS on success.
-
struct pjsip_multipart_part¶
- #include <sip_multipart.h>
This structure describes the individual body part inside a multipart message body. It mainly contains the message body itself and optional headers.
-
pjsip_msg_body *pjsip_multipart_create(pj_pool_t *pool, const pjsip_media_type *ctype, const pj_str_t *boundary)¶