aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_flash.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-15 02:02:30 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-15 02:02:30 +0000
commit9e8f015acd3a731f1c2e872b73ed2734b14df3a0 (patch)
treede0aeae5a6c3ff32aa37f0a0361c6a9b91499ccd /apps/app_flash.c
parent3cc71d5fb098bfd49a432b62117487e1ddeb4086 (diff)
Few more code clean ups.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@54534 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_flash.c')
-rw-r--r--apps/app_flash.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/apps/app_flash.c b/apps/app_flash.c
index dea8f329b..5f90093bb 100644
--- a/apps/app_flash.c
+++ b/apps/app_flash.c
@@ -75,31 +75,37 @@ static int flash_exec(struct ast_channel *chan, void *data)
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;
}