annotate cfgparser.h @ 147:0a0d7dd8fb51

new command line/config file parser
author szabii
date Sun, 18 Mar 2001 23:32:31 +0000
parents
children 2f3e01a1fd87
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
147
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
1 /*
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
2 * command line and config file parser
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
3 */
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
4
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
5 #ifndef __CONFIG_H
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
6 #define __CONFIG_H
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
7
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
8 #define CONF_TYPE_FLAG 0
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
9 #define CONF_TYPE_INT 1
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
10 #define CONF_TYPE_FLOAT 2
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
11 #define CONF_TYPE_STRING 3
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
12
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
13 #define CONF_CHK_MIN 1<<0
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
14 #define CONF_CHK_MAX 1<<1
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
15
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
16 struct config {
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
17 char *name;
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
18 void *p;
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
19 unsigned int type :2;
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
20 unsigned int flags:2;
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
21 float min,max;
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
22 };
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
23
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
24 /* parse_config_file returns:
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
25 * -1 on error (can't malloc, invalid option...)
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
26 * 0 if can't open configfile
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
27 * 1 on success
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
28 */
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
29 int parse_config_file(struct config *conf, char *conffile);
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
30
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
31 /* parse_command_line reutrns:
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
32 * -1 on error (invalid option...)
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
33 * 0 if there was no filename on command line
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
34 * 1 if it found a filename
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
35 */
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
36 int parse_command_line(struct config *conf, int argc, char **argv, char **envp, char **filename);
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
37
0a0d7dd8fb51 new command line/config file parser
szabii
parents:
diff changeset
38 #endif /* __CONFIG_H */