The introduced SHA1_NOFINAL hasher was not sufficient for EAP-AKA,
[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
30 /**
31 * Generic configuration options read from a config file.
32 *
33 * The sytax is quite simple:
34 *
35 * settings := (section|keyvalue)*
36 * section := name { settings }
37 * keyvalue := key = value\n
38 *
39 * E.g.:
40 * @code
41 a = b
42 section-one {
43 somevalue = asdf
44 subsection {
45 othervalue = xxx
46 }
47 yetanother = zz
48 }
49 section-two {
50 }
51 @endcode
52 *
53 * The values are accesses using the get() functions using dotted keys, e.g.
54 * section-one.subsection.othervalue
55 */
56 struct settings_t {
57
58 /**
59 * Get a settings value as a string.
60 *
61 * @param key key including sections
62 * @param def value returned if key not found
63 * @return value pointing to internal string
64 */
65 char* (*get_str)(settings_t *this, char *key, char *def);
66
67 /**
68 * Get a boolean yes|no, true|false value.
69 *
70 * @param jey key including sections
71 * @param def default value returned if key not found
72 * @return value of the key
73 */
74 bool (*get_bool)(settings_t *this, char *key, bool def);
75
76 /**
77 * Get an integer value.
78 *
79 * @param key key including sections
80 * @param def default value to return if key not found
81 * @return value of the key
82 */
83 int (*get_int)(settings_t *this, char *key, bool def);
84
85 /**
86 * Destroy a settings instance.
87 */
88 void (*destroy)(settings_t *this);
89 };
90
91 /**
92 * Load setings from a file.
93 */
94 settings_t *settings_create(char *file);
95
96 #endif /* SETTINGS_H_ @}*/