00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef MSG_HEADER_H
00026
00027 #define MSG_HEADER_H
00028
00039 #include <stdarg.h>
00040 #include <string.h>
00041
00042 #ifndef SU_TYPES_H
00043 #include <sofia-sip/su_types.h>
00044 #endif
00045 #ifndef SU_ALLOC_H
00046 #include <sofia-sip/su_alloc.h>
00047 #endif
00048 #ifndef MSG_H
00049 #include <sofia-sip/msg.h>
00050 #endif
00051 #ifndef URL_H
00052 #include <sofia-sip/url.h>
00053 #endif
00054
00055 SOFIA_BEGIN_DECLS
00056
00057 SOFIAPUBFUN msg_header_t *msg_header_alloc(su_home_t *,
00058 msg_hclass_t *hc,
00059 isize_t extra)
00060 __attribute__((__malloc__));
00061
00062 SOFIAPUBFUN isize_t msg_header_size(msg_header_t const *h);
00063
00064 SOFIAPUBFUN msg_header_t **msg_header_offset(msg_t const *,
00065 msg_pub_t const *,
00066 msg_header_t const *);
00067 SOFIAPUBFUN msg_header_t **msg_hclass_offset(msg_mclass_t const *,
00068 msg_pub_t const *,
00069 msg_hclass_t *);
00070 SOFIAPUBFUN msg_header_t *msg_header_access(msg_pub_t const *pub,
00071 msg_hclass_t *hc);
00072
00073 SOFIAPUBFUN msg_header_t *msg_header_copy_as(su_home_t *home,
00074 msg_hclass_t *hc,
00075 msg_header_t const *o)
00076 __attribute__((__malloc__));
00077 SOFIAPUBFUN msg_header_t *msg_header_copy(su_home_t *home,
00078 msg_header_t const *o)
00079 __attribute__((__malloc__));
00080 SOFIAPUBFUN msg_header_t *msg_header_copy_one(su_home_t *home,
00081 msg_header_t const *o)
00082 __attribute__((__malloc__));
00083 SOFIAPUBFUN msg_header_t *msg_header_dup_as(su_home_t *home,
00084 msg_hclass_t *hc,
00085 msg_header_t const *o)
00086 __attribute__((__malloc__));
00087 SOFIAPUBFUN msg_header_t *msg_header_dup(su_home_t *home,
00088 msg_header_t const *h)
00089 __attribute__((__malloc__));
00090 SOFIAPUBFUN msg_header_t *msg_header_dup_one(su_home_t *home,
00091 msg_header_t const *h)
00092 __attribute__((__malloc__));
00093
00094 SOFIAPUBFUN msg_header_t *msg_header_d(su_home_t *home,
00095 msg_t const *msg,
00096 char const *b);
00097 SOFIAPUBFUN issize_t msg_header_e(char b[], isize_t bsiz,
00098 msg_header_t const *h,
00099 int flags);
00100 SOFIAPUBFUN issize_t msg_object_e(char b[], isize_t size,
00101 msg_pub_t const *mo,
00102 int flags);
00103
00104 SOFIAPUBFUN issize_t msg_header_field_e(char b[], isize_t bsiz,
00105 msg_header_t const *h,
00106 int flags);
00107
00108 SOFIAPUBFUN int msg_header_remove(msg_t *msg,
00109 msg_pub_t *mo,
00110 msg_header_t *h);
00111
00112 SOFIAPUBFUN int msg_header_remove_all(msg_t *msg,
00113 msg_pub_t *mo,
00114 msg_header_t *h);
00115
00116 SOFIAPUBFUN int msg_header_insert(msg_t *msg, msg_pub_t *mo,
00117 msg_header_t *h);
00118
00119 SOFIAPUBFUN int msg_header_replace(msg_t *msg, msg_pub_t *mo,
00120 msg_header_t *old_header,
00121 msg_header_t *new_header);
00122
00123 SOFIAPUBFUN int msg_header_add_dup(msg_t *msg,
00124 msg_pub_t *pub,
00125 msg_header_t const *o);
00126
00127 SOFIAPUBFUN int msg_header_add_str(msg_t *msg,
00128 msg_pub_t *pub,
00129 char const *str);
00130
00131 SOFIAPUBFUN int msg_header_parse_str(msg_t *msg,
00132 msg_pub_t *pub,
00133 char *s);
00134
00135 SOFIAPUBFUN int msg_header_add_dup_as(msg_t *msg,
00136 msg_pub_t *pub,
00137 msg_hclass_t *hc,
00138 msg_header_t const *o);
00139
00140 SOFIAPUBFUN int msg_header_add_make(msg_t *msg,
00141 msg_pub_t *pub,
00142 msg_hclass_t *hc,
00143 char const *s);
00144
00145 SOFIAPUBFUN int msg_header_add_format(msg_t *msg,
00146 msg_pub_t *pub,
00147 msg_hclass_t *hc,
00148 char const *fmt,
00149 ...);
00150
00151 SOFIAPUBFUN int msg_header_prepend(msg_t *msg,
00152 msg_pub_t *pub,
00153 msg_header_t **hh,
00154 msg_header_t *h);
00155
00156 SOFIAPUBFUN msg_header_t *msg_header_make(su_home_t *home,
00157 msg_hclass_t *hc,
00158 char const *s)
00159 __attribute__((__malloc__));
00160
00161 SOFIAPUBFUN msg_header_t *msg_header_format(su_home_t *home,
00162 msg_hclass_t *hc,
00163 char const *fmt, ...)
00164 __attribute__ ((__malloc__, __format__ (printf, 3, 4)));
00165
00166 SOFIAPUBFUN msg_header_t *msg_header_vformat(su_home_t *home,
00167 msg_hclass_t *hc,
00168 char const *fmt,
00169 va_list ap)
00170 __attribute__((__malloc__));
00171
00172
00173 SOFIAPUBFUN void msg_header_free(su_home_t *home,
00174 msg_header_t *h);
00175
00176 SOFIAPUBFUN void msg_header_free_all(su_home_t *home,
00177 msg_header_t *h);
00178
00179 SOFIAPUBFUN msg_payload_t *msg_payload_create(su_home_t *home,
00180 void const *data,
00181 usize_t len)
00182 __attribute__((__malloc__));
00183
00184 SOFIAPUBFUN msg_separator_t *msg_separator_create(su_home_t *home)
00185 __attribute__((__malloc__));
00186
00187
00188
00190 #define MSG_CHUNK_BUFFER(pl) \
00191 ((char *)pl->pl_common->h_data + (pl)->pl_common->h_len)
00192
00193 #define MSG_CHUNK_AVAIL(pl) \
00194 ((pl)->pl_len + ((pl)->pl_data - (char *)pl->pl_common->h_data) - \
00195 (pl)->pl_common->h_len)
00196
00197 #define MSG_CHUNK_NEXT(pl) \
00198 ((pl)->pl_next)
00199
00200 SOFIAPUBFUN issize_t msg_headers_prepare(msg_t *,
00201 msg_header_t *headers,
00202 int flags);
00203
00204 #ifdef SU_HAVE_INLINE
00205
00206 su_inline void msg_fragment_clear(msg_common_t *h)
00207 {
00208 h->h_data = NULL, h->h_len = 0;
00209 }
00210
00212 su_inline
00213 msg_param_t **msg_header_params(msg_common_t const *h)
00214 {
00215 if (h && h->h_class->hc_params) {
00216 return (msg_param_t **)((char *)h + h->h_class->hc_params);
00217 }
00218 return NULL;
00219 }
00220 #else
00221 #define msg_fragment_clear(h) ((h)->h_data = NULL, (h)->h_len = 0)
00222 #define msg_header_params(h) \
00223 (((h) && ((msg_common_t *)h)->h_class->hc_params) ? \
00224 (msg_param_t **)((char *)(h) + ((msg_common_t *)h)->h_class->hc_params) : NULL)
00225 #endif
00226
00227 SOFIAPUBFUN void msg_fragment_clear_chain(msg_header_t *h);
00228
00229 SOFIAPUBFUN char const *msg_header_find_param(msg_common_t const *,
00230 char const *name);
00231 SOFIAPUBFUN int msg_header_add_param(su_home_t *, msg_common_t *h,
00232 char const *param);
00233 SOFIAPUBFUN int msg_header_replace_param(su_home_t *, msg_common_t *h,
00234 char const *param);
00235 SOFIAPUBFUN int msg_header_remove_param(msg_common_t *h, char const *name);
00236
00237 SOFIAPUBFUN char const *msg_header_find_item(msg_common_t const *h,
00238 char const *item);
00239
00240 SOFIAPUBFUN int msg_header_replace_item(su_home_t *, msg_common_t *h,
00241 char const *item);
00242 SOFIAPUBFUN int msg_header_remove_item(msg_common_t *h, char const *name);
00243
00245 SOFIAPUBFUN int msg_list_append_items(su_home_t *home,
00246 msg_list_t *k,
00247 msg_param_t const items[]);
00248
00250 SOFIAPUBFUN int msg_list_replace_items(su_home_t *home,
00251 msg_list_t *k,
00252 msg_param_t const items[]);
00253
00254 SOFIAPUBFUN int msg_header_join_items(su_home_t *home,
00255 msg_common_t *dst,
00256 msg_common_t const *src,
00257 int duplicate);
00258
00259 SOFIAPUBFUN issize_t msg_random_token(char token[], isize_t tlen,
00260 void const *d, isize_t dlen);
00261
00262 SOFIAPUBFUN msg_param_t msg_params_find(msg_param_t const pp[],
00263 char const *name);
00264 SOFIAPUBFUN msg_param_t *msg_params_find_slot(msg_param_t [],
00265 char const *name);
00266 SOFIAPUBFUN int msg_params_add(su_home_t *sh,
00267 msg_param_t **pp,
00268 char const *param);
00269 SOFIAPUBFUN int msg_params_cmp(char const * const a[],
00270 char const * const b[]);
00271 SOFIAPUBFUN int msg_params_replace(su_home_t *,
00272 char const * **inout_paramlist,
00273 char const *);
00274 SOFIAPUBFUN int msg_params_remove(char const **paramlist,
00275 char const *name);
00276 SOFIAPUBFUN size_t msg_params_length(char const * const * params);
00277
00279 SOFIAPUBFUN char *msg_unquote_dup(su_home_t *home, char const *q)
00280 __attribute__((__malloc__));
00281
00282 SOFIAPUBFUN char *msg_unquote(char *dst, char const *s);
00283
00285 SOFIAPUBFUN unsigned long msg_hash_string(char const *id);
00286
00287
00288 #define MSG_ALIGN(p, t) (((uintptr_t)(p) + (t) - 1) & (0 - (uintptr_t)(t)))
00289 #define MSG_STRUCT_SIZE_ALIGN(rv) ((rv) = MSG_ALIGN(rv, sizeof(void *)))
00290 #define MSG_STRUCT_ALIGN(p) ((p) = (void*)MSG_ALIGN(p, sizeof(void *)))
00291
00292 enum {
00293 msg_n_params = 8
00294 #define MSG_N_PARAMS msg_n_params
00295 };
00296
00298 #define MSG_HEADER_INIT(h, msg_class, size) \
00299 ((void)memset((h), 0, (size)), \
00300 (void)(((msg_common_t *)(h))->h_class = (msg_class)), \
00301 (h))
00302
00304 #define MSG_HEADER_NONE ((msg_header_t *)-1)
00305
00306 SOFIA_END_DECLS
00307
00308 #ifndef MSG_PROTOS_H
00309 #include <sofia-sip/msg_protos.h>
00310 #endif
00311
00312 #endif