Mercurial > mplayer.hg
comparison m_option.c @ 11947:3ccd5dcf447c
m_option_type_double
author | michael |
---|---|
date | Tue, 10 Feb 2004 14:32:06 +0000 |
parents | 3f488aa0d646 |
children | 1d32c7c7355c |
comparison
equal
deleted
inserted
replaced
11946:73b7ddcf4cbe | 11947:3ccd5dcf447c |
---|---|
177 }; | 177 }; |
178 | 178 |
179 // Float | 179 // Float |
180 | 180 |
181 #undef VAL | 181 #undef VAL |
182 #define VAL(x) (*(float*)(x)) | 182 #define VAL(x) (*(double*)(x)) |
183 | 183 |
184 static int parse_float(m_option_t* opt,char *name, char *param, void* dst, int src) { | 184 static int parse_double(m_option_t* opt,char *name, char *param, void* dst, int src) { |
185 float tmp_float; | 185 double tmp_float; |
186 char* endptr; | 186 char* endptr; |
187 src = 0; | 187 src = 0; |
188 | 188 |
189 if (param == NULL) | 189 if (param == NULL) |
190 return M_OPT_MISSING_PARAM; | 190 return M_OPT_MISSING_PARAM; |
226 return M_OPT_OUT_OF_RANGE; | 226 return M_OPT_OUT_OF_RANGE; |
227 } | 227 } |
228 | 228 |
229 if(dst) VAL(dst) = tmp_float; | 229 if(dst) VAL(dst) = tmp_float; |
230 return 1; | 230 return 1; |
231 } | |
232 | |
233 static char* print_double(m_option_t* opt, void* val) { | |
234 opt = NULL; | |
235 return dup_printf("%f",VAL(val)); | |
236 } | |
237 | |
238 m_option_type_t m_option_type_double = { | |
239 "Double", | |
240 "double precission floating point number or ratio (numerator[:/]denominator)", | |
241 sizeof(double), | |
242 0, | |
243 parse_double, | |
244 print_double, | |
245 copy_opt, | |
246 copy_opt, | |
247 NULL, | |
248 NULL | |
249 }; | |
250 | |
251 #undef VAL | |
252 #define VAL(x) (*(float*)(x)) | |
253 | |
254 static int parse_float(m_option_t* opt,char *name, char *param, void* dst, int src) { | |
255 double tmp; | |
256 int r= parse_double(opt, name, param, &tmp, src); | |
257 if(r==1 && dst) VAL(dst) = tmp; | |
231 } | 258 } |
232 | 259 |
233 static char* print_float(m_option_t* opt, void* val) { | 260 static char* print_float(m_option_t* opt, void* val) { |
234 opt = NULL; | 261 opt = NULL; |
235 return dup_printf("%f",VAL(val)); | 262 return dup_printf("%f",VAL(val)); |