m_config: add custom context to includefunc callback

This commit is contained in:
wm4 2013-12-21 19:27:19 +01:00
parent 3846fc7587
commit dadf3a9a46
3 changed files with 7 additions and 4 deletions

View File

@ -64,7 +64,7 @@ static int parse_include(struct m_config *config, struct bstr param, bool set,
if (!set)
return 1;
char *filename = bstrdup0(NULL, param);
config->includefunc(config, filename, flags);
config->includefunc(config->includefunc_ctx, filename, flags);
talloc_free(filename);
return 1;
}

View File

@ -61,7 +61,8 @@ typedef struct m_config {
bool use_profiles;
bool is_toplevel;
int (*includefunc)(struct m_config *conf, char *filename, int flags);
int (*includefunc)(void *ctx, char *filename, int flags);
void *includefunc_ctx;
void *optstruct; // struct mpopts or other
} m_config_t;

View File

@ -292,9 +292,10 @@ static void init_input(struct MPContext *mpctx)
#endif
}
static int cfg_include(struct m_config *conf, char *filename, int flags)
static int cfg_include(void *ctx, char *filename, int flags)
{
return m_config_parse_config_file(conf, filename, flags);
struct MPContext *mpctx = ctx;
return m_config_parse_config_file(mpctx->mconfig, filename, flags);
}
static int mpv_main(int argc, char *argv[])
@ -318,6 +319,7 @@ static int mpv_main(int argc, char *argv[])
&mp_default_opts, mp_opts);
mpctx->opts = mpctx->mconfig->optstruct;
mpctx->mconfig->includefunc = cfg_include;
mpctx->mconfig->includefunc_ctx = mpctx;
mpctx->mconfig->use_profiles = true;
mpctx->mconfig->is_toplevel = true;