diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-03-12 05:37:32 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-03-12 05:37:32 +0000 |
commit | b61285c1d9e13b7c8f7af8cc4837540226cd99c3 (patch) | |
tree | 865433608b42afc5993e2a252f44293b75c8c200 /app.c | |
parent | 3ad9cdea1eaa73d82c3b815688b2670dd31e35e7 (diff) |
Create experimental new options API, various cleanups
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5171 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'app.c')
-rwxr-xr-x | app.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -1455,3 +1455,38 @@ char *ast_read_textfile(const char *filename) return output; } +int ast_parseoptions(const struct ast_option *options, struct ast_flags *flags, char **args, char *optstr) +{ + char *s; + int curarg; + int argloc; + char *arg; + int res = 0; + flags->flags = 0; + if (!optstr) + return 0; + s = optstr; + while(*s) { + curarg = *s & 0x7f; + flags->flags |= options[curarg].flag; + argloc = options[curarg].argoption; + s++; + if (*s == '(') { + /* Has argument */ + s++; + arg = s; + while(*s && (*s != ')')) s++; + if (*s) { + if (argloc) + args[argloc - 1] = arg; + *s = '\0'; + s++; + } else { + ast_log(LOG_WARNING, "Missing closing parenthesis for argument '%c'\n", curarg); + res = -1; + } + } + } + return res; +} + |