author | Tero Marttila <terom@fixme.fi> |
Tue, 31 Mar 2009 22:09:53 +0300 | |
changeset 98 | f357f835f0d5 |
parent 87 | f0db6ebf18b9 |
child 100 | cfb7776bd6f0 |
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 |
*/ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
#include "error.h" |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
/** |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
* 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
|
13 |
*/ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
enum config_type { |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
CONFIG_INVALID, |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
/** 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
|
18 |
CONFIG_STRING, |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
}; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
20 |
|
87 | 21 |
/** |
22 |
* A single configuration option, with a name, type, handler function, etc. |
|
23 |
*/ |
|
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
struct config_option { |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
/** The name of the config option */ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
const char *name; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
/** The type of the value, XXX: unused */ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
29 |
enum config_type type; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
/** The value handler func */ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
err_t (*func) (void *ctx, char *value, struct error_info *err); |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
/** The value description */ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
const char *description; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
/** Help text */ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
const char *help; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
}; |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
40 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
/** |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |
* Apply a configuration name/value to an array of config_option's. |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
43 |
* |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
44 |
* This finds the appropriate config_option and calls its func. |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
45 |
*/ |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
46 |
err_t config_apply (struct config_option *options, void *ctx, const char *name, char *value, struct error_info *err); |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
47 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
48 |
#endif |