1 #ifndef fooconfparserhfoo
2 #define fooconfparserhfoo
5 This file is part of PulseAudio.
7 Copyright 2004-2006 Lennart Poettering
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2.1 of the License,
12 or (at your option) any later version.
14 PulseAudio 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 General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 #include <pulse/proplist.h>
29 /* An abstract parser for simple, line based, shallow configuration
30 * files consisting of variable assignments only. */
32 typedef struct pa_config_parser_state pa_config_parser_state
;
34 typedef int (*pa_config_parser_cb_t
)(pa_config_parser_state
*state
);
36 /* Wraps info for parsing a specific configuration variable */
37 typedef struct pa_config_item
{
38 const char *lvalue
; /* name of the variable */
39 pa_config_parser_cb_t parse
; /* Function that is called to parse the variable's value */
40 void *data
; /* Where to store the variable's data */
44 struct pa_config_parser_state
{
50 void *data
; /* The data pointer of the current pa_config_item. */
51 void *userdata
; /* The pointer that was given to pa_config_parse(). */
53 /* Private data to be used only by conf-parser.c. */
54 const pa_config_item
*item_table
;
56 pa_proplist
*proplist
;
57 pa_bool_t in_proplist
;
60 /* The configuration file parsing routine. Expects a table of
61 * pa_config_items in *t that is terminated by an item where lvalue is
64 * Some configuration files may contain a Properties section, which
65 * is a bit special. Normally all accepted lvalues must be predefined
66 * in the pa_config_item table, but in the Properties section the
67 * pa_config_item table is ignored, and all lvalues are accepted (as
68 * long as they are valid proplist keys). If the proplist pointer is
69 * non-NULL, the parser will parse any section named "Properties" as
70 * properties, and those properties will be merged into the given
71 * proplist. If proplist is NULL, then sections named "Properties"
72 * are not allowed at all in the configuration file. */
73 int pa_config_parse(const char *filename
, FILE *f
, const pa_config_item
*t
, pa_proplist
*proplist
, void *userdata
);
75 /* Generic parsers for integers, size_t, booleans and strings */
76 int pa_config_parse_int(pa_config_parser_state
*state
);
77 int pa_config_parse_unsigned(pa_config_parser_state
*state
);
78 int pa_config_parse_size(pa_config_parser_state
*state
);
79 int pa_config_parse_bool(pa_config_parser_state
*state
);
80 int pa_config_parse_not_bool(pa_config_parser_state
*state
);
81 int pa_config_parse_string(pa_config_parser_state
*state
);