| 1 |
/* Parse printf format string. |
| 2 |
Copyright (C) 1999, 2002 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 |
#ifndef _PRINTF_PARSE_H |
| 20 |
#define _PRINTF_PARSE_H |
| 21 |
|
| 22 |
#include "printf-args.h" |
| 23 |
|
| 24 |
/* Private namespace for gnulib functions */ |
| 25 |
#define printf_parse __gst_printf_parse |
| 26 |
|
| 27 |
/* Flags */ |
| 28 |
#define FLAG_GROUP 1 /* ' flag */ |
| 29 |
#define FLAG_LEFT 2 /* - flag */ |
| 30 |
#define FLAG_SHOWSIGN 4 /* + flag */ |
| 31 |
#define FLAG_SPACE 8 /* space flag */ |
| 32 |
#define FLAG_ALT 16 /* # flag */ |
| 33 |
#define FLAG_ZERO 32 |
| 34 |
|
| 35 |
#define FLAG_PTR_EXT 1024 |
| 36 |
|
| 37 |
/* A parsed directive. */ |
| 38 |
typedef struct |
| 39 |
{ |
| 40 |
const char* dir_start; |
| 41 |
const char* dir_end; |
| 42 |
int flags; |
| 43 |
const char* width_start; |
| 44 |
const char* width_end; |
| 45 |
int width_arg_index; |
| 46 |
const char* precision_start; |
| 47 |
const char* precision_end; |
| 48 |
int precision_arg_index; |
| 49 |
char conversion; /* d i o u x X f e E g G c s p n U % but not C S */ |
| 50 |
int arg_index; |
| 51 |
|
| 52 |
/* extension char in case of TYPE_POINTER_EXT. We need to store this so |
| 53 |
* we can pass it back to __gst_printf_pointer_extension_serialize() |
| 54 |
* so it knows which pointer extension it is */ |
| 55 |
char ptr_ext_char; |
| 56 |
} |
| 57 |
char_directive; |
| 58 |
|
| 59 |
/* A parsed format string. */ |
| 60 |
typedef struct |
| 61 |
{ |
| 62 |
unsigned int count; |
| 63 |
char_directive *dir; |
| 64 |
unsigned int max_width_length; |
| 65 |
unsigned int max_precision_length; |
| 66 |
} |
| 67 |
char_directives; |
| 68 |
|
| 69 |
|
| 70 |
/* Parses the format string. Fills in the number N of directives, and fills |
| 71 |
in directives[0], ..., directives[N-1], and sets directives[N].dir_start |
| 72 |
to the end of the format string. Also fills in the arg_type fields of the |
| 73 |
arguments and the needed count of arguments. */ |
| 74 |
#ifdef STATIC |
| 75 |
STATIC |
| 76 |
#else |
| 77 |
extern |
| 78 |
#endif |
| 79 |
int printf_parse (const char *format, char_directives *d, arguments *a); |
| 80 |
|
| 81 |
#endif /* _PRINTF_PARSE_H */ |