sofia-sip/su_tagarg.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of the Sofia-SIP package
00003  *
00004  * Copyright (C) 2005 Nokia Corporation.
00005  *
00006  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation; either version 2.1 of
00011  * the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  *
00023  */
00024 
00025 #ifndef SU_TAGARG_H
00026 
00027 #define SU_TAGARG_H
00028 
00037 #ifndef SU_TAG_H
00038 #include <sofia-sip/su_tag.h>
00039 #endif
00040 
00041 SOFIA_BEGIN_DECLS
00042 
00079 typedef struct {
00080   tagi_t  tl[2];
00081   va_list ap;
00082 } ta_list;
00083 
00096 #if SU_HAVE_TAGSTACK
00097 #define ta_start(ta, t, v) \
00098   do { \
00099   va_start((ta).ap, v); \
00100   (ta).tl->t_tag = (t); (ta).tl->t_value = (v); \
00101   if ((t) && (t) != tag_null && (t) != tag_next) { \
00102     (ta).tl[1].t_tag = tag_next; \
00103     (ta).tl[1].t_value = (tag_value_t)(&(v) + 1); } } while(0)
00104 #else
00105 #define ta_start(ta, t, v) \
00106   do { \
00107   va_start((ta).ap, (v)); \
00108   while ((t) == tag_next && (v)) { \
00109     (t) = ((tagi_t *)(v))->t_tag; \
00110     if ((t) == tag_null || (t) == NULL) break; \
00111     if ((t) == tag_next) { (v) = ((tagi_t *)(v))->t_value; } \
00112     else { (t) = tag_next; break; } \
00113    } \
00114    (ta).tl->t_tag = (t); (ta).tl->t_value = (v); \
00115    ((t) == NULL || (t) == tag_null || (t) == tag_next ? \
00116     ((ta).tl[1].t_value = 0) : \
00117     ((ta).tl[1].t_tag = tag_next, \
00118      (ta).tl[1].t_value = (tag_value_t)tl_vlist((ta).ap))); } while(0)
00119 #endif
00120 
00127 #define ta_args(ta) (ta).tl
00128 
00136 #define ta_tags(ta) \
00137   (ta).tl[0].t_tag, (ta).tl[0].t_value, (ta).tl[1].t_tag, (ta).tl[1].t_value
00138 
00148 #if SU_HAVE_TAGSTACK
00149 #define ta_end(ta) (va_end((ta).ap), (ta).tl->t_tag = NULL, 0)
00150 #else
00151 #define ta_end(ta) \
00152   ((((ta).tl[1].t_value) ? \
00153     (tl_vfree((tagi_t *)((ta).tl[1].t_value))) : (void)0), \
00154    (ta).tl[1].t_value = 0, va_end((ta).ap), 0)
00155 #endif
00156 
00157 SOFIA_END_DECLS
00158 
00159 #endif /* !defined(SU_TAGARG_H) */

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