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

📄 sip_mime.c

📁 Sofia SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * This file is part of the Sofia-SIP package * * Copyright (C) 2005 Nokia Corporation. * * Contact: Pekka Pessi <pekka.pessi@nokia.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * *//**@CFILE sip_mime.c  * * MIME-related SIP headers * * @author Pekka Pessi <Pekka.Pessi@nokia.com>. * * @date Created: Tue Jun 13 02:57:51 2000 ppessi */#include "config.h"/* Avoid casting sip_t to msg_pub_t and sip_header_t to msg_header_t */#define MSG_PUB_T       struct sip_s#define MSG_HDR_T       union sip_header_u#include "sofia-sip/sip_parser.h"#include "sofia-sip/msg_mime_protos.h"#include <stdio.h>#include <stddef.h>#include <stdlib.h>#include <string.h>#include <limits.h>#include <assert.h>/* ====================================================================== *//**@SIP_HEADER sip_accept Accept Header * * The @b Accept request-header field can be used to specify certain media * types which are acceptable for the response. Its syntax is defined in * [H14.1, S10.6] as follows: *  * @code *    Accept         =  "Accept" HCOLON *                       [ accept-range *(COMMA accept-range) ] *    accept-range   =  media-range *(SEMI accept-param) *    media-range    =  ( "*" "/" "*" *                      / ( m-type SLASH "*" ) *                      / ( m-type SLASH m-subtype ) *                      ) *( SEMI m-parameter ) *    accept-param   =  ("q" EQUAL qvalue) / generic-param *    qvalue         =  ( "0" [ "." 0*3DIGIT ] ) *                      / ( "1" [ "." 0*3("0") ] ) *    generic-param  =  token [ EQUAL gen-value ] *    gen-value      =  token / host / quoted-string * @endcode * * * The parsed Accept header is stored in #sip_accept_t structure. *//**@ingroup sip_accept * @typedef typedef struct sip_accept_s sip_accept_t; * * The structure #sip_accept_t contains representation of SIP * @Accept header. * * The #sip_accept_t is defined as follows: * @code * typedef struct sip_accept_s { *   sip_common_t        ac_common[1]; // Common fragment info *   sip_accept_t       *ac_next;      // Pointer to next @Acceptheader *   char const         *ac_type;      // Pointer to type/subtype *   char const         *ac_subtype;   // Points after first slash in type *   msg_param_t const  *ac_params;    // List of parameters *   char const         *ac_q;         // Value of q parameter * } sip_accept_t; * @endcode */#define sip_accept_dup_xtra msg_accept_dup_xtra#define sip_accept_dup_one  msg_accept_dup_one#define sip_accept_update   msg_accept_updatemsg_hclass_t sip_accept_class[] = SIP_HEADER_CLASS(accept, "Accept", "", ac_params, apndlist, accept);issize_t sip_accept_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  return msg_accept_d(home, h, s, slen);}issize_t sip_accept_e(char b[], isize_t bsiz, sip_header_t const *h, int flags){  return msg_accept_e(b, bsiz, h, flags);}#if SIP_HAVE_ACCEPT_DISPOSITION/* ====================================================================== *//**@SIP_HEADER sip_accept_disposition Accept-Disposition Header * * The Accept-Disposition header field is used to indicate what content * disposition types are acceptable to a client or server.  Its syntax is * defined in draft-lennox-sip-reg-payload-01.txt section 3.2 as follows: *  * @code *    Accept-Disposition = "Accept-Disposition" ":"  *                         #( (disposition-type | "*") *( ";" generic-param ) ) * @endcode * * * The parsed Accept-Disposition header * is stored in #sip_accept_disposition_t structure. */msg_hclass_t sip_accept_disposition_class[] = SIP_HEADER_CLASS(accept_disposition, "Accept-Disposition", "", 		 ad_params, apndlist, accept_disposition);issize_t sip_accept_disposition_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  sip_accept_disposition_t *ad = (sip_accept_disposition_t *)h;  assert(h);  /* Ignore empty entries (comma-whitespace) */  while (*s == ',')    s += span_lws(s + 1) + 1;  /* "Accept:" #(type/subtyp ; *(parameters))) */  if (/* Parse protocol */      sip_version_d(&s, &ad->ad_type) == -1 ||      (ad->ad_subtype = strchr(ad->ad_type, '/')) == NULL ||      (*s == ';' && msg_params_d(home, &s, &ad->ad_params) == -1))    return -1;  if (ad->ad_subtype) ad->ad_subtype++;  return msg_parse_next_field(home, h, s, slen);}issize_t sip_accept_disposition_e(char b[], isize_t bsiz, sip_header_t const *h, int flags){  char *b0 = b, *end = b + bsiz;  sip_accept_disposition_t const *ad = h->sh_accept_disposition;  MSG_STRING_E(b, end, ad->ad_type);  MSG_PARAMS_E(b, end, ad->ad_params, flags);  MSG_TERM_E(b, end);      return b - b0;}#endif/* ====================================================================== *//**@SIP_HEADER sip_accept_encoding Accept-Encoding Header * * The Accept-Encoding header is similar to Accept, but restricts the * content-codings that are acceptable in the response.  Its syntax is * defined in [H14.3, S10.7] as follows: *  * @code *    Accept-Encoding  =  "Accept-Encoding" HCOLON *                         [ encoding *(COMMA encoding) ] *    encoding         =  codings *(SEMI accept-param) *    codings          =  content-coding / "*" *    content-coding   =  token * @endcode * * * The parsed Accept-Encoding header * is stored in #sip_accept_encoding_t structure. *//**@ingroup sip_accept_encoding * @typedef typedef struct msg_accept_any_s sip_accept_encoding_t; * * The structure #sip_accept_encoding_t contains representation of SIP * @AcceptEncoding header. * * The #sip_accept_encoding_t is defined as follows: * @code * typedef struct { *   msg_common_t        aa_common[1]; // Common fragment info *   sip_accept_encoding_t *aa_next;   // Pointer to next @AcceptEncoding header *   char const            *aa_value;  // Encoding token *   msg_param_t const     *aa_params; // List of parameters *   char const            *aa_q;      // Value of q parameter  * } sip_accept_encoding_t; * @endcode */#define sip_accept_encoding_dup_xtra msg_accept_any_dup_xtra#define sip_accept_encoding_dup_one  msg_accept_any_dup_one#define sip_accept_encoding_update   msg_accept_any_updatemsg_hclass_t sip_accept_encoding_class[] = SIP_HEADER_CLASS(accept_encoding, "Accept-Encoding", "", 		 aa_params, apndlist, accept_encoding);issize_t sip_accept_encoding_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  issize_t retval = msg_accept_encoding_d(home, h, s, slen);  if (retval == -2) {    /* Empty Accept-Encoding list is not an error */    sip_accept_encoding_t *aa = (sip_accept_encoding_t *)h;    aa->aa_value = "";    retval = 0;  }  return retval;}issize_t sip_accept_encoding_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  return msg_accept_encoding_e(b, bsiz, h, f);}/* ====================================================================== *//**@SIP_HEADER sip_accept_language Accept-Language Header * * The Accept-Language header can be used to allow the client to indicate to * the server in which language it would prefer to receive reason phrases, * session descriptions or status responses carried as message bodies.  Its * syntax is defined in [H14.4, S10.8] as follows: *  * @code *    Accept-Language  =  "Accept-Language" HCOLON *                         [ language *(COMMA language) ] *    language         =  language-range *(SEMI accept-param) *    language-range   =  ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) / "*" ) * @endcode * * * The parsed Accept-Language header * is stored in #sip_accept_language_t structure. *//**@ingroup sip_accept_language * @typedef typedef struct msg_accept_any_s sip_accept_language_t; * * The structure #sip_accept_language_t contains representation of SIP * @AcceptLanguage header. * * The #sip_accept_language_t is defined as follows: * @code * typedef struct { *   msg_common_t        aa_common[1]; // Common fragment info *   sip_accept_language_t *aa_next;   // Pointer to next <language> *   char const            *aa_value;  // Language-range *   msg_param_t const     *aa_params; // List of accept-parameters *   char const            *aa_q;      // Value of q parameter  * } sip_accept_language_t; * @endcode */#define sip_accept_language_dup_xtra msg_accept_any_dup_xtra#define sip_accept_language_dup_one  msg_accept_any_dup_one#define sip_accept_language_update   msg_accept_any_updatemsg_hclass_t sip_accept_language_class[] = SIP_HEADER_CLASS(accept_language, "Accept-Language", "", 		 aa_params, apndlist, accept_language);issize_t sip_accept_language_d(su_home_t *home, sip_header_t *h, char *s, isize_t slen){  int retval = msg_accept_language_d(home, h, s, slen);  if (retval == -2) {    /* Empty Accept-Language list is not an error */    ((sip_accept_language_t *)h)->aa_value = "";    retval = 0;  }  return retval;}issize_t sip_accept_language_e(char b[], isize_t bsiz, sip_header_t const *h, int f){  return msg_accept_language_e(b, bsiz, h, f);}/* ====================================================================== *//**@SIP_HEADER sip_content_disposition Content-Disposition Header * * The Content-Disposition header field describes how the message body or, * in the case of multipart messages, a message body part is to be * interpreted by the UAC or UAS.  Its syntax is defined in @RFC3261 * as follows: *  * @code *    Content-Disposition   =  "Content-Disposition" HCOLON *                             disp-type *( SEMI disp-param ) *    disp-type             =  "render" / "session" / "icon" / "alert" *                             / disp-extension-token *    disp-param            =  handling-param / generic-param *    handling-param        =  "handling" EQUAL *                             ( "optional" / "required" *                             / other-handling ) *    other-handling        =  token *    disp-extension-token  =  token * @endcode *  * The Content-Disposition header was extended by * draft-lennox-sip-reg-payload-01.txt section 3.1 as follows: * * @code *    Content-Disposition      =  "Content-Disposition" ":" *                                disposition-type *( ";" disposition-param ) *    disposition-type         =  "script" | "sip-cgi" | token *    disposition-param        =  action-param *                             |  modification-date-param *                             |  generic-param *    action-param             =  "action" "=" action-value *    action-value             =  "store" | "remove" | token *    modification-date-param  =  "modification-date" "=" quoted-date-time *    quoted-date-time         =  <"> SIP-date <"> * @endcode * * The parsed Content-Disposition header * is stored in #sip_content_disposition_t structure. */

⌨️ 快捷键说明

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