Index: pbx/pbx_ael.c =================================================================== --- pbx/pbx_ael.c (revision 309169) +++ pbx/pbx_ael.c (working copy) @@ -55,6 +55,26 @@ #include "asterisk/argdesc.h" #endif +/*** DOCUMENTATION + + + Launch subroutine built with AEL + + + + Named subroutine to execute. + + + + + Execute the named subroutine, defined in AEL, from another dialplan + language, such as extensions.conf, Realtime extensions, or Lua. + 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. + + + ***/ + /* these functions are in ../ast_expr2.fl */ #define DEBUG_READ (1 << 0) @@ -108,6 +128,27 @@ /* interface stuff */ +#ifndef STANDALONE +static char *aelsub = "AELSub"; + +static int aelsub_exec(struct ast_channel *chan, void *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 @@ { 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()); }