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