annotate subopt-helper.h @ 14538:00c3c4111017

New suboption type: malloc'ed, zero terminated string
author reimar
date Wed, 19 Jan 2005 17:10:20 +0000
parents 6c3241503d9b
children 2ef20aa3623b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14281
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
1 #ifndef SUBOPT_HELPER_H
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
2 #define SUBOPT_HELPER_H
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
3
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
4 /**
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
5 * \file subopt-helper.h
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
6 *
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
7 * \brief Datatype and functions declarations for usage
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
8 * of the suboption parser.
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
9 *
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
10 */
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
11
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
12 #define OPT_ARG_BOOL 0
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
13 #define OPT_ARG_INT 1
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
14 #define OPT_ARG_STR 2
14538
00c3c4111017 New suboption type: malloc'ed, zero terminated string
reimar
parents: 14285
diff changeset
15 #define OPT_ARG_MSTRZ 3 ///< A malloced, zero terminated string, use free()!
14281
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
16
14285
6c3241503d9b Add a type name for the test function
reimar
parents: 14281
diff changeset
17 typedef int (*opt_test_f)(void *);
6c3241503d9b Add a type name for the test function
reimar
parents: 14281
diff changeset
18
14281
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
19 /** simple structure for defining the option name, type and storage location */
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
20 typedef struct opt_s
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
21 {
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
22 char * name; ///< string that identifies the option
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
23 int type; ///< option type as defined in subopt-helper.h
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
24 void * valp; ///< pointer to the mem where the value should be stored
14285
6c3241503d9b Add a type name for the test function
reimar
parents: 14281
diff changeset
25 opt_test_f test; ///< argument test func ( optional )
14281
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
26 int set; ///< Is set internally by the parser if the option was found.
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
27 ///< Don't use it at initialization of your opts, it will be
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
28 ///< overriden anyway!
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
29 } opt_t;
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
30
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
31 /** parses the string for the options specified in opt */
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
32 int subopt_parse( char const * const str, opt_t * opts );
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
33
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
34
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
35 /*------------------ arg specific types and declaration -------------------*/
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
36 typedef struct strarg_s
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
37 {
14538
00c3c4111017 New suboption type: malloc'ed, zero terminated string
reimar
parents: 14285
diff changeset
38 int len; ///< length of the string determined by the parser
14281
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
39 char const * str; ///< pointer to position inside the parse string
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
40 } strarg_t;
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
41
577c16f551ad suboption parser for vo and ao modules
al
parents:
diff changeset
42 #endif