[asterisk-commits] trunk - r7945 in /trunk/funcs: func_math.c func_md5.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Jan 10 10:08:29 CST 2006


Author: mogorman
Date: Tue Jan 10 10:08:28 2006
New Revision: 7945

URL: http://svn.digium.com/view/asterisk?rev=7945&view=rev
Log:
6186 amd 6187 with minor revisions.  added arg
parsing from macro.

Modified:
    trunk/funcs/func_math.c
    trunk/funcs/func_md5.c

Modified: trunk/funcs/func_math.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_math.c?rev=7945&r1=7944&r2=7945&view=diff
==============================================================================
--- trunk/funcs/func_math.c (original)
+++ trunk/funcs/func_math.c Tue Jan 10 10:08:28 2006
@@ -66,35 +66,42 @@
 
 static char *builtin_function_math(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 {
-	int argc;
-	char *argv[2];
-	char *args;
 	float fnum1;
 	float fnum2;
 	float ftmp = 0;
 	char *op;
 	int iaction=-1;
 	int type_of_result=FLOAT_RESULT;
-
+	char *parse;
+	
 	/* dunno, big calulations :D */
 	char user_result[30];
 
 	char *mvalue1, *mvalue2=NULL, *mtype_of_result;
-		
+	
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(argv0);
+		AST_APP_ARG(argv1);
+	);
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "Syntax: Math(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n");
 		return NULL;
 	}
 
-	args = ast_strdupa(data);	
-	argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0]));
-
-	if (argc < 1) {
+	parse = ast_strdupa(data);
+	if(!parse) {
+		ast_log(LOG_ERROR, "Out of memory!\n");
+		return NULL;
+	}
+
+	AST_STANDARD_APP_ARGS(args, parse);
+	
+	if (args.argc < 1) {
 		ast_log(LOG_WARNING, "Syntax: Math(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n");
 		return NULL;
 	}
 
-	mvalue1 = argv[0];
+	mvalue1 = args.argv0;
 	
 	if ((op = strchr(mvalue1, '+'))) {
 		iaction = ADDFUNCTION;
@@ -139,7 +146,7 @@
 		mvalue2 = op + 1;
 
 	/* detect wanted type of result */
-	mtype_of_result = argv[1];
+	mtype_of_result = args.argv1;
 	if (mtype_of_result)
 	{
 		if (!strcasecmp(mtype_of_result,"float") || !strcasecmp(mtype_of_result,"f"))

Modified: trunk/funcs/func_md5.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_md5.c?rev=7945&r1=7944&r2=7945&view=diff
==============================================================================
--- trunk/funcs/func_md5.c (original)
+++ trunk/funcs/func_md5.c Tue Jan 10 10:08:28 2006
@@ -55,27 +55,34 @@
 
 static char *builtin_function_checkmd5(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 {
-	int argc;
-	char *argv[2];
-	char *args;
 	char newmd5[33];
+	char *parse;
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(digest);
+		AST_APP_ARG(data);
+	);
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
 		return NULL;
 	}
 
-	args = ast_strdupa(data);	
-	argc = ast_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0]));
-
-	if (argc < 2) {
+	parse = ast_strdupa(data);
+	if (!parse) {
+		ast_log(LOG_ERROR, "Out of memory!\n");
+		return NULL;
+	}
+	
+	AST_STANDARD_APP_ARGS(args, parse);
+	
+	if (args.argc < 2) {
 		ast_log(LOG_WARNING, "Syntax: CHECK_MD5(<digest>,<data>) - missing argument!\n");
 		return NULL;
 	}
 
-	ast_md5_hash(newmd5, argv[1]);
+	ast_md5_hash(newmd5, args.data);
 
-	if (!strcasecmp(newmd5, argv[0]))	/* they match */
+	if (!strcasecmp(newmd5, args.digest) )	/* they match */
 		ast_copy_string(buf, "1", len);
 	else
 		ast_copy_string(buf, "0", len);



More information about the asterisk-commits mailing list