[asterisk-commits] branch murf/AEL2 r22081 - in /team/murf/AEL2: ./ pbx/ pbx/ael/ pbx/ael/ael-te...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 21 13:56:27 MST 2006


Author: murf
Date: Fri Apr 21 15:56:17 2006
New Revision: 22081

URL: http://svn.digium.com/view/asterisk?rev=22081&view=rev
Log:
I took some time and used purify on the sources to date.
Found a series of small leaks/un-init's, etc that I 
fixed up. 
I also inserted some %destructor directives to reduce 
any leaked memory from syntax errors in both the ael and ast_expr2 
parsers.
Included some more test cases in the ael-test dir, including the file
uploaded to the bug page, and some data "sokhapkin" contributed as a 
test case.


Added:
    team/murf/AEL2/pbx/ael/ael-test/ael-test5/
    team/murf/AEL2/pbx/ael/ael-test/ael-test5/extensions.ael   (with props)
    team/murf/AEL2/pbx/ael/ael-test/ael-test6/
    team/murf/AEL2/pbx/ael/ael-test/ael-test6/extensions.ael   (with props)
    team/murf/AEL2/pbx/ael/ael-test/ael-test7/
    team/murf/AEL2/pbx/ael/ael-test/ael-test7/extensions.ael   (with props)
    team/murf/AEL2/pbx/ael/ael-test/ref.ael-test5   (with props)
    team/murf/AEL2/pbx/ael/ael-test/ref.ael-test6   (with props)
    team/murf/AEL2/pbx/ael/ael-test/ref.ael-test7   (with props)
Modified:
    team/murf/AEL2/ast_expr2.c
    team/murf/AEL2/ast_expr2.y
    team/murf/AEL2/pbx/ael/ael-test/ref.ael-test1
    team/murf/AEL2/pbx/ael/ael-test/ref.ael-test2
    team/murf/AEL2/pbx/ael/ael-test/ref.ael-test3
    team/murf/AEL2/pbx/ael/ael-test/ref.ael-test4
    team/murf/AEL2/pbx/ael/ael.flex
    team/murf/AEL2/pbx/ael/ael.tab.c
    team/murf/AEL2/pbx/ael/ael.y
    team/murf/AEL2/pbx/ael/ael_lex.c
    team/murf/AEL2/pbx/pbx_ael.c

Modified: team/murf/AEL2/ast_expr2.c
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/ast_expr2.c?rev=22081&r1=22080&r2=22081&view=diff
==============================================================================
--- team/murf/AEL2/ast_expr2.c (original)
+++ team/murf/AEL2/ast_expr2.c Fri Apr 21 15:56:17 2006
@@ -527,11 +527,11 @@
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
-static const unsigned char yyrline[] =
-{
-       0,   163,   163,   171,   178,   179,   183,   187,   191,   195,
-     199,   203,   207,   211,   215,   219,   223,   227,   231,   235,
-     239,   243,   247,   251
+static const unsigned short int yyrline[] =
+{
+       0,   168,   168,   176,   183,   184,   188,   192,   196,   200,
+     204,   208,   212,   216,   220,   224,   228,   232,   236,   240,
+     244,   248,   252,   256
 };
 #endif
 
@@ -1037,6 +1037,121 @@
 
   switch (yytype)
     {
+      case 3: /* "TOK_COLONCOLON" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1044 "ast_expr2.c"
+        break;
+      case 4: /* "TOK_COND" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1049 "ast_expr2.c"
+        break;
+      case 5: /* "TOK_OR" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1054 "ast_expr2.c"
+        break;
+      case 6: /* "TOK_AND" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1059 "ast_expr2.c"
+        break;
+      case 7: /* "TOK_NE" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1064 "ast_expr2.c"
+        break;
+      case 8: /* "TOK_LE" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1069 "ast_expr2.c"
+        break;
+      case 9: /* "TOK_GE" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1074 "ast_expr2.c"
+        break;
+      case 10: /* "TOK_LT" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1079 "ast_expr2.c"
+        break;
+      case 11: /* "TOK_GT" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1084 "ast_expr2.c"
+        break;
+      case 12: /* "TOK_EQ" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1089 "ast_expr2.c"
+        break;
+      case 13: /* "TOK_MINUS" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1094 "ast_expr2.c"
+        break;
+      case 14: /* "TOK_PLUS" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1099 "ast_expr2.c"
+        break;
+      case 15: /* "TOK_MOD" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1104 "ast_expr2.c"
+        break;
+      case 16: /* "TOK_DIV" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1109 "ast_expr2.c"
+        break;
+      case 17: /* "TOK_MULT" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1114 "ast_expr2.c"
+        break;
+      case 18: /* "TOK_COMPL" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1119 "ast_expr2.c"
+        break;
+      case 19: /* "TOK_EQTILDE" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1124 "ast_expr2.c"
+        break;
+      case 20: /* "TOK_COLON" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1129 "ast_expr2.c"
+        break;
+      case 21: /* "TOK_LP" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1134 "ast_expr2.c"
+        break;
+      case 22: /* "TOK_RP" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1139 "ast_expr2.c"
+        break;
+      case 23: /* "TOKEN" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1144 "ast_expr2.c"
+        break;
+      case 25: /* "start" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1149 "ast_expr2.c"
+        break;
+      case 26: /* "expr" */
+#line 162 "ast_expr2.y"
+        {  if (yymsg[0] != 'C') free_value((yyvaluep->val)); };
+#line 1154 "ast_expr2.c"
+        break;
 
       default:
         break;
@@ -1352,7 +1467,7 @@
   switch (yyn)
     {
         case 2:
-#line 163 "ast_expr2.y"
+#line 168 "ast_expr2.y"
     { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
               ((struct parse_io *)parseio)->val->type = (yyvsp[0].val)->type;
               if( (yyvsp[0].val)->type == AST_EXPR_integer )
@@ -1364,7 +1479,7 @@
     break;
 
   case 3:
-#line 171 "ast_expr2.y"
+#line 176 "ast_expr2.y"
     {/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
               ((struct parse_io *)parseio)->val->type = AST_EXPR_string;
 			  ((struct parse_io *)parseio)->val->u.s = strdup(""); 
@@ -1372,12 +1487,12 @@
     break;
 
   case 4:
-#line 178 "ast_expr2.y"
+#line 183 "ast_expr2.y"
     { (yyval.val)= (yyvsp[0].val);;}
     break;
 
   case 5:
-#line 179 "ast_expr2.y"
+#line 184 "ast_expr2.y"
     { (yyval.val) = (yyvsp[-1].val); 
 	                       (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
 						   (yyloc).first_line=0; (yyloc).last_line=0;
@@ -1385,7 +1500,7 @@
     break;
 
   case 6:
-#line 183 "ast_expr2.y"
+#line 188 "ast_expr2.y"
     { (yyval.val) = op_or ((yyvsp[-2].val), (yyvsp[0].val));
 						DESTROY((yyvsp[-1].val));	
                          (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1393,7 +1508,7 @@
     break;
 
   case 7:
-#line 187 "ast_expr2.y"
+#line 192 "ast_expr2.y"
     { (yyval.val) = op_and ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                      (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1401,7 +1516,7 @@
     break;
 
   case 8:
-#line 191 "ast_expr2.y"
+#line 196 "ast_expr2.y"
     { (yyval.val) = op_eq ((yyvsp[-2].val), (yyvsp[0].val));
 						DESTROY((yyvsp[-1].val));	
 	                     (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
@@ -1409,7 +1524,7 @@
     break;
 
   case 9:
-#line 195 "ast_expr2.y"
+#line 200 "ast_expr2.y"
     { (yyval.val) = op_gt ((yyvsp[-2].val), (yyvsp[0].val));
 						DESTROY((yyvsp[-1].val));	
                          (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
@@ -1417,7 +1532,7 @@
     break;
 
   case 10:
-#line 199 "ast_expr2.y"
+#line 204 "ast_expr2.y"
     { (yyval.val) = op_lt ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                     (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1425,7 +1540,7 @@
     break;
 
   case 11:
-#line 203 "ast_expr2.y"
+#line 208 "ast_expr2.y"
     { (yyval.val) = op_ge ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                      (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1433,7 +1548,7 @@
     break;
 
   case 12:
-#line 207 "ast_expr2.y"
+#line 212 "ast_expr2.y"
     { (yyval.val) = op_le ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                      (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1441,7 +1556,7 @@
     break;
 
   case 13:
-#line 211 "ast_expr2.y"
+#line 216 "ast_expr2.y"
     { (yyval.val) = op_ne ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                      (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1449,7 +1564,7 @@
     break;
 
   case 14:
-#line 215 "ast_expr2.y"
+#line 220 "ast_expr2.y"
     { (yyval.val) = op_plus ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                       (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1457,7 +1572,7 @@
     break;
 
   case 15:
-#line 219 "ast_expr2.y"
+#line 224 "ast_expr2.y"
     { (yyval.val) = op_minus ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                        (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1465,7 +1580,7 @@
     break;
 
   case 16:
-#line 223 "ast_expr2.y"
+#line 228 "ast_expr2.y"
     { (yyval.val) = op_negate ((yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                        (yyloc).first_column = (yylsp[-1]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1473,7 +1588,7 @@
     break;
 
   case 17:
-#line 227 "ast_expr2.y"
+#line 232 "ast_expr2.y"
     { (yyval.val) = op_compl ((yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                        (yyloc).first_column = (yylsp[-1]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1481,7 +1596,7 @@
     break;
 
   case 18:
-#line 231 "ast_expr2.y"
+#line 236 "ast_expr2.y"
     { (yyval.val) = op_times ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                       (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1489,7 +1604,7 @@
     break;
 
   case 19:
-#line 235 "ast_expr2.y"
+#line 240 "ast_expr2.y"
     { (yyval.val) = op_div ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                      (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1497,7 +1612,7 @@
     break;
 
   case 20:
-#line 239 "ast_expr2.y"
+#line 244 "ast_expr2.y"
     { (yyval.val) = op_rem ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                      (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1505,7 +1620,7 @@
     break;
 
   case 21:
-#line 243 "ast_expr2.y"
+#line 248 "ast_expr2.y"
     { (yyval.val) = op_colon ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                        (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1513,7 +1628,7 @@
     break;
 
   case 22:
-#line 247 "ast_expr2.y"
+#line 252 "ast_expr2.y"
     { (yyval.val) = op_eqtilde ((yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-1].val));	
 	                        (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column; 
@@ -1521,7 +1636,7 @@
     break;
 
   case 23:
-#line 251 "ast_expr2.y"
+#line 256 "ast_expr2.y"
     { (yyval.val) = op_cond ((yyvsp[-4].val), (yyvsp[-2].val), (yyvsp[0].val)); 
 						DESTROY((yyvsp[-3].val));	
 						DESTROY((yyvsp[-1].val));	
@@ -1534,7 +1649,7 @@
     }
 
 /* Line 1126 of yacc.c.  */
-#line 1538 "ast_expr2.c"
+#line 1653 "ast_expr2.c"
 
   yyvsp -= yylen;
   yyssp -= yylen;
@@ -1809,7 +1924,7 @@
 }
 
 
-#line 258 "ast_expr2.y"
+#line 263 "ast_expr2.y"
 
 
 static struct val *

Modified: team/murf/AEL2/ast_expr2.y
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/ast_expr2.y?rev=22081&r1=22080&r2=22081&view=diff
==============================================================================
--- team/murf/AEL2/ast_expr2.y (original)
+++ team/murf/AEL2/ast_expr2.y Fri Apr 21 15:56:17 2006
@@ -158,6 +158,11 @@
 %token <val> TOKEN
 %type <val> start expr
 
+
+%destructor {  if (yymsg[0] != 'C') free_value($$); }  start expr TOKEN TOK_COND TOK_COLONCOLON TOK_OR TOK_AND TOK_EQ 
+                                 TOK_GT TOK_LT TOK_GE TOK_LE TOK_NE TOK_PLUS TOK_MINUS TOK_MULT TOK_DIV TOK_MOD TOK_COMPL TOK_COLON TOK_EQTILDE 
+                                 TOK_RP TOK_LP
+
 %%
 
 start: expr { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);

Added: team/murf/AEL2/pbx/ael/ael-test/ael-test5/extensions.ael
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/pbx/ael/ael-test/ael-test5/extensions.ael?rev=22081&view=auto
==============================================================================
--- team/murf/AEL2/pbx/ael/ael-test/ael-test5/extensions.ael (added)
+++ team/murf/AEL2/pbx/ael/ael-test/ael-test5/extensions.ael Fri Apr 21 15:56:17 2006
@@ -1,0 +1,833 @@
+///////////////////////////////////////////////////////////////////////////////
+// Helpdesk Queue
+
+context hd-queue {
+	s => {
+		NoOp(Add a background sound to tell the user their options);
+		Queue(helpdesk|t);
+		NoOp(Put in options to apologize and send user to voicemail);
+	};
+
+	0 => goto default|0|1;
+	1 => {
+		Dial(u41950 at svm1.shsu.edu);
+		Congestion(10);
+		Hangup;
+	};
+};
+
+
+context l903-calling {
+	_9903NXXXXXX => {
+		Realtime(l903_ext,exchange,${EXTEN:4:3},l903_);
+		if ("${l903_exchange}foo" = "foo") {
+			Playback(num-outside-area);
+			SayDigits(1);
+			Playback(and-area-code);
+			Playback(before-the-number);
+			Hangup;
+		};
+		&dialout(${EXTEN});
+		Congestion(10);
+		Hangup;
+	};
+};
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from houston.conf
+// Converted the extension list to the database
+
+context houston-calling {
+	_9713NXXXXXX => {
+		Realtime(hou_713_ext,exchange,${EXTEN:4:3},hou_713_);
+		if ("${hou_713_exchange}foo" = "foo") {
+			Playback(num-outside-area);
+			SayDigits(1);
+			Playback(and-area-code);
+			Playback(before-the-number);
+			Hangup;
+		};
+		&dialout(${EXTEN});
+		Congestion(10);
+		Hangup;
+	};
+
+	_9281NXXXXXX => {
+		Realtime(hou_281_ext,exchange,${EXTEN:4:3},hou_281_);
+		if ("${hou_281_exchange}foo" = "foo") {
+			Playback(num-outside-area);
+			SayDigits(1);
+			Playback(and-area-code);
+			Playback(before-the-number);
+			Hangup;
+		};
+		&dialout(${EXTEN});
+		Congestion(10);
+		Hangup;
+	};
+
+	_9832NXXXXXX => {
+		Realtime(hou_832_ext,exchange,${EXTEN:4:3},hou_832_);
+		if ("${hou_832_exchange}foo" = "foo") {
+			Playback(num-outside-area);
+			SayDigits(1);
+			Playback(and-area-code);
+			Playback(before-the-number);
+			Hangup;
+		};
+		&dialout(${EXTEN});
+		Congestion(10);
+		Hangup;
+	};
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from huntsville.conf
+// Converted the extension list to the database
+
+context huntsville-calling {
+	_9NXXXXXX => {
+		Realtime(hv_ext,exchange,${EXTEN:1:3},hv_);
+		if ("${hv_exchange}foo" = "foo") {
+			Playback(num-outside-area);
+			SayDigits(1);
+			Playback(and-area-code);
+			Playback(before-the-number);
+			Hangup;
+		};
+		&dialout(${EXTEN});
+		Congestion(10);
+		Hangup;
+	};
+
+	_NXXXXXX => {
+		NoOp(Stripping last four to see what extension we're dialing);
+		Set(LAST4=${EXTEN:3});
+		StripLSD(4);
+	};
+
+	i => Playback(pbx-invalid);
+	h => Hangup;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from macros.conf
+
+macro dialout( number ) {
+	Realtime(call_info,exten,${CALLERIDNUM:5},mon_);
+	if ("${mon_monitor}" = "YES") {
+		Dial(SIP/${number}@sgw1.shsu.edu,,wW);
+		Dial(SIP/${number}@sgw2.shsu.edu,,wW);
+	} else {
+		Dial(SIP/${number}@sgw1.shsu.edu);
+		Dial(SIP/${number}@sgw2.shsu.edu);
+	};
+};
+
+// Standard extension macro:
+//  ${ext} - Extension
+macro stdexten( ext ) {
+	Realtime(sipusers,name,${ext},sip_user_);
+	Realtime(call_info,exten|${ext},info_);
+	if ("${sip_user_name}foo" = "foo") {
+		Wait(1);
+		&dialout(${ext});
+		Congestion(10);
+		Hangup;
+	};
+	NoOp(${CALLERIDNUM});
+	RealtimeUpdate(call_info,exten,${ext},calltrace,${CALLERIDNUM});
+	System(/usr/local/bin/db_update.sh call_info calltrace ${CALLERIDNUM} exten ${ext} &);
+	&checkdnd(${ext});
+	&checkcf(${ext});
+	Realtime(call_info,exten,${CALLERIDNUM:5},mon_);
+	if ("${mon_monitor}" = "YES") {
+		Dial(SIP/${info_forwardto},25,wW);
+	} else {
+		Dial(SIP/${info_forwardto},25);
+	};
+	switch ("${DIALSTATUS}") {
+		case "BUSY":
+			&checkcfb(${ext});
+			break;
+		case "CHANUNAVAIL":
+			Dial(IAX2/asterisk:password at scm2.shsu.edu/${info_forwardto},25,wW);
+			MailboxExists(${ext});
+//			if ("${VMBOXEXISTSSTATUS}" = "FAILED") {
+//				Congestion(10);
+//				Hangup;
+//			};
+			&uvm(${ext});
+			Hangup;
+			break;
+		case "CONGESTION":
+			MailboxExists(${ext});
+			if ("${VMBOXEXISTSSTATUS}" = "FAILED") {
+				Congestion(10);
+				Hangup;
+			};
+			&bvm(${ext});
+			Hangup;
+			break;
+		default:
+			MailboxExists(${ext});
+			if ("${VMBOXEXISTSSTATUS}" = "FAILED") {
+				Congestion(10);
+				Hangup;
+			};
+			&uvm(${ext});
+			Hangup;
+	};
+	Hangup;
+};
+
+macro uvm( ext ) {
+	Dial(SIP/u${ext}@svm1.shsu.edu);
+	Playback(im-sorry);
+	Playback(voice-mail-system);
+	Playback(down);
+	Congestion(10);
+	Hangup;
+};
+
+macro bvm( ext ) {
+	Dial(SIP/b${ext}@svm1.shsu.edu);
+	Playback(im-sorry);
+	Playback(voice-mail-system);
+	Playback(down);
+	Congestion(10);
+	Hangup;
+};
+
+macro checkdnd( ext ) {
+	if ("${info_donotdisturb}foo" = "foo") {
+		NoOp(Do Not Disturb is not active);
+	} else
+		&uvm(${ext});
+};
+
+macro checkcf( ext ) {
+	if ("${info_forwardto}foo" = "foo")
+		if ("${ext}" = "43974") {
+			Set(info_forwardto=${ext}&SCCP/${ext});
+		} else {
+			Set(info_forwardto=${ext}&SIP/${ext}w);
+		};
+};
+
+macro checkcfb( ext ) {
+	if ("${info_forwardbusy}foo" = "foo") {
+		Wait(1);
+		MailboxExists(${ext});
+		if ("${VMBOXEXISTSSTATUS}" = "FAILED") {
+			&dialout(${ext});
+			Hangup;
+		};
+		&bvm(${ext});
+		Hangup;
+	};
+	&stdexten(${info_forwardbusy});
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from test.conf
+
+context test-include {
+	includes {
+		test-digium;
+		test-sounds;
+		test-phinfo;
+	};
+};
+
+context test-digium {
+	*500 => {
+		Dial(IAX2/guest at misery.digium.com/s at default);
+		Playback(demo-nogo);
+		Hangup;
+	};
+};
+
+context test-sounds {
+	*501 => {
+		Answer;
+		Musiconhold;
+		Wait(1);
+		Hangup;
+	};
+};
+
+context test-phinfo {
+	*505 => {
+		Answer;
+		NoOp(${CALLERIDNUM:5});
+		SayDigits(${CALLERIDNUM:5});
+		Hangup;
+	};
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from external.conf
+
+context long-distance {
+	includes {
+		local;
+	};
+
+	_91XXXXXXXXXX => &dialout(${EXTEN});
+	_9011. => &dialout(${EXTEN});
+};
+
+context local {
+	includes {
+		default;
+	};
+
+	911 => &dialout(911);
+	9911 => &dialout(9911);
+
+	_9NXXXXXX => goto huntsville-calling|${EXTEN}|1;
+	_936NXXXXXX => {
+		goto 9${EXTEN:3}|1;
+		Congestion(10);
+		Hangup;
+	};
+
+	_832NXXXXXX => {
+		goto 9${EXTEN}|1;
+		Congestion(10);
+		Hangup;
+	};
+
+	_713NXXXXXX => {
+		goto 9${EXTEN}|1 ;
+		Congestion(10);
+		Hangup;
+	};
+
+	_281NXXXXXX => {
+		goto 9${EXTEN}|1;
+		Congestion(10);
+		Hangup;
+
+	};
+
+	_NXXNXXXXXX => {
+		goto 9${EXTEN}|1;
+		goto 91${EXTEN}|1;
+		Congestion(10);
+		Hangup;
+	};
+
+	_91800NXXXXXX => &dialout(${EXTEN});
+	_91866NXXXXXX => &dialout(${EXTEN});
+	_91877NXXXXXX => &dialout(${EXTEN});
+	_91888NXXXXXX => &dialout(${EXTEN});
+	_91900NXXXXXX => &dialout(${EXTEN});
+	_91976NXXXXXX => &dialout(${EXTEN});
+	_9713NXXXXXX => goto houston-calling|${EXTEN}|1;
+	_9281NXXXXXX => goto houston-calling|${EXTEN}|1;
+	_9832NXXXXXX => goto houston-calling|${EXTEN}|1;
+	_9903NXXXXXX => goto l903-calling|${EXTEN}|1;
+
+	_31NXXNXXXXXX => &dialout(${EXTEN});
+
+	h => Hangup;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from internal.conf
+
+context from-scm2 {
+	_4XXXX => {
+		NoOp(DIALING SIP EXTENSION ${EXTEN} - FROM ${CALLERIDNUM});
+		Dial(SIP/${EXTEN},20,wW);
+		Hangup;
+	};
+
+	_6XXXX => {
+		NoOp(DIALING SIP EXTENSION ${EXTEN} - FROM ${CALLERIDNUM});
+		Dial(SIP/${EXTEN},20,wW);
+		Hangup;
+	};
+};
+
+///////////////////////////////////////////////////////////
+// All internal extensions work through the default context
+// Phones that can only make internal calls should be in
+// this context.
+///////////////////////////////////////////////////////////
+
+context default {
+// Include the contexts in the files that allow us to make these phone calls
+	includes {
+		vm-include;
+		apps-include;
+		test-include;
+	};
+
+// ALWAYS have an 'h' extension
+	h => {
+		NoOp(Hangup cause was: ${HANGUPCAUSE});
+		Hangup;
+	};
+
+// We like to hear that we dialed an invalid extension
+	i => Playback(pbx-invalid);
+
+// Dial the operator
+	0 => &dialout(0);
+
+// Send voicemail calls to the vm-* contexts to be handled
+	voicemail => goto vm-direct|s|1;
+	5555 => goto vm-direct|s|1;
+	62100 => goto vm-extension|s|1;
+
+// These are our campus extensions, send them to the macro
+	_6XXXX => &stdexten(${EXTEN});
+	_4XXXX => &stdexten(${EXTEN});
+// These are campus extensions as well, might need to take this out though.
+	_9294XXXX => goto _4XXXX|1;
+	_9496XXXX => goto _6XXXX|1;
+
+// These allows us to dial from the directory in our phone without worrying about dialing 9
+	_936294XXXX => {
+		goto ${EXTEN:5}|1;
+		goto 9${EXTEN:3}|1;
+		Congestion(10);
+		Hangup;
+	};
+
+	_936496XXXX => {
+		goto ${EXTEN:5}|1;
+		goto 9${EXTEN:3}|1;
+		Congestion(10);
+		Hangup;
+	};
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from apps.conf
+
+context apps-include {
+	includes {
+		app-agents;
+		app-dnd;
+		app-callforward;
+		app-calltrace;
+		app-conferences;
+		app-ssd;
+		app-psd;
+		app-idblock;
+		app-helpdesk;
+		app-dictate;
+		app-set-monitor;
+	};
+};
+
+context app-agents {
+	*54 => {
+		Answer;
+		Wait(1);
+		Read(agent_no|agent-user);
+		AgentCallbackLogin(${agent_no}|s${CALLERIDNUM:5});
+		Playback(agent-loginok);
+		Hangup;
+	};
+
+	*55 => {
+		Answer;
+		Wait(1);
+		AgentCallbackLogin(${agent_no});
+		Hangup;
+	};
+};
+
+context app-calltrace {
+// caller dials this to find out the last call missed and possibly call back
+	*69 => goto app-calltrace-perform|s|1;
+};
+
+context app-calltrace-perform {
+	s => {
+		Answer;
+		Wait(1);
+		Background(info-about-last-call);
+		Background(telephone-number);
+		RealTime(call_info|exten|${CALLERIDNUM:5}|ct_);
+		if ("${ct_calltrace}foo" = "foo") {
+			Playback(loligo/from-unknown-caller);
+			Hangup;
+		} else {
+			SayDigits("${ct_calltrace}");
+			Set(TIMEOUT(digit)=3);
+			Set(TIMEOUT(response)=7);
+			Background(loligo/to-call-this-number);
+			Background(press-1);
+			Background(loligo/silence/5);
+		};
+	};
+
+	1 => goto local|${ct_calltrace}|1;
+
+	i => {
+		Playback(vm-goodbye);
+		Hangup;
+	};
+
+	t => {
+		Playback(vm-goodbye);
+		Hangup;
+	};
+};
+
+context app-set-monitor {
+	*50 => {
+		Realtime(call_info,exten,${CALLERIDNUM:5},mon_set_);
+		if ("${mon_set_monitor}" = "YES") {
+			RealtimeUpdate(call_info,exten,${CALLERIDNUM:5},monitor|);
+			System(/usr/local/bin/db_update.sh call_info monitor '' exten ${CALLERIDNUM:5} &);
+		} else {
+			RealtimeUpdate(call_info,exten,${CALLERIDNUM:5},monitor,YES);
+			System(/usr/local/bin/db_update.sh call_info monitor YES exten ${CALLERIDNUM:5} &);
+		};
+		NoOp(${mon_set_monitor});
+		Hangup;
+	};
+};
+
+context app-dnd {
+	*78 => {
+		Answer;
+		Wait(1);
+		RealtimeUpdate(call_info,exten,${CALLERIDNUM:5},donotdisturb,YES);
+		System(/usr/local/bin/db_update.sh call_info donotdisturb YES exten ${CALLERIDNUM:5} &);
+		Playback(do-not-disturb);
+		Playback(loligo/activated);
+		Hangup;
+	};
+
+	*79 => {
+		Answer;
+		Wait(1);
+		RealtimeUpdate(call_info,exten,${CALLERIDNUM:5},donotdisturb|);
+		System(/usr/local/bin/db_update.sh call_info donotdisturb '' exten ${CALLERIDNUM:5} &);
+		Playback(do-not-disturb);
+		Playback(loligo/de-activated);
+		Hangup;
+	};
+};
+
+context app-callforward {
+	// forwards calling extension to input number *72{EXTEN}
+	_*72. => {
+		RealtimeUpdate(call_info,exten,${CALLERIDNUM:5},forwardto,${EXTEN:3});
+		System(/usr/local/bin/db_update.sh call_info forwardto ${EXTEN:3} exten ${CALLERIDNUM:5} &);
+		Answer;
+		Wait(1);
+		Playback(loligo/call-fwd-unconditional);
+		Playback(loligo/for);
+		Playback(loligo/extension);
+		SayDigits(${CALLERIDNUM:5});
+		Playback(loligo/is-set-to);
+		SayDigits(${EXTEN:3});
+		Hangup;
+	};
+
+	// prompts for extension to forward to
+	*72 => {
+		Answer;
+		Wait(1);
+		Playback(please-enter-your);
+		Playback(extension);
+		Background(then-press-pound);
+		VMAuthenticate(|s);
+		Background(loligo/ent-target-attendant);
+		Read(toext,loligo/then-press-pound);
+		Wait(1);
+		RealtimeUpdate(call_info,exten,${AUTH_MAILBOX},forwardto,${toext});
+		System(/usr/local/bin/db_update.sh call_info forwardto ${toext} exten ${AUTH_MAILBOX} &);
+		Playback(loligo/call-fwd-unconditional);
+		Playback(loligo/for);
+		Playback(loligo/extension);
+		SayDigits(${AUTH_MAILBOX});
+		Playback(loligo/is-set-to);
+		SayDigits(${toext});
+		Hangup;
+	};
+
+	// cancels dialed extension call forward
+	_*73. => {
+		Realtime(voicemail,mailbox,${EXTEN:3},auth_);
+		Answer;
+		Wait(1);
+		Authenticate(${auth_password});
+		RealtimeUpdate(call_info,exten,${EXTEN:3},forwardto,);
+		System(/usr/local/bin/db_update.sh call_info forwardto '' exten ${EXTEN:3} &);
+		Wait(1);
+		SayDigits(${EXTEN:3});
+		Playback(loligo/call-fwd-cancelled);
+		Hangup;
+	};
+
+	// cancels call forward for calling extension
+	*73 => {
+		RealtimeUpdate(call_info,exten,${CALLERIDNUM:5},forwardto,);
+		System(/usr/local/bin/db_update.sh call_info forwardto '' exten ${CALLERIDNUM:5} &);
+		Answer;
+		Wait(1);
+		Playback(loligo/call-fwd-cancelled);
+		Hangup;
+	};
+
+	// dialed call forward on busy
+	_*90. => {
+		RealtimeUpdate(call_info,exten,${CALLERIDNUM:5},forwardbusy,${EXTEN:3});
+		System(/usr/local/bin/db_update.sh call_info forwardbusy ${EXTEN:3} exten ${CALLERIDNUM:5} &);
+		Answer;
+		Wait(1);
+		Playback(loligo/call-fwd-on-busy);
+		Playback(loligo/for);
+		Playback(loligo/extension);
+		SayDigits(${CALLERIDNUM:5});
+		Playback(loligo/is-set-to);
+		SayDigits(${EXTEN:3});
+		Hangup;
+	};
+
+	// cancels call forward on busy for calling extension
+	*91 => {
+		RealtimeUpdate(call_info,exten,${CALLERIDNUM:5},forwardbusy|);
+		System(/usr/local/bin/db_update.sh call_info forwardbusy '' exten ${CALLERIDNUM:5} &);
+		Answer;
+		Wait(1);
+		Playback(loligo/call-fwd-on-busy);
+		Playback(loligo/de-activated);
+		Hangup;
+	};
+
+	h => Hangup;
+};
+
+context app-idblock {
+	_*67. => {
+		Set(CALLERID(name)=Anonymous);
+		&stdexten(${EXTEN:3});
+	};
+};
+
+context app-dictate {
+	*1 => {
+		Dictate();
+		Hangup;
+	};
+};
+
+context app-ssd {
+// *59 <xx> <y.> - Set system speed dial <xx> to digits <y.>
+// *59 <xx> 0    - Delete system speed dial <xx>
+// *59 <xx>      - Review system speed dial <xx>
+// *1xx          - Dial speed dial <xx>
+	_*59XXX. => {
+		Answer;
+		RealtimeUpdate(ssd,sd,${EXTEN:3:2},extension,${EXTEN:5});
+		System(/usr/local/bin/db_update.sh systemsd extension ${EXTEN:5} sd ${EXTEN:3:2} &);
+		Wait(1);
+		Playback(loligo/speed-dial);
+		SayDigits(${EXTEN:3:2});
+		Playback(loligo/has-been-set-to);
+		SayDigits(${EXTEN:5});
+		Hangup;
+	};
+
+	_*59XX0 => {
+		Answer;
+		RealtimeUpdate(ssd,sd,${EXTEN:3:2},extension,);
+		System(/usr/local/bin/db_update.sh systemsd extension '' sd ${EXTEN:3:2} &);
+		Wait(1);
+		Playback(loligo/speed-dial);
+		SayDigits(${EXTEN:3:2});
+		Playback(loligo/has-been-cleared);
+		Hangup;
+	};
+
+	_*59XX => {
+		Answer;
+		Realtime(ssd,sd,${EXTEN:3},ssd_);
+		if ("${ssd_extension}foo" = "foo") {
+			Playback(loligo/speed-dial);
+			SayDigits(${EXTEN:3:2});
+			Playback(loligo/is-not-set);
+			Hangup;
+		};
+		Wait(1);
+		Playback(loligo/speed-dial);
+		SayDigits(${EXTEN:3:2});
+		Playback(loligo/is-set-to);
+		SayDigits(${ssd_extension});
+		Hangup;
+	};
+
+	// NTC = number to call
+	_*1XX => {
+		Realtime(ssd,sd,${EXTEN:2},ssd_);
+		if ("${ssd_extension}foo" = "foo") {
+			Answer;
+			Wait(1);
+			Playback(loligo/speed-dial);
+			SayDigits(${EXTEN:2});
+			Playback(loligo/is-not-set);
+			Hangup;
+		};
+		&stdexten(${ssd_extension});
+		Congestion(10);
+		Hangup;
+	};
+};
+
+macro check-psd-exists ( ext ) {
+	Realtime(psd,extension,${ext},psd_);
+	if ("${psd_extension}foo" = "foo") {
+		System(/usr/local/bin/create_psd.sh ${ext});
+	} else
+		NoOp(PSD set for ${ext});
+};
+
+context app-psd {
+// *89 <xx> <y.> - Set personal speed dial <xx> to digits <y.>
+// *89 <xx> 0    - Delete personal speed dial <xx>
+// *89 <xx>      - Review personal speed dial <xx>
+// *2xx          - Dial personal speed dial <xx>
+	_*89XXX. => {
+		&check-psd-exists(${CALLERIDNUM:5});
+		Answer;
+		RealtimeUpdate(psd,extension,${CALLERIDNUM:5},s${EXTEN:3:2},${EXTEN:5});
+		System(/usr/local/bin/db_update.sh personalsd s${EXTEN:3:2} ${EXTEN:5} extension ${CALLERIDNUM:5} &);
+		Wait(1);
+		Playback(loligo/speed-dial);
+		SayDigits(${EXTEN:3:2});
+		Playback(loligo/has-been-set-to);
+		SayDigits(${EXTEN:5});
+		Hangup;
+	};
+
+	_*89XX0 => {
+		&check-psd-exists(${CALLERIDNUM:5});
+		Answer;
+		RealtimeUpdate(psd|extension|${CALLERIDNUM:5}|s${EXTEN:3:2}|);
+		System(/usr/local/bin/db_update.sh personalsd s${EXTEN:3:2} '' extension ${CALLERIDNUM:5} &);
+		Wait(1);
+		Playback(loligo/speed-dial);
+		SayDigits(${EXTEN:3:2});
+		Playback(loligo/has-been-cleared);
+		Hangup;
+	};
+
+	_*89XX => {
+		&check-psd-exists(${CALLERIDNUM:5});
+		Answer;
+		Realtime(psd|extension|${CALLERIDNUM:5}|psd_);
+		Wait(1);
+		if ("${psd_s${EXTEN:3:2}}foo" = "foo") {
+			Playback(loligo/speed-dial);
+			SayDigits(${EXTEN:3:2});
+			Playback(loligo/is-not-set);
+			Hangup;
+		};
+		Playback(loligo/speed-dial);
+		SayDigits(${EXTEN:3:2});
+		Playback(loligo/is-set-to);
+		SayDigits(${psd_s${EXTEN:3:2}});
+		Hangup;
+	};
+
+	// NTC = number to call
+	_*2XX => {
+		&check-psd-exists(${CALLERIDNUM:5});
+		Realtime(psd|extension|${CALLERIDNUM:5}|psd_);
+		if ("${psd_s${EXTEN:2}}foo" = "foo") {
+			Answer;
+			Wait(1);
+			Playback(loligo/speed-dial);
+			SayDigits(${EXTEN:2});
+			Playback(loligo/is-not-set);
+			Hangup;
+		};
+		&stdexten(${psd_s${EXTEN:2}});
+		Congestion(10);
+		Hangup;
+	};
+};
+
+context app-helpdesk {
+	*4357 => {
+		&stdexten(41950);
+		Congestion;
+	};
+};
+
+context app-conferences {
+// waiting for room number announcement
+	*86 => goto app-conf-hidden|s|1;
+};
+
+context app-conf-hidden {
+	s => {
+		Wait(1);
+		Playback(loligo/please-enter-the);
+		Playback(loligo/extension);
+		read(roomtoenter,loligo/then-press-pound);
+		Meetme(${roomtoenter});
+		Waitexten(8);
+		Hangup;
+	};
+
+	_1. => Meetme(${EXTEN});
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from vm.conf:
+
+context vm-include {
+	includes {
+		vm-direct;
+		vm-extension;
+		vm-directory;
+	};
+};
+
+context vm-direct {
+	s => {
+		Dial(SIP/5555 at svm1.shsu.edu,20);
+		Playback(im-sorry);
+		Playback(voice-mail-system);
+		Playback(down);
+		Playback(extra/pls-try-call-later);
+		Congestion(10);
+		Hangup;
+	};
+};
+
+context vm-extension {
+	s => {
+		Dial(SIP/62100 at svm1.shsu.edu,20);
+		Playback(im-sorry);
+		Playback(voice-mail-system);
+		Playback(down);
+		Playback(extra/pls-try-call-later);
+		Congestion(10);
+		Hangup;
+	};
+};
+
+context vm-directory {
+	5556 => {
+		Dial(SIP/5556 at svm1.shsu.edu);
+		Playback(im-sorry);
+		Playback(voice-mail-system);
+		Playback(down);
+		Playback(extra/pls-try-call-later);
+		Congestion(10);
+		Hangup;
+	};
+};

Propchange: team/murf/AEL2/pbx/ael/ael-test/ael-test5/extensions.ael
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/murf/AEL2/pbx/ael/ael-test/ael-test5/extensions.ael
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/murf/AEL2/pbx/ael/ael-test/ael-test5/extensions.ael
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/murf/AEL2/pbx/ael/ael-test/ael-test6/extensions.ael
URL: http://svn.digium.com/view/asterisk/team/murf/AEL2/pbx/ael/ael-test/ael-test6/extensions.ael?rev=22081&view=auto
==============================================================================
--- team/murf/AEL2/pbx/ael/ael-test/ael-test6/extensions.ael (added)
+++ team/murf/AEL2/pbx/ael/ael-test/ael-test6/extensions.ael Fri Apr 21 15:56:17 2006
@@ -1,0 +1,833 @@
+///////////////////////////////////////////////////////////////////////////////
+// Helpdesk Queue
+
+context hd-queue {
+	s => {
+		NoOp(Add a background sound to tell the user their options);
+		Queue(helpdesk|t);
+		NoOp(Put in options to apologize and send user to voicemail);
+	};
+
+	0 => goto default|0|1;
+	1 => {
+		Dial(u41950 at svm1.shsu.edu);
+		Congestion(10);
+		Hangup;
+	};
+};
+
+
+context l903-calling {
+	_9903NXXXXXX => {
+		Realtime(l903_ext|exchange|${EXTEN:4:3}|l903_);
+		if ("${l903_exchange}foo" = "foo") {
+			Playback(num-outside-area);
+			SayDigits(1);
+			Playback(and-area-code);
+			Playback(before-the-number);
+			Hangup;
+		};
+		&dialout(${EXTEN});
+		Congestion(10);
+		Hangup;
+	};
+};
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from houston.conf
+// Converted the extension list to the database
+
+context houston-calling {
+	_9713NXXXXXX => {
+		Realtime(hou_713_ext|exchange|${EXTEN:4:3}|hou_713_);
+		if ("${hou_713_exchange}foo" = "foo") {
+			Playback(num-outside-area);
+			SayDigits(1);
+			Playback(and-area-code);
+			Playback(before-the-number);
+			Hangup;
+		};
+		&dialout(${EXTEN});
+		Congestion(10);
+		Hangup;
+	};
+
+	_9281NXXXXXX => {
+		Realtime(hou_281_ext|exchange|${EXTEN:4:3}|hou_281_);
+		if ("${hou_281_exchange}foo" = "foo") {
+			Playback(num-outside-area);
+			SayDigits(1);
+			Playback(and-area-code);
+			Playback(before-the-number);
+			Hangup;
+		};
+		&dialout(${EXTEN});
+		Congestion(10);
+		Hangup;
+	};
+
+	_9832NXXXXXX => {
+		Realtime(hou_832_ext|exchange|${EXTEN:4:3}|hou_832_);
+		if ("${hou_832_exchange}foo" = "foo") {
+			Playback(num-outside-area);
+			SayDigits(1);
+			Playback(and-area-code);
+			Playback(before-the-number);
+			Hangup;
+		};
+		&dialout(${EXTEN});
+		Congestion(10);
+		Hangup;
+	};
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from huntsville.conf
+// Converted the extension list to the database
+
+context huntsville-calling {
+	_9NXXXXXX => {
+		Realtime(hv_ext|exchange|${EXTEN:1:3}|hv_);
+		if ("${hv_exchange}foo" = "foo") {
+			Playback(num-outside-area);
+			SayDigits(1);
+			Playback(and-area-code);
+			Playback(before-the-number);
+			Hangup;
+		};
+		&dialout(${EXTEN});
+		Congestion(10);
+		Hangup;
+	};
+
+	_NXXXXXX => {
+		NoOp(Stripping last four to see what extension we're dialing);
+		Set(LAST4=${EXTEN:3});
+		StripLSD(4);
+	};
+
+	i => Playback(pbx-invalid);
+	h => Hangup;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from macros.conf
+
+macro dialout( number ) {
+	Realtime(call_info|exten|${CALLERIDNUM:5}|mon_);
+	if ("${mon_monitor}" = "YES") {
+		Dial(SIP/${number}@sgw1.shsu.edu,,wW);
+		Dial(SIP/${number}@sgw2.shsu.edu,,wW);
+	} else {
+		Dial(SIP/${number}@sgw1.shsu.edu);
+		Dial(SIP/${number}@sgw2.shsu.edu);
+	};
+};
+
+// Standard extension macro:
+//  ${ext} - Extension
+macro stdexten( ext ) {
+	Realtime(sipusers|name|${ext}|sip_user_);
+	Realtime(call_info|exten|${ext}|info_);
+	if ("${sip_user_name}foo" = "foo") {
+		Wait(1);
+		&dialout(${ext});
+		Congestion(10);
+		Hangup;
+	};
+	NoOp(${CALLERIDNUM});
+	RealtimeUpdate(call_info|exten|${ext}|calltrace|${CALLERIDNUM});
+	System(/usr/local/bin/db_update.sh call_info calltrace ${CALLERIDNUM} exten ${ext} &);
+	&checkdnd(${ext});
+	&checkcf(${ext});
+	Realtime(call_info|exten|${CALLERIDNUM:5}|mon_);
+	if ("${mon_monitor}" = "YES") {
+		Dial(SIP/${info_forwardto},25,wW);
+	} else {
+		Dial(SIP/${info_forwardto},25);
+	};
+	switch ("${DIALSTATUS}") {
+		case "BUSY":
+			&checkcfb(${ext});
+			break;
+		case "CHANUNAVAIL":
+			Dial(IAX2/asterisk:password at scm2.shsu.edu/${info_forwardto},25,wW);
+			MailboxExists(${ext});
+//			if ("${VMBOXEXISTSSTATUS}" = "FAILED") {
+//				Congestion(10);
+//				Hangup;
+//			};
+			&uvm(${ext});
+			Hangup;
+			break;
+		case "CONGESTION":
+			MailboxExists(${ext});
+			if ("$(VMBOXEXISTSSTATUS}" = "FAILED") {
+				Congestion(10);
+				Hangup;
+			};
+			&bvm(${ext});
+			Hangup;
+			break;
+		default:
+			MailboxExists(${ext});
+			if ("$(VMBOXEXISTSSTATUS}" = "FAILED") {
+				Congestion(10);
+				Hangup;
+			};
+			&uvm(${ext});
+			Hangup;
+	};
+	Hangup;
+};
+
+macro uvm( ext ) {
+	Dial(SIP/u${ext}@svm1.shsu.edu);
+	Playback(im-sorry);
+	Playback(voice-mail-system);
+	Playback(down);
+	Congestion(10);
+	Hangup;
+};
+
+macro bvm( ext ) {
+	Dial(SIP/b${ext}@svm1.shsu.edu);
+	Playback(im-sorry);
+	Playback(voice-mail-system);
+	Playback(down);
+	Congestion(10);
+	Hangup;
+};
+
+macro checkdnd( ext ) {
+	if ("${info_donotdisturb}foo" = "foo") {
+		NoOp(Do Not Disturb is not active);
+	} else
+		&uvm(${ext});
+};
+
+macro checkcf( ext ) {
+	if ("${info_forwardto}foo" = "foo")
+		if ("${ext}" = "43974") {
+			Set(info_forwardto=${ext}&SCCP/${ext});
+		} else {
+			Set(info_forwardto=${ext}&SIP/${ext}w);
+		};
+};
+
+macro checkcfb( ext ) {
+	if ("${info_forwardbusy}foo" = "foo") {
+		Wait(1);
+		MailboxExists(${ext});
+		if ("$(VMBOXEXISTSSTATUS}" = "FAILED") {
+			&dialout(${ext});
+			Hangup;
+		};
+		&bvm(${ext});
+		Hangup;
+	};
+	&stdexten(${info_forwardbusy});
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// Extensions pulled from test.conf
+
+context test-include {
+	includes {
+		test-digium;
+		test-sounds;
+		test-phinfo;
+	};

[... 2689 lines stripped ...]


More information about the asterisk-commits mailing list