1 #ifndef OCONFIG_H
2 #define OCONFIG_H 1
4 #include <stdio.h>
6 /**
7 * oconfig - src/oconfig.h
8 * Copyright (C) 2006,2007 Florian octo Forster <octo at verplant.org>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; only version 2 of the License is applicable.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
24 /*
25 * Types
26 */
27 #define OCONFIG_TYPE_STRING 0
28 #define OCONFIG_TYPE_NUMBER 1
29 #define OCONFIG_TYPE_BOOLEAN 2
31 struct oconfig_value_s
32 {
33 union
34 {
35 char *string;
36 double number;
37 int boolean;
38 } value;
39 int type;
40 };
41 typedef struct oconfig_value_s oconfig_value_t;
43 struct oconfig_item_s;
44 typedef struct oconfig_item_s oconfig_item_t;
45 struct oconfig_item_s
46 {
47 char *key;
48 oconfig_value_t *values;
49 int values_num;
51 oconfig_item_t *parent;
52 oconfig_item_t *children;
53 int children_num;
54 };
56 /*
57 * Functions
58 */
59 oconfig_item_t *oconfig_parse_fh (FILE *fh);
60 oconfig_item_t *oconfig_parse_file (const char *file);
62 void oconfig_free (oconfig_item_t *ci);
64 /*
65 * vim: shiftwidth=2:tabstop=8:softtabstop=2
66 */
67 #endif /* OCONFIG_H */