annotate m_option.h @ 10425:82387bdeb8b7

more generated files
author diego
date Sun, 13 Jul 2003 23:30:28 +0000
parents b2bf632d37b5
children 73e7a5165bcd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
1
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
2 #ifndef NEW_CONFIG
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
3 #warning "Including m_option.h but NEW_CONFIG is disabled"
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
4 #else
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
5
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
6 typedef struct m_option_type m_option_type_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
7 typedef struct m_option m_option_t;
9793
b2bf632d37b5 10L forgot to fix the forward declaration too.
albeu
parents: 9791
diff changeset
8 struct m_struct_st;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
9
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
10 ///////////////////////////// Options types declarations ////////////////////////////
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
11
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
12 // Simple types
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
13 extern m_option_type_t m_option_type_flag;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
14 extern m_option_type_t m_option_type_int;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
15 extern m_option_type_t m_option_type_float;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
16 extern m_option_type_t m_option_type_string;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
17 extern m_option_type_t m_option_type_string_list;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
18 extern m_option_type_t m_option_type_position;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
19
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
20 extern m_option_type_t m_option_type_print;
8736
michael
parents: 8168
diff changeset
21 extern m_option_type_t m_option_type_print_indirect;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
22 extern m_option_type_t m_option_type_subconfig;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
23 extern m_option_type_t m_option_type_imgfmt;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
24
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
25 // Func based types
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
26 extern m_option_type_t m_option_type_func_full;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
27 extern m_option_type_t m_option_type_func_param;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
28 extern m_option_type_t m_option_type_func;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
29
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
30 typedef void (*m_opt_default_func_t)(m_option_t *, char*);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
31 typedef int (*m_opt_func_full_t)(m_option_t *, char *, char *);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
32 typedef int (*m_opt_func_param_t)(m_option_t *, char *);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
33 typedef int (*m_opt_func_t)(m_option_t *);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
34 ///////////// Backward compat
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
35 typedef m_opt_default_func_t cfg_default_func_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
36 typedef m_opt_func_full_t cfg_func_arg_param_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
37 typedef m_opt_func_param_t cfg_func_param_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
38 typedef m_opt_func_t cfg_func_t;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
39
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
40 typedef struct {
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
41 void** list;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
42 void* name_off;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
43 void* info_off;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
44 void* desc_off;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
45 } m_obj_list_t;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
46
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
47 typedef struct {
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
48 char* name;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
49 char** attribs;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
50 } m_obj_settings_t;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
51 extern m_option_type_t m_option_type_obj_settings_list;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
52
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
53 // Presets are mean to be used with options struct
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
54
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
55
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
56 typedef struct {
9791
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
57 struct m_struct_st* in_desc;
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
58 struct m_struct_st* out_desc;
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
59 void* presets; // Pointer to an arry of struct defined by in_desc
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
60 void* name_off; // Offset of the preset name inside the in_struct
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
61 } m_obj_presets_t;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
62 extern m_option_type_t m_option_type_obj_presets;
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
63
9791
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
64 extern m_option_type_t m_option_type_custom_url;
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
65
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
66 typedef struct {
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
67 struct m_struct_st* desc; // Fields description
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
68 char separator; // Field separator to use
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
69 } m_obj_params_t;
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
70 extern m_option_type_t m_option_type_obj_params;
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
71
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
72 typedef struct {
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
73 int start;
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
74 int end;
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
75 } m_span_t;
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
76 extern m_obj_params_t m_span_params_def;
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
77
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
78
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
79 // Don't be stupid keep tho old names ;-)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
80 #define CONF_TYPE_FLAG (&m_option_type_flag)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
81 #define CONF_TYPE_INT (&m_option_type_int)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
82 #define CONF_TYPE_FLOAT (&m_option_type_float)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
83 #define CONF_TYPE_STRING (&m_option_type_string)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
84 #define CONF_TYPE_FUNC (&m_option_type_func)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
85 #define CONF_TYPE_FUNC_PARAM (&m_option_type_func_param)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
86 #define CONF_TYPE_PRINT (&m_option_type_print)
8736
michael
parents: 8168
diff changeset
87 #define CONF_TYPE_PRINT_INDIRECT (&m_option_type_print_indirect)
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
88 #define CONF_TYPE_FUNC_FULL (&m_option_type_func_full)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
89 #define CONF_TYPE_SUBCONFIG (&m_option_type_subconfig)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
90 #define CONF_TYPE_STRING_LIST (&m_option_type_string_list)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
91 #define CONF_TYPE_POSITION (&m_option_type_position)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
92 #define CONF_TYPE_IMGFMT (&m_option_type_imgfmt)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
93 #define CONF_TYPE_SPAN (&m_option_type_span)
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
94 #define CONF_TYPE_OBJ_SETTINGS_LIST (&m_option_type_obj_settings_list)
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
95 #define CONF_TYPE_OBJ_PRESETS (&m_option_type_obj_presets)
9791
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
96 #define CONF_TYPE_CUSTOM_URL (&m_option_type_custom_url)
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
97 #define CONF_TYPE_OBJ_PARAMS (&m_option_type_obj_params)
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
98
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
99 /////////////////////////////////////////////////////////////////////////////////////////////
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
100
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
101 struct m_option_type {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
102 char* name;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
103 char* comments; // syntax desc, etc
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
104 unsigned int size; // size needed for a save slot
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
105 unsigned int flags;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
106
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
107 // parse is the only requiered function all others can be NULL
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
108 // If dst if non-NULL it should create/update the save slot
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
109 // If dst is NULL it should just test the validity of the arg if possible
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
110 // Src tell from where come this setting (ie cfg file, command line, playlist, ....
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
111 // It should return 1 if param was used, 0 if not.
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
112 // On error it must return 1 of the error code below
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
113 int (*parse)(m_option_t* opt,char *name, char *param, void* dst, int src);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
114 // Print back a value in human form
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
115 char* (*print)(m_option_t* opt, void* val);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
116
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
117 // These 3 will be a memcpy in 50% of the case, it's called to save/restore the status of
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
118 // the var it's there for complex type like CONF_TYPE_FUNC*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
119 // update a save slot (dst) from the current value in the prog (src)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
120 void (*save)(m_option_t* opt,void* dst, void* src);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
121 // set the current value (dst) from a save slot
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
122 void (*set)(m_option_t* opt,void* dst, void* src);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
123 // Copy betewen 2 slot (if NULL and size > 0 a memcpy will be used
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
124 void (*copy)(m_option_t* opt,void* dst, void* src);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
125 // Free the data allocated for a save slot if needed
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
126 void (*free)(void* dst);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
127 };
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
128
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
129 /// This is the same thing as a struct config it have been renamed
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
130 /// to remove this config_t, m_config_t mess. Sorry about that,
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
131 /// config_t is still provided for backward compat.
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
132 struct m_option {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
133 char *name;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
134 void *p;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
135 m_option_type_t* type;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
136 unsigned int flags;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
137 float min,max;
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
138 // This used to be function pointer to hold a 'reverse to defaults' func.
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
139 // Nom it can be used to pass any type of extra args.
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
140 // Passing a 'default func' is still valid for all func based option types
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
141 void* priv; // Type dependent data (for all kind of extended setting)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
142 };
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
143
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
144
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
145 //////////////////////////////// Option flags /////////////////////////////////
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
146
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
147 // Option flags
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
148 #define M_OPT_MIN (1<<0)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
149 #define M_OPT_MAX (1<<1)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
150 #define M_OPT_RANGE (M_OPT_MIN|M_OPT_MAX)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
151 #define M_OPT_NOCFG (1<<2)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
152 #define M_OPT_NOCMD (1<<3)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
153 // This option is global : it won't be saved on push and the command
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
154 // line parser will set it when it's parsed (ie. it won't be set later)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
155 // e.g options : -v, -quiet
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
156 #define M_OPT_GLOBAL (1<<4)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
157 // Do not save this option : it won't be saved on push but the command
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
158 // line parser will put it with it's entry (ie : it may be set later)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
159 // e.g options : -include
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
160 #define M_OPT_NOSAVE (1<<5)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
161 // Emulate old behaviour by pushing the option only if it was set by the user
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
162 #define M_OPT_OLD (1<<6)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
163
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
165 ///////////////////////////// Option type flags ///////////////////////////////////
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
166
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
167 // These flags are for the parsers. The description here apply to the m_config_t
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
168 // based parsers (ie. cmd line and config file parsers)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
169 // Some parser will refuse option types that have some of these flags
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
170
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
171 // This flag is used for the subconfig
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
172 // When this flag is set, opt->p should point to another m_option_t array
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
173 // Only the parse function will be called. If dst is set, it should create/update
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
174 // an array of char* containg opt/val pairs.
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
175 // Then the options in the child array will then be set automaticly.
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
176 // You can only affect the way suboption are parsed.
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
177 // Also note that suboptions may be directly accessed by using -option:subopt blah :-)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
178 #define M_OPT_TYPE_HAS_CHILD (1<<0)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
179 // If this flag is set the option type support option name with * at the end (used for -aa*)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
180 // This only affect the option name matching, the option type have to implement
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
181 // the needed stuff.
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
182 #define M_OPT_TYPE_ALLOW_WILDCARD (1<<1)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
183 // This flag indicate that the data is dynamicly allocated (opt->p point to a pointer)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
184 // It enable a little hack wich replace the initial value by a dynamic copy
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
185 // in case the initial value is staticly allocated (pretty common with strings)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
186 #define M_OPT_TYPE_DYNAMIC (1<<2)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
187 /// If this is set the parse function doesn't directly return
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
188 // the wanted thing. Options use this if for some reasons they have to wait
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
189 // until the set call to be able to correctly set the target var.
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
190 // So for those types you have to first parse and then set the target var
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
191 // If this flag isn't set you can parse directly to the target var
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
192 // It's used for the callback based option as the callback call may append
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
193 // later on.
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
194 #define M_OPT_TYPE_INDIRECT (1<<3)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
195
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
196
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
197 ///////////////////////////// Parser flags ////////////////////////////////////////
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
198
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
199 // Config mode : some parser type behave differently depending
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
200 // on config->mode value wich is passed in the src param of parse()
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
201 #define M_CONFIG_FILE 0
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
202 #define M_COMMAND_LINE 1
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
203
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
204 // Option parser error code
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
205 #define M_OPT_UNKNOW -1
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
206 #define M_OPT_MISSING_PARAM -2
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
207 #define M_OPT_INVALID -3
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
208 #define M_OPT_OUT_OF_RANGE -4
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
209 #define M_OPT_PARSER_ERR -5
9791
c5b63e88253d Fix some 10L typo in header (m_struct_s instead of m_struct_st).
albeu
parents: 9593
diff changeset
210 #define M_OPT_EXIT -6
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
211
9593
e9a2af584986 Add the new -vf option wich is the same as vop in reverse order.
albeu
parents: 8736
diff changeset
212 m_option_t* m_option_list_find(m_option_t* list,char* name);
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
213
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
214 inline static int
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
215 m_option_parse(m_option_t* opt,char *name, char *param, void* dst, int src) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
216 return opt->type->parse(opt,name,param,dst,src);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
217 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
218
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
219 inline static char*
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
220 m_option_print(m_option_t* opt, void* val_ptr) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
221 if(opt->type->print)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
222 return opt->type->print(opt,val_ptr);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
223 else
8168
ff6a98628e6c Fix the Gui with NEW_CONFIG
albeu
parents: 8164
diff changeset
224 return (char*)-1;
8164
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
225 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
226
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
227 inline static void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
228 m_option_save(m_option_t* opt,void* dst, void* src) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
229 if(opt->type->save)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
230 opt->type->save(opt,dst,src);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
231 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
232
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
233 inline static void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
234 m_option_set(m_option_t* opt,void* dst, void* src) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
235 if(opt->type->set)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
236 opt->type->set(opt,dst,src);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
237 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
238
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
239 inline static void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
240 m_option_copy(m_option_t* opt,void* dst, void* src) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
241 if(opt->type->copy)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
242 opt->type->set(opt,dst,src);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
243 else if(opt->type->size > 0)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
244 memcpy(dst,src,opt->type->size);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
245 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
246
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
247 inline static void
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
248 m_option_free(m_option_t* opt,void* dst) {
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
249 if(opt->type->free)
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
250 opt->type->free(dst);
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
251 }
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
252
487cfc28525d New config system + cleanup of header inter dependency
albeu
parents:
diff changeset
253 #endif