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