Loading...
Searching...
No Matches
msg_header.h
Go to the documentation of this file.
/*
* This file is part of the Sofia-SIP package
*
* Copyright (C) 2005 Nokia Corporation.
*
* Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef MSG_HEADER_H
#define MSG_HEADER_H
#include <stdarg.h>
#include <string.h>
#ifndef SU_TYPES_H
#include <sofia-sip/su_types.h>
#endif
#ifndef SU_ALLOC_H
#include <sofia-sip/su_alloc.h>
#endif
#ifndef MSG_H
#include <sofia-sip/msg.h>
#endif
#ifndef URL_H
#include <sofia-sip/url.h>
#endif
SOFIA_BEGIN_DECLS
SOFIAPUBFUN msg_header_t *msg_header_alloc(su_home_t *,
msg_hclass_t *hc,
isize_t extra)
__attribute__((__malloc__));
SOFIAPUBFUN isize_t msg_header_size(msg_header_t const *h);
SOFIAPUBFUN msg_header_t **msg_header_offset(msg_t const *,
msg_pub_t const *,
msg_header_t const *);
SOFIAPUBFUN msg_header_t **msg_hclass_offset(msg_mclass_t const *,
msg_pub_t const *,
msg_hclass_t *);
SOFIAPUBFUN msg_header_t *msg_header_access(msg_pub_t const *pub,
msg_hclass_t *hc);
SOFIAPUBFUN msg_header_t *msg_header_copy_as(su_home_t *home,
msg_hclass_t *hc,
msg_header_t const *o)
__attribute__((__malloc__));
SOFIAPUBFUN msg_header_t *msg_header_copy(su_home_t *home,
msg_header_t const *o)
__attribute__((__malloc__));
SOFIAPUBFUN msg_header_t *msg_header_copy_one(su_home_t *home,
msg_header_t const *o)
__attribute__((__malloc__));
SOFIAPUBFUN msg_header_t *msg_header_dup_as(su_home_t *home,
msg_hclass_t *hc,
msg_header_t const *o)
__attribute__((__malloc__));
SOFIAPUBFUN msg_header_t *msg_header_dup(su_home_t *home,
msg_header_t const *h)
__attribute__((__malloc__));
SOFIAPUBFUN msg_header_t *msg_header_dup_one(su_home_t *home,
msg_header_t const *h)
__attribute__((__malloc__));
SOFIAPUBFUN msg_header_t *msg_header_d(su_home_t *home,
msg_t const *msg,
char const *b);
SOFIAPUBFUN issize_t msg_header_e(char b[], isize_t bsiz,
msg_header_t const *h,
int flags);
SOFIAPUBFUN issize_t msg_object_e(char b[], isize_t size,
msg_pub_t const *mo,
int flags);
SOFIAPUBFUN issize_t msg_header_field_e(char b[], isize_t bsiz,
msg_header_t const *h,
int flags);
SOFIAPUBFUN int msg_header_remove(msg_t *msg,
msg_pub_t *mo,
msg_header_t *h);
SOFIAPUBFUN int msg_header_remove_all(msg_t *msg,
msg_pub_t *mo,
msg_header_t *h);
SOFIAPUBFUN int msg_header_insert(msg_t *msg, msg_pub_t *mo,
msg_header_t *h);
SOFIAPUBFUN int msg_header_replace(msg_t *msg, msg_pub_t *mo,
msg_header_t *old_header,
msg_header_t *new_header);
SOFIAPUBFUN int msg_header_add_dup(msg_t *msg,
msg_pub_t *pub,
msg_header_t const *o);
SOFIAPUBFUN int msg_header_add_str(msg_t *msg,
msg_pub_t *pub,
char const *str);
SOFIAPUBFUN int msg_header_parse_str(msg_t *msg,
msg_pub_t *pub,
char *s);
SOFIAPUBFUN int msg_header_add_dup_as(msg_t *msg,
msg_pub_t *pub,
msg_hclass_t *hc,
msg_header_t const *o);
SOFIAPUBFUN int msg_header_add_make(msg_t *msg,
msg_pub_t *pub,
msg_hclass_t *hc,
char const *s);
SOFIAPUBFUN int msg_header_add_format(msg_t *msg,
msg_pub_t *pub,
msg_hclass_t *hc,
char const *fmt,
...);
SOFIAPUBFUN int msg_header_prepend(msg_t *msg,
msg_pub_t *pub,
msg_header_t **hh,
msg_header_t *h);
SOFIAPUBFUN msg_header_t *msg_header_make(su_home_t *home,
msg_hclass_t *hc,
char const *s)
__attribute__((__malloc__));
SOFIAPUBFUN msg_header_t *msg_header_format(su_home_t *home,
msg_hclass_t *hc,
char const *fmt, ...)
__attribute__ ((__malloc__, __format__ (printf, 3, 4)));
SOFIAPUBFUN msg_header_t *msg_header_vformat(su_home_t *home,
msg_hclass_t *hc,
char const *fmt,
va_list ap)
__attribute__((__malloc__));
SOFIAPUBFUN void msg_header_free(su_home_t *home,
msg_header_t *h);
SOFIAPUBFUN void msg_header_free_all(su_home_t *home,
msg_header_t *h);
SOFIAPUBFUN msg_payload_t *msg_payload_create(su_home_t *home,
void const *data,
usize_t len)
__attribute__((__malloc__));
SOFIAPUBFUN msg_separator_t *msg_separator_create(su_home_t *home)
__attribute__((__malloc__));
/* Chunk handling macros */
#define MSG_CHUNK_BUFFER(pl) \
((char *)pl->pl_common->h_data + (pl)->pl_common->h_len)
#define MSG_CHUNK_AVAIL(pl) \
((pl)->pl_len + ((pl)->pl_data - (char *)pl->pl_common->h_data) - \
(pl)->pl_common->h_len)
#define MSG_CHUNK_NEXT(pl) \
((pl)->pl_next)
SOFIAPUBFUN issize_t msg_headers_prepare(msg_t *,
msg_header_t *headers,
int flags);
#ifdef SU_HAVE_INLINE
su_inline void msg_fragment_clear(msg_common_t *h)
{
h->h_data = NULL, h->h_len = 0;
}
su_inline
msg_param_t **msg_header_params(msg_common_t const *h)
{
if (h && h->h_class->hc_params) {
return (msg_param_t **)((char *)h + h->h_class->hc_params);
}
return NULL;
}
#else
#define msg_fragment_clear(h) ((h)->h_data = NULL, (h)->h_len = 0)
#define msg_header_params(h) \
(((h) && ((msg_common_t *)h)->h_class->hc_params) ? \
(msg_param_t **)((char *)(h) + ((msg_common_t *)h)->h_class->hc_params) : NULL)
#endif
SOFIAPUBFUN void msg_fragment_clear_chain(msg_header_t *h);
SOFIAPUBFUN char const *msg_header_find_param(msg_common_t const *,
char const *name);
SOFIAPUBFUN int msg_header_add_param(su_home_t *, msg_common_t *h,
char const *param);
SOFIAPUBFUN int msg_header_replace_param(su_home_t *, msg_common_t *h,
char const *param);
SOFIAPUBFUN int msg_header_remove_param(msg_common_t *h, char const *name);
SOFIAPUBFUN char const *msg_header_find_item(msg_common_t const *h,
char const *item);
SOFIAPUBFUN int msg_header_replace_item(su_home_t *, msg_common_t *h,
char const *item);
SOFIAPUBFUN int msg_header_remove_item(msg_common_t *h, char const *name);
SOFIAPUBFUN int msg_list_append_items(su_home_t *home,
msg_list_t *k,
msg_param_t const items[]);
SOFIAPUBFUN int msg_list_replace_items(su_home_t *home,
msg_list_t *k,
msg_param_t const items[]);
SOFIAPUBFUN int msg_header_join_items(su_home_t *home,
msg_common_t *dst,
msg_common_t const *src,
int duplicate);
SOFIAPUBFUN issize_t msg_random_token(char token[], isize_t tlen,
void const *d, isize_t dlen);
SOFIAPUBFUN msg_param_t msg_params_find(msg_param_t const pp[],
char const *name);
SOFIAPUBFUN msg_param_t *msg_params_find_slot(msg_param_t [],
char const *name);
SOFIAPUBFUN int msg_params_add(su_home_t *sh,
msg_param_t **pp,
char const *param);
SOFIAPUBFUN int msg_params_cmp(char const * const a[],
char const * const b[]);
SOFIAPUBFUN int msg_params_replace(su_home_t *,
char const * **inout_paramlist,
char const *);
SOFIAPUBFUN int msg_params_remove(char const **paramlist,
char const *name);
SOFIAPUBFUN size_t msg_params_length(char const * const * params);
SOFIAPUBFUN char *msg_unquote_dup(su_home_t *home, char const *q)
__attribute__((__malloc__));
SOFIAPUBFUN char *msg_unquote(char *dst, char const *s);
SOFIAPUBFUN unsigned long msg_hash_string(char const *id);
/* Align pointer p for multiple of t (which must be a power of 2) */
#define MSG_ALIGN(p, t) (((uintptr_t)(p) + (t) - 1) & (0 - (uintptr_t)(t)))
#define MSG_STRUCT_SIZE_ALIGN(rv) ((rv) = MSG_ALIGN(rv, sizeof(void *)))
#define MSG_STRUCT_ALIGN(p) ((p) = (void*)MSG_ALIGN(p, sizeof(void *)))
enum {
msg_n_params = 8 /* allocation size of parameter string list */
#define MSG_N_PARAMS msg_n_params
};
#define MSG_HEADER_INIT(h, msg_class, size) \
((void)memset((h), 0, (size)), \
(void)(((msg_common_t *)(h))->h_class = (msg_class)), \
(h))
#define MSG_HEADER_NONE ((msg_header_t *)(intptr_t)-1)
SOFIA_END_DECLS
#ifndef MSG_PROTOS_H
#include <sofia-sip/msg_protos.h>
#endif
#endif
msg_payload_t
struct msg_payload_s msg_payload_t
The structure msg_payload_t contains representation of MIME message payload.
Definition msg_types.h:92
msg_separator_t
struct msg_separator_s msg_separator_t
The structure msg_separator_t contains representation of separator line between message headers and b...
Definition msg_types.h:91
msg.h
Base message interface.
msg_fragment_clear
void msg_fragment_clear(msg_common_t *h)
Clear encoded data from header structure.
Definition msg_header.h:206
msg_header_access
msg_header_t * msg_header_access(msg_pub_t const *pub, msg_hclass_t *hc)
Get a header from the public message structure.
Definition msg_parser_util.c:1914
msg_random_token
issize_t msg_random_token(char token[], isize_t tlen, void const *d, isize_t dlen)
Generates a random token.
Definition msg_parser_util.c:1934
msg_params_cmp
int msg_params_cmp(char const *const a[], char const *const b[])
Compare parameter lists.
Definition msg_parser_util.c:1689
msg_header_replace_item
int msg_header_replace_item(su_home_t *, msg_common_t *h, char const *item)
Add an item to a header.
Definition msg_parser_util.c:1202
msg_header_add_make
int msg_header_add_make(msg_t *msg, msg_pub_t *pub, msg_hclass_t *hc, char const *s)
Parse a string as a given header field and add result to the message.
Definition msg_parser.c:2697
msg_header_add_param
int msg_header_add_param(su_home_t *, msg_common_t *h, char const *param)
Add a parameter to a header.
Definition msg_parser_util.c:1013
msg_header_dup_one
msg_header_t * msg_header_dup_one(su_home_t *home, msg_header_t const *h))
Duplicate a sigle header.
Definition msg_header_copy.c:213
msg_payload_create
msg_payload_t * msg_payload_create(su_home_t *home, void const *data, usize_t len))
Create a MIME payload.
Definition msg_basic.c:212
msg_header_free
void msg_header_free(su_home_t *home, msg_header_t *h)
Free a header structure.
Definition msg_parser.c:3096
msg_header_make
msg_header_t * msg_header_make(su_home_t *home, msg_hclass_t *hc, char const *s))
Make a header from a value string.
Definition msg_header_make.c:64
msg_header_free_all
void msg_header_free_all(su_home_t *home, msg_header_t *h)
Free a (list of) header structures.
Definition msg_parser.c:3102
msg_header_insert
int msg_header_insert(msg_t *msg, msg_pub_t *mo, msg_header_t *h)
Insert a (list of) header(s) to the fragment chain.
Definition msg_parser.c:2891
msg_list_replace_items
int msg_list_replace_items(su_home_t *home, msg_list_t *k, msg_param_t const items[])
Replace a list of constant items on a list.
Definition msg_generic.c:233
msg_header_vformat
msg_header_t * msg_header_vformat(su_home_t *home, msg_hclass_t *hc, char const *fmt, va_list ap))
Make a MSG header with formatting provided.
Definition msg_header_make.c:105
msg_header_remove_all
int msg_header_remove_all(msg_t *msg, msg_pub_t *mo, msg_header_t *h)
Remove a header list from the header structure and fragment chain.
Definition msg_parser.c:2968
msg_params_length
size_t msg_params_length(char const *const *params)
Calculate number of parameters in a parameter list.
Definition msg_parser_util.c:1392
msg_header_replace
int msg_header_replace(msg_t *msg, msg_pub_t *mo, msg_header_t *old_header, msg_header_t *new_header)
Replace a header item with a (list of) header(s).
Definition msg_parser.c:3020
msg_header_e
issize_t msg_header_e(char b[], isize_t bsiz, msg_header_t const *h, int flags)
Encode a header.
Definition msg_parser.c:1717
msg_hclass_offset
msg_header_t ** msg_hclass_offset(msg_mclass_t const *, msg_pub_t const *, msg_hclass_t *)
Find place to insert header of the class hc.
Definition msg_parser.c:2469
msg_unquote_dup
char * msg_unquote_dup(su_home_t *home, char const *q))
Unquote a string, return a duplicate.
Definition msg_parser_util.c:1714
msg_header_remove_param
int msg_header_remove_param(msg_common_t *h, char const *name)
Remove a parameter from header.
Definition msg_parser_util.c:1081
msg_header_offset
msg_header_t ** msg_header_offset(msg_t const *, msg_pub_t const *, msg_header_t const *)
Get offset of header h from structure mo.
Definition msg_parser_util.c:1898
msg_header_replace_param
int msg_header_replace_param(su_home_t *, msg_common_t *h, char const *param)
Replace or add a parameter to a header.
Definition msg_parser_util.c:1049
msg_object_e
issize_t msg_object_e(char b[], isize_t size, msg_pub_t const *mo, int flags)
Encode a message to the buffer.
Definition msg_parser_util.c:1863
msg_header_copy_as
msg_header_t * msg_header_copy_as(su_home_t *home, msg_hclass_t *hc, msg_header_t const *o))
Copy a list of header objects.
Definition msg_header_copy.c:148
msg_header_copy
msg_header_t * msg_header_copy(su_home_t *home, msg_header_t const *o))
Copy a header list.
Definition msg_header_copy.c:193
msg_header_copy_one
msg_header_t * msg_header_copy_one(su_home_t *home, msg_header_t const *o))
Copy a single header.
Definition msg_header_copy.c:182
msg_header_find_item
char const * msg_header_find_item(msg_common_t const *h, char const *item)
Find a header item.
Definition msg_parser_util.c:1160
msg_header_field_e
issize_t msg_header_field_e(char b[], isize_t bsiz, msg_header_t const *h, int flags)
Encode header contents.
Definition msg_parser_util.c:1889
msg_header_alloc
msg_header_t * msg_header_alloc(su_home_t *, msg_hclass_t *hc, isize_t extra))
Allocate a header structure.
Definition msg_parser.c:2307
msg_header_remove
int msg_header_remove(msg_t *msg, msg_pub_t *mo, msg_header_t *h)
Remove a header from the header structure and fragment chain.
Definition msg_parser.c:2919
msg_header_add_str
int msg_header_add_str(msg_t *msg, msg_pub_t *pub, char const *str)
Add string contents to message.
Definition msg_parser.c:2800
msg_header_join_items
int msg_header_join_items(su_home_t *home, msg_common_t *dst, msg_common_t const *src, int duplicate)
Join header item lists.
Definition msg_parser_util.c:1578
msg_header_remove_item
int msg_header_remove_item(msg_common_t *h, char const *name)
Remove an item from a header.
Definition msg_parser_util.c:1232
msg_header_size
isize_t msg_header_size(msg_header_t const *h)
Calculate the size of a duplicate of a header structure.
Definition msg_parser_util.c:1843
msg_headers_prepare
issize_t msg_headers_prepare(msg_t *, msg_header_t *headers, int flags)
Encode headers in chain.
Definition msg_parser.c:1589
msg_list_append_items
int msg_list_append_items(su_home_t *home, msg_list_t *k, msg_param_t const items[])
Append a list of constant items to a list.
Definition msg_generic.c:211
msg_hash_string
unsigned long msg_hash_string(char const *id)
Calculate a hash over a string.
Definition msg_parser_util.c:1823
msg_header_d
msg_header_t * msg_header_d(su_home_t *home, msg_t const *msg, char const *b)
Decode a message header.
Definition msg_parser.c:1242
msg_header_prepend
int msg_header_prepend(msg_t *msg, msg_pub_t *pub, msg_header_t **hh, msg_header_t *h)
Prepend a (list of) header(s) to the header structure and fragment chain.
Definition msg_parser.c:2411
msg_header_add_dup
int msg_header_add_dup(msg_t *msg, msg_pub_t *pub, msg_header_t const *o)
Duplicate and add a (list of) header(s) to the message.
Definition msg_parser.c:2558
msg_header_add_format
int msg_header_add_format(msg_t *msg, msg_pub_t *pub, msg_hclass_t *hc, char const *fmt,...)
Add formatting result to message.
Definition msg_parser.c:2754
msg_header_params
msg_param_t ** msg_header_params(msg_common_t const *h)
Pointer to header parameters.
Definition msg_header.h:213
msg_header_dup
msg_header_t * msg_header_dup(su_home_t *home, msg_header_t const *h))
Duplicate a header list.
Definition msg_header_copy.c:316
msg_header_parse_str
int msg_header_parse_str(msg_t *msg, msg_pub_t *pub, char *s)
Add string to message.
Definition msg_parser.c:2836
msg_fragment_clear_chain
void msg_fragment_clear_chain(msg_header_t *h)
Clear encoded data from header fields.
Definition msg_parser_util.c:805
msg_header_dup_as
msg_header_t * msg_header_dup_as(su_home_t *home, msg_hclass_t *hc, msg_header_t const *o))
Duplicate a header as class hc.
Definition msg_header_copy.c:259
msg_unquote
char * msg_unquote(char *dst, char const *s)
Unquote string.
Definition msg_parser_util.c:1755
msg_header_add_dup_as
int msg_header_add_dup_as(msg_t *msg, msg_pub_t *pub, msg_hclass_t *hc, msg_header_t const *o)
Duplicate a header as a given type and add the duplicate into message.
Definition msg_parser.c:2634
msg_header_find_param
char const * msg_header_find_param(msg_common_t const *, char const *name)
Find a header parameter.
Definition msg_parser_util.c:853
msg_protos.h
Prototypes for common headers.
msg_hclass_t
struct msg_hclass_s const msg_hclass_t
Header class.
Definition msg_types.h:48
msg_header_t
MSG_HDR_T msg_header_t
Any protocol-specific header object.
Definition msg_types.h:87
msg_list_t
struct msg_list_s msg_list_t
Type for token list headers.
Definition msg_types.h:101
msg_t
struct msg_s msg_t
Message object.
Definition msg_types.h:54
msg_common_t
struct msg_common_s msg_common_t
Common part of header.
Definition msg_types.h:89
msg_pub_t
MSG_PUB_T msg_pub_t
Public protocol-specific message structure for accessing the message.
Definition msg_types.h:81
msg_mclass_t
struct msg_mclass_s msg_mclass_t
Message class.
Definition msg_types.h:45
msg_common_s::h_data
void const * h_data
Fragment data.
Definition msg_types.h:115
msg_common_s::h_len
usize_t h_len
Fragment length (including CRLF).
Definition msg_types.h:116
msg_common_s::h_class
msg_hclass_t * h_class
Header class.
Definition msg_types.h:114
su_alloc.h
su_home_t
SU_HOME_T su_home_t
SOFIAPUBFUN
#define SOFIAPUBFUN
su_inline
#define su_inline
su_types.h

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