Back to index

tetex-bin  3.0
printf-args.c
Go to the documentation of this file.
00001 /* Decomposed printf argument list.
00002    Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify it
00005    under the terms of the GNU Library General Public License as published
00006    by the Free Software Foundation; either version 2, or (at your option)
00007    any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public
00015    License along with this program; if not, write to the Free Software
00016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00017    USA.  */
00018 
00019 #ifdef HAVE_CONFIG_H
00020 # include <config.h>
00021 #endif
00022 
00023 /* Specification.  */
00024 #include "printf-args.h"
00025 
00026 #ifdef STATIC
00027 STATIC
00028 #endif
00029 int
00030 printf_fetchargs (va_list args, arguments *a)
00031 {
00032   size_t i;
00033   argument *ap;
00034 
00035   for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
00036     switch (ap->type)
00037       {
00038       case TYPE_SCHAR:
00039        ap->a.a_schar = va_arg (args, /*signed char*/ int);
00040        break;
00041       case TYPE_UCHAR:
00042        ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
00043        break;
00044       case TYPE_SHORT:
00045        ap->a.a_short = va_arg (args, /*short*/ int);
00046        break;
00047       case TYPE_USHORT:
00048        ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
00049        break;
00050       case TYPE_INT:
00051        ap->a.a_int = va_arg (args, int);
00052        break;
00053       case TYPE_UINT:
00054        ap->a.a_uint = va_arg (args, unsigned int);
00055        break;
00056       case TYPE_LONGINT:
00057        ap->a.a_longint = va_arg (args, long int);
00058        break;
00059       case TYPE_ULONGINT:
00060        ap->a.a_ulongint = va_arg (args, unsigned long int);
00061        break;
00062 #ifdef HAVE_LONG_LONG
00063       case TYPE_LONGLONGINT:
00064        ap->a.a_longlongint = va_arg (args, long long int);
00065        break;
00066       case TYPE_ULONGLONGINT:
00067        ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
00068        break;
00069 #endif
00070       case TYPE_DOUBLE:
00071        ap->a.a_double = va_arg (args, double);
00072        break;
00073 #ifdef HAVE_LONG_DOUBLE
00074       case TYPE_LONGDOUBLE:
00075        ap->a.a_longdouble = va_arg (args, long double);
00076        break;
00077 #endif
00078       case TYPE_CHAR:
00079        ap->a.a_char = va_arg (args, int);
00080        break;
00081 #ifdef HAVE_WINT_T
00082       case TYPE_WIDE_CHAR:
00083        ap->a.a_wide_char = va_arg (args, wint_t);
00084        break;
00085 #endif
00086       case TYPE_STRING:
00087        ap->a.a_string = va_arg (args, const char *);
00088        break;
00089 #ifdef HAVE_WCHAR_T
00090       case TYPE_WIDE_STRING:
00091        ap->a.a_wide_string = va_arg (args, const wchar_t *);
00092        break;
00093 #endif
00094       case TYPE_POINTER:
00095        ap->a.a_pointer = va_arg (args, void *);
00096        break;
00097       case TYPE_COUNT_SCHAR_POINTER:
00098        ap->a.a_count_schar_pointer = va_arg (args, signed char *);
00099        break;
00100       case TYPE_COUNT_SHORT_POINTER:
00101        ap->a.a_count_short_pointer = va_arg (args, short *);
00102        break;
00103       case TYPE_COUNT_INT_POINTER:
00104        ap->a.a_count_int_pointer = va_arg (args, int *);
00105        break;
00106       case TYPE_COUNT_LONGINT_POINTER:
00107        ap->a.a_count_longint_pointer = va_arg (args, long int *);
00108        break;
00109 #ifdef HAVE_LONG_LONG
00110       case TYPE_COUNT_LONGLONGINT_POINTER:
00111        ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
00112        break;
00113 #endif
00114       default:
00115        /* Unknown type.  */
00116        return -1;
00117       }
00118   return 0;
00119 }