aboutsummaryrefslogtreecommitdiffstats
path: root/pbx/pbx_ael.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2011-03-12 20:42:33 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2011-03-12 20:42:33 +0000
commitb760c34658c0cfee7a665647b8f9eae7fc9f4b9a (patch)
tree14339c658295b01aaca0832affafcba50ba9ba23 /pbx/pbx_ael.c
parent1a9e533f307388196173fd0b97654c2d8d442852 (diff)
Merged revisions 310462 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ................ r310462 | tilghman | 2011-03-12 14:27:54 -0600 (Sat, 12 Mar 2011) | 45 lines Merged revisions 310448 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ................ r310448 | tilghman | 2011-03-12 14:24:54 -0600 (Sat, 12 Mar 2011) | 38 lines Recorded merge of revisions 310435 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r310435 | tilghman | 2011-03-12 14:22:07 -0600 (Sat, 12 Mar 2011) | 31 lines Add AELSub, which provides a stable entry point into AEL subroutines. This commit needs some explanation, given that we're adding a new application into an existing release branch. This is generally a violation of our release policy, except in very limited circumstances, and I believe this is one of those circumstances. The problem that this solves is one of the sanity of using multiple dialplan languages to define a dialplan. In the case of the reporter, he or she is using AEL is define subroutines, while using Realtime extensions to invoke those subroutines. While you can do this, it's based upon the reality of AEL using actual dialplan extensions; however, there is no guarantee that the details of _how_ AEL is compiled into extensions will remain stable. In fact, at the time of this commit, it has already changed twice, once in a fundamental way. Now normally, a new application would only be added to trunk. However, this application is explicitly to create a stable user-level API between versions, and adding it to trunk only will not solve the user's problem of switching between 1.6.2 and 1.8, nor will it help anybody switching from 1.8 to 1.10. Therefore, it needs to go into existing release branches. For the sake of consistency, and also because one of the changes was between 1.4 and 1.6.x, I am also electing to commit this to 1.4. (closes issue #18910) Reported by: alexandrekeller Patches: 20110304__issue18919__1.6.2.diff.txt uploaded by tilghman (license 14) 20110304__issue18919__1.4.diff.txt uploaded by tilghman (license 14) Tested by: alexandrekeller ........ ................ ................ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@310500 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx/pbx_ael.c')
-rw-r--r--pbx/pbx_ael.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c
index 7c9d6c120..96c65ff6d 100644
--- a/pbx/pbx_ael.c
+++ b/pbx/pbx_ael.c
@@ -55,6 +55,26 @@ static int mtx_prof = -1; /* helps the standalone compile with the mtx_prof flag
#include "asterisk/argdesc.h"
#endif
+/*** DOCUMENTATION
+ <application name="AELSub" language="en_US">
+ <synopsis>
+ Launch subroutine built with AEL
+ </synopsis>
+ <syntax>
+ <parameter name="routine" required="true">
+ <para>Named subroutine to execute.</para>
+ </parameter>
+ <parameter name="args" required="false" />
+ </syntax>
+ <description>
+ <para>Execute the named subroutine, defined in AEL, from another dialplan
+ language, such as extensions.conf, Realtime extensions, or Lua.</para>
+ <para>The purpose of this application is to provide a sane entry point into
+ AEL subroutines, the implementation of which may change from time to time.</para>
+ </description>
+ </application>
+ ***/
+
/* these functions are in ../ast_expr2.fl */
#define DEBUG_READ (1 << 0)
@@ -108,6 +128,27 @@ static int aeldebug = 0;
/* interface stuff */
+#ifndef STANDALONE
+static char *aelsub = "AELSub";
+
+static int aelsub_exec(struct ast_channel *chan, const char *vdata)
+{
+ char buf[256], *data = ast_strdupa(vdata);
+ struct ast_app *gosub = pbx_findapp("Gosub");
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(name);
+ AST_APP_ARG(args);
+ );
+
+ if (gosub) {
+ AST_STANDARD_RAW_ARGS(args, data);
+ snprintf(buf, sizeof(buf), "%s,~~s~~,1(%s)", args.name, args.args);
+ return pbx_exec(chan, gosub, buf);
+ }
+ return -1;
+}
+#endif
+
/* if all the below are static, who cares if they are present? */
static int pbx_load_module(void)
@@ -224,12 +265,18 @@ static int unload_module(void)
{
ast_context_destroy(NULL, registrar);
ast_cli_unregister_multiple(cli_ael, ARRAY_LEN(cli_ael));
+#ifndef STANDALONE
+ ast_unregister_application(aelsub);
+#endif
return 0;
}
static int load_module(void)
{
ast_cli_register_multiple(cli_ael, ARRAY_LEN(cli_ael));
+#ifndef STANDALONE
+ ast_register_application_xml(aelsub, aelsub_exec);
+#endif
return (pbx_load_module());
}