1/* -*- buffer-read-only: t -*- vi: set ro: */
2/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3#line 1
4/* Decomposed printf argument list.
5   Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2010 Free Software
6   Foundation, Inc.
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 3, or (at your option)
11   any later version.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18   You should have received a copy of the GNU General Public License along
19   with this program; if not, write to the Free Software Foundation,
20   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
21
22/* This file can be parametrized with the following macros:
23     ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions.
24     PRINTF_FETCHARGS   Name of the function to be defined.
25     STATIC             Set to 'static' to declare the function static.  */
26
27#ifndef PRINTF_FETCHARGS
28# include <config.h>
29#endif
30
31/* Specification.  */
32#ifndef PRINTF_FETCHARGS
33# include "printf-args.h"
34#endif
35
36#ifdef STATIC
37STATIC
38#endif
39int
40PRINTF_FETCHARGS (va_list args, arguments *a)
41{
42  size_t i;
43  argument *ap;
44
45  for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
46    switch (ap->type)
47      {
48      case TYPE_SCHAR:
49        ap->a.a_schar = va_arg (args, /*signed char*/ int);
50        break;
51      case TYPE_UCHAR:
52        ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
53        break;
54      case TYPE_SHORT:
55        ap->a.a_short = va_arg (args, /*short*/ int);
56        break;
57      case TYPE_USHORT:
58        ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
59        break;
60      case TYPE_INT:
61        ap->a.a_int = va_arg (args, int);
62        break;
63      case TYPE_UINT:
64        ap->a.a_uint = va_arg (args, unsigned int);
65        break;
66      case TYPE_LONGINT:
67        ap->a.a_longint = va_arg (args, long int);
68        break;
69      case TYPE_ULONGINT:
70        ap->a.a_ulongint = va_arg (args, unsigned long int);
71        break;
72#if HAVE_LONG_LONG_INT
73      case TYPE_LONGLONGINT:
74        ap->a.a_longlongint = va_arg (args, long long int);
75        break;
76      case TYPE_ULONGLONGINT:
77        ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
78        break;
79#endif
80      case TYPE_DOUBLE:
81        ap->a.a_double = va_arg (args, double);
82        break;
83      case TYPE_LONGDOUBLE:
84        ap->a.a_longdouble = va_arg (args, long double);
85        break;
86      case TYPE_CHAR:
87        ap->a.a_char = va_arg (args, int);
88        break;
89#if HAVE_WINT_T
90      case TYPE_WIDE_CHAR:
91        /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
92           default argument promotions", this is not the case in mingw32,
93           where wint_t is 'unsigned short'.  */
94        ap->a.a_wide_char =
95          (sizeof (wint_t) < sizeof (int)
96           ? (wint_t) va_arg (args, int)
97           : va_arg (args, wint_t));
98        break;
99#endif
100      case TYPE_STRING:
101        ap->a.a_string = va_arg (args, const char *);
102        /* A null pointer is an invalid argument for "%s", but in practice
103           it occurs quite frequently in printf statements that produce
104           debug output.  Use a fallback in this case.  */
105        if (ap->a.a_string == NULL)
106          ap->a.a_string = "(NULL)";
107        break;
108#if HAVE_WCHAR_T
109      case TYPE_WIDE_STRING:
110        ap->a.a_wide_string = va_arg (args, const wchar_t *);
111        /* A null pointer is an invalid argument for "%ls", but in practice
112           it occurs quite frequently in printf statements that produce
113           debug output.  Use a fallback in this case.  */
114        if (ap->a.a_wide_string == NULL)
115          {
116            static const wchar_t wide_null_string[] =
117              {
118                (wchar_t)'(',
119                (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
120                (wchar_t)')',
121                (wchar_t)0
122              };
123            ap->a.a_wide_string = wide_null_string;
124          }
125        break;
126#endif
127      case TYPE_POINTER:
128        ap->a.a_pointer = va_arg (args, void *);
129        break;
130      case TYPE_COUNT_SCHAR_POINTER:
131        ap->a.a_count_schar_pointer = va_arg (args, signed char *);
132        break;
133      case TYPE_COUNT_SHORT_POINTER:
134        ap->a.a_count_short_pointer = va_arg (args, short *);
135        break;
136      case TYPE_COUNT_INT_POINTER:
137        ap->a.a_count_int_pointer = va_arg (args, int *);
138        break;
139      case TYPE_COUNT_LONGINT_POINTER:
140        ap->a.a_count_longint_pointer = va_arg (args, long int *);
141        break;
142#if HAVE_LONG_LONG_INT
143      case TYPE_COUNT_LONGLONGINT_POINTER:
144        ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
145        break;
146#endif
147#if ENABLE_UNISTDIO
148      /* The unistdio extensions.  */
149      case TYPE_U8_STRING:
150        ap->a.a_u8_string = va_arg (args, const uint8_t *);
151        /* A null pointer is an invalid argument for "%U", but in practice
152           it occurs quite frequently in printf statements that produce
153           debug output.  Use a fallback in this case.  */
154        if (ap->a.a_u8_string == NULL)
155          {
156            static const uint8_t u8_null_string[] =
157              { '(', 'N', 'U', 'L', 'L', ')', 0 };
158            ap->a.a_u8_string = u8_null_string;
159          }
160        break;
161      case TYPE_U16_STRING:
162        ap->a.a_u16_string = va_arg (args, const uint16_t *);
163        /* A null pointer is an invalid argument for "%lU", but in practice
164           it occurs quite frequently in printf statements that produce
165           debug output.  Use a fallback in this case.  */
166        if (ap->a.a_u16_string == NULL)
167          {
168            static const uint16_t u16_null_string[] =
169              { '(', 'N', 'U', 'L', 'L', ')', 0 };
170            ap->a.a_u16_string = u16_null_string;
171          }
172        break;
173      case TYPE_U32_STRING:
174        ap->a.a_u32_string = va_arg (args, const uint32_t *);
175        /* A null pointer is an invalid argument for "%llU", but in practice
176           it occurs quite frequently in printf statements that produce
177           debug output.  Use a fallback in this case.  */
178        if (ap->a.a_u32_string == NULL)
179          {
180            static const uint32_t u32_null_string[] =
181              { '(', 'N', 'U', 'L', 'L', ')', 0 };
182            ap->a.a_u32_string = u32_null_string;
183          }
184        break;
185#endif
186      default:
187        /* Unknown type.  */
188        return -1;
189      }
190  return 0;
191}
192