6 static int handler(void* user
, const char* section
, const char* name
, const char* value
)
8 configuration
* pconfig
= (configuration
*)user
;
10 #define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
11 if (MATCH("global", "credit_value")) {
12 pconfig
->credit_value
= atoi(value
);
13 } else if (MATCH("global", "external_timer")) {
14 pconfig
->external_timer
= atoi(value
);
15 } else if (MATCH("global", "sync_switch")) {
16 pconfig
->sync_switch
= atoi(value
);
17 } else if (MATCH("global", "sync_switch_delay")) {
18 pconfig
->sync_switch_delay
= atoi(value
);
19 } else if (MATCH("global", "default_switch_state")) {
20 pconfig
->default_switch_state
= atoi(value
);
21 //}else if (MATCH("user", "name")) {
22 // pconfig->name = strdup(value);
23 //} else if (MATCH("user", "email")) {
24 // pconfig->email = strdup(value);
26 return 0; /* unknown section/name, error */
31 int init_config(configuration
*config
)
33 return ini_parse("config.ini", handler
, config
) >= 0;