sip 1.12.10
|
00001 /* 00002 * This file is part of the Sofia-SIP package 00003 * 00004 * Copyright (C) 2005 Nokia Corporation. 00005 * 00006 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation; either version 2.1 of 00011 * the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 * 00023 */ 00024 00025 #ifndef SIP_PARSER_H 00026 00027 #define SIP_PARSER_H 00028 00029 00043 #ifndef SU_ALLOC_H 00044 #include <sofia-sip/su_alloc.h> 00045 #endif 00046 00047 #ifndef MSG_H 00048 #include <sofia-sip/msg.h> 00049 #endif 00050 00051 #ifndef MSG_PARSER_H 00052 #include <sofia-sip/msg_parser.h> 00053 #endif 00054 00055 #ifndef SIP_H 00056 #include <sofia-sip/sip.h> 00057 #endif 00058 00059 #ifndef SIP_HEADER_H 00060 #include <sofia-sip/sip_header.h> 00061 #endif 00062 00063 SOFIA_BEGIN_DECLS 00064 00065 /* --------------------------------------------------------------------------- 00066 * 1) Macros for defining boilerplate functions and structures for each header 00067 */ 00068 00069 #define SIP_HDR_TEST(x) ((x)->sh_class) 00070 00072 #define SIP_HEADER_CLASS(c, l, s, params, kind, dup) \ 00073 MSG_HEADER_CLASS(sip_, c, l, s, params, kind, sip_ ## dup, sip_ ## dup) 00074 00076 #define SIP_HEADER_CLASS_C(c, l, s, params, kind, dup) \ 00077 MSG_HEADER_CLASS_C(sip_, c, l, s, params, kind, sip_ ## dup, sip_ ## dup) 00078 00080 #define SIP_HEADER_CLASS_G(c, l, s, kind) \ 00081 MSG_HEADER_CLASS(sip_, c, l, s, g_common, kind, msg_generic, sip_null) 00082 00084 #define SIP_HEADER_CLASS_LIST(c, l, s, kind) \ 00085 MSG_HEADER_CLASS(sip_, c, l, s, k_items, kind, msg_list, sip_null) 00086 00088 #define SIP_HEADER_CLASS_AUTH(c, l, kind) \ 00089 MSG_HEADER_CLASS(sip_, c, l, "", au_params, kind, msg_auth, sip_null) 00090 00091 #define sip_null_update NULL 00092 #define sip_any_update NULL 00093 00094 /* --------------------------------------------------------------------------- 00095 * 2) Prototypes for internal decoding/encoding functions 00096 */ 00097 00098 /* Version string */ 00099 SOFIAPUBFUN int sip_version_d(char **ss, char const **ver); 00100 SOFIAPUBFUN isize_t sip_version_xtra(char const *version); 00101 SOFIAPUBFUN void sip_version_dup(char **pp, char const **dd, char const *s); 00102 00103 /* Transport identifiers */ 00104 #define SIP_TRANSPORT_LEN(s) SIP_STRING_SIZE((s)) 00105 SOFIAPUBFUN issize_t sip_transport_d(char **ss, char const **ttransport); 00106 SOFIAPUBFUN isize_t sip_transport_xtra(char const *transport); 00107 SOFIAPUBFUN void sip_transport_dup(char **pp, char const **dd, char const *s); 00108 00109 /* Method */ 00110 SOFIAPUBFUN sip_method_t sip_method_d(char **ss, char const **nname); 00111 00112 /* Call-ID */ 00113 SOFIAPUBFUN char *sip_word_at_word_d(char **ss); 00114 00116 SOFIAPUBFUN issize_t sip_extract_body(msg_t *, sip_t *, char b[], isize_t bsiz, int eos); 00117 00118 SOFIAPUBFUN issize_t sip_any_route_d(su_home_t *, sip_header_t *, char *s, isize_t slen); 00119 SOFIAPUBFUN issize_t sip_any_route_e(char [], isize_t, sip_header_t const *, int flags); 00120 SOFIAPUBFUN isize_t sip_any_route_dup_xtra(sip_header_t const *h, isize_t offset); 00121 SOFIAPUBFUN char *sip_any_route_dup_one(sip_header_t *dst, 00122 sip_header_t const *src, 00123 char *b, isize_t xtra); 00124 #define sip_any_route_update NULL 00125 00126 SOFIAPUBFUN issize_t sip_name_addr_d(su_home_t *home, 00127 char **inout_s, 00128 char const **return_display, 00129 url_t *out_url, 00130 msg_param_t const **return_params, 00131 char const **return_comment); 00132 00133 SOFIAPUBFUN issize_t sip_name_addr_e(char b[], isize_t bsiz, 00134 int flags, 00135 char const *display, 00136 int always_ltgt, url_t const url[], 00137 msg_param_t const params[], 00138 char const *comment); 00139 00140 SOFIAPUBFUN isize_t sip_name_addr_xtra(char const *display, url_t const *addr, 00141 msg_param_t const params[], 00142 isize_t offset); 00143 00144 SOFIAPUBFUN char *sip_name_addr_dup(char const **d_display, char const *display, 00145 url_t *d_addr, url_t const *addr, 00146 msg_param_t const **d_params, 00147 msg_param_t const params[], 00148 char *b, isize_t xtra); 00149 00150 00151 /* --------------------------------------------------------------------------- 00152 * 3) Compatibility macros and functions 00153 */ 00154 00155 #define sip_generic_d msg_generic_d 00156 #define sip_generic_e msg_generic_e 00157 00158 #define sip_numeric_d msg_numeric_d 00159 #define sip_numeric_e msg_numeric_e 00160 00161 #define sip_any_copy_xtra msg_default_copy_xtra 00162 #define sip_any_copy_one msg_default_copy_one 00163 #define sip_any_dup_xtra msg_default_dup_xtra 00164 #define sip_any_dup_one msg_default_dup_one 00165 00166 #define sip_generic_dup_xtra msg_generic_dup_xtra 00167 #define sip_generic_dup_one msg_generic_dup_one 00168 00169 00170 #define sip_auth_d msg_auth_d 00171 #define sip_auth_e msg_auth_e 00172 00173 #define sip_header_dup_as msg_header_dup_as 00174 #define sip_header_alloc msg_header_alloc 00175 #define sip_header_copy_as msg_header_copy_as 00176 00177 #define SIP_ALIGN MSG_ALIGN 00178 #define SIP_STRUCT_SIZE_ALIGN MSG_STRUCT_SIZE_ALIGN 00179 #define SIP_STRUCT_ALIGN MSG_STRUCT_ALIGN 00180 00181 #define sip_comment_d msg_comment_d 00182 #define sip_quoted_d(ss, qq) msg_quoted_d(ss, qq) 00183 00184 #define SIP_CHAR_E MSG_CHAR_E 00185 #define SIP_STRING_LEN MSG_STRING_LEN 00186 #define SIP_STRING_E MSG_STRING_E 00187 #define SIP_STRING_DUP MSG_STRING_DUP 00188 #define SIP_STRING_SIZE MSG_STRING_SIZE 00189 #define SIP_NAME_E MSG_NAME_E 00190 00191 /* Parameters */ 00192 #define SIP_PARAM_MATCH MSG_PARAM_MATCH 00193 #define SIP_PARAM_MATCH_P MSG_PARAM_MATCH_P 00194 00195 /* Parameter lists */ 00196 #define SIP_N_PARAMS MSG_N_PARAMS 00197 #define sip_params_d msg_params_d 00198 #define sip_params_dup msg_params_dup 00199 #define SIP_PARAMS_NUM MSG_PARAMS_NUM 00200 #define SIP_PARAMS_E MSG_PARAMS_E 00201 #define SIP_PARAMS_SIZE MSG_PARAMS_SIZE 00202 #define sip_params_count msg_params_count 00203 #define sip_params_copy_xtra msg_params_copy_xtra 00204 #define sip_params_copy msg_params_copy 00205 00206 SOFIAPUBFUN int sip_generic_xtra(sip_generic_t const *g); 00207 00208 SOFIAPUBFUN sip_generic_t *sip_generic_dup(su_home_t *home, 00209 msg_hclass_t *hc, 00210 sip_generic_t const *u); 00211 00212 SOFIAPUBFUN sip_generic_t *sip_generic_copy(su_home_t *home, 00213 msg_hclass_t *hc, 00214 sip_generic_t const *o); 00215 00216 SOFIA_END_DECLS 00217 00218 #endif