source: trunk/third/gettext/lib/printf.h @ 16931

Revision 16931, 3.5 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r16930, which included commits to RCS files with non-trunk default branches.
Line 
1/*  Copyright (C) 1991-1993, 1995, 2000, 2001 Free Software Foundation, Inc.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by
5the Free Software Foundation; either version 2, or (at your option)
6any later version.
7
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License
14along with this program; if not, write to the Free Software
15Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
16
17#ifndef _PRINTF_H
18
19#define _PRINTF_H       1
20
21#include <stdio.h>
22#include <sys/types.h>
23
24#if HAVE_STDDEF_H
25# include <stddef.h>
26#endif
27
28#ifndef PARAMS
29# if defined (__GNUC__) || __STDC__
30#  define PARAMS(args) args
31# else
32#  define PARAMS(args) ()
33# endif
34#endif
35
36struct printf_info
37{
38  int prec;                     /* Precision.  */
39  int width;                    /* Width.  */
40  char spec;                    /* Format letter.  */
41  unsigned is_long_double:1;    /* L flag.  */
42  unsigned is_short:1;          /* h flag.  */
43  unsigned is_char:1;           /* hh flag.  */
44  unsigned is_long:1;           /* l flag.  */
45  unsigned is_longlong:1;       /* ll flag.  */
46  unsigned alt:1;               /* # flag.  */
47  unsigned space:1;             /* Space flag.  */
48  unsigned left:1;              /* - flag.  */
49  unsigned showsign:1;          /* + flag.  */
50  unsigned group:1;             /* ' flag.  */
51  char pad;                     /* Padding character.  */
52};
53
54
55/* Type of a printf specifier-handler function.
56   STREAM is the FILE on which to write output.
57   INFO gives information about the format specification.
58   Arguments can be read from ARGS.
59   The function should return the number of characters written,
60   or -1 for errors.  */
61
62typedef int (*printf_function) PARAMS ((FILE * __stream,
63                                        const struct printf_info * __info,
64                                        const void **const __args));
65typedef int (*printf_arginfo_function) PARAMS ((const struct printf_info
66                                                *__info,
67                                                size_t __n,
68                                                int *__argtypes));
69
70/* Parse FMT, and fill in N elements of ARGTYPES with the
71   types needed for the conversions FMT specifies.  Returns
72   the number of arguments required by FMT.
73
74   The ARGINFO function registered with a user-defined format is passed a
75   `struct printf_info' describing the format spec being parsed.  A width
76   or precision of INT_MIN means a `*' was used to indicate that the
77   width/precision will come from an arg.  The function should fill in the
78   array it is passed with the types of the arguments it wants, and return
79   the number of arguments it wants.  */
80
81extern size_t parse_printf_format PARAMS ((const char *__fmt,
82                                           size_t __n,
83                                           int *__argtypes));
84
85/* Codes returned by `parse_printf_format' for basic types.
86
87   These values cover all the standard format specifications.
88   Users can add new values after PA_LAST for their own types.  */
89
90enum
91{                               /* C type: */
92  PA_INT,                       /* int */
93  PA_CHAR,                      /* int, cast to char */
94  PA_STRING,                    /* const char *, a '\0'-terminated string */
95  PA_POINTER,                   /* void * */
96  PA_FLOAT,                     /* float */
97  PA_DOUBLE,                    /* double */
98  PA_LAST
99};
100
101/* Flag bits that can be set in a type returned by `parse_printf_format'.  */
102#define PA_FLAG_MASK            0xff00
103#define PA_FLAG_LONG_LONG       (1 << 8)
104#define PA_FLAG_LONG_DOUBLE     PA_FLAG_LONG_LONG
105#define PA_FLAG_LONG            (1 << 9)
106#define PA_FLAG_SHORT           (1 << 10)
107#define PA_FLAG_PTR             (1 << 11)
108#define PA_FLAG_CHAR            (1 << 12)
109
110
111#endif /* printf.h  */
Note: See TracBrowser for help on using the repository browser.