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 int extra)
00060 __attribute__((__malloc__));
00061
00062 SOFIAPUBFUN int 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 int msg_header_e(char b[], int bsiz,
00098 msg_header_t const *h,
00099 int flags);
00100 SOFIAPUBFUN int msg_object_e(char b[], int size,
00101 msg_pub_t const *mo,
00102 int flags);
00103
00104 SOFIAPUBFUN int msg_header_field_e(char b[], int bsiz,
00105 msg_header_t const *h,
00106 int flags);
00107
00108 SOFIAPUBFUN int msg_copy_all(msg_t *msg,
00109 msg_pub_t *dst,
00110 msg_pub_t const *src);
00111
00112 SOFIAPUBFUN int msg_header_remove(msg_t *msg,
00113 msg_pub_t *mo,
00114 msg_header_t *h);
00115 SOFIAPUBFUN int msg_header_remove_all(msg_t *msg,
00116 msg_pub_t *mo,
00117 msg_header_t *h);
00118
00119 SOFIAPUBFUN int msg_header_insert(msg_t *msg, msg_pub_t *mo,
00120 msg_header_t *h);
00121
00122 SOFIAPUBFUN int msg_header_replace(msg_t *msg, msg_pub_t *mo,
00123 msg_header_t *old_header,
00124 msg_header_t *new_header);
00125
00126 SOFIAPUBFUN int msg_header_add_dup(msg_t *msg,
00127 msg_pub_t *pub,
00128 msg_header_t const *o);
00129
00130 SOFIAPUBFUN int msg_header_add_str(msg_t *msg,
00131 msg_pub_t *pub,
00132 char const *str);
00133
00134 SOFIAPUBFUN int msg_header_add_dup_as(msg_t *msg,
00135 msg_pub_t *pub,
00136 msg_hclass_t *hc,
00137 msg_header_t const *o);
00138
00139 SOFIAPUBFUN int msg_header_add_make(msg_t *msg,
00140 msg_pub_t *pub,
00141 msg_hclass_t *hc,
00142 char const *s);
00143
00144 SOFIAPUBFUN int msg_header_prepend(msg_t *msg,
00145 msg_pub_t *pub,
00146 msg_header_t **hh,
00147 msg_header_t *h);
00148
00149 SOFIAPUBFUN msg_header_t *msg_header_make(su_home_t *home,
00150 msg_hclass_t *hc,
00151 char const *s)
00152 __attribute__((__malloc__));
00153
00154 SOFIAPUBFUN msg_header_t *msg_header_format(su_home_t *home,
00155 msg_hclass_t *hc,
00156 char const *fmt, ...)
00157 __attribute__ ((__malloc__, __format__ (printf, 3, 4)));
00158
00159 SOFIAPUBFUN msg_header_t *msg_header_vformat(su_home_t *home,
00160 msg_hclass_t *hc,
00161 char const *fmt,
00162 va_list ap)
00163 __attribute__((__malloc__));
00164
00165
00166 SOFIAPUBFUN void msg_header_free(su_home_t *home,
00167 msg_header_t *h);
00168
00169 SOFIAPUBFUN void msg_header_free_all(su_home_t *home,
00170 msg_header_t *h);
00171
00172 SOFIAPUBFUN msg_payload_t *msg_payload_create(su_home_t *home,
00173 void const *data,
00174 int len)
00175 __attribute__((__malloc__));
00176
00177 SOFIAPUBFUN msg_separator_t *msg_separator_create(su_home_t *home)
00178 __attribute__((__malloc__));
00179
00180
00181
00183 #define MSG_CHUNK_BUFFER(pl) \
00184 ((char *)pl->pl_common->h_data + (pl)->pl_common->h_len)
00185
00186 #define MSG_CHUNK_AVAIL(pl) \
00187 ((pl)->pl_len + ((pl)->pl_data - (char *)pl->pl_common->h_data) - \
00188 (pl)->pl_common->h_len)
00189
00190 #define MSG_CHUNK_NEXT(pl) \
00191 ((pl)->pl_next)
00192
00193 SOFIAPUBFUN int msg_headers_prepare(msg_t *,
00194 msg_header_t *headers,
00195 int flags);
00196
00197 #ifdef SU_HAVE_INLINE
00198
00199 static inline void msg_fragment_clear(msg_common_t *h)
00200 {
00201 h->h_data = NULL, h->h_len = 0;
00202 }
00203
00205 static inline
00206 msg_param_t **msg_header_params(msg_common_t const *h)
00207 {
00208 if (h && h->h_class->hc_params) {
00209 return (msg_param_t **)((char *)h + h->h_class->hc_params);
00210 }
00211 return NULL;
00212 }
00213 #else
00214 #define msg_fragment_clear(h) ((h)->h_data = NULL, (h)->h_len = 0)
00215 #define msg_header_params(h) \
00216 (((h) && ((msg_common_t *)h)->h_class->hc_params) ? \
00217 (msg_param_t **)((char *)(h) + ((msg_common_t *)h)->h_class->hc_params) : NULL)
00218 #endif
00219
00220 SOFIAPUBFUN char const *msg_header_find_param(msg_common_t const *,
00221 char const *name);
00222 SOFIAPUBFUN int msg_header_add_param(su_home_t *, msg_common_t *h,
00223 char const *param);
00224 SOFIAPUBFUN int msg_header_replace_param(su_home_t *, msg_common_t *h,
00225 char const *param);
00226 SOFIAPUBFUN int msg_header_remove_param(msg_common_t *h, char const *name);
00227
00229 SOFIAPUBFUN int msg_list_append_items(su_home_t *home, msg_list_t *k,
00230 msg_param_t const items[]);
00231
00233 SOFIAPUBFUN int msg_list_replace_items(su_home_t *home,
00234 msg_list_t *k,
00235 msg_param_t const items[]);
00236
00237 SOFIAPUBFUN int msg_random_token(char token[], int tlen,
00238 void const *d, int dlen);
00239
00240 SOFIAPUBFUN msg_param_t msg_params_find(msg_param_t const pp[],
00241 char const *name);
00242 SOFIAPUBFUN msg_param_t *msg_params_find_slot(msg_param_t [],
00243 char const *name);
00244 SOFIAPUBFUN int msg_params_add(su_home_t *sh,
00245 msg_param_t **pp,
00246 char const *param);
00247 SOFIAPUBFUN int msg_params_cmp(char const * const a[],
00248 char const * const b[]);
00249 SOFIAPUBFUN int msg_params_replace(su_home_t *,
00250 char const * **inout_paramlist,
00251 char const *);
00252 SOFIAPUBFUN int msg_params_remove(char const **paramlist,
00253 char const *name);
00254 SOFIAPUBFUN size_t msg_params_length(char const * const * params);
00255
00257 SOFIAPUBFUN char *msg_unquote_dup(su_home_t *home, char const *q)
00258 __attribute__((__malloc__));
00259
00260 SOFIAPUBFUN char *msg_unquote(char *dst, char const *s);
00261
00263 SOFIAPUBFUN unsigned long msg_hash_string(char const *id);
00264
00265
00266 #define MSG_ALIGN(p, t) (((t) - 1 + (long)(p))&-(long)(t))
00267 #define MSG_STRUCT_SIZE_ALIGN(rv) ((rv) = MSG_ALIGN(rv, (int)sizeof(void *)))
00268 #define MSG_STRUCT_ALIGN(p) ((p) = (void*)MSG_ALIGN(p, (int)sizeof(void *)))
00269
00270 enum {
00271 msg_n_params = 8,
00272 #define MSG_N_PARAMS msg_n_params
00273 };
00274
00276 #define MSG_HEADER_INIT(h, msg_class, size) \
00277 ((void)memset((h), 0, (size)), \
00278 (void)(((msg_common_t *)(h))->h_class = (msg_class)), \
00279 (h))
00280
00282 #define MSG_HEADER_NONE ((msg_header_t *)-1)
00283
00284 #ifndef MSG_PROTOS_H
00285 #include <sofia-sip/msg_protos.h>
00286 #endif
00287
00288 SOFIA_END_DECLS
00289
00290 #endif