[asterisk-commits] trunk r16558 - in /trunk: ./ apps/ channels/
include/asterisk/ pbx/ res/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Mar 30 14:29:47 MST 2006
Author: rizzo
Date: Thu Mar 30 15:29:39 2006
New Revision: 16558
URL: http://svn.digium.com/view/asterisk?rev=16558&view=rev
Log:
as discussed with Mark a few weeks ago, the 'newstack' argument
in pbx_exec is always 1 so it can be removed.
This change also takes away ast_exec_extension(), and lets all
switch functions (exists, canmatch, exec, matchmore) all use the same
prototype, which makes the code a bit cleaner.
Modified:
trunk/apps/app_dial.c
trunk/apps/app_exec.c
trunk/apps/app_meetme.c
trunk/apps/app_page.c
trunk/apps/app_voicemail.c
trunk/apps/app_while.c
trunk/channels/chan_iax2.c
trunk/include/asterisk/channel.h
trunk/include/asterisk/pbx.h
trunk/pbx.c
trunk/pbx/pbx_dundi.c
trunk/pbx/pbx_loopback.c
trunk/pbx/pbx_realtime.c
trunk/res/res_agi.c
trunk/res/res_features.c
Modified: trunk/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_dial.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Thu Mar 30 15:29:39 2006
@@ -1449,7 +1449,7 @@
if (*ch == '^')
*ch = '|';
}
- res = pbx_exec(peer, app, opt_args[OPT_ARG_CALLEE_MACRO], 1);
+ res = pbx_exec(peer, app, opt_args[OPT_ARG_CALLEE_MACRO]);
ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
res = 0;
} else {
Modified: trunk/apps/app_exec.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_exec.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/apps/app_exec.c (original)
+++ trunk/apps/app_exec.c Thu Mar 30 15:29:39 2006
@@ -82,7 +82,7 @@
if (appname) {
app = pbx_findapp(appname);
if (app) {
- res = pbx_exec(chan, app, args, 1);
+ res = pbx_exec(chan, app, args);
} else {
ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
res = -1;
Modified: trunk/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_meetme.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Thu Mar 30 15:29:39 2006
@@ -1143,7 +1143,7 @@
app = pbx_findapp("agi");
if (app) {
char *s = ast_strdupa(agifile);
- ret = pbx_exec(chan, app, s, 1);
+ ret = pbx_exec(chan, app, s);
} else {
ast_log(LOG_WARNING, "Could not find application (agi)\n");
ret = -2;
Modified: trunk/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_page.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/apps/app_page.c (original)
+++ trunk/apps/app_page.c Thu Mar 30 15:29:39 2006
@@ -186,7 +186,7 @@
}
if (!res) {
snprintf(meetmeopts, sizeof(meetmeopts), "%ud|A%sqxd", confid, ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "t");
- pbx_exec(chan, app, meetmeopts, 1);
+ pbx_exec(chan, app, meetmeopts);
}
LOCAL_USER_REMOVE(u);
Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Mar 30 15:29:39 2006
@@ -3422,7 +3422,7 @@
old_priority = chan->priority;
/* call the the Directory, changes the channel */
- res = pbx_exec(chan, app, context ? context : "default", 1);
+ res = pbx_exec(chan, app, context ? context : "default");
ast_copy_string(username, chan->exten, sizeof(username));
Modified: trunk/apps/app_while.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_while.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/apps/app_while.c (original)
+++ trunk/apps/app_while.c Thu Mar 30 15:29:39 2006
@@ -101,7 +101,7 @@
if (ast_true(expr)) {
if ((app = pbx_findapp(myapp))) {
- res = pbx_exec(chan, app, mydata, 1);
+ res = pbx_exec(chan, app, mydata);
} else {
ast_log(LOG_WARNING, "Count not find application! (%s)\n", myapp);
res = -1;
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Thu Mar 30 15:29:39 2006
@@ -9573,7 +9573,7 @@
}
/*! \brief Execute IAX2 dialplan switch */
-static int iax2_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, int newstack, const char *data)
+static int iax2_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
{
char odata[256];
char req[256];
@@ -9589,7 +9589,7 @@
if (dialstatus) {
dial = pbx_findapp(dialstatus);
if (dial)
- pbx_exec(chan, dial, "", newstack);
+ pbx_exec(chan, dial, "");
}
return -1;
} else if (priority != 1)
@@ -9618,7 +9618,7 @@
ast_mutex_unlock(&dpcache_lock);
dial = pbx_findapp("Dial");
if (dial) {
- return pbx_exec(chan, dial, req, newstack);
+ return pbx_exec(chan, dial, req);
} else {
ast_log(LOG_WARNING, "No dial application registered\n");
}
Modified: trunk/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/channel.h?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Thu Mar 30 15:29:39 2006
@@ -317,10 +317,8 @@
/*! Procedure causing blocking */
const char *blockproc;
- /*! Current application */
- char *appl;
- /*! Data passed to current application */
- char *data;
+ const char *appl; /*! Current application */
+ const char *data; /*! Data passed to current application */
/*! Which fd had an event detected on */
int fdno;
Modified: trunk/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/pbx.h?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/include/asterisk/pbx.h (original)
+++ trunk/include/asterisk/pbx.h Thu Mar 30 15:29:39 2006
@@ -82,22 +82,20 @@
struct ast_custom_function *next;
};
+/*! \brief All switch functions have the same interface, so define a type for them */
+typedef int (ast_switch_f)(struct ast_channel *chan, const char *context,
+ const char *exten, int priority, const char *callerid, const char *data);
+
/*! Data structure associated with an asterisk switch */
struct ast_switch {
- /*! NULL */
struct ast_switch *next;
- /*! Name of the switch */
- const char *name;
- /*! Description of the switch */
- const char *description;
+ const char *name; /*! Name of the switch */
+ const char *description; /*! Description of the switch */
- int (*exists)(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data);
-
- int (*canmatch)(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data);
-
- int (*exec)(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, int newstack, const char *data);
-
- int (*matchmore)(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data);
+ ast_switch_f *exists;
+ ast_switch_f *canmatch;
+ ast_switch_f *exec;
+ ast_switch_f *matchmore;
};
struct ast_timing {
@@ -160,7 +158,6 @@
* \param c channel to execute on
* \param app which app to execute
* \param data the data passed into the app
- * \param newstack stack pointer
*
* This application executes an application on a given channel. It
* saves the stack and executes the given appliation passing in
@@ -168,7 +165,7 @@
*
* \return 0 on success, and -1 on failure
*/
-int pbx_exec(struct ast_channel *c, struct ast_app *app, void *data, int newstack);
+int pbx_exec(struct ast_channel *c, struct ast_app *app, void *data);
/*!
* \brief Register a new context
@@ -484,22 +481,6 @@
* \retval -1 on failure.
*/
int ast_spawn_extension(struct ast_channel *c, const char *context,
- const char *exten, int priority, const char *callerid);
-
-/*!
- * \brief Execute an extension.
- *
- * \param c channel to execute upon
- * \param context which context extension is in
- * \param exten extension to execute
- * \param priority priority to execute within the given extension
- * \param callerid Caller-ID
- *
- * If it's not available, do whatever you should do for
- * default extensions and halt the thread if necessary. This function does not
- * return, except on error.
- */
-int ast_exec_extension(struct ast_channel *c, const char *context,
const char *exten, int priority, const char *callerid);
/*!
Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Thu Mar 30 15:29:39 2006
@@ -478,34 +478,29 @@
how many times it is called, it returns to the same place */
int pbx_exec(struct ast_channel *c, /*!< Channel */
struct ast_app *app, /*!< Application */
- void *data, /*!< Data for execution */
- int newstack) /*!< Force stack increment */
+ void *data) /*!< Data for execution */
{
int res;
- char *saved_c_appl;
- char *saved_c_data;
+ const char *saved_c_appl;
+ const char *saved_c_data;
int (*execute)(struct ast_channel *chan, void *data) = app->execute;
- if (newstack) {
- if (c->cdr)
- ast_cdr_setapp(c->cdr, app->name, data);
-
- /* save channel values */
- saved_c_appl= c->appl;
- saved_c_data= c->data;
-
- c->appl = app->name;
- c->data = data;
- res = execute(c, data);
- /* restore channel values */
- c->appl= saved_c_appl;
- c->data= saved_c_data;
- return res;
- } else
- ast_log(LOG_WARNING, "You really didn't want to call this function with newstack set to 0\n");
- return -1;
+ if (c->cdr)
+ ast_cdr_setapp(c->cdr, app->name, data);
+
+ /* save channel values */
+ saved_c_appl= c->appl;
+ saved_c_data= c->data;
+
+ c->appl = app->name;
+ c->data = data;
+ res = execute(c, data);
+ /* restore channel values */
+ c->appl= saved_c_appl;
+ c->data= saved_c_data;
+ return res;
}
@@ -514,7 +509,6 @@
#define HELPER_EXISTS 0
#define HELPER_SPAWN 1
-#define HELPER_EXEC 2
#define HELPER_CANMATCH 3
#define HELPER_MATCHMORE 4
#define HELPER_FINDLABEL 5
@@ -1500,7 +1494,6 @@
struct ast_switch *sw;
char *data;
const char *foundcontext=NULL;
- int newstack = 0;
int res;
int status = 0;
char *incstack[AST_PBX_MAX_STACK];
@@ -1536,9 +1529,6 @@
ast_mutex_unlock(&conlock);
return -1;
case HELPER_SPAWN:
- newstack++;
- /* Fall through */
- case HELPER_EXEC:
app = pbx_findapp(e->app);
ast_mutex_unlock(&conlock);
if (app) {
@@ -1551,7 +1541,7 @@
if (option_debug) {
ast_log(LOG_DEBUG, "Launching '%s'\n", app->name);
snprintf(atmp, 80, "STACK-%s-%s-%d", context, exten, priority);
- snprintf(atmp2, EXT_DATA_SIZE+100, "%s(\"%s\", \"%s\") %s", app->name, c->name, passdata, (newstack ? "in new stack" : "in same stack"));
+ snprintf(atmp2, EXT_DATA_SIZE+100, "%s(\"%s\", \"%s\") %s", app->name, c->name, passdata, "in new stack");
pbx_builtin_setvar_helper(c, atmp, atmp2);
}
if (option_verbose > 2)
@@ -1559,7 +1549,7 @@
term_color(tmp, app->name, COLOR_BRCYAN, 0, sizeof(tmp)),
term_color(tmp2, c->name, COLOR_BRMAGENTA, 0, sizeof(tmp2)),
term_color(tmp3, passdata, COLOR_BRMAGENTA, 0, sizeof(tmp3)),
- (newstack ? "in new stack" : "in same stack"));
+ "in new stack");
manager_event(EVENT_FLAG_CALL, "Newexten",
"Channel: %s\r\n"
"Context: %s\r\n"
@@ -1569,7 +1559,7 @@
"AppData: %s\r\n"
"Uniqueid: %s\r\n",
c->name, c->context, c->exten, c->priority, app->name, passdata, c->uniqueid);
- res = pbx_exec(c, app, passdata, newstack);
+ res = pbx_exec(c, app, passdata);
return res;
} else {
ast_log(LOG_WARNING, "No application '%s' for extension (%s, %s, %d)\n", e->app, context, exten, priority);
@@ -1594,12 +1584,9 @@
ast_mutex_unlock(&conlock);
return -1;
case HELPER_SPAWN:
- newstack++;
- /* Fall through */
- case HELPER_EXEC:
ast_mutex_unlock(&conlock);
if (sw->exec)
- res = sw->exec(c, foundcontext ? foundcontext : context, exten, priority, callerid, newstack, data);
+ res = sw->exec(c, foundcontext ? foundcontext : context, exten, priority, callerid, data);
else {
ast_log(LOG_WARNING, "No execution engine for switch %s\n", sw->name);
res = -1;
@@ -2073,11 +2060,6 @@
int ast_spawn_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
{
return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_SPAWN);
-}
-
-int ast_exec_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
-{
- return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_EXEC);
}
static int __ast_pbx_run(struct ast_channel *c)
@@ -4600,7 +4582,7 @@
if (app) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Launching %s(%s) on %s\n", as->app, as->appdata, chan->name);
- pbx_exec(chan, app, as->appdata, 1);
+ pbx_exec(chan, app, as->appdata);
} else
ast_log(LOG_WARNING, "No such application '%s'\n", as->app);
} else {
@@ -4814,7 +4796,7 @@
if (app) {
if (option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_4 "Launching %s(%s) on %s\n", tmp->app, tmp->data, tmp->chan->name);
- pbx_exec(tmp->chan, app, tmp->data, 1);
+ pbx_exec(tmp->chan, app, tmp->data);
} else
ast_log(LOG_WARNING, "No such application '%s'\n", tmp->app);
ast_hangup(tmp->chan);
@@ -5247,7 +5229,7 @@
}
if ((app = pbx_findapp(ptr2))) {
- res = pbx_exec(chan, app, ptr1 ? ptr1 : "", 1);
+ res = pbx_exec(chan, app, ptr1 ? ptr1 : "");
} else {
ast_log(LOG_WARNING, "Cannot locate application %s\n", ptr2);
res = -1;
Modified: trunk/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_dundi.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Thu Mar 30 15:29:39 2006
@@ -4382,7 +4382,7 @@
return dundi_helper(chan, context, exten, priority, data, DUNDI_FLAG_CANMATCH);
}
-static int dundi_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, int newstack, const char *data)
+static int dundi_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
{
struct dundi_result results[MAX_RESULTS];
int res;
@@ -4428,7 +4428,7 @@
snprintf(req, sizeof(req), "%s/%s", results[x].tech, results[x].dest);
dial = pbx_findapp("Dial");
if (dial)
- res = pbx_exec(chan, dial, req, newstack);
+ res = pbx_exec(chan, dial, req);
} else
res = -1;
return res;
Modified: trunk/pbx/pbx_loopback.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_loopback.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/pbx/pbx_loopback.c (original)
+++ trunk/pbx/pbx_loopback.c Thu Mar 30 15:29:39 2006
@@ -147,13 +147,11 @@
return res;
}
-static int loopback_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, int newstack, const char *data)
-{
- LOOPBACK_COMMON;
- if (newstack)
- res = ast_spawn_extension(chan, newcontext, newexten, newpriority, callerid);
- else
- res = ast_exec_extension(chan, newcontext, newexten, newpriority, callerid);
+static int loopback_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
+{
+ LOOPBACK_COMMON;
+ res = ast_spawn_extension(chan, newcontext, newexten, newpriority, callerid);
+ /* XXX hmmm... res is overridden ? */
if (newpattern && !ast_extension_match(newpattern, exten))
res = -1;
return res;
Modified: trunk/pbx/pbx_realtime.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_realtime.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/pbx/pbx_realtime.c (original)
+++ trunk/pbx/pbx_realtime.c Thu Mar 30 15:29:39 2006
@@ -177,14 +177,14 @@
return res > 0 ? res : 0;
}
-static int realtime_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, int newstack, const char *data)
+static int realtime_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
{
char app[256];
char appdata[512]="";
char *tmp="";
- char tmp1[80];
- char tmp2[80];
- char tmp3[EXT_DATA_SIZE];
+ char tmp1[80];
+ char tmp2[80];
+ char tmp3[EXT_DATA_SIZE];
struct ast_app *a;
struct ast_variable *v;
REALTIME_COMMON(MODE_MATCH);
@@ -218,7 +218,7 @@
"Uniqueid: %s\r\n",
chan->name, chan->context, chan->exten, chan->priority, app, appdata ? appdata : "(NULL)", chan->uniqueid);
- res = pbx_exec(chan, a, appdata, newstack);
+ res = pbx_exec(chan, a, appdata);
} else
ast_log(LOG_NOTICE, "No such application '%s' for extension '%s' in context '%s'\n", app, exten, context);
}
Modified: trunk/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_agi.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/res/res_agi.c (original)
+++ trunk/res/res_agi.c Thu Mar 30 15:29:39 2006
@@ -1090,7 +1090,7 @@
app = pbx_findapp(argv[1]);
if (app) {
- res = pbx_exec(chan, app, argv[2], 1);
+ res = pbx_exec(chan, app, argv[2]);
} else {
ast_log(LOG_WARNING, "Could not find application (%s)\n", argv[1]);
res = -2;
Modified: trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_features.c?rev=16558&r1=16557&r2=16558&view=diff
==============================================================================
--- trunk/res/res_features.c (original)
+++ trunk/res/res_features.c Thu Mar 30 15:29:39 2006
@@ -502,7 +502,7 @@
if (option_verbose > 3)
ast_verbose(VERBOSE_PREFIX_3 "User hit '%s' to record call. filename: %s\n", code, args);
- pbx_exec(callee_chan, monitor_app, args, 1);
+ pbx_exec(callee_chan, monitor_app, args);
pbx_builtin_setvar_helper(callee_chan, "TOUCH_MONITOR_OUTPUT", touch_filename);
pbx_builtin_setvar_helper(caller_chan, "TOUCH_MONITOR_OUTPUT", touch_filename);
@@ -924,7 +924,7 @@
struct ast_channel *work = chan;
if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLEE))
work = peer;
- res = pbx_exec(work, app, feature->app_args, 1);
+ res = pbx_exec(work, app, feature->app_args);
if (res < 0)
return res;
} else {
@@ -1267,7 +1267,7 @@
if (monitor_app && src) {
char *tmp = ast_strdupa(monitor_exec);
if (tmp) {
- pbx_exec(src, monitor_app, tmp, 1);
+ pbx_exec(src, monitor_app, tmp);
} else {
ast_log(LOG_ERROR, "Monitor failed: out of memory\n");
}
More information about the asterisk-commits
mailing list