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
|
|
12
|
|
13 #define CONF_CHK_MIN 1<<0
|
|
14 #define CONF_CHK_MAX 1<<1
|
|
15
|
|
16 struct config {
|
|
17 char *name;
|
|
18 void *p;
|
|
19 unsigned int type :2;
|
|
20 unsigned int flags:2;
|
|
21 float min,max;
|
|
22 };
|
|
23
|
|
24 /* parse_config_file returns:
|
|
25 * -1 on error (can't malloc, invalid option...)
|
|
26 * 0 if can't open configfile
|
|
27 * 1 on success
|
|
28 */
|
|
29 int parse_config_file(struct config *conf, char *conffile);
|
|
30
|
|
31 /* parse_command_line reutrns:
|
|
32 * -1 on error (invalid option...)
|
|
33 * 0 if there was no filename on command line
|
|
34 * 1 if it found a filename
|
|
35 */
|
|
36 int parse_command_line(struct config *conf, int argc, char **argv, char **envp, char **filename);
|
|
37
|
|
38 #endif /* __CONFIG_H */
|