/*
* 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.
*
*/
#include "asterisk.h"
ASTERISK_FILE_VERSION(__FILE__, "$Revision: 136726 $")
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.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/ael_structs.h"
#ifdef AAL_ARGCHECK
#include "asterisk/argdesc.h"
#endif
static char expr_output[2096];
/* 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);
static int errs, warns;
static int notes;
#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
*/
/* null definitions for structs passed down the infrastructure */
struct argapp
{
struct argapp *next;
};
#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);
int ast_expr(char *expr, char *buf, int length);
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 linkprio(struct ael_extension *exten, struct ael_priority *prio, struct ael_extension *mother_exten);
void destroy_extensions(struct ael_extension *exten);
static void linkexten(struct ael_extension *exten, struct ael_extension *add);
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 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 pval *current_db=0;
static pval *current_context=0;
static pval *current_extension=0;
static const char *match_context;
static const char *match_exten;
static const char *match_label;
static int in_abstract_context;
static int count_labels; /* true, put matcher in label counting mode */
static int label_count; /* labels are only meant to be counted in a context or exten */
static int return_on_context_match;
static pval *last_matched_label;
struct pval *match_pval(pval *item);
static void check_timerange(pval *p);
static void check_dow(pval *DOW);
static void check_day(pval *DAY);
static void check_month(pval *MON);
static void check_expr2_input(pval *expr, char *str);
static int extension_matches(pval *here, const char *exten, const char *pattern);
static void check_goto(pval *item);
static void find_pval_goto_item(pval *item, int lev);
static void find_pval_gotos(pval *item, int lev);
static struct pval *find_label_in_current_context(char *exten, char *label, pval *curr_cont);
static struct pval *find_first_label_in_current_context(char *label, pval *curr_cont);
static void print_pval_list(FILE *fin, pval *item, int depth);
static struct pval *find_label_in_current_extension(const char *label, pval *curr_ext);
static struct pval *find_label_in_current_db(const char *context, const char *exten, const char *label);
static pval *get_goto_target(pval *item);
static int label_inside_case(pval *label);
static void attach_exten(struct ael_extension **list, struct ael_extension *newmem);
static void fix_gotos_in_extensions(struct ael_extension *exten);
static pval *get_extension_or_contxt(pval *p);
static pval *get_contxt(pval *p);
static void remove_spaces_before_equals(char *str);
static void substitute_commas(char *str);
/* I am adding this code to substitute commas with vertbars in the args to apps */
static void substitute_commas(char *str)
{
char *p = str;
while (p && *p)
{
if (*p == ',' && ((p != str && *(p-1) != '\\')
|| p == str))
*p = '|';
if (*p == '\\' && *(p+1) == ',') { /* learning experience: the '\,' is turned into just ',' by pbx_config; So we need to do the same */
char *q = p;
while (*q) { /* move the ',' and everything after it up 1 char */
*q = *(q+1);
q++;
}
}
p++;
}
}
/* PRETTY PRINTER FOR AEL: ============================================================================= */
static void print_pval(FILE *fin, pval *item, int depth)
{
int i;
pval *lp;
for (i=0; i<depth; i++) {
fprintf(fin, "\t"); /* depth == indentation */
}
switch ( item->type ) {
case PV_WORD:
fprintf(fin,"%s;\n", item->u1.str); /* usually, words are encapsulated in something else */
break;
case PV_MACRO:
fprintf(fin,"macro %s(", item->u1.str);
for (lp=item->u2.arglist; lp; lp=lp->next) {
if (lp != item->u2.arglist )
fprintf(fin,", ");
fprintf(fin,"%s", lp->u1.str);
}
fprintf(fin,") {\n");
print_pval_list(fin,item->u3.macro_statements,depth+1);
for (i=0; i<depth; i++) {
fprintf(fin,"\t"); /* depth == indentation */
}
fprintf(fin,"};\n\n");
break;
case PV_CONTEXT:
if ( item->u3.abstract )
fprintf(fin,"abstract context %s {\n", item->u1.str);
else
fprintf(fin,"context %s {\n", item->u1.str);
print_pval_list(fin,item->u2.statements,depth+1);
for (i=0; i<depth; i++) {
fprintf(fin,"\t"); /* depth == indentation */
}
fprintf(fin,"};\n\n");
break;
case PV_MACRO_CALL:
fprintf(fin,"&%s(", item->u1.str);
for (lp=item->u2.arglist; lp; lp=lp->next) {
if ( lp != item->u2.arglist )
fprintf(fin,", ");
fprintf(fin,"%s", lp->u1.str);
}
fprintf(fin,");\n");
break;
case PV_APPLICATION_CALL:
fprintf(fin,"%s(", item->u1.str);
for (lp=item->u2.arglist; lp; lp=lp->next) {
if ( lp != item->u2.arglist )
fprintf(fin,",");
fprintf(fin,"%s", lp->u1.str);
}
fprintf(fin,");\n");
break;
case PV_CASE:
fprintf(fin,"case %s:\n", item->u1.str);
print_pval_list(fin,item->u2.statements, depth+1);
break;
case PV_PATTERN:
fprintf(fin,"pattern %s:\n", item->u1.str);
print_pval_list(fin,item->u2.statements, depth+1);
break;
case PV_DEFAULT:
fprintf(fin,"default:\n");
print_pval_list(fin,item->u2.statements, depth+1);
break;
case PV_CATCH:
fprintf(fin,"catch %s {\n", item->u1.str);
print_pval_list(fin,item->u2.statements, depth+1);
for (i=0; i<depth; i++) {
fprintf(fin,"\t"); /* depth == indentation */
}
fprintf(fin,"};\n");
break;
case PV_SWITCHES:
fprintf(fin,"switc
没有合适的资源?快使用搜索试试~ 我知道了~
pbx.rar_asterisk_pbx spo_pbx 源码
共117个文件
ael:46个
ael2:14个
c:10个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 69 浏览量
2022-09-19
14:34:05
上传
评论
收藏 225KB RAR 举报
温馨提示
Asterisk中pbx交换核心的源码 pbx是Asterisk的核心部分 重要哦
资源详情
资源评论
资源推荐
收起资源包目录
pbx.rar_asterisk_pbx spo_pbx 源码 (117个子文件)
extensions.ael 73KB
extensions.ael 73KB
extensions.ael 18KB
extensions.ael 18KB
extensions.ael 11KB
extensions.ael 9KB
extensions.ael 3KB
extensions.ael 2KB
extensions.ael 2KB
extensions.ael 988B
extensions.ael 869B
extensions.ael 812B
extensions.ael 267B
extensions.ael 230B
extensions.ael 225B
extensions.ael 223B
extensions.ael 213B
extensions.ael 208B
extensions.ael 164B
c.ael 110B
c.ael 106B
extensions.ael 92B
extensions.ael 90B
f.ael 82B
f.ael 82B
extensions.ael 63B
extensions.ael 59B
qq.ael 45B
qq.ael 45B
j.ael 43B
j.ael 43B
e.ael 42B
h.ael 42B
e.ael 42B
h.ael 42B
b.ael 42B
b.ael 42B
g.ael 41B
a.ael 41B
a.ael 41B
i.ael 41B
d.ael 41B
d.ael 41B
g.ael 41B
i.ael 41B
extensions.ael 25B
ref.ael-ntest10 25KB
ref.ael-ntest12 3KB
ref.ael-ntest22 5KB
ref.ael-ntest23 2KB
ref.ael-ntest9 2KB
ref.ael-test1 2KB
ref.ael-test11 2KB
ref.ael-test14 1KB
ref.ael-test15 1KB
ref.ael-test16 1KB
ref.ael-test18 1KB
ref.ael-test19 2KB
ref.ael-test2 3KB
ref.ael-test20 1KB
ref.ael-test3 2KB
ref.ael-test4 3KB
ref.ael-test5 1KB
ref.ael-test6 2KB
ref.ael-test7 2KB
ref.ael-test8 1KB
ref.ael-vtest13 107KB
ref.ael-vtest17 2KB
ref.ael-vtest21 182B
ref.ael-vtest25 200B
telemarket_torture.ael2 27KB
telemarket_torture.ael2 27KB
apptest.ael2 3KB
apptest.ael2 3KB
include2.ael2 98B
include2.ael2 98B
include4.ael2 87B
include4.ael2 87B
include1.ael2 78B
include1.ael2 78B
include3.ael2 57B
include3.ael2 57B
include5.ael2 56B
include5.ael2 56B
pbx_ael.c 145KB
pbx_dundi.c 144KB
ael_lex.c 97KB
ael.tab.c 96KB
pbx_config.c 70KB
dundi-parser.c 23KB
pbx_spool.c 15KB
pbx_gtkconsole.c 13KB
pbx_realtime.c 7KB
pbx_loopback.c 6KB
ael.flex 23KB
ael.tab.h 4KB
dundi-parser.h 3KB
Makefile 2KB
.pbx_ael.makeopts 0B
.pbx_gtkconsole.makeopts 0B
共 117 条
- 1
- 2
weixin_42651887
- 粉丝: 76
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0