1
/* $Id: sip_multipart.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#ifndef __PJSIP_SIP_MULTIPART_H__
20
#define __PJSIP_SIP_MULTIPART_H__
23
* @file pjsip/sip_multipart.h
24
* @brief Multipart support.
27
#include <pjsip/sip_msg.h>
32
* @defgroup PJSIP_MULTIPART Multipart message bodies.
34
* @brief Support for multipart message bodies.
39
* This structure describes the individual body part inside a multipart
40
* message body. It mainly contains the message body itself and optional
43
typedef struct pjsip_multipart_part
46
* Standard list element.
48
PJ_DECL_LIST_MEMBER(struct pjsip_multipart_part);
51
* Optional message headers.
56
* Pointer to the message body.
60
} pjsip_multipart_part;
63
* Create an empty multipart body.
65
* @param pool Memory pool to allocate memory from.
66
* @param ctype Optional MIME media type of the multipart
67
* bodies. If not specified, "multipart/mixed"
69
* @param boundary Optional string to be set as part boundary.
70
* The boundary string excludes the leading
71
* hyphens. If this parameter is NULL or empty,
72
* a random boundary will be generated.
74
* @return Multipart body instance with no part.
76
PJ_DECL(pjsip_msg_body*) pjsip_multipart_create(pj_pool_t *pool,
77
const pjsip_media_type *ctype,
78
const pj_str_t *boundary);
81
* Create an empty multipart part.
83
* @param pool The memory pool.
85
* @return The multipart part.
87
PJ_DECL(pjsip_multipart_part*) pjsip_multipart_create_part(pj_pool_t *pool);
91
* Perform a deep clone to a multipart part.
93
* @param pool The memory pool.
94
* @param part The part to be duplicated.
96
* @return Copy of the multipart part.
98
PJ_DECL(pjsip_multipart_part*)
99
pjsip_multipart_clone_part(pj_pool_t *pool,
100
const pjsip_multipart_part *part);
103
* Add a part into multipart bodies.
105
* @param pool The memory pool.
106
* @param mp The multipart bodies.
107
* @param part The part to be added into the bodies.
109
* @return PJ_SUCCESS on success.
111
PJ_DECL(pj_status_t) pjsip_multipart_add_part(pj_pool_t *pool,
113
pjsip_multipart_part *part);
116
* Get the first part of multipart bodies.
118
* @param mp The multipart bodies.
120
* @return The first part, or NULL if the multipart
121
* bodies currently doesn't hold any elements.
123
PJ_DECL(pjsip_multipart_part*)
124
pjsip_multipart_get_first_part(const pjsip_msg_body *mp);
127
* Get the next part after the specified part.
129
* @param mp The multipart bodies.
130
* @param part The part.
132
* @return The next part, or NULL if there is no other part after
135
PJ_DECL(pjsip_multipart_part*)
136
pjsip_multipart_get_next_part(const pjsip_msg_body *mp,
137
pjsip_multipart_part *part);
140
* Find a body inside multipart bodies which has the specified content type.
142
* @param mp The multipart body.
143
* @param content_type Content type to find.
144
* @param start If specified, the search will begin at
145
* start->next. Otherwise it will begin at
146
* the first part in the multipart bodies.
148
* @return The first part with the specified content type
151
PJ_DECL(pjsip_multipart_part*)
152
pjsip_multipart_find_part( const pjsip_msg_body *mp,
153
const pjsip_media_type *content_type,
154
const pjsip_multipart_part *start);
157
* Parse multipart message.
159
* @param pool Memory pool.
160
* @param buf Input buffer.
161
* @param len The buffer length.
162
* @param ctype Content type of the multipart body.
163
* @param options Parsing options, must be zero for now.
165
* @return Multipart message body.
167
PJ_DECL(pjsip_msg_body*) pjsip_multipart_parse(pj_pool_t *pool,
168
char *buf, pj_size_t len,
169
const pjsip_media_type *ctype,
179
#endif /* __PJSIP_SIP_MULTIPART_H__ */