45 #include "asterisk/pval.h"
47 #include "asterisk/argdesc.h"
72 #define DEBUG_READ (1 << 0)
73 #define DEBUG_TOKENS (1 << 1)
74 #define DEBUG_MACROS (1 << 2)
75 #define DEBUG_CONTEXTS (1 << 3)
77 static char *config =
"extensions.ael";
78 static char *registrar =
"pbx_ael";
79 static int pbx_load_module(
void);
90 int option_matches_j(
struct argdesc *should,
pval *is,
struct argapp *app);
91 int option_matches(
struct argdesc *should,
pval *is,
struct argapp *app);
92 int ael_is_funcname(
char *name);
95 int check_app_args(
pval *appcall,
pval *arglist,
struct argapp *app);
97 void check_pval_item(
pval *item,
struct argapp *
apps,
int in_globals);
99 void ast_expr_register_extra_error_info(
char *errmsg);
100 void ast_expr_clear_extra_error_info(
void);
109 void destroy_pval(
pval *item);
110 void destroy_pval_item(
pval *item);
111 int is_float(
char *arg );
112 int is_int(
char *arg );
113 int is_empty(
char *arg);
117 static int aeldebug = 0;
122 static char *aelsub =
"AELSub";
124 static int aelsub_exec(
struct ast_channel *chan,
const char *vdata)
134 AST_STANDARD_RAW_ARGS(args, data);
135 snprintf(buf,
sizeof(buf),
"%s,~~s~~,1(%s)", args.name, args.args);
144 static int pbx_load_module(
void)
146 int errs=0, sem_err=0, sem_warn=0, sem_note=0;
151 struct pval *parse_tree;
153 ast_log(LOG_DEBUG,
"Starting AEL load process.\n");
154 if (config[0] ==
'/')
155 rfilename = (
char *)config;
157 rfilename =
ast_alloca(strlen(config) + strlen(ast_config_AST_CONFIG_DIR) + 2);
158 sprintf(rfilename,
"%s/%s", ast_config_AST_CONFIG_DIR, config);
160 if (access(rfilename,R_OK) != 0) {
161 ast_log(LOG_NOTICE,
"File %s not found; AEL declining load\n", rfilename);
165 parse_tree = ael2_parse(rfilename, &errs);
166 ast_log(LOG_DEBUG,
"AEL load process: parsed config file name '%s'.\n", rfilename);
167 ael2_semantic_check(parse_tree, &sem_err, &sem_warn, &sem_note);
168 if (errs == 0 && sem_err == 0) {
169 ast_log(LOG_DEBUG,
"AEL load process: checked config file name '%s'.\n", rfilename);
171 if (ast_compile_ael2(&local_contexts, local_table, parse_tree)) {
172 ast_log(LOG_ERROR,
"AEL compile failed! Aborting.\n");
173 destroy_pval(parse_tree);
176 ast_log(LOG_DEBUG,
"AEL load process: compiled config file name '%s'.\n", rfilename);
180 local_contexts = NULL;
181 ast_log(LOG_DEBUG,
"AEL load process: merged config file name '%s'.\n", rfilename);
182 for (con = ast_walk_contexts(NULL); con; con = ast_walk_contexts(con))
184 ast_log(LOG_DEBUG,
"AEL load process: verified config file name '%s'.\n", rfilename);
186 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);
187 destroy_pval(parse_tree);
190 destroy_pval(parse_tree);
200 e->
command =
"ael set debug {read|tokens|contexts|off}";
202 "Usage: ael set debug {read|tokens|contexts|off}\n"
203 " Enable AEL read, token, or context debugging,\n"
204 " or disable all AEL debugging messages. Note: this\n"
205 " currently does nothing.\n";
211 if (a->argc != e->
args)
212 return CLI_SHOWUSAGE;
214 if (!strcasecmp(a->argv[3],
"read"))
215 aeldebug |= DEBUG_READ;
216 else if (!strcasecmp(a->argv[3],
"tokens"))
217 aeldebug |= DEBUG_TOKENS;
218 else if (!strcasecmp(a->argv[3],
"contexts"))
219 aeldebug |= DEBUG_CONTEXTS;
220 else if (!strcasecmp(a->argv[3],
"off"))
223 return CLI_SHOWUSAGE;
234 "Usage: ael reload\n"
235 " Reloads AEL configuration.\n";
242 return CLI_SHOWUSAGE;
249 return (pbx_load_module() ? CLI_FAILURE : CLI_SUCCESS);
254 AST_CLI_DEFINE(handle_cli_ael_reload,
"Reload AEL configuration"),
255 AST_CLI_DEFINE(handle_cli_ael_set_debug,
"Enable AEL debugging flags")
258 static int unload_module(
void)
268 static int load_module(
void)
274 return (pbx_load_module());
277 static int reload(
void)
280 return pbx_load_module();
284 #define AST_MODULE "ael"
285 int ael_external_load_module(
void);
286 int ael_external_load_module(
void)
293 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
"Asterisk Extension Language Compiler",
294 .support_level = AST_MODULE_SUPPORT_EXTENDED,
296 .unload = unload_module,
298 .requires =
"res_ael_share",
302 static const char *
const ael_funclist[] =
339 "QUEUE_MEMBER_COUNT",
361 int ael_is_funcname(
char *name)
364 t =
sizeof(ael_funclist)/
sizeof(
char*);
366 while ((s < t) && strcasecmp(name, ael_funclist[s]))
int ast_hashtab_compare_contexts(const void *ah_a, const void *ah_b)
hashtable functions for contexts
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
int ast_hashtab_newsize_java(struct ast_hashtab *tab)
Create a prime number roughly 2x the current table size.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Registered applications container.
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
descriptor for a cli entry.
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
int ast_unregister_application(const char *app)
Unregister an application.
int ast_hashtab_resize_java(struct ast_hashtab *tab)
Determines if a table resize should occur using the Java algorithm (if the table load factor is 75% o...
int args
This gets set in ast_cli_register()
Configuration File Parser.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Core PBX routines and definitions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
void ast_merge_contexts_and_delete(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *registrar)
Merge the temporary contexts into a global contexts list and delete from the global list the ones tha...
static struct ast_context * find_context(const char *context)
lookup for a context with a given name,
Structures for AEL - the Asterisk extension language.
Support for logging to various files, console and syslog Configuration in file logger.conf.
Module has failed to load, may be in an inconsistent state.
Standard Command Line Interface.
ast_app: A registered application
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
#define ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking)
Create the hashtable list.
int ast_context_verify_includes(struct ast_context *con)
Verifies includes in an ast_contect structure.
struct ast_app * pbx_findapp(const char *app)
Look up an application.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
ast_context: An extension context
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define AST_APP_ARG(name)
Define an application argument.