diff options
Diffstat (limited to 'res')
77 files changed, 970 insertions, 929 deletions
diff --git a/res/Makefile b/res/Makefile index 2b688edc4..5a8f35a85 100644 --- a/res/Makefile +++ b/res/Makefile @@ -1,6 +1,6 @@ # # Asterisk -- An open source telephony toolkit. -# +# # Makefile for resource modules # # Copyright (C) 1999-2006, Digium, Inc. diff --git a/res/ael/ael.flex b/res/ael/ael.flex index 0b6ec32f1..8ea881512 100644 --- a/res/ael/ael.flex +++ b/res/ael/ael.flex @@ -269,11 +269,11 @@ includes { STORE_POS; return KW_INCLUDES;} [ ]+ { my_col += yyleng; } [\t]+ { my_col += (yyleng*8)-(my_col%8); } -({KEYWORD}?[-a-zA-Z0-9'"_/.\<\>\*\+!$#\[\]]|{HIBIT}|(\\.)|(\$\{)|(\$\[)) { - /* boy did I open a can of worms when I changed the lexical token "word". +({KEYWORD}?[-a-zA-Z0-9'"_/.\<\>\*\+!$#\[\]]|{HIBIT}|(\\.)|(\$\{)|(\$\[)) { + /* boy did I open a can of worms when I changed the lexical token "word". all the above keywords can be used as a beginning to a "word".- - before, a "word" would match a longer sequence than the above - keywords, and all would be well. But now "word" is a single char + before, a "word" would match a longer sequence than the above + keywords, and all would be well. But now "word" is a single char and feeds into a statemachine sort of sequence from there on. So... I added the {KEYWORD}? to the beginning of the word match sequence */ @@ -344,7 +344,7 @@ includes { STORE_POS; return KW_INCLUDES;} } } -<curlystate>{NOPARENS}[\(\[\{] { +<curlystate>{NOPARENS}[\(\[\{] { char c = yytext[yyleng-1]; if (c == '{') parencount2++; @@ -352,7 +352,7 @@ includes { STORE_POS; return KW_INCLUDES;} yymore(); } -<curlystate>{NOPARENS}[\]\)] { +<curlystate>{NOPARENS}[\]\)] { char c = yytext[yyleng-1]; if ( pbcpop2(c)) { /* error */ STORE_LOC; @@ -387,7 +387,7 @@ includes { STORE_POS; return KW_INCLUDES;} } } -<brackstate>{NOPARENS}[\(\[\{] { +<brackstate>{NOPARENS}[\(\[\{] { char c = yytext[yyleng-1]; if (c == '[') parencount3++; @@ -395,7 +395,7 @@ includes { STORE_POS; return KW_INCLUDES;} yymore(); } -<brackstate>{NOPARENS}[\}\)] { +<brackstate>{NOPARENS}[\}\)] { char c = yytext[yyleng-1]; if ( pbcpop3(c)) { /* error */ STORE_LOC; @@ -580,7 +580,7 @@ includes { STORE_POS; return KW_INCLUDES;} glob_t globbuf; /* the current globbuf */ int globbuf_pos = -1; /* where we are in the current globbuf */ globbuf.gl_offs = 0; /* initialize it to silence gcc */ - + p1 = strchr(yytext,'"'); p2 = strrchr(yytext,'"'); if ( include_stack_index >= MAX_INCLUDE_DEPTH ) { @@ -625,8 +625,8 @@ includes { STORE_POS; return KW_INCLUDES;} yy_delete_buffer( YY_CURRENT_BUFFER, yyscanner ); include_stack[include_stack_index-1].globbuf_pos++; setup_filestack(fnamebuf, sizeof(fnamebuf), &include_stack[include_stack_index-1].globbuf, include_stack[include_stack_index-1].globbuf_pos, yyscanner, 0); - /* finish this */ - + /* finish this */ + } else { if (include_stack[include_stack_index].fname) { free(include_stack[include_stack_index].fname); @@ -641,7 +641,7 @@ includes { STORE_POS; return KW_INCLUDES;} } else { globfree(&include_stack[include_stack_index].globbuf); include_stack[include_stack_index].globbuf_pos = -1; - + yy_delete_buffer( YY_CURRENT_BUFFER, yyscanner ); yy_switch_to_buffer(include_stack[include_stack_index].bufstate, yyscanner ); my_lineno = include_stack[include_stack_index].lineno; @@ -811,7 +811,7 @@ struct pval *ael2_parse(char *filename, int *errors) buffer = (char*)malloc(stats.st_size+2); if (fread(buffer, 1, stats.st_size, fin) != stats.st_size) { ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno)); - } + } buffer[stats.st_size]=0; fclose(fin); @@ -883,7 +883,7 @@ static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, buffer = (char*)malloc(stats.st_size+1); if (fread(buffer, 1, stats.st_size, in1) != stats.st_size) { ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno)); - } + } buffer[stats.st_size] = 0; ast_debug(1, " --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size); fclose(in1); diff --git a/res/ael/ael.tab.c b/res/ael/ael.tab.c index c838d797c..87370a190 100644 --- a/res/ael/ael.tab.c +++ b/res/ael/ael.tab.c @@ -1,19 +1,19 @@ /* A Bison parser, made by GNU Bison 2.5. */ /* Bison implementation for Yacc-like parsers in C - + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -120,7 +120,7 @@ static void set_dads(pval *dad, pval *child_list); void reset_parencount(yyscan_t yyscanner); void reset_semicount(yyscan_t yyscanner); void reset_argcount(yyscan_t yyscanner ); - + #define YYLEX_PARAM ((struct parse_io *)parseio)->scanner #define YYERROR_VERBOSE 1 @@ -2897,7 +2897,7 @@ yyreduce: free((yyvsp[(1) - (2)].str)); free((yyvsp[(2) - (2)].str)); prev_word = (yyval.str); - } + } } break; @@ -4002,9 +4002,7 @@ static pval *nword(char *string, YYLTYPE *pos) static void set_dads(struct pval *dad, struct pval *child_list) { struct pval *t; - + for(t=child_list;t;t=t->next) /* simple stuff */ t->dad = dad; } - - diff --git a/res/ael/ael.tab.h b/res/ael/ael.tab.h index 93fc23d0c..1647649a8 100644 --- a/res/ael/ael.tab.h +++ b/res/ael/ael.tab.h @@ -1,19 +1,19 @@ /* A Bison parser, made by GNU Bison 2.5. */ /* Bison interface for Yacc-like parsers in C - + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -118,6 +118,3 @@ typedef struct YYLTYPE # define YYLTYPE_IS_DECLARED 1 # define YYLTYPE_IS_TRIVIAL 1 #endif - - - diff --git a/res/ael/ael.y b/res/ael/ael.y index 27e04c583..c157c6cb7 100644 --- a/res/ael/ael.y +++ b/res/ael/ael.y @@ -43,7 +43,7 @@ static void set_dads(pval *dad, pval *child_list); void reset_parencount(yyscan_t yyscanner); void reset_semicount(yyscan_t yyscanner); void reset_argcount(yyscan_t yyscanner ); - + #define YYLEX_PARAM ((struct parse_io *)parseio)->scanner #define YYERROR_VERBOSE 1 @@ -211,7 +211,7 @@ context : opt_abstract KW_CONTEXT context_name LC elements RC { $$->u1.str = $3; $$->u2.statements = $5; set_dads($$,$5); - $$->u3.abstract = $1;} + $$->u3.abstract = $1;} ; /* optional "abstract" keyword XXX there is no regression test for this */ @@ -422,7 +422,7 @@ word3_list : word { $$ = $1;} free($1); free($2); prev_word = $$; - } + } } | word word word { if (asprintf(&($$), "%s%s%s", $1, $2, $3) < 0) { @@ -545,7 +545,7 @@ statement : LC statements RC { opt_else : KW_ELSE statement { $$ = $2; } | { $$ = NULL ; } - + target : goto_word { $$ = nword($1, &@1); } | goto_word BAR goto_word { $$ = nword($1, &@1); @@ -884,8 +884,7 @@ static pval *nword(char *string, YYLTYPE *pos) static void set_dads(struct pval *dad, struct pval *child_list) { struct pval *t; - + for(t=child_list;t;t=t->next) /* simple stuff */ t->dad = dad; } - diff --git a/res/ael/ael_lex.c b/res/ael/ael_lex.c index 6aec03bee..ad79cf257 100644 --- a/res/ael/ael_lex.c +++ b/res/ael/ael_lex.c @@ -36,7 +36,7 @@ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -53,7 +53,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; @@ -186,7 +186,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ @@ -248,7 +248,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -1027,9 +1027,9 @@ static int yy_init_globals (yyscan_t yyscanner ); /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ # define yylval yyg->yylval_r - + # define yylloc yyg->yylloc_r - + int ael_yylex_init (yyscan_t* scanner); int ael_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); @@ -1068,9 +1068,9 @@ YYSTYPE * ael_yyget_lval (yyscan_t yyscanner ); void ael_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); YYLTYPE *ael_yyget_lloc (yyscan_t yyscanner ); - + void ael_yyset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); - + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -1084,7 +1084,7 @@ extern int ael_yywrap (yyscan_t yyscanner ); #endif static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner); - + #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); #endif @@ -1562,11 +1562,11 @@ YY_RULE_SETUP case 51: YY_RULE_SETUP #line 272 "ael.flex" -{ - /* boy did I open a can of worms when I changed the lexical token "word". +{ + /* boy did I open a can of worms when I changed the lexical token "word". all the above keywords can be used as a beginning to a "word".- - before, a "word" would match a longer sequence than the above - keywords, and all would be well. But now "word" is a single char + before, a "word" would match a longer sequence than the above + keywords, and all would be well. But now "word" is a single char and feeds into a statemachine sort of sequence from there on. So... I added the {KEYWORD}? to the beginning of the word match sequence */ @@ -1668,7 +1668,7 @@ case 59: /* rule 59 can match eol */ YY_RULE_SETUP #line 347 "ael.flex" -{ +{ char c = yytext[yyleng-1]; if (c == '{') parencount2++; @@ -1680,7 +1680,7 @@ case 60: /* rule 60 can match eol */ YY_RULE_SETUP #line 355 "ael.flex" -{ +{ char c = yytext[yyleng-1]; if ( pbcpop2(c)) { /* error */ STORE_LOC; @@ -1722,7 +1722,7 @@ case 62: /* rule 62 can match eol */ YY_RULE_SETUP #line 390 "ael.flex" -{ +{ char c = yytext[yyleng-1]; if (c == '[') parencount3++; @@ -1734,7 +1734,7 @@ case 63: /* rule 63 can match eol */ YY_RULE_SETUP #line 398 "ael.flex" -{ +{ char c = yytext[yyleng-1]; if ( pbcpop3(c)) { /* error */ STORE_LOC; @@ -1961,7 +1961,7 @@ YY_RULE_SETUP glob_t globbuf; /* the current globbuf */ int globbuf_pos = -1; /* where we are in the current globbuf */ globbuf.gl_offs = 0; /* initialize it to silence gcc */ - + p1 = strchr(yytext,'"'); p2 = strrchr(yytext,'"'); if ( include_stack_index >= MAX_INCLUDE_DEPTH ) { @@ -2014,8 +2014,8 @@ case YY_STATE_EOF(brackstate): ael_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner ); include_stack[include_stack_index-1].globbuf_pos++; setup_filestack(fnamebuf, sizeof(fnamebuf), &include_stack[include_stack_index-1].globbuf, include_stack[include_stack_index-1].globbuf_pos, yyscanner, 0); - /* finish this */ - + /* finish this */ + } else { if (include_stack[include_stack_index].fname) { free(include_stack[include_stack_index].fname); @@ -2030,7 +2030,7 @@ case YY_STATE_EOF(brackstate): } else { globfree(&include_stack[include_stack_index].globbuf); include_stack[include_stack_index].globbuf_pos = -1; - + ael_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner ); ael_yy_switch_to_buffer(include_stack[include_stack_index].bufstate,yyscanner ); my_lineno = include_stack[include_stack_index].lineno; @@ -2568,7 +2568,7 @@ static void ael_yy_load_buffer_state (yyscan_t yyscanner) YY_BUFFER_STATE ael_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) ael_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in ael_yy_create_buffer()" ); @@ -2612,7 +2612,7 @@ static void ael_yy_load_buffer_state (yyscan_t yyscanner) #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ - + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a ael_yyrestart() or at EOF. @@ -2638,7 +2638,7 @@ extern int isatty (int ); } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } @@ -2744,9 +2744,9 @@ static void ael_yyensure_buffer_stack (yyscan_t yyscanner) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in ael_yyensure_buffer_stack()" ); - + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_top = 0; return; @@ -2775,12 +2775,12 @@ static void ael_yyensure_buffer_stack (yyscan_t yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE ael_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -2816,7 +2816,7 @@ YY_BUFFER_STATE ael_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yys */ YY_BUFFER_STATE ael_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) { - + return ael_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); } @@ -2833,7 +2833,7 @@ YY_BUFFER_STATE ael_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) ael_yyalloc(n ,yyscanner ); @@ -2901,10 +2901,10 @@ YY_EXTRA_TYPE ael_yyget_extra (yyscan_t yyscanner) int ael_yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -2914,10 +2914,10 @@ int ael_yyget_lineno (yyscan_t yyscanner) int ael_yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -2978,8 +2978,8 @@ void ael_yyset_lineno (int line_number , yyscan_t yyscanner) /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "ael_yyset_lineno called with no buffer" , yyscanner); - + yy_fatal_error( "ael_yyset_lineno called with no buffer" , yyscanner); + yylineno = line_number; } @@ -2993,8 +2993,8 @@ void ael_yyset_column (int column_no , yyscan_t yyscanner) /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "ael_yyset_column called with no buffer" , yyscanner); - + yy_fatal_error( "ael_yyset_column called with no buffer" , yyscanner); + yycolumn = column_no; } @@ -3047,13 +3047,13 @@ YYLTYPE *ael_yyget_lloc (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yylloc; } - + void ael_yyset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylloc = yylloc_param; } - + /* User-visible API */ /* ael_yylex_init is special because it creates the scanner itself, so it is @@ -3101,20 +3101,20 @@ int ael_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals errno = EINVAL; return 1; } - + *ptr_yy_globals = (yyscan_t) ael_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - + if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } - + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - + ael_yyset_extra (yy_user_defined, *ptr_yy_globals); - + return yy_init_globals ( *ptr_yy_globals ); } @@ -3384,7 +3384,7 @@ struct pval *ael2_parse(char *filename, int *errors) buffer = (char*)malloc(stats.st_size+2); if (fread(buffer, 1, stats.st_size, fin) != stats.st_size) { ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno)); - } + } buffer[stats.st_size]=0; fclose(fin); @@ -3456,7 +3456,7 @@ static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, buffer = (char*)malloc(stats.st_size+1); if (fread(buffer, 1, stats.st_size, in1) != stats.st_size) { ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno)); - } + } buffer[stats.st_size] = 0; ast_debug(1, " --Read in included file %s, %d chars\n",fnamebuf2, (int)stats.st_size); fclose(in1); @@ -3486,4 +3486,3 @@ static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, } } } - diff --git a/res/ael/pval.c b/res/ael/pval.c index 07545f659..bbfeb2d76 100644 --- a/res/ael/pval.c +++ b/res/ael/pval.c @@ -20,7 +20,7 @@ /*! \file * * \brief Compile symbolic Asterisk Extension Logic into Asterisk extensions, version 2. - * + * */ /*** MODULEINFO @@ -117,16 +117,16 @@ 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) { @@ -141,7 +141,7 @@ static void print_pval(FILE *fin, pval *item, int depth) } fprintf(fin,"};\n\n"); break; - + case PV_CONTEXT: if ( item->u3.abstract ) fprintf(fin,"abstract context %s {\n", item->u1.str); @@ -153,7 +153,7 @@ static void print_pval(FILE *fin, pval *item, int depth) } fprintf(fin,"};\n\n"); break; - + case PV_MACRO_CALL: fprintf(fin,"&%s(", item->u1.str); for (lp=item->u2.arglist; lp; lp=lp->next) { @@ -163,7 +163,7 @@ static void print_pval(FILE *fin, pval *item, int depth) } fprintf(fin,");\n"); break; - + case PV_APPLICATION_CALL: fprintf(fin,"%s(", item->u1.str); for (lp=item->u2.arglist; lp; lp=lp->next) { @@ -173,22 +173,22 @@ static void print_pval(FILE *fin, pval *item, int depth) } 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); @@ -197,7 +197,7 @@ static void print_pval(FILE *fin, pval *item, int depth) } fprintf(fin,"};\n"); break; - + case PV_SWITCHES: fprintf(fin,"switches {\n"); print_pval_list(fin,item->u1.list,depth+1); @@ -206,7 +206,7 @@ static void print_pval(FILE *fin, pval *item, int depth) } fprintf(fin,"};\n"); break; - + case PV_ESWITCHES: fprintf(fin,"eswitches {\n"); print_pval_list(fin,item->u1.list,depth+1); @@ -215,7 +215,7 @@ static void print_pval(FILE *fin, pval *item, int depth) } fprintf(fin,"};\n"); break; - + case PV_INCLUDES: fprintf(fin,"includes {\n"); for (lp=item->u1.list; lp; lp=lp->next) { @@ -224,7 +224,7 @@ static void print_pval(FILE *fin, pval *item, int depth) } fprintf(fin,"%s", lp->u1.str); /* usually, words are encapsulated in something else */ if (lp->u2.arglist) - fprintf(fin,"|%s|%s|%s|%s", + fprintf(fin,"|%s|%s|%s|%s", lp->u2.arglist->u1.str, lp->u2.arglist->next->u1.str, lp->u2.arglist->next->next->u1.str, @@ -232,13 +232,13 @@ static void print_pval(FILE *fin, pval *item, int depth) ); fprintf(fin,";\n"); /* usually, words are encapsulated in something else */ } - + for (i=0; i<depth; i++) { fprintf(fin,"\t"); /* depth == indentation */ } fprintf(fin,"};\n"); break; - + case PV_STATEMENTBLOCK: fprintf(fin,"{\n"); print_pval_list(fin,item->u1.list, depth+1); @@ -247,15 +247,15 @@ static void print_pval(FILE *fin, pval *item, int depth) } fprintf(fin,"}\n"); break; - + case PV_VARDEC: fprintf(fin,"%s=%s;\n", item->u1.str, item->u2.val); break; - + case PV_LOCALVARDEC: fprintf(fin,"local %s=%s;\n", item->u1.str, item->u2.val); break; - + case PV_GOTO: fprintf(fin,"goto %s", item->u1.list->u1.str); if ( item->u1.list->next ) @@ -264,42 +264,42 @@ static void print_pval(FILE *fin, pval *item, int depth) fprintf(fin,",%s", item->u1.list->next->next->u1.str); fprintf(fin,"\n"); break; - + case PV_LABEL: fprintf(fin,"%s:\n", item->u1.str); break; - + case PV_FOR: fprintf(fin,"for (%s; %s; %s)\n", item->u1.for_init, item->u2.for_test, item->u3.for_inc); print_pval_list(fin,item->u4.for_statements,depth+1); break; - + case PV_WHILE: fprintf(fin,"while (%s)\n", item->u1.str); print_pval_list(fin,item->u2.statements,depth+1); break; - + case PV_BREAK: fprintf(fin,"break;\n"); break; - + case PV_RETURN: fprintf(fin,"return;\n"); break; - + case PV_CONTINUE: fprintf(fin,"continue;\n"); break; - + case PV_RANDOM: case PV_IFTIME: case PV_IF: if ( item->type == PV_IFTIME ) { - - fprintf(fin,"ifTime ( %s|%s|%s|%s )\n", - item->u1.list->u1.str, - item->u1.list->next->u1.str, - item->u1.list->next->next->u1.str, + + fprintf(fin,"ifTime ( %s|%s|%s|%s )\n", + item->u1.list->u1.str, + item->u1.list->next->u1.str, + item->u1.list->next->next->u1.str, item->u1.list->next->next->next->u1.str ); } else if ( item->type == PV_RANDOM ) { @@ -335,7 +335,7 @@ static void print_pval(FILE *fin, pval *item, int depth) print_pval_list(fin,item->u3.else_statements, depth); } break; - + case PV_SWITCH: fprintf(fin,"switch( %s ) {\n", item->u1.str); print_pval_list(fin,item->u2.statements,depth+1); @@ -344,22 +344,22 @@ static void print_pval(FILE *fin, pval *item, int depth) } fprintf(fin,"}\n"); break; - + case PV_EXTENSION: if ( item->u4.regexten ) fprintf(fin, "regexten "); if ( item->u3.hints ) fprintf(fin,"hints(%s) ", item->u3.hints); - + fprintf(fin,"%s => ", item->u1.str); print_pval_list(fin,item->u2.statements,depth+1); fprintf(fin,"\n"); break; - + case PV_IGNOREPAT: fprintf(fin,"ignorepat => %s;\n", item->u1.str); break; - + case PV_GLOBALS: fprintf(fin,"globals {\n"); print_pval_list(fin,item->u1.statements,depth+1); @@ -374,7 +374,7 @@ static void print_pval(FILE *fin, pval *item, int depth) static void print_pval_list(FILE *fin, pval *item, int depth) { pval *i; - + for (i=item; i; i=i->next) { print_pval(fin, i, depth); } @@ -402,12 +402,12 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f but you may not need it */ { pval *lp; - + switch ( item->type ) { case PV_WORD: /* fields: item->u1.str == string associated with this (word). */ break; - + case PV_MACRO: /* fields: item->u1.str == name of macro item->u2.arglist == pval list of PV_WORD arguments of macro, as given by user @@ -417,11 +417,11 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f item->u3.macro_statements == pval list of statements in macro body. */ for (lp=item->u2.arglist; lp; lp=lp->next) { - + } traverse_pval_item_template(item->u3.macro_statements,depth+1); break; - + case PV_CONTEXT: /* fields: item->u1.str == name of context item->u2.statements == pval list of statements in context body @@ -429,7 +429,7 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f */ traverse_pval_item_template(item->u2.statements,depth+1); break; - + case PV_MACRO_CALL: /* fields: item->u1.str == name of macro to call item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user @@ -439,7 +439,7 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f for (lp=item->u2.arglist; lp; lp=lp->next) { } break; - + case PV_APPLICATION_CALL: /* fields: item->u1.str == name of application to call item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user @@ -449,47 +449,47 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f for (lp=item->u2.arglist; lp; lp=lp->next) { } break; - + case PV_CASE: /* fields: item->u1.str == value of case item->u2.statements == pval list of statements under the case */ traverse_pval_item_template(item->u2.statements,depth+1); break; - + case PV_PATTERN: /* fields: item->u1.str == value of case item->u2.statements == pval list of statements under the case */ traverse_pval_item_template(item->u2.statements,depth+1); break; - + case PV_DEFAULT: - /* fields: + /* fields: item->u2.statements == pval list of statements under the case */ traverse_pval_item_template(item->u2.statements,depth+1); break; - + case PV_CATCH: /* fields: item->u1.str == name of extension to catch item->u2.statements == pval list of statements in context body */ traverse_pval_item_template(item->u2.statements,depth+1); break; - + case PV_SWITCHES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list */ traverse_pval_item_template(item->u1.list,depth+1); break; - + case PV_ESWITCHES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list */ traverse_pval_item_template(item->u1.list,depth+1); break; - + case PV_INCLUDES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list item->u2.arglist == pval list of 4 PV_WORD elements for time values @@ -497,37 +497,37 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f traverse_pval_item_template(item->u1.list,depth+1); traverse_pval_item_template(item->u2.arglist,depth+1); break; - + case PV_STATEMENTBLOCK: /* fields: item->u1.list == pval list of statements in block, one per entry in the list */ traverse_pval_item_template(item->u1.list,depth+1); break; - + case PV_LOCALVARDEC: case PV_VARDEC: /* fields: item->u1.str == variable name item->u2.val == variable value to assign */ break; - + case PV_GOTO: /* fields: item->u1.list == pval list of PV_WORD target names, up to 3, in order as given by user. item->u1.list->u1.str == where the data on a PV_WORD will always be. */ - + if ( item->u1.list->next ) ; if ( item->u1.list->next && item->u1.list->next->next ) ; - + break; - + case PV_LABEL: /* fields: item->u1.str == label name */ break; - + case PV_FOR: /* fields: item->u1.for_init == a string containing the initalizer item->u2.for_test == a string containing the loop test @@ -537,7 +537,7 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f */ traverse_pval_item_template(item->u4.for_statements,depth+1); break; - + case PV_WHILE: /* fields: item->u1.str == the while conditional, as supplied by user @@ -545,22 +545,22 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f */ traverse_pval_item_template(item->u2.statements,depth+1); break; - + case PV_BREAK: /* fields: none */ break; - + case PV_RETURN: /* fields: none */ break; - + case PV_CONTINUE: /* fields: none */ break; - + case PV_IFTIME: /* fields: item->u1.list == there are 4 linked PV_WORDs here. @@ -573,7 +573,7 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f traverse_pval_item_template(item->u3.else_statements,depth+1); } break; - + case PV_RANDOM: /* fields: item->u1.str == the random number expression, as supplied by user @@ -586,7 +586,7 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f traverse_pval_item_template(item->u3.else_statements,depth+1); } break; - + case PV_IF: /* fields: item->u1.str == the if conditional, as supplied by user @@ -599,16 +599,16 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f traverse_pval_item_template(item->u3.else_statements,depth+1); } break; - + case PV_SWITCH: /* fields: item->u1.str == the switch expression - item->u2.statements == a pval list of statements in the switch, + item->u2.statements == a pval list of statements in the switch, (will be case statements, most likely!) */ traverse_pval_item_template(item->u2.statements,depth+1); break; - + case PV_EXTENSION: /* fields: item->u1.str == the extension name, label, whatever it's called @@ -618,12 +618,12 @@ void traverse_pval_item_template(pval *item, int depth)/* depth comes in handy f */ traverse_pval_item_template(item->u2.statements,depth+1); break; - + case PV_IGNOREPAT: /* fields: item->u1.str == the ignorepat data */ break; - + case PV_GLOBALS: /* fields: item->u1.statements == pval list of statements, usually vardecs */ @@ -636,7 +636,7 @@ void traverse_pval_template(pval *item, int depth) /* depth comes in handy for a but you may not need it */ { pval *i; - + for (i=item; i; i=i->next) { traverse_pval_item_template(i, depth); } @@ -696,16 +696,16 @@ static int extension_matches(pval *here, const char *exten, const char *pattern) { int err1; regex_t preg; - + /* simple case, they match exactly, the pattern and exten name */ if (strcmp(pattern,exten) == 0) return 1; - + if (pattern[0] == '_') { char reg1[2000]; const char *p; char *r = reg1; - + if ( strlen(pattern)*5 >= 2000 ) /* safety valve */ { ast_log(LOG_ERROR,"Error: The pattern %s is way too big. Pattern matching cancelled.\n", pattern); @@ -725,7 +725,7 @@ static int extension_matches(pval *here, const char *exten, const char *pattern) *r++ = 'X'; *r++ = ']'; break; - + case 'Z': *r++ = '['; *r++ = '1'; @@ -734,7 +734,7 @@ static int extension_matches(pval *here, const char *exten, const char *pattern) *r++ = 'Z'; *r++ = ']'; break; - + case 'N': *r++ = '['; *r++ = '2'; @@ -743,7 +743,7 @@ static int extension_matches(pval *here, const char *exten, const char *pattern) *r++ = 'N'; *r++ = ']'; break; - + case '[': while ( *p && *p != ']' ) { *r++ = *p++; @@ -754,7 +754,7 @@ static int extension_matches(pval *here, const char *exten, const char *pattern) here->filename, here->startline, here->endline, pattern); } break; - + case '.': case '!': *r++ = '.'; @@ -767,7 +767,7 @@ static int extension_matches(pval *here, const char *exten, const char *pattern) default: *r++ = *p; break; - + } } *r++ = '$'; /* what if the extension is a pattern ?? */ @@ -783,7 +783,7 @@ static int extension_matches(pval *here, const char *exten, const char *pattern) } err1 = regexec(&preg, exten, 0, 0, 0); regfree(&preg); - + if ( err1 ) { /* ast_log(LOG_NOTICE,"*****************************[%d]Extension %s did not match %s(%s)\n", err1,exten, pattern, reg1); */ @@ -793,8 +793,8 @@ static int extension_matches(pval *here, const char *exten, const char *pattern) exten, pattern); */ return 1; } - - + + } else { if ( strcmp(exten,pattern) == 0 ) { return 1; @@ -856,7 +856,7 @@ static void check_timerange(pval *p) } *e = '\0'; e++; - while (*e && !isdigit(*e)) + while (*e && !isdigit(*e)) e++; if (!*e) { ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: The time range format (%s) is missing the end time!\n", @@ -907,7 +907,7 @@ static void check_dow(pval *DOW) char *c; /* The following line is coincidence, really! */ int s, e; - + dow = ast_strdupa(DOW->u1.str); /* Check for all days */ @@ -1013,7 +1013,7 @@ static void check_month(pval *MON) mon = ast_strdupa(MON->u1.str); /* Check for all days */ - if (ast_strlen_zero(mon) || !strcmp(mon, "*")) + if (ast_strlen_zero(mon) || !strcmp(mon, "*")) return ; /* Get start and ending days */ c = strchr(mon, '-'); @@ -1044,11 +1044,11 @@ static void check_month(pval *MON) static int check_break(pval *item) { pval *p = item; - + while( p && p->type != PV_MACRO && p->type != PV_CONTEXT ) /* early cutout, sort of */ { /* a break is allowed in WHILE, FOR, CASE, DEFAULT, PATTERN; otherwise, it don't make no sense */ - if( p->type == PV_CASE || p->type == PV_DEFAULT || p->type == PV_PATTERN + if( p->type == PV_CASE || p->type == PV_DEFAULT || p->type == PV_PATTERN || p->type == PV_WHILE || p->type == PV_FOR ) { return 1; } @@ -1057,14 +1057,14 @@ static int check_break(pval *item) ast_log(LOG_ERROR,"Error: file %s, line %d-%d: 'break' not in switch, for, or while statement!\n", item->filename, item->startline, item->endline); errs++; - + return 0; } static int check_continue(pval *item) { pval *p = item; - + while( p && p->type != PV_MACRO && p->type != PV_CONTEXT ) /* early cutout, sort of */ { /* a break is allowed in WHILE, FOR, CASE, DEFAULT, PATTERN; otherwise, it don't make no sense */ @@ -1076,14 +1076,14 @@ static int check_continue(pval *item) ast_log(LOG_ERROR,"Error: file %s, line %d-%d: 'continue' not in 'for' or 'while' statement!\n", item->filename, item->startline, item->endline); errs++; - + return 0; } static struct pval *in_macro(pval *item) { struct pval *curr; - curr = item; + curr = item; while( curr ) { if( curr->type == PV_MACRO ) { return curr; @@ -1096,7 +1096,7 @@ static struct pval *in_macro(pval *item) static struct pval *in_context(pval *item) { struct pval *curr; - curr = item; + curr = item; while( curr ) { if( curr->type == PV_MACRO || curr->type == PV_CONTEXT ) { return curr; @@ -1114,11 +1114,11 @@ static void check_label(pval *item) struct pval *curr; struct pval *x; int alright = 0; - + /* A label outside an extension just plain does not make sense! */ - + curr = item; - + while( curr ) { if( curr->type == PV_MACRO || curr->type == PV_EXTENSION ) { alright = 1; @@ -1130,21 +1130,21 @@ static void check_label(pval *item) { ast_log(LOG_ERROR,"Error: file %s, line %d-%d: Label %s is not within an extension or macro!\n", item->filename, item->startline, item->endline, item->u1.str); - errs++; + errs++; } - - + + /* basically, ensure that a label is not repeated in a context. Period. The method: well, for each label, find the first label in the context with the same name. If it's not the current label, then throw an error. */ - + /* printf("==== check_label: ====\n"); */ if( !current_extension ) curr = current_context; else curr = current_extension; - + x = find_first_label_in_current_context((char *)item->u1.str, curr); /* printf("Hey, check_label found with item = %x, and x is %x, and currcont is %x, label name is %s\n", item,x, current_context, (char *)item->u1.str); */ if( x && x != item ) @@ -1161,7 +1161,7 @@ static pval *get_goto_target(pval *item) /* just one item-- the label should be in the current extension */ pval *curr_ext = get_extension_or_contxt(item); /* containing exten, or macro */ pval *curr_cont; - + if (!item->u1.list) { return NULL; } @@ -1175,21 +1175,21 @@ static pval *get_goto_target(pval *item) /* TWO items */ if (item->u1.list->next && !item->u1.list->next->next) { - if (!strstr((item->u1.list)->u1.str,"${") + if (!strstr((item->u1.list)->u1.str,"${") && !strstr(item->u1.list->next->u1.str,"${") ) /* Don't try to match variables */ { struct pval *x = find_label_in_current_context((char *)item->u1.list->u1.str, (char *)item->u1.list->next->u1.str, curr_cont); return x; } } - + /* All 3 items! */ if (item->u1.list->next && item->u1.list->next->next) { /* all three */ pval *first = item->u1.list; pval *second = item->u1.list->next; pval *third = item->u1.list->next->next; - - if (!strstr((item->u1.list)->u1.str,"${") + + if (!strstr((item->u1.list)->u1.str,"${") && !strstr(item->u1.list->next->u1.str,"${") && !strstr(item->u1.list->next->next->u1.str,"${")) /* Don't try to match variables */ { struct pval *x = find_label_in_current_db((char*)first->u1.str, (char*)second->u1.str, (char*)third->u1.str); @@ -1197,7 +1197,7 @@ static pval *get_goto_target(pval *item) struct pval *p3; struct pval *that_context = find_context(item->u1.list->u1.str); - + /* the target of the goto could be in an included context!! Fancy that!! */ /* look for includes in the current context */ if (that_context) { @@ -1257,17 +1257,17 @@ static void check_goto(pval *item) else return; } - + /* TWO items */ if (item->u1.list->next && !item->u1.list->next->next) { /* two items */ /* printf("Calling find_label_in_current_context with args %s, %s\n", (char*)((item->u1.list)->u1.str), (char *)item->u1.list->next->u1.str); */ - if (!strstr((item->u1.list)->u1.str,"${") + if (!strstr((item->u1.list)->u1.str,"${") && !strstr(item->u1.list->next->u1.str,"${") ) /* Don't try to match variables */ { struct pval *z = get_contxt(item); struct pval *x = 0; - + if (z) x = find_label_in_current_context((char *)item->u1.list->u1.str, (char *)item->u1.list->next->u1.str, z); @@ -1280,17 +1280,17 @@ static void check_goto(pval *item) return; } } - + /* All 3 items! */ if (item->u1.list->next && item->u1.list->next->next) { /* all three */ pval *first = item->u1.list; pval *second = item->u1.list->next; pval *third = item->u1.list->next->next; - + /* printf("Calling find_label_in_current_db with args %s, %s, %s\n", (char*)first->u1.str, (char*)second->u1.str, (char*)third->u1.str); */ - if (!strstr((item->u1.list)->u1.str,"${") + if (!strstr((item->u1.list)->u1.str,"${") && !strstr(item->u1.list->next->u1.str,"${") && !strstr(item->u1.list->next->next->u1.str,"${")) /* Don't try to match variables */ { struct pval *x = find_label_in_current_db((char*)first->u1.str, (char*)second->u1.str, (char*)third->u1.str); @@ -1298,7 +1298,7 @@ static void check_goto(pval *item) struct pval *p3; struct pval *found = 0; struct pval *that_context = find_context(item->u1.list->u1.str); - + /* the target of the goto could be in an included context!! Fancy that!! */ /* look for includes in the current context */ if (that_context) { @@ -1334,7 +1334,7 @@ static void check_goto(pval *item) { ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: It's bad form to have a goto in a macro to a target outside the macro!\n", item->filename, item->startline, item->endline); - warns++; + warns++; } } } @@ -1343,7 +1343,7 @@ static void check_goto(pval *item) #ifdef STANDALONE struct pbx_find_info pfiq = {.stacklen = 0 }; extern int localized_pbx_load_module(void); - /* if this is a standalone, we will need to make sure the + /* if this is a standalone, we will need to make sure the localized load of extensions.conf is done */ if (!extensions_dot_conf_loaded) { localized_pbx_load_module(); @@ -1351,9 +1351,9 @@ static void check_goto(pval *item) } pbx_find_extension(NULL, NULL, &pfiq, first->u1.str, second->u1.str, atoi(third->u1.str), - atoi(third->u1.str) ? NULL : third->u1.str, NULL, + atoi(third->u1.str) ? NULL : third->u1.str, NULL, atoi(third->u1.str) ? E_MATCH : E_FINDLABEL); - + if (pfiq.status != STATUS_SUCCESS) { ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: goto: Couldn't find goto target %s|%s|%s, not even in extensions.conf!\n", item->filename, item->startline, item->endline, first->u1.str, second->u1.str, third->u1.str); @@ -1373,24 +1373,24 @@ static void check_goto(pval *item) { ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: It's bad form to have a goto in a macro to a target outside the macro!\n", item->filename, item->startline, item->endline); - warns++; + warns++; } } } } } } - + static void find_pval_goto_item(pval *item, int lev) { struct pval *p4; - + if (lev>100) { ast_log(LOG_ERROR,"find_pval_goto in infinite loop! item_type: %u\n\n", item->type); return; } - + switch ( item->type ) { case PV_MACRO: /* fields: item->u1.str == name of macro @@ -1400,12 +1400,12 @@ static void find_pval_goto_item(pval *item, int lev) item->u3.macro_statements == pval list of statements in macro body. */ - + /* printf("Descending into macro %s at line %d\n", item->u1.str, item->startline); */ find_pval_gotos(item->u3.macro_statements,lev+1); /* if we're just searching for a context, don't bother descending into them */ - + break; - + case PV_CONTEXT: /* fields: item->u1.str == name of context item->u2.statements == pval list of statements in context body @@ -1420,7 +1420,7 @@ static void find_pval_goto_item(pval *item, int lev) /* printf("Descending into Case of %s\n", item->u1.str); */ find_pval_gotos(item->u2.statements,lev+1); break; - + case PV_PATTERN: /* fields: item->u1.str == value of case item->u2.statements == pval list of statements under the case @@ -1428,15 +1428,15 @@ static void find_pval_goto_item(pval *item, int lev) /* printf("Descending into Pattern of %s\n", item->u1.str); */ find_pval_gotos(item->u2.statements,lev+1); break; - + case PV_DEFAULT: - /* fields: + /* fields: item->u2.statements == pval list of statements under the case */ /* printf("Descending into default\n"); */ find_pval_gotos(item->u2.statements,lev+1); break; - + case PV_CATCH: /* fields: item->u1.str == name of extension to catch item->u2.statements == pval list of statements in context body @@ -1444,21 +1444,21 @@ static void find_pval_goto_item(pval *item, int lev) /* printf("Descending into catch of %s\n", item->u1.str); */ find_pval_gotos(item->u2.statements,lev+1); break; - + case PV_STATEMENTBLOCK: /* fields: item->u1.list == pval list of statements in block, one per entry in the list */ /* printf("Descending into statement block\n"); */ find_pval_gotos(item->u1.list,lev+1); break; - + case PV_GOTO: /* fields: item->u1.list == pval list of PV_WORD target names, up to 3, in order as given by user. item->u1.list->u1.str == where the data on a PV_WORD will always be. */ check_goto(item); /* THE WHOLE FUNCTION OF THIS ENTIRE ROUTINE!!!! */ break; - + case PV_INCLUDES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list */ @@ -1474,7 +1474,7 @@ static void find_pval_goto_item(pval *item, int lev) } } break; - + case PV_FOR: /* fields: item->u1.for_init == a string containing the initalizer item->u2.for_test == a string containing the loop test @@ -1485,7 +1485,7 @@ static void find_pval_goto_item(pval *item, int lev) /* printf("Descending into for at line %d\n", item->startline); */ find_pval_gotos(item->u4.for_statements,lev+1); break; - + case PV_WHILE: /* fields: item->u1.str == the while conditional, as supplied by user @@ -1494,7 +1494,7 @@ static void find_pval_goto_item(pval *item, int lev) /* printf("Descending into while at line %d\n", item->startline); */ find_pval_gotos(item->u2.statements,lev+1); break; - + case PV_RANDOM: /* fields: item->u1.str == the random number expression, as supplied by user @@ -1502,7 +1502,7 @@ static void find_pval_goto_item(pval *item, int lev) item->u3.else_statements == a pval list of statements in the else (could be zero) fall thru to PV_IF */ - + case PV_IFTIME: /* fields: item->u1.list == the time values, 4 of them, as PV_WORD structs in a list @@ -1525,17 +1525,17 @@ static void find_pval_goto_item(pval *item, int lev) find_pval_gotos(item->u3.else_statements,lev+1); } break; - + case PV_SWITCH: /* fields: item->u1.str == the switch expression - item->u2.statements == a pval list of statements in the switch, + item->u2.statements == a pval list of statements in the switch, (will be case statements, most likely!) */ /* printf("Descending into switch at line %d\n", item->startline); */ find_pval_gotos(item->u3.else_statements,lev+1); break; - + case PV_EXTENSION: /* fields: item->u1.str == the extension name, label, whatever it's called @@ -1556,7 +1556,7 @@ static void find_pval_goto_item(pval *item, int lev) static void find_pval_gotos(pval *item,int lev) { pval *i; - + for (i=item; i; i=i->next) { /* printf("About to call pval_goto_item, itemcount=%d, itemtype=%d\n", item_count, i->type); */ find_pval_goto_item(i, lev); @@ -1569,7 +1569,7 @@ static void find_pval_gotos(pval *item,int lev) static struct pval *match_pval_item(pval *item) { pval *x; - + switch ( item->type ) { case PV_MACRO: /* fields: item->u1.str == name of macro @@ -1581,15 +1581,15 @@ static struct pval *match_pval_item(pval *item) */ /* printf(" matching in MACRO %s, match_context=%s; retoncontmtch=%d; \n", item->u1.str, match_context, return_on_context_match); */ if (!strcmp(match_context,"*") || !strcmp(item->u1.str, match_context)) { - + /* printf("MACRO: match context is: %s\n", match_context); */ - + if (return_on_context_match && !strcmp(item->u1.str, match_context)) /* if we're just searching for a context, don't bother descending into them */ { /* printf("Returning on matching macro %s\n", match_context); */ return item; } - - + + if (!return_on_context_match) { /* printf("Descending into matching macro %s/%s\n", match_context, item->u1.str); */ if ((x=match_pval(item->u3.macro_statements))) { @@ -1600,9 +1600,9 @@ static struct pval *match_pval_item(pval *item) } else { /* printf("Skipping context/macro %s\n", item->u1.str); */ } - + break; - + case PV_CONTEXT: /* fields: item->u1.str == name of context item->u2.statements == pval list of statements in context body @@ -1615,7 +1615,7 @@ static struct pval *match_pval_item(pval *item) /* printf("non-CONTEXT: Responded with pval match %x\n", x); */ return item; } - + if (!return_on_context_match ) { /* printf("Descending into matching context %s\n", match_context); */ if ((x=match_pval(item->u2.statements))) /* if we're just searching for a context, don't bother descending into them */ { @@ -1638,7 +1638,7 @@ static struct pval *match_pval_item(pval *item) return x; } break; - + case PV_PATTERN: /* fields: item->u1.str == value of case item->u2.statements == pval list of statements under the case @@ -1649,9 +1649,9 @@ static struct pval *match_pval_item(pval *item) return x; } break; - + case PV_DEFAULT: - /* fields: + /* fields: item->u2.statements == pval list of statements under the case */ /* printf(" matching in DEFAULT\n"); */ @@ -1660,7 +1660,7 @@ static struct pval *match_pval_item(pval *item) return x; } break; - + case PV_CATCH: /* fields: item->u1.str == name of extension to catch item->u2.statements == pval list of statements in context body @@ -1671,7 +1671,7 @@ static struct pval *match_pval_item(pval *item) return x; } break; - + case PV_STATEMENTBLOCK: /* fields: item->u1.list == pval list of statements in block, one per entry in the list */ @@ -1681,19 +1681,19 @@ static struct pval *match_pval_item(pval *item) return x; } break; - + case PV_LABEL: /* fields: item->u1.str == label name */ - /* printf("PV_LABEL %s (cont=%s, exten=%s\n", + /* printf("PV_LABEL %s (cont=%s, exten=%s\n", item->u1.str, current_context->u1.str, (current_extension?current_extension->u1.str:"<macro>"));*/ - + if (count_labels) { if (!strcmp(match_label, item->u1.str)) { label_count++; last_matched_label = item; } - + } else { if (!strcmp(match_label, item->u1.str)) { /* printf("LABEL: Responded with pval match %x\n", x); */ @@ -1701,7 +1701,7 @@ static struct pval *match_pval_item(pval *item) } } break; - + case PV_FOR: /* fields: item->u1.for_init == a string containing the initalizer item->u2.for_test == a string containing the loop test @@ -1715,7 +1715,7 @@ static struct pval *match_pval_item(pval *item) return x; } break; - + case PV_WHILE: /* fields: item->u1.str == the while conditional, as supplied by user @@ -1727,7 +1727,7 @@ static struct pval *match_pval_item(pval *item) return x; } break; - + case PV_RANDOM: /* fields: item->u1.str == the random number expression, as supplied by user @@ -1735,7 +1735,7 @@ static struct pval *match_pval_item(pval *item) item->u3.else_statements == a pval list of statements in the else (could be zero) fall thru to PV_IF */ - + case PV_IFTIME: /* fields: item->u1.list == the time values, 4 of them, as PV_WORD structs in a list @@ -1761,11 +1761,11 @@ static struct pval *match_pval_item(pval *item) } } break; - + case PV_SWITCH: /* fields: item->u1.str == the switch expression - item->u2.statements == a pval list of statements in the switch, + item->u2.statements == a pval list of statements in the switch, (will be case statements, most likely!) */ /* printf(" matching in SWITCH\n"); */ @@ -1774,7 +1774,7 @@ static struct pval *match_pval_item(pval *item) return x; } break; - + case PV_EXTENSION: /* fields: item->u1.str == the extension name, label, whatever it's called @@ -1821,7 +1821,7 @@ struct pval *match_pval(pval *item) for (i=item; i; i=i->next) { pval *x; /* printf(" -- match pval: item %d\n", i->type); */ - + if ((x = match_pval_item(i))) { /* printf("match_pval: returning x=%x\n", (int)x); */ return x; /* cut the search short */ @@ -1837,7 +1837,7 @@ int count_labels_in_current_context(char *label) count_labels = 1; return_on_context_match = 0; match_pval(current_context->u2.statements); - + return label_count; } #endif @@ -1847,17 +1847,17 @@ struct pval *find_first_label_in_current_context(char *label, pval *curr_cont) /* printf(" --- Got args %s, %s\n", exten, label); */ struct pval *ret; struct pval *p3; - + count_labels = 0; return_on_context_match = 0; match_context = "*"; match_exten = "*"; match_label = label; - + ret = match_pval(curr_cont); if (ret) return ret; - + /* the target of the goto could be in an included context!! Fancy that!! */ /* look for includes in the current context */ for (p3=curr_cont->u2.statements; p3; p3=p3->next) { @@ -1887,7 +1887,7 @@ struct pval *find_label_in_current_context(char *exten, char *label, pval *curr_ /* printf(" --- Got args %s, %s\n", exten, label); */ struct pval *ret; struct pval *p3; - + count_labels = 0; return_on_context_match = 0; match_context = "*"; @@ -1896,7 +1896,7 @@ struct pval *find_label_in_current_context(char *exten, char *label, pval *curr_ ret = match_pval(curr_cont->u2.statements); if (ret) return ret; - + /* the target of the goto could be in an included context!! Fancy that!! */ /* look for includes in the current context */ for (p3=curr_cont->u2.statements; p3; p3=p3->next) { @@ -1941,7 +1941,7 @@ static struct pval *find_label_in_current_db(const char *context, const char *ex match_context = context; match_exten = exten; match_label = label; - + return match_pval(current_db); } @@ -2003,12 +2003,12 @@ int option_matches_j( struct argdesc *should, pval *is, struct argapp *app) { struct argchoice *ac; char *opcop,*q,*p; - + switch (should->dtype) { case ARGD_OPTIONSET: if ( strstr(is->u1.str,"${") ) return 0; /* no checking anything if there's a var reference in there! */ - + opcop = ast_strdupa(is->u1.str); for (q=opcop;*q;q++) { /* erase the innards of X(innard) type arguments, so we don't get confused later */ @@ -2019,7 +2019,7 @@ int option_matches_j( struct argdesc *should, pval *is, struct argapp *app) q = p+1; } } - + for (ac=app->opts; ac; ac=ac->next) { if (strlen(ac->name)>1 && strchr(ac->name,'(') == 0 && strcmp(ac->name,is->u1.str) == 0) /* multichar option, no parens, and a match? */ return 0; @@ -2027,13 +2027,13 @@ int option_matches_j( struct argdesc *should, pval *is, struct argapp *app) for (ac=app->opts; ac; ac=ac->next) { if (strlen(ac->name)==1 || strchr(ac->name,'(')) { char *p = strchr(opcop,ac->name[0]); /* wipe out all matched options in the user-supplied string */ - + if (p && *p == 'j') { ast_log(LOG_ERROR, "Error: file %s, line %d-%d: The j option in the %s application call is not appropriate for AEL!\n", is->filename, is->startline, is->endline, app->name); errs++; } - + if (p) { *p = '+'; if (ac->name[1] == '(') { @@ -2058,14 +2058,14 @@ int option_matches_j( struct argdesc *should, pval *is, struct argapp *app) default: return 0; } - + } int option_matches( struct argdesc *should, pval *is, struct argapp *app) { struct argchoice *ac; char *opcop; - + switch (should->dtype) { case ARGD_STRING: if (is_empty(is->u1.str) && should->type == ARGD_REQUIRED) @@ -2073,21 +2073,21 @@ int option_matches( struct argdesc *should, pval *is, struct argapp *app) if (is->u1.str && strlen(is->u1.str) > 0) /* most will match */ return 1; break; - + case ARGD_INT: if (is_int(is->u1.str)) return 1; else return 0; break; - + case ARGD_FLOAT: if (is_float(is->u1.str)) return 1; else return 0; break; - + case ARGD_ENUM: if( !is->u1.str || strlen(is->u1.str) == 0 ) return 1; /* a null arg in the call will match an enum, I guess! */ @@ -2097,10 +2097,10 @@ int option_matches( struct argdesc *should, pval *is, struct argapp *app) } return 0; break; - + case ARGD_OPTIONSET: opcop = ast_strdupa(is->u1.str); - + for (ac=app->opts; ac; ac=ac->next) { if (strlen(ac->name)>1 && strchr(ac->name,'(') == 0 && strcmp(ac->name,is->u1.str) == 0) /* multichar option, no parens, and a match? */ return 1; @@ -2108,7 +2108,7 @@ int option_matches( struct argdesc *should, pval *is, struct argapp *app) for (ac=app->opts; ac; ac=ac->next) { if (strlen(ac->name)==1 || strchr(ac->name,'(')) { char *p = strchr(opcop,ac->name[0]); /* wipe out all matched options in the user-supplied string */ - + if (p) { *p = '+'; if (ac->name[1] == '(') { @@ -2139,7 +2139,7 @@ int check_app_args(pval* appcall, pval *arglist, struct argapp *app) struct argdesc *ad = app->args; pval *pa; int z; - + for (pa = arglist; pa; pa=pa->next) { if (!ad) { ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: Extra argument %s not in application call to %s !\n", @@ -2151,12 +2151,12 @@ int check_app_args(pval* appcall, pval *arglist, struct argapp *app) do { if ( ad->dtype == ARGD_VARARG ) /* once we hit the VARARG, all bets are off. Discontinue the comparisons */ break; - + z= option_matches( ad, pa, app); if (!z) { if ( !arglist ) arglist=appcall; - + if (ad->type == ARGD_REQUIRED) { ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: Required argument %s not in application call to %s !\n", arglist->filename, arglist->startline, arglist->endline, ad->dtype==ARGD_OPTIONSET?"options":ad->name, app->name); @@ -2173,7 +2173,7 @@ int check_app_args(pval* appcall, pval *arglist, struct argapp *app) /* any app nodes left, that are not optional? */ for ( ; ad; ad=ad->next) { if (ad->type == ARGD_REQUIRED && ad->dtype != ARGD_VARARG) { - if ( !arglist ) + if ( !arglist ) arglist=appcall; ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: Required argument %s not in application call to %s !\n", arglist->filename, arglist->startline, arglist->endline, ad->dtype==ARGD_OPTIONSET?"options":ad->name, app->name); @@ -2196,11 +2196,11 @@ void check_switch_expr(pval *item, struct argapp *apps) struct appsetvar *v,*v2; struct argchoice *c; pval *t; - + p = item->u1.str; while (p && *p && (*p == ' ' || *p == '\t' || *p == '$' || *p == '{' ) ) p++; - + buff1 = ast_strdupa(p); while (strlen(buff1) > 0 && ( buff1[strlen(buff1)-1] == '}' || buff1[strlen(buff1)-1] == ' ' || buff1[strlen(buff1)-1] == '\t')) @@ -2221,7 +2221,7 @@ void check_switch_expr(pval *item, struct argapp *apps) int def= 0; int pat = 0; int f1 = 0; - + /* first of all, does this switch have a default case ? */ for (t=item->u2.statements; t; t=t->next) { if (t->type == PV_DEFAULT) { @@ -2275,7 +2275,7 @@ void check_switch_expr(pval *item, struct argapp *apps) if (f1) break; } - + /* see if it sets the var */ if (!f1) { ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: Couldn't find an application call in this extension that sets the expression (%s) value!\n", @@ -2286,7 +2286,7 @@ void check_switch_expr(pval *item, struct argapp *apps) #else pval *t,*tl=0,*p2; int def= 0; - + /* first of all, does this switch have a default case ? */ for (t=item->u2.statements; t; t=t->next) { if (t->type == PV_DEFAULT) { @@ -2299,7 +2299,7 @@ void check_switch_expr(pval *item, struct argapp *apps) return; /* if no default, warn and insert a default case at the end */ p2 = tl->next = calloc(1, sizeof(struct pval)); - + p2->type = PV_DEFAULT; p2->startline = tl->startline; p2->endline = tl->endline; @@ -2309,7 +2309,7 @@ void check_switch_expr(pval *item, struct argapp *apps) ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: A default case was automatically added to the switch.\n", p2->filename, p2->startline, p2->endline); warns++; - + #endif } @@ -2336,7 +2336,7 @@ static void check_abstract_reference(pval *abstract_context) { pval *i,*j; /* find some context includes that reference this context */ - + /* otherwise, print out a warning */ for (i=current_db; i; i=i->next) { @@ -2371,13 +2371,13 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) char errmsg[4096]; char *strp; - + switch (item->type) { case PV_WORD: /* fields: item->u1.str == string associated with this (word). item->u2.arglist == pval list of 4 PV_WORD elements for time values (only in PV_INCLUDES) */ break; - + case PV_MACRO: /* fields: item->u1.str == name of macro item->u2.arglist == pval list of PV_WORD arguments of macro, as given by user @@ -2391,13 +2391,13 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) current_extension = 0; check_macro_returns(item); - + for (lp=item->u2.arglist; lp; lp=lp->next) { - + } check_pval(item->u3.macro_statements, apps,in_globals); break; - + case PV_CONTEXT: /* fields: item->u1.str == name of context item->u2.statements == pval list of statements in context body @@ -2412,7 +2412,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) in_abstract_context = 0; check_pval(item->u2.statements, apps,in_globals); break; - + case PV_MACRO_CALL: /* fields: item->u1.str == name of macro to call item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user @@ -2420,7 +2420,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) item->u2.arglist->next == next arg */ #ifdef STANDALONE - /* if this is a standalone, we will need to make sure the + /* if this is a standalone, we will need to make sure the localized load of extensions.conf is done */ if (!extensions_dot_conf_loaded) { localized_pbx_load_module(); @@ -2435,14 +2435,14 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) /* look for the macro in the extensions.conf world */ pbx_find_extension(NULL, NULL, &pfiq, item->u1.str, "s", 1, NULL, NULL, E_MATCH); - + if (pfiq.status != STATUS_SUCCESS) { char namebuf2[256]; snprintf(namebuf2, 256, "macro-%s", item->u1.str); - + /* look for the macro in the extensions.conf world */ pbx_find_extension(NULL, NULL, &pfiq2, namebuf2, "s", 1, NULL, NULL, E_MATCH); - + if (pfiq2.status == STATUS_SUCCESS) { ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: macro call to non-existent %s! (macro-%s was found in the extensions.conf stuff, but we are using gosubs!)\n", item->filename, item->startline, item->endline, item->u1.str, item->u1.str); @@ -2457,7 +2457,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: macro call to %s cannot be found in the AEL code!\n", item->filename, item->startline, item->endline, item->u1.str); warns++; - + #endif #ifdef THIS_IS_1DOT4 char namebuf2[256]; @@ -2465,13 +2465,13 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) /* look for the macro in the extensions.conf world */ pbx_find_extension(NULL, NULL, &pfiq, namebuf2, "s", 1, NULL, NULL, E_MATCH); - + if (pfiq.status != STATUS_SUCCESS) { ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: macro call to %s was not found in the AEL, nor the extensions.conf !\n", item->filename, item->startline, item->endline, item->u1.str); warns++; } - + #endif } else if (macro_def->type != PV_MACRO) { @@ -2482,7 +2482,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) /* macro_def is a MACRO, so do the args match in number? */ int hereargs = 0; int thereargs = 0; - + for (lp=item->u2.arglist; lp; lp=lp->next) { hereargs++; } @@ -2496,7 +2496,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) } } break; - + case PV_APPLICATION_CALL: /* fields: item->u1.str == name of application to call item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user @@ -2539,7 +2539,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) free(item->u1.str); item->u1.str = 0; } - + #ifdef AAL_ARGCHECK found = 0; for (app=apps; app; app=app->next) { @@ -2556,7 +2556,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) check_app_args(item, item->u2.arglist, app); #endif break; - + case PV_CASE: /* fields: item->u1.str == value of case item->u2.statements == pval list of statements under the case @@ -2565,44 +2565,44 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) /* find the last statement */ check_pval(item->u2.statements, apps,in_globals); break; - + case PV_PATTERN: /* fields: item->u1.str == value of case item->u2.statements == pval list of statements under the case */ /* Make sure sequence of statements under case is terminated with goto, return, or break */ /* find the last statement */ - + check_pval(item->u2.statements, apps,in_globals); break; - + case PV_DEFAULT: - /* fields: + /* fields: item->u2.statements == pval list of statements under the case */ check_pval(item->u2.statements, apps,in_globals); break; - + case PV_CATCH: /* fields: item->u1.str == name of extension to catch item->u2.statements == pval list of statements in context body */ check_pval(item->u2.statements, apps,in_globals); break; - + case PV_SWITCHES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list */ check_pval(item->u1.list, apps,in_globals); break; - + case PV_ESWITCHES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list */ check_pval(item->u1.list, apps,in_globals); break; - + case PV_INCLUDES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list */ @@ -2618,20 +2618,20 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) check_day(lp->u2.arglist->next->next); check_month(lp->u2.arglist->next->next->next); } - + if (that_context) { find_pval_gotos(that_context->u2.statements,0); - + } } break; - + case PV_STATEMENTBLOCK: /* fields: item->u1.list == pval list of statements in block, one per entry in the list */ check_pval(item->u1.list, apps,in_globals); break; - + case PV_VARDEC: /* fields: item->u1.str == variable name item->u2.val == variable value to assign @@ -2650,7 +2650,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) check_expr2_input(item,item->u2.val); } break; - + case PV_LOCALVARDEC: /* fields: item->u1.str == variable name item->u2.val == variable value to assign @@ -2667,7 +2667,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) } check_expr2_input(item,item->u2.val); break; - + case PV_GOTO: /* fields: item->u1.list == pval list of PV_WORD target names, up to 3, in order as given by user. item->u1.list->u1.str == where the data on a PV_WORD will always be. @@ -2675,10 +2675,10 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) /* don't check goto's in abstract contexts */ if ( in_abstract_context ) break; - + check_goto(item); break; - + case PV_LABEL: /* fields: item->u1.str == label name */ @@ -2690,7 +2690,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) check_label(item); break; - + case PV_FOR: /* fields: item->u1.for_init == a string containing the initalizer item->u2.for_test == a string containing the loop test @@ -2722,11 +2722,11 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) } check_expr2_input(item,item->u2.for_test); check_expr2_input(item,item->u3.for_inc); - + ast_expr_clear_extra_error_info(); check_pval(item->u4.for_statements, apps,in_globals); break; - + case PV_WHILE: /* fields: item->u1.str == the while conditional, as supplied by user @@ -2744,24 +2744,24 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) check_expr2_input(item,item->u1.str); check_pval(item->u2.statements, apps,in_globals); break; - + case PV_BREAK: /* fields: none */ check_break(item); break; - + case PV_RETURN: /* fields: none */ break; - + case PV_CONTINUE: /* fields: none */ check_continue(item); break; - + case PV_RANDOM: /* fields: item->u1.str == the random number expression, as supplied by user @@ -2786,7 +2786,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) break; case PV_IFTIME: - /* fields: item->u1.list == the if time values, 4 of them, each in PV_WORD, linked list + /* fields: item->u1.list == the if time values, 4 of them, each in PV_WORD, linked list item->u2.statements == a pval list of statements in the if () item->u3.else_statements == a pval list of statements in the else @@ -2804,7 +2804,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) check_pval(item->u3.else_statements, apps,in_globals); } break; - + case PV_IF: /* fields: item->u1.str == the if conditional, as supplied by user @@ -2827,11 +2827,11 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) check_pval(item->u3.else_statements, apps,in_globals); } break; - + case PV_SWITCH: /* fields: item->u1.str == the switch expression - item->u2.statements == a pval list of statements in the switch, + item->u2.statements == a pval list of statements in the switch, (will be case statements, most likely!) */ /* we can check the switch expression, see if it matches any of the app variables... @@ -2839,7 +2839,7 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) check_switch_expr(item, apps); check_pval(item->u2.statements, apps,in_globals); break; - + case PV_EXTENSION: /* fields: item->u1.str == the extension name, label, whatever it's called @@ -2848,15 +2848,15 @@ void check_pval_item(pval *item, struct argapp *apps, int in_globals) item->u4.regexten == an int boolean. non-zero says that regexten was specified */ current_extension = item ; - + check_pval(item->u2.statements, apps,in_globals); break; - + case PV_IGNOREPAT: /* fields: item->u1.str == the ignorepat data */ break; - + case PV_GLOBALS: /* fields: item->u1.statements == pval list of statements, usually vardecs */ @@ -2873,16 +2873,16 @@ void check_pval(pval *item, struct argapp *apps, int in_globals) pval *i; /* checks to do: - 1. Do goto's point to actual labels? + 1. Do goto's point to actual labels? 2. Do macro calls reference a macro? 3. Does the number of macro args match the definition? 4. Is a macro call missing its & at the front? 5. Application calls-- we could check syntax for existing applications, - but I need some some sort of universal description bnf for a general - sort of method for checking arguments, in number, maybe even type, at least. + but I need some sort of universal description bnf for a general + sort of method for checking arguments, in number, maybe even type, at least. Don't want to hand code checks for hundreds of applications. */ - + for (i=item; i; i=i->next) { check_pval_item(i,apps,in_globals); } @@ -2890,7 +2890,7 @@ void check_pval(pval *item, struct argapp *apps, int in_globals) void ael2_semantic_check(pval *item, int *arg_errs, int *arg_warns, int *arg_notes) { - + #ifdef AAL_ARGCHECK int argapp_errs =0; char *rfilename; @@ -2902,7 +2902,7 @@ void ael2_semantic_check(pval *item, int *arg_errs, int *arg_warns, int *arg_not #ifdef AAL_ARGCHECK rfilename = ast_alloca(10 + strlen(ast_config_AST_VAR_DIR)); sprintf(rfilename, "%s/applist", ast_config_AST_VAR_DIR); - + apps = argdesc_parse(rfilename, &argapp_errs); /* giveth */ #endif current_db = item; @@ -2942,7 +2942,7 @@ struct ael_extension *new_exten(void) void linkprio(struct ael_extension *exten, struct ael_priority *prio, struct ael_extension *mother_exten) { char *p1, *p2; - + if (!exten->plist) { exten->plist = prio; exten->plist_last = prio; @@ -2952,7 +2952,7 @@ void linkprio(struct ael_extension *exten, struct ael_priority *prio, struct ael } if( !prio->exten ) prio->exten = exten; /* don't override the switch value */ - /* The following code will cause all priorities within an extension + /* The following code will cause all priorities within an extension to have ${EXTEN} or ${EXTEN: replaced with ~~EXTEN~~, which is set just before the first switch in an exten. The switches will muck up the original ${EXTEN} value, so we save it away @@ -2986,17 +2986,17 @@ void destroy_extensions(struct ael_extension *exten) struct ael_extension *ne, *nen; for (ne=exten; ne; ne=nen) { struct ael_priority *pe, *pen; - + if (ne->name) free(ne->name); - + /* cidmatch fields are allocated with name, and freed when the name field is freed. Don't do a free for this field, unless you LIKE to see a crash! */ if (ne->hints) free(ne->hints); - + for (pe=ne->plist; pe; pe=pen) { pen = pe->next; if (pe->app) @@ -3024,7 +3024,7 @@ void destroy_extensions(struct ael_extension *exten) static int label_inside_case(pval *label) { pval *p = label; - + while( p && p->type != PV_MACRO && p->type != PV_CONTEXT ) /* early cutout, sort of */ { if( p->type == PV_CASE || p->type == PV_DEFAULT || p->type == PV_PATTERN ) { return 1; @@ -3099,11 +3099,11 @@ int find_switch_item(pval *item) case PV_LOCALVARDEC: /* fields: item->u1.str == string associated with this (word). */ break; - + case PV_WORD: /* fields: item->u1.str == string associated with this (word). */ break; - + case PV_MACRO: /* fields: item->u1.str == name of macro item->u2.arglist == pval list of PV_WORD arguments of macro, as given by user @@ -3116,7 +3116,7 @@ int find_switch_item(pval *item) if (contains_switch(item->u3.macro_statements)) return 1; break; - + case PV_CONTEXT: /* fields: item->u1.str == name of context item->u2.statements == pval list of statements in context body @@ -3126,7 +3126,7 @@ int find_switch_item(pval *item) if (contains_switch(item->u2.statements)) return 1; break; - + case PV_MACRO_CALL: /* fields: item->u1.str == name of macro to call item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user @@ -3134,7 +3134,7 @@ int find_switch_item(pval *item) item->u2.arglist->next == next arg */ break; - + case PV_APPLICATION_CALL: /* fields: item->u1.str == name of application to call item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user @@ -3142,7 +3142,7 @@ int find_switch_item(pval *item) item->u2.arglist->next == next arg */ break; - + case PV_CASE: /* fields: item->u1.str == value of case item->u2.statements == pval list of statements under the case @@ -3151,7 +3151,7 @@ int find_switch_item(pval *item) if (contains_switch(item->u2.statements)) return 1; break; - + case PV_PATTERN: /* fields: item->u1.str == value of case item->u2.statements == pval list of statements under the case @@ -3160,16 +3160,16 @@ int find_switch_item(pval *item) if (contains_switch(item->u2.statements)) return 1; break; - + case PV_DEFAULT: - /* fields: + /* fields: item->u2.statements == pval list of statements under the case */ /* had better not see this */ if (contains_switch(item->u2.statements)) return 1; break; - + case PV_CATCH: /* fields: item->u1.str == name of extension to catch item->u2.statements == pval list of statements in context body @@ -3178,47 +3178,47 @@ int find_switch_item(pval *item) if (contains_switch(item->u2.statements)) return 1; break; - + case PV_SWITCHES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list */ break; - + case PV_ESWITCHES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list */ break; - + case PV_INCLUDES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list item->u2.arglist == pval list of 4 PV_WORD elements for time values */ break; - + case PV_STATEMENTBLOCK: /* fields: item->u1.list == pval list of statements in block, one per entry in the list */ if (contains_switch(item->u1.list) ) return 1; break; - + case PV_VARDEC: /* fields: item->u1.str == variable name item->u2.val == variable value to assign */ break; - + case PV_GOTO: /* fields: item->u1.list == pval list of PV_WORD target names, up to 3, in order as given by user. item->u1.list->u1.str == where the data on a PV_WORD will always be. */ break; - + case PV_LABEL: /* fields: item->u1.str == label name */ break; - + case PV_FOR: /* fields: item->u1.for_init == a string containing the initalizer item->u2.for_test == a string containing the loop test @@ -3229,7 +3229,7 @@ int find_switch_item(pval *item) if (contains_switch(item->u4.for_statements)) return 1; break; - + case PV_WHILE: /* fields: item->u1.str == the while conditional, as supplied by user @@ -3238,22 +3238,22 @@ int find_switch_item(pval *item) if (contains_switch(item->u2.statements)) return 1; break; - + case PV_BREAK: /* fields: none */ break; - + case PV_RETURN: /* fields: none */ break; - + case PV_CONTINUE: /* fields: none */ break; - + case PV_IFTIME: /* fields: item->u1.list == there are 4 linked PV_WORDs here. @@ -3268,7 +3268,7 @@ int find_switch_item(pval *item) return 1; } break; - + case PV_RANDOM: /* fields: item->u1.str == the random number expression, as supplied by user @@ -3283,7 +3283,7 @@ int find_switch_item(pval *item) return 1; } break; - + case PV_IF: /* fields: item->u1.str == the if conditional, as supplied by user @@ -3298,16 +3298,16 @@ int find_switch_item(pval *item) return 1; } break; - + case PV_SWITCH: /* fields: item->u1.str == the switch expression - item->u2.statements == a pval list of statements in the switch, + item->u2.statements == a pval list of statements in the switch, (will be case statements, most likely!) */ return 1; /* JACKPOT */ break; - + case PV_EXTENSION: /* fields: item->u1.str == the extension name, label, whatever it's called @@ -3318,12 +3318,12 @@ int find_switch_item(pval *item) if (contains_switch(item->u2.statements)) return 1; break; - + case PV_IGNOREPAT: /* fields: item->u1.str == the ignorepat data */ break; - + case PV_GLOBALS: /* fields: item->u1.statements == pval list of statements, usually vardecs */ @@ -3335,7 +3335,7 @@ int find_switch_item(pval *item) int contains_switch(pval *item) { pval *i; - + for (i=item; i; i=i->next) { if (find_switch_item(i)) return 1; @@ -3375,7 +3375,7 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, if (!(new_label = malloc(BUF_SIZE))) { return -1; } - + if ((mother_exten && !mother_exten->checked_switch) || (exten && !exten->checked_switch)) { if (contains_switch(statement)) { /* only run contains_switch if you haven't checked before */ if (mother_exten) { @@ -3461,7 +3461,7 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, pr->origin = p; linkprio(exten, pr, mother_exten); break; - + case PV_GOTO: pr = new_prio(); pr->type = AEL_APPCALL; @@ -3469,22 +3469,22 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, if( p->u2.goto_target ) { p->u3.goto_target_in_case = label_inside_case(p->u2.goto_target); } - + if (!p->u1.list->next) /* just one */ { pr->app = strdup("Goto"); if (!mother_exten) pr->appargs = strdup(p->u1.list->u1.str); - else { /* for the case of simple within-extension gotos in case/pattern/default statement blocks: */ + else { /* for the case of simple within-extension gotos in case/pattern/default statement blocks: */ snprintf(buf1, BUF_SIZE, "%s,%s", mother_exten->name, p->u1.list->u1.str); pr->appargs = strdup(buf1); } - + } else if (p->u1.list->next && !p->u1.list->next->next) /* two */ { snprintf(buf1, BUF_SIZE, "%s,%s", p->u1.list->u1.str, p->u1.list->next->u1.str); pr->app = strdup("Goto"); pr->appargs = strdup(buf1); } else if (p->u1.list->next && p->u1.list->next->next) { - snprintf(buf1, BUF_SIZE, "%s,%s,%s", p->u1.list->u1.str, + snprintf(buf1, BUF_SIZE, "%s,%s,%s", p->u1.list->u1.str, p->u1.list->next->u1.str, p->u1.list->next->next->u1.str); pr->app = strdup("Goto"); @@ -3519,7 +3519,7 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, for_loop->type = AEL_CONTROL1; /* simple goto */ for_end->type = AEL_APPCALL; for_init->app = strdup("MSet"); - + strcpy(buf2,p->u1.for_init); remove_spaces_before_equals(buf2); strp = strchr(buf2, '='); @@ -3624,20 +3624,20 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, /* link & load! */ linkprio(exten, for_init, mother_exten); linkprio(exten, for_test, mother_exten); - + /* now, put the body of the for loop here */ exten->loop_break = for_end; exten->loop_continue = for_inc; - + if (gen_prios(exten, new_label, p->u4.for_statements, mother_exten, this_context)) { /* this will link in all the statements here */ return -1; } - + linkprio(exten, for_inc, mother_exten); linkprio(exten, for_loop, mother_exten); linkprio(exten, for_end, mother_exten); - - + + exten->loop_break = loop_break_save; exten->loop_continue = loop_continue_save; for_loop->origin = p; @@ -3664,19 +3664,19 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, while_end->appargs = strdup(buf1); linkprio(exten, while_test, mother_exten); - + /* now, put the body of the for loop here */ exten->loop_break = while_end; exten->loop_continue = while_test; - + if (gen_prios(exten, new_label, p->u2.statements, mother_exten, this_context)) { /* this will link in all the while body statements here */ return -1; } linkprio(exten, while_loop, mother_exten); linkprio(exten, while_end, mother_exten); - - + + exten->loop_break = loop_break_save; exten->loop_continue = loop_continue_save; while_loop->origin = p; @@ -3703,11 +3703,11 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, linkprio(exten, switch_test, mother_exten); linkprio(exten, switch_end, mother_exten); - + exten->loop_break = switch_end; exten->loop_continue = 0; default_exists = 0; - + for (p2=p->u2.statements; p2; p2=p2->next) { /* now, for each case/default put the body of the for loop here */ if (p2->type == PV_CASE) { @@ -3726,12 +3726,12 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, /* the break/continue locations are inherited from parent */ switch_case->loop_break = exten->loop_break; switch_case->loop_continue = exten->loop_continue; - + linkexten(exten,switch_case); snprintf(buf1, BUF_SIZE, "sw_%d_%s", local_control_statement_count, p2->u1.str); switch_case->name = strdup(buf1); snprintf(new_label, BUF_SIZE, "sw_%s_%s_%d", label, p2->u1.str, local_control_statement_count); - + if (gen_prios(switch_case, new_label, p2->u2.statements, exten, this_context)) { /* this will link in all the case body statements here */ return -1; } @@ -3870,7 +3870,7 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, } switch_case->context = this_context; switch_case->is_switch = 1; - + /* new: the default case intros a pattern with ., which covers ALMOST everything. but it doesn't cover a NULL pattern. So, we'll define a null extension to match that goto's the default extension. */ @@ -3904,13 +3904,13 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, linkexten(exten,switch_case); snprintf(buf1, BUF_SIZE, "_sw_%d_.", local_control_statement_count); switch_case->name = strdup(buf1); - + snprintf(new_label, BUF_SIZE, "sw_%s_default_%d", label, local_control_statement_count); - + if (gen_prios(switch_case, new_label, p2->u2.statements, exten, this_context)) { /* this will link in all the default: body statements here */ return -1; } - + /* here is where we write code to "fall thru" to the next case... if there is one... */ for (p3=p2->u2.statements; p3; p3=p3->next) { if (!p3->next) @@ -3963,7 +3963,7 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, /* what could it be??? */ } } - + exten->loop_break = loop_break_save; exten->loop_continue = loop_continue_save; switch_test->origin = p; @@ -4038,13 +4038,13 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, case PV_IFTIME: control_statement_count++; snprintf(new_label, BUF_SIZE, "iftime_%s_%d", label, control_statement_count); - + if_test = new_prio(); if_test->type = AEL_IFTIME_CONTROL; snprintf(buf1, BUF_SIZE, "%s,%s,%s,%s", - p->u1.list->u1.str, - p->u1.list->next->u1.str, - p->u1.list->next->next->u1.str, + p->u1.list->u1.str, + p->u1.list->next->u1.str, + p->u1.list->next->next->u1.str, p->u1.list->next->next->next->u1.str); if_test->app = 0; if_test->appargs = strdup(buf1); @@ -4075,33 +4075,33 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, } else { if_false->goto_true = if_end; } - + /* link & load! */ linkprio(exten, if_test, mother_exten); linkprio(exten, if_false, mother_exten); - + /* now, put the body of the if here */ - + if (gen_prios(exten, new_label, p->u2.statements, mother_exten, this_context)) { /* this will link in all the statements here */ return -1; } - + if (p->u3.else_statements) { linkprio(exten, if_skip, mother_exten); if (gen_prios(exten, new_label, p->u3.else_statements, mother_exten, this_context)) { /* this will link in all the statements here */ return -1; } } - + linkprio(exten, if_end, mother_exten); - + break; case PV_RANDOM: case PV_IF: control_statement_count++; snprintf(new_label, BUF_SIZE, "if_%s_%d", label, control_statement_count); - + if_test = new_prio(); if_end = new_prio(); if_test->type = AEL_IF_CONTROL; @@ -4116,7 +4116,7 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, if_end->app = strdup("NoOp"); if_end->appargs = strdup(buf1); if_test->origin = p; - + if (p->u3.else_statements) { if_skip = new_prio(); if_skip->type = AEL_CONTROL1; /* simple goto */ @@ -4126,25 +4126,25 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, if_skip = 0; if_test->goto_false = if_end;; } - + /* link & load! */ linkprio(exten, if_test, mother_exten); - + /* now, put the body of the if here */ - + if (gen_prios(exten, new_label, p->u2.statements, mother_exten, this_context)) { /* this will link in all the statements here */ return -1; } - + if (p->u3.else_statements) { linkprio(exten, if_skip, mother_exten); if (gen_prios(exten, new_label, p->u3.else_statements, mother_exten, this_context)) { /* this will link in all the statements here */ return -1; } } - + linkprio(exten, if_end, mother_exten); - + break; case PV_STATEMENTBLOCK: @@ -4166,12 +4166,12 @@ static int gen_prios(struct ael_extension *exten, char *label, pval *statement, switch_case->has_switch = exten->has_switch; switch_case->checked_switch = exten->checked_switch; } - + switch_case->context = this_context; linkexten(exten,switch_case); switch_case->name = strdup(p->u1.str); snprintf(new_label, BUF_SIZE, "catch_%s_%d",p->u1.str, control_statement_count); - + if (gen_prios(switch_case, new_label, p->u2.statements, mother_exten,this_context)) { /* this will link in all the catch body statements here */ return -1; } @@ -4205,17 +4205,17 @@ void set_priorities(struct ael_extension *exten) i=2; else i=1; - + for (pr=exten->plist; pr; pr=pr->next) { pr->priority_num = i; - + if (!pr->origin || (pr->origin && pr->origin->type != PV_LABEL) ) /* Labels don't show up in the dialplan, but we want them to point to the right priority, which would be the next line after the label; */ i++; } - + exten = exten->next_exten; } while ( exten ); } @@ -4231,16 +4231,16 @@ void add_extensions(struct ael_extension *exten) } do { struct ael_priority *last = 0; - + pbx_substitute_variables_helper(NULL, exten->name, realext, sizeof(realext) - 1); if (exten->hints) { - if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, PRIORITY_HINT, NULL, exten->cidmatch, + if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, PRIORITY_HINT, NULL, exten->cidmatch, exten->hints, NULL, ast_free_ptr, registrar)) { ast_log(LOG_WARNING, "Unable to add step at priority 'hint' of extension '%s'\n", exten->name); } } - + for (pr=exten->plist; pr; pr=pr->next) { char app[2000]; char appargs[2000]; @@ -4252,7 +4252,7 @@ void add_extensions(struct ael_extension *exten) last = pr; continue; } - + if (pr->app) strcpy(app, pr->app); else @@ -4265,7 +4265,7 @@ void add_extensions(struct ael_extension *exten) case AEL_APPCALL: /* easy case. Everything is all set up */ break; - + case AEL_CONTROL1: /* FOR loop, WHILE loop, BREAK, CONTINUE, IF, IFTIME */ /* simple, unconditional goto. */ strcpy(app,"Goto"); @@ -4276,12 +4276,12 @@ void add_extensions(struct ael_extension *exten) } else snprintf(appargs,sizeof(appargs),"%d", pr->goto_true->priority_num); break; - + case AEL_FOR_CONTROL: /* WHILE loop test, FOR loop test */ strcpy(app,"GotoIf"); snprintf(appargs,sizeof(appargs),"%s?%d:%d", pr->appargs, pr->priority_num+1, pr->goto_false->priority_num); break; - + case AEL_IF_CONTROL: strcpy(app,"GotoIf"); if (pr->origin->u3.else_statements ) @@ -4304,7 +4304,7 @@ void add_extensions(struct ael_extension *exten) strcpy(app,"Return"); appargs[0] = 0; break; - + default: break; } @@ -4313,10 +4313,10 @@ void add_extensions(struct ael_extension *exten) } else label = 0; - - if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, pr->priority_num, (label?label:NULL), exten->cidmatch, + + if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, pr->priority_num, (label?label:NULL), exten->cidmatch, app, strdup(appargs), ast_free_ptr, registrar)) { - ast_log(LOG_WARNING, "Unable to add step at priority '%d' of extension '%s'\n", pr->priority_num, + ast_log(LOG_WARNING, "Unable to add step at priority '%d' of extension '%s'\n", pr->priority_num, exten->name); } last = pr; @@ -4334,7 +4334,7 @@ static void attach_exten(struct ael_extension **list, struct ael_extension *newm return; } lptr = *list; - + while( lptr->next_exten ) { lptr = lptr->next_exten; } @@ -4345,20 +4345,20 @@ static void attach_exten(struct ael_extension **list, struct ael_extension *newm static pval *get_extension_or_contxt(pval *p) { while( p && p->type != PV_EXTENSION && p->type != PV_CONTEXT && p->type != PV_MACRO ) { - + p = p->dad; } - + return p; } static pval *get_contxt(pval *p) { while( p && p->type != PV_CONTEXT && p->type != PV_MACRO ) { - + p = p->dad; } - + return p; } @@ -4369,9 +4369,9 @@ static void fix_gotos_in_extensions(struct ael_extension *exten) struct ael_priority *p; for(p=e->plist;p;p=p->next) { - + if( p->origin && p->origin->type == PV_GOTO && p->origin->u3.goto_target_in_case ) { - + /* fix the extension of the goto target to the actual extension in the post-compiled dialplan */ pval *target = p->origin->u2.goto_target; @@ -4379,24 +4379,24 @@ static void fix_gotos_in_extensions(struct ael_extension *exten) pval *pv2 = p->origin; char buf1[500]; char *apparg_save = p->appargs; - + p->appargs = 0; if (!pv2->u1.list->next) /* just one -- it won't hurt to repeat the extension */ { snprintf(buf1,sizeof(buf1),"%s,%s", z->name, pv2->u1.list->u1.str); p->appargs = strdup(buf1); - + } else if (pv2->u1.list->next && !pv2->u1.list->next->next) /* two */ { snprintf(buf1,sizeof(buf1),"%s,%s", z->name, pv2->u1.list->next->u1.str); p->appargs = strdup(buf1); } else if (pv2->u1.list->next && pv2->u1.list->next->next) { - snprintf(buf1,sizeof(buf1),"%s,%s,%s", pv2->u1.list->u1.str, + snprintf(buf1,sizeof(buf1),"%s,%s,%s", pv2->u1.list->u1.str, z->name, pv2->u1.list->next->next->u1.str); p->appargs = strdup(buf1); } else printf("WHAT? The goto doesn't fall into one of three cases for GOTO????\n"); - + if( apparg_save ) { free(apparg_save); } @@ -4447,12 +4447,12 @@ int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *lo for (p=root; p; p=p->next ) { pval *lp; int argc; - + switch (p->type) { case PV_MACRO: - + context = ast_context_find_or_create(local_contexts, local_table, p->u1.str, registrar); - + exten = new_exten(); exten->context = context; exten->name = strdup("~~s~~"); @@ -4467,7 +4467,7 @@ int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *lo np2->appargs = strdup(buf); linkprio(exten, np2, NULL); } - + /* CONTAINS APPCALLS, CATCH, just like extensions... */ if (gen_prios(exten, p->u1.str, p->u3.macro_statements, 0, context)) { return -1; @@ -4481,35 +4481,35 @@ int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *lo linkprio(exten, np2, NULL); exten-> return_target = np2; } - + set_priorities(exten); attach_exten(&exten_list, exten); break; - + case PV_GLOBALS: /* already done */ break; - + case PV_CONTEXT: context = ast_context_find_or_create(local_contexts, local_table, p->u1.str, registrar); - + /* contexts contain: ignorepat, includes, switches, eswitches, extensions, */ for (p2=p->u2.statements; p2; p2=p2->next) { pval *p3; char *s3; - + switch (p2->type) { case PV_EXTENSION: exten = new_exten(); exten->name = strdup(p2->u1.str); exten->context = context; - + if( (s3=strchr(exten->name, '/') ) != 0 ) { *s3 = 0; exten->cidmatch = s3+1; } - + if ( p2->u3.hints ) exten->hints = strdup(p2->u3.hints); exten->regexten = p2->u4.regexten; @@ -4538,15 +4538,15 @@ int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *lo set_priorities(exten); attach_exten(&exten_list, exten); break; - + case PV_IGNOREPAT: ast_context_add_ignorepat2(context, p2->u1.str, registrar); break; - + case PV_INCLUDES: for (p3 = p2->u1.list; p3 ;p3=p3->next) { if ( p3->u2.arglist ) { - snprintf(buf,sizeof(buf), "%s,%s,%s,%s,%s", + snprintf(buf,sizeof(buf), "%s,%s,%s,%s,%s", p3->u1.str, p3->u2.arglist->u1.str, p3->u2.arglist->next->u1.str, @@ -4557,7 +4557,7 @@ int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *lo ast_context_add_include2(context, p3->u1.str, registrar); } break; - + case PV_SWITCHES: for (p3 = p2->u1.list; p3 ;p3=p3->next) { char *c = strchr(p3->u1.str, '/'); @@ -4587,13 +4587,13 @@ int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *lo break; } } - + break; - + default: /* huh? what? */ break; - + } } @@ -4667,7 +4667,7 @@ int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *lo fix_gotos_in_extensions(exten_list); /* find and fix extension ref in gotos to labels that are in case statements */ add_extensions(exten_list); /* actually makes calls to create priorities in ast_contexts -- feeds dialplan to asterisk */ destroy_extensions(exten_list); /* all that remains is an empty husk, discard of it as is proper */ - + return 0; } @@ -4685,7 +4685,7 @@ void destroy_pval_item(pval *item) if (item->filename) free(item->filename); - + switch (item->type) { case PV_WORD: /* fields: item->u1.str == string associated with this (word). */ @@ -4694,7 +4694,7 @@ void destroy_pval_item(pval *item) if ( item->u2.arglist ) destroy_pval(item->u2.arglist); break; - + case PV_MACRO: /* fields: item->u1.str == name of macro item->u2.arglist == pval list of PV_WORD arguments of macro, as given by user @@ -4708,7 +4708,7 @@ void destroy_pval_item(pval *item) free(item->u1.str); destroy_pval(item->u3.macro_statements); break; - + case PV_CONTEXT: /* fields: item->u1.str == name of context item->u2.statements == pval list of statements in context body @@ -4718,7 +4718,7 @@ void destroy_pval_item(pval *item) free(item->u1.str); destroy_pval(item->u2.statements); break; - + case PV_MACRO_CALL: /* fields: item->u1.str == name of macro to call item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user @@ -4729,7 +4729,7 @@ void destroy_pval_item(pval *item) free(item->u1.str); destroy_pval(item->u2.arglist); break; - + case PV_APPLICATION_CALL: /* fields: item->u1.str == name of application to call item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user @@ -4740,7 +4740,7 @@ void destroy_pval_item(pval *item) free(item->u1.str); destroy_pval(item->u2.arglist); break; - + case PV_CASE: /* fields: item->u1.str == value of case item->u2.statements == pval list of statements under the case @@ -4749,7 +4749,7 @@ void destroy_pval_item(pval *item) free(item->u1.str); destroy_pval(item->u2.statements); break; - + case PV_PATTERN: /* fields: item->u1.str == value of case item->u2.statements == pval list of statements under the case @@ -4758,14 +4758,14 @@ void destroy_pval_item(pval *item) free(item->u1.str); destroy_pval(item->u2.statements); break; - + case PV_DEFAULT: - /* fields: + /* fields: item->u2.statements == pval list of statements under the case */ destroy_pval(item->u2.statements); break; - + case PV_CATCH: /* fields: item->u1.str == name of extension to catch item->u2.statements == pval list of statements in context body @@ -4774,32 +4774,32 @@ void destroy_pval_item(pval *item) free(item->u1.str); destroy_pval(item->u2.statements); break; - + case PV_SWITCHES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list */ destroy_pval(item->u1.list); break; - + case PV_ESWITCHES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list */ destroy_pval(item->u1.list); break; - + case PV_INCLUDES: /* fields: item->u1.list == pval list of PV_WORD elements, one per entry in the list item->u2.arglist == pval list of 4 PV_WORD elements for time values */ destroy_pval(item->u1.list); break; - + case PV_STATEMENTBLOCK: /* fields: item->u1.list == pval list of statements in block, one per entry in the list */ destroy_pval(item->u1.list); break; - + case PV_LOCALVARDEC: case PV_VARDEC: /* fields: item->u1.str == variable name @@ -4810,22 +4810,22 @@ void destroy_pval_item(pval *item) if (item->u2.val) free(item->u2.val); break; - + case PV_GOTO: /* fields: item->u1.list == pval list of PV_WORD target names, up to 3, in order as given by user. item->u1.list->u1.str == where the data on a PV_WORD will always be. */ - + destroy_pval(item->u1.list); break; - + case PV_LABEL: /* fields: item->u1.str == label name */ if (item->u1.str) free(item->u1.str); break; - + case PV_FOR: /* fields: item->u1.for_init == a string containing the initalizer item->u2.for_test == a string containing the loop test @@ -4841,7 +4841,7 @@ void destroy_pval_item(pval *item) free(item->u3.for_inc); destroy_pval(item->u4.for_statements); break; - + case PV_WHILE: /* fields: item->u1.str == the while conditional, as supplied by user @@ -4851,22 +4851,22 @@ void destroy_pval_item(pval *item) free(item->u1.str); destroy_pval(item->u2.statements); break; - + case PV_BREAK: /* fields: none */ break; - + case PV_RETURN: /* fields: none */ break; - + case PV_CONTINUE: /* fields: none */ break; - + case PV_IFTIME: /* fields: item->u1.list == the 4 time values, in PV_WORD structs, linked list @@ -4880,7 +4880,7 @@ void destroy_pval_item(pval *item) destroy_pval(item->u3.else_statements); } break; - + case PV_RANDOM: /* fields: item->u1.str == the random percentage, as supplied by user @@ -4902,18 +4902,18 @@ void destroy_pval_item(pval *item) destroy_pval(item->u3.else_statements); } break; - + case PV_SWITCH: /* fields: item->u1.str == the switch expression - item->u2.statements == a pval list of statements in the switch, + item->u2.statements == a pval list of statements in the switch, (will be case statements, most likely!) */ if (item->u1.str) free(item->u1.str); destroy_pval(item->u2.statements); break; - + case PV_EXTENSION: /* fields: item->u1.str == the extension name, label, whatever it's called @@ -4927,14 +4927,14 @@ void destroy_pval_item(pval *item) free(item->u3.hints); destroy_pval(item->u2.statements); break; - + case PV_IGNOREPAT: /* fields: item->u1.str == the ignorepat data */ if (item->u1.str) free(item->u1.str); break; - + case PV_GLOBALS: /* fields: item->u1.statements == pval list of statements, usually vardecs */ @@ -4944,13 +4944,13 @@ void destroy_pval_item(pval *item) free(item); } -void destroy_pval(pval *item) +void destroy_pval(pval *item) { pval *i,*nxt; - + for (i=item; i; i=nxt) { nxt = i->next; - + destroy_pval_item(i); } } @@ -5020,14 +5020,14 @@ int ael_is_funcname(char *name) int s,t; t = sizeof(ael_funclist)/sizeof(char*); s = 0; - while ((s < t) && strcasecmp(name, ael_funclist[s])) + while ((s < t) && strcasecmp(name, ael_funclist[s])) s++; if ( s < t ) return 1; else return 0; } -#endif +#endif /* PVAL PI */ @@ -5130,7 +5130,7 @@ void pvalMacroAddStatement( pval *p, pval *statement ) else linku1(p->u3.macro_statements, statement); - + } pval *pvalMacroWalkStatements( pval *p, pval **next_statement ) @@ -5534,35 +5534,35 @@ char* pvalVarDecGetValue( pval *p ) void pvalGotoSetTarget( pval *p, char *context, char *exten, char *label ) { pval *con, *ext, *pri; - + if (!pvalCheckType(p, "pvalGotoSetTarget", PV_GOTO)) return; if (context && strlen(context)) { con = pvalCreateNode(PV_WORD); ext = pvalCreateNode(PV_WORD); pri = pvalCreateNode(PV_WORD); - + con->u1.str = context; ext->u1.str = exten; pri->u1.str = label; - + con->next = ext; ext->next = pri; p->u1.list = con; } else if (exten && strlen(exten)) { ext = pvalCreateNode(PV_WORD); pri = pvalCreateNode(PV_WORD); - + ext->u1.str = exten; pri->u1.str = label; - + ext->next = pri; p->u1.list = ext; } else { pri = pvalCreateNode(PV_WORD); - + pri->u1.str = label; - + p->u1.list = pri; } } @@ -5575,7 +5575,7 @@ void pvalGotoGetTarget( pval *p, char **context, char **exten, char **label ) *context = p->u1.list->u1.str; *exten = p->u1.list->next->u1.str; *label = p->u1.list->next->next->u1.str; - + } else if (p->u1.list && p->u1.list->next ) { *exten = p->u1.list->u1.str; *label = p->u1.list->next->u1.str; @@ -5585,7 +5585,7 @@ void pvalGotoGetTarget( pval *p, char **context, char **exten, char **label ) *label = p->u1.list->u1.str; *context = 0; *exten = 0; - + } else { *context = 0; *exten = 0; @@ -5941,4 +5941,3 @@ pval * linku1(pval *head, pval *tail) } return head; } - diff --git a/res/ari/ari_model_validators.h b/res/ari/ari_model_validators.h index 403a5fb17..d40a8c9d6 100644 --- a/res/ari/ari_model_validators.h +++ b/res/ari/ari_model_validators.h @@ -148,7 +148,7 @@ int ast_ari_validate_list(struct ast_json *json, int (*fn)(struct ast_json *)); /*! @} */ /*! - * \brief Function type for validator functions. Allows for + * \brief Function type for validator functions. Allows for */ typedef int (*ari_validator)(struct ast_json *json); diff --git a/res/ari/ari_websockets.c b/res/ari/ari_websockets.c index 6a296dcf6..768e24e80 100644 --- a/res/ari/ari_websockets.c +++ b/res/ari/ari_websockets.c @@ -155,7 +155,7 @@ struct ast_json *ast_ari_websocket_session_read( "{" \ " \"error\": \"InvalidMessage\"," \ " \"message\": \"Message validation failed\"" \ - "}" + "}" int ast_ari_websocket_session_write(struct ast_ari_websocket_session *session, struct ast_json *message) diff --git a/res/ari/config.c b/res/ari/config.c index 2d3a80d0b..275f41d96 100644 --- a/res/ari/config.c +++ b/res/ari/config.c @@ -39,8 +39,8 @@ static struct aco_type general_option = { .type = ACO_GLOBAL, .name = "general", .item_offset = offsetof(struct ast_ari_conf, general), - .category = "^general$", - .category_match = ACO_WHITELIST, + .category = "general", + .category_match = ACO_WHITELIST_EXACT, }; static struct aco_type *general_options[] = ACO_TYPES(&general_option); @@ -156,8 +156,8 @@ static void *user_find(struct ao2_container *tmp_container, const char *cat) static struct aco_type user_option = { .type = ACO_ITEM, .name = "user", - .category_match = ACO_BLACKLIST, - .category = "^general$", + .category_match = ACO_BLACKLIST_EXACT, + .category = "general", .matchfield = "type", .matchvalue = "user", .item_alloc = user_alloc, diff --git a/res/ari/resource_events.c b/res/ari/resource_events.c index 028144676..fb996f798 100644 --- a/res/ari/resource_events.c +++ b/res/ari/resource_events.c @@ -128,7 +128,7 @@ static void app_handler(void *data, const char *app_name, if (!session) { return; } - + /* Determine if we've been replaced */ if (strcmp(msg_type, "ApplicationReplaced") == 0 && strcmp(msg_application, app_name) == 0) { @@ -339,4 +339,3 @@ void ast_ari_events_user_event(struct ast_variable *headers, "Error processing request"); } } - diff --git a/res/parking/res_parking.h b/res/parking/res_parking.h index b8be0419b..6fbde0921 100644 --- a/res/parking/res_parking.h +++ b/res/parking/res_parking.h @@ -135,7 +135,7 @@ struct parking_lot_cfg *parking_lot_cfg_create(const char *cat); * \param dynamic non-zero if creating a dynamic parking lot with this. Don't replace existing parking lots. Ever. * * \retval A reference to the new parking lot - * \retval NULL if it was not found and could not be be allocated + * \retval NULL if it was not found and could not be allocated * * \note The parking lot will need to be unreffed if it ever falls out of scope * \note The parking lot will automatically be added to the parking lot container if needed as part of this process diff --git a/res/res_ael_share.c b/res/res_ael_share.c index bbe870b10..0918f53b3 100644 --- a/res/res_ael_share.c +++ b/res/res_ael_share.c @@ -21,7 +21,7 @@ * \brief Shareable AEL code -- mainly between internal and external modules * * \author Steve Murphy <murf@digium.com> - * + * * \ingroup applications */ diff --git a/res/res_agi.c b/res/res_agi.c index 4caa13bb1..f19303f4d 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -2048,7 +2048,7 @@ static int handle_connection(const char *agiurl, const struct ast_sockaddr addr, FastAGI defaults to port 4573 */ static enum agi_result launch_netscript(char *agiurl, char *argv[], int *fds) { - int s = 0, flags; + int s = 0; char *host, *script; int num_addrs = 0, i = 0; struct ast_sockaddr *addrs; @@ -2078,14 +2078,7 @@ static enum agi_result launch_netscript(char *agiurl, char *argv[], int *fds) continue; } - if ((flags = fcntl(s, F_GETFL)) < 0) { - ast_log(LOG_WARNING, "fcntl(F_GETFL) failed: %s\n", strerror(errno)); - close(s); - continue; - } - - if (fcntl(s, F_SETFL, flags | O_NONBLOCK) < 0) { - ast_log(LOG_WARNING, "fnctl(F_SETFL) failed: %s\n", strerror(errno)); + if (ast_fd_set_flags(s, O_NONBLOCK)) { close(s); continue; } @@ -2251,9 +2244,8 @@ static enum agi_result launch_script(struct ast_channel *chan, char *script, int close(toast[1]); return AGI_RESULT_FAILURE; } - res = fcntl(audio[1], F_GETFL); - if (res > -1) - res = fcntl(audio[1], F_SETFL, res | O_NONBLOCK); + + res = ast_fd_set_flags(audio[1], O_NONBLOCK); if (res < 0) { ast_log(LOG_WARNING, "unable to set audio pipe parameters: %s\n", strerror(errno)); close(fromast[0]); diff --git a/res/res_calendar.c b/res/res_calendar.c index 16a326563..e8ad49910 100644 --- a/res/res_calendar.c +++ b/res/res_calendar.c @@ -18,7 +18,7 @@ /*! \file * \brief Calendaring API - * + * * \todo Support responding to a meeting invite * \todo Support writing attendees */ @@ -27,7 +27,7 @@ * \addtogroup configuration_file Configuration Files */ -/*! +/*! * \page calendar.conf calendar.conf * \verbinclude calendar.conf.sample */ @@ -1859,8 +1859,8 @@ static int unload_module(void) * Module loading including tests for configuration or dependencies. * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails - * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the - * configuration file or other non-critical problem return + * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the + * configuration file or other non-critical problem return * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS. */ static int load_module(void) diff --git a/res/res_calendar_caldav.c b/res/res_calendar_caldav.c index 02a44c72f..0d938d295 100644 --- a/res/res_calendar_caldav.c +++ b/res/res_calendar_caldav.c @@ -322,7 +322,7 @@ static struct ast_str *caldav_get_events_between(struct caldav_pvt *pvt, time_t return response; } -static time_t icalfloat_to_timet(icaltimetype time) +static time_t icalfloat_to_timet(icaltimetype time) { struct ast_tm tm = {0,}; struct timeval tv; diff --git a/res/res_calendar_icalendar.c b/res/res_calendar_icalendar.c index 4e335dd97..e5d80b4b8 100644 --- a/res/res_calendar_icalendar.c +++ b/res/res_calendar_icalendar.c @@ -161,7 +161,7 @@ static icalcomponent *fetch_icalendar(struct icalendar_pvt *pvt) return comp; } -static time_t icalfloat_to_timet(icaltimetype time) +static time_t icalfloat_to_timet(icaltimetype time) { struct ast_tm tm = {0,}; struct timeval tv; diff --git a/res/res_clialiases.c b/res/res_clialiases.c index 633ed89f4..355d437ab 100644 --- a/res/res_clialiases.c +++ b/res/res_clialiases.c @@ -21,7 +21,7 @@ * \brief CLI Aliases * * \author\verbatim Joshua Colp <jcolp@digium.com> \endverbatim - * + * * This module provides the capability to create aliases to other * CLI commands. */ @@ -30,7 +30,7 @@ * \addtogroup configuration_file Configuration Files */ -/*! +/*! * \page cli_aliases.conf cli_aliases.conf * \verbinclude cli_aliases.conf.sample */ @@ -105,7 +105,7 @@ static char *cli_alias_passthrough(struct ast_cli_entry *e, int cmd, struct ast_ struct cli_alias tmp = { .cli_entry.command = e->command, }; - char *generator; + char *generator = NULL; const char *line; /* Try to find the alias based on the CLI entry */ @@ -120,14 +120,10 @@ static char *cli_alias_passthrough(struct ast_cli_entry *e, int cmd, struct ast_ case CLI_GENERATE: line = a->line; line += (strlen(alias->alias)); - if (!strncasecmp(alias->alias, alias->real_cmd, strlen(alias->alias))) { - generator = NULL; - } else if (!ast_strlen_zero(a->word)) { + if (strncasecmp(alias->alias, alias->real_cmd, strlen(alias->alias))) { struct ast_str *real_cmd = ast_str_alloca(strlen(alias->real_cmd) + strlen(line) + 1); ast_str_append(&real_cmd, 0, "%s%s", alias->real_cmd, line); generator = ast_cli_generator(ast_str_buffer(real_cmd), a->word, a->n); - } else { - generator = ast_cli_generator(alias->real_cmd, a->word, a->n); } ao2_ref(alias, -1); return generator; @@ -282,8 +278,8 @@ static int unload_module(void) * Module loading including tests for configuration or dependencies. * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails - * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the - * configuration file or other non-critical problem return + * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the + * configuration file or other non-critical problem return * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS. */ static int load_module(void) diff --git a/res/res_config_curl.c b/res/res_config_curl.c index bc1a3fb35..61b62452d 100644 --- a/res/res_config_curl.c +++ b/res/res_config_curl.c @@ -23,7 +23,7 @@ * \author Tilghman Lesher <res_config_curl_v1@the-tilghman.com> * * Depends on the CURL library - http://curl.haxx.se/ - * + * */ /*** MODULEINFO diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c index a21aa31a8..78f1fa80e 100644 --- a/res/res_config_ldap.c +++ b/res/res_config_ldap.c @@ -35,7 +35,7 @@ * \addtogroup configuration_file Configuration Files */ -/*! +/*! * \page res_ldap.conf res_ldap.conf * \verbinclude res_ldap.conf.sample */ @@ -92,7 +92,7 @@ struct category_and_metric { int var_metric; /*!< For organizing variables (particularly includes and switch statments) within a context */ }; -/*! \brief Table configuration +/*! \brief Table configuration */ struct ldap_table_config { char *table_name; /*!< table name */ @@ -103,7 +103,7 @@ struct ldap_table_config { /* TODO: Make proxies work */ }; -/*! \brief Should be locked before using it +/*! \brief Should be locked before using it */ static AST_LIST_HEAD_NOLOCK_STATIC(table_configs, ldap_table_config); static struct ldap_table_config *base_table_config; @@ -134,7 +134,7 @@ static struct ldap_table_config *table_config_new(const char *table_name) /*! \brief Find a table_config * - * Should be locked before using it + * Should be locked before using it * * \note This function assumes ldap_lock to be locked. */ @@ -180,7 +180,7 @@ static int semicolon_count_str(const char *somestr) } /* \brief Count semicolons in variables - * + * * takes a linked list of \a ast_variable variables, finds the one with the name variable_value * and returns the number of semicolons in the value for that \a ast_variable */ @@ -273,7 +273,7 @@ static const char *convert_attribute_name_to_ldap(struct ldap_table_config *tabl return attribute_name; } -/*! \brief Convert ldap attribute name to variable name +/*! \brief Convert ldap attribute name to variable name * * \note Should be locked before using it */ @@ -301,7 +301,7 @@ static const char *convert_attribute_name_from_ldap(struct ldap_table_config *ta return attribute_name; } -/*! \brief Get variables from ldap entry attributes +/*! \brief Get variables from ldap entry attributes * \note Should be locked before using it * \return a linked list of ast_variable variables. */ @@ -311,8 +311,10 @@ static struct ast_variable *realtime_ldap_entry_to_var(struct ldap_table_config BerElement *ber = NULL; struct ast_variable *var = NULL; struct ast_variable *prev = NULL; +#if 0 int is_delimited = 0; int i = 0; +#endif char *ldap_attribute_name; struct berval *value; int pos = 0; @@ -340,6 +342,7 @@ static struct ast_variable *realtime_ldap_entry_to_var(struct ldap_table_config ast_debug(2, "md5: %s\n", valptr); } if (valptr) { +#if 0 /* ok, so looping through all delimited values except the last one (not, last character is not delimited...) */ if (is_delimited) { i = 0; @@ -360,6 +363,7 @@ static struct ast_variable *realtime_ldap_entry_to_var(struct ldap_table_config i++; } } +#endif /* for the last delimited value or if the value is not delimited: */ if (prev) { prev->next = ast_variable_new(attribute_name, &valptr[pos], table_config->table_name); @@ -384,7 +388,7 @@ static struct ast_variable *realtime_ldap_entry_to_var(struct ldap_table_config /*! \brief Get variables from ldap entry attributes - Should be locked before using it * * The results are freed outside this function so is the \a vars array. - * + * * \return \a vars - an array of ast_variable variables terminated with a null. */ static struct ast_variable **realtime_ldap_result_to_vars(struct ldap_table_config *table_config, @@ -407,7 +411,7 @@ static struct ast_variable **realtime_ldap_result_to_vars(struct ldap_table_conf */ ldap_entry = ldap_first_entry(ldapConn, ldap_result_msg); - for (tot_count = 0; ldap_entry; tot_count++) { + for (tot_count = 0; ldap_entry; tot_count++) { struct ast_variable *tmp = realtime_ldap_entry_to_var(table_config, ldap_entry); tot_count += semicolon_count_var(tmp); ldap_entry = ldap_next_entry(ldapConn, ldap_entry); @@ -582,7 +586,7 @@ static int is_ldap_connect_error(int err) /*! \brief Get LDAP entry by dn and return attributes as variables * - * Should be locked before using it + * Should be locked before using it * * This is used for setting the default values of an object * i.e., with accountBaseDN @@ -704,7 +708,7 @@ static char *cleaned_basedn(struct ast_channel *channel, const char *basedn) return cbasedn; } -/*! \brief Replace \<search\> by \<by\> in string. +/*! \brief Replace \<search\> by \<by\> in string. * \note No check is done on string allocated size ! */ static int replace_string_in_string(char *string, const char *search, const char *by) @@ -729,7 +733,7 @@ static int replace_string_in_string(char *string, const char *search, const char return replaced; } -/*! \brief Append a name=value filter string. The filter string can grow. +/*! \brief Append a name=value filter string. The filter string can grow. */ static void append_var_and_value_to_filter(struct ast_str **filter, struct ldap_table_config *table_config, @@ -797,7 +801,7 @@ static struct ast_str *create_lookup_filter(struct ldap_table_config *config, co return filter; } -/*! \brief LDAP base function +/*! \brief LDAP base function * \return a null terminated array of ast_variable (one per entry) or NULL if no entry is found or if an error occured * caller should free the returned array and ast_variables * \param entries_count_ptr is a pointer to found entries count (can be NULL) @@ -821,7 +825,7 @@ static struct ast_variable **realtime_ldap_base_ap(unsigned int *entries_count_p ast_log(LOG_ERROR, "No table_name specified.\n"); ast_free(clean_basedn); return NULL; - } + } if (!field) { ast_log(LOG_ERROR, "Realtime retrieval requires at least 1 parameter" @@ -878,7 +882,7 @@ static struct ast_variable **realtime_ldap_base_ap(unsigned int *entries_count_p ast_log(LOG_WARNING, "Failed to query directory. Error: %s.\n", ldap_err2string(result)); ast_log(LOG_WARNING, "Query: %s\n", ast_str_buffer(filter)); } else { - /* this is where we create the variables from the search result + /* this is where we create the variables from the search result * freeing this \a vars outside this function */ if (ldap_count_entries(ldapConn, ldap_result_msg) > 0) { /* is this a static var or some other? they are handled different for delimited values */ @@ -900,7 +904,7 @@ static struct ast_variable **realtime_ldap_base_ap(unsigned int *entries_count_p if (strcasecmp(tmp->name, "accountBaseDN") == 0) { /* Get the variable to compare with for the defaults */ struct ast_variable *base_var = ldap_loadentry(table_config, tmp->value); - + while (base_var) { struct ast_variable *next = base_var->next; struct ast_variable *test_var = *p; @@ -1103,7 +1107,7 @@ static int compare_categories(const void *a, const void *b) return 1; } else if (as->metric == bs->metric && strcmp(as->name, bs->name) != 0) { return strcmp(as->name, bs->name); - } + } /* if the metric and the category name is the same, we check the variable metric */ if (as->var_metric < bs->var_metric) { return -1; @@ -1117,7 +1121,7 @@ static int compare_categories(const void *a, const void *b) /*! \brief See Asterisk Realtime Documentation * * This is for Static Realtime - * + * * load the configuration stuff for the .conf files * called on a reload */ @@ -1703,8 +1707,8 @@ static struct ast_config_engine ldap_engine = { * Module loading including tests for configuration or dependencies. * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails - * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the - * configuration file or other non-critical problem return + * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the + * configuration file or other non-critical problem return * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS. * * \todo Don't error or warn on a default install. If the config is @@ -1772,7 +1776,7 @@ static int reload(void) ast_log(LOG_NOTICE, "Cannot reload LDAP RealTime driver.\n"); ast_mutex_unlock(&ldap_lock); return 0; - } + } if (!ldap_reconnect()) { ast_log(LOG_WARNING, "Couldn't establish connection to your directory server. Check debug.\n"); @@ -1859,7 +1863,7 @@ static int parse_config(void) if (!(s = ast_variable_retrieve(config, "_general", "basedn"))) { ast_log(LOG_ERROR, "No LDAP base dn found, using '%s' as default.\n", RES_CONFIG_LDAP_DEFAULT_BASEDN); ast_copy_string(base_distinguished_name, RES_CONFIG_LDAP_DEFAULT_BASEDN, sizeof(base_distinguished_name)); - } else + } else ast_copy_string(base_distinguished_name, s, sizeof(base_distinguished_name)); if (!(s = ast_variable_retrieve(config, "_general", "version")) && !(s = ast_variable_retrieve(config, "_general", "protocol"))) { @@ -1875,7 +1879,7 @@ static int parse_config(void) int is_general = (strcasecmp(category_name, "_general") == 0); int is_config = (strcasecmp(category_name, "config") == 0); /*!< using the [config] context for Static RealTime */ struct ast_variable *var = ast_variable_browse(config, category_name); - + if (var) { struct ldap_table_config *table_config = table_config_for_table_name(category_name); @@ -1974,7 +1978,7 @@ static char *realtime_ldap_status(struct ast_cli_entry *e, int cmd, struct ast_c if (!ldapConn) return CLI_FAILURE; - if (!ast_strlen_zero(url)) + if (!ast_strlen_zero(url)) snprintf(status, sizeof(status), "Connected to '%s', baseDN %s", url, base_distinguished_name); if (!ast_strlen_zero(user)) diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c index 583a84558..e86445088 100644 --- a/res/res_config_odbc.c +++ b/res/res_config_odbc.c @@ -145,7 +145,7 @@ static SQLHSTMT custom_prepare(struct odbc_obj *obj, void *data) ENCODE_CHUNK(encodebuf, newval); ast_string_field_set(cps, encoding[x], encodebuf); newval = cps->encoding[x]; - } + } SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, NULL); } @@ -245,7 +245,7 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl for (x = 0; x < colcount; x++) { colsize = 0; collen = sizeof(coltitle); - res = SQLDescribeCol(stmt, x + 1, (unsigned char *)coltitle, sizeof(coltitle), &collen, + res = SQLDescribeCol(stmt, x + 1, (unsigned char *)coltitle, sizeof(coltitle), &collen, &datatype, &colsize, &decimaldigits, &nullable); if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) { ast_log(LOG_WARNING, "SQL Describe Column error! [%s]\n", ast_str_buffer(sql)); @@ -315,7 +315,7 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl * \param ap list containing one or more field/operator/value set. * * Select database and preform query on table, prepare the sql statement - * Sub-in the values to the prepared statement and execute it. + * Sub-in the values to the prepared statement and execute it. * Execute this prepared query against several ODBC connected databases. * Return results as an ast_config variable. * @@ -416,7 +416,7 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char * for (x=0;x<colcount;x++) { colsize = 0; collen = sizeof(coltitle); - res = SQLDescribeCol(stmt, x + 1, (unsigned char *)coltitle, sizeof(coltitle), &collen, + res = SQLDescribeCol(stmt, x + 1, (unsigned char *)coltitle, sizeof(coltitle), &collen, &datatype, &colsize, &decimaldigits, &nullable); if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) { ast_log(LOG_WARNING, "SQL Describe Column error! [%s]\n", ast_str_buffer(sql)); @@ -1015,7 +1015,7 @@ static struct ast_config *config_odbc(const char *database, const char *table, c return NULL; } continue; - } + } if (strcmp(last, q.category) || last_cat_metric != q.cat_metric) { cur_cat = ast_category_new_dynamic(q.category); if (!cur_cat) { diff --git a/res/res_config_sqlite.c b/res/res_config_sqlite.c index fa45fec35..1834333a0 100644 --- a/res/res_config_sqlite.c +++ b/res/res_config_sqlite.c @@ -27,7 +27,7 @@ * res_config_sqlite is a module for the Asterisk Open Source PBX to * support SQLite 2 databases. It can be used to fetch configuration * from a database (static configuration files and/or using the Asterisk - * RealTime Architecture - ARA). It can also be used to log CDR entries. + * RealTime Architecture - ARA). It can also be used to log CDR entries. * Note that Asterisk already comes with a module named cdr_sqlite. * There are two reasons for including it in res_config_sqlite: * the first is that rewriting it was a training to learn how to write a @@ -75,7 +75,7 @@ * \addtogroup configuration_file Configuration Files */ -/*! +/*! * \page res_config_sqlite.conf res_config_sqlite.conf * \verbinclude res_config_sqlite.conf.sample */ @@ -431,7 +431,7 @@ static int realtime_destroy_handler(const char *database, const char *table, * \brief Asterisk callback function for the CLI status command. * * \param e CLI command - * \param cmd + * \param cmd * \param a CLI argument list * \return RESULT_SUCCESS */ @@ -1657,8 +1657,8 @@ static int unload_module(void) * Module loading including tests for configuration or dependencies. * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails - * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the - * configuration file or other non-critical problem return + * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the + * configuration file or other non-critical problem return * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS. */ static int load_module(void) diff --git a/res/res_config_sqlite3.c b/res/res_config_sqlite3.c index 56558624f..a03397034 100644 --- a/res/res_config_sqlite3.c +++ b/res/res_config_sqlite3.c @@ -33,7 +33,7 @@ * \addtogroup configuration_file Configuration Files */ -/*! +/*! * \page res_config_sqlite3.conf res_config_sqlite3.conf * \verbinclude res_config_sqlite3.conf.sample */ @@ -1171,7 +1171,7 @@ static int realtime_sqlite3_require(const char *database, const char *table, va_ struct realtime_sqlite3_db *db; /* SQLite3 columns are dynamically typed, with type affinity. Built-in functions will - * return the results as char * anyway. The only field that that cannot contain text + * return the results as char * anyway. The only field that cannot contain text * data is an INTEGER PRIMARY KEY, which must be a 64-bit signed integer. So, for * the purposes here we really only care whether the column exists and not what its * type or length is. */ @@ -1352,8 +1352,8 @@ static void discover_sqlite3_caps(void) * Module loading including tests for configuration or dependencies. * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails - * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the - * configuration file or other non-critical problem return + * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the + * configuration file or other non-critical problem return * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS. */ static int load_module(void) diff --git a/res/res_convert.c b/res/res_convert.c index c2966a85f..3fa9d515a 100644 --- a/res/res_convert.c +++ b/res/res_convert.c @@ -18,13 +18,13 @@ */ /*! \file - * + * * \brief file format conversion CLI command using Asterisk formats and translators * * \author redice li <redice_li@yahoo.com> * \author Russell Bryant <russell@digium.com> * - */ + */ /*** MODULEINFO <support_level>core</support_level> @@ -43,7 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static int split_ext(char *filename, char **name, char **ext) { *name = *ext = filename; - + if ((*ext = strrchr(filename, '.'))) { **ext = '\0'; (*ext)++; @@ -55,8 +55,8 @@ static int split_ext(char *filename, char **name, char **ext) return 0; } -/*! - * \brief Convert a file from one format to another +/*! + * \brief Convert a file from one format to another * \param e CLI entry * \param cmd command number * \param a list of cli arguments @@ -87,13 +87,13 @@ static char *handle_cli_file_convert(struct ast_cli_entry *e, int cmd, struct as case CLI_GENERATE: return NULL; } - + /* ugly, can be removed when CLI entries have ast_module pointers */ ast_module_ref(ast_module_info->self); if (a->argc != 4 || ast_strlen_zero(a->argv[2]) || ast_strlen_zero(a->argv[3])) { ret = CLI_SHOWUSAGE; - goto fail_out; + goto fail_out; } file_in = ast_strdupa(a->argv[2]); @@ -107,7 +107,7 @@ static char *handle_cli_file_convert(struct ast_cli_entry *e, int cmd, struct as ast_cli(a->fd, "Unable to open input file: %s\n", a->argv[2]); goto fail_out; } - + if (split_ext(file_out, &name_out, &ext_out)) { ast_cli(a->fd, "'%s' is an invalid filename!\n", a->argv[3]); goto fail_out; @@ -118,7 +118,7 @@ static char *handle_cli_file_convert(struct ast_cli_entry *e, int cmd, struct as } start = ast_tvnow(); - + while ((f = ast_readframe(fs_in))) { if (ast_writestream(fs_out, f)) { ast_frfree(f); @@ -139,7 +139,7 @@ fail_out: ast_filedelete(name_out, ext_out); } - if (fs_in) + if (fs_in) ast_closestream(fs_in); ast_module_unref(ast_module_info->self); diff --git a/res/res_corosync.c b/res/res_corosync.c index ce94e4151..af8afdb7f 100644 --- a/res/res_corosync.c +++ b/res/res_corosync.c @@ -1205,4 +1205,3 @@ static int unload_module(void) } AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Corosync"); - diff --git a/res/res_curl.c b/res/res_curl.c index 4906dde77..aa10eff91 100644 --- a/res/res_curl.c +++ b/res/res_curl.c @@ -23,14 +23,14 @@ * \author Tilghman Lesher <res_curl_v1@the-tilghman.com> * * Depends on the CURL library - http://curl.haxx.se/ - * + * */ /*! \li \ref res_curl.c uses the configuration file \ref res_curl.conf * \addtogroup configuration_file Configuration Files */ -/*! +/*! * \page res_curl.conf res_curl.conf * \verbinclude res_curl.conf.sample */ @@ -61,7 +61,9 @@ static int unload_module(void) /* If the dependent modules are still in memory, forbid unload */ for (i = 0; i < ARRAY_LEN(dependents); i++) { if (ast_module_check(dependents[i])) { - ast_log(LOG_ERROR, "%s (dependent module) is still loaded. Cannot unload res_curl.so\n", dependents[i]); + if (!ast_shutting_down()) { + ast_log(LOG_WARNING, "%s (dependent module) is still loaded. Cannot unload res_curl.so\n", dependents[i]); + } res = -1; } } @@ -74,19 +76,9 @@ static int unload_module(void) return res; } -/*! - * \brief Load the module - * - * Module loading including tests for configuration or dependencies. - * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, - * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails - * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the - * configuration file or other non-critical problem return - * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS. - */ static int load_module(void) { - int res = 0; + int res = AST_MODULE_LOAD_SUCCESS; if (curl_global_init(CURL_GLOBAL_ALL)) { ast_log(LOG_ERROR, "Unable to initialize the cURL library. Cannot load res_curl.so\n"); diff --git a/res/res_fax.c b/res/res_fax.c index 6e4451b67..823d560d9 100644 --- a/res/res_fax.c +++ b/res/res_fax.c @@ -365,7 +365,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") 'gateway' and state is 'Uninitialized'.</para> </parameter> <parameter name="FileName" required="false"> - <para>Filename of the image being sent/recieved for this FAX session. This field is not + <para>Filename of the image being sent/received for this FAX session. This field is not included if Operation isn't 'send' or 'receive'.</para> </parameter> <parameter name="PagesTransmitted" required="false"> @@ -377,7 +377,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") Operation is not 'send' or 'receive'. Will be 0 for 'send'.</para> </parameter> <parameter name="TotalBadLines" required="false"> - <para>Total number of bad lines sent/recieved during this session. This field is not + <para>Total number of bad lines sent/received during this session. This field is not included if Operation is not 'send' or 'received'.</para> </parameter> </syntax> diff --git a/res/res_fax_spandsp.c b/res/res_fax_spandsp.c index 0152b00dd..26f9ed372 100644 --- a/res/res_fax_spandsp.c +++ b/res/res_fax_spandsp.c @@ -859,7 +859,7 @@ static int spandsp_fax_gateway_start(struct ast_fax_session *s) t38_set_fill_bit_removal(p->t38_core_state, t38_param->fill_bit_removal); t38_set_mmr_transcoding(p->t38_core_state, t38_param->transcoding_mmr); t38_set_jbig_transcoding(p->t38_core_state, t38_param->transcoding_jbig); - t38_set_data_rate_management_method(p->t38_core_state, + t38_set_data_rate_management_method(p->t38_core_state, (t38_param->rate_management == AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF)? 1 : 2); t38_gateway_set_transmit_on_idle(&p->t38_gw_state, TRUE); @@ -868,7 +868,7 @@ static int spandsp_fax_gateway_start(struct ast_fax_session *s) t38_gateway_set_supported_modems(&p->t38_gw_state, spandsp_modems(s->details)); - /* engage udptl nat on other side of T38 line + /* engage udptl nat on other side of T38 line * (Asterisk changes media ports thus we send a few packets to reinitialize * pinholes in NATs and FWs */ diff --git a/res/res_format_attr_opus.c b/res/res_format_attr_opus.c index 857b9435c..9e5fe6673 100644 --- a/res/res_format_attr_opus.c +++ b/res/res_format_attr_opus.c @@ -116,7 +116,7 @@ static void sdp_fmtp_get(const char *attributes, const char *name, int *attr) /* Skip any preceeding blanks as some implementations separate attributes using spaces too */ kvp = ast_skip_blanks(kvp); - /* If we are at at the requested attribute get its value and return */ + /* If we are at the requested attribute get its value and return */ if (!strncmp(kvp, name, strlen(name)) && kvp[strlen(name)] == '=') { if (sscanf(kvp, "%*[^=]=%30d", &val) == 1) { *attr = val; diff --git a/res/res_format_attr_silk.c b/res/res_format_attr_silk.c index d52ec7410..fcbe7a846 100644 --- a/res/res_format_attr_silk.c +++ b/res/res_format_attr_silk.c @@ -111,7 +111,7 @@ static void silk_generate_sdp_fmtp(const struct ast_format *format, unsigned int return; } - if ((attr->maxbitrate > 5000) && (attr->maxbitrate < 40000)) { + if ((attr->maxbitrate > 5000) && (attr->maxbitrate < 40000)) { ast_str_append(str, 0, "a=fmtp:%u maxaveragebitrate=%u\r\n", payload, attr->maxbitrate); } diff --git a/res/res_hep.c b/res/res_hep.c index f3b65ad26..a91b7ec77 100644 --- a/res/res_hep.c +++ b/res/res_hep.c @@ -260,8 +260,8 @@ static struct aco_type global_option = { .type = ACO_GLOBAL, .name = "general", .item_offset = offsetof(struct module_config, general), - .category_match = ACO_WHITELIST, - .category = "^general$", + .category_match = ACO_WHITELIST_EXACT, + .category = "general", }; struct aco_type *global_options[] = ACO_TYPES(&global_option); @@ -423,7 +423,7 @@ int hepv3_is_loaded(void) { RAII_VAR(struct module_config *, config, ao2_global_obj_ref(global_config), ao2_cleanup); - return (config != NULL) ? 1 : 0; + return config && config->general->enabled; } struct hepv3_capture_info *hepv3_create_capture_info(const void *payload, size_t len) diff --git a/res/res_http_post.c b/res/res_http_post.c index 4b864b5d8..f7c4d308f 100644 --- a/res/res_http_post.c +++ b/res/res_http_post.c @@ -17,7 +17,7 @@ */ /*! - * \file + * \file * \brief HTTP POST upload support for Asterisk HTTP server * * \author Terry Wilson <twilson@digium.com @@ -113,7 +113,7 @@ static GMimeMessage *parse_message(FILE *f) parser = g_mime_parser_new_with_stream(stream); g_mime_parser_set_respect_content_length(parser, 1); - + g_object_unref(stream); message = g_mime_parser_construct_message(parser diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c index 75a6eba64..956c52c54 100644 --- a/res/res_http_websocket.c +++ b/res/res_http_websocket.c @@ -291,6 +291,7 @@ int AST_OPTIONAL_API_NAME(ast_websocket_server_remove_protocol)(struct ast_webso /*! \brief Close function for websocket session */ int AST_OPTIONAL_API_NAME(ast_websocket_close)(struct ast_websocket *session, uint16_t reason) { + enum ast_websocket_opcode opcode = AST_WEBSOCKET_OPCODE_CLOSE; char frame[4] = { 0, }; /* The header is 2 bytes and the reason code takes up another 2 bytes */ int res; @@ -298,7 +299,7 @@ int AST_OPTIONAL_API_NAME(ast_websocket_close)(struct ast_websocket *session, ui return 0; } - frame[0] = AST_WEBSOCKET_OPCODE_CLOSE | 0x80; + frame[0] = opcode | 0x80; frame[1] = 2; /* The reason code is always 2 bytes */ /* If no reason has been specified assume 1000 which is normal closure */ @@ -445,19 +446,7 @@ int AST_OPTIONAL_API_NAME(ast_websocket_is_secure)(struct ast_websocket *session int AST_OPTIONAL_API_NAME(ast_websocket_set_nonblock)(struct ast_websocket *session) { - int flags; - - if ((flags = fcntl(session->fd, F_GETFL)) == -1) { - return -1; - } - - flags |= O_NONBLOCK; - - if ((flags = fcntl(session->fd, F_SETFL, flags)) == -1) { - return -1; - } - - return 0; + return ast_fd_set_flags(session->fd, O_NONBLOCK); } int AST_OPTIONAL_API_NAME(ast_websocket_set_timeout)(struct ast_websocket *session, int timeout) @@ -944,17 +933,11 @@ static struct ast_http_uri websocketuri = { /*! \brief Simple echo implementation which echoes received text and binary frames */ static void websocket_echo_callback(struct ast_websocket *session, struct ast_variable *parameters, struct ast_variable *headers) { - int flags, res; + int res; ast_debug(1, "Entering WebSocket echo loop\n"); - if ((flags = fcntl(ast_websocket_fd(session), F_GETFL)) == -1) { - goto end; - } - - flags |= O_NONBLOCK; - - if (fcntl(ast_websocket_fd(session), F_SETFL, flags) == -1) { + if (ast_fd_set_flags(ast_websocket_fd(session), O_NONBLOCK)) { goto end; } diff --git a/res/res_limit.c b/res/res_limit.c index 5f61f1b09..29e0c9dc3 100644 --- a/res/res_limit.c +++ b/res/res_limit.c @@ -2,7 +2,7 @@ * Asterisk -- An open source telephony toolkit. * * Resource limits - * + * * Copyright (c) 2006 Tilghman Lesher. All rights reserved. * * Tilghman Lesher <res_limit_200607@the-tilghman.com> @@ -215,4 +215,3 @@ static int load_module(void) } AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Resource limits"); - diff --git a/res/res_monitor.c b/res/res_monitor.c index b7ef2ea88..88fb2d5ba 100644 --- a/res/res_monitor.c +++ b/res/res_monitor.c @@ -27,7 +27,7 @@ <depend type="module">func_periodic_hook</depend> <support_level>core</support_level> ***/ - + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") @@ -273,9 +273,9 @@ AST_MUTEX_DEFINE_STATIC(monitorlock); static unsigned long seq = 0; -/*! - * \brief Change state of monitored channel - * \param chan +/*! + * \brief Change state of monitored channel + * \param chan * \param state monitor state * \retval 0 on success. * \retval -1 on failure. @@ -374,7 +374,7 @@ int AST_OPTIONAL_API_NAME(ast_monitor_start)(struct ast_channel *chan, const cha } else { monitor->format = ast_strdup("wav"); } - + /* open files */ if (stream_action & X_REC_IN) { if (ast_fileexists(monitor->read_filename, NULL, NULL) > 0) @@ -448,13 +448,13 @@ static const char *get_soxmix_format(const char *format) res = "ul"; if (!strcasecmp(format,"alaw")) res = "al"; - + return res; } -/*! - * \brief Stop monitoring channel - * \param chan +/*! + * \brief Stop monitoring channel + * \param chan * \param need_lock * Stop the recording, close any open streams, mix in/out channels if required * \return Always 0 @@ -514,7 +514,7 @@ int AST_OPTIONAL_API_NAME(ast_monitor_stop)(struct ast_channel *chan, int need_l #endif format = get_soxmix_format(format); delfiles = 1; - } + } execute_args = pbx_builtin_getvar_helper(chan, "MONITOR_EXEC_ARGS"); if (ast_strlen_zero(execute_args)) { execute_args = ""; @@ -580,8 +580,8 @@ static int unpause_monitor_exec(struct ast_channel *chan, const char *data) return ast_monitor_unpause(chan); } -/*! - * \brief Change monitored filename of channel +/*! + * \brief Change monitored filename of channel * \param chan * \param fname_base new filename * \param need_lock @@ -626,7 +626,7 @@ int AST_OPTIONAL_API_NAME(ast_monitor_change_fname)(struct ast_channel *chan, co * and we aren't interfering with the recording itself. */ ast_debug(2, "comparing tmpstring %s to filename_base %s\n", tmpstring, ast_channel_monitor(chan)->filename_base); - + if ((fd[0] = open(tmpstring, O_CREAT | O_WRONLY, 0644)) < 0 || (fd[1] = open(ast_channel_monitor(chan)->filename_base, O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0) { if (fd[0] < 0) { @@ -710,7 +710,7 @@ static int start_monitor_exec(struct ast_channel *chan, const char *data) AST_APP_ARG(fname_base); AST_APP_ARG(options); ); - + /* Parse arguments. */ if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "Monitor requires an argument\n"); diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index d79151676..0afacf53c 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -19,7 +19,7 @@ /*! \file * * \brief Routines implementing music on hold - * + * * \author Mark Spencer <markster@digium.com> */ @@ -27,7 +27,7 @@ * \addtogroup configuration_file Configuration Files */ -/*! +/*! * \page musiconhold.conf musiconhold.conf * \verbinclude musiconhold.conf.sample */ @@ -312,7 +312,7 @@ static void moh_files_release(struct ast_channel *chan, void *data) state->class = mohclass_unref(state->class, "Unreffing channel's music class upon deactivation of generator"); } -static int ast_moh_files_next(struct ast_channel *chan) +static int ast_moh_files_next(struct ast_channel *chan) { struct moh_files_state *state = ast_channel_music_state(chan); int tries; @@ -331,6 +331,7 @@ static int ast_moh_files_next(struct ast_channel *chan) } } else { state->announcement = 0; + state->samples = 0; } if (!state->class->total_files) { @@ -558,7 +559,7 @@ static int spawn_mp3(struct mohclass *class) DIR *dir = NULL; struct dirent *de; - + if (!strcasecmp(class->dir, "nodir")) { files = 1; } else { @@ -576,19 +577,19 @@ static int spawn_mp3(struct mohclass *class) argv[argc++] = "--mono"; argv[argc++] = "-r"; argv[argc++] = "8000"; - + if (!ast_test_flag(class, MOH_SINGLE)) { argv[argc++] = "-b"; argv[argc++] = "2048"; } - + argv[argc++] = "-f"; - + if (ast_test_flag(class, MOH_QUIET)) argv[argc++] = "4096"; else argv[argc++] = "8192"; - + /* Look for extra arguments and add them to the list */ ast_copy_string(xargs, class->args, sizeof(xargs)); argptr = xargs; @@ -612,9 +613,9 @@ static int spawn_mp3(struct mohclass *class) files++; } else if (dir) { while ((de = readdir(dir)) && (files < MAX_MP3S)) { - if ((strlen(de->d_name) > 3) && - ((ast_test_flag(class, MOH_CUSTOM) && - (!strcasecmp(de->d_name + strlen(de->d_name) - 4, ".raw") || + if ((strlen(de->d_name) > 3) && + ((ast_test_flag(class, MOH_CUSTOM) && + (!strcasecmp(de->d_name + strlen(de->d_name) - 4, ".raw") || !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".sln"))) || !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".mp3"))) { ast_copy_string(fns[files], de->d_name, sizeof(fns[files])); @@ -627,7 +628,7 @@ static int spawn_mp3(struct mohclass *class) if (dir) { closedir(dir); } - if (pipe(fds)) { + if (pipe(fds)) { ast_log(LOG_WARNING, "Pipe failed\n"); return -1; } @@ -883,7 +884,7 @@ static int start_moh_exec(struct ast_channel *chan, const char *data) AST_STANDARD_APP_ARGS(args, parse); class = S_OR(args.class, NULL); - if (ast_moh_start(chan, class, NULL)) + if (ast_moh_start(chan, class, NULL)) ast_log(LOG_WARNING, "Unable to start music on hold class '%s' on channel %s\n", class, ast_channel_name(chan)); return 0; @@ -924,7 +925,6 @@ static struct mohclass *_get_mohbyname(const char *name, int warn, int flags, co static struct mohdata *mohalloc(struct mohclass *cl) { struct mohdata *moh; - long flags; if (!(moh = ast_calloc(1, sizeof(*moh)))) return NULL; @@ -936,10 +936,8 @@ static struct mohdata *mohalloc(struct mohclass *cl) } /* Make entirely non-blocking */ - flags = fcntl(moh->pipe[0], F_GETFL); - fcntl(moh->pipe[0], F_SETFL, flags | O_NONBLOCK); - flags = fcntl(moh->pipe[1], F_GETFL); - fcntl(moh->pipe[1], F_SETFL, flags | O_NONBLOCK); + ast_fd_set_flags(moh->pipe[0], O_NONBLOCK); + ast_fd_set_flags(moh->pipe[1], O_NONBLOCK); moh->f.frametype = AST_FRAME_VOICE; moh->f.subclass.format = cl->format; @@ -950,7 +948,7 @@ static struct mohdata *mohalloc(struct mohclass *cl) ao2_lock(cl); AST_LIST_INSERT_HEAD(&cl->members, moh, list); ao2_unlock(cl); - + return moh; } @@ -961,9 +959,9 @@ static void moh_release(struct ast_channel *chan, void *data) struct ast_format *oldwfmt; ao2_lock(class); - AST_LIST_REMOVE(&moh->parent->members, moh, list); + AST_LIST_REMOVE(&moh->parent->members, moh, list); ao2_unlock(class); - + close(moh->pipe[0]); close(moh->pipe[1]); @@ -1294,8 +1292,8 @@ static int _moh_register(struct mohclass *moh, int reload, int unref, const char } return -1; } - } else if (!strcasecmp(moh->mode, "mp3") || !strcasecmp(moh->mode, "mp3nb") || - !strcasecmp(moh->mode, "quietmp3") || !strcasecmp(moh->mode, "quietmp3nb") || + } else if (!strcasecmp(moh->mode, "mp3") || !strcasecmp(moh->mode, "mp3nb") || + !strcasecmp(moh->mode, "quietmp3") || !strcasecmp(moh->mode, "quietmp3nb") || !strcasecmp(moh->mode, "httpmp3") || !strcasecmp(moh->mode, "custom")) { if (init_app_class(moh)) { if (unref) { @@ -1437,7 +1435,7 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con if (!strcasecmp(tmp->name, "name")) ast_copy_string(mohclass->name, tmp->value, sizeof(mohclass->name)); else if (!strcasecmp(tmp->name, "mode")) - ast_copy_string(mohclass->mode, tmp->value, sizeof(mohclass->mode)); + ast_copy_string(mohclass->mode, tmp->value, sizeof(mohclass->mode)); else if (!strcasecmp(tmp->name, "directory")) ast_copy_string(mohclass->dir, tmp->value, sizeof(mohclass->dir)); else if (!strcasecmp(tmp->name, "application")) @@ -1448,7 +1446,7 @@ static int local_ast_moh_start(struct ast_channel *chan, const char *mclass, con ast_set2_flag(mohclass, ast_true(tmp->value), MOH_RANDOMIZE); else if (!strcasecmp(tmp->name, "sort") && !strcasecmp(tmp->value, "random")) ast_set_flag(mohclass, MOH_RANDOMIZE); - else if (!strcasecmp(tmp->name, "sort") && !strcasecmp(tmp->value, "alpha")) + else if (!strcasecmp(tmp->name, "sort") && !strcasecmp(tmp->value, "alpha")) ast_set_flag(mohclass, MOH_SORTALPHA); else if (!strcasecmp(tmp->name, "format")) { ao2_cleanup(mohclass->format); @@ -1641,7 +1639,7 @@ static void moh_class_destructor(void *obj) stime = time(NULL) + 2; killpid(class->pid, class->kill_delay, class->kill_method); - while ((ast_wait_for_input(class->srcfd, 100) > 0) && + while ((ast_wait_for_input(class->srcfd, 100) > 0) && (bytes = read(class->srcfd, buff, 8192)) && time(NULL) < stime) { tbytes = tbytes + bytes; } @@ -1742,7 +1740,7 @@ static int load_moh_classes(int reload) } } /* These names were deprecated in 1.4 and should not be used until after the next major release. */ - if (!strcasecmp(cat, "classes") || !strcasecmp(cat, "moh_files") || + if (!strcasecmp(cat, "classes") || !strcasecmp(cat, "moh_files") || !strcasecmp(cat, "general")) { continue; } @@ -1824,7 +1822,7 @@ static int load_moh_classes(int reload) ast_config_destroy(cfg); - ao2_t_callback(mohclasses, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, + ao2_t_callback(mohclasses, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, moh_classes_delete_marked, NULL, "Purge marked classes"); return numclasses; @@ -1925,6 +1923,9 @@ static char *handle_cli_moh_show_classes(struct ast_cli_entry *e, int cmd, struc ast_cli(a->fd, "Class: %s\n", class->name); ast_cli(a->fd, "\tMode: %s\n", S_OR(class->mode, "<none>")); ast_cli(a->fd, "\tDirectory: %s\n", S_OR(class->dir, "<none>")); + if (ast_test_flag(class, MOH_ANNOUNCEMENT)) { + ast_cli(a->fd, "\tAnnouncement: %s\n", S_OR(class->announcement, "<none>")); + } if (ast_test_flag(class, MOH_CUSTOM)) { ast_cli(a->fd, "\tApplication: %s\n", S_OR(class->args, "<none>")); ast_cli(a->fd, "\tKill Escalation Delay: %zu ms\n", class->kill_delay / 1000); @@ -1968,8 +1969,8 @@ static int moh_class_cmp(void *obj, void *arg, int flags) * Module loading including tests for configuration or dependencies. * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails - * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the - * configuration file or other non-critical problem return + * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the + * configuration file or other non-critical problem return * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS. */ static int load_module(void) diff --git a/res/res_mwi_external_ami.c b/res/res_mwi_external_ami.c index 0479f8bcf..92eafb893 100644 --- a/res/res_mwi_external_ami.c +++ b/res/res_mwi_external_ami.c @@ -373,4 +373,3 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "AMI support for external .load = load_module, .unload = unload_module, ); - diff --git a/res/res_odbc.c b/res/res_odbc.c index 48273c4ac..7395449c5 100644 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -22,7 +22,7 @@ /*! \file * * \brief ODBC resource manager - * + * * \author Mark Spencer <markster@digium.com> * \author Anthony Minessale II <anthmct@yahoo.com> * \author Tilghman Lesher <tilghman@digium.com> @@ -34,7 +34,7 @@ * \addtogroup configuration_file Configuration Files */ -/*! +/*! * \page res_odbc.conf res_odbc.conf * \verbinclude res_odbc.conf.sample */ @@ -1068,16 +1068,6 @@ static int unload_module(void) return -1; } -/*! - * \brief Load the module - * - * Module loading including tests for configuration or dependencies. - * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, - * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails - * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the - * configuration file or other non-critical problem return - * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS. - */ static int load_module(void) { if (!(class_container = ao2_container_alloc(1, null_hash_fn, ao2_match_by_addr))) @@ -1086,8 +1076,7 @@ static int load_module(void) return AST_MODULE_LOAD_DECLINE; ast_cli_register_multiple(cli_odbc, ARRAY_LEN(cli_odbc)); ast_data_register_multiple(odbc_providers, ARRAY_LEN(odbc_providers)); - ast_log(LOG_NOTICE, "res_odbc loaded.\n"); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "ODBC resource", diff --git a/res/res_odbc_transaction.c b/res/res_odbc_transaction.c index 7e48b72cf..b6b303929 100644 --- a/res/res_odbc_transaction.c +++ b/res/res_odbc_transaction.c @@ -222,7 +222,7 @@ static struct odbc_txn_frame *find_transaction(struct ast_channel *chan, const c /* No datastore? Definitely no transaction then */ return NULL; } - + oldlist = txn_store->data; AST_LIST_LOCK(oldlist); diff --git a/res/res_parking.c b/res/res_parking.c index 593134b60..ddf801245 100644 --- a/res/res_parking.c +++ b/res/res_parking.c @@ -291,8 +291,8 @@ static struct aco_type global_option = { .type = ACO_GLOBAL, .name = "globals", .item_offset = offsetof(struct parking_config, global), - .category_match = ACO_WHITELIST, - .category = "^general$", + .category_match = ACO_WHITELIST_EXACT, + .category = "general", }; struct aco_type *global_options[] = ACO_TYPES(&global_option); @@ -300,8 +300,8 @@ struct aco_type *global_options[] = ACO_TYPES(&global_option); static struct aco_type parking_lot_type = { .type = ACO_ITEM, .name = "parking_lot", - .category_match = ACO_BLACKLIST, - .category = "^(general)$", + .category_match = ACO_BLACKLIST_EXACT, + .category = "general", .item_alloc = parking_lot_cfg_alloc, .item_find = named_item_find, .item_offset = offsetof(struct parking_config, parking_lots), diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c index 71f875753..89fb29c2d 100644 --- a/res/res_phoneprov.c +++ b/res/res_phoneprov.c @@ -33,7 +33,7 @@ * \addtogroup configuration_file Configuration Files */ -/*! +/*! * \page phoneprov.conf phoneprov.conf * \verbinclude phoneprov.conf.sample */ diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 1fce19b8a..842cc20e3 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -2573,13 +2573,13 @@ int ast_sip_register_endpoint_identifier_with_name(struct ast_sip_endpoint_ident id_list_item = ast_calloc(1, sizeof(*id_list_item)); if (!id_list_item) { - ast_log(LOG_ERROR, "Unabled to add endpoint identifier. Out of memory.\n"); + ast_log(LOG_ERROR, "Unable to add endpoint identifier. Out of memory.\n"); return -1; } id_list_item->identifier = identifier; id_list_item->name = name; - ast_debug(1, "Register endpoint identifier %s (%p)\n", name, identifier); + ast_debug(1, "Register endpoint identifier %s(%p)\n", name ?: "", identifier); if (ast_strlen_zero(name)) { /* if an identifier has no name then place in front */ @@ -2602,7 +2602,8 @@ int ast_sip_register_endpoint_identifier_with_name(struct ast_sip_endpoint_ident id_list_item->priority = 0; while ((current = strchr(current, ','))) { ++id_list_item->priority; - if (!strncmp(prev, name, current - prev)) { + if (!strncmp(prev, name, current - prev) + && strlen(name) == current - prev) { break; } prev = ++current; @@ -3241,7 +3242,7 @@ pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint, ast_assert(status != NULL); contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL); - if (ast_sip_set_tpselector_from_ep_or_uri(endpoint, pjsip_uri_get_uri(contact_hdr->uri), + if (!contact_hdr || ast_sip_set_tpselector_from_ep_or_uri(endpoint, pjsip_uri_get_uri(contact_hdr->uri), &selector)) { return NULL; } diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c index 2f29456ab..a9a90ac92 100644 --- a/res/res_pjsip/config_transport.c +++ b/res/res_pjsip/config_transport.c @@ -917,6 +917,12 @@ static int transport_tls_method_handler(const struct aco_option *opt, struct ast state->tls.method = PJSIP_SSL_UNSPECIFIED_METHOD; } else if (!strcasecmp(var->value, "tlsv1")) { state->tls.method = PJSIP_TLSV1_METHOD; +#ifdef HAVE_PJSIP_TLS_TRANSPORT_PROTO + } else if (!strcasecmp(var->value, "tlsv1_1")) { + state->tls.method = PJSIP_TLSV1_1_METHOD; + } else if (!strcasecmp(var->value, "tlsv1_2")) { + state->tls.method = PJSIP_TLSV1_2_METHOD; +#endif } else if (!strcasecmp(var->value, "sslv2")) { state->tls.method = PJSIP_SSLV2_METHOD; } else if (!strcasecmp(var->value, "sslv3")) { @@ -933,6 +939,10 @@ static int transport_tls_method_handler(const struct aco_option *opt, struct ast static const char *tls_method_map[] = { [PJSIP_SSL_UNSPECIFIED_METHOD] = "unspecified", [PJSIP_TLSV1_METHOD] = "tlsv1", +#ifdef HAVE_PJSIP_TLS_TRANSPORT_PROTO + [PJSIP_TLSV1_1_METHOD] = "tlsv1_1", + [PJSIP_TLSV1_2_METHOD] = "tlsv1_2", +#endif [PJSIP_SSLV2_METHOD] = "sslv2", [PJSIP_SSLV3_METHOD] = "sslv3", [PJSIP_SSLV23_METHOD] = "sslv23", diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c index 2bd40e84f..40490b255 100644 --- a/res/res_pjsip/location.c +++ b/res/res_pjsip/location.c @@ -1347,4 +1347,3 @@ int ast_sip_destroy_sorcery_location(void) return 0; } - diff --git a/res/res_pjsip/pjsip_cli.c b/res/res_pjsip/pjsip_cli.c index 56ec191ed..4544a1717 100644 --- a/res/res_pjsip/pjsip_cli.c +++ b/res/res_pjsip/pjsip_cli.c @@ -82,31 +82,22 @@ int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags) return 0; } -static char *complete_show_sorcery_object(struct ao2_container *container, +static void complete_show_sorcery_object(struct ao2_container *container, struct ast_sip_cli_formatter_entry *formatter_entry, - const char *word, int state) + const char *word) { - char *result = NULL; - int wordlen = strlen(word); - int which = 0; - - struct ao2_iterator i = ao2_iterator_init(container, 0); + size_t wordlen = strlen(word); void *object; + struct ao2_iterator i = ao2_iterator_init(container, 0); while ((object = ao2_t_iterator_next(&i, "iterate thru endpoints table"))) { const char *id = formatter_entry->get_id(object); - if (!strncasecmp(word, id, wordlen) - && ++which > state) { - result = ast_strdup(id); + if (!strncasecmp(word, id, wordlen)) { + ast_cli_completion_add(ast_strdup(id)); } ao2_t_ref(object, -1, "toss iterator endpoint ptr before break"); - if (result) { - break; - } } ao2_iterator_destroy(&i); - - return result; } static void dump_str_and_free(int fd, struct ast_str *buf) @@ -211,7 +202,8 @@ char *ast_sip_cli_traverse_objects(struct ast_cli_entry *e, int cmd, struct ast_ if (cmd == CLI_GENERATE) { ast_free(context.output_buffer); - return complete_show_sorcery_object(container, formatter_entry, a->word, a->n); + complete_show_sorcery_object(container, formatter_entry, a->word); + return NULL; } if (is_container) { diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c index 54c6c4929..9aab75b83 100644 --- a/res/res_pjsip/pjsip_configuration.c +++ b/res/res_pjsip/pjsip_configuration.c @@ -1565,8 +1565,8 @@ static int ami_show_endpoint(struct mansession *s, const struct message *m) return 0; } - astman_send_listack(s, m, "Following are Events for each object " - "associated with the the Endpoint", "start"); + astman_send_listack(s, m, "Following are Events for each object associated with the Endpoint", + "start"); /* the endpoint detail needs to always come first so apply as such */ if (format_ami_endpoint(endpoint, &ami) || diff --git a/res/res_pjsip/pjsip_global_headers.c b/res/res_pjsip/pjsip_global_headers.c index 501f5f523..4de28b586 100644 --- a/res/res_pjsip/pjsip_global_headers.c +++ b/res/res_pjsip/pjsip_global_headers.c @@ -55,7 +55,7 @@ struct header { static struct header *alloc_header(const char *name, const char *value) { struct header *alloc; - + alloc = ast_calloc_with_stringfields(1, struct header, 32); if (!alloc) { @@ -139,7 +139,7 @@ static int add_header(struct header_list *headers, const char *name, const char } AST_RWLIST_WRLOCK(headers); - if (replace) { + if (replace) { remove_header(headers, name); } if (to_add) { diff --git a/res/res_pjsip/pjsip_message_filter.c b/res/res_pjsip/pjsip_message_filter.c index 085d9787e..427aec740 100644 --- a/res/res_pjsip/pjsip_message_filter.c +++ b/res/res_pjsip/pjsip_message_filter.c @@ -429,15 +429,27 @@ static pj_bool_t on_rx_process_uris(pjsip_rx_data *rdata) return PJ_TRUE; } - while ((contact = - (pjsip_contact_hdr *) pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, - contact ? contact->next : NULL))) { + + contact = (pjsip_contact_hdr *) pjsip_msg_find_hdr( + rdata->msg_info.msg, PJSIP_H_CONTACT, NULL); + + if (!contact && pjsip_method_creates_dialog(&rdata->msg_info.msg->line.req.method)) { + /* A contact header is required for dialog creating methods */ + static const pj_str_t missing_contact = { "Missing Contact header", 22 }; + pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 400, + &missing_contact, NULL, NULL); + return PJ_TRUE; + } + + while (contact) { if (!contact->star && !is_sip_uri(contact->uri)) { print_uri_debug(URI_TYPE_CONTACT, rdata, (pjsip_hdr *)contact); pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, PJSIP_SC_UNSUPPORTED_URI_SCHEME, NULL, NULL, NULL); return PJ_TRUE; } + contact = (pjsip_contact_hdr *) pjsip_msg_find_hdr( + rdata->msg_info.msg, PJSIP_H_CONTACT, contact->next); } return PJ_FALSE; diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c index d4ea911c9..a0352a6fb 100644 --- a/res/res_pjsip/pjsip_options.c +++ b/res/res_pjsip/pjsip_options.c @@ -1157,7 +1157,24 @@ static int qualify_and_schedule_cb_with_aor(void *obj, void *arg, int flags) static int qualify_and_schedule_cb_without_aor(void *obj, void *arg, int flags) { - qualify_and_schedule_contact((struct ast_sip_contact *) obj); + /* + * These are really dynamic contacts. We need to retrieve the aor associated + * with the contact since it's possible some of the aor's fields were updated + * since last load. + */ + struct ast_sip_contact *contact = obj; + struct ast_sip_aor *aor = ast_sip_location_retrieve_aor(contact->aor); + + if (aor) { + qualify_and_schedule_cb_with_aor(obj, aor, flags); + ao2_ref(aor, -1); + } else { + ast_log(LOG_WARNING, "Unable to locate AOR for contact '%s'. Keeping old " + "associated settings: frequency=%d, timeout=%f, authenticate=%s\n", + contact->uri, contact->qualify_frequency, contact->qualify_timeout, + contact->authenticate_qualify ? "yes" : "no"); + qualify_and_schedule_contact(contact); + } return 0; } @@ -1185,32 +1202,21 @@ static int qualify_and_schedule_all_cb(void *obj, void *arg, int flags) return 0; } -/*! - * \internal - * \brief Unschedule all existing contacts - */ -static int unschedule_all_cb(void *obj, void *arg, int flags) -{ - struct sched_data *data = obj; - - AST_SCHED_DEL_UNREF(sched, data->id, ao2_ref(data, -1)); - - return CMP_MATCH; -} - static void qualify_and_schedule_all(void) { - struct ast_variable *var = ast_variable_new("qualify_frequency >", "0", ""); struct ao2_container *aors; struct ao2_container *contacts; - if (!var) { - return; - } - aors = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), - "aor", AST_RETRIEVE_FLAG_MULTIPLE, var); + /* + * It's possible that the AOR had some of it's fields updated prior to a + * reload. For instance qualifying could have been turned on or off by + * setting the qualify_frequency. Due to this we have to iterate through + * all contacts (static and dynamic), and not just ones where the frequency + * is greater than zero, updating any contact fields with the AOR's values. + */ - ao2_callback(sched_qualifies, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, unschedule_all_cb, NULL); + aors = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), + "aor", AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL); if (aors) { ao2_callback(aors, OBJ_NODATA, qualify_and_schedule_all_cb, NULL); @@ -1218,14 +1224,11 @@ static void qualify_and_schedule_all(void) } contacts = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), - "contact", AST_RETRIEVE_FLAG_MULTIPLE, var); + "contact", AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL); if (contacts) { ao2_callback(contacts, OBJ_NODATA, qualify_and_schedule_cb_without_aor, NULL); ao2_ref(contacts, -1); } - - ast_variables_destroy(var); - } int ast_sip_format_contact_ami(void *obj, void *arg, int flags) @@ -1278,7 +1281,7 @@ int ast_sip_format_contact_ami(void *obj, void *arg, int flags) astman_append(ami->s, "%s\r\n", ast_str_buffer(buf)); ami->count++; - + ast_free(buf); ao2_cleanup(status); return 0; diff --git a/res/res_pjsip/pjsip_session.c b/res/res_pjsip/pjsip_session.c index 7460e0a2b..074ec4e0b 100644 --- a/res/res_pjsip/pjsip_session.c +++ b/res/res_pjsip/pjsip_session.c @@ -118,4 +118,3 @@ int ast_sip_session_add_supplements(struct ast_sip_session *session) return 0; } - diff --git a/res/res_pjsip_dlg_options.c b/res/res_pjsip_dlg_options.c index 564c51fbf..03d7afa18 100644 --- a/res/res_pjsip_dlg_options.c +++ b/res/res_pjsip_dlg_options.c @@ -101,6 +101,7 @@ static int unload_module(void) } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SIP OPTIONS in dialog handler", + .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, diff --git a/res/res_pjsip_endpoint_identifier_ip.c b/res/res_pjsip_endpoint_identifier_ip.c index 14716234a..5324af7b9 100644 --- a/res/res_pjsip_endpoint_identifier_ip.c +++ b/res/res_pjsip_endpoint_identifier_ip.c @@ -105,7 +105,7 @@ struct ip_identify_match { struct ast_ha *matches; /*! \brief Perform SRV resolution of hostnames */ unsigned int srv_lookups; - /*! \brief Hosts to be resolved after applying configuration */ + /*! \brief Hosts to be resolved when applying configuration */ struct ao2_container *hosts; }; @@ -150,8 +150,8 @@ static int header_identify_match_check(void *obj, void *arg, int flags) c_header = ast_strdupa(identify->match_header); c_value = strchr(c_header, ':'); if (!c_value) { - ast_log(LOG_WARNING, "Identify '%s' has invalid header_match: No ':' separator found!\n", - ast_sorcery_object_get_id(identify)); + /* This should not be possible. The object cannot be created if so. */ + ast_assert(0); return 0; } *c_value = '\0'; @@ -161,17 +161,19 @@ static int header_identify_match_check(void *obj, void *arg, int flags) pj_header_name = pj_str(c_header); header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &pj_header_name, NULL); if (!header) { - ast_debug(3, "SIP message does not contain header '%s'\n", c_header); + ast_debug(3, "Identify '%s': SIP message does not have header '%s'\n", + ast_sorcery_object_get_id(identify), + c_header); return 0; } pj_header_value = pj_str(c_value); if (pj_strcmp(&pj_header_value, &header->hvalue)) { - ast_debug(3, "SIP message contains header '%s' but value '%.*s' does not match value '%s' for endpoint '%s'\n", + ast_debug(3, "Identify '%s': SIP message has header '%s' but value '%.*s' does not match '%s'\n", + ast_sorcery_object_get_id(identify), c_header, (int) pj_strlen(&header->hvalue), pj_strbuf(&header->hvalue), - c_value, - identify->endpoint_name); + c_value); return 0; } @@ -261,7 +263,7 @@ static int ip_identify_match_host_lookup(struct ip_identify_match *identify, con } for (i = 0; i < num_addrs; ++i) { - /* Check if the address is already in the list, if so don't bother adding it again */ + /* Check if the address is already in the list, if so don't add it again */ if (identify->matches && (ast_apply_ha(identify->matches, &addrs[i]) != AST_SENSE_ALLOW)) { continue; } @@ -283,14 +285,13 @@ static int ip_identify_match_host_lookup(struct ip_identify_match *identify, con } /*! \brief Helper function which performs an SRV lookup and then resolves the hostname */ -static int ip_identify_match_srv_lookup(struct ip_identify_match *identify, const char *prefix, const char *host) +static int ip_identify_match_srv_lookup(struct ip_identify_match *identify, const char *prefix, const char *host, int results) { char service[NI_MAXHOST]; struct srv_context *context = NULL; int srv_ret; const char *srvhost; unsigned short srvport; - int results = 0; snprintf(service, sizeof(service), "%s.%s", prefix, host); @@ -372,10 +373,33 @@ static int ip_identify_apply(const struct ast_sorcery *sorcery, void *obj) char *current_string; struct ao2_iterator i; + /* Validate the identify object configuration */ + if (ast_strlen_zero(identify->endpoint_name)) { + ast_log(LOG_ERROR, "Identify '%s' missing required endpoint name.\n", + ast_sorcery_object_get_id(identify)); + return -1; + } + if (ast_strlen_zero(identify->match_header) /* No header to match */ + /* and no static IP addresses with a mask */ + && !identify->matches + /* and no addresses to resolve */ + && (!identify->hosts || !ao2_container_count(identify->hosts))) { + ast_log(LOG_ERROR, "Identify '%s' is not configured to match anything.\n", + ast_sorcery_object_get_id(identify)); + return -1; + } + if (!ast_strlen_zero(identify->match_header) + && !strchr(identify->match_header, ':')) { + ast_log(LOG_ERROR, "Identify '%s' missing ':' separator in match_header '%s'.\n", + ast_sorcery_object_get_id(identify), identify->match_header); + return -1; + } + if (!identify->hosts) { return 0; } + /* Resolve the match addresses now */ i = ao2_iterator_init(identify->hosts, 0); while ((current_string = ao2_iterator_next(&i))) { struct ast_sockaddr address; @@ -383,26 +407,29 @@ static int ip_identify_apply(const struct ast_sorcery *sorcery, void *obj) /* If the provided string is not an IP address perform SRV resolution on it */ if (identify->srv_lookups && !ast_sockaddr_parse(&address, current_string, 0)) { - results = ip_identify_match_srv_lookup(identify, "_sip._udp", current_string); + results = ip_identify_match_srv_lookup(identify, "_sip._udp", current_string, + results); if (results != -1) { - results += ip_identify_match_srv_lookup(identify, "_sip._tcp", current_string); + results = ip_identify_match_srv_lookup(identify, "_sip._tcp", + current_string, results); } if (results != -1) { - results += ip_identify_match_srv_lookup(identify, "_sips._tcp", current_string); + results = ip_identify_match_srv_lookup(identify, "_sips._tcp", + current_string, results); } } - /* If SRV falls fall back to a normal lookup on the host itself */ + /* If SRV fails fall back to a normal lookup on the host itself */ if (!results) { results = ip_identify_match_host_lookup(identify, current_string); } if (results == 0) { - ast_log(LOG_ERROR, "Address '%s' provided on ip endpoint identifier '%s' did not resolve to any address\n", - current_string, ast_sorcery_object_get_id(obj)); + ast_log(LOG_WARNING, "Identify '%s' provided address '%s' did not resolve to any address\n", + ast_sorcery_object_get_id(identify), current_string); } else if (results == -1) { - ast_log(LOG_ERROR, "An error occurred when adding resolution results of '%s' on '%s'\n", - current_string, ast_sorcery_object_get_id(obj)); + ast_log(LOG_ERROR, "Identify '%s' failed when adding resolution results of '%s'\n", + ast_sorcery_object_get_id(identify), current_string); ao2_ref(current_string, -1); ao2_iterator_destroy(&i); return -1; diff --git a/res/res_pjsip_history.c b/res/res_pjsip_history.c index bcc4877f6..ffe1a1d88 100644 --- a/res/res_pjsip_history.c +++ b/res/res_pjsip_history.c @@ -1282,7 +1282,7 @@ static char *pjsip_show_history(struct ast_cli_entry *e, int cmd, struct ast_cli } entry = ao2_bump(AST_VECTOR_GET(vec, 0)); if (vec == &vector_history) { - ast_mutex_lock(&history_lock); + ast_mutex_unlock(&history_lock); } } diff --git a/res/res_pjsip_notify.c b/res/res_pjsip_notify.c index 8258b3857..fdc7ecf54 100644 --- a/res/res_pjsip_notify.c +++ b/res/res_pjsip_notify.c @@ -82,7 +82,7 @@ order; any other header is treated as part of the SIP request.</para> </description> - <configOption name="^.*$"> + <configOption name=""> <synopsis>A key/value pair to add to a NOTIFY request.</synopsis> <description> <para>If the key is <literal>Content</literal>, @@ -234,8 +234,8 @@ static void *notify_cfg_alloc(void) static struct aco_type notify_option = { .type = ACO_ITEM, .name = "notify", - .category_match = ACO_BLACKLIST, - .category = "^general$", + .category_match = ACO_BLACKLIST_EXACT, + .category = "general", .item_offset = offsetof(struct notify_cfg, notify_options), .item_alloc = notify_option_alloc, .item_find = notify_option_find @@ -993,7 +993,7 @@ static int load_module(void) return AST_MODULE_LOAD_DECLINE; } - aco_option_register_custom(¬ify_cfg, "^.*$", ACO_REGEX, notify_options, + aco_option_register_custom(¬ify_cfg, "", ACO_PREFIX, notify_options, "", notify_option_handler, 0); if (aco_process_config(¬ify_cfg, 0)) { diff --git a/res/res_pjsip_outbound_publish.c b/res/res_pjsip_outbound_publish.c index 1c73a0977..6b40ff493 100644 --- a/res/res_pjsip_outbound_publish.c +++ b/res/res_pjsip_outbound_publish.c @@ -1334,6 +1334,7 @@ static int reload_module(void) } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "PJSIP Outbound Publish Support", + .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .reload = reload_module, .unload = unload_module, diff --git a/res/res_pjsip_phoneprov_provider.c b/res/res_pjsip_phoneprov_provider.c index 8dafabc53..6cec0870d 100644 --- a/res/res_pjsip_phoneprov_provider.c +++ b/res/res_pjsip_phoneprov_provider.c @@ -413,6 +413,7 @@ static int reload_module(void) } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Phoneprov Provider", + .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .reload = reload_module, .unload = unload_module, diff --git a/res/res_pjsip_publish_asterisk.c b/res/res_pjsip_publish_asterisk.c index 72e1e4d7e..53ee60fe4 100644 --- a/res/res_pjsip_publish_asterisk.c +++ b/res/res_pjsip_publish_asterisk.c @@ -929,6 +929,7 @@ static int unload_module(void) } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Asterisk Event PUBLISH Support", + .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .reload = reload_module, .unload = unload_module, diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c index cb0be6127..88005b85c 100644 --- a/res/res_pjsip_pubsub.c +++ b/res/res_pjsip_pubsub.c @@ -525,7 +525,7 @@ static void pubsub_on_rx_notify(pjsip_evsub *sub, pjsip_rx_data *rdata, int *p_s pj_str_t **p_st_text, pjsip_hdr *res_hdr, pjsip_msg_body **p_body); static void pubsub_on_client_refresh(pjsip_evsub *sub); static void pubsub_on_server_timeout(pjsip_evsub *sub); - + static pjsip_evsub_user pubsub_cb = { .on_evsub_state = pubsub_on_evsub_state, .on_rx_refresh = pubsub_on_rx_refresh, @@ -613,8 +613,12 @@ static void subscription_persistence_update(struct sip_subscription_tree *sub_tr expires = expires_hdr ? expires_hdr->ivalue : DEFAULT_PUBLISH_EXPIRES; sub_tree->persistence->expires = ast_tvadd(ast_tvnow(), ast_samp2tv(expires, 1)); - pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, contact_hdr->uri, - sub_tree->persistence->contact_uri, sizeof(sub_tree->persistence->contact_uri)); + if (contact_hdr) { + pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, contact_hdr->uri, + sub_tree->persistence->contact_uri, sizeof(sub_tree->persistence->contact_uri)); + } else { + ast_log(LOG_WARNING, "Contact not updated due to missing contact header\n"); + } /* When receiving a packet on an streaming transport, it's possible to receive more than one SIP * message at a time into the rdata->pkt_info.packet buffer. However, the rdata->msg_info.msg_buf @@ -895,7 +899,7 @@ static int have_visited(const char *resource, struct resources *visited) * This iterates through the items on a resource list and creates tree nodes for each one. The * tree nodes created are children of the supplied parent node. If an item in the resource * list is itself a list, then this function is called recursively to provide children for - * the the new node. + * the new node. * * If an item in a resource list is not a list, then the supplied subscription handler is * called into as if a new SUBSCRIBE for the list item were presented. The handler's response diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 0fcd509fb..585202787 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -618,7 +618,7 @@ static void process_ice_attributes(struct ast_sip_session *session, struct ast_s /* Find all of the candidates */ for (attr_i = 0; attr_i < remote_stream->attr_count; ++attr_i) { - char foundation[32], transport[32], address[PJ_INET6_ADDRSTRLEN + 1], cand_type[6], relay_address[PJ_INET6_ADDRSTRLEN + 1] = ""; + char foundation[33], transport[32], address[PJ_INET6_ADDRSTRLEN + 1], cand_type[6], relay_address[PJ_INET6_ADDRSTRLEN + 1] = ""; unsigned int port, relay_port = 0; struct ast_rtp_engine_ice_candidate candidate = { 0, }; @@ -631,7 +631,7 @@ static void process_ice_attributes(struct ast_sip_session *session, struct ast_s ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value, sizeof(attr_value)); - if (sscanf(attr_value, "%31s %30u %31s %30u %46s %30u typ %5s %*s %23s %*s %30u", foundation, &candidate.id, transport, + if (sscanf(attr_value, "%32s %30u %31s %30u %46s %30u typ %5s %*s %23s %*s %30u", foundation, &candidate.id, transport, (unsigned *)&candidate.priority, address, &port, cand_type, relay_address, &relay_port) < 7) { /* Candidate did not parse properly */ continue; diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index f2ee3478b..b4fe0be77 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -473,7 +473,7 @@ enum delayed_method { /*! * \internal - * \brief Convert delayed method enum value to to a string. + * \brief Convert delayed method enum value to a string. * \since 13.3.0 * * \param method Delayed method enum value to convert to a string. @@ -1507,7 +1507,7 @@ static int sip_session_suspend_task(void *data) suspender->suspended = 1; ast_cond_signal(&suspender->cond_suspended); - /* Wait for the the serializer suspension to be completed. */ + /* Wait for the serializer suspension to be completed. */ while (!suspender->complete) { ast_cond_wait(&suspender->cond_complete, ao2_object_get_lockaddr(suspender)); } @@ -2019,6 +2019,12 @@ static enum sip_get_destination_result get_destination(struct ast_sip_session *s ast_copy_pj_str(domain, &sip_ruri->host, size); pbx_builtin_setvar_helper(session->channel, "SIPDOMAIN", domain); + /* + * Save off the INVITE Request-URI in case it is + * needed: CHANNEL(pjsip,request_uri) + */ + session->request_uri = pjsip_uri_clone(session->inv_session->pool, ruri); + return SIP_GET_DEST_EXTEN_FOUND; } @@ -2502,6 +2508,12 @@ static void handle_outgoing_response(struct ast_sip_session *session, pjsip_tx_d struct ast_sip_session_supplement *supplement; struct pjsip_status_line status = tdata->msg->line.status; pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL); + + if (!cseq) { + ast_log(LOG_ERROR, "Cannot send response due to missing sequence header"); + return; + } + ast_debug(3, "Method is %.*s, Response is %d %.*s\n", (int) pj_strlen(&cseq->method.name), pj_strbuf(&cseq->method.name), status.code, (int) pj_strlen(&status.reason), pj_strbuf(&status.reason)); diff --git a/res/res_pktccops.c b/res/res_pktccops.c index 037e533d3..512d706d3 100644 --- a/res/res_pktccops.c +++ b/res/res_pktccops.c @@ -19,10 +19,10 @@ /*!\file * * \brief PacketCable COPS - * + * * \author Attila Domjan <attila.domjan.hu@gmail.com> * - * \note + * \note * This module is an add-on to chan_mgcp. It adds support for the * PacketCable MGCP variation called NCS. Res_pktccops implements COPS * (RFC 2748), a protocol used to manage dynamic bandwith allocation in @@ -96,7 +96,7 @@ struct pktcobj { unsigned char cnum; unsigned char ctype; char *contents; - struct pktcobj *next; + struct pktcobj *next; }; struct copsmsg { @@ -136,7 +136,7 @@ struct cops_cmts { char name[80]; char host[80]; char port[80]; - uint16_t t1; + uint16_t t1; uint16_t t7; uint16_t t8; uint32_t keepalive; @@ -186,7 +186,7 @@ static uint16_t cops_constructgatespec(struct gatespec *gs, char *res) if (res == NULL) { return 0; } - + *res = (char) gs->direction; *(res + 1) = (char) gs->protocolid; *(res + 2) = (char) gs->flags; @@ -226,7 +226,7 @@ static uint16_t cops_construct_gate (int cmd, char *p, uint16_t trid, { struct gatespec gs; int offset = 0; - + ast_debug(3, "CMD: %d\n", cmd); /* Transaction Identifier 8 octets */ @@ -246,7 +246,7 @@ static uint16_t cops_construct_gate (int cmd, char *p, uint16_t trid, *(p + offset++) = 1; /* stype */ *((uint32_t *) (p + offset)) = htonl(mtahost); offset += 4; - + if (cmd == GATE_INFO || cmd == GATE_SET_HAVE_GATEID || cmd == GATE_DEL) { /* Gate ID 8 Octets */ *(p + offset++) = 0; @@ -258,7 +258,7 @@ static uint16_t cops_construct_gate (int cmd, char *p, uint16_t trid, if (cmd == GATE_INFO || cmd == GATE_DEL) { return offset; } - + } /* Activity Count 8 octets */ @@ -392,7 +392,7 @@ static int cops_sendmsg (int sfd, struct copsmsg * sendmsg) char *buf; int bufpos; struct pktcobj *pobject; - + if (sfd < 0) { return -1; } @@ -435,7 +435,7 @@ static int cops_sendmsg (int sfd, struct copsmsg * sendmsg) pobject = pobject->next; } } - + errno = 0; #ifdef HAVE_MSG_NOSIGNAL #define SENDFLAGS MSG_NOSIGNAL | MSG_DONTWAIT @@ -481,15 +481,15 @@ struct cops_gate * AST_OPTIONAL_API_NAME(ast_pktccops_gate_alloc)(int cmd, ast_debug(3, "------- gate modify gateid 0x%x ssip: 0x%x\n", gate->gateid, ssip); /* TODO implement it */ ast_log(LOG_WARNING, "Modify GateID not implemented\n"); - } - + } + if ((gate = cops_gate_cmd(cmd, NULL, cops_trid++, mta, actcount, bitrate, psize, ssip, ssport, gate))) { ast_debug(3, "COPS: Allocating gate for mta: 0x%x\n", mta); gate->got_dq_gi = got_dq_gi; gate->gate_remove = gate_remove; return(gate); } else { - ast_debug(3, "COPS: Couldn't allocate gate for mta: 0x%x\n", mta); + ast_debug(3, "COPS: Couldn't allocate gate for mta: 0x%x\n", mta); return NULL; } } @@ -552,7 +552,7 @@ static struct cops_gate *cops_gate_cmd(int cmd, struct cops_cmts *cmts, gate->trid = trid; } } - + gate->in_transaction = time(NULL); if (!(gateset = malloc(sizeof(struct copsmsg)))) { @@ -563,7 +563,7 @@ static struct cops_gate *cops_gate_cmd(int cmd, struct cops_cmts *cmts, gateset->verflag = 0x10; gateset->opcode = 2; /* Decision */ gateset->clienttype = 0x8008; /* =PacketCable */ - + /* Handle object */ gateset->object = malloc(sizeof(struct pktcobj)); if (!gateset->object) { @@ -629,7 +629,7 @@ static struct cops_gate *cops_gate_cmd(int cmd, struct cops_cmts *cmts, return NULL; } gateset->object->next->next->next->next = NULL; - + gateset->length = COPS_HEADER_SIZE + gateset->object->length + gateset->object->next->length + gateset->object->next->next->length + gateset->object->next->next->next->length; if ((cmd == GATE_INFO || cmd == GATE_SET_HAVE_GATEID || cmd == GATE_DEL) && gate) { @@ -650,7 +650,7 @@ static struct cops_gate *cops_gate_cmd(int cmd, struct cops_cmts *cmts, static int cops_connect(char *host, char *port) { - int s, sfd = -1, flags; + int s, sfd = -1; struct addrinfo hints; struct addrinfo *rp; struct addrinfo *result; @@ -660,7 +660,7 @@ static int cops_connect(char *host, char *port) memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; + hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = 0; hints.ai_protocol = 0; @@ -676,8 +676,7 @@ static int cops_connect(char *host, char *port) if (sfd == -1) { ast_log(LOG_WARNING, "Failed socket\n"); } - flags = fcntl(sfd, F_GETFL); - fcntl(sfd, F_SETFL, flags | O_NONBLOCK); + ast_fd_set_flags(sfd, O_NONBLOCK); #ifdef HAVE_SO_NOSIGPIPE setsockopt(sfd, SOL_SOCKET, SO_NOSIGPIPE, &trueval, sizeof(trueval)); #endif @@ -827,7 +826,7 @@ static void *do_pktccops(void *data) ast_debug(3, " S-Num S-type: 0x%.4x len: %i\n", (unsigned)snst, sobjlen); if (snst == 0x0101 ) { recvtrid = ntohs(*((uint16_t *) (sobjp + 4))); - scommand = ntohs(*((uint16_t *) (sobjp + 6))); + scommand = ntohs(*((uint16_t *) (sobjp + 6))); ast_debug(3, " Transaction Identifier command: %i trid %i\n", scommand, recvtrid); } else if (snst == 0x0201) { subscrid = ntohl(*((uint32_t *) (sobjp + 4))); @@ -873,7 +872,7 @@ static void *do_pktccops(void *data) gate->gate_open = NULL; } break; - } + } } } AST_LIST_TRAVERSE_SAFE_END; @@ -944,7 +943,7 @@ static void *do_pktccops(void *data) cmts->state = 2; cmts->katimer = time(NULL); } - } + } if (len <= 0) { ast_debug(3, "COPS: lost connection to %s\n", cmts->name); close(cmts->sfd); @@ -954,7 +953,7 @@ static void *do_pktccops(void *data) cops_freemsg(recmsg); } } - AST_LIST_UNLOCK(&cmts_list); + AST_LIST_UNLOCK(&cmts_list); } if (pktcreload) { ast_debug(3, "Reloading pktccops...\n"); @@ -1059,7 +1058,7 @@ static int load_pktccops_config(void) } else { ast_log(LOG_WARNING, "Unkown option %s in general section of res_ptkccops.conf\n", v->name); } - } + } } else { /* Defaults */ host = NULL; @@ -1071,7 +1070,7 @@ static int load_pktccops_config(void) for (v = ast_variable_browse(config, cat); v; v = v->next) { if (!strcasecmp(v->name, "host")) { - host = v->value; + host = v->value; } else if (!strcasecmp(v->name, "port")) { port = v->value; } else if (!strcasecmp(v->name, "t1")) { @@ -1155,11 +1154,11 @@ static char *pktccops_show_cmtses(struct ast_cli_entry *e, int cmd, struct ast_c struct cops_cmts *cmts; char statedesc[16]; int katimer; - + switch(cmd) { case CLI_INIT: e->command = "pktccops show cmtses"; - e->usage = + e->usage = "Usage: pktccops show cmtses\n" " List PacketCable COPS CMTSes.\n"; @@ -1195,7 +1194,7 @@ static char *pktccops_show_gates(struct ast_cli_entry *e, int cmd, struct ast_cl switch(cmd) { case CLI_INIT: e->command = "pktccops show gates"; - e->usage = + e->usage = "Usage: pktccops show gates\n" " List PacketCable COPS GATEs.\n"; @@ -1226,8 +1225,8 @@ static char *pktccops_show_gates(struct ast_cli_entry *e, int cmd, struct ast_cl } else { ast_copy_string(state_desc, "N/A", sizeof(state_desc)); } - - ast_cli(a->fd, "%-16s 0x%.8x 0x%08x %-10s %10i %10i %u\n", (gate->cmts) ? gate->cmts->name : "null" , gate->gateid, gate->mta, + + ast_cli(a->fd, "%-16s 0x%.8x 0x%08x %-10s %10i %10i %u\n", (gate->cmts) ? gate->cmts->name : "null" , gate->gateid, gate->mta, state_desc, (int) (time(NULL) - gate->allocated), (gate->checked) ? (int) (time(NULL) - gate->checked) : 0, (unsigned int) gate->in_transaction); } AST_LIST_UNLOCK(&cmts_list); @@ -1244,7 +1243,7 @@ static char *pktccops_show_pools(struct ast_cli_entry *e, int cmd, struct ast_cl switch(cmd) { case CLI_INIT: e->command = "pktccops show pools"; - e->usage = + e->usage = "Usage: pktccops show pools\n" " List PacketCable COPS ip pools of MTAs.\n"; @@ -1277,7 +1276,7 @@ static char *pktccops_gatedel(struct ast_cli_entry *e, int cmd, struct ast_cli_a switch (cmd) { case CLI_INIT: e->command = "pktccops gatedel"; - e->usage = + e->usage = "Usage: pktccops gatedel <cmts> <gateid>\n" " Send Gate-Del to cmts.\n"; return NULL; @@ -1297,13 +1296,13 @@ static char *pktccops_gatedel(struct ast_cli_entry *e, int cmd, struct ast_cli_a } } AST_LIST_UNLOCK(&cmts_list); - + if (!found) return CLI_SHOWUSAGE; trid = cops_trid++; if (!sscanf(a->argv[3], "%x", &gateid)) { - ast_cli(a->fd, "bad gate specification (%s)\n", a->argv[3]); + ast_cli(a->fd, "bad gate specification (%s)\n", a->argv[3]); return CLI_SHOWUSAGE; } @@ -1315,7 +1314,7 @@ static char *pktccops_gatedel(struct ast_cli_entry *e, int cmd, struct ast_cli_a break; } } - + if (!found) { ast_cli(a->fd, "gate not found: %s\n", a->argv[3]); return CLI_SHOWUSAGE; @@ -1337,7 +1336,7 @@ static char *pktccops_gateset(struct ast_cli_entry *e, int cmd, struct ast_cli_a switch (cmd) { case CLI_INIT: e->command = "pktccops gateset"; - e->usage = + e->usage = "Usage: pktccops gateset <cmts> <mta> <acctcount> <bitrate> <packet size> <switch ip> <switch port>\n" " Send Gate-Set to cmts.\n"; return NULL; @@ -1388,7 +1387,7 @@ static char *pktccops_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_arg switch (cmd) { case CLI_INIT: e->command = "pktccops set debug {on|off}"; - e->usage = + e->usage = "Usage: pktccops set debug {on|off}\n" " Turn on/off debuging\n"; return NULL; @@ -1520,4 +1519,3 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "PktcCOPS manager .unload = unload_module, .reload = reload_module, ); - diff --git a/res/res_realtime.c b/res/res_realtime.c index b26cde5b3..4291b519c 100644 --- a/res/res_realtime.c +++ b/res/res_realtime.c @@ -23,7 +23,7 @@ * * \author Anthony Minessale <anthmct@yahoo.com> * \author Mark Spencer <markster@digium.com> - * + * * \ingroup applications */ @@ -44,7 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/cli.h" -static char *cli_realtime_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +static char *cli_realtime_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { #define CRL_HEADER_FORMAT "%30s %-30s\n" struct ast_variable *var = NULL, *orig_var = NULL; @@ -62,7 +62,7 @@ static char *cli_realtime_load(struct ast_cli_entry *e, int cmd, struct ast_cli_ } - if (a->argc < 5) + if (a->argc < 5) return CLI_SHOWUSAGE; var = ast_load_realtime_all(a->argv[2], a->argv[3], a->argv[4], SENTINEL); @@ -100,7 +100,7 @@ static char *cli_realtime_update(struct ast_cli_entry *e, int cmd, struct ast_cl return NULL; } - if (a->argc < 7) + if (a->argc < 7) return CLI_SHOWUSAGE; res = ast_update_realtime(a->argv[2], a->argv[3], a->argv[4], a->argv[5], a->argv[6], SENTINEL); @@ -135,7 +135,7 @@ static char *cli_realtime_update2(struct ast_cli_entry *e, int cmd, struct ast_c return NULL; } - if (a->argc < 7) + if (a->argc < 7) return CLI_SHOWUSAGE; if (a->argc == 7) { diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index 5271d1bf4..263dbff18 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -255,6 +255,8 @@ struct rtp_learning_info { struct timeval received; /*!< The time of the first received packet */ int max_seq; /*!< The highest sequence number received */ int packets; /*!< The number of remaining packets before the source is accepted */ + /*! Type of media stream carried by the RTP instance */ + enum ast_media_type stream_type; }; #ifdef HAVE_OPENSSL_SRTP @@ -2765,8 +2767,7 @@ static int create_new_socket(const char *type, int af) } ast_log(LOG_WARNING, "Unable to allocate %s socket: %s\n", type, strerror(errno)); } else { - long flags = fcntl(sock, F_GETFL); - fcntl(sock, F_SETFL, flags | O_NONBLOCK); + ast_fd_set_flags(sock, O_NONBLOCK); #ifdef SO_NO_CHECK if (nochecksums) { setsockopt(sock, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums)); @@ -2813,18 +2814,29 @@ static int rtp_learning_rtp_seq_update(struct rtp_learning_info *info, uint16_t info->received = ast_tvnow(); } - /* - * Protect against packet floods by checking that we - * received the packet sequence in at least the minimum - * allowed time. - */ - if (ast_tvzero(info->received)) { - info->received = ast_tvnow(); - } else if (!info->packets && (ast_tvdiff_ms(ast_tvnow(), info->received) < learning_min_duration )) { - /* Packet flood; reset */ - info->packets = learning_min_sequential - 1; - info->received = ast_tvnow(); + switch (info->stream_type) { + case AST_MEDIA_TYPE_UNKNOWN: + case AST_MEDIA_TYPE_AUDIO: + /* + * Protect against packet floods by checking that we + * received the packet sequence in at least the minimum + * allowed time. + */ + if (ast_tvzero(info->received)) { + info->received = ast_tvnow(); + } else if (!info->packets + && ast_tvdiff_ms(ast_tvnow(), info->received) < learning_min_duration) { + /* Packet flood; reset */ + info->packets = learning_min_sequential - 1; + info->received = ast_tvnow(); + } + break; + case AST_MEDIA_TYPE_VIDEO: + case AST_MEDIA_TYPE_IMAGE: + case AST_MEDIA_TYPE_TEXT: + break; } + info->max_seq = seq; return info->packets; @@ -3235,7 +3247,9 @@ static int ast_rtp_destroy(struct ast_rtp_instance *instance) * entry at this point since it holds a reference to the * RTP instance while it's active. */ - close(rtp->rtcp->s); + if (rtp->rtcp->s > -1 && rtp->s != rtp->rtcp->s) { + close(rtp->rtcp->s); + } ast_free(rtp->rtcp->local_addr_str); ast_free(rtp->rtcp); } @@ -4743,7 +4757,6 @@ static struct ast_frame *ast_rtcp_interpret(struct ast_rtp_instance *instance, c unsigned int first_word; /*! True if we have seen an acceptable SSRC to learn the remote RTCP address */ unsigned int ssrc_seen; - int report_counter = 0; struct ast_rtp_rtcp_report_block *report_block; struct ast_frame *f = &ast_null_frame; @@ -4957,7 +4970,7 @@ static struct ast_frame *ast_rtcp_interpret(struct ast_rtp_instance *instance, c if (!report_block) { return &ast_null_frame; } - rtcp_report->report_block[report_counter] = report_block; + rtcp_report->report_block[0] = report_block; report_block->source_ssrc = ntohl(rtcpheader[i]); report_block->lost_count.packets = ntohl(rtcpheader[i + 1]) & 0x00ffffff; report_block->lost_count.fraction = ((ntohl(rtcpheader[i + 1]) & 0xff000000) >> 24); @@ -4994,7 +5007,6 @@ static struct ast_frame *ast_rtcp_interpret(struct ast_rtp_instance *instance, c ast_verbose(" DLSR: %4.4f (sec)\n",(double)report_block->dlsr / 65536.0); ast_verbose(" RTT: %4.4f(sec)\n", rtp->rtcp->rtt); } - report_counter++; } /* If and when we handle more than one report block, this should occur outside * this loop. @@ -5433,6 +5445,15 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc * source and we should switch to it. */ if (!ast_sockaddr_cmp(&rtp->rtp_source_learn.proposed_address, &addr)) { + if (rtp->rtp_source_learn.stream_type == AST_MEDIA_TYPE_UNKNOWN) { + struct ast_rtp_codecs *codecs; + + codecs = ast_rtp_instance_get_codecs(instance); + rtp->rtp_source_learn.stream_type = + ast_rtp_codecs_get_stream_type(codecs); + ast_verb(4, "%p -- Strict RTP qualifying stream type: %s\n", + rtp, ast_codec_media_type2str(rtp->rtp_source_learn.stream_type)); + } if (!rtp_learning_rtp_seq_update(&rtp->rtp_source_learn, seqno)) { /* Accept the new RTP stream */ ast_verb(4, "%p -- Strict RTP switching source address to %s\n", diff --git a/res/res_rtp_multicast.c b/res/res_rtp_multicast.c index fd3ae21ef..70d9f3de4 100644 --- a/res/res_rtp_multicast.c +++ b/res/res_rtp_multicast.c @@ -96,7 +96,7 @@ struct multicast_rtp { unsigned int ssrc; /*! Sequence number, used when creating/sending the RTP packet */ uint16_t seqno; - unsigned int lastts; + unsigned int lastts; struct timeval txcore; struct ast_smoother *smoother; }; diff --git a/res/res_smdi.c b/res/res_smdi.c index 7b4c42b17..8622da4a0 100644 --- a/res/res_smdi.c +++ b/res/res_smdi.c @@ -251,7 +251,7 @@ static void smdi_interface_destroy(void *obj) ast_module_unref(ast_module_info->self); } -/*! +/*! * \internal * \brief Push an SMDI message to the back of an interface's message queue. * \param iface a pointer to the interface to use. @@ -326,10 +326,10 @@ static inline int lock_msg_q(struct ast_smdi_interface *iface, enum smdi_message switch (type) { case SMDI_MWI: return ast_mutex_lock(&iface->mwi_q_lock); - case SMDI_MD: + case SMDI_MD: return ast_mutex_lock(&iface->md_q_lock); } - + return -1; } @@ -377,7 +377,7 @@ static void purge_old_messages(struct ast_smdi_interface *iface, enum smdi_messa struct timeval now = ast_tvnow(); long elapsed = 0; void *msg; - + lock_msg_q(iface, type); msg = unlink_from_msg_q(iface, type); unlock_msg_q(iface, type); @@ -391,7 +391,7 @@ static void purge_old_messages(struct ast_smdi_interface *iface, enum smdi_messa ao2_ref(msg, -1); ast_log(LOG_NOTICE, "Purged expired message from %s SMDI %s message queue. " "Message was %ld milliseconds too old.\n", - iface->name, (type == SMDI_MD) ? "MD" : "MWI", + iface->name, (type == SMDI_MD) ? "MD" : "MWI", elapsed - iface->msg_expiry); lock_msg_q(iface, type); @@ -475,7 +475,7 @@ static void *smdi_msg_find(struct ast_smdi_interface *iface, return msg; } -static void *smdi_message_wait(struct ast_smdi_interface *iface, int timeout, +static void *smdi_message_wait(struct ast_smdi_interface *iface, int timeout, enum smdi_message_type type, const char *search_key, struct ast_flags options) { struct timeval start; @@ -574,7 +574,7 @@ struct ast_smdi_interface * AST_OPTIONAL_API_NAME(ast_smdi_interface_find)(const return iface; } -/*! +/*! * \internal * \brief Read an SMDI message. * @@ -588,9 +588,8 @@ static void *smdi_read(void *iface_p) struct ast_smdi_interface *iface = iface_p; struct ast_smdi_md_message *md_msg; struct ast_smdi_mwi_message *mwi_msg; - char c = '\0'; char *cp = NULL; - int i; + int i, c; int start = 0; /* read an smdi message */ @@ -618,7 +617,14 @@ static void *smdi_read(void *iface_p) /* read the message desk number */ for (i = 0; i < sizeof(md_msg->mesg_desk_num) - 1; i++) { - md_msg->mesg_desk_num[i] = fgetc(iface->file); + c = fgetc(iface->file); + if (c == EOF) { + ast_log(LOG_ERROR, "Unexpected EOF while reading MD message\n"); + ao2_ref(md_msg, -1); + ao2_ref(iface, -1); + return NULL; + } + md_msg->mesg_desk_num[i] = (char) c; ast_debug(1, "Read a '%c'\n", md_msg->mesg_desk_num[i]); } @@ -628,7 +634,14 @@ static void *smdi_read(void *iface_p) /* read the message desk terminal number */ for (i = 0; i < sizeof(md_msg->mesg_desk_term) - 1; i++) { - md_msg->mesg_desk_term[i] = fgetc(iface->file); + c = fgetc(iface->file); + if (c == EOF) { + ast_log(LOG_ERROR, "Unexpected EOF while reading SMDI message\n"); + ao2_ref(md_msg, -1); + ao2_ref(iface, -1); + return NULL; + } + md_msg->mesg_desk_term[i] = (char) c; ast_debug(1, "Read a '%c'\n", md_msg->mesg_desk_term[i]); } @@ -637,7 +650,14 @@ static void *smdi_read(void *iface_p) ast_debug(1, "The message desk terminal is '%s'\n", md_msg->mesg_desk_term); /* read the message type */ - md_msg->type = fgetc(iface->file); + c = fgetc(iface->file); + if (c == EOF) { + ast_log(LOG_ERROR, "Unexpected EOF while reading SMDI message\n"); + ao2_ref(md_msg, -1); + ao2_ref(iface, -1); + return NULL; + } + md_msg->type = (char) c; ast_debug(1, "Message type is '%c'\n", md_msg->type); @@ -719,7 +739,7 @@ static void *smdi_read(void *iface_p) /* discard the 'I' (from 'MWI') */ fgetc(iface->file); - + /* read the forwarding station number (may be blank) */ cp = &mwi_msg->fwd_st[0]; for (i = 0; i < sizeof(mwi_msg->fwd_st) - 1; i++) { @@ -742,8 +762,16 @@ static void *smdi_read(void *iface_p) ast_copy_string(mwi_msg->name, mwi_msg->fwd_st, sizeof(mwi_msg->name)); /* read the mwi failure cause */ - for (i = 0; i < sizeof(mwi_msg->cause) - 1; i++) - mwi_msg->cause[i] = fgetc(iface->file); + for (i = 0; i < sizeof(mwi_msg->cause) - 1; i++) { + c = fgetc(iface->file); + if (c == EOF) { + ast_log(LOG_ERROR, "Unexpected EOF while reading MWI message\n"); + ao2_ref(mwi_msg, -1); + ao2_ref(iface, -1); + return NULL; + } + mwi_msg->cause[i] = (char) c; + } mwi_msg->cause[sizeof(mwi_msg->cause) - 1] = '\0'; @@ -943,7 +971,7 @@ static int smdi_load(int reload) tcflag_t paritybit = PARENB; /* even parity checking */ tcflag_t charsize = CS7; /* seven bit characters */ int stopbits = 0; /* One stop bit */ - + int msdstrip = 0; /* strip zero digits */ long msg_expiry = SMDI_MSG_EXPIRY_TIME; @@ -1026,7 +1054,7 @@ static int smdi_load(int reload) continue; } } - + if (!(iface = alloc_smdi_interface())) continue; @@ -1054,19 +1082,19 @@ static int smdi_load(int reload) ast_log(LOG_ERROR, "Error setting baud rate on %s (%s)\n", iface->name, strerror(errno)); continue; } - + /* set the stop bits */ if (stopbits) iface->mode.c_cflag = iface->mode.c_cflag | CSTOPB; /* set two stop bits */ else iface->mode.c_cflag = iface->mode.c_cflag & ~CSTOPB; /* set one stop bit */ - + /* set the parity */ iface->mode.c_cflag = (iface->mode.c_cflag & ~PARENB & ~PARODD) | paritybit; - + /* set the character size */ iface->mode.c_cflag = (iface->mode.c_cflag & ~CSIZE) | charsize; - + /* commit the desired attributes */ if (tcsetattr(iface->fd, TCSAFLUSH, &iface->mode)) { ast_log(LOG_ERROR, "Error setting attributes on %s (%s)\n", iface->name, strerror(errno)); @@ -1132,7 +1160,7 @@ static int smdi_load(int reload) if (ao2_container_count(new_ifaces)) { res = 1; } - + return res; } @@ -1303,7 +1331,7 @@ static int smdi_msg_read(struct ast_channel *chan, const char *cmd, char *data, ast_channel_lock(chan); datastore = ast_channel_datastore_find(chan, &smdi_msg_datastore_info, args.id); ast_channel_unlock(chan); - + if (!datastore) { ast_log(LOG_WARNING, "No SMDI message found for message ID '%s'\n", args.id); goto return_error; @@ -1353,8 +1381,8 @@ static int _unload_module(int fromload); * Module loading including tests for configuration or dependencies. * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails - * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the - * configuration file or other non-critical problem return + * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the + * configuration file or other non-critical problem return * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS. */ static int load_module(void) @@ -1379,6 +1407,9 @@ static int load_module(void) ast_custom_function_register(&smdi_msg_retrieve_function); ast_custom_function_register(&smdi_msg_function); + /* For Optional API. */ + ast_module_shutdown_ref(ast_module_info->self); + return AST_MODULE_LOAD_SUCCESS; } @@ -1408,9 +1439,6 @@ static int _unload_module(int fromload) smdi_loaded = 0; - /* For Optional API. */ - ast_module_shutdown_ref(ast_module_info->self); - return 0; } diff --git a/res/res_snmp.c b/res/res_snmp.c index c7cfa3174..79ff4b1e5 100644 --- a/res/res_snmp.c +++ b/res/res_snmp.c @@ -109,8 +109,8 @@ static int load_config(void) * Module loading including tests for configuration or dependencies. * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails - * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the - * configuration file or other non-critical problem return + * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the + * configuration file or other non-critical problem return * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS. */ static int load_module(void) diff --git a/res/res_sorcery_astdb.c b/res/res_sorcery_astdb.c index fee857525..135709ebd 100644 --- a/res/res_sorcery_astdb.c +++ b/res/res_sorcery_astdb.c @@ -336,14 +336,14 @@ static void sorcery_astdb_retrieve_prefix(const struct ast_sorcery *sorcery, voi const char *family_prefix = data; size_t family_len = strlen(family_prefix) + strlen(type) + 1; /* +1 for slash delimiter */ char family[family_len + 1]; - char tree[prefix_len + sizeof("%")]; + char tree[prefix_len + 1]; RAII_VAR(struct ast_db_entry *, entries, NULL, ast_db_freetree); struct ast_db_entry *entry; - snprintf(tree, sizeof(tree), "%.*s%%", (int) prefix_len, prefix); + snprintf(tree, sizeof(tree), "%.*s", (int) prefix_len, prefix); snprintf(family, sizeof(family), "%s/%s", family_prefix, type); - if (!(entries = ast_db_gettree(family, tree))) { + if (!(entries = ast_db_gettree_by_prefix(family, tree))) { return; } diff --git a/res/res_sorcery_realtime.c b/res/res_sorcery_realtime.c index 1c52eb90f..9b0b25fb1 100644 --- a/res/res_sorcery_realtime.c +++ b/res/res_sorcery_realtime.c @@ -97,7 +97,7 @@ static int sorcery_realtime_create(const struct ast_sorcery *sorcery, void *data return (ast_store_realtime_fields(config->family, fields) <= 0) ? -1 : 0; } -/*! \brief Internal helper function which returns a filtered objectset. +/*! \brief Internal helper function which returns a filtered objectset. * * The following are filtered out of the objectset: * \li The id field. This is returned to the caller in an out parameter. diff --git a/res/res_speech.c b/res/res_speech.c index 7d75985ca..f61588f57 100644 --- a/res/res_speech.c +++ b/res/res_speech.c @@ -365,5 +365,5 @@ AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, - .load_pri = AST_MODPRI_APP_DEPEND, + .load_pri = AST_MODPRI_APP_DEPEND - 1, ); diff --git a/res/res_srtp.c b/res/res_srtp.c index 74587d55d..773d53316 100644 --- a/res/res_srtp.c +++ b/res/res_srtp.c @@ -196,7 +196,7 @@ static struct ast_srtp *res_srtp_new(void) ast_free(srtp); return NULL; } - + srtp->warned = 1; return srtp; @@ -453,7 +453,7 @@ static int ast_srtp_protect(struct ast_srtp *srtp, void **buf, int *len, int rtc if ((*len + SRTP_MAX_TRAILER_LEN) > sizeof(srtp->buf)) { return -1; } - + localbuf = rtcp ? srtp->rtcpbuf : srtp->buf; memcpy(localbuf, *buf, *len); diff --git a/res/res_stasis.c b/res/res_stasis.c index b1cea3ad5..9a06a5287 100644 --- a/res/res_stasis.c +++ b/res/res_stasis.c @@ -2124,8 +2124,8 @@ static int load_module(void) return AST_MODULE_LOAD_SUCCESS; } -AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Stasis application support", - .load_pri = AST_MODPRI_APP_DEPEND, +AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Stasis application support", + .load_pri = AST_MODPRI_APP_DEPEND - 1, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, diff --git a/res/res_statsd.c b/res/res_statsd.c index b8e4d0475..67166e820 100644 --- a/res/res_statsd.c +++ b/res/res_statsd.c @@ -233,8 +233,8 @@ static struct aco_type global_option = { .type = ACO_GLOBAL, .name = "global", .item_offset = offsetof(struct conf, global), - .category = "^general$", - .category_match = ACO_WHITELIST + .category = "general", + .category_match = ACO_WHITELIST_EXACT, }; static struct aco_type *global_options[] = ACO_TYPES(&global_option); diff --git a/res/res_timing_dahdi.c b/res/res_timing_dahdi.c index 1ef5117c7..72983fa06 100644 --- a/res/res_timing_dahdi.c +++ b/res/res_timing_dahdi.c @@ -16,11 +16,11 @@ * at the top of the source tree. */ -/*! +/*! * \file * \author Russell Bryant <russell@digium.com> * - * \brief DAHDI timing interface + * \brief DAHDI timing interface */ /*** MODULEINFO @@ -156,7 +156,7 @@ static enum ast_timer_event dahdi_timer_get_event(void *data) return AST_TIMING_EVENT_CONTINUOUS; case DAHDI_EVENT_TIMER_EXPIRED: default: - return AST_TIMING_EVENT_EXPIRED; + return AST_TIMING_EVENT_EXPIRED; } } @@ -178,7 +178,7 @@ static int dahdi_test_timer(void) { int fd; int x = 160; - + fd = open("/dev/dahdi/timer", O_RDWR); if (fd < 0) { diff --git a/res/res_timing_pthread.c b/res/res_timing_pthread.c index 1e76720ec..f57c737f6 100644 --- a/res/res_timing_pthread.c +++ b/res/res_timing_pthread.c @@ -132,11 +132,9 @@ static void *pthread_timer_open(void) } for (i = 0; i < ARRAY_LEN(timer->pipe); ++i) { - int flags = fcntl(timer->pipe[i], F_GETFL); - flags |= O_NONBLOCK; - fcntl(timer->pipe[i], F_SETFL, flags); + ast_fd_set_flags(timer->pipe[i], O_NONBLOCK); } - + ao2_lock(pthread_timers); if (!ao2_container_count(pthread_timers)) { ast_mutex_lock(&timing_thread.lock); diff --git a/res/res_xmpp.c b/res/res_xmpp.c index 1b0ae427b..41f89961c 100644 --- a/res/res_xmpp.c +++ b/res/res_xmpp.c @@ -822,8 +822,8 @@ static struct aco_type global_option = { .type = ACO_GLOBAL, .name = "global", .item_offset = offsetof(struct xmpp_config, global), - .category_match = ACO_WHITELIST, - .category = "^general$", + .category_match = ACO_WHITELIST_EXACT, + .category = "general", }; struct aco_type *global_options[] = ACO_TYPES(&global_option); @@ -831,8 +831,8 @@ struct aco_type *global_options[] = ACO_TYPES(&global_option); static struct aco_type client_option = { .type = ACO_ITEM, .name = "client", - .category_match = ACO_BLACKLIST, - .category = "^(general)$", + .category_match = ACO_BLACKLIST_EXACT, + .category = "general", .item_alloc = ast_xmpp_client_config_alloc, .item_find = xmpp_config_find, .item_prelink = xmpp_config_prelink, diff --git a/res/snmp/agent.c b/res/snmp/agent.c index 7cd895559..ffec44406 100644 --- a/res/snmp/agent.c +++ b/res/snmp/agent.c @@ -555,7 +555,7 @@ static u_char *ast_var_channel_types_table(struct variable *vp, oid *name, size_ ast_variables_destroy(channel_types); if (next == NULL || tech == NULL) return NULL; - + switch (vp->magic) { case ASTCHANTYPEINDEX: long_ret = name[*length - 1]; diff --git a/res/stasis/app.c b/res/stasis/app.c index 1e885c6f8..91b006572 100644 --- a/res/stasis/app.c +++ b/res/stasis/app.c @@ -1432,25 +1432,15 @@ int app_unsubscribe_bridge_id(struct stasis_app *app, const char *bridge_id) int app_is_subscribed_bridge_id(struct stasis_app *app, const char *bridge_id) { struct app_forwards *forwards; - SCOPED_AO2LOCK(lock, app->forwards); - - forwards = ao2_find(app->forwards, BRIDGE_ALL, OBJ_SEARCH_KEY | OBJ_NOLOCK); - if (forwards) { - ao2_ref(forwards, -1); - return 1; - } if (ast_strlen_zero(bridge_id)) { bridge_id = BRIDGE_ALL; } - forwards = ao2_find(app->forwards, bridge_id, OBJ_SEARCH_KEY | OBJ_NOLOCK); - if (forwards) { - ao2_ref(forwards, -1); - return 1; - } + forwards = ao2_find(app->forwards, bridge_id, OBJ_SEARCH_KEY); + ao2_cleanup(forwards); - return 0; + return forwards != NULL; } static void *bridge_find(const struct stasis_app *app, const char *id) @@ -1565,5 +1555,3 @@ void stasis_app_unregister_event_sources(void) stasis_app_unregister_event_source(&bridge_event_source); stasis_app_unregister_event_source(&channel_event_source); } - - |