su 1.12.11devel
Loading...
Searching...
No Matches
su_tagarg.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_TAGARG_H
27#define SU_TAGARG_H
28
37#ifndef SU_TAG_H
38#include <sofia-sip/su_tag.h>
39#endif
40
41SOFIA_BEGIN_DECLS
42
80typedef struct {
81 tagi_t tl[2];
82 va_list ap;
83} ta_list;
84
85#if defined(va_copy)
86#define su_va_copy(dst, src) va_copy((dst), (src))
87#elif defined(__va_copy)
88#define su_va_copy(dst, src) __va_copy((dst), (src))
89#else
90#define su_va_copy(dst, src) (memcpy(&(dst), &(src), sizeof (va_list)))
91#endif
92
105#if SU_HAVE_TAGSTACK
106/* All arguments are saved into stack (left-to-right) */
107#define ta_start(ta, t, v) \
108 do { \
109 tag_type_t ta_start__tag = (t); tag_value_t ta_start__value = (v); \
110 va_start((ta).ap, (v)); \
111 while ((ta_start__tag) == tag_next && (ta_start__value) != 0) { \
112 ta_start__tag = ((tagi_t *)ta_start__value)->t_tag; \
113 if (ta_start__tag == tag_null || ta_start__tag == NULL) \
114 break; \
115 if (ta_start__tag == tag_next) { \
116 ta_start__value = ((tagi_t *)ta_start__value)->t_value; } \
117 else { \
118 ta_start__tag = tag_next; \
119 break; \
120 } \
121 } \
122 (ta).tl->t_tag = ta_start__tag; (ta).tl->t_value = ta_start__value; \
123 if (ta_start__tag != NULL && \
124 ta_start__tag != tag_null && \
125 ta_start__tag != tag_next) { \
126 (ta).tl[1].t_tag = tag_next; \
127 (ta).tl[1].t_value = (tag_value_t)(&(v) + 1); \
128 } else { \
129 (ta).tl[1].t_tag = 0; (ta).tl[1].t_value = (tag_value_t)0; \
130 } \
131 } while(0)
132#else
133/* Tagged arguments are in registers - copy all of them. */
134#define ta_start(ta, t, v) \
135 do { \
136 tag_type_t ta_start__tag = (t); tag_value_t ta_start__value = (v); \
137 va_start((ta).ap, (v)); \
138 while ((ta_start__tag) == tag_next && (ta_start__value) != 0) { \
139 ta_start__tag = ((tagi_t *)ta_start__value)->t_tag; \
140 if (ta_start__tag == tag_null || ta_start__tag == NULL) \
141 break; \
142 if (ta_start__tag == tag_next) { \
143 ta_start__value = ((tagi_t *)ta_start__value)->t_value; \
144 } else { \
145 ta_start__tag = tag_next; \
146 break; \
147 } \
148 } \
149 (ta).tl->t_tag = ta_start__tag; (ta).tl->t_value = ta_start__value; \
150 if (ta_start__tag != NULL && \
151 ta_start__tag != tag_null && \
152 ta_start__tag != tag_next) { \
153 va_list ta_start__ap; \
154 su_va_copy(ta_start__ap, (ta).ap); \
155 (ta).tl[1].t_tag = tag_next; \
156 (ta).tl[1].t_value = (tag_value_t)tl_vlist(ta_start__ap); \
157 va_end(ta_start__ap); \
158 } else { \
159 (ta).tl[1].t_value = 0; (ta).tl[1].t_value = (tag_value_t)0; \
160 } \
161 } while(0)
162#endif
163
170#define ta_args(ta) (ta).tl
171
179#define ta_tags(ta) \
180 (ta).tl[0].t_tag, (ta).tl[0].t_value, (ta).tl[1].t_tag, (ta).tl[1].t_value
181
191#if SU_HAVE_TAGSTACK
192#define ta_end(ta) (va_end((ta).ap), (ta).tl->t_tag = NULL, 0)
193#else
194#define ta_end(ta) \
195 ((((ta).tl[1].t_value) ? \
196 (tl_vfree((tagi_t *)((ta).tl[1].t_value))) : (void)0), \
197 (ta).tl[1].t_value = 0, va_end((ta).ap), 0)
198#endif
199
200SOFIA_END_DECLS
201
202#endif /* !defined(SU_TAGARG_H) */
Structure for accessing tagged argument lists.
Definition su_tagarg.h:80
Tag item.
Definition su_tag.h:63
\ Object-oriented tags and tag list interface.

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