(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: https://origsvn.digium.com/svn/asterisk/trunk@106757 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.1
Steve Murphy 18 years ago
parent 121bc8141f
commit 377e51c4d4

@ -2096,9 +2096,7 @@ static int load_module(void)
int res;
struct ast_context *con;
con = ast_context_find("app_dial_gosub_virtual_context");
if (!con)
con = ast_context_create(NULL, "app_dial_gosub_virtual_context", "app_dial");
con = ast_context_find_or_create(NULL, NULL, "app_dial_gosub_virtual_context", "app_dial");
if (!con)
ast_log(LOG_ERROR, "Dial virtual context 'app_dial_gosub_virtual_context' does not exist and unable to create\n");
else

@ -5280,7 +5280,7 @@ static int sla_build_trunk(struct ast_config *cfg, const char *cat)
if (!ast_strlen_zero(trunk->autocontext)) {
struct ast_context *context;
context = ast_context_find_or_create(NULL, trunk->autocontext, sla_registrar);
context = ast_context_find_or_create(NULL, NULL, trunk->autocontext, sla_registrar);
if (!context) {
ast_log(LOG_ERROR, "Failed to automatically find or create "
"context '%s' for SLA!\n", trunk->autocontext);
@ -5417,7 +5417,7 @@ static int sla_build_station(struct ast_config *cfg, const char *cat)
if (!ast_strlen_zero(station->autocontext)) {
struct ast_context *context;
struct sla_trunk_ref *trunk_ref;
context = ast_context_find_or_create(NULL, station->autocontext, sla_registrar);
context = ast_context_find_or_create(NULL, NULL, station->autocontext, sla_registrar);
if (!context) {
ast_log(LOG_ERROR, "Failed to automatically find or create "
"context '%s' for SLA!\n", station->autocontext);

@ -6147,9 +6147,7 @@ static int load_module(void)
if (!reload_queues(0))
return AST_MODULE_LOAD_DECLINE;
con = ast_context_find("app_queue_gosub_virtual_context");
if (!con)
con = ast_context_create(NULL, "app_queue_gosub_virtual_context", "app_queue");
con = ast_context_find_or_create(NULL, NULL, "app_queue_gosub_virtual_context", "app_queue");
if (!con)
ast_log(LOG_ERROR, "Queue virtual context 'app_queue_gosub_virtual_context' does not exist and unable to create\n");
else

@ -10771,8 +10771,7 @@ static int set_config(char *config_file, int reload)
} else if (!strcasecmp(v->name, "regcontext")) {
ast_copy_string(regcontext, v->value, sizeof(regcontext));
/* Create context if it doesn't exist already */
if (!ast_context_find(regcontext))
ast_context_create(NULL, regcontext, "IAX2");
ast_context_find_or_create(NULL, NULL, regcontext, "IAX2");
} else if (!strcasecmp(v->name, "tos")) {
if (ast_str2tos(v->value, &tos))
ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);

@ -3388,6 +3388,7 @@ static void register_peer_exten(struct sip_peer *peer, int onoff)
{
char multi[256];
char *stringp, *ext, *context;
struct pbx_find_info q = { .stacklen = 0 };
/* XXX note that global_regcontext is both a global 'enable' flag and
* the name of the global regexten context, if not specified
@ -3408,11 +3409,12 @@ static void register_peer_exten(struct sip_peer *peer, int onoff)
} else {
context = global_regcontext;
}
if (onoff)
if (onoff) {
ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop",
ast_strdup(peer->name), ast_free_ptr, "SIP");
else
} else if (pbx_find_extension(NULL, NULL, &q, context, ext, 1, NULL, "", E_MATCH)) {
ast_context_remove_extension(context, ext, 1, NULL);
}
}
}
@ -20297,8 +20299,7 @@ static int reload_config(enum channelreloadreason reason)
/* Create contexts if they don't exist already */
while ((context = strsep(&stringp, "&"))) {
ast_copy_string(used_context, context, sizeof(used_context));
if (!ast_context_find(context))
ast_context_create(NULL, context, "SIP");
ast_context_find_or_create(NULL, NULL, context, "SIP");
}
ast_copy_string(global_regcontext, v->value, sizeof(global_regcontext));
} else if (!strcasecmp(v->name, "regextenonqualify")) {

@ -5801,8 +5801,7 @@ static int reload_config(void)
/* Create contexts if they don't exist already */
while ((context = strsep(&stringp, "&"))) {
ast_copy_string(used_context, context, sizeof(used_context));
if (!ast_context_find(context))
ast_context_create(NULL, context, "Skinny");
ast_context_find_or_create(NULL, NULL, context, "Skinny");
}
ast_copy_string(regcontext, v->value, sizeof(regcontext));
} else if (!strcasecmp(v->name, "dateformat")) {

@ -25,6 +25,7 @@
#include "asterisk/sched.h"
#include "asterisk/chanvars.h"
#include "asterisk/hashtab.h"
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
@ -166,46 +167,37 @@ struct ast_app *pbx_findapp(const char *app);
*/
int pbx_exec(struct ast_channel *c, struct ast_app *app, void *data);
/*!
* \brief Register a new context
*
* \param extcontexts pointer to the ast_context structure pointer
* \param name name of the new context
* \param registrar registrar of the context
*
* This will first search for a context with your name. If it exists already, it will not
* create a new one. If it does not exist, it will create a new one with the given name
* and registrar.
*
* \return NULL on failure, and an ast_context structure on success
*/
struct ast_context *ast_context_create(struct ast_context **extcontexts, const char *name, const char *registrar);
/*!
* \brief Register a new context or find an existing one
*
* \param extcontexts pointer to the ast_context structure pointer
* \param exttable pointer to the hashtable that contains all the elements in extcontexts
* \param name name of the new context
* \param registrar registrar of the context
*
* This function allows you to play in two environments: the global contexts (active dialplan)
* or an external context set of your choosing. To act on the external set, make sure extcontexts
* and exttable are set; for the globals, make sure both extcontexts and exttable are NULL.
*
* This will first search for a context with your name. If it exists already, it will not
* create a new one. If it does not exist, it will create a new one with the given name
* and registrar.
*
* \return NULL on failure, and an ast_context structure on success
*/
struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, const char *name, const char *registrar);
struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar);
/*!
* \brief Merge the temporary contexts into a global contexts list and delete from the
* global list the ones that are being added
*
* \param extcontexts pointer to the ast_context structure pointer
* \param extcontexts pointer to the ast_context structure
* \param exttable pointer to the ast_hashtab structure that contains all the elements in extcontexts
* \param registrar of the context; if it's set the routine will delete all contexts
* that belong to that registrar; if NULL only the contexts that are specified
* in extcontexts
*/
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar);
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar);
/*!
* \brief Destroy a context (matches the specified context (or ANY context if NULL)
@ -973,8 +965,18 @@ struct ast_exten *pbx_find_extension(struct ast_channel *chan,
struct ast_context *bypass, struct pbx_find_info *q,
const char *context, const char *exten, int priority,
const char *label, const char *callerid, enum ext_match_t action);
/* every time a write lock is obtained for contexts,
a counter is incremented. You can check this via the
following func */
int ast_wrlock_contexts_version(void);
/* hashtable functions for contexts */
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b);
unsigned int ast_hashtab_hash_contexts(const void *obj);
#if defined(__cplusplus) || defined(c_plusplus)
}

@ -1,6 +1,7 @@
#ifndef _ASTERISK_PVAL_H
#define _ASTERISK_PVAL_H
/* whatever includes this, better include asterisk/lock.h and asterisk/hashtab.h */
typedef enum
{
@ -143,7 +144,7 @@ void destroy_extensions(struct ael_extension *exten);
static void gen_prios(struct ael_extension *exten, char *label, pval *statement, struct ael_extension *mother_exten, struct ast_context *context ); */
void set_priorities(struct ael_extension *exten);
void add_extensions(struct ael_extension *exten);
void ast_compile_ael2(struct ast_context **local_contexts, struct pval *root);
void 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 );

@ -488,9 +488,7 @@ static int park_call_full(struct ast_channel *chan, struct ast_channel *peer, in
ast_adsi_unload_session(peer);
}
con = ast_context_find(parking_con);
if (!con)
con = ast_context_create(NULL, parking_con, registrar);
con = ast_context_find_or_create(NULL, NULL, parking_con, registrar);
if (!con) /* Still no context? Bad */
ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
/* Tell the peer channel the number of the parking space */
@ -2228,12 +2226,9 @@ static void *do_parking_thread(void *ignore)
if (peername_flat[i] == '/')
peername_flat[i]= '0';
}
con = ast_context_find(parking_con_dial);
if (!con) {
con = ast_context_create(NULL, parking_con_dial, registrar);
if (!con)
ast_log(LOG_ERROR, "Parking dial context '%s' does not exist and unable to create\n", parking_con_dial);
}
con = ast_context_find_or_create(NULL, NULL, parking_con_dial, registrar);
if (!con)
ast_log(LOG_ERROR, "Parking dial context '%s' does not exist and unable to create\n", parking_con_dial);
if (con) {
char returnexten[AST_MAX_EXTENSION];
struct ast_datastore *features_datastore;
@ -2822,7 +2817,7 @@ static int load_config(void)
ast_debug(1, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
}
if (!(con = ast_context_find(parking_con)) && !(con = ast_context_create(NULL, parking_con, registrar))) {
if (!(con = ast_context_find_or_create(NULL, NULL, parking_con, registrar))) {
ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
return -1;
}

File diff suppressed because it is too large Load Diff

@ -41,6 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/cli.h"
#include "asterisk/app.h"
#include "asterisk/callerid.h"
#include "asterisk/hashtab.h"
#include "asterisk/ael_structs.h"
#include "asterisk/pval.h"
#ifdef AAL_ARGCHECK
@ -88,7 +89,7 @@ void linkprio(struct ael_extension *exten, struct ael_priority *prio);
void destroy_extensions(struct ael_extension *exten);
void set_priorities(struct ael_extension *exten);
void add_extensions(struct ael_extension *exten);
void ast_compile_ael2(struct ast_context **local_contexts, struct pval *root);
void 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 );
@ -108,6 +109,8 @@ 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;
struct ast_hashtab *local_table=NULL;
struct pval *parse_tree;
ast_log(LOG_NOTICE, "Starting AEL load process.\n");
@ -127,10 +130,13 @@ static int pbx_load_module(void)
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);
ast_compile_ael2(&local_contexts, parse_tree);
local_table = ast_hashtab_create(11, ast_hashtab_compare_contexts, ast_hashtab_resize_java, ast_hashtab_newsize_java, ast_hashtab_hash_contexts, 0);
ast_compile_ael2(&local_contexts, local_table, parse_tree);
ast_log(LOG_NOTICE, "AEL load process: compiled config file name '%s'.\n", rfilename);
ast_merge_contexts_and_delete(&local_contexts, registrar);
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);

@ -51,7 +51,7 @@ static int extenpatternmatchnew_config = 0;
AST_MUTEX_DEFINE_STATIC(save_dialplan_lock);
static struct ast_context *local_contexts = NULL;
static struct ast_hashtab *local_table = NULL;
/*
* Prototypes for our completion functions
*/
@ -1371,7 +1371,6 @@ static int pbx_load_config(const char *config_file)
const char *aft;
const char *newpm;
struct ast_flags config_flags = { 0 };
cfg = ast_config_load(config_file, config_flags);
if (!cfg)
return 0;
@ -1399,7 +1398,7 @@ static int pbx_load_config(const char *config_file)
/* All categories but "general" or "globals" are considered contexts */
if (!strcasecmp(cxt, "general") || !strcasecmp(cxt, "globals"))
continue;
con=ast_context_find_or_create(&local_contexts,cxt, registrar);
con=ast_context_find_or_create(&local_contexts, local_table, cxt, registrar);
if (con == NULL)
continue;
@ -1601,7 +1600,7 @@ static void pbx_load_users(void)
/* Only create a context here when it is really needed. Otherwise default empty context
created by pbx_config may conflict with the one explicitly created by pbx_ael */
if (!con)
con = ast_context_find_or_create(&local_contexts, userscontext, registrar);
con = ast_context_find_or_create(&local_contexts, local_table, userscontext, registrar);
if (!con) {
ast_log(LOG_ERROR, "Can't find/create user context '%s'\n", userscontext);
@ -1626,12 +1625,17 @@ static int pbx_load_module(void)
{
struct ast_context *con;
if(!pbx_load_config(config))
if (!local_table)
local_table = ast_hashtab_create(17, ast_hashtab_compare_contexts, ast_hashtab_resize_java, ast_hashtab_newsize_java, ast_hashtab_hash_contexts, 0);
if (!pbx_load_config(config))
return AST_MODULE_LOAD_DECLINE;
pbx_load_users();
ast_merge_contexts_and_delete(&local_contexts, registrar);
ast_merge_contexts_and_delete(&local_contexts, local_table, registrar);
local_table = NULL; /* the local table has been moved into the global one. */
local_contexts = NULL;
for (con = NULL; (con = ast_walk_contexts(con));)
ast_context_verify_includes(con);

@ -60,6 +60,7 @@
%option bison-locations
%{
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <sys/types.h>
@ -70,9 +71,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define GLOB_ABORTED GLOB_ABEND
#endif
# include <glob.h>
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/hashtab.h"
#include "ael/ael.tab.h"
#include "asterisk/ael_structs.h"

File diff suppressed because it is too large Load Diff

@ -120,7 +120,7 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 54 "ael.y"
#line 56 "ael.y"
{
int intval; /* integer value, typically flags */
char *str; /* strings */

@ -31,6 +31,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <string.h>
#include "asterisk/logger.h"
#include "asterisk/lock.h"
#include "asterisk/hashtab.h"
#include "asterisk/ael_structs.h"
pval * linku1(pval *head, pval *tail);

@ -803,9 +803,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#define GLOB_ABORTED GLOB_ABEND
#endif
# include <glob.h>
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/hashtab.h"
#include "ael/ael.tab.h"
#include "asterisk/ael_structs.h"
@ -906,7 +907,7 @@ static void pbcwhere(const char *text, int *line, int *col )
#define STORE_POS
#define STORE_LOC
#endif
#line 909 "ael_lex.c"
#line 911 "ael_lex.c"
#define INITIAL 0
#define paren 1
@ -1145,10 +1146,10 @@ YY_DECL
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
#line 187 "ael.flex"
#line 189 "ael.flex"
#line 1151 "ael_lex.c"
#line 1153 "ael_lex.c"
yylval = yylval_param;
@ -1239,260 +1240,260 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
#line 189 "ael.flex"
#line 191 "ael.flex"
{ STORE_POS; return LC;}
YY_BREAK
case 2:
YY_RULE_SETUP
#line 190 "ael.flex"
#line 192 "ael.flex"
{ STORE_POS; return RC;}
YY_BREAK
case 3:
YY_RULE_SETUP
#line 191 "ael.flex"
#line 193 "ael.flex"
{ STORE_POS; return LP;}
YY_BREAK
case 4:
YY_RULE_SETUP
#line 192 "ael.flex"
#line 194 "ael.flex"
{ STORE_POS; return RP;}
YY_BREAK
case 5:
YY_RULE_SETUP
#line 193 "ael.flex"
#line 195 "ael.flex"
{ STORE_POS; return SEMI;}
YY_BREAK
case 6:
YY_RULE_SETUP
#line 194 "ael.flex"
#line 196 "ael.flex"
{ STORE_POS; return EQ;}
YY_BREAK
case 7:
YY_RULE_SETUP
#line 195 "ael.flex"
#line 197 "ael.flex"
{ STORE_POS; return COMMA;}
YY_BREAK
case 8:
YY_RULE_SETUP
#line 196 "ael.flex"
#line 198 "ael.flex"
{ STORE_POS; return COLON;}
YY_BREAK
case 9:
YY_RULE_SETUP
#line 197 "ael.flex"
#line 199 "ael.flex"
{ STORE_POS; return AMPER;}
YY_BREAK
case 10:
YY_RULE_SETUP
#line 198 "ael.flex"
#line 200 "ael.flex"
{ STORE_POS; return BAR;}
YY_BREAK
case 11:
YY_RULE_SETUP
#line 199 "ael.flex"
#line 201 "ael.flex"
{ STORE_POS; return EXTENMARK;}
YY_BREAK
case 12:
YY_RULE_SETUP
#line 200 "ael.flex"
#line 202 "ael.flex"
{ STORE_POS; return AT;}
YY_BREAK
case 13:
YY_RULE_SETUP
#line 201 "ael.flex"
#line 203 "ael.flex"
{/*comment*/}
YY_BREAK
case 14:
YY_RULE_SETUP
#line 202 "ael.flex"
#line 204 "ael.flex"
{ STORE_POS; return KW_CONTEXT;}
YY_BREAK
case 15:
YY_RULE_SETUP
#line 203 "ael.flex"
#line 205 "ael.flex"
{ STORE_POS; return KW_ABSTRACT;}
YY_BREAK
case 16:
YY_RULE_SETUP
#line 204 "ael.flex"
#line 206 "ael.flex"
{ STORE_POS; return KW_EXTEND;}
YY_BREAK
case 17:
YY_RULE_SETUP
#line 205 "ael.flex"
#line 207 "ael.flex"
{ STORE_POS; return KW_MACRO;};
YY_BREAK
case 18:
YY_RULE_SETUP
#line 206 "ael.flex"
#line 208 "ael.flex"
{ STORE_POS; return KW_GLOBALS;}
YY_BREAK
case 19:
YY_RULE_SETUP
#line 207 "ael.flex"
#line 209 "ael.flex"
{ STORE_POS; return KW_LOCAL;}
YY_BREAK
case 20:
YY_RULE_SETUP
#line 208 "ael.flex"
#line 210 "ael.flex"
{ STORE_POS; return KW_IGNOREPAT;}
YY_BREAK
case 21:
YY_RULE_SETUP
#line 209 "ael.flex"
#line 211 "ael.flex"
{ STORE_POS; return KW_SWITCH;}
YY_BREAK
case 22:
YY_RULE_SETUP
#line 210 "ael.flex"
#line 212 "ael.flex"
{ STORE_POS; return KW_IF;}
YY_BREAK
case 23:
YY_RULE_SETUP
#line 211 "ael.flex"
#line 213 "ael.flex"
{ STORE_POS; return KW_IFTIME;}
YY_BREAK
case 24:
YY_RULE_SETUP
#line 212 "ael.flex"
#line 214 "ael.flex"
{ STORE_POS; return KW_RANDOM;}
YY_BREAK
case 25:
YY_RULE_SETUP
#line 213 "ael.flex"
#line 215 "ael.flex"
{ STORE_POS; return KW_REGEXTEN;}
YY_BREAK
case 26:
YY_RULE_SETUP
#line 214 "ael.flex"
#line 216 "ael.flex"
{ STORE_POS; return KW_HINT;}
YY_BREAK
case 27:
YY_RULE_SETUP
#line 215 "ael.flex"
#line 217 "ael.flex"
{ STORE_POS; return KW_ELSE;}
YY_BREAK
case 28:
YY_RULE_SETUP
#line 216 "ael.flex"
#line 218 "ael.flex"
{ STORE_POS; return KW_GOTO;}
YY_BREAK
case 29:
YY_RULE_SETUP
#line 217 "ael.flex"
#line 219 "ael.flex"
{ STORE_POS; return KW_JUMP;}
YY_BREAK
case 30:
YY_RULE_SETUP
#line 218 "ael.flex"
#line 220 "ael.flex"
{ STORE_POS; return KW_RETURN;}
YY_BREAK
case 31:
YY_RULE_SETUP
#line 219 "ael.flex"
#line 221 "ael.flex"
{ STORE_POS; return KW_BREAK;}
YY_BREAK
case 32:
YY_RULE_SETUP
#line 220 "ael.flex"
#line 222 "ael.flex"
{ STORE_POS; return KW_CONTINUE;}
YY_BREAK
case 33:
YY_RULE_SETUP
#line 221 "ael.flex"
#line 223 "ael.flex"
{ STORE_POS; return KW_FOR;}
YY_BREAK
case 34:
YY_RULE_SETUP
#line 222 "ael.flex"
#line 224 "ael.flex"
{ STORE_POS; return KW_WHILE;}
YY_BREAK
case 35:
YY_RULE_SETUP
#line 223 "ael.flex"
#line 225 "ael.flex"
{ STORE_POS; return KW_CASE;}
YY_BREAK
case 36:
YY_RULE_SETUP
#line 224 "ael.flex"
#line 226 "ael.flex"
{ STORE_POS; return KW_DEFAULT;}
YY_BREAK
case 37:
YY_RULE_SETUP
#line 225 "ael.flex"
#line 227 "ael.flex"
{ STORE_POS; return KW_PATTERN;}
YY_BREAK
case 38:
YY_RULE_SETUP
#line 226 "ael.flex"
#line 228 "ael.flex"
{ STORE_POS; return KW_CATCH;}
YY_BREAK
case 39:
YY_RULE_SETUP
#line 227 "ael.flex"
#line 229 "ael.flex"
{ STORE_POS; return KW_SWITCHES;}
YY_BREAK
case 40:
YY_RULE_SETUP
#line 228 "ael.flex"
#line 230 "ael.flex"
{ STORE_POS; return KW_ESWITCHES;}
YY_BREAK
case 41:
YY_RULE_SETUP
#line 229 "ael.flex"
#line 231 "ael.flex"
{ STORE_POS; return KW_INCLUDES;}
YY_BREAK
case 42:
YY_RULE_SETUP
#line 230 "ael.flex"
#line 232 "ael.flex"
{ BEGIN(comment); my_col += 2; }
YY_BREAK
case 43:
YY_RULE_SETUP
#line 232 "ael.flex"
#line 234 "ael.flex"
{ my_col += yyleng; }
YY_BREAK
case 44:
/* rule 44 can match eol */
YY_RULE_SETUP
#line 233 "ael.flex"
#line 235 "ael.flex"
{ ++my_lineno; my_col=1;}
YY_BREAK
case 45:
YY_RULE_SETUP
#line 234 "ael.flex"
#line 236 "ael.flex"
{ my_col += yyleng; }
YY_BREAK
case 46:
/* rule 46 can match eol */
YY_RULE_SETUP
#line 235 "ael.flex"
#line 237 "ael.flex"
{ ++my_lineno; my_col=1;}
YY_BREAK
case 47:
YY_RULE_SETUP
#line 236 "ael.flex"
#line 238 "ael.flex"
{ my_col += 2; BEGIN(INITIAL); }
YY_BREAK
case 48:
/* rule 48 can match eol */
YY_RULE_SETUP
#line 238 "ael.flex"
#line 240 "ael.flex"
{ my_lineno++; my_col = 1; }
YY_BREAK
case 49:
YY_RULE_SETUP
#line 239 "ael.flex"
#line 241 "ael.flex"
{ my_col += yyleng; }
YY_BREAK
case 50:
YY_RULE_SETUP
#line 240 "ael.flex"
#line 242 "ael.flex"
{ my_col += (yyleng*8)-(my_col%8); }
YY_BREAK
case 51:
YY_RULE_SETUP
#line 242 "ael.flex"
#line 244 "ael.flex"
{
STORE_POS;
yylval->str = strdup(yytext);
@ -1510,7 +1511,7 @@ YY_RULE_SETUP
case 52:
/* rule 52 can match eol */
YY_RULE_SETUP
#line 258 "ael.flex"
#line 260 "ael.flex"
{
if ( pbcpop(')') ) { /* error */
STORE_LOC;
@ -1536,7 +1537,7 @@ YY_RULE_SETUP
case 53:
/* rule 53 can match eol */
YY_RULE_SETUP
#line 280 "ael.flex"
#line 282 "ael.flex"
{
char c = yytext[yyleng-1];
if (c == '(')
@ -1548,7 +1549,7 @@ YY_RULE_SETUP
case 54:
/* rule 54 can match eol */
YY_RULE_SETUP
#line 288 "ael.flex"
#line 290 "ael.flex"
{
char c = yytext[yyleng-1];
if ( pbcpop(c)) { /* error */
@ -1573,7 +1574,7 @@ YY_RULE_SETUP
case 55:
/* rule 55 can match eol */
YY_RULE_SETUP
#line 310 "ael.flex"
#line 312 "ael.flex"
{
char c = yytext[yyleng-1];
if (c == '(')
@ -1585,7 +1586,7 @@ YY_RULE_SETUP
case 56:
/* rule 56 can match eol */
YY_RULE_SETUP
#line 318 "ael.flex"
#line 320 "ael.flex"
{
if ( pbcpop(')') ) { /* error */
STORE_LOC;
@ -1613,7 +1614,7 @@ YY_RULE_SETUP
case 57:
/* rule 57 can match eol */
YY_RULE_SETUP
#line 342 "ael.flex"
#line 344 "ael.flex"
{
if( parencount != 0) { /* printf("Folding in a comma!\n"); */
yymore();
@ -1631,7 +1632,7 @@ YY_RULE_SETUP
case 58:
/* rule 58 can match eol */
YY_RULE_SETUP
#line 356 "ael.flex"
#line 358 "ael.flex"
{
char c = yytext[yyleng-1];
if ( pbcpop(c) ) { /* error */
@ -1652,7 +1653,7 @@ YY_RULE_SETUP
case 59:
/* rule 59 can match eol */
YY_RULE_SETUP
#line 373 "ael.flex"
#line 375 "ael.flex"
{
char c = yytext[yyleng-1];
yymore();
@ -1662,7 +1663,7 @@ YY_RULE_SETUP
case 60:
/* rule 60 can match eol */
YY_RULE_SETUP
#line 379 "ael.flex"
#line 381 "ael.flex"
{
char c = yytext[yyleng-1];
if ( pbcpop(c) ) { /* error */
@ -1678,7 +1679,7 @@ YY_RULE_SETUP
case 61:
/* rule 61 can match eol */
YY_RULE_SETUP
#line 391 "ael.flex"
#line 393 "ael.flex"
{
STORE_LOC;
yylval->str = strdup(yytext);
@ -1691,7 +1692,7 @@ YY_RULE_SETUP
case 62:
/* rule 62 can match eol */
YY_RULE_SETUP
#line 400 "ael.flex"
#line 402 "ael.flex"
{
char fnamebuf[1024],*p1,*p2;
int glob_ret;
@ -1741,7 +1742,7 @@ case YY_STATE_EOF(paren):
case YY_STATE_EOF(semic):
case YY_STATE_EOF(argg):
case YY_STATE_EOF(comment):
#line 445 "ael.flex"
#line 447 "ael.flex"
{
char fnamebuf[2048];
if (include_stack_index > 0 && include_stack[include_stack_index-1].globbuf_pos < include_stack[include_stack_index-1].globbuf.gl_pathc-1) {
@ -1778,10 +1779,10 @@ case YY_STATE_EOF(comment):
YY_BREAK
case 63:
YY_RULE_SETUP
#line 479 "ael.flex"
#line 481 "ael.flex"
ECHO;
YY_BREAK
#line 1784 "ael_lex.c"
#line 1786 "ael_lex.c"
case YY_END_OF_BUFFER:
{
@ -2906,7 +2907,7 @@ void *ael_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 479 "ael.flex"
#line 481 "ael.flex"

@ -3963,7 +3963,7 @@ static void fix_gotos_in_extensions(struct ael_extension *exten)
}
void ast_compile_ael2(struct ast_context **local_contexts, struct pval *root)
void ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *local_table, struct pval *root)
{
pval *p,*p2;
struct ast_context *context;
@ -3994,7 +3994,7 @@ void ast_compile_ael2(struct ast_context **local_contexts, struct pval *root)
switch (p->type) {
case PV_MACRO:
context = ast_context_create(local_contexts, p->u1.str, registrar);
context = ast_context_find_or_create(local_contexts, local_table, p->u1.str, registrar);
exten = new_exten();
exten->context = context;
@ -4032,7 +4032,7 @@ void ast_compile_ael2(struct ast_context **local_contexts, struct pval *root)
break;
case PV_CONTEXT:
context = ast_context_find_or_create(local_contexts, p->u1.str, registrar);
context = ast_context_find_or_create(local_contexts, local_table, p->u1.str, registrar);
/* contexts contain: ignorepat, includes, switches, eswitches, extensions, */
for (p2=p->u2.statements; p2; p2=p2->next) {

@ -131,7 +131,7 @@ aelparse.c: $(ASTTOPDIR)/res/ael/ael_lex.c
aelparse.o: ASTCFLAGS+=-I$(ASTTOPDIR)/res -DSTANDALONE_AEL
aelparse: aelparse.o aelbison.o pbx_ael.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o
aelparse: aelparse.o aelbison.o pbx_ael.o hashtab.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o
astobj2.c: $(ASTTOPDIR)/main/astobj2.c
@cp $< $@
@ -155,7 +155,7 @@ hashtest.o: ASTCFLAGS+=-O0
extconf.o: extconf.c
conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o
conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o hashtab.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o
testexpr2s: $(ASTTOPDIR)/main/ast_expr2f.c $(ASTTOPDIR)/main/ast_expr2.c $(ASTTOPDIR)/main/ast_expr2.h
$(CC) -g -c -I$(ASTTOPDIR)/include -DSTANDALONE_AEL $(ASTTOPDIR)/main/ast_expr2f.c -o ast_expr2f.o

@ -19,6 +19,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/ast_expr.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/lock.h"
#include "asterisk/hashtab.h"
#include "asterisk/ael_structs.h"
#include "asterisk/extconf.h"
@ -582,3 +584,34 @@ int main(int argc, char **argv)
return 0;
}
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b);
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
{
return 0;
}
unsigned int ast_hashtab_hash_contexts(const void *obj);
unsigned int ast_hashtab_hash_contexts(const void *obj)
{
return 0;
}
#ifdef DEBUG_THREADS
void ast_mark_lock_acquired(void *lock_addr)
{
}
void ast_remove_lock_info(void *lock_addr)
{
}
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr)
{
}
#endif

@ -47,6 +47,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/config.h"
#include "asterisk/options.h"
#include "asterisk/callerid.h"
#include "asterisk/lock.h"
#include "asterisk/hashtab.h"
#include "asterisk/ael_structs.h"
#include "asterisk/devicestate.h"
#include "asterisk/stringfields.h"
@ -604,14 +606,7 @@ int ast_context_add_include2(struct ast_context *con, const char *value,
return localized_context_add_include2(con, value,registrar);
}
struct ast_context *ast_context_create(struct ast_context **extcontexts, const char *name, const char *registrar)
{
printf("Creating context %s, registrar=%s\n", name, registrar);
return localized_context_create(extcontexts, name, registrar);
}
struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, const char *name, const char *registrar)
struct ast_context *ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
{
printf("find/Creating context %s, registrar=%s\n", name, registrar);
@ -658,9 +653,9 @@ int ast_context_verify_includes(struct ast_context *con)
return localized_context_verify_includes(con);
}
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar);
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar);
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char *registrar)
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
{
localized_merge_contexts_and_delete(extcontexts, registrar);
}
@ -688,3 +683,33 @@ struct ast_exten *pbx_find_extension(struct ast_channel *chan,
return localized_find_extension(bypass, q, context, exten, priority, label, callerid, action);
}
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b);
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
{
return 0;
}
unsigned int ast_hashtab_hash_contexts(const void *obj);
unsigned int ast_hashtab_hash_contexts(const void *obj)
{
return 0;
}
#ifdef DEBUG_THREADS
void ast_mark_lock_acquired(void *lock_addr)
{
}
void ast_remove_lock_info(void *lock_addr)
{
}
void ast_store_lock_info(enum ast_lock_type type, const char *filename,
int line_num, const char *func, const char *lock_name, void *lock_addr)
{
}
#endif

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save