From: Tilghman Lesher Date: Sat, 12 Mar 2011 20:22:07 +0000 (+0000) Subject: Add AELSub, which provides a stable entry point into AEL subroutines. X-Git-Tag: 1.4.42-rc1~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75dc421e15ef7c4a754539e2b66e2fe8835be87e;p=thirdparty%2Fasterisk.git 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: https://origsvn.digium.com/svn/asterisk/branches/1.4@310435 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/pbx/pbx_ael.c b/pbx/pbx_ael.c index 1191992e03..774bf9bd8e 100644 --- a/pbx/pbx_ael.c +++ b/pbx/pbx_ael.c @@ -4502,6 +4502,30 @@ int ast_compile_ael2(struct ast_context **local_contexts, struct pval *root) static int aeldebug = 0; +#ifndef STANDALONE_AEL +static char *aelsub = "AELSub"; +static char *aelsub_synopsis = "Launch subroutine built with AEL"; +static char *aelsub_descrip = +"AELSub([|])\n" +"Execute the named subroutine, defined in AEL, from another dialplan language,\n" +"such as extensions.conf or Realtime extensions.\n\n" +"The purpose of this application is to provide a sane entry point into AEL\n" +"subroutines, the implementation of which may change from time to time.\n"; + +static int aelsub_exec(struct ast_channel *chan, void *vdata) +{ + char *data = ast_strdupa(vdata); + struct ast_app *macro = pbx_findapp("Macro"); + if (macro) { + if (strncmp(data, "macro-", 6) == 0) { + data += 6; + } + return pbx_exec(chan, macro, data); + } + return -1; +} +#endif + /* interface stuff */ /* if all the below are static, who cares if they are present? */ @@ -4620,12 +4644,18 @@ static int unload_module(void) { ast_context_destroy(NULL, registrar); ast_cli_unregister_multiple(cli_ael, sizeof(cli_ael) / sizeof(struct ast_cli_entry)); +#ifndef STANDALONE_AEL + ast_unregister_application(aelsub); +#endif return 0; } static int load_module(void) { ast_cli_register_multiple(cli_ael, sizeof(cli_ael) / sizeof(struct ast_cli_entry)); +#ifndef STANDALONE_AEL + ast_register_application(aelsub, aelsub_exec, aelsub_synopsis, aelsub_descrip); +#endif return (pbx_load_module()); }