]> code.delx.au - pulseaudio/blob - src/pulsecore/conf-parser.h
remap: Change remapping function argument type from void to int16_t / float as approp...
[pulseaudio] / src / pulsecore / conf-parser.h
1 #ifndef fooconfparserhfoo
2 #define fooconfparserhfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2004-2006 Lennart Poettering
8
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.
13
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.
18
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
22 USA.
23 ***/
24
25 #include <stdio.h>
26
27 #include <pulse/proplist.h>
28
29 /* An abstract parser for simple, line based, shallow configuration
30 * files consisting of variable assignments only. */
31
32 typedef struct pa_config_parser_state pa_config_parser_state;
33
34 typedef int (*pa_config_parser_cb_t)(pa_config_parser_state *state);
35
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 */
41 const char *section;
42 } pa_config_item;
43
44 struct pa_config_parser_state {
45 const char *filename;
46 unsigned lineno;
47 char *section;
48 char *lvalue;
49 char *rvalue;
50 void *data; /* The data pointer of the current pa_config_item. */
51 void *userdata; /* The pointer that was given to pa_config_parse(). */
52
53 /* Private data to be used only by conf-parser.c. */
54 const pa_config_item *item_table;
55 char buf[4096];
56 pa_proplist *proplist;
57 bool in_proplist;
58 };
59
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
62 * NULL.
63 *
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);
74
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);
82
83 #endif