⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msg_mime.c

📁 Sofia SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.
💻 C
📖 第 1 页 / 共 4 页
字号:
 *   msg_common_t            k_common[1]; // Common fragment info *   msg_content_language_t *k_next;      // (Content-Encoding header) *   msg_param_t            *k_items;     // List of languages * } msg_content_language_t; * @endcode */msg_hclass_t msg_content_language_class[] =MSG_HEADER_CLASS_LIST(content_language, "Content-Language", "", list);issize_t msg_content_language_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen){  msg_content_language_t *k = (msg_content_language_t *)h;  return msg_commalist_d(home, &s, &k->k_items, msg_token_scan);}issize_t msg_content_language_e(char b[], isize_t bsiz, msg_header_t const *h, int f){  assert(msg_is_content_language(h));  return msg_list_e(b, bsiz, h, f);}/* ====================================================================== *//**@ingroup msg_mime * @defgroup msg_content_length Content-Length Header * * The Content-Length header indicates the size of the message-body in * decimal number of octets.  Its syntax is defined in [S10.18] as * follows: * * @code *    Content-Length  =  ( "Content-Length" / "l" ) HCOLON 1*DIGIT * @endcode * *//**@ingroup msg_content_length * @typedef typedef struct msg_content_length_s msg_content_length_t; * * The structure msg_content_length_t contains representation of a * Content-Length header. * * The msg_content_length_t is defined as follows: * @code * typedef struct msg_content_length_s { *   msg_common_t   l_common[1];        // Common fragment info *   msg_error_t   *l_next;             // Link to next (dummy) *   unsigned long  l_length;           // Numeric value * } msg_content_length_t; * @endcode */#define msg_content_length_d msg_numeric_d#define msg_content_length_e msg_numeric_emsg_hclass_t msg_content_length_class[] =MSG_HEADER_CLASS(msg_, content_length, "Content-Length", "l",		 l_common, single_critical, msg_default, msg_generic);/**@ingroup msg_content_length *燙reate a @b Content-Length header object. * * The function msg_content_length_create() creates a Content-Length * header object with the value @a n.  The memory for the header is * allocated from the memory home @a home. * * @param home  memory home * @param n     payload size in bytes * * @return * The function msg_content_length_create() returns a pointer to newly * created @b Content-Length header object when successful or NULL upon * an error. */msg_content_length_t *msg_content_length_create(su_home_t *home, uint32_t n){  msg_content_length_t *l = (msg_content_length_t *)    msg_header_alloc(home, msg_content_length_class, 0);  if (l)    l->l_length = n;  return l;}/* ====================================================================== *//**@ingroup msg_mime * @defgroup msg_content_md5 Content-MD5 Header * * The Content-MD5 header is an MD5 digest of the entity-body for the * purpose of providing an end-to-end message integrity check (MIC) of the * message-body. Its syntax is defined in [@RFC1864, H14.15] as follows: * * @code *      Content-MD5   = "Content-MD5" ":" md5-digest *      md5-digest   = <base64 of 128 bit MD5 digest as per @RFC1864> * @endcode *//**@ingroup msg_content_md5 * @typedef struct msg_generic_s msg_content_md5_t;  * * The structure msg_content_md5_t contains representation of an @b * Content-MD5 header. * * The msg_content_md5_t is defined as follows: * @code * typedef struct msg_generic_s * { *   msg_common_t   g_common[1];    // Common fragment info *   msg_generic_t *g_next;	    // Link to next header *   char const    *g_string;	    // Header value * } msg_content_md5_t; * @endcode */#define msg_content_md5_d msg_generic_d#define msg_content_md5_e msg_generic_emsg_hclass_t msg_content_md5_class[] =MSG_HEADER_CLASS_G(content_md5, "Content-MD5", "", single);/* ====================================================================== *//**@ingroup msg_mime * @defgroup msg_content_id Content-ID Header * * The Content-ID header is an unique identifier of an entity-body. The * Content-ID value may be used for uniquely identifying MIME entities in * several contexts, particularly for caching data referenced by the * message/external-body mechanism. Its syntax is defined in [RFC2045] as * follows: * * @code *      Content-ID   = "Content-ID" ":" msg-id *      msg-id       = [CFWS] "<" id-left "@" id-right ">" [CFWS] *      id-left      = dot-atom-text / no-fold-quote / obs-id-left *      id-right     = dot-atom-text / no-fold-literal / obs-id-right * @endcode *//**@ingroup msg_content_id * @typedef msg_generic_t msg_content_id_t; * Content-ID Header Structure. * @code * typedef struct * { *   msg_common_t      g_common[1];    // Common fragment info *   msg_content_id_t *g_next;	       // Link to next header *   char const       *g_string;       // Header value * } * @endcode */#define msg_content_id_d msg_generic_d#define msg_content_id_e msg_generic_emsg_hclass_t msg_content_id_class[] =MSG_HEADER_CLASS_G(content_id, "Content-ID", "", single);/* ====================================================================== *//**@ingroup msg_mime * @defgroup msg_content_type Content-Type Header * * The @b Content-Type header indicates the media type of the message-body * sent to the recipient. Its syntax is defined in [H3.7, S20.15] * as follows: * * @code *    Content-Type  = ( "Content-Type" | "c" ) ":" media-type *    media-type    = type "/" subtype *( ";" parameter ) *    type          = token *    subtype       = token * @endcode *//**@ingroup msg_content_type * @typedef typedef struct msg_content_type_s msg_content_type_t; * * The structure msg_content_type_t contains representation of @b * Content-Type header. * * The msg_content_type_t is defined as follows: * @code * typedef struct msg_content_type_s { *   msg_common_t        c_common[1];  // Common fragment info *   msg_unknown_t      *c_next;       // Dummy link to next *   char const         *c_type;       // Pointer to type/subtype *   char const         *c_subtype;    // Points after first slash in type *   msg_param_t const  *c_params;     // List of parameters * } msg_content_type_t; * @endcode * * The @a c_type is always void of whitespace, that is, there is no * whitespace around the slash. */#define msg_content_type_update NULLmsg_hclass_t msg_content_type_class[] =MSG_HEADER_CLASS(msg_, content_type, "Content-Type", "c", c_params,		 single, msg_content_type, msg_content_type);issize_t msg_content_type_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen){  msg_content_type_t *c;  assert(h);  c = (msg_content_type_t *)h;  /* "Content-type:" type/subtyp *(; parameter))) */  if (msg_mediatype_d(&s, &c->c_type) == -1 || /* compacts token / token */      (c->c_subtype = strchr(c->c_type, '/')) == NULL ||      (*s == ';' && msg_params_d(home, &s, &c->c_params) == -1) ||      (*s != '\0'))    return -1;  c->c_subtype++;  return 0;}issize_t msg_content_type_e(char b[], isize_t bsiz, msg_header_t const *h, int flags){  char *b0 = b, *end = b + bsiz;  msg_content_type_t const *c = (msg_content_type_t *)h;  assert(msg_is_content_type(h));  MSG_STRING_E(b, end, c->c_type);  MSG_PARAMS_E(b, end, c->c_params, flags);  MSG_TERM_E(b, end);  return b - b0;}isize_t msg_content_type_dup_xtra(msg_header_t const *h, isize_t offset){  msg_content_type_t const *c = (msg_content_type_t *)h;  MSG_PARAMS_SIZE(offset, c->c_params);  offset += MSG_STRING_SIZE(c->c_type);  return offset;}/** Duplicate one msg_content_type_t object */char *msg_content_type_dup_one(msg_header_t *dst, msg_header_t const *src,			       char *b, isize_t xtra){  msg_content_type_t *c = (msg_content_type_t *)dst;  msg_content_type_t const *o = (msg_content_type_t *)src;  char *end = b + xtra;  b = msg_params_dup(&c->c_params, o->c_params, b, xtra);  MSG_STRING_DUP(b, c->c_type, o->c_type);  c->c_subtype = c->c_type ? strchr(c->c_type, '/') : NULL;  if (c->c_subtype)    c->c_subtype++;  assert(b <= end); (void)end;  return b;}/* ====================================================================== *//**@ingroup msg_mime * @defgroup msg_mime_version MIME-Version Header * * MIME-Version header indicates what version of the protocol was used * to construct the message.  Its syntax is defined in [H19.4.1, S20.24] * as follows: * * @code *    MIME-Version   = "MIME-Version" ":" 1*DIGIT "." 1*DIGIT * @endcode *//**@ingroup msg_mime_version * @typedef struct msg_generic_s msg_mime_version_t;  * * The structure msg_mime_version_t contains representation of an @b * MIME-Version header. * * The msg_mime_version_t is defined as follows: * @code * typedef struct msg_generic_s * { *   msg_common_t   g_common[1];    // Common fragment info *   msg_generic_t *g_next;	    // Link to next header *   char const    *g_string;	    // Header value * } msg_mime_version_t; * @endcode */msg_hclass_t msg_mime_version_class[] =MSG_HEADER_CLASS_G(mime_version, "MIME-Version", "", single);issize_t msg_mime_version_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen){  return msg_generic_d(home, h, s, slen);}issize_t msg_mime_version_e(char b[], isize_t bsiz, msg_header_t const *h, int f){  assert(msg_is_mime_version(h));  return msg_generic_e(b, bsiz, h, f);}/* ====================================================================== *//**@ingroup msg_mime * @defgroup msg_content_location Content-Location Header * * *//**@ingroup msg_content_location * @typedef struct msg_generic_s msg_content_location_t;  * * The structure msg_content_location_t contains representation of an @b * Content-Location header. * * The msg_content_location_t is defined as follows: * @code * typedef struct msg_generic_s * { *   msg_common_t   g_common[1];    // Common fragment info *   msg_generic_t *g_next;	    // Link to next header *   char const    *g_string;	    // Header value * } msg_content_location_t; * @endcode */#define msg_content_location_d msg_generic_d#define msg_content_location_e msg_generic_emsg_hclass_t msg_content_location_class[] =MSG_HEADER_CLASS_G(content_location, "Content-Location", "", single);/* ====================================================================== */#if 0/**@ingroup msg_mime * @defgroup msg_content_base Content-Base Header * * @RFC2617: * Content-Base was deleted from the specification: it was not * implemented widely, and there is no simple, safe way to introduce it * without a robust extension mechanism. In addition, it is used in a * similar, but not identical fashion in MHTML [45]. * *//**@ingroup msg_content_base * @typedef msg_generic_t msg_content_base_t; * Content-Base Header Structure. * @code * typedef struct * { *   msg_common_t        g_common[1];    // Common fragment info *   msg_content_base_t *g_next;	 // Link to next header *   char const         *g_string;       // Header value * } * @endcode */#define msg_content_base_d msg_generic_d#define msg_content_base_e msg_generic_emsg_hclass_t msg_content_base_class[] =MSG_HEADER_CLASS_G(content_base, "Content-Base", "", single);#endif/* ====================================================================== *//**@ingroup msg_mime * @defgroup msg_content_transfer_encoding Content-Transfer-Encoding Header * * *//**@ingroup msg_content_transfer_encoding * @typedef struct msg_generic_s msg_content_transfer_encoding_t;  * * The structure msg_content_transfer_encoding_t contains representation of * an @b Content-Transfer-Encoding header. * * The msg_content_transfer_encoding_t is defined as follows: * @code * typedef struct msg_generic_s * { *   msg_common_t   g_common[1];    // Common fragment info *   msg_generic_t *g_next;	    // Link to next header *   char const    *g_string;	    // Header value * } msg_content_transfer_encoding_t; * @endcode */#define msg_content_transfer_encoding_d msg_generic_d#define msg_content_transfer_encoding_e msg_generic_emsg_hclass_t msg_content_transfer_encoding_class[] =MSG_HEADER_CLASS_G(content_transfer_encoding, "Content-Transfer-Encoding",		   "", single);/* ====================================================================== *//**@ingroup msg_mime * @defgroup msg_warning Warning Header *  * The Warning response-header field is used to carry additional information * about the status of a response. Its syntax is defined in [S20.43] * as follows: *  * @code *    Warning        =  "Warning" HCOLON warning-value *(COMMA warning-value) *    warning-value  =  warn-code SP warn-agent SP warn-text *    warn-code      =  3DIGIT *    warn-agent     =  hostport / pseudonym *                      ;  the name or pseudonym of the server adding *                      ;  the Warning header, for use in debugging *    warn-text      =  quoted-string *    pseudonym      =  token * @endcode *//**@ingroup msg_warning * @typedef struct msg_warning_s msg_warning_t;  * * The structure msg_warning_t contains representation of an @b * Warning header. * * The msg_warning_t is defined as follows: * @code * typedef struct msg_warning_s * { *   msg_common_t        w_common[1];  // Common fragment info *   msg_warning_t      *w_next;       // Link to next Warning header *   unsigned            w_code;       // Warning code *   char const         *w_host;       // Hostname or pseudonym *   char const         *w_port;       // Port number *   char const         *w_text;       // Warning text * } msg_warning_t; * @endcode */issize_t msg_warning_d(su_home_t *home, msg_header_t *h, char *s, isize_t slen){  msg_warning_t *w = (msg_warning_t *)h;  char *text;  while (*s == ',')   /* Ignore empty entries (comma-whitespace) */    *s = '\0', s += span_lws(s + 1) + 1;  /* Parse protocol */  if (!IS_DIGIT(*s))	    return -1;  w->w_code = strtoul(s, &s, 10);  skip_lws(&s);  /* Host (and port) */  if (msg_hostport_d(&s, &w->w_host, &w->w_port) == -1)    return -1;  if (msg_quoted_d(&s, &text) == -1)    return -1;  if (msg_unquote(text, text) == NULL)    return -1;  w->w_text = text;  return msg_parse_next_field(home, h, s, slen);}issize_t msg_warning_e(char b[], isize_t bsiz, msg_header_t const *h, int f){  msg_warning_t const *w = (msg_warning_t *)h;  char const *port = w->w_port;  int n;  size_t m;  n = snprintf(b, bsiz, "%03u %s%s%s ", 	       w->w_code, w->w_host, port ? ":" : "", port ? port : "");  if (n < 0)    return n;  m = msg_unquoted_e((size_t)n < bsiz ? b + n : NULL, bsiz - n, w->w_text);  if (b && n + m < bsiz)    b[n + m] = '\0';  return n + m;}isize_t msg_warning_dup_xtra(msg_header_t const *h, isize_t offset){  msg_warning_t const *w = (msg_warning_t *)h;  offset += MSG_STRING_SIZE(w->w_host);  offset += MSG_STRING_SIZE(w->w_port);  offset += MSG_STRING_SIZE(w->w_text);  return offset;}char *msg_warning_dup_one(msg_header_t *dst, 			  msg_header_t const *src, 			  char *b, 			  isize_t xtra){  msg_warning_t *w = (msg_warning_t *)dst;  msg_warning_t const *o = (msg_warning_t *)src;  char *end = b + xtra;  w->w_code = o->w_code;  MSG_STRING_DUP(b, w->w_host, o->w_host);  MSG_STRING_DUP(b, w->w_port, o->w_port);  MSG_STRING_DUP(b, w->w_text, o->w_text);  assert(b <= end); (void)end;  return b;}#define msg_warning_update NULLmsg_hclass_t msg_warning_class[] =   MSG_HEADER_CLASS(msg_, warning, "Warning", "", w_common, append, 		   msg_warning, msg_warning);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -