#!/usr/local/bin/perl/perl
&init_socket;
# machine and port for the familyd generate server
$server = "cae016.ed.ray.com";
$server_port = 4000;
# username of person to receive error mail
$maintainer = "gmm7689@sudcv91.ed.ray.com";
MAIN: while(1) {
system("clear");
# get the partname to look for
print "Check on a Family of Parts Member\n".
"\n".
"Enter name of CADDS Family of Parts Member to look for\n".
"or q to quit: ";
chop($partname = <STDIN>);
exit if($partname =~ /^q/i);
# exit if no characters were entered.
#($partname =~ /^$/) && next MAIN;
$family_file = "/usr2/std/fpts/family-list";
# open the list of Families of Parts. Only families which are listed in this
# file will be available for searching
open(FAMILIES, $family_file) || print "\nUnable to open family list.\n\n"
&& next MAIN;
# pull the family name out of the part
unless(($family, $member) = ($partname =~ /(.*)-family.(.*)/))
{
print "\n".
"Invalid Family of Parts Member Name.\n".
"\n";
next MAIN;
}
$found_a_match = 0;
# find the right family
while(<FAMILIES>)
{
# remove the trailing newline
chop;
# deal with continuation lines
while (s/\\$//) { $_ .= <FAMILIES>; }
# split lines into its parts
($directory, $partname) = split(':');
# check the partname for a match
if($partname eq $family)
{
$found_a_match = 1;
last;
}
}
# done with this file
close(FAMILIES);
# if no matches were found, exit the search
if($found_a_match != 1)
{
print "\n".
"There is no family named $family in the catalog.\n".
"\n";
next MAIN;
}
# see if this is a valid member
if(`grep -c -i "^$member " $directory/_tbl` == 0)
{
print "\n".
"There is no member named $member in the family $family.\n".
"\n";
next MAIN;
}
$filename = $directory . "-family/" . $member . "/_pd";
$filename =~ s/(.*)/\L\1\E/;
# if the part doesn't exist, ask if it should be generated
unless(-e $filename)
{
print "\n".
"Member $member has not been generated.\n".
"Do you want it to generate it (y/n)? ";
if(<STDIN> =~ /^y/)
{
&generate_part($partname, $member, $directory);
}
}
else
{
print "\n".
"This part has been generated.\n".
"\n";
$member =~ s/(.*)/\L\1\E/;
print "To activate the part, use the command\n".
"activate part ${partname}-family.$member\n".
"\n";
}
} #end MAIN
continue
{
print "Press Return to continue.";
<>;
}
sub generate_part {
local ($partname, $member, $directory) = @_;
print "Part generation in progress, please wait.";
# networking setup
chop($hostname = `hostname`);
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $type, $len, $thataddr) = gethostbyname($server);
$sockaddr = 'S n a4 x8';
$thatport = pack($sockaddr, &AF_INET, $server_port, $thataddr);
print ".";
socket(S, &PF_INET, &SOCK_STREAM, $proto) ||
&form_die("Unable to create socket.");
print ".";
connect(S, $thatport) ||
print("Can not connect to server $server.") && return;
print ".";
select(S); $| = 1; select(STDOUT);
# end networking setup
# send part information
print S "$partname $member $directory\n";
print ".";
# get result code
$_ = <S>;
print "\n";
# determine proper response based on result code
if($_ == 0)
{
# generate succeeded
print "Member $member was generated successfully.\n";
# make the member name lowercase for the activate part command
$member =~ s/(.*)/\L$1\E/;
# give command to activate the part
print "To activate the part, use the command\n".
"activate part $partname-family.$member\n";
}
elsif ($_ == 2)
{
# part may exist
print "Unable to generate member $member because the part's directory\n".
"already exists. The part may already have been generated.\n".
"You will be contacted when the problem has been corrected.\n";
# so the maintainer knows who was generating the part...
system("echo $partname-family.$member failed | ".
"/usr/ucb/mail -s check_family_part_failure $maintainer");
# make the member name lowercase for the activate part command
$member =~ s/(.*)/\L$1\E/;
# give command to activate the part
print "You may also try to activate the part using the command\n".
"activate part ${partname}-family.$member\n";
}
else
{
# so the maintainer knows who was generating the part...
system("echo $partname-family.$member failed | ".
"/usr/ucb/mail -s check_family_part_failure $maintainer");
# generate failed
print "Member $member failed to generate.\n".
"You will be contacted when the problem has been corrected.\n";
}
}
sub init_socket {
#included sys/socket.ph so it doesn't have to be require'd
if (!defined &_sys_socket_h) {
eval 'sub _sys_socket_h {1;}';
eval 'sub SOCK_STREAM {1;}';
eval 'sub SOCK_DGRAM {2;}';
eval 'sub SOCK_RAW {3;}';
eval 'sub SOCK_RDM {4;}';
eval 'sub SOCK_SEQPACKET {5;}';
eval 'sub SO_DEBUG {0x0001;}';
eval 'sub SO_ACCEPTCONN {0x0002;}';
eval 'sub SO_REUSEADDR {0x0004;}';
eval 'sub SO_KEEPALIVE {0x0008;}';
eval 'sub SO_DONTROUTE {0x0010;}';
eval 'sub SO_BROADCAST {0x0020;}';
eval 'sub SO_USELOOPBACK {0x0040;}';
eval 'sub SO_LINGER {0x0080;}';
eval 'sub SO_OOBINLINE {0x0100;}';
eval 'sub SO_DONTLINGER {(~ &SO_LINGER);}';
eval 'sub SO_SNDBUF {0x1001;}';
eval 'sub SO_RCVBUF {0x1002;}';
eval 'sub SO_SNDLOWAT {0x1003;}';
eval 'sub SO_RCVLOWAT {0x1004;}';
eval 'sub SO_SNDTIMEO {0x1005;}';
eval 'sub SO_RCVTIMEO {0x1006;}';
eval 'sub SO_ERROR {0x1007;}';
eval 'sub SO_TYPE {0x1008;}';
eval 'sub SOL_SOCKET {0xffff;}';
eval 'sub AF_UNSPEC {0;}';
eval 'sub AF_UNIX {1;}';
eval 'sub AF_INET {2;}';
eval 'sub AF_IMPLINK {3;}';
eval 'sub AF_PUP {4;}';
eval 'sub AF_CHAOS {5;}';
eval 'sub AF_NS {6;}';
eval 'sub AF_NBS {7;}';
eval 'sub AF_ECMA {8;}';
eval 'sub AF_DATAKIT {9;}';
eval 'sub AF_CCITT {10;}';
eval 'sub AF_SNA {11;}';
eval 'sub AF_DECnet {12;}';
eval 'sub AF_DLI {13;}';
eval 'sub AF_LAT {14;}';
eval 'sub AF_HYLINK {15;}';
eval 'sub AF_APPLETALK {16;}';
eval 'sub AF_NIT {17;}';
eval 'sub AF_802 {18;}';
eval 'sub AF_OSI {19;}';
eval 'sub AF_X25 {20;}';
eval 'sub AF_OSINET {21;}';
eval 'sub AF_GOSIP {22;}';
eval 'sub AF_MAX {21;}';
eval 'sub PF_UNSPEC { &AF_UNSPEC;}';
eval 'sub PF_UNIX { &AF_UNIX;}';
eval 'sub PF_INET { &AF_INET;}';
eval 'sub PF_IMPLINK { &AF_IMPLINK;}';
eval 'sub PF_PUP { &AF_PUP;}';
eval 'sub PF_CHAOS { &AF_CHAOS;}';
eval 'sub PF_NS { &AF_NS;}';
eval 'sub PF_NBS { &AF_NBS;}';
eval 'sub PF_ECMA { &AF_ECMA;}';
eval 'sub PF_DATAKIT { &AF_DATAKIT;}';
eval 'sub PF_CCITT { &AF_CCITT;}';
eval 'sub PF_SNA { &AF_SNA;}';
eval 'sub PF_DECnet { &AF_DECnet;}';
eval 'sub PF_DLI { &AF_DLI;}';
eval 'sub PF_LAT { &AF_LAT;}';
eval 'sub PF_HYLINK { &AF_HYLINK;}';
eval 'sub PF_APPLETALK { &AF_APPLETALK;}';
eval 'sub PF_NIT { &AF_NIT;}';
eval 'sub PF_802 { &AF_802;}';
eval 'sub PF_OSI { &AF_OSI;}';
eval 'sub PF_X25 { &AF_X25;}';
eval 'sub PF_OSINET { &AF_OSINET;}';
eval 'sub PF_GOSIP { &AF_GOSIP;}';
eval 'sub PF_MAX { &AF_MAX;}';
eval 'sub SOMAXCONN {5;}';
eval 'sub MSG_OOB {0x1;}';
eval 'sub MSG_PEEK {0x2;}';
eval 'sub MSG_DONTROUTE {0x4;}';
eval 'sub MSG_MAXIOVLEN {16;}';
}}
Last Modified: Wed Aug 28 14:41:29 EDT 1996
Gregory Marr <gregm@alum.wpi.edu>