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

📄 msg_mime.c

📁 sip协议栈
💻 C
📖 第 1 页 / 共 5 页
字号:
 * * 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);int msg_content_type_d(su_home_t *home, msg_header_t *h, char *s, int 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;}int msg_content_type_e(char b[], int 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;}int msg_content_type_dup_xtra(msg_header_t const *h, int offset){  int rv = offset;  msg_content_type_t const *c = (msg_content_type_t *)h;  MSG_PARAMS_SIZE(rv, c->c_params);  rv += MSG_STRING_SIZE(c->c_type);  return rv;}/** Duplicate one msg_content_type_t object */char *msg_content_type_dup_one(msg_header_t *dst, msg_header_t const *src,			       char *b, int 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 = strchr(c->c_type, '/');  c->c_subtype++;  assert(b <= 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);int msg_mime_version_d(su_home_t *home, msg_header_t *h, char *s, int slen){  return msg_generic_d(home, h, s, slen);}int msg_mime_version_e(char b[], int 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 */int msg_warning_d(su_home_t *home, msg_header_t *h, char *s, int slen){  msg_warning_t *w = (msg_warning_t *)h;  msg_header_t *h0 = h;  msg_header_t **hh = &h->sh_succ;  assert(h);  for (;*s;) {    char *text = NULL;    /* Ignore empty entries (comma-whitespace) */    if (*s == ',') { *s++ = '\0'; skip_lws(&s); continue; }    if (!h) {      /* Allocate next header structure */      if (!(h = msg_header_alloc(home, h0->sh_class, 0)))	return -1;      *hh = h; h->sh_prev = hh; hh = &h->sh_succ;      w = w->w_next = (msg_warning_t *)h;    }    /* 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;    if (*s != '\0' && *s != ',')      return -1;    h = NULL;  }  if (h)		/* Empty list */    return -1;  return 0;}int msg_warning_e(char b[], int 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;  n = snprintf(b, bsiz, "%03u %s%s%s ", 	       w->w_code, w->w_host, port ? ":" : "", port ? port : "");  if (n >= 0) {    n += msg_unquoted_e(n < bsiz ? b + n : NULL, bsiz - n, w->w_text);    if (b && n < bsiz)      b[n] = '\0';  }  return n;}int msg_warning_dup_xtra(msg_header_t const *h, int offset){  int rv = offset;  msg_warning_t const *w = (msg_warning_t *)h;  rv += MSG_STRING_SIZE(w->w_host);  rv += MSG_STRING_SIZE(w->w_port);  rv += MSG_STRING_SIZE(w->w_text);  return rv;}char *msg_warning_dup_one(msg_header_t *dst, 			  msg_header_t const *src, 			  char *b, 			  int 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);  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 + -