summaryrefslogtreecommitdiffstats
path: root/libmenu
diff options
context:
space:
mode:
authorUoti Urpala <uau@symbol.nonexistent.invalid>2008-04-26 10:44:59 +0300
committerUoti Urpala <uau@symbol.nonexistent.invalid>2008-04-26 10:44:59 +0300
commitfb33e286b5c23dbe8d0aeaf63cd3490bed3906e3 (patch)
tree9e1eb90e7ec461afd59c3411c2be253b75a9f448 /libmenu
parent6be229cbbfbe29ad61025051b1d903f5619e0b8a (diff)
downloadmpv-fb33e286b5c23dbe8d0aeaf63cd3490bed3906e3.tar.bz2
mpv-fb33e286b5c23dbe8d0aeaf63cd3490bed3906e3.tar.xz
Move global mconfig to mpctx
The global was used in the function cfg_include which handles the -include option. Make the address available in that function by creating a new dynamically allocated option in m_config_new that has the address in the option's private data. asxparser.c also used the global. Making it available through all ways the code could get called required a number of relatively straightforward changes to playtree and menu code.
Diffstat (limited to 'libmenu')
-rw-r--r--libmenu/menu.c14
-rw-r--r--libmenu/menu.h3
-rw-r--r--libmenu/menu_cmdlist.c2
-rw-r--r--libmenu/menu_param.c2
4 files changed, 14 insertions, 7 deletions
diff --git a/libmenu/menu.c b/libmenu/menu.c
index 3c47623ed6..6d3c6fb83e 100644
--- a/libmenu/menu.c
+++ b/libmenu/menu.c
@@ -71,6 +71,7 @@ double menu_mouse_y = -1.0;
int menu_mouse_pos_updated = 0;
static struct MPContext *menu_ctx = NULL;
+static struct m_config *menu_mconfig = NULL;
static menu_def_t* menu_list = NULL;
static int menu_count = 0;
static menu_cmd_bindings_t *cmd_bindings = NULL;
@@ -85,11 +86,12 @@ menu_cmd_bindings_t *get_cmd_bindings(const char *name) {
return NULL;
}
-static int menu_parse_config(char* buffer) {
+static int menu_parse_config(char* buffer, struct m_config *mconfig)
+{
char *element,*body, **attribs, *name;
menu_info_t* minfo = NULL;
int r,i;
- ASX_Parser_t* parser = asx_parser_new();
+ ASX_Parser_t* parser = asx_parser_new(mconfig);
while(1) {
r = asx_get_element(parser,&buffer,&element,&body,&attribs);
@@ -211,7 +213,9 @@ static int menu_parse_config(char* buffer) {
#define BUF_STEP 1024
#define BUF_MIN 128
#define BUF_MAX BUF_STEP*1024
-int menu_init(struct MPContext *mpctx, char* cfg_file) {
+int menu_init(struct MPContext *mpctx, struct m_config *mconfig,
+ char* cfg_file)
+{
char* buffer = NULL;
int bl = BUF_STEP, br = 0;
int f, fd;
@@ -250,7 +254,8 @@ int menu_init(struct MPContext *mpctx, char* cfg_file) {
close(fd);
menu_ctx = mpctx;
- f = menu_parse_config(buffer);
+ menu_mconfig = mconfig;
+ f = menu_parse_config(buffer, mconfig);
free(buffer);
return f;
}
@@ -311,6 +316,7 @@ menu_t* menu_open(char *name) {
m->priv_st = &(menu_list[i].type->priv_st);
m->priv = m_struct_copy(m->priv_st,menu_list[i].cfg);
m->ctx = menu_ctx;
+ m->mconfig = menu_mconfig;
m->type = &menu_list[i];
if(menu_list[i].type->open(m,menu_list[i].args))
return m;
diff --git a/libmenu/menu.h b/libmenu/menu.h
index 2d62a5be89..7b63fad547 100644
--- a/libmenu/menu.h
+++ b/libmenu/menu.h
@@ -13,6 +13,7 @@ struct m_struct_st;
struct menu_s {
struct MPContext *ctx;
+ struct m_config *mconfig;
void (*draw)(menu_t* menu,mp_image_t* mpi);
void (*read_cmd)(menu_t* menu,int cmd);
int (*read_key)(menu_t* menu,int cmd);
@@ -52,7 +53,7 @@ typedef struct menu_info_s {
#define MENU_CMD_CLICK 11
/// Global init/uninit
-int menu_init(struct MPContext *mpctx, char* cfg_file);
+int menu_init(struct MPContext *mpctx, struct m_config *mconfig, char* cfg_file);
void menu_uninit(void);
/// Open a menu defined in the config file
diff --git a/libmenu/menu_cmdlist.c b/libmenu/menu_cmdlist.c
index ab7cbeb3a9..13025c222c 100644
--- a/libmenu/menu_cmdlist.c
+++ b/libmenu/menu_cmdlist.c
@@ -98,7 +98,7 @@ static int parse_args(menu_t* menu,char* args) {
char *element,*body, **attribs, *name;
list_entry_t* m = NULL;
int r;
- ASX_Parser_t* parser = asx_parser_new();
+ ASX_Parser_t* parser = asx_parser_new(menu->mconfig);
while(1) {
r = asx_get_element(parser,&args,&element,&body,&attribs);
diff --git a/libmenu/menu_param.c b/libmenu/menu_param.c
index a1aeef44bd..6eadf8825d 100644
--- a/libmenu/menu_param.c
+++ b/libmenu/menu_param.c
@@ -94,7 +94,7 @@ static int parse_args(menu_t* menu,char* args) {
list_entry_t* m = NULL;
int r;
m_option_t* opt;
- ASX_Parser_t* parser = asx_parser_new();
+ ASX_Parser_t* parser = asx_parser_new(menu->mconfig);
while(1) {