Wed Jan 8 2020 09:49:52

Asterisk developer's documentation


ael_structs.h File Reference

Structures for AEL - the Asterisk extension language. More...

#include "asterisk/paths.h"
#include "pval.h"

Go to the source code of this file.

Data Structures

struct  ael_extension
 
struct  ael_priority
 
struct  parse_io
 

Macros

#define QUAD_MAX   (0x7fffffffffffffffLL)
 
#define QUAD_MIN   (-0x7fffffffffffffffLL-1)
 
#define YY_TYPEDEF_YY_SCANNER_T
 

Typedefs

typedef void * yyscan_t
 

Enumerations

enum  ael_priority_type {
  AEL_APPCALL, AEL_CONTROL1, AEL_FOR_CONTROL, AEL_IF_CONTROL,
  AEL_IFTIME_CONTROL, AEL_RAND_CONTROL, AEL_LABEL, AEL_RETURN
}
 

Functions

struct pvalael2_parse (char *fname, int *errs)
 
void ael2_print (char *fname, pval *tree)
 
void ael2_semantic_check (pval *item, int *errs, int *warns, int *notes)
 
void destroy_pval (pval *item)
 
pvallinku1 (pval *head, pval *tail)
 
pvalnpval (pvaltype type, int first_line, int last_line, int first_column, int last_column)
 

Variables

char * prev_word
 

Detailed Description

Structures for AEL - the Asterisk extension language.

pbx_ael.c

Todo:
document this file (ael.h)

Definition in file ael_structs.h.

Macro Definition Documentation

#define QUAD_MAX   (0x7fffffffffffffffLL)

Definition at line 54 of file ael_structs.h.

#define QUAD_MIN   (-0x7fffffffffffffffLL-1)

Definition at line 51 of file ael_structs.h.

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 70 of file ael_structs.h.

Typedef Documentation

typedef void* yyscan_t

Definition at line 71 of file ael_structs.h.

Enumeration Type Documentation

Enumerator
AEL_APPCALL 
AEL_CONTROL1 
AEL_FOR_CONTROL 
AEL_IF_CONTROL 
AEL_IFTIME_CONTROL 
AEL_RAND_CONTROL 
AEL_LABEL 
AEL_RETURN 

Definition at line 84 of file ael_structs.h.

Function Documentation

struct pval* ael2_parse ( char *  fname,
int *  errs 
)

Definition at line 3344 of file ael_lex.c.

References ael_yy_scan_string(), ael_yylex_destroy(), ael_yylex_init(), ael_yyparse(), ael_yyset_lineno(), ast_log(), calloc, errno, free, io, LOG_ERROR, malloc, parse_io::pval, parse_io::scanner, strdup, and parse_io::syntax_error_count.

Referenced by pbx_load_module().

3345 {
3346  struct pval *pvalue;
3347  struct parse_io *io;
3348  char *buffer;
3349  struct stat stats;
3350  FILE *fin;
3351 
3352  /* extern int ael_yydebug; */
3353 
3354  io = calloc(sizeof(struct parse_io),1);
3355  /* reset the global counters */
3356  prev_word = 0;
3357  my_lineno = 1;
3359  my_col = 0;
3360  /* ael_yydebug = 1; */
3361  ael_yylex_init(&io->scanner);
3362  fin = fopen(filename,"r");
3363  if ( !fin ) {
3364  ast_log(LOG_ERROR,"File %s could not be opened\n", filename);
3365  *errors = 1;
3366  return 0;
3367  }
3368  if (my_file)
3369  free(my_file);
3370  my_file = strdup(filename);
3371  stat(filename, &stats);
3372  buffer = (char*)malloc(stats.st_size+2);
3373  if (fread(buffer, 1, stats.st_size, fin) != stats.st_size) {
3374  ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
3375  }
3376  buffer[stats.st_size]=0;
3377  fclose(fin);
3378 
3379  ael_yy_scan_string (buffer ,io->scanner);
3380  ael_yyset_lineno(1 , io->scanner);
3381 
3382  /* ael_yyset_in (fin , io->scanner); OLD WAY */
3383 
3384  ael_yyparse(io);
3385 
3386 
3387  pvalue = io->pval;
3388  *errors = io->syntax_error_count;
3389 
3391  free(buffer);
3392  free(io);
3393 
3394  return pvalue;
3395 }
#define malloc(a)
Definition: astmm.h:88
static struct io_context * io
Definition: chan_gtalk.c:228
struct pval * pval
Definition: ael_structs.h:77
static int my_col
Definition: ael_lex.c:872
yyscan_t scanner
Definition: ael_structs.h:78
#define calloc(a, b)
Definition: astmm.h:79
YY_BUFFER_STATE ael_yy_scan_string(yyconst char *yy_str, yyscan_t yyscanner)
Definition: ael_lex.c:2807
int ael_yylex_init(yyscan_t *scanner)
Definition: ael_lex.c:3054
void ael_yyset_lineno(int line_number, yyscan_t yyscanner)
Definition: ael_lex.c:2965
static int include_stack_index
Definition: ael_lex.c:904
char * my_file
Definition: ael_lex.c:873
int syntax_error_count
Definition: ael_structs.h:79
Definition: pval.h:48
static int my_lineno
Definition: ael_lex.c:871
#define LOG_ERROR
Definition: logger.h:155
#define free(a)
Definition: astmm.h:94
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
char * prev_word
Definition: ael_lex.c:874
int ael_yyparse(struct parse_io *)
#define strdup(a)
Definition: astmm.h:106
int ael_yylex_destroy(yyscan_t yyscanner)
Definition: ael_lex.c:3145
void ael2_print ( char *  fname,
pval tree 
)

Definition at line 384 of file pval.c.

References ast_log(), LOG_ERROR, and print_pval_list().

385 {
386  FILE *fin = fopen(fname,"w");
387  if ( !fin ) {
388  ast_log(LOG_ERROR, "Couldn't open %s for writing.\n", fname);
389  return;
390  }
391  print_pval_list(fin, tree, 0);
392  fclose(fin);
393 }
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void print_pval_list(FILE *fin, pval *item, int depth)
Definition: pval.c:375
void ael2_semantic_check ( pval item,
int *  errs,
int *  warns,
int *  notes 
)

Definition at line 2892 of file pval.c.

References ast_alloca, ast_config_AST_VAR_DIR, check_context_names(), check_pval(), errs, notes, and warns.

Referenced by pbx_load_module().

2893 {
2894 
2895 #ifdef AAL_ARGCHECK
2896  int argapp_errs =0;
2897  char *rfilename;
2898 #endif
2899  struct argapp *apps=0;
2900 
2901  if (!item)
2902  return; /* don't check an empty tree */
2903 #ifdef AAL_ARGCHECK
2904  rfilename = ast_alloca(10 + strlen(ast_config_AST_VAR_DIR));
2905  sprintf(rfilename, "%s/applist", ast_config_AST_VAR_DIR);
2906 
2907  apps = argdesc_parse(rfilename, &argapp_errs); /* giveth */
2908 #endif
2909  current_db = item;
2910  errs = warns = notes = 0;
2911 
2913  check_pval(item, apps, 0);
2914 
2915 #ifdef AAL_ARGCHECK
2916  argdesc_destroy(apps); /* taketh away */
2917 #endif
2918  current_db = 0;
2919 
2920  *arg_errs = errs;
2921  *arg_warns = warns;
2922  *arg_notes = notes;
2923 }
void check_pval(pval *item, struct argapp *apps, int in_globals)
Definition: pval.c:2872
static int errs
Definition: pval.c:67
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: utils.h:653
Definition: pbx.c:1301
Definition: pval.h:110
static int notes
Definition: pval.c:68
static int warns
Definition: pval.c:67
const char * ast_config_AST_VAR_DIR
Definition: asterisk.c:261
static pval * current_db
Definition: pval.c:74
static void check_context_names(void)
Definition: pval.c:2317
void destroy_pval ( pval item)

Definition at line 4979 of file pval.c.

Referenced by destroy_pval_item(), pbx_load_module(), and switch().

4980 {
4981  pval *i,*nxt;
4982 
4983  for (i=item; i; i=nxt) {
4984  nxt = i->next;
4985 
4986  destroy_pval_item(i);
4987  }
4988 }
void destroy_pval_item(pval *item)
Definition: pval.c:4711
Definition: pval.h:48
struct pval * next
Definition: pval.h:93
pval* linku1 ( pval head,
pval tail 
)

Definition at line 5926 of file pval.c.

Referenced by pvalAppCallAddArg(), pvalCasePatDefAddStatement(), pvalContextAddStatement(), pvalESwitchesAddSwitch(), pvalGlobalsAddStatement(), pvalIncludesAddInclude(), pvalIncludesAddIncludeWithTimeConstraints(), pvalMacroAddArg(), pvalMacroAddStatement(), pvalMacroCallAddArg(), pvalStatementBlockAddStatement(), pvalSwitchAddCase(), pvalSwitchesAddSwitch(), pvalTopLevAddObject(), and switch().

5927 {
5928  if (!head)
5929  return tail;
5930  if (tail) {
5931  if (!head->next) {
5932  head->next = tail;
5933  } else {
5934  head->u1_last->next = tail;
5935  }
5936  head->u1_last = tail;
5937  tail->prev = head; /* the dad link only points to containers */
5938  }
5939  return head;
5940 }
struct pval * u1_last
Definition: pval.h:64
struct pval * prev
Definition: pval.h:97
struct pval * next
Definition: pval.h:93
struct pval * npval ( pvaltype  type,
int  first_line,
int  last_line,
int  first_column,
int  last_column 
)

Definition at line 3966 of file ael.tab.c.

References calloc, pval::endcol, pval::endline, pval::filename, first_column, first_line, S_OR, pval::startcol, pval::startline, strdup, pval::type, and type.

Referenced by npval2(), and switch().

3968 {
3969  pval *z = calloc(1, sizeof(struct pval));
3970  z->type = type;
3971  z->startline = first_line;
3972  z->endline = last_line;
3973  z->startcol = first_column;
3974  z->endcol = last_column;
3975  z->filename = strdup(S_OR(my_file, "<none>"));
3976  return z;
3977 }
yylloc first_column
Definition: ast_expr2.c:1858
int startline
Definition: pval.h:51
#define calloc(a, b)
Definition: astmm.h:79
char * filename
Definition: pval.h:55
char * my_file
Definition: ael_lex.c:873
Definition: pval.h:48
int endcol
Definition: pval.h:54
pvaltype type
Definition: pval.h:50
static const char type[]
Definition: chan_nbs.c:57
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:77
#define strdup(a)
Definition: astmm.h:106
int endline
Definition: pval.h:52
int startcol
Definition: pval.h:53
yylloc first_line
Definition: ast_expr2.c:1857

Variable Documentation

char* prev_word

Definition at line 874 of file ael_lex.c.

Referenced by c_prevword(), and switch().