#include "config.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <assert.h>
#include <sofia-sip/su_alloc.h>
#include "msg_internal.h"
#include "sofia-sip/msg.h"
#include "sofia-sip/msg_mime.h"
#include <sofia-sip/su_uniqueid.h>
#include <sofia-sip/su_errno.h>
#include <sofia-sip/msg_parser.h>
#include <sofia-sip/msg_mime_protos.h>
Include dependency graph for msg_mime.c:
Defines | |
#define | MSG_HEADER_CLASS_G(c, l, s, kind) |
Define a header class for headers without any extra data to copy. | |
#define | MSG_HEADER_CLASS_LIST(c, l, s, kind) |
Define a header class for a msg_list_t kind of header. | |
#define | CRLF_TEST(b) |
Calculate length of line ending (0, 1 or 2). | |
Functions | |
msg_multipart_t * | msg_multipart_create (su_home_t *home, char const *content_type, void const *data, int dlen) |
Create a part for MIME multipart entity. | |
msg_multipart_t * | msg_multipart_parse (su_home_t *home, msg_content_type_t const *c, msg_payload_t *pl) |
Parse a MIME multipart. | |
int | msg_multipart_complete (su_home_t *home, msg_content_type_t *c, msg_multipart_t *mp) |
Add all missing parts to the multipart. | |
msg_header_t * | msg_multipart_serialize (msg_header_t **head0, msg_multipart_t *mp) |
Serialize a multipart message. | |
int | msg_multipart_prepare (msg_t *msg, msg_multipart_t *mp, int flags) |
Encode a multipart. | |
int | msg_multipart_d (su_home_t *home, msg_header_t *h, char *s, int slen) |
Decode a multipart. | |
int | msg_multipart_e (char b[], int bsiz, msg_header_t const *h, int flags) |
Encode a multipart. | |
int | msg_multipart_dup_xtra (msg_header_t const *h, int offset) |
Calculate extra size of a multipart. | |
char * | msg_multipart_dup_one (msg_header_t *dst, msg_header_t const *src, char *b, int xtra) |
Duplicate one msg_multipart_t object. | |
unsigned | msg_q_value (char const *q) |
Calculate Q value. | |
int | msg_mediatype_d (char **ss, char const **type) |
Parse media type (type/subtype). | |
char * | msg_accept_dup_one (msg_header_t *dst, msg_header_t const *src, char *b, int xtra) |
Duplicate one msg_accept_t object. | |
int | msg_accept_update (msg_common_t *h, char const *name, int namelen, char const *value) |
Update parameter(s) for Accept header. | |
int | msg_accept_any_update (msg_common_t *h, char const *name, int namelen, char const *value) |
Update parameter(s) for Accept-* header. | |
char * | msg_content_disposition_dup_one (msg_header_t *dst, msg_header_t const *src, char *b, int xtra) |
Duplicate one msg_content_disposition_t object. | |
int | msg_content_disposition_update (msg_common_t *h, char const *name, int namelen, char const *value) |
Update Content-Disposition parameters. | |
msg_content_length_t * | msg_content_length_create (su_home_t *home, uint32_t n) |
Create a Content-Length header object. | |
char * | msg_content_type_dup_one (msg_header_t *dst, msg_header_t const *src, char *b, int xtra) |
Duplicate one msg_content_type_t object. | |
Variables | |
char const | msg_mime_version_1_0 [] |
Protocol version of MIME. | |
msg_hclass_t | msg_accept_class [] |
Header class for Accept header. | |
msg_hclass_t | msg_accept_charset_class [1] |
Header class for Accept-Charset header. | |
msg_hclass_t | msg_accept_encoding_class [1] |
Header class for Accept-Encoding header. | |
msg_hclass_t | msg_accept_language_class [1] |
Header class for Accept-Language header. | |
msg_hclass_t | msg_content_disposition_class [] |
Header class for Content-Disposition header. | |
msg_hclass_t | msg_content_encoding_class [] |
Header class for Content-Encoding header. | |
msg_hclass_t | msg_content_language_class [] |
Header class for Content-Language header. | |
msg_hclass_t | msg_content_length_class [] |
Header class for Content-Length header. | |
msg_hclass_t | msg_content_md5_class [] |
Header class for Content-MD5 header. | |
msg_hclass_t | msg_content_id_class [] |
Header class for Content-ID header. | |
msg_hclass_t | msg_content_type_class [] |
Header class for Content-Type header. | |
msg_hclass_t | msg_mime_version_class [] |
Header class for MIME-Version header. | |
msg_hclass_t | msg_content_location_class [] |
Header class for Content-Location header. | |
msg_hclass_t | msg_content_transfer_encoding_class [] |
Header class for Content-Transfer-Encoding header. | |
msg_hclass_t | msg_warning_class [] |
Header class for Warning header. |
int msg_mediatype_d | ( | char ** | ss, | |
char const ** | type | |||
) |
Parse media type (type/subtype).
The function msg_mediatype_d() parses a mediatype string.
ss | string to be parsed [IN/OUT] | |
type | value result for media type [OUT] |
0 | when successful, | |
-1 | upon an error. |
int msg_multipart_complete | ( | su_home_t * | home, | |
msg_content_type_t * | c, | |||
msg_multipart_t * | mp | |||
) |
Add all missing parts to the multipart.
The function msg_multipart_complete() adds missing components to the multipart message. The missing components may include boundaries between body parts, separators between body-part headers and data, and close-delimiter after last body-part.
home | home for allocating structures [IN/OUT] | |
c | content-type header for multipart [IN/OUT] | |
mp | pointer to first multipart structure [IN/OUT] |
msg_multipart_t* msg_multipart_create | ( | su_home_t * | home, | |
char const * | content_type, | |||
void const * | data, | |||
int | dlen | |||
) |
Create a part for MIME multipart entity.
The function msg_multipart_create() allocates a new msg_multipart_t object from memory home home. If content_type is non-NULL, it makes a msg_content_type_t header object and adds the header to the msg_multipart_t object. If dlen is nonzero, it allocates a msg_payload_t structure of dlen bytes for the payload of the newly created msg_multipart_t object. If data is non-NULL, it copies the dlen bytes of of data to the payload of the newly created msg_multipart_t object.
int msg_multipart_e | ( | char | b[], | |
int | bsiz, | |||
msg_header_t const * | h, | |||
int | flags | |||
) |
Encode a multipart.
Please note that here we just encode a element, the msg_multipart_t itself.
msg_multipart_t* msg_multipart_parse | ( | su_home_t * | home, | |
msg_content_type_t const * | c, | |||
msg_payload_t * | pl | |||
) |
Parse a MIME multipart.
The function msg_multipart_parse() parses a MIME multipart message. The common syntax of multiparts is described in RFC 2046 (section 7).
home | home for allocating structures [IN/OUT] | |
c | content-type header for multipart [IN] | |
pl | payload structure for multipart [IN] |
"--Pekka"
. int msg_multipart_prepare | ( | msg_t * | msg, | |
msg_multipart_t * | mp, | |||
int | flags | |||
) |
Encode a multipart.
unsigned msg_q_value | ( | char const * | q | ) |
Calculate Q value.
The function msg_q_value() converts q-value string q to numeric value in range (0..1000). Q values are used, for instance, to describe relative priorities of registered contacts.
q | q-value string ("1" | "." 1,3DIGIT) |