su 1.12.11devel
Loading...
Searching...
No Matches
su_tag_inline.h
Go to the documentation of this file.
1/*
2 * This file is part of the Sofia-SIP package
3 *
4 * Copyright (C) 2005 Nokia Corporation.
5 *
6 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef SU_TAG_INLINE_H
27#define SU_TAG_INLINE_H
37#ifndef SU_TAG_H
38#include <sofia-sip/su_tag.h>
39#endif
40#ifndef SU_TAG_CLASS_H
42#endif
43
44SOFIA_BEGIN_DECLS
45
46#define tt_next tt_class->tc_next
47#define tt_len tt_class->tc_len
48#define tt_move tt_class->tc_move
49#define tt_xtra tt_class->tc_xtra
50#define tt_dup tt_class->tc_dup
51#define tt_free tt_class->tc_free
52#define tt_find tt_class->tc_find
53#define tt_snprintf tt_class->tc_snprintf
54#define tt_filter tt_class->tc_filter
55
56#define TAG_TYPE_OF(t) ((t) && (t)->t_tag ? (t)->t_tag : tag_null)
57
59su_inline int t_end(tagi_t const *t)
60{
61 tag_type_t tt = TAG_TYPE_OF(t);
62
63 /* XXX - virtualize this */
64
65 return tt == tag_null || tt == tag_next;
66}
67
68su_inline tagi_t const *t_next(tagi_t const *t)
69{
70 tag_type_t tt = TAG_TYPE_OF(t);
71
72 if (tt->tt_next)
73 return tt->tt_next(t);
74 else
75 return t + 1;
76}
77
78su_inline tagi_t *t_move(tagi_t *dst, tagi_t const *src)
79{
80 tag_type_t tt = TAG_TYPE_OF(src);
81
82 if (tt->tt_move)
83 return tt->tt_move(dst, src);
84
85 *dst = *src;
86 return dst + 1;
87}
88
89su_inline size_t t_xtra(tagi_t const *t, size_t offset)
90{
91 tag_type_t tt = TAG_TYPE_OF(t);
92
93 if (tt->tt_xtra)
94 return tt->tt_xtra(t, offset);
95
96 return 0;
97}
98
99su_inline tagi_t *t_dup(tagi_t *dst, tagi_t const *src, void **bb)
100{
101 tag_type_t tt = TAG_TYPE_OF(src);
102
103 if (tt->tt_dup)
104 return tt->tt_dup(dst, src, bb);
105
106 *dst = *src;
107 return dst + 1;
108}
109
110su_inline tagi_t const *t_find(tag_type_t tt, tagi_t const *lst)
111{
112 if (!tt)
113 return NULL;
114
115 if (tt->tt_find)
116 return tt->tt_find(tt, lst);
117
118 for (; lst; lst = t_next(lst)) {
119 if (tt == lst->t_tag)
120 return lst;
121 }
122
123 return NULL;
124}
125
126su_inline tagi_t *t_free(tagi_t *t)
127{
128 tag_type_t tt = TAG_TYPE_OF(t);
129
130 if (tt->tt_free)
131 return tt->tt_free(t);
132 else if (tt->tt_next)
133 return (tagi_t *)tt->tt_next(t);
134 else
135 return t + 1;
136}
137
138su_inline size_t t_len(tagi_t const *t)
139{
140 tag_type_t tt = TAG_TYPE_OF(t);
141
142 if (tt->tt_len)
143 return tt->tt_len(t);
144
145 return sizeof(*t);
146}
147
148SOFIA_END_DECLS
149
150#endif /* !defined(SU_TAG_INLINE_H) */
Tag item.
Definition su_tag.h:63
tag_type_t t_tag
Tag.
Definition su_tag.h:64
#define su_inline
Define as suitable declarator static inline functions.
Definition su_configure.h:90
\ Object-oriented tags and tag list interface.
struct tag_type_s const * tag_type_t
Tag item type.
Definition su_tag.h:55
tag_typedef_t tag_next
Jump to another tag list.
Definition su_taglist.c:1030
tag_typedef_t tag_null
End of tag list.
Definition su_taglist.c:889
int t_end(tagi_t const *t)
Check if the tag item is last in current list.
Definition su_tag_inline.h:59

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