dect
/
asterisk
Archived
13
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
asterisk/pbx/pbx_ael.c

378 lines
9.7 KiB
C
Raw Normal View History

/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2006, Digium, Inc.
*
* Steve Murphy <murf@parsetree.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*! \file
*
* \brief Compile symbolic Asterisk Extension Logic into Asterisk extensions, version 2.
*
*/
/*** MODULEINFO
<depend>res_ael_share</depend>
<support_level>extended</support_level>
***/
#include "asterisk.h"
#if !defined(STANDALONE)
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#endif
#include <ctype.h>
#include <regex.h>
#include <sys/stat.h>
#ifdef STANDALONE
#ifdef HAVE_MTX_PROFILE
static int mtx_prof = -1; /* helps the standalone compile with the mtx_prof flag on */
#endif
#endif
#include "asterisk/pbx.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/cli.h"
#include "asterisk/app.h"
#include "asterisk/callerid.h"
(closes issue #6002) Reported by: rizzo Tested by: murf Proposal of the changes to be made, and then an announcement of how they were accomplished: http://lists.digium.com/pipermail/asterisk-dev/2008-February/032065.html and: http://lists.digium.com/pipermail/asterisk-dev/2008-March/032124.html Here is a recap, file by file, of what I have done: pbx/pbx_config.c pbx/pbx_ael.c All funcs that were passed a ptr to the context list, now will ALSO be passed a hashtab ptr to the same set. Why? because (for the time being), the dialplan is stored in both, to facilitate a quick, low-cost move to hash-tables to speed up dialplan processing. If it was deemed necessary to pass the context LIST, well, it is just as necessary to have the TABLE available. This is because the list/table in question might not be the global one, but temporary ones we would use to stage the dialplan on, and then swap into the global position when things are ready. We now have one external function for apps to use, "ast_context_find_or_create()" instead of the pre-existing "find" and "create", as all existing usages used both in tandem anyway. pbx_config, and pbx_ael, will stage the reloaded dialplan into local lists and tables, and then call merge_contexts_and_delete, which will merge (now) existing contexts and priorities from other registrars into this local set by copying them. Then, merge_contexts_and_delete will lock down the contexts, swap the lists and tables, and unlock (real quick), and then destroy the old dialplan. chan_sip.c chan_iax.c chan_skinny.c All the channel drivers that would add regcontexts now use the ast_context_find_or_create now. chan_sip also includes a small fix to get rid of warnings about removing priorities that never got entered. apps/app_meetme.c apps/app_dial.c apps/app_queue.c All the apps that added a context/exten/priority were also modified to use ast_context_find_or_create instead. include/asterisk/pbx.h ast_context_create() is removed. Find_or_create_ is the new method. ast_context_find_or_create() interface gets the hashtab added. ast_merge_contexts_and_delete() gets the local hashtab arg added. ast_wrlock_contexts_version() is added so you can detect if someone else got a writelock between your readlocking and writelocking. ast_hashtab_compare_contexts was made public for use in pbx_config/pbx_ael ast_hashtab_hash_contexts was in like fashion make public. include/asterisk/pval.h ast_compile_ael2() interface changed to include the local hashtab table ptr. main/features.c For the sake of the parking context, we use ast_context_find_or_create(). main/pbx.c I changed all the "tree" names to "table" instead. That's because the original implementation was based on binary trees. (had a free library). Then I moved to hashtabs. Now, the names move forward too. refcount field added to contexts, so you can keep track of how many modules wanted this context to exist. Some log messages that are warnings were inflated from LOG_NOTICE to LOG_WARNING. Added some calls to ast_verb(3,...) for debug messages Lots of little mods to ast_context_remove_extension2, which is now excersized in ways it was not previously; one definite bug fixed. find_or_create was upgraded to handle both local lists/tables as well as the globals. context_merge() was added to do the per-context merging of the old/present contexts/extens/prios into the new/proposed local list/tables ast_merge_contexts_and_delete() was heavily modified. ast_add_extension2() was also upgraded to handle changes. the context_destroy() code was re-engineered to handle the new way of doing things, by exten/prio instead of by context. res/ael/pval.c res/ael/ael.tab.c res/ael/ael.tab.h res/ael/ael.y res/ael/ael_lex.c res/ael/ael.flex utils/ael_main.c utils/extconf.c utils/conf2ael.c utils/Makefile Had to change the interface to ast_compile_ael2(), to include the hashtab ptr. This ended up involving several external apps. The main gotcha was I had to include lock.h and hashtab.h in several places. As a side note, I tested this stuff pretty thoroughly, I replicated the problems originally reported by Luigi, and made triply sure that reloads worked, and everything worked thru "stop gracefully". I found a and fixed a few bugs as I was merging into trunk, that did not appear in my tests of bug6002. How's this for verbose commit messages? git-svn-id: http://svn.digium.com/svn/asterisk/trunk@106757 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-07 18:57:57 +00:00
#include "asterisk/hashtab.h"
#include "asterisk/ael_structs.h"
#include "asterisk/pval.h"
#ifdef AAL_ARGCHECK
#include "asterisk/argdesc.h"
#endif
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
2011-03-12 20:42:33 +00:00
/*** 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)
#define DEBUG_TOKENS (1 << 1)
#define DEBUG_MACROS (1 << 2)
#define DEBUG_CONTEXTS (1 << 3)
static char *config = "extensions.ael";
static char *registrar = "pbx_ael";
static int pbx_load_module(void);
#ifndef AAL_ARGCHECK
/* for the time being, short circuit all the AAL related structures
without permanently removing the code; after/during the AAL
development, this code can be properly re-instated
*/
#endif
#ifdef AAL_ARGCHECK
int option_matches_j( struct argdesc *should, pval *is, struct argapp *app);
int option_matches( struct argdesc *should, pval *is, struct argapp *app);
int ael_is_funcname(char *name);
#endif
int check_app_args(pval *appcall, pval *arglist, struct argapp *app);
void check_pval(pval *item, struct argapp *apps, int in_globals);
void check_pval_item(pval *item, struct argapp *apps, int in_globals);
void check_switch_expr(pval *item, struct argapp *apps);
void ast_expr_register_extra_error_info(char *errmsg);
void ast_expr_clear_extra_error_info(void);
struct pval *find_macro(char *name);
struct pval *find_context(char *name);
struct pval *find_context(char *name);
struct pval *find_macro(char *name);
struct ael_priority *new_prio(void);
struct ael_extension *new_exten(void);
void destroy_extensions(struct ael_extension *exten);
void set_priorities(struct ael_extension *exten);
void add_extensions(struct ael_extension *exten);
int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *local_table, struct pval *root);
void destroy_pval(pval *item);
void destroy_pval_item(pval *item);
int is_float(char *arg );
int is_int(char *arg );
int is_empty(char *arg);
/* static void substitute_commas(char *str); */
static int aeldebug = 0;
/* interface stuff */
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
2011-03-12 20:42:33 +00:00
#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)
{
int errs=0, sem_err=0, sem_warn=0, sem_note=0;
char *rfilename;
struct ast_context *local_contexts=NULL, *con;
(closes issue #6002) Reported by: rizzo Tested by: murf Proposal of the changes to be made, and then an announcement of how they were accomplished: http://lists.digium.com/pipermail/asterisk-dev/2008-February/032065.html and: http://lists.digium.com/pipermail/asterisk-dev/2008-March/032124.html Here is a recap, file by file, of what I have done: pbx/pbx_config.c pbx/pbx_ael.c All funcs that were passed a ptr to the context list, now will ALSO be passed a hashtab ptr to the same set. Why? because (for the time being), the dialplan is stored in both, to facilitate a quick, low-cost move to hash-tables to speed up dialplan processing. If it was deemed necessary to pass the context LIST, well, it is just as necessary to have the TABLE available. This is because the list/table in question might not be the global one, but temporary ones we would use to stage the dialplan on, and then swap into the global position when things are ready. We now have one external function for apps to use, "ast_context_find_or_create()" instead of the pre-existing "find" and "create", as all existing usages used both in tandem anyway. pbx_config, and pbx_ael, will stage the reloaded dialplan into local lists and tables, and then call merge_contexts_and_delete, which will merge (now) existing contexts and priorities from other registrars into this local set by copying them. Then, merge_contexts_and_delete will lock down the contexts, swap the lists and tables, and unlock (real quick), and then destroy the old dialplan. chan_sip.c chan_iax.c chan_skinny.c All the channel drivers that would add regcontexts now use the ast_context_find_or_create now. chan_sip also includes a small fix to get rid of warnings about removing priorities that never got entered. apps/app_meetme.c apps/app_dial.c apps/app_queue.c All the apps that added a context/exten/priority were also modified to use ast_context_find_or_create instead. include/asterisk/pbx.h ast_context_create() is removed. Find_or_create_ is the new method. ast_context_find_or_create() interface gets the hashtab added. ast_merge_contexts_and_delete() gets the local hashtab arg added. ast_wrlock_contexts_version() is added so you can detect if someone else got a writelock between your readlocking and writelocking. ast_hashtab_compare_contexts was made public for use in pbx_config/pbx_ael ast_hashtab_hash_contexts was in like fashion make public. include/asterisk/pval.h ast_compile_ael2() interface changed to include the local hashtab table ptr. main/features.c For the sake of the parking context, we use ast_context_find_or_create(). main/pbx.c I changed all the "tree" names to "table" instead. That's because the original implementation was based on binary trees. (had a free library). Then I moved to hashtabs. Now, the names move forward too. refcount field added to contexts, so you can keep track of how many modules wanted this context to exist. Some log messages that are warnings were inflated from LOG_NOTICE to LOG_WARNING. Added some calls to ast_verb(3,...) for debug messages Lots of little mods to ast_context_remove_extension2, which is now excersized in ways it was not previously; one definite bug fixed. find_or_create was upgraded to handle both local lists/tables as well as the globals. context_merge() was added to do the per-context merging of the old/present contexts/extens/prios into the new/proposed local list/tables ast_merge_contexts_and_delete() was heavily modified. ast_add_extension2() was also upgraded to handle changes. the context_destroy() code was re-engineered to handle the new way of doing things, by exten/prio instead of by context. res/ael/pval.c res/ael/ael.tab.c res/ael/ael.tab.h res/ael/ael.y res/ael/ael_lex.c res/ael/ael.flex utils/ael_main.c utils/extconf.c utils/conf2ael.c utils/Makefile Had to change the interface to ast_compile_ael2(), to include the hashtab ptr. This ended up involving several external apps. The main gotcha was I had to include lock.h and hashtab.h in several places. As a side note, I tested this stuff pretty thoroughly, I replicated the problems originally reported by Luigi, and made triply sure that reloads worked, and everything worked thru "stop gracefully". I found a and fixed a few bugs as I was merging into trunk, that did not appear in my tests of bug6002. How's this for verbose commit messages? git-svn-id: http://svn.digium.com/svn/asterisk/trunk@106757 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-07 18:57:57 +00:00
struct ast_hashtab *local_table=NULL;
struct pval *parse_tree;
ast_log(LOG_NOTICE, "Starting AEL load process.\n");
if (config[0] == '/')
rfilename = (char *)config;
else {
rfilename = alloca(strlen(config) + strlen(ast_config_AST_CONFIG_DIR) + 2);
sprintf(rfilename, "%s/%s", ast_config_AST_CONFIG_DIR, config);
}
if (access(rfilename,R_OK) != 0) {
ast_log(LOG_NOTICE, "File %s not found; AEL declining load\n", rfilename);
return AST_MODULE_LOAD_DECLINE;
}
parse_tree = ael2_parse(rfilename, &errs);
ast_log(LOG_NOTICE, "AEL load process: parsed config file name '%s'.\n", rfilename);
ael2_semantic_check(parse_tree, &sem_err, &sem_warn, &sem_note);
if (errs == 0 && sem_err == 0) {
ast_log(LOG_NOTICE, "AEL load process: checked config file name '%s'.\n", rfilename);
(closes issue #6002) Reported by: rizzo Tested by: murf Proposal of the changes to be made, and then an announcement of how they were accomplished: http://lists.digium.com/pipermail/asterisk-dev/2008-February/032065.html and: http://lists.digium.com/pipermail/asterisk-dev/2008-March/032124.html Here is a recap, file by file, of what I have done: pbx/pbx_config.c pbx/pbx_ael.c All funcs that were passed a ptr to the context list, now will ALSO be passed a hashtab ptr to the same set. Why? because (for the time being), the dialplan is stored in both, to facilitate a quick, low-cost move to hash-tables to speed up dialplan processing. If it was deemed necessary to pass the context LIST, well, it is just as necessary to have the TABLE available. This is because the list/table in question might not be the global one, but temporary ones we would use to stage the dialplan on, and then swap into the global position when things are ready. We now have one external function for apps to use, "ast_context_find_or_create()" instead of the pre-existing "find" and "create", as all existing usages used both in tandem anyway. pbx_config, and pbx_ael, will stage the reloaded dialplan into local lists and tables, and then call merge_contexts_and_delete, which will merge (now) existing contexts and priorities from other registrars into this local set by copying them. Then, merge_contexts_and_delete will lock down the contexts, swap the lists and tables, and unlock (real quick), and then destroy the old dialplan. chan_sip.c chan_iax.c chan_skinny.c All the channel drivers that would add regcontexts now use the ast_context_find_or_create now. chan_sip also includes a small fix to get rid of warnings about removing priorities that never got entered. apps/app_meetme.c apps/app_dial.c apps/app_queue.c All the apps that added a context/exten/priority were also modified to use ast_context_find_or_create instead. include/asterisk/pbx.h ast_context_create() is removed. Find_or_create_ is the new method. ast_context_find_or_create() interface gets the hashtab added. ast_merge_contexts_and_delete() gets the local hashtab arg added. ast_wrlock_contexts_version() is added so you can detect if someone else got a writelock between your readlocking and writelocking. ast_hashtab_compare_contexts was made public for use in pbx_config/pbx_ael ast_hashtab_hash_contexts was in like fashion make public. include/asterisk/pval.h ast_compile_ael2() interface changed to include the local hashtab table ptr. main/features.c For the sake of the parking context, we use ast_context_find_or_create(). main/pbx.c I changed all the "tree" names to "table" instead. That's because the original implementation was based on binary trees. (had a free library). Then I moved to hashtabs. Now, the names move forward too. refcount field added to contexts, so you can keep track of how many modules wanted this context to exist. Some log messages that are warnings were inflated from LOG_NOTICE to LOG_WARNING. Added some calls to ast_verb(3,...) for debug messages Lots of little mods to ast_context_remove_extension2, which is now excersized in ways it was not previously; one definite bug fixed. find_or_create was upgraded to handle both local lists/tables as well as the globals. context_merge() was added to do the per-context merging of the old/present contexts/extens/prios into the new/proposed local list/tables ast_merge_contexts_and_delete() was heavily modified. ast_add_extension2() was also upgraded to handle changes. the context_destroy() code was re-engineered to handle the new way of doing things, by exten/prio instead of by context. res/ael/pval.c res/ael/ael.tab.c res/ael/ael.tab.h res/ael/ael.y res/ael/ael_lex.c res/ael/ael.flex utils/ael_main.c utils/extconf.c utils/conf2ael.c utils/Makefile Had to change the interface to ast_compile_ael2(), to include the hashtab ptr. This ended up involving several external apps. The main gotcha was I had to include lock.h and hashtab.h in several places. As a side note, I tested this stuff pretty thoroughly, I replicated the problems originally reported by Luigi, and made triply sure that reloads worked, and everything worked thru "stop gracefully". I found a and fixed a few bugs as I was merging into trunk, that did not appear in my tests of bug6002. How's this for verbose commit messages? git-svn-id: http://svn.digium.com/svn/asterisk/trunk@106757 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-07 18:57:57 +00:00
local_table = ast_hashtab_create(11, ast_hashtab_compare_contexts, ast_hashtab_resize_java, ast_hashtab_newsize_java, ast_hashtab_hash_contexts, 0);
if (ast_compile_ael2(&local_contexts, local_table, parse_tree)) {
ast_log(LOG_ERROR, "AEL compile failed! Aborting.\n");
destroy_pval(parse_tree); /* free up the memory */
return AST_MODULE_LOAD_DECLINE;
}
ast_log(LOG_NOTICE, "AEL load process: compiled config file name '%s'.\n", rfilename);
(closes issue #6002) Reported by: rizzo Tested by: murf Proposal of the changes to be made, and then an announcement of how they were accomplished: http://lists.digium.com/pipermail/asterisk-dev/2008-February/032065.html and: http://lists.digium.com/pipermail/asterisk-dev/2008-March/032124.html Here is a recap, file by file, of what I have done: pbx/pbx_config.c pbx/pbx_ael.c All funcs that were passed a ptr to the context list, now will ALSO be passed a hashtab ptr to the same set. Why? because (for the time being), the dialplan is stored in both, to facilitate a quick, low-cost move to hash-tables to speed up dialplan processing. If it was deemed necessary to pass the context LIST, well, it is just as necessary to have the TABLE available. This is because the list/table in question might not be the global one, but temporary ones we would use to stage the dialplan on, and then swap into the global position when things are ready. We now have one external function for apps to use, "ast_context_find_or_create()" instead of the pre-existing "find" and "create", as all existing usages used both in tandem anyway. pbx_config, and pbx_ael, will stage the reloaded dialplan into local lists and tables, and then call merge_contexts_and_delete, which will merge (now) existing contexts and priorities from other registrars into this local set by copying them. Then, merge_contexts_and_delete will lock down the contexts, swap the lists and tables, and unlock (real quick), and then destroy the old dialplan. chan_sip.c chan_iax.c chan_skinny.c All the channel drivers that would add regcontexts now use the ast_context_find_or_create now. chan_sip also includes a small fix to get rid of warnings about removing priorities that never got entered. apps/app_meetme.c apps/app_dial.c apps/app_queue.c All the apps that added a context/exten/priority were also modified to use ast_context_find_or_create instead. include/asterisk/pbx.h ast_context_create() is removed. Find_or_create_ is the new method. ast_context_find_or_create() interface gets the hashtab added. ast_merge_contexts_and_delete() gets the local hashtab arg added. ast_wrlock_contexts_version() is added so you can detect if someone else got a writelock between your readlocking and writelocking. ast_hashtab_compare_contexts was made public for use in pbx_config/pbx_ael ast_hashtab_hash_contexts was in like fashion make public. include/asterisk/pval.h ast_compile_ael2() interface changed to include the local hashtab table ptr. main/features.c For the sake of the parking context, we use ast_context_find_or_create(). main/pbx.c I changed all the "tree" names to "table" instead. That's because the original implementation was based on binary trees. (had a free library). Then I moved to hashtabs. Now, the names move forward too. refcount field added to contexts, so you can keep track of how many modules wanted this context to exist. Some log messages that are warnings were inflated from LOG_NOTICE to LOG_WARNING. Added some calls to ast_verb(3,...) for debug messages Lots of little mods to ast_context_remove_extension2, which is now excersized in ways it was not previously; one definite bug fixed. find_or_create was upgraded to handle both local lists/tables as well as the globals. context_merge() was added to do the per-context merging of the old/present contexts/extens/prios into the new/proposed local list/tables ast_merge_contexts_and_delete() was heavily modified. ast_add_extension2() was also upgraded to handle changes. the context_destroy() code was re-engineered to handle the new way of doing things, by exten/prio instead of by context. res/ael/pval.c res/ael/ael.tab.c res/ael/ael.tab.h res/ael/ael.y res/ael/ael_lex.c res/ael/ael.flex utils/ael_main.c utils/extconf.c utils/conf2ael.c utils/Makefile Had to change the interface to ast_compile_ael2(), to include the hashtab ptr. This ended up involving several external apps. The main gotcha was I had to include lock.h and hashtab.h in several places. As a side note, I tested this stuff pretty thoroughly, I replicated the problems originally reported by Luigi, and made triply sure that reloads worked, and everything worked thru "stop gracefully". I found a and fixed a few bugs as I was merging into trunk, that did not appear in my tests of bug6002. How's this for verbose commit messages? git-svn-id: http://svn.digium.com/svn/asterisk/trunk@106757 f38db490-d61c-443f-a65b-d21fe96a405b
2008-03-07 18:57:57 +00:00
ast_merge_contexts_and_delete(&local_contexts, local_table, registrar);
local_table = NULL; /* it's the dialplan global now */
local_contexts = NULL;
ast_log(LOG_NOTICE, "AEL load process: merged config file name '%s'.\n", rfilename);
for (con = ast_walk_contexts(NULL); con; con = ast_walk_contexts(con))
ast_context_verify_includes(con);
ast_log(LOG_NOTICE, "AEL load process: verified config file name '%s'.\n", rfilename);
} else {
ast_log(LOG_ERROR, "Sorry, but %d syntax errors and %d semantic errors were detected. It doesn't make sense to compile.\n", errs, sem_err);
destroy_pval(parse_tree); /* free up the memory */
return AST_MODULE_LOAD_DECLINE;
}
destroy_pval(parse_tree); /* free up the memory */
return AST_MODULE_LOAD_SUCCESS;
}
/* CLI interface */
static char *handle_cli_ael_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
e->command = "ael set debug {read|tokens|macros|contexts|off}";
e->usage =
"Usage: ael set debug {read|tokens|macros|contexts|off}\n"
" Enable AEL read, token, macro, or context debugging,\n"
" or disable all AEL debugging messages. Note: this\n"
" currently does nothing.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (a->argc != e->args)
return CLI_SHOWUSAGE;
if (!strcasecmp(a->argv[3], "read"))
aeldebug |= DEBUG_READ;
else if (!strcasecmp(a->argv[3], "tokens"))
aeldebug |= DEBUG_TOKENS;
else if (!strcasecmp(a->argv[3], "macros"))
aeldebug |= DEBUG_MACROS;
else if (!strcasecmp(a->argv[3], "contexts"))
aeldebug |= DEBUG_CONTEXTS;
else if (!strcasecmp(a->argv[3], "off"))
aeldebug = 0;
else
return CLI_SHOWUSAGE;
return CLI_SUCCESS;
}
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :) (closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85460 f38db490-d61c-443f-a65b-d21fe96a405b
2007-10-11 19:03:06 +00:00
static char *handle_cli_ael_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :) (closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85460 f38db490-d61c-443f-a65b-d21fe96a405b
2007-10-11 19:03:06 +00:00
switch (cmd) {
case CLI_INIT:
e->command = "ael reload";
e->usage =
"Usage: ael reload\n"
" Reloads AEL configuration.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :) (closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85460 f38db490-d61c-443f-a65b-d21fe96a405b
2007-10-11 19:03:06 +00:00
if (a->argc != 2)
return CLI_SHOWUSAGE;
Merge a ton of NEW_CLI conversions. Thanks to everyone that helped out! :) (closes issue #10724) Reported by: eliel Patches: chan_skinny.c.patch uploaded by eliel (license 64) chan_oss.c.patch uploaded by eliel (license 64) chan_mgcp.c.patch2 uploaded by eliel (license 64) pbx_config.c.patch uploaded by seanbright (license 71) iax2-provision.c.patch uploaded by eliel (license 64) chan_gtalk.c.patch uploaded by eliel (license 64) pbx_ael.c.patch uploaded by seanbright (license 71) file.c.patch uploaded by seanbright (license 71) image.c.patch uploaded by seanbright (license 71) cli.c.patch uploaded by moy (license 222) astobj2.c.patch uploaded by moy (license 222) asterisk.c.patch uploaded by moy (license 222) res_limit.c.patch uploaded by seanbright (license 71) res_convert.c.patch uploaded by seanbright (license 71) res_crypto.c.patch uploaded by seanbright (license 71) app_osplookup.c.patch uploaded by seanbright (license 71) app_rpt.c.patch uploaded by seanbright (license 71) app_mixmonitor.c.patch uploaded by seanbright (license 71) channel.c.patch uploaded by seanbright (license 71) translate.c.patch uploaded by seanbright (license 71) udptl.c.patch uploaded by seanbright (license 71) threadstorage.c.patch uploaded by seanbright (license 71) db.c.patch uploaded by seanbright (license 71) cdr.c.patch uploaded by moy (license 222) pbd_dundi.c.patch uploaded by moy (license 222) app_osplookup-rev83558.patch uploaded by moy (license 222) res_clioriginate.c.patch uploaded by moy (license 222) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@85460 f38db490-d61c-443f-a65b-d21fe96a405b
2007-10-11 19:03:06 +00:00
return (pbx_load_module() ? CLI_FAILURE : CLI_SUCCESS);
}
static struct ast_cli_entry cli_ael[] = {
AST_CLI_DEFINE(handle_cli_ael_reload, "Reload AEL configuration"),
AST_CLI_DEFINE(handle_cli_ael_set_debug, "Enable AEL debugging flags")
};
static int unload_module(void)
{
ast_context_destroy(NULL, registrar);
ast_cli_unregister_multiple(cli_ael, ARRAY_LEN(cli_ael));
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
2011-03-12 20:42:33 +00:00
#ifndef STANDALONE
ast_unregister_application(aelsub);
#endif
return 0;
}
static int load_module(void)
{
ast_cli_register_multiple(cli_ael, ARRAY_LEN(cli_ael));
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
2011-03-12 20:42:33 +00:00
#ifndef STANDALONE
ast_register_application_xml(aelsub, aelsub_exec);
#endif
return (pbx_load_module());
}
static int reload(void)
{
return pbx_load_module();
}
#ifdef STANDALONE
#define AST_MODULE "ael"
int ael_external_load_module(void);
int ael_external_load_module(void)
{
pbx_load_module();
return 1;
}
#endif
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Asterisk Extension Language Compiler",
.load = load_module,
.unload = unload_module,
.reload = reload,
);
#ifdef AAL_ARGCHECK
static const char * const ael_funclist[] =
{
"AGENT",
"ARRAY",
"BASE64_DECODE",
"BASE64_ENCODE",
"CALLERID",
"CDR",
"CHANNEL",
"CHECKSIPDOMAIN",
"CHECK_MD5",
"CURL",
"CUT",
"DB",
"DB_EXISTS",
"DUNDILOOKUP",
"ENUMLOOKUP",
"ENV",
"EVAL",
"EXISTS",
"FIELDQTY",
"FILTER",
"GROUP",
"GROUP_COUNT",
"GROUP_LIST",
"GROUP_MATCH_COUNT",
"IAXPEER",
"IF",
"IFTIME",
"ISNULL",
"KEYPADHASH",
"LANGUAGE",
"LEN",
"MATH",
"MD5",
"MUSICCLASS",
"QUEUEAGENTCOUNT",
"QUEUE_MEMBER_COUNT",
"QUEUE_MEMBER_LIST",
"QUOTE",
"RAND",
"REGEX",
"SET",
"SHA1",
"SIPCHANINFO",
"SIPPEER",
"SIP_HEADER",
"SORT",
"STAT",
"STRFTIME",
"STRPTIME",
"TIMEOUT",
"TXTCIDNAME",
"URIDECODE",
"URIENCODE",
"VMCOUNT"
};
int ael_is_funcname(char *name)
{
int s,t;
t = sizeof(ael_funclist)/sizeof(char*);
s = 0;
while ((s < t) && strcasecmp(name, ael_funclist[s]))
s++;
if ( s < t )
return 1;
else
return 0;
}
#endif