Loading...
Searching...
No Matches
su_tag.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 SU_TAG_H
#define SU_TAG_H
#ifndef SU_CONFIG_H
#include <sofia-sip/su_config.h>
#endif
#ifndef SU_TYPES_H
#include <sofia-sip/su_types.h>
#endif
#ifndef SU_ALLOC_H
#include <sofia-sip/su_alloc.h>
#endif
#include <stdarg.h>
#include <stddef.h> /* ANSI C: size_t */
SOFIA_BEGIN_DECLS
typedef struct tag_type_s const *tag_type_t;
typedef intptr_t tag_value_t;
#define TAG_LIST tag_type_t tag, tag_value_t value, ...
typedef struct {
tag_type_t t_tag;
tag_value_t t_value;
} tagi_t;
typedef struct tag_class_s const tag_class_t;
struct tag_type_s {
char const *tt_ns;
char const *tt_name;
tag_class_t *tt_class;
tag_value_t tt_magic;
};
typedef struct tag_type_s const tag_typedef_t[1];
SOFIAPUBVAR tag_typedef_t tag_null;
SOFIAPUBVAR tag_typedef_t tag_skip;
SOFIAPUBVAR tag_typedef_t tag_next;
SOFIAPUBVAR tag_typedef_t tag_any;
SOFIAPUBVAR tag_typedef_t tag_filter;
typedef int tag_filter_f(tagi_t const *filter, tagi_t const *dest);
#define TAG_NULL() (tag_type_t)0, (tag_value_t)0
#define TAG_END() (tag_type_t)0, (tag_value_t)0
#define TAG_SKIP(x) tag_skip, (tag_value_t)(x)
#define TAG_NEXT(next) tag_next, (tag_value_t)(next)
#define TAG_ANY() tag_any, (tag_value_t)0
#define TAG_IF(condition, item) !(condition) ? tag_skip : item
#define TAG_FILTER(function) tag_filter, tag_filter_v(function)
SOFIAPUBFUN int t_snprintf(tagi_t const *t, char b[], size_t size);
SOFIAPUBFUN int t_scan(tag_type_t tt, su_home_t *home, char const *s,
tag_value_t *return_value);
/* Tagarg functions */
SOFIAPUBFUN tagi_t *tl_tlist(su_home_t *, tag_type_t, tag_value_t, ...);
SOFIAPUBFUN size_t tl_tmove(tagi_t *dst, size_t, tag_type_t, tag_value_t, ...);
SOFIAPUBFUN int tl_gets(tagi_t const lst[], tag_type_t, tag_value_t, ...);
SOFIAPUBFUN int tl_tgets(tagi_t lst[], tag_type_t, tag_value_t, ...);
SOFIAPUBFUN tagi_t *tl_tfilter(su_home_t *, tagi_t const lst[],
tag_type_t, tag_value_t, ...);
SOFIAPUBFUN int tl_tremove(tagi_t lst[], tag_type_t, tag_value_t, ...);
/* Low-level taglist manipulation functions */
SOFIAPUBFUN size_t tl_len(tagi_t const lst[]);
SOFIAPUBFUN size_t tl_vllen(tag_type_t tag, tag_value_t value, va_list ap);
SOFIAPUBFUN size_t tl_xtra(tagi_t const lst[], size_t offset);
SOFIAPUBFUN tagi_t *tl_next(tagi_t const *lst);
SOFIAPUBFUN tagi_t *tl_move(tagi_t *dst, tagi_t const src[]);
SOFIAPUBFUN tagi_t *tl_dup(tagi_t dst[], tagi_t const lst[], void **bb);
SOFIAPUBFUN tagi_t *tl_adup(su_home_t *, tagi_t const lst[]);
SOFIAPUBFUN void tl_free(tagi_t list[]);
SOFIAPUBFUN tagi_t *tl_find(tagi_t const lst[], tag_type_t tt);
SOFIAPUBFUN tagi_t *tl_find_last(tagi_t const lst[], tag_type_t tt);
SOFIAPUBFUN tagi_t *tl_filter(tagi_t *, tagi_t const filter[],
tagi_t const lst[], void **b);
SOFIAPUBFUN tagi_t *tl_afilter(su_home_t *, tagi_t const filter[],
tagi_t const lst[]);
SOFIAPUBFUN tagi_t *tl_filtered_tlist(su_home_t *home, tagi_t const filter[],
tag_type_t, tag_value_t, ...);
SOFIAPUBFUN size_t tl_vlen(va_list ap);
SOFIAPUBFUN tagi_t *tl_list(tag_type_t tag, tag_value_t value, ...);
SOFIAPUBFUN tagi_t *tl_vlist2(tag_type_t tag, tag_value_t value, va_list ap);
SOFIAPUBFUN tagi_t *tl_vlist(va_list ap);
SOFIAPUBFUN tagi_t *tl_llist(tag_type_t tag, tag_value_t value, ...);
SOFIAPUBFUN tagi_t *tl_vllist(tag_type_t tag, tag_value_t value, va_list ap);
SOFIAPUBFUN void tl_vfree(tagi_t *t);
#define SU_ALIGN(x) \
((sizeof(void *) - ((intptr_t)(x) & (sizeof(void *) - 1))) & (sizeof(void *) - 1))
#if SU_INLINE_TAG_CAST
su_inline tag_value_t tag_int_v(int v) { return (tag_value_t)v; }
su_inline tag_value_t tag_int_vr(int *vp) { return (tag_value_t)vp; }
su_inline tag_value_t tag_uint_v(unsigned v) { return (tag_value_t)v; }
su_inline tag_value_t tag_uint_vr(unsigned *vp) { return (tag_value_t)vp; }
su_inline tag_value_t tag_usize_v(usize_t v) { return (tag_value_t)v; }
su_inline tag_value_t tag_usize_vr(usize_t *vp) { return (tag_value_t)vp; }
su_inline tag_value_t tag_size_v(size_t v) { return (tag_value_t)v; }
su_inline tag_value_t tag_size_vr(size_t *vp) { return (tag_value_t)vp; }
su_inline tag_value_t tag_bool_v(int v) { return v != 0; }
su_inline tag_value_t tag_bool_vr(int *vp) { return (tag_value_t)vp; }
su_inline tag_value_t tag_ptr_v(void *v) { return (tag_value_t)v; }
su_inline tag_value_t tag_ptr_vr(void *vp, void *v)
{ (void)v; return(tag_value_t)vp; }
su_inline tag_value_t tag_cptr_v(void const *v) { return (tag_value_t)v; }
su_inline tag_value_t tag_cptr_vr(void *vp, void const *v)
{ (void)v; return(tag_value_t)vp; }
su_inline tag_value_t tag_cstr_v(char const *v) { return (tag_value_t)v; }
su_inline tag_value_t tag_cstr_vr(char const**vp) {return(tag_value_t)vp;}
su_inline tag_value_t tag_str_v(char const *v) { return (tag_value_t)v; }
su_inline tag_value_t tag_str_vr(char const **vp) {return(tag_value_t)vp;}
#if __cplusplus
extern "C++" {
su_inline tag_value_t tag_ptr_v(void const *v)
{ return (tag_value_t)v; }
su_inline tag_value_t tag_ptr_vr(void *vp, void const *p)
{ return (tag_value_t)vp; }
su_inline tag_value_t tag_str_v(char *v) { return (tag_value_t)v; }
su_inline tag_value_t tag_str_vr(char **vp) {return (tag_value_t)vp;}
}
#endif
su_inline tag_value_t tag_filter_v(tag_filter_f *v) {return(tag_value_t)v;}
#else
#define tag_int_v(v) (tag_value_t)(v)
#define tag_int_vr(v) (tag_value_t)(v)
#define tag_uint_v(v) (tag_value_t)(v)
#define tag_uint_vr(v) (tag_value_t)(v)
#define tag_usize_v(v) (tag_value_t)(v)
#define tag_usize_vr(v) (tag_value_t)(v)
#define tag_size_v(v) (tag_value_t)(v)
#define tag_size_vr(v) (tag_value_t)(v)
#define tag_bool_v(v) (tag_value_t)(v != 0)
#define tag_bool_vr(v) (tag_value_t)(v)
#define tag_ptr_v(v) (tag_value_t)(v)
#define tag_ptr_vr(v,x) (tag_value_t)(v)
#define tag_cptr_v(v) (tag_value_t)(v)
#define tag_cptr_vr(v,x) (tag_value_t)(v)
#define tag_cstr_v(v) (tag_value_t)(v)
#define tag_cstr_vr(v) (tag_value_t)(v)
#define tag_str_v(v) (tag_value_t)(v)
#define tag_str_vr(v) (tag_value_t)(v)
#define tag_filter_v(v) (tag_value_t)(v)
#endif
SOFIA_END_DECLS
#endif
tag_class_s
Virtual function table for tags.
Definition su_tag_class.h:65
tag_type_s
Tag structure.
Definition su_tag.h:76
tag_type_s::tt_ns
char const * tt_ns
Tag namespace (e.g., "sip" or "nua").
Definition su_tag.h:77
tag_type_s::tt_class
tag_class_t * tt_class
Tag class defines the type of the value.
Definition su_tag.h:79
tag_type_s::tt_magic
tag_value_t tt_magic
Class-specific data (e.g., pointer to header class structure).
Definition su_tag.h:80
tag_type_s::tt_name
char const * tt_name
Tag name (e.g, "min_se").
Definition su_tag.h:78
tagi_t
Tag item.
Definition su_tag.h:63
tagi_t::t_value
tag_value_t t_value
Value.
Definition su_tag.h:65
tagi_t::t_tag
tag_type_t t_tag
Tag.
Definition su_tag.h:64
su_alloc.h
Home-based memory management interface.
su_home_t
SU_HOME_T su_home_t
Memory home type.
Definition su_alloc.h:50
su_config.h
su library configuration
SOFIAPUBFUN
#define SOFIAPUBFUN
SOFIAPUBFUN declares an exported function.
Definition su_config.h:66
SOFIAPUBVAR
#define SOFIAPUBVAR
SOFIAPUBVAR declares an exported variable.
Definition su_config.h:68
su_inline
#define su_inline
Define as suitable declarator static inline functions.
Definition su_configure.h:90
tl_llist
tagi_t * tl_llist(tag_type_t tag, tag_value_t value,...)
Make a linear tag list until TAG_END().
Definition su_taglist.c:793
tl_vlen
size_t tl_vlen(va_list ap)
Calculate length of a tag list with a va_list.
Definition su_taglist.c:634
tl_vllen
size_t tl_vllen(tag_type_t tag, tag_value_t value, va_list ap)
Calculate length of a linear tag list.
Definition su_taglist.c:717
tag_typedef_t
struct tag_type_s const tag_typedef_t[1]
Definition of tag type.
Definition su_tag.h:85
tl_vfree
void tl_vfree(tagi_t *t)
Free a tag list allocated by tl_list(), tl_llist() or tl_vlist().
Definition su_taglist.c:806
tl_tgets
int tl_tgets(tagi_t lst[], tag_type_t, tag_value_t,...)
Find tags from given list.
Definition su_taglist.c:432
tl_adup
tagi_t * tl_adup(su_home_t *, tagi_t const lst[])
Allocate and duplicate a tag list using memory home.
Definition su_taglist.c:311
tag_value_t
intptr_t tag_value_t
Tag item value.
Definition su_tag.h:57
tl_find_last
tagi_t * tl_find_last(tagi_t const lst[], tag_type_t tt)
Find last tag item with type tt from list.
Definition su_taglist.c:350
tl_tlist
tagi_t * tl_tlist(su_home_t *, tag_type_t, tag_value_t,...)
Allocate and duplicate tagged arguments as a tag list using memory home.
Definition su_taglist.c:331
tl_afilter
tagi_t * tl_afilter(su_home_t *, tagi_t const filter[], tagi_t const lst[])
Filter a tag list.
Definition su_taglist.c:549
tl_dup
tagi_t * tl_dup(tagi_t dst[], tagi_t const lst[], void **bb)
Duplicate a tag list.
Definition su_taglist.c:288
tl_move
tagi_t * tl_move(tagi_t *dst, tagi_t const src[])
Move a tag list.
Definition su_taglist.c:232
tag_class_t
struct tag_class_s const tag_class_t
Tag type class.
Definition su_tag.h:69
tl_gets
int tl_gets(tagi_t const lst[], tag_type_t, tag_value_t,...)
Find tags from given list.
Definition su_taglist.c:393
tag_skip
tag_typedef_t tag_skip
Ignore tag item.
Definition su_taglist.c:970
tl_tremove
int tl_tremove(tagi_t lst[], tag_type_t, tag_value_t,...)
Remove listed tags from the list lst.
Definition su_taglist.c:611
tl_len
size_t tl_len(tagi_t const lst[])
Calculate effective length of a tag list as bytes.
Definition su_taglist.c:243
tag_type_t
struct tag_type_s const * tag_type_t
Tag item type.
Definition su_tag.h:55
tl_next
tagi_t * tl_next(tagi_t const *lst)
Get next tag item from list.
Definition su_taglist.c:167
tag_filter
tag_typedef_t tag_filter
Filter tag using function as argument.
Definition su_taglist.c:1078
tl_tmove
size_t tl_tmove(tagi_t *dst, size_t, tag_type_t, tag_value_t,...)
Move a tag list.
Definition su_taglist.c:192
tag_filter_f
int tag_filter_f(tagi_t const *filter, tagi_t const *dest)
Prototype for filtering function used with TAG_FILTER().
Definition su_tag.h:107
t_snprintf
int t_snprintf(tagi_t const *t, char b[], size_t size)
Convert tag item to a string.
Definition su_taglist.c:137
tag_any
tag_typedef_t tag_any
Any tag accepted when filtering.
Definition su_taglist.c:1118
tl_tfilter
tagi_t * tl_tfilter(su_home_t *, tagi_t const lst[], tag_type_t, tag_value_t,...)
Filter tag list src with given tags.
Definition su_taglist.c:581
tl_vlist
tagi_t * tl_vlist(va_list ap)
Convert va_list to tag list.
Definition su_taglist.c:649
tl_xtra
size_t tl_xtra(tagi_t const lst[], size_t offset)
Calculate the size of extra memory areas associated with tag list.
Definition su_taglist.c:256
tl_free
void tl_free(tagi_t list[])
Free a tag list.
Definition su_taglist.c:304
tag_next
tag_typedef_t tag_next
Jump to another tag list.
Definition su_taglist.c:1030
tl_filtered_tlist
tagi_t * tl_filtered_tlist(su_home_t *home, tagi_t const filter[], tag_type_t, tag_value_t,...)
Create a filtered tag list.
Definition su_taglist.c:596
tl_find
tagi_t * tl_find(tagi_t const lst[], tag_type_t tt)
Find first tag item with type tt from list.
Definition su_taglist.c:344
tl_list
tagi_t * tl_list(tag_type_t tag, tag_value_t value,...)
Make a tag list until TAG_NEXT() or TAG_END().
Definition su_taglist.c:704
t_scan
int t_scan(tag_type_t tt, su_home_t *home, char const *s, tag_value_t *return_value)
Convert string to a tag value.
Definition su_taglist.c:813
tl_vllist
tagi_t * tl_vllist(tag_type_t tag, tag_value_t value, va_list ap)
Make a linear tag list.
Definition su_taglist.c:746
tag_null
tag_typedef_t tag_null
End of tag list.
Definition su_taglist.c:889
su_types.h
Basic integer types for su library.
intptr_t
SU_INTPTR_T intptr_t
Integer type large enough to store pointers.
Definition su_types.h:75

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