Mercurial > mplayer.hg
annotate cfgparser.h @ 3490:d33dac3fcfa1
applied Panagiotis' patch
author | gabucino |
---|---|
date | Fri, 14 Dec 2001 17:37:45 +0000 |
parents | b97a9e3fdb63 |
children | f61dcc63be5f |
rev | line source |
---|---|
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 |
152 | 14 #define CONF_TYPE_PRINT 6 |
1536
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
153
diff
changeset
|
15 #define CONF_TYPE_FUNC_FULL 7 |
2617 | 16 #define CONF_TYPE_SUBCONFIG 8 |
17 | |
1536
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
153
diff
changeset
|
18 |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
153
diff
changeset
|
19 |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
153
diff
changeset
|
20 #define ERR_NOT_AN_OPTION -1 |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
153
diff
changeset
|
21 #define ERR_MISSING_PARAM -2 |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
153
diff
changeset
|
22 #define ERR_OUT_OF_RANGE -3 |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
153
diff
changeset
|
23 #define ERR_FUNC_ERR -4 |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
153
diff
changeset
|
24 |
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
153
diff
changeset
|
25 |
147 | 26 |
153 | 27 #define CONF_MIN (1<<0) |
28 #define CONF_MAX (1<<1) | |
29 #define CONF_RANGE (CONF_MIN|CONF_MAX) | |
151 | 30 #define CONF_NOCFG (1<<2) |
31 #define CONF_NOCMD (1<<3) | |
147 | 32 |
33 struct config { | |
34 char *name; | |
35 void *p; | |
2617 | 36 unsigned int type :4; |
151 | 37 unsigned int flags:4; |
147 | 38 float min,max; |
39 }; | |
40 | |
1536
e89233dab4da
New feature for option processing: CONF_TYPE_FUNC_FULL
folke
parents:
153
diff
changeset
|
41 typedef int (*cfg_func_arg_param_t)(struct config *, char *, char *); |
150 | 42 typedef int (*cfg_func_param_t)(struct config *, char *); |
43 typedef int (*cfg_func_t)(struct config *); | |
44 | |
147 | 45 /* parse_config_file returns: |
46 * -1 on error (can't malloc, invalid option...) | |
47 * 0 if can't open configfile | |
48 * 1 on success | |
49 */ | |
50 int parse_config_file(struct config *conf, char *conffile); | |
51 | |
1629 | 52 /* parse_command_line returns: |
147 | 53 * -1 on error (invalid option...) |
54 * 0 if there was no filename on command line | |
1629 | 55 * >=1 if there were filenames |
147 | 56 */ |
1629 | 57 int parse_command_line(struct config *conf, int argc, char **argv, char **envp, char ***filenames); |
147 | 58 |
59 #endif /* __CONFIG_H */ |