summaryrefslogtreecommitdiffstats
path: root/subopt-helper.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-01-19 17:10:20 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-01-19 17:10:20 +0000
commitca8fc9929bdc71e2192a8fdbcab2eb0c1fb6191c (patch)
treeeb22dec8700b3581b735ae10863416673aac0c70 /subopt-helper.c
parentce701ae4386237798ffe06447021481e8e8002fc (diff)
downloadmpv-ca8fc9929bdc71e2192a8fdbcab2eb0c1fb6191c.tar.bz2
mpv-ca8fc9929bdc71e2192a8fdbcab2eb0c1fb6191c.tar.xz
New suboption type: malloc'ed, zero terminated string
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14539 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subopt-helper.c')
-rw-r--r--subopt-helper.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/subopt-helper.c b/subopt-helper.c
index df2ceda639..1ffd5fe746 100644
--- a/subopt-helper.c
+++ b/subopt-helper.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#include <assert.h>
#ifndef MPDEBUG
@@ -144,6 +145,23 @@ int subopt_parse( char const * const str, opt_t * opts )
last = parse_str( &str[parse_pos],
(strarg_t *)opts[idx].valp );
break;
+ case OPT_ARG_MSTRZ:
+ {
+ char **valp = opts[idx].valp;
+ strarg_t tmp;
+ tmp.str = NULL;
+ tmp.len = 0;
+ last = parse_str( &str[parse_pos], &tmp );
+ if (*valp)
+ free(*valp);
+ *valp = NULL;
+ if (tmp.str && tmp.len > 0) {
+ *valp = malloc(tmp.len + 1);
+ memcpy(*valp, tmp.str, tmp.len);
+ *valp[tmp.len] = 0;
+ }
+ break;
+ }
default:
assert( 0 && "Arg type of suboption doesn't exist!" );
last = NULL; // break parsing!
@@ -237,7 +255,7 @@ static char const * parse_str( char const * const str, strarg_t * const valp )
match = &str[strlen(str)];
// empty string or too long
- if ((match == str) || (match - str > 255))
+ if ((match == str) || (match - str > INT_MAX))
return NULL;
valp->len = match - str;