#include "asterisk.h"
#include <ctype.h>
#include <regex.h>
#include <sys/stat.h>
#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"
#include "asterisk/hashtab.h"
#include "asterisk/ael_structs.h"
#include "asterisk/pval.h"
Go to the source code of this file.
Defines | |
#define | DEBUG_CONTEXTS (1 << 3) |
#define | DEBUG_MACROS (1 << 2) |
#define | DEBUG_READ (1 << 0) |
#define | DEBUG_TOKENS (1 << 1) |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
void | add_extensions (struct ael_extension *exten) |
void | ast_compile_ael2 (struct ast_context **local_contexts, struct ast_hashtab *local_table, struct pval *root) |
void | ast_expr_clear_extra_error_info (void) |
void | ast_expr_register_extra_error_info (char *errmsg) |
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 | destroy_extensions (struct ael_extension *exten) |
void | destroy_pval (pval *item) |
void | destroy_pval_item (pval *item) |
pval * | find_context (char *name) |
pval * | find_macro (char *name) |
static char * | handle_cli_ael_debug_multiple_deprecated (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_ael_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_ael_set_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
int | is_empty (char *arg) |
int | is_float (char *arg) |
int | is_int (char *arg) |
static int | load_module (void) |
ael_extension * | new_exten (void) |
ael_priority * | new_prio (void) |
static int | pbx_load_module (void) |
static int | reload (void) |
void | set_priorities (struct ael_extension *exten) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Asterisk Extension Language Compiler" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, .reload = reload, } |
static int | aeldebug = 0 |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_cli_entry | cli_ael [] |
static struct ast_cli_entry | cli_ael_debug_multiple_deprecated = { .handler = handle_cli_ael_debug_multiple_deprecated , .summary = "Enable AEL debugging flags" ,__VA_ARGS__ } |
static char * | config = "extensions.ael" |
static char * | registrar = "pbx_ael" |
Definition in file pbx_ael.c.
#define DEBUG_CONTEXTS (1 << 3) |
Definition at line 63 of file pbx_ael.c.
Referenced by handle_cli_ael_debug_multiple_deprecated(), and handle_cli_ael_set_debug().
#define DEBUG_MACROS (1 << 2) |
Definition at line 62 of file pbx_ael.c.
Referenced by handle_cli_ael_debug_multiple_deprecated(), and handle_cli_ael_set_debug().
#define DEBUG_READ (1 << 0) |
Definition at line 60 of file pbx_ael.c.
Referenced by handle_cli_ael_debug_multiple_deprecated(), and handle_cli_ael_set_debug().
#define DEBUG_TOKENS (1 << 1) |
Definition at line 61 of file pbx_ael.c.
Referenced by handle_cli_ael_debug_multiple_deprecated(), and handle_cli_ael_set_debug().
void add_extensions | ( | struct ael_extension * | exten | ) |
void ast_compile_ael2 | ( | struct ast_context ** | local_contexts, | |
struct ast_hashtab * | local_table, | |||
struct pval * | root | |||
) |
void ast_expr_clear_extra_error_info | ( | void | ) |
void ast_expr_register_extra_error_info | ( | char * | errmsg | ) |
void destroy_extensions | ( | struct ael_extension * | exten | ) |
void destroy_pval | ( | pval * | item | ) |
void destroy_pval_item | ( | pval * | item | ) |
struct pval* find_context | ( | char * | name | ) |
struct pval* find_macro | ( | char * | name | ) |
static char* handle_cli_ael_debug_multiple_deprecated | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 161 of file pbx_ael.c.
References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, DEBUG_CONTEXTS, DEBUG_MACROS, DEBUG_READ, DEBUG_TOKENS, and ast_cli_entry::usage.
00162 { 00163 switch (cmd) { 00164 case CLI_INIT: 00165 e->command = "ael debug [read|tokens|macros|contexts|off]"; 00166 e->usage = 00167 "Usage: ael debug [read|tokens|macros|contexts|off]\n" 00168 " Enable AEL read, token, macro, or context debugging,\n" 00169 " or disable all AEL debugging messages. Note: this\n" 00170 " currently does nothing.\n"; 00171 return NULL; 00172 case CLI_GENERATE: 00173 return NULL; 00174 } 00175 00176 if (a->argc != 3) 00177 return CLI_SHOWUSAGE; 00178 00179 if (!strcasecmp(a->argv[2], "read")) 00180 aeldebug |= DEBUG_READ; 00181 else if (!strcasecmp(a->argv[2], "tokens")) 00182 aeldebug |= DEBUG_TOKENS; 00183 else if (!strcasecmp(a->argv[2], "macros")) 00184 aeldebug |= DEBUG_MACROS; 00185 else if (!strcasecmp(a->argv[2], "contexts")) 00186 aeldebug |= DEBUG_CONTEXTS; 00187 else if (!strcasecmp(a->argv[2], "off")) 00188 aeldebug = 0; 00189 else 00190 return CLI_SHOWUSAGE; 00191 00192 return CLI_SUCCESS; 00193 }
static char* handle_cli_ael_reload | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 229 of file pbx_ael.c.
References ast_cli_args::argc, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, pbx_load_module(), and ast_cli_entry::usage.
00230 { 00231 switch (cmd) { 00232 case CLI_INIT: 00233 e->command = "ael reload"; 00234 e->usage = 00235 "Usage: ael reload\n" 00236 " Reloads AEL configuration.\n"; 00237 return NULL; 00238 case CLI_GENERATE: 00239 return NULL; 00240 } 00241 00242 if (a->argc != 2) 00243 return CLI_SHOWUSAGE; 00244 00245 return (pbx_load_module() ? CLI_FAILURE : CLI_SUCCESS); 00246 }
static char* handle_cli_ael_set_debug | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 195 of file pbx_ael.c.
References ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, DEBUG_CONTEXTS, DEBUG_MACROS, DEBUG_READ, DEBUG_TOKENS, and ast_cli_entry::usage.
00196 { 00197 switch (cmd) { 00198 case CLI_INIT: 00199 e->command = "ael set debug {read|tokens|macros|contexts|off}"; 00200 e->usage = 00201 "Usage: ael debug {read|tokens|macros|contexts|off}\n" 00202 " Enable AEL read, token, macro, or context debugging,\n" 00203 " or disable all AEL debugging messages. Note: this\n" 00204 " currently does nothing.\n"; 00205 return NULL; 00206 case CLI_GENERATE: 00207 return NULL; 00208 } 00209 00210 if (a->argc != e->args) 00211 return CLI_SHOWUSAGE; 00212 00213 if (!strcasecmp(a->argv[3], "read")) 00214 aeldebug |= DEBUG_READ; 00215 else if (!strcasecmp(a->argv[3], "tokens")) 00216 aeldebug |= DEBUG_TOKENS; 00217 else if (!strcasecmp(a->argv[3], "macros")) 00218 aeldebug |= DEBUG_MACROS; 00219 else if (!strcasecmp(a->argv[3], "contexts")) 00220 aeldebug |= DEBUG_CONTEXTS; 00221 else if (!strcasecmp(a->argv[3], "off")) 00222 aeldebug = 0; 00223 else 00224 return CLI_SHOWUSAGE; 00225 00226 return CLI_SUCCESS; 00227 }
int is_empty | ( | char * | arg | ) |
int is_float | ( | char * | arg | ) |
int is_int | ( | char * | arg | ) |
static int load_module | ( | void | ) | [static] |
Definition at line 261 of file pbx_ael.c.
References ast_cli_register_multiple(), cli_ael, and pbx_load_module().
00262 { 00263 ast_cli_register_multiple(cli_ael, sizeof(cli_ael) / sizeof(struct ast_cli_entry)); 00264 return (pbx_load_module()); 00265 }
struct ael_extension* new_exten | ( | void | ) |
struct ael_priority* new_prio | ( | void | ) |
static int pbx_load_module | ( | void | ) | [static] |
Definition at line 113 of file pbx_ael.c.
References ael2_parse(), ael2_semantic_check(), ast_compile_ael2(), ast_config_AST_CONFIG_DIR, ast_context_verify_includes(), ast_hashtab_compare_contexts(), ast_hashtab_create(), ast_hashtab_hash_contexts(), ast_hashtab_newsize_java(), ast_hashtab_resize_java(), ast_log(), ast_merge_contexts_and_delete(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_walk_contexts(), destroy_pval(), local_contexts, local_table, LOG_ERROR, and LOG_NOTICE.
Referenced by handle_cli_ael_reload(), handle_cli_dialplan_reload(), load_module(), and reload().
00114 { 00115 int errs=0, sem_err=0, sem_warn=0, sem_note=0; 00116 char *rfilename; 00117 struct ast_context *local_contexts=NULL, *con; 00118 struct ast_hashtab *local_table=NULL; 00119 00120 struct pval *parse_tree; 00121 00122 ast_log(LOG_NOTICE, "Starting AEL load process.\n"); 00123 if (config[0] == '/') 00124 rfilename = (char *)config; 00125 else { 00126 rfilename = alloca(strlen(config) + strlen(ast_config_AST_CONFIG_DIR) + 2); 00127 sprintf(rfilename, "%s/%s", ast_config_AST_CONFIG_DIR, config); 00128 } 00129 if (access(rfilename,R_OK) != 0) { 00130 ast_log(LOG_NOTICE, "File %s not found; AEL declining load\n", rfilename); 00131 return AST_MODULE_LOAD_DECLINE; 00132 } 00133 00134 parse_tree = ael2_parse(rfilename, &errs); 00135 ast_log(LOG_NOTICE, "AEL load process: parsed config file name '%s'.\n", rfilename); 00136 ael2_semantic_check(parse_tree, &sem_err, &sem_warn, &sem_note); 00137 if (errs == 0 && sem_err == 0) { 00138 ast_log(LOG_NOTICE, "AEL load process: checked config file name '%s'.\n", rfilename); 00139 local_table = ast_hashtab_create(11, ast_hashtab_compare_contexts, ast_hashtab_resize_java, ast_hashtab_newsize_java, ast_hashtab_hash_contexts, 0); 00140 ast_compile_ael2(&local_contexts, local_table, parse_tree); 00141 ast_log(LOG_NOTICE, "AEL load process: compiled config file name '%s'.\n", rfilename); 00142 00143 ast_merge_contexts_and_delete(&local_contexts, local_table, registrar); 00144 local_table = NULL; /* it's the dialplan global now */ 00145 local_contexts = NULL; 00146 ast_log(LOG_NOTICE, "AEL load process: merged config file name '%s'.\n", rfilename); 00147 for (con = ast_walk_contexts(NULL); con; con = ast_walk_contexts(con)) 00148 ast_context_verify_includes(con); 00149 ast_log(LOG_NOTICE, "AEL load process: verified config file name '%s'.\n", rfilename); 00150 } else { 00151 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); 00152 destroy_pval(parse_tree); /* free up the memory */ 00153 return AST_MODULE_LOAD_DECLINE; 00154 } 00155 destroy_pval(parse_tree); /* free up the memory */ 00156 00157 return AST_MODULE_LOAD_SUCCESS; 00158 }
static int reload | ( | void | ) | [static] |
Definition at line 267 of file pbx_ael.c.
References pbx_load_module().
00268 { 00269 return pbx_load_module(); 00270 }
void set_priorities | ( | struct ael_extension * | exten | ) |
static int unload_module | ( | void | ) | [static] |
Definition at line 254 of file pbx_ael.c.
References ast_cli_unregister_multiple(), ast_context_destroy(), and cli_ael.
00255 { 00256 ast_context_destroy(NULL, registrar); 00257 ast_cli_unregister_multiple(cli_ael, sizeof(cli_ael) / sizeof(struct ast_cli_entry)); 00258 return 0; 00259 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Asterisk Extension Language Compiler" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, .reload = reload, } [static] |
const struct ast_module_info* ast_module_info = &__mod_info [static] |
struct ast_cli_entry cli_ael[] [static] |
Initial value:
{ { .handler = handle_cli_ael_reload , .summary = "Reload AEL configuration" ,__VA_ARGS__ }, { .handler = handle_cli_ael_set_debug , .summary = "Enable AEL debugging flags" ,__VA_ARGS__ } .deprecate_cmd = &cli_ael_debug_multiple_deprecated) }
Definition at line 249 of file pbx_ael.c.
Referenced by load_module(), and unload_module().
struct ast_cli_entry cli_ael_debug_multiple_deprecated = { .handler = handle_cli_ael_debug_multiple_deprecated , .summary = "Enable AEL debugging flags" ,__VA_ARGS__ } [static] |