[asterisk-commits] russell: branch group/asterisk-cpp r168455 - /team/group/asterisk-cpp/main/app.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 11 18:34:03 CST 2009


Author: russell
Date: Sun Jan 11 18:34:02 2009
New Revision: 168455

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=168455
Log:
fix app arg parsing funcs to account for changes in app.h

Modified:
    team/group/asterisk-cpp/main/app.c

Modified: team/group/asterisk-cpp/main/app.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/asterisk-cpp/main/app.c?view=diff&rev=168455&r1=168454&r2=168455
==============================================================================
--- team/group/asterisk-cpp/main/app.c (original)
+++ team/group/asterisk-cpp/main/app.c Sun Jan 11 18:34:02 2009
@@ -1667,7 +1667,7 @@
 	return output;
 }
 
-int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
+int ast_app_parse_options(const struct ast_app_option *options, size_t num_options, struct ast_flags *flags, char **args, char *optstr)
 {
 	char *s, *arg;
 	int curarg, res = 0;
@@ -1680,8 +1680,17 @@
 
 	s = optstr;
 	while (*s) {
-		curarg = *s++ & 0x7f;	/* the array (in app.h) has 128 entries */
-		argloc = options[curarg].arg_index;
+		unsigned int i;
+		curarg = *s++;
+		for (i = 0; i < num_options; i++) {
+			if (options[i].optchar == curarg) {
+				break;
+			}
+		}
+		if (i == num_options) {
+			continue;
+		}
+		argloc = options[i].arg_index;
 		if (*s == '(') {
 			/* Has argument */
 			arg = ++s;
@@ -1695,7 +1704,7 @@
 				break;
 			}
 		}
-		ast_set_flag(flags, options[curarg].flag);
+		ast_set_flag(flags, options[i].flag);
 	}
 
 	return res;
@@ -1705,7 +1714,7 @@
    better handle the large number of options it provides. After it is, you need to get rid of this variant 
    -- unless, of course, someone else digs up some use for large flag fields. */
 
-int ast_app_parse_options64(const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr)
+int ast_app_parse_options64(const struct ast_app_option *options, size_t num_options, struct ast_flags64 *flags, char **args, char *optstr)
 {
 	char *s, *arg;
 	int curarg, res = 0;
@@ -1718,9 +1727,18 @@
 
 	s = optstr;
 	while (*s) {
-		curarg = *s++ & 0x7f;	/* the array (in app.h) has 128 entries */
-		ast_set_flag64(flags, options[curarg].flag);
-		argloc = options[curarg].arg_index;
+		unsigned int i;
+		curarg = *s++;
+		for (i = 0; i < num_options; i++) {
+			if (options[i].optchar == curarg) {
+				break;
+			}
+		}
+		if (i == num_options) {
+			continue;
+		}
+		ast_set_flag64(flags, options[i].flag);
+		argloc = options[i].arg_index;
 		if (*s == '(') {
 			/* Has argument */
 			arg = ++s;




More information about the asterisk-commits mailing list