updated Doxyfile
[strongswan.git] / src / libstrongswan / settings.h
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * $Id$
16 */
17
18 /**
19 * @defgroup settings settings
20 * @{ @ingroup libstrongswan
21 */
22
23 #ifndef SETTINGS_H_
24 #define SETTINGS_H_
25
26 typedef struct settings_t settings_t;
27
28 #include <library.h>
29 #include <utils/enumerator.h>
30
31 /**
32 * Generic configuration options read from a config file.
33 *
34 * The syntax is quite simple:
35 *
36 * settings := (section|keyvalue)*
37 * section := name { settings }
38 * keyvalue := key = value\n
39 *
40 * E.g.:
41 * @code
42 a = b
43 section-one {
44 somevalue = asdf
45 subsection {
46 othervalue = xxx
47 }
48 yetanother = zz
49 }
50 section-two {
51 }
52 @endcode
53 *
54 * The values are accesses using the get() functions using dotted keys, e.g.
55 * section-one.subsection.othervalue
56 */
57 struct settings_t {
58
59 /**
60 * Get a settings value as a string.
61 *
62 * @param key key including sections, printf style format
63 * @param def value returned if key not found
64 * @param ... argument list for key
65 * @return value pointing to internal string
66 */
67 char* (*get_str)(settings_t *this, char *key, char *def, ...);
68
69 /**
70 * Get a boolean yes|no, true|false value.
71 *
72 * @param key key including sections, printf style format
73 * @param def value returned if key not found
74 * @param ... argument list for key
75 * @return value of the key
76 */
77 bool (*get_bool)(settings_t *this, char *key, bool def, ...);
78
79 /**
80 * Get an integer value.
81 *
82 * @param key key including sections, printf style format
83 * @param def value returned if key not found
84 * @param ... argument list for key
85 * @return value of the key
86 */
87 int (*get_int)(settings_t *this, char *key, int def, ...);
88
89 /**
90 * Get a time value.
91 *
92 * @param key key including sections, printf style format
93 * @param def value returned if key not found
94 * @param ... argument list for key
95 * @return value of the key
96 */
97 u_int32_t (*get_time)(settings_t *this, char *key, u_int32_t def, ...);
98
99 /**
100 * Create an enumerator over subsection names of a section.
101 *
102 * @param section section including parents, printf style format
103 * @param ... argument list for key
104 * @return enumerator over subsection names
105 */
106 enumerator_t* (*create_section_enumerator)(settings_t *this,
107 char *section, ...);
108 /**
109 * Destroy a settings instance.
110 */
111 void (*destroy)(settings_t *this);
112 };
113
114 /**
115 * Load setings from a file.
116 */
117 settings_t *settings_create(char *file);
118
119 #endif /** SETTINGS_H_ @}*/