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