1 /* Declarations for xprintf & friends.
2 Copyright (C) 1995, 1996 Christian von Roques */
6 /* Parts of this file are adapted from the GNU C Library.
7 Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
9 The GNU C Library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
14 The GNU C Library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Library General Public
20 License along with the GNU C Library; see the file COPYING.LIB. If
21 not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
22 Cambridge, MA 02139, USA. */
29 /* This code is just an incomplete sketch how GNU libc could be used,
30 if it provided the necessary functionality. Problems:
31 o obstack_printf() is not yet available, it will be in version 2.
32 o User defined conversion specifiers cannot take struct arguments.
33 Using GNU libc should be *significantly* faster. */
37 # define XP_PAR1 FILE *stream
38 # define XP_PARN const void **args
40 typedef struct printf_info xprintf_info;
42 /* @@@ GNU libc version 2's register_printf_function *requires*
43 non-NULL 3rd argument */
44 # define xprintf_register(spec, func) \
45 register_printf_function ((spec), (func), NULL)
47 # define xprintf printf
48 # define xvprintf vprintf
49 # define xfprintf fprintf
50 # define xvfprintf vfprintf
51 # define xoprintf obstack_printf
52 # define xvoprintf obstack_vprintf
54 #else /* !USE_PRINTF */
56 /* Emulate GNU libc functionality on top of standard libc */
63 # define XP_PAR1 xgprintf_func *f, void *a
64 # define XP_PARN va_list *ap
66 /* Type of a generic print function */
67 typedef int xgprintf_func (void *, const char *, size_t);
71 int prec; /* Precision. */
72 int width; /* Width. */
73 unsigned char spec; /* Format letter. */
74 unsigned int is_long_double:1;/* L flag. */
75 unsigned int is_short:1; /* h flag. */
76 unsigned int is_long:1; /* l flag. */
77 unsigned int alt:1; /* # flag. */
78 unsigned int space:1; /* Space flag. */
79 unsigned int left:1; /* - flag. */
80 unsigned int showsign:1; /* + flag. */
81 char pad; /* Padding character. */
84 /* Type of a printf specifier-handler function.
85 `printer' is the generic print function to be called with first
86 argument `out'. `info' gives information about the format
87 specification. Arguments can be read from `args'. The function
88 shall return the number of characters written, or -1 for errors. */
89 typedef int xprintf_function (xgprintf_func *printer, void *out,
90 const xprintf_info *info,
93 void xprintf_register (char spec, xprintf_function *);
95 int xgprintf(xgprintf_func *, void *, const char *, ...);
96 int xvgprintf(xgprintf_func *, void *, const char *, va_list);
98 int xprintf (const char *, ...);
99 int xvprintf (const char *, va_list);
100 int xfprintf (FILE *, const char *, ...);
101 int xvfprintf (FILE *, const char *, va_list);
104 int xoprintf (struct obstack *, const char *, ...);
105 int xvoprintf (struct obstack *, const char *, va_list);
107 #endif /* !USE_PRINTF */
108 #endif /* _XPRINTF_H_ */