chiark / gitweb /
tree-wide: some work-arounds for gcc false positives regarding uninitialized variables
[elogind.git] / src / basic / parse-printf-format.h
1 /***
2   This file is part of systemd.
3
4   Copyright 2014 Emil Renner Berthing <systemd@esmil.dk>
5
6   With parts from the GNU C Library
7   Copyright 1991-2014 Free Software Foundation, Inc.
8
9   systemd is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as published by
11   the Free Software Foundation; either version 2.1 of the License, or
12   (at your option) any later version.
13
14   systemd is distributed in the hope that it will be useful, but
15   WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   Lesser General Public License for more details.
18
19   You should have received a copy of the GNU Lesser General Public License
20   along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #pragma once
24
25 #include "config.h"
26
27 #ifdef HAVE_PRINTF_H
28 #include <printf.h>
29 #else
30
31 #include <stddef.h>
32
33 enum {        /* C type: */
34   PA_INT,     /* int */
35   PA_CHAR,    /* int, cast to char */
36   PA_WCHAR,   /* wide char */
37   PA_STRING,  /* const char *, a '\0'-terminated string */
38   PA_WSTRING, /* const wchar_t *, wide character string */
39   PA_POINTER, /* void * */
40   PA_FLOAT,   /* float */
41   PA_DOUBLE,  /* double */
42   PA_LAST
43 };
44
45 /* Flag bits that can be set in a type returned by `parse_printf_format'.  */
46 #define PA_FLAG_MASK        0xff00
47 #define PA_FLAG_LONG_LONG   (1 << 8)
48 #define PA_FLAG_LONG_DOUBLE PA_FLAG_LONG_LONG
49 #define PA_FLAG_LONG        (1 << 9)
50 #define PA_FLAG_SHORT       (1 << 10)
51 #define PA_FLAG_PTR         (1 << 11)
52
53 size_t parse_printf_format(const char *fmt, size_t n, int *types);
54
55 #endif /* HAVE_PRINTF_H */
56