#!/usr/annex/perl
# $Modified: Tue Nov 16 14:56:49 1993 by cwilson $
#
# Generate the cu_device_names and cu_system_names from the 
# NIS ktools map.
#
$SYS = "/usr/annex/cu_system_names";
$DEV = "/usr/annex/cu_device_names";

$con = `ypmatch rtelnetd_con ktools`;
$dbg = `ypmatch rtelnetd_dbg ktools`;

open (S, ">$SYS") || die "Unable to open $SYS, $!.\n";
open (D, ">$DEV") || die "Unable to open $DEV, $!.\n";

print D "# Changes to the Engineering Annex CU device configuration\n";
print D "# Automatically generated by kgenerate (probably via rtelnetd)\n";
print D '# on ' . `date` . "\n";

print S "# Changes to the Engineering Annex CU system configuration\n";
print S "# Automatically generated by kgenerate (probably via rtelnetd)\n";
print S '# on ' . `date` . "\n";

foreach (split('`', $con)) {
    ($name, $ports) = /(\w+):(.*)/;
    $x = 0;
    foreach $p (split(',', $ports)) {
	print D "Direct\t\tannex/$name.con.$x\t- Any direct\n";
	print D "$name.con.$x\tannex/$name.con.$x\t- Any direct\n";
	print S "$name.con.$x\tAny $name.con.$x\t9600 unused\n";
	$x++;
    }
}
	
foreach (split('`', $dbg)) {
    ($name, $ports) = /(\w+):(.*)/;
    $x = 0;
    foreach $p (split(',', $ports)) {
	print D "Direct\t\tannex/$name.dbg.$x\t- Any direct\n";
	print D "$name.dbg.$x\tannex/$name.dbg.$x\t- Any direct\n";
	print S "$name.dbg.$x\tAny $name.dbg.$x\t9600 unused\n";
	$x++;
    }
}

