[asterisk-commits] file: trunk r54534 - in /trunk/apps: app_exec.c app_flash.c app_image.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Feb 14 19:02:31 MST 2007


Author: file
Date: Wed Feb 14 20:02:30 2007
New Revision: 54534

URL: http://svn.digium.com/view/asterisk?view=rev&rev=54534
Log:
Few more code clean ups.

Modified:
    trunk/apps/app_exec.c
    trunk/apps/app_flash.c
    trunk/apps/app_image.c

Modified: trunk/apps/app_exec.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_exec.c?view=diff&rev=54534&r1=54533&r2=54534
==============================================================================
--- trunk/apps/app_exec.c (original)
+++ trunk/apps/app_exec.c Wed Feb 14 20:02:30 2007
@@ -95,30 +95,31 @@
 	char *s, *appname, *endargs, args[MAXRESULT] = "";
 	struct ast_app *app;
 
+	if (ast_strlen_zero(data))
+		return 0;
+
 	u = ast_module_user_add(chan);
-
-	/* Check and parse arguments */
-	if (data) {
-		s = ast_strdupa(data);
-		appname = strsep(&s, "(");
-		if (s) {
-			endargs = strrchr(s, ')');
-			if (endargs)
-				*endargs = '\0';
-			pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
+	
+	s = ast_strdupa(data);
+	appname = strsep(&s, "(");
+	if (s) {
+		endargs = strrchr(s, ')');
+		if (endargs)
+			*endargs = '\0';
+		pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
+	}
+	if (appname) {
+		app = pbx_findapp(appname);
+		if (app) {
+			res = pbx_exec(chan, app, args);
+		} else {
+			ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
+			res = -1;
 		}
-		if (appname) {
-			app = pbx_findapp(appname);
-			if (app) {
-				res = pbx_exec(chan, app, args);
-			} else {
-				ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
-				res = -1;
-			}
-		}
 	}
 
 	ast_module_user_remove(u);
+
 	return res;
 }
 
@@ -129,31 +130,32 @@
 	char *s, *appname, *endargs, args[MAXRESULT] = "";
 	struct ast_app *app;
 
+	if (ast_strlen_zero(data))
+		return 0;
+
 	u = ast_module_user_add(chan);
 
-	/* Check and parse arguments */
-	if (data) {
-		s = ast_strdupa(data);
-		appname = strsep(&s, "(");
-		if (s) {
-			endargs = strrchr(s, ')');
-			if (endargs)
-				*endargs = '\0';
-			pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
+	s = ast_strdupa(data);
+	appname = strsep(&s, "(");
+	if (s) {
+		endargs = strrchr(s, ')');
+		if (endargs)
+			*endargs = '\0';
+		pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
+	}
+	if (appname) {
+		app = pbx_findapp(appname);
+		if (app) {
+			res = pbx_exec(chan, app, args);
+			pbx_builtin_setvar_helper(chan, "TRYSTATUS", res ? "FAILED" : "SUCCESS");
+		} else {
+			ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
+			pbx_builtin_setvar_helper(chan, "TRYSTATUS", "NOAPP");
 		}
-		if (appname) {
-			app = pbx_findapp(appname);
-			if (app) {
-				res = pbx_exec(chan, app, args);
-				pbx_builtin_setvar_helper(chan, "TRYSTATUS", res ? "FAILED" : "SUCCESS");
-			} else {
-				ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
-				pbx_builtin_setvar_helper(chan, "TRYSTATUS", "NOAPP");
-			}
-		}
 	}
 
 	ast_module_user_remove(u);
+
 	return 0;
 }
 

Modified: trunk/apps/app_flash.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_flash.c?view=diff&rev=54534&r1=54533&r2=54534
==============================================================================
--- trunk/apps/app_flash.c (original)
+++ trunk/apps/app_flash.c Wed Feb 14 20:02:30 2007
@@ -75,31 +75,37 @@
 	int x;
 	struct ast_module_user *u;
 	struct zt_params ztp;
+
+	if (strcasecmp(chan->tech->type, "Zap")) {
+		ast_log(LOG_WARNING, "%s is not a Zap channel\n", chan->name);
+		return -1;
+	}
+
 	u = ast_module_user_add(chan);
-	if (!strcasecmp(chan->tech->type, "Zap")) {
-		memset(&ztp, 0, sizeof(ztp));
-		res = ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp);
-		if (!res) {
-			if (ztp.sigtype & __ZT_SIG_FXS) {
-				x = ZT_FLASH;
-				res = ioctl(chan->fds[0], ZT_HOOK, &x);
-				if (!res || (errno == EINPROGRESS)) {
-					if (res) {
-						/* Wait for the event to finish */
-						zt_wait_event(chan->fds[0]);
-					}
-					res = ast_safe_sleep(chan, 1000);
-					if (option_verbose > 2)
-						ast_verbose(VERBOSE_PREFIX_3 "Flashed channel %s\n", chan->name);
-				} else
-					ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", chan->name, strerror(errno));
+	
+	memset(&ztp, 0, sizeof(ztp));
+	res = ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp);
+	if (!res) {
+		if (ztp.sigtype & __ZT_SIG_FXS) {
+			x = ZT_FLASH;
+			res = ioctl(chan->fds[0], ZT_HOOK, &x);
+			if (!res || (errno == EINPROGRESS)) {
+				if (res) {
+					/* Wait for the event to finish */
+					zt_wait_event(chan->fds[0]);
+				}
+				res = ast_safe_sleep(chan, 1000);
+				if (option_verbose > 2)
+					ast_verbose(VERBOSE_PREFIX_3 "Flashed channel %s\n", chan->name);
 			} else
-				ast_log(LOG_WARNING, "%s is not an FXO Channel\n", chan->name);
+				ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", chan->name, strerror(errno));
 		} else
-			ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));
+			ast_log(LOG_WARNING, "%s is not an FXO Channel\n", chan->name);
 	} else
-		ast_log(LOG_WARNING, "%s is not a Zap channel\n", chan->name);
+		ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));
+
 	ast_module_user_remove(u);
+
 	return res;
 }
 

Modified: trunk/apps/app_image.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_image.c?view=diff&rev=54534&r1=54533&r2=54534
==============================================================================
--- trunk/apps/app_image.c (original)
+++ trunk/apps/app_image.c Wed Feb 14 20:02:30 2007
@@ -96,9 +96,7 @@
 		return 0;
 	}
 
-	res = ast_send_image(chan, args.filename);
-	
-	if (!res)
+	if (!(res = ast_send_image(chan, args.filename)))
 		pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "OK");
 	
 	ast_module_user_remove(u);



More information about the asterisk-commits mailing list