summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-09-04 19:49:35 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-09-04 19:49:35 +0300
commit0e1b7765be878491565cf5e471f22b15e106164c (patch)
tree422e500c289335182a2a64934dcabf10b95e32dc /mplayer.c
parenta9618c1c6fe9424dfaeb1677348e0382d7252554 (diff)
parentdcfd043ea8d0c46929aad78596314d837c290d39 (diff)
downloadmpv-0e1b7765be878491565cf5e471f22b15e106164c.tar.bz2
mpv-0e1b7765be878491565cf5e471f22b15e106164c.tar.xz
Merge svn changes up to r29644
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c60
1 files changed, 45 insertions, 15 deletions
diff --git a/mplayer.c b/mplayer.c
index 7553621f9a..71a0b9d488 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -52,6 +52,7 @@
#include "cfg-mplayer-def.h"
#include "ffmpeg_files/intreadwrite.h"
+#include "libavutil/avstring.h"
#include "subreader.h"
@@ -915,34 +916,59 @@ static void load_per_output_config (m_config_t* conf, char *cfg, char *out)
}
}
+/**
+ * Tries to load a config file
+ * @return 0 if file was not found, 1 otherwise
+ */
+static int try_load_config(m_config_t *conf, const char *file)
+{
+ struct stat st;
+ if (stat(file, &st))
+ return 0;
+ mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Loading config '%s'\n", file);
+ m_config_parse_config_file (conf, file);
+ return 1;
+}
+
static void load_per_file_config (m_config_t* conf, const char *const file)
{
char *confpath;
- char cfg[strlen(file)+10];
- struct stat st;
+ char cfg[PATH_MAX];
char *name;
+ if (strlen(file) > PATH_MAX - 14) {
+ mp_msg(MSGT_CPLAYER, MSGL_WARN, "Filename is too long, can not load file or directory specific config files\n");
+ return;
+ }
sprintf (cfg, "%s.conf", file);
- if (use_filedir_conf && !stat (cfg, &st))
- {
- mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Loading config '%s'\n", cfg);
- m_config_parse_config_file (conf, cfg);
- return;
+ name = strrchr(cfg, '/');
+ if (HAVE_DOS_PATHS) {
+ char *tmp = strrchr(cfg, '\\');
+ if (!name || tmp > name)
+ name = tmp;
+ tmp = strrchr(cfg, ':');
+ if (!name || tmp > name)
+ name = tmp;
}
-
- if ((name = strrchr (cfg, '/')) == NULL)
+ if (!name)
name = cfg;
else
name++;
+ if (use_filedir_conf) {
+ char dircfg[PATH_MAX];
+ strcpy(dircfg, cfg);
+ strcpy(dircfg + (name - cfg), "mplayer.conf");
+ try_load_config(conf, dircfg);
+
+ if (try_load_config(conf, cfg))
+ return;
+ }
+
if ((confpath = get_path (name)) != NULL)
{
- if (!stat (confpath, &st))
- {
- mp_tmsg(MSGT_CPLAYER,MSGL_INFO,"Loading config '%s'\n", confpath);
- m_config_parse_config_file (conf, confpath);
- }
+ try_load_config(conf, confpath);
free (confpath);
}
@@ -3426,7 +3452,7 @@ if (mpctx->demuxer && mpctx->demuxer->type==DEMUXER_TYPE_PLAYLIST)
if ((strlen(bname)>10) && !strncmp(bname,"qt",2) && !strncmp(bname+3,"gateQT",6))
continue;
- if (!strncmp(bname,mp_basename(mpctx->filename),strlen(bname))) // ignoring self-reference
+ if (!strcmp(playlist_entry, mpctx->filename)) // ignoring self-reference
continue;
entry = play_tree_new();
@@ -3439,6 +3465,10 @@ if (mpctx->demuxer && mpctx->demuxer->type==DEMUXER_TYPE_PLAYLIST)
strncpy(temp, mpctx->filename, strlen(mpctx->filename)-strlen(mp_basename(mpctx->filename)));
temp[strlen(mpctx->filename)-strlen(mp_basename(mpctx->filename))]='\0';
strcat(temp, playlist_entry);
+ if (!strcmp(temp, mpctx->filename)) {
+ free(temp);
+ continue;
+ }
play_tree_add_file(entry,temp);
mp_msg(MSGT_CPLAYER,MSGL_V,"Resolving reference to %s.\n",temp);
free(temp);