]> git.ipfire.org Git - people/ms/systemd.git/blob - conf-parser.h
parse socket files properly
[people/ms/systemd.git] / conf-parser.h
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 #ifndef fooconfparserhfoo
4 #define fooconfparserhfoo
5
6 #include <stdio.h>
7
8 /* An abstract parser for simple, line based, shallow configuration
9 * files consisting of variable assignments only. */
10
11 typedef int (*config_parser_cb_t)(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
12
13 /* Wraps info for parsing a specific configuration variable */
14 typedef struct ConfigItem {
15 const char *lvalue; /* name of the variable */
16 config_parser_cb_t parse; /* Function that is called to parse the variable's value */
17 void *data; /* Where to store the variable's data */
18 const char *section;
19 } ConfigItem;
20
21 /* The configuration file parsing routine. Expects a table of
22 * config_items in *t that is terminated by an item where lvalue is
23 * NULL */
24 int config_parse(const char *filename, const char* const * sections, const ConfigItem *t, void *userdata);
25
26 /* Generic parsers */
27 int config_parse_int(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
28 int config_parse_unsigned(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
29 int config_parse_size(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
30 int config_parse_bool(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
31 int config_parse_string(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
32 int config_parse_strv(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata);
33
34 #endif