147
|
1 /*
|
|
2 * command line and config file parser
|
|
3 */
|
|
4
|
|
5 #ifndef __CONFIG_H
|
|
6 #define __CONFIG_H
|
|
7
|
|
8 #define CONF_TYPE_FLAG 0
|
|
9 #define CONF_TYPE_INT 1
|
|
10 #define CONF_TYPE_FLOAT 2
|
|
11 #define CONF_TYPE_STRING 3
|
150
|
12 #define CONF_TYPE_FUNC 4
|
151
|
13 #define CONF_TYPE_FUNC_PARAM 5
|
147
|
14
|
150
|
15 #define CONF_CHK_MIN (1<<0)
|
|
16 #define CONF_CHK_MAX (1<<1)
|
151
|
17 #define CONF_NOCFG (1<<2)
|
|
18 #define CONF_NOCMD (1<<3)
|
147
|
19
|
|
20 struct config {
|
|
21 char *name;
|
|
22 void *p;
|
150
|
23 unsigned int type :3;
|
151
|
24 unsigned int flags:4;
|
147
|
25 float min,max;
|
|
26 };
|
|
27
|
150
|
28 typedef int (*cfg_func_param_t)(struct config *, char *);
|
|
29 typedef int (*cfg_func_t)(struct config *);
|
|
30
|
147
|
31 /* parse_config_file returns:
|
|
32 * -1 on error (can't malloc, invalid option...)
|
|
33 * 0 if can't open configfile
|
|
34 * 1 on success
|
|
35 */
|
|
36 int parse_config_file(struct config *conf, char *conffile);
|
|
37
|
|
38 /* parse_command_line reutrns:
|
|
39 * -1 on error (invalid option...)
|
|
40 * 0 if there was no filename on command line
|
|
41 * 1 if it found a filename
|
|
42 */
|
|
43 int parse_command_line(struct config *conf, int argc, char **argv, char **envp, char **filename);
|
|
44
|
|
45 #endif /* __CONFIG_H */
|