Update pulse width to 100ms
[hdmi-switcher.git] / config.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "config.h"
5
6 static int handler(void* user, const char* section, const char* name, const char* value)
7 {
8 configuration* pconfig = (configuration*)user;
9
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);
25 } else {
26 return 0; /* unknown section/name, error */
27 }
28 return 1;
29 }
30
31 int init_config(configuration *config)
32 {
33 return ini_parse("config.ini", handler, config) >= 0;
34 }