[svn-commits] branch oej/multiparking - r8298 in /team/oej/multiparking: ./ apps/ channels/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Jan 19 15:07:48 MST 2006


Author: oej
Date: Thu Jan 19 16:07:46 2006
New Revision: 8298

URL: http://svn.digium.com/view/asterisk?rev=8298&view=rev
Log:
Merged revisions 8270,8278,8282 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r8270 | tilghman | 2006-01-19 19:58:45 +0100 (Thu, 19 Jan 2006) | 2 lines

Deprecate the use of Random in 1.3, 1.4

........
r8278 | tilghman | 2006-01-19 20:18:51 +0100 (Thu, 19 Jan 2006) | 3 lines

Merged revisions 8276 via svnmerge from
/branches/1.2

........
r8282 | oej | 2006-01-19 20:41:06 +0100 (Thu, 19 Jan 2006) | 2 lines

Enable "musicclass" setting for sip peers

........

Modified:
    team/oej/multiparking/   (props changed)
    team/oej/multiparking/apps/app_random.c
    team/oej/multiparking/ast_expr2.fl
    team/oej/multiparking/ast_expr2.y
    team/oej/multiparking/channels/chan_sip.c

Propchange: team/oej/multiparking/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Jan 19 16:07:46 2006
@@ -1,1 +1,1 @@
-/trunk:1-8266
+/trunk:1-8297

Modified: team/oej/multiparking/apps/app_random.c
URL: http://svn.digium.com/view/asterisk/team/oej/multiparking/apps/app_random.c?rev=8298&r1=8297&r2=8298&view=diff
==============================================================================
--- team/oej/multiparking/apps/app_random.c (original)
+++ team/oej/multiparking/apps/app_random.c Thu Jan 19 16:07:46 2006
@@ -39,6 +39,8 @@
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 
+/* TODO This app should be removed from trunk following the release of 1.4 */
+
 static char *tdesc = "Random goto";
 
 static char *app_random = "Random";
@@ -47,13 +49,12 @@
 
 static char *random_descrip =
 "Random([probability]:[[context|]extension|]priority)\n"
-"  probability := INTEGER in the range 1 to 100\n";
+"  probability := INTEGER in the range 1 to 100\n"
+"DEPRECATED: Use GotoIf($[${RAND(1,100)} > <number>]?<label>)\n";
 
 STANDARD_LOCAL_USER;
 
 LOCAL_USER_DECL;
-
-static char random_state[256];
 
 static int random_exec(struct ast_channel *chan, void *data)
 {
@@ -63,7 +64,8 @@
 	char *s;
 	char *prob;
 	int probint;
-	
+	static int deprecated = 0;
+
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "Random requires an argument ([probability]:[[context|]extension|]priority)\n");
 		return -1;
@@ -82,7 +84,12 @@
 	if ((!prob) || (sscanf(prob, "%d", &probint) != 1))
 		probint = 0;
 
-	if ((random() % 100) + probint > 100) {
+	if (!deprecated) {
+		deprecated = 1;
+		ast_log(LOG_WARNING, "Random is deprecated in Asterisk 1.3 or later.  Replace with GotoIf($[${RAND(0,99)} + %d >= 100]?%s)\n", probint, s);
+	}
+
+	if ((ast_random() % 100) + probint > 100) {
 		res = ast_parseable_goto(chan, s);
 		if (option_verbose > 2)
 			ast_verbose( VERBOSE_PREFIX_3 "Random branches to (%s,%s,%d)\n",
@@ -105,7 +112,6 @@
 
 int load_module(void)
 {
-	initstate((getppid() * 65535 + getpid()) % RAND_MAX, random_state, 256);
 	return ast_register_application(app_random, random_exec, random_synopsis, random_descrip);
 }
 

Modified: team/oej/multiparking/ast_expr2.fl
URL: http://svn.digium.com/view/asterisk/team/oej/multiparking/ast_expr2.fl?rev=8298&r1=8297&r2=8298&view=diff
==============================================================================
--- team/oej/multiparking/ast_expr2.fl (original)
+++ team/oej/multiparking/ast_expr2.fl Thu Jan 19 16:07:46 2006
@@ -67,7 +67,7 @@
  
 void ast_yyset_column(int column_no, yyscan_t yyscanner);
 int ast_yyget_column(yyscan_t yyscanner);
-
+static int curlycount = 0;
 %}
 
 %option prefix="ast_yy"
@@ -77,6 +77,7 @@
 %option bison-bridge
 %option bison-locations
 %option noyywrap
+%x var trail
 
 %%
 
@@ -98,6 +99,8 @@
 \:\:	{ SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;}
 \(	{ SET_COLUMNS; SET_STRING; return TOK_LP;}
 \)	{ SET_COLUMNS; SET_STRING; return TOK_RP;}
+\$\{   {/* gather the contents of ${} expressions, with trailing stuff, into a single TOKEN. They are much more complex now than they used to be */
+                       curlycount = 0; BEGIN(var); yymore();}
 
 [ 	\r]		{}
 \"[^"]*\"   {SET_COLUMNS; SET_STRING; return TOKEN;}
@@ -106,7 +109,14 @@
 [0-9]+		{   SET_COLUMNS;  /* the original behavior of the expression parser was to bring in numbers as a numeric string */
 				SET_NUMERIC_STRING;
 				return TOKEN;}
-[a-zA-Z0-9,.';{}\\_^%$#@!]+	{SET_COLUMNS; SET_STRING; return TOKEN;}
+[a-zA-Z0-9,.';\\_^%$#@!]+	{SET_COLUMNS; SET_STRING; return TOKEN;}
+
+<var>[^{}]*\}  {curlycount--; if(curlycount < 0){ BEGIN(trail);  yymore();} else {  yymore();}}
+<var>[^{}]*\{  {curlycount++; yymore();  }
+<trail>[^-\t\r \n$():?%/+=*<>!|&]* {BEGIN(0); SET_COLUMNS; SET_STRING; return TOKEN;}
+<trail>[-\t\r \n$():?%/+=*<>!|&]        {char c = yytext[yyleng-1]; BEGIN(0); unput(c); SET_COLUMNS; SET_STRING; return TOKEN;}
+<trail>\$\{            {curlycount = 0; BEGIN(var); yymore();  }
+<trail><<EOF>>		{BEGIN(0); SET_COLUMNS; SET_STRING; return TOKEN; /* actually, if an expr is only a variable ref, this could happen a LOT */}
 
 %%
 
@@ -153,6 +163,7 @@
 			ast_copy_string(buf, io.val->u.s, length);
 #endif /* STANDALONE */
 			return_value = strlen(buf);
+			free(io.val->u.s);
 		}
 		free(io.val);
 	}
@@ -167,15 +178,6 @@
 	int i=0;
 	spacebuf[0] = 0;
 	
-#ifdef WHEN_LOC_MEANS_SOMETHING
-	if( loc->first_column > 7990 ) /* if things get out of whack, why crash? */
-		loc->first_column = 7990;
-	if( loc->last_column > 7990 )
-		loc->last_column = 7990;
-	for(i=0;i<loc->first_column;i++) spacebuf[i] = ' ';
-	for(   ;i<loc->last_column;i++) spacebuf[i] = '^';
-	spacebuf[i] = 0;
-#endif
 	for(i=0;i< (int)(yytext - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf);i++) spacebuf2[i] = ' ';  /* uh... assuming yyg is defined, then I can use the yycolumn macro,
 													which is the same thing as... get this:
 													yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column

Modified: team/oej/multiparking/ast_expr2.y
URL: http://svn.digium.com/view/asterisk/team/oej/multiparking/ast_expr2.y?rev=8298&r1=8297&r2=8298&view=diff
==============================================================================
--- team/oej/multiparking/ast_expr2.y (original)
+++ team/oej/multiparking/ast_expr2.y Thu Jan 19 16:07:46 2006
@@ -124,7 +124,12 @@
    some useful info about the error. Not as easy as it looks, but it
    is possible. */
 #define ast_yyerror(x) ast_yyerror(x,&yyloc,parseio)
-
+#define DESTROY(x) { \
+if ((x)->type == AST_EXPR_numeric_string || (x)->type == AST_EXPR_string) \
+	free((x)->u.s); \
+	(x)->u.s = 0; \
+	free(x); \
+}
 %}
  
 %pure-parser
@@ -158,69 +163,91 @@
 %%
 
 start: expr { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
-              ((struct parse_io *)parseio)->val->type = $$->type;
-              if( $$->type == AST_EXPR_integer )
-		((struct parse_io *)parseio)->val->u.i = $$->u.i;
+              ((struct parse_io *)parseio)->val->type = $1->type;
+              if( $1->type == AST_EXPR_integer )
+				  ((struct parse_io *)parseio)->val->u.i = $1->u.i;
               else
-                ((struct parse_io *)parseio)->val->u.s = $$->u.s; }
+				  ((struct parse_io *)parseio)->val->u.s = $1->u.s; 
+			  free($1);
+			}
 	;
 
 expr:	TOKEN   { $$= $1;}
 	| TOK_LP expr TOK_RP { $$ = $2; 
 	                       @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
-						   @$.first_line=0; @$.last_line=0;}
+						   @$.first_line=0; @$.last_line=0;
+							DESTROY($1); DESTROY($3); }
 	| expr TOK_OR expr { $$ = op_or ($1, $3);
+						DESTROY($2);	
                          @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 						 @$.first_line=0; @$.last_line=0;}
 	| expr TOK_AND expr { $$ = op_and ($1, $3); 
+						DESTROY($2);	
 	                      @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
                           @$.first_line=0; @$.last_line=0;}
 	| expr TOK_EQ expr { $$ = op_eq ($1, $3);
+						DESTROY($2);	
 	                     @$.first_column = @1.first_column; @$.last_column = @3.last_column;
 						 @$.first_line=0; @$.last_line=0;}
 	| expr TOK_GT expr { $$ = op_gt ($1, $3);
+						DESTROY($2);	
                          @$.first_column = @1.first_column; @$.last_column = @3.last_column;
 						 @$.first_line=0; @$.last_line=0;}
 	| expr TOK_LT expr { $$ = op_lt ($1, $3); 
+						DESTROY($2);	
 	                     @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 						 @$.first_line=0; @$.last_line=0;}
 	| expr TOK_GE expr  { $$ = op_ge ($1, $3); 
+						DESTROY($2);	
 	                      @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 						  @$.first_line=0; @$.last_line=0;}
 	| expr TOK_LE expr  { $$ = op_le ($1, $3); 
+						DESTROY($2);	
 	                      @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 						  @$.first_line=0; @$.last_line=0;}
 	| expr TOK_NE expr  { $$ = op_ne ($1, $3); 
+						DESTROY($2);	
 	                      @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 						  @$.first_line=0; @$.last_line=0;}
 	| expr TOK_PLUS expr { $$ = op_plus ($1, $3); 
+						DESTROY($2);	
 	                       @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 						   @$.first_line=0; @$.last_line=0;}
 	| expr TOK_MINUS expr { $$ = op_minus ($1, $3); 
+						DESTROY($2);	
 	                        @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 							@$.first_line=0; @$.last_line=0;}
 	| TOK_MINUS expr %prec TOK_COMPL { $$ = op_negate ($2); 
+						DESTROY($1);	
 	                        @$.first_column = @1.first_column; @$.last_column = @2.last_column; 
 							@$.first_line=0; @$.last_line=0;}
 	| TOK_COMPL expr   { $$ = op_compl ($2); 
+						DESTROY($1);	
 	                        @$.first_column = @1.first_column; @$.last_column = @2.last_column; 
 							@$.first_line=0; @$.last_line=0;}
 	| expr TOK_MULT expr { $$ = op_times ($1, $3); 
+						DESTROY($2);	
 	                       @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 						   @$.first_line=0; @$.last_line=0;}
 	| expr TOK_DIV expr { $$ = op_div ($1, $3); 
+						DESTROY($2);	
 	                      @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 						  @$.first_line=0; @$.last_line=0;}
 	| expr TOK_MOD expr { $$ = op_rem ($1, $3); 
+						DESTROY($2);	
 	                      @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 						  @$.first_line=0; @$.last_line=0;}
 	| expr TOK_COLON expr { $$ = op_colon ($1, $3); 
+						DESTROY($2);	
 	                        @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 							@$.first_line=0; @$.last_line=0;}
 	| expr TOK_EQTILDE expr { $$ = op_eqtilde ($1, $3); 
+						DESTROY($2);	
 	                        @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 							@$.first_line=0; @$.last_line=0;}
 	| expr TOK_COND expr TOK_COLONCOLON expr  { $$ = op_cond ($1, $3, $5); 
+						DESTROY($2);	
+						DESTROY($4);	
 	                        @$.first_column = @1.first_column; @$.last_column = @3.last_column; 
 							@$.first_line=0; @$.last_line=0;}
 	;
@@ -281,6 +308,7 @@
 	}
 	if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
 		free (vp->u.s);	
+	free(vp);
 }
 
 

Modified: team/oej/multiparking/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/multiparking/channels/chan_sip.c?rev=8298&r1=8297&r2=8298&view=diff
==============================================================================
--- team/oej/multiparking/channels/chan_sip.c (original)
+++ team/oej/multiparking/channels/chan_sip.c Thu Jan 19 16:07:46 2006
@@ -12243,7 +12243,7 @@
 			}
 		} else if (!strcasecmp(v->name, "accountcode")) {
 			ast_copy_string(peer->accountcode, v->value, sizeof(peer->accountcode));
-		} else if (!strcasecmp(v->name, "musiconhold")) {
+		} else if (!strcasecmp(v->name, "musicclass") || !strcasecmp(v->name, "musiconhold")) {
 			ast_copy_string(peer->musicclass, v->value, sizeof(peer->musicclass));
 		} else if (!strcasecmp(v->name, "parkinglot")) {
 			ast_copy_string(peer->parkinglot, v->value, sizeof(peer->parkinglot));



More information about the svn-commits mailing list