changeset 15733:e678e306068e

support lenght-quoting of strings in subopt parser.
author reimar
date Thu, 16 Jun 2005 09:03:11 +0000
parents 52edb32f0c2a
children 7e4fa8fc255c
files DOCS/man/en/mplayer.1 subopt-helper.c
diffstat 2 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Thu Jun 16 07:42:01 2005 +0000
+++ b/DOCS/man/en/mplayer.1	Thu Jun 16 09:03:11 2005 +0000
@@ -383,6 +383,22 @@
 If an option is marked as (XXX only), it will only work in combination with
 the XXX option or if XXX is compiled in.
 .PP
+.I NOTE:
+.PD 0
+.RSs
+The suboption parser (used for example for -ao pcm suboptions) supports
+a special kind of string-escaping intended for use with external GUIs.
+.PP
+It has the following format:
+.PP
+%n%string_of_lenght_n
+.PP
+Usage example:
+.PP
+mplayer -ao pcm:file=%10%C:test.wav test.avi
+.RE
+.PD 1
+.PP
 You can put all of the options in a configuration file which will be read
 every time MPlayer is run.
 The system-wide configuration file 'mplayer.conf' is in your configuration
--- a/subopt-helper.c	Thu Jun 16 07:42:01 2005 +0000
+++ b/subopt-helper.c	Thu Jun 16 09:03:11 2005 +0000
@@ -247,10 +247,21 @@
   return endp;
 }
 
-static char const * parse_str( char const * const str, strarg_t * const valp )
+#define QUOTE_CHAR '%'
+static char const * parse_str( char const * str, strarg_t * const valp )
 {
   char const * match = strchr( str, ':' );
 
+  if (str[0] == QUOTE_CHAR) {
+    int len = 0;
+    str = &str[1];
+    len = (int)strtol(str, (char **)&str, 0);
+    if (!str || str[0] != QUOTE_CHAR || (len > strlen(str) - 1))
+      return NULL;
+    str = &str[1];
+    match = &str[len];
+  }
+  else
   if ( !match )
     match = &str[strlen(str)];