summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-03-16 20:37:54 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-03-16 20:37:54 +0000
commitdd4a3b182565a709bbf77fee337622edcd88ff55 (patch)
tree48f4c3eead053d4df3ce96bf0ed87934574061fa
parent827f2eae920e403dff3cc240b7b74e65b7afc7c1 (diff)
Simplify some code in ast_app_run_sub().
* Remove unnnecessary const from const char * const var declaration in the ast_app_run_macro() and ast_app_run_sub() prototypes. The second const is unnecessary. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@359904 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--include/asterisk/app.h8
-rw-r--r--main/app.c14
2 files changed, 12 insertions, 10 deletions
diff --git a/include/asterisk/app.h b/include/asterisk/app.h
index 5f79b3570..a9b0d3441 100644
--- a/include/asterisk/app.h
+++ b/include/asterisk/app.h
@@ -131,8 +131,8 @@ int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int
* \retval 0 success
* \retval -1 failure
*/
-int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel
- *macro_chan, const char * const macro_name, const char * const macro_args);
+int ast_app_run_macro(struct ast_channel *autoservice_chan,
+ struct ast_channel *macro_chan, const char *macro_name, const char *macro_args);
/*!
* \since 11
@@ -151,8 +151,8 @@ int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel
* \retval 0 success
* \retval -1 failure
*/
-int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel
- *sub_chan, const char * const name, const char * const args);
+int ast_app_run_sub(struct ast_channel *autoservice_chan,
+ struct ast_channel *sub_chan, const char *name, const char *args);
/*!
* \brief Set voicemail function callbacks
diff --git a/main/app.c b/main/app.c
index 3cdb18432..1354d44e0 100644
--- a/main/app.c
+++ b/main/app.c
@@ -281,22 +281,24 @@ static int app_exec_dialplan(struct ast_channel *autoservice_chan, struct ast_ch
return res;
}
-int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char * const name, const char * const args)
+int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *name, const char *args)
{
char buf[1024];
snprintf(buf, sizeof(buf), "%s%s%s", name, ast_strlen_zero(args) ? "" : ",", S_OR(args, ""));
return app_exec_dialplan(autoservice_chan, macro_chan, buf, 0);
}
-int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char * const location, const char * const args)
+int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *location, const char *args)
{
char buf[1024];
size_t offset = snprintf(buf, sizeof(buf), "%s", location);
+
/* need to bump the priority by one if we already have a pbx */
if (ast_channel_pbx(sub_chan)) {
int iprio;
- const char * priority = location;
- const char * next = strchr(priority,',');
+ const char *priority = location;
+ const char *next = strchr(priority,',');
+
/* jump to the priority portion of the location */
if (next) {
priority = next + 1;
@@ -314,8 +316,8 @@ int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *su
}
}
}
- if (offset < sizeof(buf)) {
- snprintf(buf + offset, sizeof(buf) - offset, "%s%s%s", ast_strlen_zero(args) ? "" : "(", S_OR(args, ""), ast_strlen_zero(args) ? "" : ")");
+ if (!ast_strlen_zero(args) && offset < sizeof(buf)) {
+ snprintf(buf + offset, sizeof(buf) - offset, "(%s)", args);
}
return app_exec_dialplan(autoservice_chan, sub_chan, buf, 1);
}