sip  1.12.11devel
sip_parser.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef SIP_PARSER_H
27 #define SIP_PARSER_H
28 
29 
43 #ifndef SU_ALLOC_H
44 #include <sofia-sip/su_alloc.h>
45 #endif
46 
47 #ifndef MSG_H
48 #include <sofia-sip/msg.h>
49 #endif
50 
51 #ifndef MSG_PARSER_H
52 #include <sofia-sip/msg_parser.h>
53 #endif
54 
55 #ifndef SIP_H
56 #include <sofia-sip/sip.h>
57 #endif
58 
59 #ifndef SIP_HEADER_H
60 #include <sofia-sip/sip_header.h>
61 #endif
62 
63 #ifndef SOFIA_SIP_SU_STRING_H
64 #include <sofia-sip/su_string.h>
65 #endif
66 
67 SOFIA_BEGIN_DECLS
68 
69 /* ---------------------------------------------------------------------------
70  * 1) Macros for defining boilerplate functions and structures for each header
71  */
72 
73 #define SIP_HDR_TEST(x) ((x)->sh_class)
74 
76 #define SIP_HEADER_CLASS(c, l, s, params, kind, dup) \
77  MSG_HEADER_CLASS(sip_, c, l, s, params, kind, sip_ ## dup, sip_ ## dup)
78 
80 #define SIP_HEADER_CLASS_C(c, l, s, params, kind, dup) \
81  MSG_HEADER_CLASS_C(sip_, c, l, s, params, kind, sip_ ## dup, sip_ ## dup)
82 
84 #define SIP_HEADER_CLASS_G(c, l, s, kind) \
85  MSG_HEADER_CLASS(sip_, c, l, s, g_common, kind, msg_generic, sip_null)
86 
88 #define SIP_HEADER_CLASS_LIST(c, l, s, kind) \
89  MSG_HEADER_CLASS(sip_, c, l, s, k_items, kind, msg_list, sip_null)
90 
92 #define SIP_HEADER_CLASS_AUTH(c, l, kind) \
93  MSG_HEADER_CLASS(sip_, c, l, "", au_params, kind, msg_auth, sip_null)
94 
95 #define sip_null_update NULL
96 #define sip_any_update NULL
97 
98 /* ---------------------------------------------------------------------------
99  * 2) Prototypes for internal decoding/encoding functions
100  */
101 
102 /* Version string */
103 SOFIAPUBFUN int sip_version_d(char **ss, char const **ver);
104 SOFIAPUBFUN isize_t sip_version_xtra(char const *version);
105 SOFIAPUBFUN void sip_version_dup(char **pp, char const **dd, char const *s);
106 
107 /* Transport identifiers */
108 #define SIP_TRANSPORT_LEN(s) SIP_STRING_SIZE((s))
109 SOFIAPUBFUN issize_t sip_transport_d(char **ss, char const **ttransport);
110 SOFIAPUBFUN isize_t sip_transport_xtra(char const *transport);
111 SOFIAPUBFUN void sip_transport_dup(char **pp, char const **dd, char const *s);
112 
113 /* Method */
114 SOFIAPUBFUN sip_method_t sip_method_d(char **ss, char const **nname);
115 
116 /* Call-ID */
117 SOFIAPUBFUN char *sip_word_at_word_d(char **ss);
118 
120 SOFIAPUBFUN issize_t sip_extract_body(msg_t *, sip_t *, char b[], isize_t bsiz, int eos);
121 
122 SOFIAPUBFUN issize_t sip_any_route_d(su_home_t *, sip_header_t *, char *s, isize_t slen);
123 SOFIAPUBFUN issize_t sip_any_route_e(char [], isize_t, sip_header_t const *, int flags);
124 SOFIAPUBFUN isize_t sip_any_route_dup_xtra(sip_header_t const *h, isize_t offset);
125 SOFIAPUBFUN char *sip_any_route_dup_one(sip_header_t *dst,
126  sip_header_t const *src,
127  char *b, isize_t xtra);
128 #define sip_any_route_update NULL
129 
130 SOFIAPUBFUN issize_t sip_name_addr_d(su_home_t *home,
131  char **inout_s,
132  char const **return_display,
133  url_t *out_url,
134  msg_param_t const **return_params,
135  char const **return_comment);
136 
137 SOFIAPUBFUN issize_t sip_name_addr_e(char b[], isize_t bsiz,
138  int flags,
139  char const *display,
140  int always_ltgt, url_t const url[],
141  msg_param_t const params[],
142  char const *comment);
143 
144 SOFIAPUBFUN isize_t sip_name_addr_xtra(char const *display, url_t const *addr,
145  msg_param_t const params[],
146  isize_t offset);
147 
148 SOFIAPUBFUN char *sip_name_addr_dup(char const **d_display, char const *display,
149  url_t *d_addr, url_t const *addr,
150  msg_param_t const **d_params,
151  msg_param_t const params[],
152  char *b, isize_t xtra);
153 
154 
155 /* ---------------------------------------------------------------------------
156  * 3) Compatibility macros and functions
157  */
158 
159 #define sip_generic_d msg_generic_d
160 #define sip_generic_e msg_generic_e
161 
162 #define sip_numeric_d msg_numeric_d
163 #define sip_numeric_e msg_numeric_e
164 
165 #define sip_any_copy_xtra msg_default_copy_xtra
166 #define sip_any_copy_one msg_default_copy_one
167 #define sip_any_dup_xtra msg_default_dup_xtra
168 #define sip_any_dup_one msg_default_dup_one
169 
170 #define sip_generic_dup_xtra msg_generic_dup_xtra
171 #define sip_generic_dup_one msg_generic_dup_one
172 
173 
174 #define sip_auth_d msg_auth_d
175 #define sip_auth_e msg_auth_e
176 
177 #define sip_header_dup_as msg_header_dup_as
178 #define sip_header_alloc msg_header_alloc
179 #define sip_header_copy_as msg_header_copy_as
180 
181 #define SIP_ALIGN MSG_ALIGN
182 #define SIP_STRUCT_SIZE_ALIGN MSG_STRUCT_SIZE_ALIGN
183 #define SIP_STRUCT_ALIGN MSG_STRUCT_ALIGN
184 
185 #define sip_comment_d msg_comment_d
186 #define sip_quoted_d(ss, qq) msg_quoted_d(ss, qq)
187 
188 #define SIP_CHAR_E MSG_CHAR_E
189 #define SIP_STRING_LEN MSG_STRING_LEN
190 #define SIP_STRING_E MSG_STRING_E
191 #define SIP_STRING_DUP MSG_STRING_DUP
192 #define SIP_STRING_SIZE MSG_STRING_SIZE
193 #define SIP_NAME_E MSG_NAME_E
194 
195 /* Parameters */
196 #define SIP_PARAM_MATCH MSG_PARAM_MATCH
197 #define SIP_PARAM_MATCH_P MSG_PARAM_MATCH_P
198 
199 /* Parameter lists */
200 #define SIP_N_PARAMS MSG_N_PARAMS
201 #define sip_params_d msg_params_d
202 #define sip_params_dup msg_params_dup
203 #define SIP_PARAMS_NUM MSG_PARAMS_NUM
204 #define SIP_PARAMS_E MSG_PARAMS_E
205 #define SIP_PARAMS_SIZE MSG_PARAMS_SIZE
206 #define sip_params_count msg_params_count
207 #define sip_params_copy_xtra msg_params_copy_xtra
208 #define sip_params_copy msg_params_copy
209 
210 SOFIAPUBFUN int sip_generic_xtra(sip_generic_t const *g);
211 
212 SOFIAPUBFUN sip_generic_t *sip_generic_dup(su_home_t *home,
213  msg_hclass_t *hc,
214  sip_generic_t const *u);
215 
216 SOFIAPUBFUN sip_generic_t *sip_generic_copy(su_home_t *home,
217  msg_hclass_t *hc,
218  sip_generic_t const *o);
219 
220 SOFIA_END_DECLS
221 
222 #endif
struct msg_hclass_s const msg_hclass_t
SIP objects.
union sip_header_u sip_header_t
Any SIP header - union of all possible SIP headers.
Definition: sip.h:114
sip_method_t
IDs for well-known SIP methods.
Definition: sip.h:48
SIP parser library prototypes.
char * sip_name_addr_dup(char const **d_display, char const *display, url_t *d_addr, url_t const *addr, msg_param_t const **d_params, msg_param_t const params[], char *b, isize_t xtra)
Duplicate a name-addr-params construct.
Definition: sip_basic.c:841
void sip_version_dup(char **pp, char const **dd, char const *s)
Duplicate a transport string.
Definition: sip_parser.c:292
issize_t sip_transport_d(char **ss, char const **ttransport)
Decode transport.
Definition: sip_parser.c:461
int sip_version_d(char **ss, char const **ver)
Parse SIP version.
Definition: sip_parser.c:229
issize_t sip_name_addr_e(char b[], isize_t bsiz, int flags, char const *display, int always_ltgt, url_t const url[], msg_param_t const params[], char const *comment)
Encode name-addr and parameter list.
Definition: sip_basic.c:764
sip_method_t sip_method_d(char **ss, char const **nname)
Parse a SIP method name.
Definition: sip_parser.c:369
issize_t sip_extract_body(msg_t *, sip_t *, char b[], isize_t bsiz, int eos)
Extract SIP message body, including separator line.
Definition: sip_parser.c:168
issize_t sip_name_addr_d(su_home_t *home, char **inout_s, char const **return_display, url_t *out_url, msg_param_t const **return_params, char const **return_comment)
Parse name-addr.
Definition: sip_basic.c:648
issize_t sip_any_route_d(su_home_t *, sip_header_t *, char *s, isize_t slen)
Parse a Route or a Record-Route header.
Definition: sip_basic.c:2104
void sip_transport_dup(char **pp, char const **dd, char const *s)
Duplicate a transport string.
Definition: sip_parser.c:547
char * sip_word_at_word_d(char **ss)
Parse SIP <word "@" word> construct used in Call-ID.
Definition: sip_parser.c:570
isize_t sip_name_addr_xtra(char const *display, url_t const *addr, msg_param_t const params[], isize_t offset)
Calculate the extra size needed to duplicate a name-addr-params construct.
Definition: sip_basic.c:816
isize_t sip_version_xtra(char const *version)
Calculate extra space required by version string.
Definition: sip_parser.c:284
isize_t sip_transport_xtra(char const *transport)
Calculate extra space required by sip_transport_dup()
Definition: sip_parser.c:531
SIP message object.
Definition: sip.h:230
SU_HOME_T su_home_t
#define SOFIAPUBFUN

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.