Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
ael_structs.h File Reference

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

#include "asterisk/paths.h"
#include "pval.h"
Include dependency graph for ael_structs.h:
This graph shows which files directly or indirectly include this file:

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

◆ QUAD_MAX

#define QUAD_MAX   (0x7fffffffffffffffLL)

Definition at line 54 of file ael_structs.h.

◆ QUAD_MIN

#define QUAD_MIN   (-0x7fffffffffffffffLL-1)

Definition at line 51 of file ael_structs.h.

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 70 of file ael_structs.h.

Typedef Documentation

◆ yyscan_t

typedef void* yyscan_t

Definition at line 71 of file ael_structs.h.

Enumeration Type Documentation

◆ ael_priority_type

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

◆ ael2_parse()

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

Definition at line 3360 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(), include_stack_index, io, LOG_ERROR, LOG_WARNING, malloc(), my_col, my_file, my_lineno, prev_word, parse_io::pval, parse_io::scanner, strdup, and parse_io::syntax_error_count.

Referenced by pbx_load_module().

3361 {
3362  struct pval *pvalue;
3363  struct parse_io *io;
3364  char *buffer;
3365  struct stat stats;
3366  FILE *fin;
3367 
3368  /* extern int ael_yydebug; */
3369 
3370  io = calloc(sizeof(struct parse_io),1);
3371  /* reset the global counters */
3372  prev_word = 0;
3373  my_lineno = 1;
3375  my_col = 0;
3376  /* ael_yydebug = 1; */
3377  ael_yylex_init(&io->scanner);
3378  fin = fopen(filename,"r");
3379  if ( !fin ) {
3380  ast_log(LOG_ERROR,"File %s could not be opened\n", filename);
3381  *errors = 1;
3382  return 0;
3383  }
3384  if (my_file)
3385  free(my_file);
3386  my_file = strdup(filename);
3387  if (stat(filename, &stats)) {
3388  ast_log(LOG_WARNING, "failed to populate stats from file '%s'\n", filename);
3389  }
3390  buffer = (char*)malloc(stats.st_size+2);
3391  if (fread(buffer, 1, stats.st_size, fin) != stats.st_size) {
3392  ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno));
3393  }
3394  buffer[stats.st_size]=0;
3395  fclose(fin);
3396 
3397  ael_yy_scan_string (buffer ,io->scanner);
3398  ael_yyset_lineno(1 , io->scanner);
3399 
3400  /* ael_yyset_in (fin , io->scanner); OLD WAY */
3401 
3402  ael_yyparse(io);
3403 
3404 
3405  pvalue = io->pval;
3406  *errors = io->syntax_error_count;
3407 
3409  free(buffer);
3410  free(io);
3411 
3412  return pvalue;
3413 }
struct pval * pval
Definition: ael_structs.h:77
#define LOG_WARNING
Definition: logger.h:274
char * my_file
Definition: ael_lex.c:888
static int my_col
Definition: ael_lex.c:887
yyscan_t scanner
Definition: ael_structs.h:78
#define calloc(a, b)
Definition: astmm.h:157
YY_BUFFER_STATE ael_yy_scan_string(yyconst char *yy_str, yyscan_t yyscanner)
Definition: ael_lex.c:2823
char * malloc()
#define ast_log
Definition: astobj2.c:42
int ael_yylex_init(yyscan_t *scanner)
Definition: ael_lex.c:3070
void free()
static struct io_context * io
Definition: chan_ooh323.c:401
void ael_yyset_lineno(int line_number, yyscan_t yyscanner)
Definition: ael_lex.c:2981
static int include_stack_index
Definition: ael_lex.c:919
int syntax_error_count
Definition: ael_structs.h:79
Definition: pval.h:48
static int my_lineno
Definition: ael_lex.c:886
#define LOG_ERROR
Definition: logger.h:285
int errno
char * prev_word
Definition: ael_lex.c:889
int ael_yyparse(struct parse_io *)
#define strdup(a)
Definition: astmm.h:165
int ael_yylex_destroy(yyscan_t yyscanner)
Definition: ael_lex.c:3161

◆ ael2_print()

void ael2_print ( char *  fname,
pval tree 
)

Definition at line 382 of file pval.c.

References ast_log, item, LOG_ERROR, print_pval_list(), traverse_pval_item_template(), and traverse_pval_template().

Referenced by main().

383 {
384  FILE *fin = fopen(fname,"w");
385  if ( !fin ) {
386  ast_log(LOG_ERROR, "Couldn't open %s for writing.\n", fname);
387  return;
388  }
389  print_pval_list(fin, tree, 0);
390  fclose(fin);
391 }
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
static void print_pval_list(FILE *fin, pval *item, int depth)
Definition: pval.c:373

◆ ael2_semantic_check()

void ael2_semantic_check ( pval item,
int *  errs,
int *  warns,
int *  notes 
)

Definition at line 2885 of file pval.c.

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

Referenced by pbx_load_module().

2886 {
2887 
2888 #ifdef AAL_ARGCHECK
2889  int argapp_errs =0;
2890  char *rfilename;
2891 #endif
2892  struct argapp *apps=0;
2893 
2894  if (!item)
2895  return; /* don't check an empty tree */
2896 #ifdef AAL_ARGCHECK
2897  rfilename = ast_alloca(10 + strlen(ast_config_AST_VAR_DIR));
2898  sprintf(rfilename, "%s/applist", ast_config_AST_VAR_DIR);
2899 
2900  apps = argdesc_parse(rfilename, &argapp_errs); /* giveth */
2901 #endif
2902  current_db = item;
2903  errs = warns = notes = 0;
2904 
2906  check_pval(item, apps, 0);
2907 
2908 #ifdef AAL_ARGCHECK
2909  argdesc_destroy(apps); /* taketh away */
2910 #endif
2911  current_db = 0;
2912 
2913  *arg_errs = errs;
2914  *arg_warns = warns;
2915  *arg_notes = notes;
2916 }
static int errs
Definition: pval.c:65
Registered applications container.
Definition: pbx_app.c:67
static struct aco_type item
Definition: test_config.c:1463
Definition: pval.h:110
static int notes
Definition: pval.c:66
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:290
static int warns
Definition: pval.c:65
const char * ast_config_AST_VAR_DIR
Definition: options.c:157
static pval * current_db
Definition: pval.c:72
static void check_context_names(void)
Definition: pval.c:2310
void check_pval(pval *item, struct argapp *apps, int in_globals)
Definition: pval.c:2865

◆ destroy_pval()

void destroy_pval ( pval item)

Definition at line 4940 of file pval.c.

Referenced by yydestruct(), and yyparse().

4941 {
4942  pval *i,*nxt;
4943 
4944  for (i=item; i; i=nxt) {
4945  nxt = i->next;
4946 
4947  destroy_pval_item(i);
4948  }
4949 }
void destroy_pval_item(pval *item)
Definition: pval.c:4672
Definition: pval.h:48
struct pval * next
Definition: pval.h:93

◆ linku1()

pval* linku1 ( pval head,
pval tail 
)

Definition at line 5922 of file pval.c.

5923 {
5924  if (!head)
5925  return tail;
5926  if (tail) {
5927  if (!head->next) {
5928  head->next = tail;
5929  } else {
5930  head->u1_last->next = tail;
5931  }
5932  head->u1_last = tail;
5933  tail->prev = head; /* the dad link only points to containers */
5934  }
5935  return head;
5936 }
struct pval * u1_last
Definition: pval.h:64
struct pval * prev
Definition: pval.h:97
struct pval * next
Definition: pval.h:93

◆ npval()

struct pval * npval ( pvaltype  type,
int  first_line,
int  last_line,
int  first_column,
int  last_column 
)

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

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

Referenced by npval2(), and yyparse().

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

Variable Documentation

◆ prev_word

char* prev_word

Definition at line 889 of file ael_lex.c.

Referenced by ael2_parse(), c_prevword(), while(), yydestruct(), and yyparse().