1 /*
2  * This file is part of MPlayer.
3  *
4  * MPlayer is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * MPlayer is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef MPLAYER_SUBOPT_HELPER_H
20 #define MPLAYER_SUBOPT_HELPER_H
21 
22 /**
23  * \file
24  *
25  * \brief Datatype and functions declarations for usage
26  *        of the suboption parser.
27  *
28  */
29 
30 #define OPT_ARG_BOOL 0
31 #define OPT_ARG_INT  1
32 #define OPT_ARG_STR  2
33 #define OPT_ARG_MSTRZ 3 ///< A malloced, zero terminated string, use free()!
34 #define OPT_ARG_FLOAT 4
35 
36 typedef int (*opt_test_f)(void *);
37 
38 /** simple structure for defining the option name, type and storage location */
39 typedef struct opt_s
40 {
41   const char * name; ///< string that identifies the option
42   int type;    ///< option type as defined in subopt-helper.h
43   void * valp; ///< pointer to the mem where the value should be stored
44   opt_test_f test; ///< argument test func ( optional )
45 } opt_t;
46 
47 /** parses the string for the options specified in opt */
48 int subopt_parse( char const * const str, const opt_t * opts );
49 
50 
51 /*------------------ arg specific types and declaration -------------------*/
52 typedef struct strarg_s
53 {
54   int len; ///< length of the string determined by the parser
55   char const * str;  ///< pointer to position inside the parse string
56 } strarg_t;
57 
58 
59 int int_non_neg(void *iptr);
60 int int_pos(void *iptr);
61 
62 int strargcmp(strarg_t *arg, const char *str);
63 int strargcasecmp(strarg_t *arg, char *str);
64 
65 #endif /* MPLAYER_SUBOPT_HELPER_H */
66