| 61 print STDERR "FAIL (unexpected result '$res')\n"; |
61 print STDERR "FAIL (unexpected result '$res')\n"; |
| 62 exit(1); |
62 exit(1); |
| 63 } |
63 } |
| 64 } |
64 } |
| 65 |
65 |
| 66 |
66 ############ send_file #### |
| 67 ############ send_file ############# |
67 # Use this to send a wave # |
| 68 # Use this to send a wave file on # |
68 # file on the channel # |
| 69 # the channel # |
69 ########################### |
| 70 # # |
|
| 71 #################################### |
|
| 72 sub send_file { |
70 sub send_file { |
| 73 my ($myfile) = @_; |
71 my ($myfile) = @_; |
| 74 chomp($myfile); |
72 chomp($myfile); |
| 75 if ($DEBUG == 1 ) { |
73 if ($DEBUG == 1 ) { |
| 76 print DEBUGOUT "Sending stream $myfile \n"; |
74 print DEBUGOUT "Sending stream $myfile \n"; |
| 81 $result =~ /result=(-?\d+)/; |
79 $result =~ /result=(-?\d+)/; |
| 82 return $1; |
80 return $1; |
| 83 } |
81 } |
| 84 |
82 |
| 85 ############ hangup ############### |
83 ############ hangup ############### |
| 86 # Use this to hand up a channel # |
84 # Use this to hang up a channel # |
| 87 # the channel # |
|
| 88 # # |
|
| 89 #################################### |
85 #################################### |
| 90 sub hangup { |
86 sub hangup { |
| 91 if ($DEBUG == 1 ) { |
87 if ($DEBUG == 1 ) { |
| 92 print DEBUGOUT "Hanging up \n"; |
88 print DEBUGOUT "Hanging up \n"; |
| 93 } |
89 } |
| 112 &checkresult($result); |
108 &checkresult($result); |
| 113 $result =~ /result=(-?\d+)/; |
109 $result =~ /result=(-?\d+)/; |
| 114 return $1; |
110 return $1; |
| 115 } |
111 } |
| 116 |
112 |
| 117 ############ say_digits ############ |
113 ############ say_digits ################### |
| 118 # Use this to say a digits # |
114 # Use this to say digits over the channel # |
| 119 # over the channel # |
115 ########################################### |
| 120 # # |
|
| 121 #################################### |
|
| 122 sub say_digits { |
116 sub say_digits { |
| 123 my ($mynumber) = @_; |
117 my ($mynumber) = @_; |
| 124 chomp($mynumber); |
118 chomp($mynumber); |
| 125 if ($DEBUG == 1 ) { |
119 if ($DEBUG == 1 ) { |
| 126 print DEBUGOUT "Saying digits $mynumber \n"; |
120 print DEBUGOUT "Saying digits $mynumber \n"; |
| 128 print "SAY DIGITS $mynumber \"0123456789\"\n"; |
122 print "SAY DIGITS $mynumber \"0123456789\"\n"; |
| 129 my $result = <STDIN>; |
123 my $result = <STDIN>; |
| 130 &checkresult($result); |
124 &checkresult($result); |
| 131 } |
125 } |
| 132 |
126 |
| 133 ############ get_choice ############ |
127 ######## get_choice ############ |
| 134 # Use this to receive a DTMF # |
128 # Use this to receive a DTMF # |
| 135 # choice from the channel # |
129 # choice from the channel # |
| 136 # # |
130 ################################ |
| 137 #################################### |
|
| 138 sub get_choice { |
131 sub get_choice { |
| 139 if ($DEBUG == 1 ) { |
132 if ($DEBUG == 1 ) { |
| 140 print DEBUGOUT "Getting choice \n"; |
133 print DEBUGOUT "Getting choice \n"; |
| 141 } |
134 } |
| 142 print "WAIT FOR DIGIT 15000\n"; |
135 print "WAIT FOR DIGIT 15000\n"; |
| 144 &checkresult($result); |
137 &checkresult($result); |
| 145 $result =~ /result=(-?\d+)/; |
138 $result =~ /result=(-?\d+)/; |
| 146 return $1; |
139 return $1; |
| 147 } |
140 } |
| 148 |
141 |
| 149 ############ answer ############### |
142 ###### answer ###### |
| 150 # Anser the channel # |
143 # Anser the channel # |
| 151 # # |
144 ##################### |
| 152 #################################### |
|
| 153 sub answer { |
145 sub answer { |
| 154 if ($DEBUG == 1 ) { |
146 if ($DEBUG == 1 ) { |
| 155 print DEBUGOUT "Answering the channel \n"; |
147 print DEBUGOUT "Answering the channel \n"; |
| 156 } |
148 } |
| 157 print "ANSWER\n"; |
149 print "ANSWER\n"; |
| 237 return "FAIL"; |
229 return "FAIL"; |
| 238 } |
230 } |
| 239 my $myext = $aig[1]; |
231 my $myext = $aig[1]; |
| 240 return $myext; |
232 return $myext; |
| 241 } |
233 } |
| 242 ########### init_agi ############### |
234 |
| 243 # Use this to initialize the AGI # |
235 ############### init_agi ################## |
| 244 # variable # |
236 # Use this to initialize the AGI variable # |
| 245 # # |
237 ########################################### |
| 246 #################################### |
|
| 247 sub init_agi { |
238 sub init_agi { |
| 248 while(<STDIN>) { |
239 while(<STDIN>) { |
| 249 chomp; |
240 chomp; |
| 250 last unless length($_); |
241 last unless length($_); |
| 251 if (/^agi_(\w+)\:\s+(.*)$/) { |
242 if (/^agi_(\w+)\:\s+(.*)$/) { |
| 252 $AGI{$1} = $2; |
243 $AGI{$1} = $2; |
| 253 } |
244 } |
| 254 } |
245 } |
| 255 } |
246 } |
| 256 |
247 |
| 257 ############ ascii2num ############# |
248 ######### ascii2num ########## |
| 258 # Removes 48 to get a number out # |
249 # Removes 48 to get a number # |
| 259 # of the asciss return # |
250 # out of the asciss return # |
| 260 #################################### |
251 ############################## |
| 261 sub ascii2num { |
252 sub ascii2num { |
| 262 my ($asc) = @_; |
253 my ($asc) = @_; |
| 263 my $ret; |
254 my $ret; |
| 264 $ret = $asc - 48; |
255 $ret = $asc - 48; |
| 265 return $ret; |
256 return $ret; |
| 266 } |
257 } |
| 267 |
258 |
| 268 |
259 ############# Welcome ############## |
| 269 ########### Welcome ############### |
|
| 270 # This is the welcome menu # |
260 # This is the welcome menu # |
| 271 # # |
|
| 272 #################################### |
261 #################################### |
| 273 sub welcome { |
262 sub welcome { |
| 274 my $ret = 0; |
263 my $ret = 0; |
| 275 $ret = &send_file("welcome"); |
264 $ret = &send_file("welcome"); |
| 276 if ($ret == 0) { |
265 if ($ret == 0) { |
| 306 ######### manage_calls ############# |
295 ######### manage_calls ############# |
| 307 # This is what is called if you # |
296 # This is what is called if you # |
| 308 # want to manage already scheduled # |
297 # want to manage already scheduled # |
| 309 # wakeup calls # |
298 # wakeup calls # |
| 310 #################################### |
299 #################################### |
| 311 |
|
| 312 sub manage_calls { |
300 sub manage_calls { |
| 313 my $checker = "false"; |
301 my $checker = "false"; |
| 314 my @calls; |
302 my @calls; |
| 315 my $del; |
303 my $del; |
| 316 #my $ret; |
304 #my $ret; |
| 369 $del = &send_file("cancelled"); |
357 $del = &send_file("cancelled"); |
| 370 } |
358 } |
| 371 } |
359 } |
| 372 $del = &send_file("goodbye"); |
360 $del = &send_file("goodbye"); |
| 373 } |
361 } |
| 374 |
362 } |
| 375 } |
363 |
| 376 |
364 ######## schedule_new ########## |
| 377 ######## schedule_new ############## |
365 # This is the menu to schedule # |
| 378 # This is the menu to schedule a # |
366 # a new wakeup call # |
| 379 # a new wakeup call # |
367 ################################ |
| 380 #################################### |
|
| 381 sub schedule_new { |
368 sub schedule_new { |
| 382 my $checker = "false"; |
369 my $checker = "false"; |
| 383 my $ret_var; |
370 my $ret_var; |
| 384 my $ret_dummy = 0; |
371 my $ret_dummy = 0; |
| 385 my $time; |
372 my $time; |
| 491 return $ret_var; |
478 return $ret_var; |
| 492 } |
479 } |
| 493 |
480 |
| 494 ######## get_time_string ########### |
481 ######## get_time_string ########### |
| 495 # This will return the time string # |
482 # This will return the time string # |
| 496 # when inputing a string like # |
483 # when inputing a string like hhmi # |
| 497 # hhmi # |
|
| 498 #################################### |
484 #################################### |
| 499 sub get_time_string { |
485 sub get_time_string { |
| 500 my ($intime) = @_; |
486 my ($intime) = @_; |
| 501 my $minutes = substr($intime, 2, 4); |
487 my $minutes = substr($intime, 2, 4); |
| 502 my $hours = substr($intime, 0, 2); |
488 my $hours = substr($intime, 0, 2); |
| 536 } |
522 } |
| 537 $ret_val = $month . $day . $hours . $minutes; |
523 $ret_val = $month . $day . $hours . $minutes; |
| 538 return $ret_val; |
524 return $ret_val; |
| 539 } |
525 } |
| 540 |
526 |
| 541 ############ new_time ############## |
527 ############ new_time ################ |
| 542 # This will return the time string # |
528 # This will return the time string # |
| 543 # with a time set 10 minute into # |
529 # with a time set 10 minute into # |
| 544 # the future # |
530 # the future. The string is MMDDhhmi # |
| 545 # The string is # |
531 ###################################### |
| 546 # MMDDhhmi # |
|
| 547 #################################### |
|
| 548 sub new_time { |
532 sub new_time { |
| 549 my ($input) = @_; |
533 my ($input) = @_; |
| 550 my @timedata; |
534 my @timedata; |
| 551 my $minutes; |
535 my $minutes; |
| 552 my $hours; |
536 my $hours; |
| 692 |
676 |
| 693 # Stream out the wakeup |
677 # Stream out the wakeup |
| 694 return 0; |
678 return 0; |
| 695 } |
679 } |
| 696 |
680 |
| 697 ########### main program ########### |
681 ######## main program ######## |
| 698 # Here goes the main program # |
682 # Here goes the main program # |
| 699 # # |
683 ############################## |
| 700 #################################### |
|
| 701 |
|
| 702 my $numargs = $#ARGV + 1; |
684 my $numargs = $#ARGV + 1; |
| 703 if ($DEBUG == 1) { |
685 if ($DEBUG == 1) { |
| 704 open (DEBUGOUT, '>', $debugfile) or die "Cannot open $debugfile for write :$!"; |
686 open (DEBUGOUT, '>', $debugfile) or die "Cannot open $debugfile for write :$!"; |
| 705 } |
687 } |
| 706 |
688 |