libcfe  0.12.1
some useful C-functions
getparam.h
Go to the documentation of this file.
1 #ifndef XGETPARAM_H
2 #define XGETPARAM_H
3 
4 #include <stddef.h>
5 
6 /* argument is required when OPTION_ARG_YES is set and OPTION_ARG_MAYBE not, if none is specified no argument will be accepted */
7 #define PARAM_OPTION_ARG_YES 16
8 #define PARAM_OPTION_ARG_MAYBE (8 + PARAM_OPTION_ARG_YES)
9 
10 #define PARAM_OPTION_BOOL (1 + PARAM_OPTION_ARG_MAYBE)
11 #define ARG_TYPE_INT (2 + PARAM_OPTION_ARG_YES)
12 #define ARG_TYPE_STR (4 + PARAM_OPTION_ARG_YES)
13 #define ARG_TYPE_DOUBLE (ARG_TYPE_INT | ARG_TYPE_STR)
14 
15 #define PARAM_ACTION_FUNC 64
16 #define PARAM_ACTION_VAR 32
17 
18 /* getparam options */
19 #define FAIL_ON_UNKNOWN 1 << 0
20 
21 typedef struct
22 {
23  char *longopt;
24  char shortopt;
25  char *configname;
26  short int type;
27  void *ptr;
29  char *help_text;
30 } option_t;
31 
32 typedef int (*option_func_t)(option_t, void *, option_t **);
33 
36 size_t add_config_options(option_t **o_in, option_t add[]);
37 int getparam(option_t **o, int argc, char **argv);
38 int readconfig(option_t **o, const char *file, int options);
39 
40 #endif /* XGETPARAM_H */
char * longopt
Definition: getparam.h:23
int getparam(option_t **o, int argc, char **argv)
Definition: getparam.c:243
char shortopt
Definition: getparam.h:24
void * default_value
Definition: getparam.h:28
void * ptr
Definition: getparam.h:27
char * configname
Definition: getparam.h:25
void print_options_help(option_t *o)
Definition: getparam.c:76
short int type
Definition: getparam.h:26
int(* option_func_t)(option_t, void *, option_t **)
Definition: getparam.h:32
size_t add_config_options(option_t **o_in, option_t add[])
Definition: getparam.c:126
void print_options_config(option_t *o)
Definition: getparam.c:104
int readconfig(option_t **o, const char *file, int options)
Definition: getparam.c:395
char * help_text
Definition: getparam.h:29