author | Tero Marttila <terom@fixme.fi> |
Tue, 31 Mar 2009 23:36:05 +0300 | |
changeset 100 | cfb7776bd6f0 |
parent 83 | c8e2dac08207 |
child 120 | 576bab0a1c5a |
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 |
#include "config.h" |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
#include <string.h> |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
4 |
#include <assert.h> |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
|
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
6 |
const struct config_option* config_lookup (const struct config_option *options, const char *name, struct error_info *err) |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
{ |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
8 |
const struct config_option *option; |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
|
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
// find the matching config opt |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
for (option = options; option->name && option->type; option++) { |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
if (strcmp(option->name, name) == 0) |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
13 |
return option; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
14 |
} |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
15 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
16 |
// not found |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
17 |
SET_ERROR_STR(err, ERR_MODULE_CONF, "unknown configuration option"); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
18 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
19 |
return NULL; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
20 |
} |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
21 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
22 |
/** |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
23 |
* Parse a raw value for a CONFIG_IRC_CHAN into an irc_chan |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
24 |
*/ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
25 |
static struct irc_chan* config_parse_irc_chan (struct nexus *nexus, char *raw_value, struct error_info *err) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
26 |
{ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
27 |
const char *network, *channel; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
28 |
struct irc_chan *chan; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
29 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
30 |
// parse required args |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
31 |
if ((network = strsep(&raw_value, "/")) == NULL) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
32 |
JUMP_SET_ERROR_STR(err, ERR_MODULE_CONF, "invalid <network> for CONFIG_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:
83
diff
changeset
|
33 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
34 |
if ((channel = strsep(&raw_value, "/")) == NULL) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
35 |
JUMP_SET_ERROR_STR(err, ERR_MODULE_CONF, "invalid <channel> for CONFIG_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:
83
diff
changeset
|
36 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
37 |
// extraneous stuff? |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
38 |
if (raw_value) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
39 |
JUMP_SET_ERROR_STR(err, ERR_MODULE_CONF, "trailing data for CONFIG_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:
83
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:
83
diff
changeset
|
41 |
// get the channel? |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
42 |
if ((chan = irc_client_get_chan(nexus->client, network, channel)) == NULL) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
43 |
JUMP_SET_ERROR_STR(err, ERR_MODULE_CONF, "unknown network/channel name for CONFIG_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:
83
diff
changeset
|
44 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
45 |
// ok |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
46 |
return chan; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
47 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
48 |
error: |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
49 |
return NULL; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
50 |
} |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
51 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
52 |
err_t config_parse (const struct config_option *option, struct nexus *nexus, struct config_value *value, char *raw_value, struct error_info *err) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
53 |
{ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
54 |
// parse the value |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
55 |
switch (option->type) { |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
56 |
case CONFIG_STRING: |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
57 |
// simple! |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
58 |
value->string = raw_value; |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
59 |
break; |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
60 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
61 |
case 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:
83
diff
changeset
|
62 |
// parse the value |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
63 |
if (!(value->irc_chan = config_parse_irc_chan(nexus, raw_value, err))) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
64 |
return ERROR_CODE(err); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
65 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
66 |
break; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
67 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
68 |
default: |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
69 |
NOT_REACHED(); |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
70 |
} |
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
71 |
|
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
72 |
// copy the type |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
73 |
value->type = option->type; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
74 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
75 |
// ok |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
76 |
return SUCCESS; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
77 |
} |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
78 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
79 |
err_t config_apply_opt (const struct config_option *option, void *ctx, const struct config_value *value, struct error_info *err) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
80 |
{ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
81 |
// wrong type? |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
82 |
if (option->type != value->type) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
83 |
// XXX: info about type names |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
84 |
return SET_ERROR(err, ERR_CONFIG_TYPE); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
85 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
86 |
// null? |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
87 |
if (!value) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
88 |
RETURN_SET_ERROR_STR(err, ERR_CONFIG_REQUIRED, option->name); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
89 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
90 |
// call the handler |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
91 |
switch (option->type) { |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
92 |
case CONFIG_STRING: return option->func.string(ctx, value->string, err); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
93 |
case CONFIG_IRC_CHAN: return option->func.irc_chan(ctx, value->irc_chan, err); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
94 |
default: NOT_REACHED(); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
95 |
} |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
96 |
} |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
97 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
98 |
err_t config_apply (const struct config_option *options, void *ctx, const char *name, const struct config_value *value, struct error_info *err) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
99 |
{ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
100 |
const struct config_option *option; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
101 |
|
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
102 |
// no matching option found? |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
103 |
if (!(option = config_lookup(options, name, err))) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
104 |
return ERROR_CODE(err); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
105 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
106 |
// apply it |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
107 |
return config_apply_opt(option, ctx, value, err); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
108 |
} |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
109 |
|
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
110 |
err_t config_apply_string (const struct config_option *options, void *ctx, const char *name, char *value, struct error_info *err) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
111 |
{ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
112 |
struct config_value conf_value = { CONFIG_STRING, { .string = value } }; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
113 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
114 |
return config_apply(options, ctx, name, &conf_value, err); |
83
c8e2dac08207
add config module and modify irc_log/nexus to use it
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
115 |
} |
100
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
116 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
117 |
err_t config_apply_irc_chan (const struct config_option *options, void *ctx, const char *name, struct irc_chan *value, struct error_info *err) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
118 |
{ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
119 |
struct config_value conf_value = { CONFIG_STRING, { .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:
83
diff
changeset
|
120 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
121 |
return config_apply(options, ctx, name, &conf_value, err); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
122 |
} |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
123 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
124 |
err_t config_apply_raw (const struct config_option *options, struct nexus *nexus, void *ctx, const char *name, char *raw_value, struct error_info *err) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
125 |
{ |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
126 |
const struct config_option *option; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
127 |
struct config_value value; |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
128 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
129 |
// no matching option found? |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
130 |
if (!(option = config_lookup(options, name, err))) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
131 |
return ERROR_CODE(err); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
132 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
133 |
// parse it |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
134 |
if (config_parse(option, nexus, &value, raw_value, err)) |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
135 |
return ERROR_CODE(err); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
136 |
|
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
137 |
// apply it |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
138 |
return config_apply_opt(option, ctx, &value, err); |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
139 |
} |
cfb7776bd6f0
improve the config module futher, now the module_desc interface uses structured config_value's
Tero Marttila <terom@fixme.fi>
parents:
83
diff
changeset
|
140 |