su_taglist.c File Reference


Detailed Description

Implementation of tag items and lists.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>
Date:
Created: Tue Feb 20 20:03:38 2001 ppessi

#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <limits.h>
#include <assert.h>
#include <sofia-sip/su_config.h>
#include <sofia-sip/su_tag.h>
#include <sofia-sip/su_tag_class.h>
#include <sofia-sip/su_tag_inline.h>
#include <sofia-sip/su_tagarg.h>
#include <sofia-sip/su.h>

Include dependency graph for su_taglist.c:


Functions

unsigned longlong strtoull (const char *, char **, int)
 Convert an ASCII string into an unsigned long long integer.
int t_snprintf (tagi_t const *t, char b[], size_t size)
 Convert tag item to a string.
tagi_ttl_next (tagi_t const *t)
 Get next tag item from list.
size_t tl_tmove (tagi_t *dst, size_t size, tag_type_t t_tag, tag_value_t t_value,...)
 Move a tag list.
tagi_ttl_move (tagi_t *dst, tagi_t const src[])
 Move a tag list.
size_t tl_len (tagi_t const lst[])
 Calculate effective length of a tag list as bytes.
size_t tl_xtra (tagi_t const lst[], size_t offset)
 Calculate the size of extra memory areas associated with tag list.
tagi_ttl_dup (tagi_t dst[], tagi_t const src[], void **bb)
 Duplicate a tag list.
void tl_free (tagi_t list[])
 Free a tag list.
tagi_ttl_adup (su_home_t *home, tagi_t const lst[])
 Allocate and duplicate a tag list using memory home.
tagi_ttl_tlist (su_home_t *home, tag_type_t tag, tag_value_t value,...)
 Allocate and duplicate tagged arguments as a tag list using memory home.
tagi_ttl_find (tagi_t const lst[], tag_type_t tt)
 Find first tag item with type tt from list.
tagi_ttl_find_last (tagi_t const lst[], tag_type_t tt)
 Find last tag item with type tt from list.
int tl_gets (tagi_t const lst[], tag_type_t tag, tag_value_t value,...)
 Find tags from given list.
int tl_tgets (tagi_t lst[], tag_type_t tag, tag_value_t value,...)
 Find tags from given list.
tagi_tt_filter (tagi_t *dst, tagi_t const filter[], tagi_t const *src, void **bb)
 Filter an element in tag list.
tagi_ttl_filter (tagi_t dst[], tagi_t const filter[], tagi_t const src[], void **b)
 Make filtered copy of a tag list src with filter to dst.
tagi_ttl_afilter (su_home_t *home, tagi_t const filter[], tagi_t const src[])
 Filter a tag list.
tagi_ttl_tfilter (su_home_t *home, tagi_t const src[], tag_type_t tag, tag_value_t value,...)
 Filter tag list src with given tags.
tagi_ttl_filtered_tlist (su_home_t *home, tagi_t const filter[], tag_type_t tag, tag_value_t value,...)
 Create a filtered tag list.
int tl_tremove (tagi_t lst[], tag_type_t tag, tag_value_t value,...)
 Remove listed tags from the list lst.
size_t tl_vlen (va_list ap)
 Calculate length of a tag list with a va_list.
tagi_ttl_vlist (va_list ap)
 Convert va_list to tag list.
tagi_ttl_list (tag_type_t tag, tag_value_t value,...)
 Make a tag list until TAG_NEXT() or TAG_END().
size_t tl_vllen (tag_type_t tag, tag_value_t value, va_list ap)
 Calculate length of a linear tag list.
tagi_ttl_vllist (tag_type_t tag, tag_value_t value, va_list ap)
 Make a linear tag list.
tagi_ttl_llist (tag_type_t tag, tag_value_t value,...)
 Make a linear tag list until TAG_END().
void tl_vfree (tagi_t *t)
 Free a tag list allocated by tl_list(), tl_llist() or tl_vlist().
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.

Variables

tag_typedef_t tag_null
 End of tag list.
tag_typedef_t tag_skip
 Ignore tag item.
tag_typedef_t tag_next
 Jump to another tag list.
tag_typedef_t tag_filter
 Filter tag using function as argument.
tag_typedef_t tag_any
 Any tag accepted when filtering.
tag_class_t ns_tag_class [1]
 Namespace filtering class.
tag_class_t size_tag_class [1]
 Tag class for tags with size_t value.
tag_class_t usize_tag_class [1]
 Tag class for tags with usize_t value.
tag_class_t cstr_tag_class [1]
 Tag class for constant strings.

Function Documentation

unsigned longlong strtoull ( const char *  string,
char **  endPtr,
int  base 
)

Convert an ASCII string into an unsigned long long integer.

Parameters:
[in] string String of ASCII digits, possibly preceded by white space. For bases greater than 10, either lower- or upper-case digits may be used.
[out] endPtr Where to store address of terminating character, or NULL.
[in] base Base for conversion. Must be less than 37. If 0, then the base is chosen from the leading characters of string: "0x" means hex, "0" means octal, anything else means decimal.
Returns:
The integer equivalent of string. If endPtr is non-NULL, then pointer to the character after the last one that was part of the integer is stored to *endPtr.
If string doesn't contain a valid integer value, then zero is returned and *endPtr is set to original value of string.

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.

int t_snprintf ( tagi_t const *  t,
char  b[],
size_t  size 
)

Convert tag item to a string.

tagi_t* tl_adup ( su_home_t home,
tagi_t const  lst[] 
)

Allocate and duplicate a tag list using memory home.

tagi_t* tl_afilter ( su_home_t home,
tagi_t const  filter[],
tagi_t const  src[] 
)

Filter a tag list.

The function tl_afilter() will build a tag list containing tags specified in filter and extracted from src. It will allocate the memory used by tag list via the specified memory home, which may be also NULL.

See also:
tl_afilter(), tl_tfilter(), tl_filtered_tlist(), TAG_FILTER(), TAG_ANY(), ns_tag_class

tagi_t* tl_dup ( tagi_t  dst[],
tagi_t const  src[],
void **  bb 
)

Duplicate a tag list.

Deep copy the tag list src to the buffer dst. Memory areas associated with src are copied to buffer at **bb.

This is a rather low-level function. See tl_adup() for a more convenient functionality.

The size of the dst buffer must be at least tl_len(src) bytes. The size of buffer **bb must be at least tl_dup_xtra(src) bytes.

Parameters:
[out] dst pointer to the destination buffer
[in] src tag list to be duplicated
[in,out] bb pointer to pointer to buffer
Returns:
A pointer to the dst list after last duplicated taglist element.
The pointer at *bb is updated to the byte after last duplicated memory area.

tagi_t* tl_filter ( tagi_t  dst[],
tagi_t const  filter[],
tagi_t const  src[],
void **  b 
)

Make filtered copy of a tag list src with filter to dst.

Each tag in src is checked against tags in list filter. If the tag is in the filter list, or there is a special filter tag in the list which matches with the tag in src, the tag is duplicated to dst using memory buffer in b.

When dst is NULL, this function calculates the size of the filtered list.

See also:
tl_afilter(), tl_tfilter(), tl_filtered_tlist(), TAG_FILTER(), TAG_ANY(), ns_tag_class

tagi_t* tl_filtered_tlist ( su_home_t home,
tagi_t const  filter[],
tag_type_t  tag,
tag_value_t  value,
  ... 
)

Create a filtered tag list.

See also:
tl_afilter(), tl_tfilter(), TAG_FILTER(), TAG_ANY(), ns_tag_class

tagi_t* tl_find ( tagi_t const  lst[],
tag_type_t  tt 
)

Find first tag item with type tt from list.

tagi_t* tl_find_last ( tagi_t const  lst[],
tag_type_t  tt 
)

Find last tag item with type tt from list.

void tl_free ( tagi_t  list[]  ) 

Free a tag list.

The function tl_free() frees resources associated with a tag list. In other words, it calls t_free on each tag item on the list.

int tl_gets ( tagi_t const  lst[],
tag_type_t  tag,
tag_value_t  value,
  ... 
)

Find tags from given list.

size_t tl_len ( tagi_t const  lst[]  ) 

Calculate effective length of a tag list as bytes.

tagi_t* tl_move ( tagi_t dst,
tagi_t const  src[] 
)

Move a tag list.

The function tl_move() copies the tag list src to the buffer dst. The size of the dst list must be at least tl_len(src) bytes.

Parameters:
dst pointer to the destination buffer
src tag list to be moved
Returns:
The function tl_move() returns a pointer to the dst list after last moved element.

tagi_t* tl_tfilter ( su_home_t home,
tagi_t const  src[],
tag_type_t  tag,
tag_value_t  value,
  ... 
)

Filter tag list src with given tags.

See also:
tl_afilter(), tl_filtered_tlist(), TAG_FILTER(), TAG_ANY(), ns_tag_class

int tl_tgets ( tagi_t  lst[],
tag_type_t  tag,
tag_value_t  value,
  ... 
)

Find tags from given list.

Copies values of argument tag list into the reference tags in the tag list lst.

See also:
tl_gets()

tagi_t* tl_tlist ( su_home_t home,
tag_type_t  tag,
tag_value_t  value,
  ... 
)

Allocate and duplicate tagged arguments as a tag list using memory home.

size_t tl_tmove ( tagi_t dst,
size_t  size,
tag_type_t  t_tag,
tag_value_t  t_value,
  ... 
)

Move a tag list.

The function tl_tmove() moves the tag list arguments to dst. The dst must have big enough for all arguments.

Parameters:
dst pointer to the destination buffer
size sizeof dst
t_tag,t_value,... tag list
Returns:
The function tl_tmove() returns number of tag list items initialized.

int tl_tremove ( tagi_t  lst[],
tag_type_t  tag,
tag_value_t  value,
  ... 
)

Remove listed tags from the list lst.

void tl_vfree ( tagi_t t  ) 

Free a tag list allocated by tl_list(), tl_llist() or tl_vlist().

size_t tl_vlen ( va_list  ap  ) 

Calculate length of a tag list with a va_list.

size_t tl_vllen ( tag_type_t  tag,
tag_value_t  value,
va_list  ap 
)

Calculate length of a linear tag list.

tagi_t* tl_vllist ( tag_type_t  tag,
tag_value_t  value,
va_list  ap 
)

Make a linear tag list.

size_t tl_xtra ( tagi_t const  lst[],
size_t  offset 
)

Calculate the size of extra memory areas associated with tag list.


Variable Documentation

tag_class_t size_tag_class[1]

Tag class for tags with size_t value.

Since:
New in 1.12.5

tag_typedef_t tag_any

Any tag accepted when filtering.

tag_typedef_t tag_filter

Filter tag using function as argument.

tag_typedef_t tag_skip

Ignore tag item.

tag_class_t usize_tag_class[1]

Tag class for tags with usize_t value.

Since:
New in 1.12.5


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