Skip to content

Commit

Permalink
m_option_type_double
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11948 b3059339-0415-0410-9bf9-f77b7e298cf2
  • Loading branch information
michael committed Feb 10, 2004
1 parent fccc9cf commit 2c82d5a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
33 changes: 30 additions & 3 deletions m_option.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ m_option_type_t m_option_type_int = {
// Float

#undef VAL
#define VAL(x) (*(float*)(x))
#define VAL(x) (*(double*)(x))

static int parse_float(m_option_t* opt,char *name, char *param, void* dst, int src) {
float tmp_float;
static int parse_double(m_option_t* opt,char *name, char *param, void* dst, int src) {
double tmp_float;
char* endptr;
src = 0;

Expand Down Expand Up @@ -230,6 +230,33 @@ static int parse_float(m_option_t* opt,char *name, char *param, void* dst, int s
return 1;
}

static char* print_double(m_option_t* opt, void* val) {
opt = NULL;
return dup_printf("%f",VAL(val));
}

m_option_type_t m_option_type_double = {
"Double",
"double precission floating point number or ratio (numerator[:/]denominator)",
sizeof(double),
0,
parse_double,
print_double,
copy_opt,
copy_opt,
NULL,
NULL
};

#undef VAL
#define VAL(x) (*(float*)(x))

static int parse_float(m_option_t* opt,char *name, char *param, void* dst, int src) {
double tmp;
int r= parse_double(opt, name, param, &tmp, src);
if(r==1 && dst) VAL(dst) = tmp;
}

static char* print_float(m_option_t* opt, void* val) {
opt = NULL;
return dup_printf("%f",VAL(val));
Expand Down
2 changes: 2 additions & 0 deletions m_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct m_struct_st;
extern m_option_type_t m_option_type_flag;
extern m_option_type_t m_option_type_int;
extern m_option_type_t m_option_type_float;
extern m_option_type_t m_option_type_double;
extern m_option_type_t m_option_type_string;
extern m_option_type_t m_option_type_string_list;
extern m_option_type_t m_option_type_position;
Expand Down Expand Up @@ -78,6 +79,7 @@ extern m_obj_params_t m_span_params_def;
#define CONF_TYPE_FLAG (&m_option_type_flag)
#define CONF_TYPE_INT (&m_option_type_int)
#define CONF_TYPE_FLOAT (&m_option_type_float)
#define CONF_TYPE_DOUBLE (&m_option_type_double)
#define CONF_TYPE_STRING (&m_option_type_string)
#define CONF_TYPE_FUNC (&m_option_type_func)
#define CONF_TYPE_FUNC_PARAM (&m_option_type_func_param)
Expand Down

0 comments on commit 2c82d5a

Please sign in to comment.