#!/usr/bin/perl

# Created by John L. Chmielewski on Sat May 24, 2008

# this script sends CALL and CALLINFO lines to the server
# The way to test ncid and ncidd
# ./testserver ../ncidd OR ./testserver /usr/sbin/ncidd -N1
# ./TestGWcalls
# ./ncid 3334

($testfile = shift) || ($testfile = "TestGWcalls.data");

open(OUTPUT, '|nc localhost 3334') || die "Could not open netcat\n";
open(TESTFILE, $testfile) || die "Could not open $testfile\n";

print "Connect server to port 3334 for test: ./testserver ../ncid\n\n";
print "Then press <ENTER> multiple times to:\n";
print "    send CALL:     line (Incoming Call)\n";
print "    send CALLINFO: line (Hangup After Answer)\n";
print "    send CALL:     line (Incoming Call)\n";
print "    send CALLINFO: line (Hangup Before Answer)\n";
print "    send CALLINFO: line (Outgoing Call)\n";
print "    end  program\n\n";

select(OUTPUT);
$| = 1;

while (<TESTFILE>) {
    if (/^#/) { next; }
	if (/\w.*/) { print STDOUT; print; }
	else { $response = <STDIN>; }
}

exit 0;
