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