sip 1.12.11devel
|
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 #ifndef SOFIA_SIP_SU_STRING_H 00064 #include <sofia-sip/su_string.h> 00065 #endif 00066 00067 SOFIA_BEGIN_DECLS 00068 00069 /* --------------------------------------------------------------------------- 00070 * 1) Macros for defining boilerplate functions and structures for each header 00071 */ 00072 00073 #define SIP_HDR_TEST(x) ((x)->sh_class) 00074 00076 #define SIP_HEADER_CLASS(c, l, s, params, kind, dup) \ 00077 MSG_HEADER_CLASS(sip_, c, l, s, params, kind, sip_ ## dup, sip_ ## dup) 00078 00080 #define SIP_HEADER_CLASS_C(c, l, s, params, kind, dup) \ 00081 MSG_HEADER_CLASS_C(sip_, c, l, s, params, kind, sip_ ## dup, sip_ ## dup) 00082 00084 #define SIP_HEADER_CLASS_G(c, l, s, kind) \ 00085 MSG_HEADER_CLASS(sip_, c, l, s, g_common, kind, msg_generic, sip_null) 00086 00088 #define SIP_HEADER_CLASS_LIST(c, l, s, kind) \ 00089 MSG_HEADER_CLASS(sip_, c, l, s, k_items, kind, msg_list, sip_null) 00090 00092 #define SIP_HEADER_CLASS_AUTH(c, l, kind) \ 00093 MSG_HEADER_CLASS(sip_, c, l, "", au_params, kind, msg_auth, sip_null) 00094 00095 #define sip_null_update NULL 00096 #define sip_any_update NULL 00097 00098 /* --------------------------------------------------------------------------- 00099 * 2) Prototypes for internal decoding/encoding functions 00100 */ 00101 00102 /* Version string */ 00103 SOFIAPUBFUN int sip_version_d(char **ss, char const **ver); 00104 SOFIAPUBFUN isize_t sip_version_xtra(char const *version); 00105 SOFIAPUBFUN void sip_version_dup(char **pp, char const **dd, char const *s); 00106 00107 /* Transport identifiers */ 00108 #define SIP_TRANSPORT_LEN(s) SIP_STRING_SIZE((s)) 00109 SOFIAPUBFUN issize_t sip_transport_d(char **ss, char const **ttransport); 00110 SOFIAPUBFUN isize_t sip_transport_xtra(char const *transport); 00111 SOFIAPUBFUN void sip_transport_dup(char **pp, char const **dd, char const *s); 00112 00113 /* Method */ 00114 SOFIAPUBFUN sip_method_t sip_method_d(char **ss, char const **nname); 00115 00116 /* Call-ID */ 00117 SOFIAPUBFUN char *sip_word_at_word_d(char **ss); 00118 00120 SOFIAPUBFUN issize_t sip_extract_body(msg_t *, sip_t *, char b[], isize_t bsiz, int eos); 00121 00122 SOFIAPUBFUN issize_t sip_any_route_d(su_home_t *, sip_header_t *, char *s, isize_t slen); 00123 SOFIAPUBFUN issize_t sip_any_route_e(char [], isize_t, sip_header_t const *, int flags); 00124 SOFIAPUBFUN isize_t sip_any_route_dup_xtra(sip_header_t const *h, isize_t offset); 00125 SOFIAPUBFUN char *sip_any_route_dup_one(sip_header_t *dst, 00126 sip_header_t const *src, 00127 char *b, isize_t xtra); 00128 #define sip_any_route_update NULL 00129 00130 SOFIAPUBFUN issize_t sip_name_addr_d(su_home_t *home, 00131 char **inout_s, 00132 char const **return_display, 00133 url_t *out_url, 00134 msg_param_t const **return_params, 00135 char const **return_comment); 00136 00137 SOFIAPUBFUN issize_t sip_name_addr_e(char b[], isize_t bsiz, 00138 int flags, 00139 char const *display, 00140 int always_ltgt, url_t const url[], 00141 msg_param_t const params[], 00142 char const *comment); 00143 00144 SOFIAPUBFUN isize_t sip_name_addr_xtra(char const *display, url_t const *addr, 00145 msg_param_t const params[], 00146 isize_t offset); 00147 00148 SOFIAPUBFUN char *sip_name_addr_dup(char const **d_display, char const *display, 00149 url_t *d_addr, url_t const *addr, 00150 msg_param_t const **d_params, 00151 msg_param_t const params[], 00152 char *b, isize_t xtra); 00153 00154 00155 /* --------------------------------------------------------------------------- 00156 * 3) Compatibility macros and functions 00157 */ 00158 00159 #define sip_generic_d msg_generic_d 00160 #define sip_generic_e msg_generic_e 00161 00162 #define sip_numeric_d msg_numeric_d 00163 #define sip_numeric_e msg_numeric_e 00164 00165 #define sip_any_copy_xtra msg_default_copy_xtra 00166 #define sip_any_copy_one msg_default_copy_one 00167 #define sip_any_dup_xtra msg_default_dup_xtra 00168 #define sip_any_dup_one msg_default_dup_one 00169 00170 #define sip_generic_dup_xtra msg_generic_dup_xtra 00171 #define sip_generic_dup_one msg_generic_dup_one 00172 00173 00174 #define sip_auth_d msg_auth_d 00175 #define sip_auth_e msg_auth_e 00176 00177 #define sip_header_dup_as msg_header_dup_as 00178 #define sip_header_alloc msg_header_alloc 00179 #define sip_header_copy_as msg_header_copy_as 00180 00181 #define SIP_ALIGN MSG_ALIGN 00182 #define SIP_STRUCT_SIZE_ALIGN MSG_STRUCT_SIZE_ALIGN 00183 #define SIP_STRUCT_ALIGN MSG_STRUCT_ALIGN 00184 00185 #define sip_comment_d msg_comment_d 00186 #define sip_quoted_d(ss, qq) msg_quoted_d(ss, qq) 00187 00188 #define SIP_CHAR_E MSG_CHAR_E 00189 #define SIP_STRING_LEN MSG_STRING_LEN 00190 #define SIP_STRING_E MSG_STRING_E 00191 #define SIP_STRING_DUP MSG_STRING_DUP 00192 #define SIP_STRING_SIZE MSG_STRING_SIZE 00193 #define SIP_NAME_E MSG_NAME_E 00194 00195 /* Parameters */ 00196 #define SIP_PARAM_MATCH MSG_PARAM_MATCH 00197 #define SIP_PARAM_MATCH_P MSG_PARAM_MATCH_P 00198 00199 /* Parameter lists */ 00200 #define SIP_N_PARAMS MSG_N_PARAMS 00201 #define sip_params_d msg_params_d 00202 #define sip_params_dup msg_params_dup 00203 #define SIP_PARAMS_NUM MSG_PARAMS_NUM 00204 #define SIP_PARAMS_E MSG_PARAMS_E 00205 #define SIP_PARAMS_SIZE MSG_PARAMS_SIZE 00206 #define sip_params_count msg_params_count 00207 #define sip_params_copy_xtra msg_params_copy_xtra 00208 #define sip_params_copy msg_params_copy 00209 00210 SOFIAPUBFUN int sip_generic_xtra(sip_generic_t const *g); 00211 00212 SOFIAPUBFUN sip_generic_t *sip_generic_dup(su_home_t *home, 00213 msg_hclass_t *hc, 00214 sip_generic_t const *u); 00215 00216 SOFIAPUBFUN sip_generic_t *sip_generic_copy(su_home_t *home, 00217 msg_hclass_t *hc, 00218 sip_generic_t const *o); 00219 00220 SOFIA_END_DECLS 00221 00222 #endif