Commit | Line | Data |
---|---|---|
d3ce09f5 SS |
1 | /* Parse a printf-style format string. |
2 | ||
61baf725 | 3 | Copyright (C) 1986-2017 Free Software Foundation, Inc. |
d3ce09f5 SS |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
6a997029 TT |
20 | #ifndef COMMON_FORMAT_H |
21 | #define COMMON_FORMAT_H | |
22 | ||
d3ce09f5 SS |
23 | #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG) |
24 | # define USE_PRINTF_I64 1 | |
25 | # define PRINTF_HAS_LONG_LONG | |
26 | #else | |
27 | # define USE_PRINTF_I64 0 | |
28 | #endif | |
29 | ||
30 | /* The argclass represents the general type of data that goes with a | |
31 | format directive; int_arg for %d, long_arg for %l, and so forth. | |
32 | Note that these primarily distinguish types by size and need for | |
33 | special handling, so for instance %u and %x are (at present) also | |
34 | classed as int_arg. */ | |
35 | ||
36 | enum argclass | |
37 | { | |
38 | literal_piece, | |
39 | int_arg, long_arg, long_long_arg, ptr_arg, | |
40 | string_arg, wide_string_arg, wide_char_arg, | |
16e812b2 UW |
41 | double_arg, long_double_arg, |
42 | dec32float_arg, dec64float_arg, dec128float_arg | |
d3ce09f5 SS |
43 | }; |
44 | ||
45 | /* A format piece is a section of the format string that may include a | |
46 | single print directive somewhere in it, and the associated class | |
47 | for the argument. */ | |
48 | ||
49 | struct format_piece | |
50 | { | |
51 | char *string; | |
52 | enum argclass argclass; | |
53 | }; | |
54 | ||
55 | /* Return an array of printf fragments found at the given string, and | |
56 | rewrite ARG with a pointer to the end of the format string. */ | |
57 | ||
bbc13ae3 | 58 | extern struct format_piece *parse_format_string (const char **arg); |
d3ce09f5 SS |
59 | |
60 | /* Given a pointer to an array of format pieces, free any memory that | |
61 | would have been allocated by parse_format_string. */ | |
62 | ||
63 | extern void free_format_pieces (struct format_piece *frags); | |
64 | ||
65 | /* Freeing, cast as a cleanup. */ | |
66 | ||
67 | extern void free_format_pieces_cleanup (void *); | |
6a997029 TT |
68 | |
69 | #endif /* COMMON_FORMAT_H */ |