1*a1acfa9bSespie /* Decomposed printf argument list.
2*a1acfa9bSespie Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
3*a1acfa9bSespie
4*a1acfa9bSespie This program is free software; you can redistribute it and/or modify it
5*a1acfa9bSespie under the terms of the GNU Library General Public License as published
6*a1acfa9bSespie by the Free Software Foundation; either version 2, or (at your option)
7*a1acfa9bSespie any later version.
8*a1acfa9bSespie
9*a1acfa9bSespie This program is distributed in the hope that it will be useful,
10*a1acfa9bSespie but WITHOUT ANY WARRANTY; without even the implied warranty of
11*a1acfa9bSespie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12*a1acfa9bSespie Library General Public License for more details.
13*a1acfa9bSespie
14*a1acfa9bSespie You should have received a copy of the GNU Library General Public
15*a1acfa9bSespie License along with this program; if not, write to the Free Software
16*a1acfa9bSespie Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17*a1acfa9bSespie USA. */
18*a1acfa9bSespie
19*a1acfa9bSespie #ifdef HAVE_CONFIG_H
20*a1acfa9bSespie # include <config.h>
21*a1acfa9bSespie #endif
22*a1acfa9bSespie
23*a1acfa9bSespie /* Specification. */
24*a1acfa9bSespie #include "printf-args.h"
25*a1acfa9bSespie
26*a1acfa9bSespie #ifdef STATIC
27*a1acfa9bSespie STATIC
28*a1acfa9bSespie #endif
29*a1acfa9bSespie int
printf_fetchargs(va_list args,arguments * a)30*a1acfa9bSespie printf_fetchargs (va_list args, arguments *a)
31*a1acfa9bSespie {
32*a1acfa9bSespie size_t i;
33*a1acfa9bSespie argument *ap;
34*a1acfa9bSespie
35*a1acfa9bSespie for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
36*a1acfa9bSespie switch (ap->type)
37*a1acfa9bSespie {
38*a1acfa9bSespie case TYPE_SCHAR:
39*a1acfa9bSespie ap->a.a_schar = va_arg (args, /*signed char*/ int);
40*a1acfa9bSespie break;
41*a1acfa9bSespie case TYPE_UCHAR:
42*a1acfa9bSespie ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
43*a1acfa9bSespie break;
44*a1acfa9bSespie case TYPE_SHORT:
45*a1acfa9bSespie ap->a.a_short = va_arg (args, /*short*/ int);
46*a1acfa9bSespie break;
47*a1acfa9bSespie case TYPE_USHORT:
48*a1acfa9bSespie ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
49*a1acfa9bSespie break;
50*a1acfa9bSespie case TYPE_INT:
51*a1acfa9bSespie ap->a.a_int = va_arg (args, int);
52*a1acfa9bSespie break;
53*a1acfa9bSespie case TYPE_UINT:
54*a1acfa9bSespie ap->a.a_uint = va_arg (args, unsigned int);
55*a1acfa9bSespie break;
56*a1acfa9bSespie case TYPE_LONGINT:
57*a1acfa9bSespie ap->a.a_longint = va_arg (args, long int);
58*a1acfa9bSespie break;
59*a1acfa9bSespie case TYPE_ULONGINT:
60*a1acfa9bSespie ap->a.a_ulongint = va_arg (args, unsigned long int);
61*a1acfa9bSespie break;
62*a1acfa9bSespie #ifdef HAVE_LONG_LONG
63*a1acfa9bSespie case TYPE_LONGLONGINT:
64*a1acfa9bSespie ap->a.a_longlongint = va_arg (args, long long int);
65*a1acfa9bSespie break;
66*a1acfa9bSespie case TYPE_ULONGLONGINT:
67*a1acfa9bSespie ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
68*a1acfa9bSespie break;
69*a1acfa9bSespie #endif
70*a1acfa9bSespie case TYPE_DOUBLE:
71*a1acfa9bSespie ap->a.a_double = va_arg (args, double);
72*a1acfa9bSespie break;
73*a1acfa9bSespie #ifdef HAVE_LONG_DOUBLE
74*a1acfa9bSespie case TYPE_LONGDOUBLE:
75*a1acfa9bSespie ap->a.a_longdouble = va_arg (args, long double);
76*a1acfa9bSespie break;
77*a1acfa9bSespie #endif
78*a1acfa9bSespie case TYPE_CHAR:
79*a1acfa9bSespie ap->a.a_char = va_arg (args, int);
80*a1acfa9bSespie break;
81*a1acfa9bSespie #ifdef HAVE_WINT_T
82*a1acfa9bSespie case TYPE_WIDE_CHAR:
83*a1acfa9bSespie ap->a.a_wide_char = va_arg (args, wint_t);
84*a1acfa9bSespie break;
85*a1acfa9bSespie #endif
86*a1acfa9bSespie case TYPE_STRING:
87*a1acfa9bSespie ap->a.a_string = va_arg (args, const char *);
88*a1acfa9bSespie break;
89*a1acfa9bSespie #ifdef HAVE_WCHAR_T
90*a1acfa9bSespie case TYPE_WIDE_STRING:
91*a1acfa9bSespie ap->a.a_wide_string = va_arg (args, const wchar_t *);
92*a1acfa9bSespie break;
93*a1acfa9bSespie #endif
94*a1acfa9bSespie case TYPE_POINTER:
95*a1acfa9bSespie ap->a.a_pointer = va_arg (args, void *);
96*a1acfa9bSespie break;
97*a1acfa9bSespie case TYPE_COUNT_SCHAR_POINTER:
98*a1acfa9bSespie ap->a.a_count_schar_pointer = va_arg (args, signed char *);
99*a1acfa9bSespie break;
100*a1acfa9bSespie case TYPE_COUNT_SHORT_POINTER:
101*a1acfa9bSespie ap->a.a_count_short_pointer = va_arg (args, short *);
102*a1acfa9bSespie break;
103*a1acfa9bSespie case TYPE_COUNT_INT_POINTER:
104*a1acfa9bSespie ap->a.a_count_int_pointer = va_arg (args, int *);
105*a1acfa9bSespie break;
106*a1acfa9bSespie case TYPE_COUNT_LONGINT_POINTER:
107*a1acfa9bSespie ap->a.a_count_longint_pointer = va_arg (args, long int *);
108*a1acfa9bSespie break;
109*a1acfa9bSespie #ifdef HAVE_LONG_LONG
110*a1acfa9bSespie case TYPE_COUNT_LONGLONGINT_POINTER:
111*a1acfa9bSespie ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
112*a1acfa9bSespie break;
113*a1acfa9bSespie #endif
114*a1acfa9bSespie default:
115*a1acfa9bSespie /* Unknown type. */
116*a1acfa9bSespie return -1;
117*a1acfa9bSespie }
118*a1acfa9bSespie return 0;
119*a1acfa9bSespie }
120