|
@@ -10,13 +10,14 @@
|
10
|
10
|
extern int verbosity;
|
11
|
11
|
extern Configuration config;
|
12
|
12
|
|
13
|
|
-#define CMP(a) (!strcmp(cptr, a))
|
|
13
|
+#define CMP(a) (!strcmp(keyptr, a))
|
14
|
14
|
|
15
|
15
|
/* ---------------------------------------------------------------- */
|
16
|
16
|
int parse_config(char *fname, int flags)
|
17
|
17
|
{
|
18
|
18
|
FILE *fp;
|
19
|
|
-char line[SZ_STRINGS+1], *cptr;
|
|
19
|
+char line[SZ_STRINGS+1],
|
|
20
|
+ *keyptr, *typeptr, *cptr;
|
20
|
21
|
int numligne;
|
21
|
22
|
|
22
|
23
|
#if DEBUG_LEVEL
|
|
@@ -49,23 +50,35 @@ while (fgets(line, SZ_STRINGS, fp))
|
49
|
50
|
}
|
50
|
51
|
|
51
|
52
|
/* seek for the first token in this line */
|
52
|
|
- if (NULL==(cptr = strtok(line, " \t"))) {
|
|
53
|
+ if (NULL==(keyptr = strtok(line, " \t"))) {
|
53
|
54
|
/* Got an empty line */
|
54
|
55
|
continue;
|
55
|
56
|
}
|
56
|
|
-
|
57
|
57
|
/* skip comments */
|
58
|
|
- if ('#'==*cptr) continue;
|
59
|
|
-
|
60
|
|
- if(verbosity) fprintf(stderr, "[%s]\n", cptr);
|
|
58
|
+ if ('#'==*keyptr) continue;
|
|
59
|
+ /* seek for the type field */
|
|
60
|
+ if (NULL==(typeptr = strtok(NULL, " \t"))) {
|
|
61
|
+ /* we can(t get a type flag ? wtf ? */
|
|
62
|
+ fprintf(stderr, "ERROR line %d : no type\n", numligne);
|
|
63
|
+ continue;
|
|
64
|
+ }
|
61
|
65
|
|
|
66
|
+ if(verbosity)
|
|
67
|
+ fprintf(stderr, "[%s] type %s\n", keyptr, typeptr);
|
62
|
68
|
|
|
69
|
+ if CMP("abort") {
|
|
70
|
+ fprintf(stderr, "abort in config file\n");
|
|
71
|
+ }
|
63
|
72
|
|
|
73
|
+ if (CMP("input_device")) {
|
|
74
|
+ config.input_device = strdup(strtok(NULL, " \t"));
|
|
75
|
+ continue;
|
|
76
|
+ }
|
64
|
77
|
}
|
65
|
78
|
|
66
|
79
|
fclose(fp);
|
67
|
80
|
|
68
|
|
-return -1;
|
|
81
|
+return 0;
|
69
|
82
|
}
|
70
|
83
|
/* ---------------------------------------------------------------- */
|
71
|
84
|
int show_config(char *title)
|
|
@@ -75,7 +88,8 @@ if (verbosity) {
|
75
|
88
|
printf("********** %s **********\n", title);
|
76
|
89
|
}
|
77
|
90
|
|
78
|
|
-printf("valid %d\n", config.valid);
|
|
91
|
+printf("valid : %d\n", config.valid);
|
|
92
|
+printf("input device : %s\n", config.input_device);
|
79
|
93
|
|
80
|
94
|
puts("");
|
81
|
95
|
return 0;
|