summaryrefslogtreecommitdiffstats
path: root/playtreeparser.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-07-29 07:24:09 +0300
committerUoti Urpala <uau@mplayer2.org>2011-07-29 07:24:09 +0300
commit5d5ca22a6d9e87d3865ea2feb54218a6e0dfffea (patch)
tree3de73607f684c8117443d25d6c7777023723a41c /playtreeparser.c
parent8bd13d50cffb82725d2f5385574782c3002903b2 (diff)
downloadmpv-5d5ca22a6d9e87d3865ea2feb54218a6e0dfffea.tar.bz2
mpv-5d5ca22a6d9e87d3865ea2feb54218a6e0dfffea.tar.xz
options: commandline: accept --foo=xyz style options
Allow writing commandline options with two leading dashes. In this mode a parameter for the option, if any, follows after a '='; following separate commandline arguments are never consumed as a parameter to a previous double-dash option. Flag options may omit parameter and behave like old single-dash syntax. "--fs=yes", "--fs=no" and "--fs" are all valid; the first two behave like configuration file "fs=yes" and "fs=no", and last is the same as old "-fs" (same effect as "--fs=yes").
Diffstat (limited to 'playtreeparser.c')
-rw-r--r--playtreeparser.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/playtreeparser.c b/playtreeparser.c
index 777af83634..14220274de 100644
--- a/playtreeparser.c
+++ b/playtreeparser.c
@@ -31,6 +31,8 @@
#include <unistd.h>
#include <ctype.h>
#include <limits.h>
+
+#include "talloc.h"
#include "asxparser.h"
#include "m_config.h"
#include "playtree.h"
@@ -355,7 +357,7 @@ parse_pls(play_tree_parser_t* p) {
entry = play_tree_new();
play_tree_add_file(entry,entries[num].file);
if (entries[num].length)
- play_tree_set_param(entry, "endpos", entries[num].length);
+ play_tree_set_param(entry, bstr("endpos"), bstr(entries[num].length));
free(entries[num].file);
if(list)
play_tree_append_entry(last_entry,entry);
@@ -853,13 +855,13 @@ play_tree_add_basepath(play_tree_t* pt, char* bp) {
}
// Wrapper for play_tree_add_basepath (add base path from file)
-void play_tree_add_bpf(play_tree_t* pt, char* filename)
+void play_tree_add_bpf(play_tree_t *pt, struct bstr filename)
{
char *ls, *file;
- if (pt && filename)
+ if (pt)
{
- file = strdup(filename);
+ file = bstrdup0(NULL, filename);
if (file)
{
ls = strrchr(file,'/');
@@ -868,25 +870,30 @@ void play_tree_add_bpf(play_tree_t* pt, char* filename)
ls[1] = '\0';
play_tree_add_basepath(pt,file);
}
- free(file);
+ talloc_free(file);
}
}
}
play_tree_t*
-parse_playlist_file(struct m_config *mconfig, char* file) {
+parse_playlist_file(struct m_config *mconfig, struct bstr file) {
stream_t *stream;
play_tree_t* ret;
int f=DEMUXER_TYPE_PLAYLIST;
- stream = open_stream(file,0,&f);
+ char *file0 = bstrdup0(NULL, file);
+ stream = open_stream(file0, 0, &f);
+ talloc_free(file0);
if(!stream) {
- mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Error while opening playlist file %s: %s\n",file,strerror(errno));
+ mp_msg(MSGT_PLAYTREE,MSGL_ERR,
+ "Error while opening playlist file %.*s: %s\n",
+ BSTR_P(file), strerror(errno));
return NULL;
}
- mp_msg(MSGT_PLAYTREE,MSGL_V,"Parsing playlist file %s...\n",file);
+ mp_msg(MSGT_PLAYTREE, MSGL_V,
+ "Parsing playlist file %.*s...\n", BSTR_P(file));
ret = parse_playtree(stream, mconfig, 1);
free_stream(stream);