Loading...
Searching...
No Matches
su_tagarg.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_TAGARG_H
#define SU_TAGARG_H
#ifndef SU_TAG_H
#include <sofia-sip/su_tag.h>
#endif
SOFIA_BEGIN_DECLS
typedef struct {
tagi_t tl[2];
va_list ap;
} ta_list;
#if defined(va_copy)
#define su_va_copy(dst, src) va_copy((dst), (src))
#elif defined(__va_copy)
#define su_va_copy(dst, src) __va_copy((dst), (src))
#else
#define su_va_copy(dst, src) (memcpy(&(dst), &(src), sizeof (va_list)))
#endif
#if SU_HAVE_TAGSTACK
/* All arguments are saved into stack (left-to-right) */
#define ta_start(ta, t, v) \
do { \
tag_type_t ta_start__tag = (t); tag_value_t ta_start__value = (v); \
va_start((ta).ap, (v)); \
while ((ta_start__tag) == tag_next && (ta_start__value) != 0) { \
ta_start__tag = ((tagi_t *)ta_start__value)->t_tag; \
if (ta_start__tag == tag_null || ta_start__tag == NULL) \
break; \
if (ta_start__tag == tag_next) { \
ta_start__value = ((tagi_t *)ta_start__value)->t_value; } \
else { \
ta_start__tag = tag_next; \
break; \
} \
} \
(ta).tl->t_tag = ta_start__tag; (ta).tl->t_value = ta_start__value; \
if (ta_start__tag != NULL && \
ta_start__tag != tag_null && \
ta_start__tag != tag_next) { \
(ta).tl[1].t_tag = tag_next; \
(ta).tl[1].t_value = (tag_value_t)(&(v) + 1); \
} else { \
(ta).tl[1].t_tag = 0; (ta).tl[1].t_value = (tag_value_t)0; \
} \
} while(0)
#else
/* Tagged arguments are in registers - copy all of them. */
#define ta_start(ta, t, v) \
do { \
tag_type_t ta_start__tag = (t); tag_value_t ta_start__value = (v); \
va_start((ta).ap, (v)); \
while ((ta_start__tag) == tag_next && (ta_start__value) != 0) { \
ta_start__tag = ((tagi_t *)ta_start__value)->t_tag; \
if (ta_start__tag == tag_null || ta_start__tag == NULL) \
break; \
if (ta_start__tag == tag_next) { \
ta_start__value = ((tagi_t *)ta_start__value)->t_value; \
} else { \
ta_start__tag = tag_next; \
break; \
} \
} \
(ta).tl->t_tag = ta_start__tag; (ta).tl->t_value = ta_start__value; \
if (ta_start__tag != NULL && \
ta_start__tag != tag_null && \
ta_start__tag != tag_next) { \
va_list ta_start__ap; \
su_va_copy(ta_start__ap, (ta).ap); \
(ta).tl[1].t_tag = tag_next; \
(ta).tl[1].t_value = (tag_value_t)tl_vlist(ta_start__ap); \
va_end(ta_start__ap); \
} else { \
(ta).tl[1].t_value = 0; (ta).tl[1].t_value = (tag_value_t)0; \
} \
} while(0)
#endif
#define ta_args(ta) (ta).tl
#define ta_tags(ta) \
(ta).tl[0].t_tag, (ta).tl[0].t_value, (ta).tl[1].t_tag, (ta).tl[1].t_value
#if SU_HAVE_TAGSTACK
#define ta_end(ta) (va_end((ta).ap), (ta).tl->t_tag = NULL, 0)
#else
#define ta_end(ta) \
((((ta).tl[1].t_value) ? \
(tl_vfree((tagi_t *)((ta).tl[1].t_value))) : (void)0), \
(ta).tl[1].t_value = 0, va_end((ta).ap), 0)
#endif
SOFIA_END_DECLS
#endif /* !defined(SU_TAGARG_H) */
ta_list
Structure for accessing tagged argument lists.
Definition su_tagarg.h:80
tagi_t
Tag item.
Definition su_tag.h:63
su_tag.h
\ 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.