summaryrefslogtreecommitdiffstats
path: root/m_property.c
diff options
context:
space:
mode:
authoruau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-02-21 00:49:24 +0000
committeruau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-02-21 00:49:24 +0000
commitd5d4c6c7e224709c53d28352ce6aadc3c6e72374 (patch)
tree9fe98ae571ad6bda5cf04273cefabd6ffcbf92ae /m_property.c
parente23b2395c0265c0a0bd92c0468e20e8ce42793e6 (diff)
downloadmpv-d5d4c6c7e224709c53d28352ce6aadc3c6e72374.tar.bz2
mpv-d5d4c6c7e224709c53d28352ce6aadc3c6e72374.tar.xz
Split command/property handling from mplayer.c to a new file command.c.
Move some global and static variables under a struct that can be given as a parameter. Add a context argument to the property functions so that they do not have to depend on global/static variables. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22298 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'm_property.c')
-rw-r--r--m_property.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/m_property.c b/m_property.c
index c108669390..fe28f145b5 100644
--- a/m_property.c
+++ b/m_property.c
@@ -17,13 +17,13 @@
#define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
-int m_property_do(m_option_t* prop, int action, void* arg) {
+int m_property_do(m_option_t* prop, int action, void* arg, void *ctx) {
if(!prop) return M_PROPERTY_UNKNOWN;
- return ((m_property_ctrl_f)prop->p)(prop,action,arg);
+ return ((m_property_ctrl_f)prop->p)(prop,action,arg,ctx);
}
-char* m_property_print(m_option_t* prop) {
+char* m_property_print(m_option_t* prop, void *ctx) {
m_property_ctrl_f ctrl;
void* val;
char* ret;
@@ -32,11 +32,11 @@ char* m_property_print(m_option_t* prop) {
ctrl = prop->p;
// look if the property have it's own print func
- if(ctrl(prop,M_PROPERTY_PRINT,&ret) >= 0)
+ if(ctrl(prop,M_PROPERTY_PRINT,&ret, ctx) >= 0)
return ret;
// fallback on the default print for this type
val = calloc(1,prop->type->size);
- if(ctrl(prop,M_PROPERTY_GET,val) <= 0) {
+ if(ctrl(prop,M_PROPERTY_GET,val,ctx) <= 0) {
free(val);
return NULL;
}
@@ -45,7 +45,7 @@ char* m_property_print(m_option_t* prop) {
return ret == (char*)-1 ? NULL : ret;
}
-int m_property_parse(m_option_t* prop, char* txt) {
+int m_property_parse(m_option_t* prop, char* txt, void *ctx) {
m_property_ctrl_f ctrl;
void* val;
int r;
@@ -54,7 +54,7 @@ int m_property_parse(m_option_t* prop, char* txt) {
ctrl = prop->p;
// try the property own parsing func
- if((r = ctrl(prop,M_PROPERTY_PARSE,txt)) != M_PROPERTY_NOT_IMPLEMENTED)
+ if((r = ctrl(prop,M_PROPERTY_PARSE,txt,ctx)) != M_PROPERTY_NOT_IMPLEMENTED)
return r;
// fallback on the default
val = calloc(1,prop->type->size);
@@ -62,13 +62,13 @@ int m_property_parse(m_option_t* prop, char* txt) {
free(val);
return r;
}
- r = ctrl(prop,M_PROPERTY_SET,val);
+ r = ctrl(prop,M_PROPERTY_SET,val,ctx);
m_option_free(prop,val);
free(val);
return r;
}
-char* m_properties_expand_string(m_option_t* prop_list,char* str) {
+char* m_properties_expand_string(m_option_t* prop_list,char* str, void *ctx) {
int l,fr=0,pos=0,size=strlen(str)+512;
char *p = NULL,*e,*ret = malloc(size), num_val;
int skip = 0, lvl = 0, skip_lvl = 0;
@@ -110,7 +110,7 @@ char* m_properties_expand_string(m_option_t* prop_list,char* str) {
memcpy(pname,str+2,pl);
pname[pl] = 0;
if((prop = m_option_list_find(prop_list,pname)) &&
- (p = m_property_print(prop)))
+ (p = m_property_print(prop, ctx)))
l = strlen(p), fr = 1;
else
l = 0;
@@ -124,7 +124,7 @@ char* m_properties_expand_string(m_option_t* prop_list,char* str) {
memcpy(pname,str+2,pl);
pname[pl] = 0;
if(!(prop = m_option_list_find(prop_list,pname)) ||
- m_property_do(prop,M_PROPERTY_GET,NULL) < 0)
+ m_property_do(prop,M_PROPERTY_GET,NULL, ctx) < 0)
skip = 1, skip_lvl = lvl;
}
str = e+1, l = 0;