14281
|
1 #ifndef SUBOPT_HELPER_H
|
|
2 #define SUBOPT_HELPER_H
|
|
3
|
|
4 /**
|
|
5 * \file subopt-helper.h
|
|
6 *
|
|
7 * \brief Datatype and functions declarations for usage
|
|
8 * of the suboption parser.
|
|
9 *
|
|
10 */
|
|
11
|
|
12 #define OPT_ARG_BOOL 0
|
|
13 #define OPT_ARG_INT 1
|
|
14 #define OPT_ARG_STR 2
|
|
15
|
14285
|
16 typedef int (*opt_test_f)(void *);
|
|
17
|
14281
|
18 /** simple structure for defining the option name, type and storage location */
|
|
19 typedef struct opt_s
|
|
20 {
|
|
21 char * name; ///< string that identifies the option
|
|
22 int type; ///< option type as defined in subopt-helper.h
|
|
23 void * valp; ///< pointer to the mem where the value should be stored
|
14285
|
24 opt_test_f test; ///< argument test func ( optional )
|
14281
|
25 int set; ///< Is set internally by the parser if the option was found.
|
|
26 ///< Don't use it at initialization of your opts, it will be
|
|
27 ///< overriden anyway!
|
|
28 } opt_t;
|
|
29
|
|
30 /** parses the string for the options specified in opt */
|
|
31 int subopt_parse( char const * const str, opt_t * opts );
|
|
32
|
|
33
|
|
34 /*------------------ arg specific types and declaration -------------------*/
|
|
35 typedef struct strarg_s
|
|
36 {
|
|
37 unsigned char len; ///< length of the string determined by the parser
|
|
38 char const * str; ///< pointer to position inside the parse string
|
|
39 } strarg_t;
|
|
40
|
|
41 #endif
|