author | Tero Marttila <terom@fixme.fi> |
Wed, 27 May 2009 23:57:48 +0300 | |
branch | new-lib-errors |
changeset 217 | 7728d6ec3abf |
parent 154 | src/config.h@f4472119de3b |
child 218 | 5229a5d098b2 |
permissions | -rw-r--r-- |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
#ifndef CONFIG_H |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
#define CONFIG_H |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
/** |
87 | 5 |
* @file |
6 |
* |
|
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
* Support for module configuration parameters |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
*/ |
217 | 9 |
#include <lib/error.h> |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
10 |
#include <stdbool.h> |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
|
217 | 12 |
enum config_error_code { |
13 |
ERR_CONFIG_NONE, |
|
14 |
ERR_CONFIG_NAME, ///< unknown option name |
|
15 |
ERR_CONFIG_TYPE, ///< invalid value type for parameter |
|
16 |
ERR_CONFIG_REQUIRED, ///< missing value for required parameter |
|
17 |
ERR_CONFIG_VALUE, ///< invalid value |
|
18 |
ERR_CONFIG_PARAMS, ///< invalid number of parameters |
|
19 |
}; |
|
20 |
||
21 |
const struct error_list config_errors; |
|
22 |
||
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
/** |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
* Different types of configuration parameters |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
*/ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
enum config_type { |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
CONFIG_INVALID, |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
|
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
29 |
/** No value at all */ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
30 |
CONFIG_NULL, |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
31 |
|
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
/** A plain NUL-terminated string */ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
CONFIG_STRING, |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
34 |
|
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
35 |
/** A user-defined type, further identified by a string */ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
36 |
CONFIG_USER, |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
37 |
|
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
38 |
/** An IRC channel */ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
39 |
CONFIG_IRC_CHAN, |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
40 |
}; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
41 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
42 |
/** |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
43 |
* A CONFIG_USER type info |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
44 |
*/ |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
45 |
struct config_user_type { |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
46 |
/** The name of the type */ |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
47 |
const char *name; |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
48 |
}; |
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
49 |
|
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
50 |
/** |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
51 |
* Structure to hold a value as defined by config_type |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
52 |
*/ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
53 |
struct config_value { |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
54 |
/** The type of the value */ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
55 |
enum config_type type; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
56 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
57 |
/** The typed value */ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
58 |
union { |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
59 |
/** Value for CONFIG_STRING */ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
60 |
char *string; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
61 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
62 |
/** Value for CONFIG_IRC_CHAN */ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
63 |
struct irc_chan *irc_chan; |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
64 |
|
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
65 |
/** Value for CONFIG_USER */ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
66 |
struct { |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
67 |
/** The specific user type */ |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
68 |
const struct config_user_type *type; |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
69 |
|
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
70 |
/** The pointer value */ |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
71 |
void *ptr; |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
72 |
} user; |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
73 |
}; |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
74 |
}; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
75 |
|
87 | 76 |
/** |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
77 |
* Structure to define a single parameter for an option |
87 | 78 |
*/ |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
79 |
struct config_param { |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
80 |
/** The name of the arg */ |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
81 |
const char *name; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
82 |
|
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
83 |
/** The type */ |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
84 |
enum config_type type; |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
85 |
|
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
86 |
/** The specific type for CONFIG_USER */ |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
87 |
const struct config_user_type *user_type; |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
88 |
|
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
89 |
/** Description */ |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
90 |
const char *description; |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
91 |
|
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
92 |
/** Optional value handler function, by type */ |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
93 |
union { |
217 | 94 |
err_t (*string) (void *ctx, char *value, error_t *err); |
95 |
err_t (*irc_chan) (void *ctx, struct irc_chan *chan, error_t *err); |
|
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
96 |
} func; |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
97 |
|
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
98 |
/** Use handler function? */ |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
99 |
bool is_handler; |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
100 |
|
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
101 |
/** Optional value? */ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
102 |
bool optional; |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
103 |
}; |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
104 |
|
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
105 |
/** |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
106 |
* The maximum number of parameters that a single option can have, although this includes the terminating NULL |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
107 |
*/ |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
108 |
#define CONFIG_PARAMS_MAX (15 + 1) |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
109 |
|
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
110 |
/** |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
111 |
* The maximum number of values that an option can access, including the terminating NULL |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
112 |
*/ |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
113 |
#define CONFIG_VALUES_MAX CONFIG_PARAMS_MAX |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
114 |
|
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
115 |
/** |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
116 |
* A more complicated configuration option that can have multiple parameters |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
117 |
*/ |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
118 |
struct config_option { |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
119 |
/** The name of the config option */ |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
120 |
const char *name; |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
121 |
|
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
122 |
/** The list of parameters */ |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
123 |
const struct config_param params[CONFIG_PARAMS_MAX]; |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
124 |
|
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
125 |
/** The handler function */ |
217 | 126 |
err_t (*func) (void *ctx, const struct config_option *option, const struct config_value values[], error_t *err); |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
127 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
128 |
/** Help text */ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
129 |
const char *help; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
130 |
}; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
131 |
|
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
132 |
#define CONFIG_PARAM(name, type, desc, optional) \ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
133 |
{ name, type, NULL, desc, { NULL }, false, optional } |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
134 |
|
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
135 |
#define CONFIG_PARAM_OPTIONAL(name, type, desc) \ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
136 |
CONFIG_PARAM(name, type, desc, true) |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
137 |
|
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
138 |
#define CONFIG_PARAM_USER(name, user_type, desc, optional) \ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
139 |
{ name, CONFIG_USER, user_type, desc, { NULL }, false, optional } |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
140 |
|
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
141 |
#define CONFIG_PARAM_USER_OPTIONAL(name, user_type, desc) \ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
142 |
CONFIG_PARAM_USER(name, user_type, desc, true) |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
143 |
|
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
144 |
#define CONFIG_PARAM_HANDLER(name, type, desc, _func_name_, func) \ |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
145 |
{ name, type, NULL, desc, {._func_name_ = func }, true, false } |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
146 |
|
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
147 |
#define CONFIG_PARAM_END \ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
148 |
{ NULL, 0, NULL, NULL, { NULL }, false, false } |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
149 |
|
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
150 |
#define CONFIG_OPT(name, func, help, ...) \ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
151 |
{ name, { __VA_ARGS__, CONFIG_PARAM_END }, func, help } |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
152 |
|
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
153 |
#define CONFIG_OPT_STRING(name, func, desc, help) \ |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
154 |
CONFIG_OPT(name, NULL, help, CONFIG_PARAM_HANDLER(name, CONFIG_STRING, desc, string, func)) |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
155 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
156 |
#define CONFIG_OPT_IRC_CHAN(name, func, desc, help) \ |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
157 |
CONFIG_OPT(name, NULL, help, CONFIG_PARAM_HANDLER(name, CONFIG_IRC_CHAN, desc, irc_chan, func)) |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
158 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
159 |
#define CONFIG_OPT_END \ |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
160 |
{ NULL, {}, NULL, NULL } |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
161 |
|
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
162 |
#define CONFIG_OPTIONS(...) \ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
163 |
{ __VA_ARGS__, CONFIG_OPT_END } |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
164 |
|
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
165 |
#define CONFIG_VALUE(type, _name_, value) \ |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
166 |
{ (type), { ._name_ = value } } |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
167 |
|
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
168 |
#define CONFIG_VALUE_STRING(str_value) \ |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
169 |
CONFIG_VALUE(CONFIG_STRING, string, (str_value)) |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
170 |
|
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
171 |
#define CONFIG_VALUE_IRC_CHAN(irc_chan_value) \ |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
172 |
CONFIG_VALUE(CONFIG_IRC_CHAN, irc_chan, (irc_chan_value)) |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
173 |
|
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
174 |
#define CONFIG_VALUE_USER(user_type, user_value) \ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
175 |
CONFIG_VALUE(CONFIG_USER, user, { user_type, user_value }) |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
176 |
|
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
177 |
#define CONFIG_VALUE_END \ |
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
178 |
{ 0, { NULL } } |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
179 |
|
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
180 |
/** |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
181 |
* Lookup a config option by name. |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
182 |
* |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
183 |
* @param options a CONFIG_OPT_END-terminated array of config_option's |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
184 |
* @param name the config_option::name to look up |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
185 |
* @param err returned error info if not found |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
186 |
* @return a direct pointer to the config_option if found |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
187 |
*/ |
217 | 188 |
const struct config_option* config_lookup (const struct config_option *options, const char *name, error_t *err); |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
189 |
|
122
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
190 |
/** |
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
191 |
* Returns the number of params that an option has |
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
192 |
* |
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
193 |
* @param option the option to count |
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
194 |
* @return the number of params |
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
195 |
*/ |
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
196 |
int config_params_count (const struct config_option *option); |
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
197 |
|
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
198 |
// XXX: move this into nexus |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
199 |
#include "nexus.h" |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
200 |
/** |
122
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
201 |
* Parse a raw value into a suitable configuration value for the given param, based on its type. |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
202 |
* |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
203 |
* Since this needs to access the application state, you need to pass in the nexus as an argument. |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
204 |
* |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
205 |
* Formats supported: |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
206 |
* CONFIG_IRC_CHAN - uses a '<network>/<channel>' format and irc_client_get_chan |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
207 |
* |
122
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
208 |
*/ |
217 | 209 |
err_t config_parse_param (const struct config_param *param, struct nexus *nexus, struct config_value *value, char *raw_value, error_t *err); |
122
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
210 |
|
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
211 |
/** |
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
212 |
* Parse a raw value into a suitable configuration value for a single-param option, based on the config option type. |
52ffbdb6bba1
start implementing multiple args for lua_module_conf
Tero Marttila <terom@fixme.fi>
parents:
121
diff
changeset
|
213 |
* |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
214 |
* @param option the option to parse the value for, use config_lookup to find it |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
215 |
* @param nexus the application state |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
216 |
* @param value the returned value, if succesfull |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
217 |
* @param raw_value the raw value to parse based on the type |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
218 |
* @param err returned error info |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
219 |
*/ |
217 | 220 |
err_t config_parse (const struct config_option *option, struct nexus *nexus, struct config_value *value, char *raw_value, error_t *err); |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
221 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
222 |
/** |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
223 |
* Apply a list of parsed configuration values to the given config_option struct. |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
224 |
* |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
225 |
* The config option handlers take a context argument; the value of this depends on the implementor of the config_option. |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
226 |
* |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
227 |
* @param option the option to apply |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
228 |
* @param ctx the context pointer for the option handler |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
229 |
* @param values the NULL-terminated array of parsed values |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
230 |
* @param err returned error info |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
231 |
*/ |
217 | 232 |
err_t config_apply_opt (const struct config_option *option, void *ctx, const struct config_value values[], error_t *err); |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
233 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
234 |
/** |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
235 |
* Apply a list of parsed configuration values for the named config opt. |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
236 |
* |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
237 |
* @param options a CONFIG_OPT_END-terminated array of config_option's |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
238 |
* @param ctx the context pointer for the option handler |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
239 |
* @param name the config_option::name to look up |
120
576bab0a1c5a
modify config to support options with multiple params/values
Tero Marttila <terom@fixme.fi>
parents:
100
diff
changeset
|
240 |
* @param values the NULL-termianted array of parsed values |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
241 |
* @param err returned error info |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
242 |
*/ |
217 | 243 |
err_t config_apply (const struct config_option *options, void *ctx, const char *name, const struct config_value values[], error_t *err); |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
244 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
245 |
/** |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
246 |
* Apply a string value for the named config opt. |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
247 |
* |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
248 |
* @param options a CONFIG_OPT_END-terminated array of config_option's |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
249 |
* @param ctx the context pointer for the option handler |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
250 |
* @param name the config_option::name to look up |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
251 |
* @param value the string value |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
252 |
* @param err returned error info |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
253 |
*/ |
217 | 254 |
err_t config_apply_string (const struct config_option *options, void *ctx, const char *name, char *value, error_t *err); |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
255 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
256 |
/** |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
257 |
* Apply an irc_chan value for the named config opt. |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
258 |
* |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
259 |
* @param options a CONFIG_OPT_END-terminated array of config_option's |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
260 |
* @param ctx the context pointer for the option handler |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
261 |
* @param name the config_option::name to look up |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
262 |
* @param value the irc_chan value |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
263 |
* @param err returned error info |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
264 |
*/ |
217 | 265 |
err_t config_apply_irc_chan (const struct config_option *options, void *ctx, const char *name, struct irc_chan *value, error_t *err); |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
266 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
267 |
/** |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
268 |
* Parse and apply a configuration value for the named config opt. |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
269 |
* |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
270 |
* See config_parse() for more info. |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
271 |
* |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
272 |
* @param options a CONFIG_OPT_END-terminated array of config_option's |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
273 |
* @param nexus the application state |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
274 |
* @param ctx the context pointer for the option handler |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
275 |
* @param name the config_option::name to look up |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
276 |
* @param raw_value the raw value to parse |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
277 |
* @param err returned error info |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
278 |
* |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
279 |
* @see config_parse |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
280 |
*/ |
217 | 281 |
err_t config_apply_raw (const struct config_option option[], struct nexus *nexus, void *ctx, const char *name, char *raw_value, error_t *err); |
121
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
282 |
|
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
283 |
/** |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
284 |
* Lookup a config_value by name from the given list of config_values for the given config_option |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
285 |
*/ |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
286 |
const struct config_value* config_get_value (const struct config_option *option, const struct config_value values[], const char *name); |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
287 |
|
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
288 |
const char* config_get_string (const struct config_option *option, const struct config_value values[], const char *name); |
4682ebbc5644
implement logwatch_conf_filter such that it compiles and loads, but not yet tested
Tero Marttila <terom@fixme.fi>
parents:
120
diff
changeset
|
289 |
struct irc_chan* config_get_irc_chan (const struct config_option *option, const struct config_value values[], const char *name); |
154
f4472119de3b
initial code towards transport implementation, doesn't compile
Tero Marttila <terom@fixme.fi>
parents:
122
diff
changeset
|
290 |
void* config_get_user (const struct config_option *option, const struct config_value values[], const char *name, const struct config_user_type *user_type); |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
291 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
292 |
#endif |