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
|
|
16 /** simple structure for defining the option name, type and storage location */
|
|
17 typedef struct opt_s
|
|
18 {
|
|
19 char * name; ///< string that identifies the option
|
|
20 int type; ///< option type as defined in subopt-helper.h
|
|
21 void * valp; ///< pointer to the mem where the value should be stored
|
|
22 int (* test)(void *); ///< argument test func ( optional )
|
|
23 int set; ///< Is set internally by the parser if the option was found.
|
|
24 ///< Don't use it at initialization of your opts, it will be
|
|
25 ///< overriden anyway!
|
|
26 } opt_t;
|
|
27
|
|
28 /** parses the string for the options specified in opt */
|
|
29 int subopt_parse( char const * const str, opt_t * opts );
|
|
30
|
|
31
|
|
32 /*------------------ arg specific types and declaration -------------------*/
|
|
33 typedef struct strarg_s
|
|
34 {
|
|
35 unsigned char len; ///< length of the string determined by the parser
|
|
36 char const * str; ///< pointer to position inside the parse string
|
|
37 } strarg_t;
|
|
38
|
|
39 #endif
|