]>
git.ipfire.org Git - people/ms/systemd.git/blob - conf-parser.h
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
3 #ifndef fooconfparserhfoo
4 #define fooconfparserhfoo
8 /* An abstract parser for simple, line based, shallow configuration
9 * files consisting of variable assignments only. */
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
);
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 */
21 /* The configuration file parsing routine. Expects a table of
22 * config_items in *t that is terminated by an item where lvalue is
24 int config_parse(const char *filename
, const char* const * sections
, const ConfigItem
*t
, void *userdata
);
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
);