47 #include <sofia-sip/bnf.h>
50 #include <sofia-sip/url.h>
60 #if HAVE_STRUCT_KEYWORDS && 0
62 #define MSG_HEADER_CLASS(pr, c, l, s, params, kind, dup, upd) \
64 hc_hash: pr##c##_hash, \
65 hc_parse: pr##c##_d, \
66 hc_print: pr##c##_e, \
67 hc_dxtra: dup##_dup_xtra, \
68 hc_dup_one: dup##_dup_one, \
69 hc_update: upd##_update, \
71 hc_len: sizeof(l) - 1, \
73 hc_size: MSG_ALIGN(sizeof(pr##c##_t), sizeof(void*)), \
74 hc_params: offsetof(pr##c##_t, params), \
75 hc_kind: msg_kind_##kind, \
79 #define MSG_HEADER_CLASS(pr, c, l, s, params, kind, dup, upd) \
90 MSG_ALIGN(sizeof(pr##c##_t), sizeof(void*)), \
91 offsetof(pr##c##_t, params), \
97 #define msg_kind_single_critical msg_kind_single, 1
98 #define msg_kind_list_critical msg_kind_list, 1
101 char b[], isize_t bsiz,
int eos);
103 char b[], isize_t bsiz,
int eos);
107 char b[], isize_t bsiz,
int eos);
129 char *b, isize_t xtra);
142 char *b, isize_t xtra);
147 char *b, isize_t xtra);
154 char *b, isize_t xtra);
163 char *b, isize_t xtra);
169 #define MSG_HEADER_DATA(h) ((char *)(h) + (h)->sh_class->hc_size)
171 #define MSG_HEADER_TEST(h) ((h) && (h)->sh_class)
176 char const **return_host,
177 char const **return_port);
186 char *s, isize_t slen);
189 #define MSG_TERM_E(p, e) ((p) < (e) ? (p)[0] = '\0' : '\0')
192 #define MSG_CHAR_E(p, e, c) (++(p) < (e) ? ((p)[-1]=(c)) : (c))
195 #define MSG_STRING_LEN(s, sep_size) ((s) ? (strlen(s) + sep_size) : 0)
198 #define MSG_STRING_E(p, e, s) do { \
199 size_t _n = strlen(s); if (p + _n+1 < e) memcpy(p, s, _n+1); p+= _n; } while(0)
202 #define MSG_STRING_DUP(p, d, s) \
203 (void)((s)?((p)=(char*)memccpy((void *)((d)=(char*)p),(s),0,INT_MAX))\
209 #define MSG_STRING_SIZE(s) ((s) ? (strlen(s) + 1) : 0)
212 msg_param_t **append_list,
213 issize_t (*scanner)(
char *s));
218 msg_param_t **append_list,
219 issize_t (*scanner)(
char *s),
223 #define MSG_COMMALIST_E(b, end, params, compact) do { \
224 char const * const *p_; char const * c_ = ""; \
225 for (p_ = (params); p_ && *p_; p_++, c_ = (compact ? "," : ", ")) \
226 { MSG_STRING_E(b, (end), c_); MSG_STRING_E(b, (end), *p_); } \
234 #define MSG_PARAM_MATCH(v, s, name) \
235 (strncasecmp(s, name "=", sizeof(name)) == 0 ? (v = s + sizeof(name)) : NULL)
238 #define MSG_PARAM_MATCH_P(v, s, name) \
239 ((strncasecmp((s), name "", sizeof(name) - 1) == 0 && \
240 ((s)[sizeof(name) - 1] == '=' || (s)[sizeof(name) - 1] == '\0')) ? \
244 #define MSG_PARAMS_NUM(n) (((n) + MSG_N_PARAMS - 1) & (size_t)(0 - MSG_N_PARAMS))
248 msg_param_t
const **return_params);
252 msg_param_t
const **return_params);
260 msg_param_t
const *src,
265 #define MSG_PARAMS_E(b, end, params, flags) \
266 (b) += msg_params_e((b), (size_t)((b) < (end) ? (end) - (b) : 0), (params))
269 #define MSG_PARAMS_SIZE(rv, params) (rv = msg_params_dup_xtra(params, rv))
273 char *b, isize_t xtra);
280 for (n = 0; params[n]; n++)
294 MSG_STRUCT_SIZE_ALIGN(offset);
296 for (n = 0; params[n]; n++)
297 offset += strlen(params[n]) + 1;
306 return (
char *)h + h->
h_class->hc_size;