#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  lookup.pl simstart.pl simupd.pl
# Wrapped by raymond@sunkist.berkeley.edu on Sat Jun  1 23:29:59 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'lookup.pl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lookup.pl'\"
else
echo shar: Extracting \"'lookup.pl'\" \(1842 characters\)
sed "s/^X//" >'lookup.pl' <<'END_OF_FILE'
X#!/usr/custom/bin/perl
X#
X# lookup: Looks up a word/phrase in various archive indexes
X#
X# downward compatible to perl version 2.0.
X#
X# Usage:
X#
X#       lookup perl-expression
X#
X# Configuration:
X#
X#       $limit = limit on amount of output generated
X#       $dir   = directory where the indexes are kept
X#
X# Copyright 1991, Raymond Chen (rjc@math.princeton.edu)
X# Distribution unrestricted, so long as you keep my name on it.
X
X$dir = "c:/news/csip";
X
Xdie "usage: $0 word" if $#ARGV < $[;
X
Xif (1 != eval "sub match { $ARGV[0]; }1;")
X    { print "Malformed search criterion\n"; exit 1; }
X
X$limit = 400;                   # don't output more than this
X$count = 0;                     # number of entries output so far
X$marker = "\001";               # nonprintable inserted by simupd.pl
X
Xdo do_lookup("$dir/simibm.idx", "wsmr-SIMTEL20.army.mil");
X#do do_lookup("$dir/grape", "grape.ecs.clarkson.edu");
X#do do_lookup("$dir/garbo", "garbo.uwasa.fi");
X#do do_lookup("$dir/mm", "FidoNet node 2:515/1 (Micro Maniacs Opus)");
X
Xsub do_lookup {
X    local($archive, $sitename) = @_;
X
X    open(in, "<".$archive) ||
X    open(in, "zcat $archive |") ||
X    (print "Couldn't open $archive\n", return 0);
X
X    $dir = $prevdir = "";
X
X    print "\nPrograms on $sitename matching your search criterion:\n\n";
X
X    while (<in>) {
X        if (/^~$/) {
X            $dir = <in>;
X            $_ = <in>; $_ = <in>; # skip two header lines
X        }
X        if (do match()) {
X            print $dir if $dir ne $prevdir;
X            $prevdir = $dir;
X            s/^$marker//o;
X            print;
X            do linecount();
X        }
X    }
X    close(in);
X}
X
Xsub linecount {
X    if ($count++ > $limit) {
X        print "... Output truncated due to excessive length.\n" .
X              "    Try a more restrictive search string.\n";
X        close(in);
X        exit 0;
X    }
X}
END_OF_FILE
if test 1842 -ne `wc -c <'lookup.pl'`; then
    echo shar: \"'lookup.pl'\" unpacked with wrong size!
fi
# end of 'lookup.pl'
fi
if test -f 'simstart.pl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'simstart.pl'\"
else
echo shar: Extracting \"'simstart.pl'\" \(915 characters\)
sed "s/^X//" >'simstart.pl' <<'END_OF_FILE'
X#!/usr/bin/perl
X#
X# simstart.pl
X#
X# Converts simibm.raw into a form that simtel.update and lookup can use.
X#
Xformat stdout =
X@<<<<<<<<<<<< @<<@>>>>>  @<<<<<  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
X$file,       $at,$size,  $date,  $comment
X.
X
X$simfile = "simibm.raw";
X
X$= = 0;				# No automatic page breaks
X
Xopen(in, $simfile);		# Open simibm.raw
Xwhile (<in>)			# Read one line
X{
X        ($dev,$dir,$file,$size,$type,$date,$comment) = 
X		/^"(.*)","(.*)","(.*)",.*,(.*),(.),(.*),"(.*)"/;
X	$at = ($type == 8) ? "B" : "A";
X        if ( $ldev ne $dev || $ldir ne $dir ) {		# New page
X               print "~\nDirectory $dev$dir\n";
X               print "Filename    Type Length  Date    Description\n";
X               print "===============================================================================\n";
X        }
X        write;		# Write the line
X        $ldev = $dev;
X        $ldir = $dir;
X}
X
Xprint "~\n";
END_OF_FILE
if test 915 -ne `wc -c <'simstart.pl'`; then
    echo shar: \"'simstart.pl'\" unpacked with wrong size!
fi
chmod +x 'simstart.pl'
# end of 'simstart.pl'
fi
if test -f 'simupd.pl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'simupd.pl'\"
else
echo shar: Extracting \"'simupd.pl'\" \(3769 characters\)
sed "s/^X//" >'simupd.pl' <<'END_OF_FILE'
X#!/usr/custom/bin/perl -s
X#
X# upd2.pl: Updates the master file from Raymond Chen's Monthly Postings
X#
X# Switches:
X#   -m = mark new files with Ctrl-A
X#   -n = don't compress the output
X#
X# Configuration:
X#
X#       $dir   = directory where the indexes are kept
X#
X# Copyright 1991, Raymond Chen (rjc@math.princeton.edu)
X# Distribution unrestricted, so long as you keep my name on it.
X
X$directory_count = $undeleted = $unadded = $deleted = $added = 0;
X
X# if UNIX:
X#   $HOME = $ENV{"HOME"};
X#   $dir = "$HOME/index";
X#
X# if MSDOS:
X$dir = "C:/news/csip";
X$n = 1;                 # don't compress in MS-DOS
X
X$simibm = "$dir/simibm.idx";
X$simnew = ">$dir/simibm.new";
X
X$|=1;
X
Xunless (open(in, "<".$simibm)) {
X    $simnew = "| compress $simnew.Z" unless $n;
X    open(in, "zcat $simibm |") || die "Couldn't open $simibm";
X}
X
Xopen(out, $simnew) || "Couldn't open $simnew";
X
X# Plan of attack:
X#
X# Start in state "skipping".
X#
X# Skipping:  Read from <> until /^ Directory/.  Save the directory name
X#            and call "find_directory".  Then switch to state "matching".
X#
X# Matching:  Read a filename from <>.
X#            If a header, then ignore it and stay in Matching mode.
X#            If the 15th character is not A or B, switch to Skipping.
X#            Otherwise call "find_match" to insert the guy.
X
X$added = $unchanged = $directory_count = 0;
X$skipping = 1;
X$prevline = <in>;	# our peek-ahead buffer.
X
Xwhile ($skipping > 0) {
X  $skipping = do skip() if ($skipping == 1);
X  $skipping = do match() if ($skipping == 2);
X}
X
X# skip:  Skip to a new directory.
Xsub skip {
X  while (<>) {
X    next unless /^ Directory/;
X    s/^ Directory.*(PD\d?:)/Directory $1/;
X    $dirname = $_;
X    return 2 * do find_directory();
X  }
X  # if we get here, we've hit EOF.
X  return 0;
X}
X
X# find_directory:  Find the directory in $dirname, 
X# outputting the gunk we skipped over to get there.
X
Xsub find_directory {
X  chop($_ = $dirname);
X  print "\n$_" if !$q;# tell the user we're looking for a directory
X  print out $prevline;  # output the tilde.
X  while (<in>) {
X    print out;          # display the next line in the file.
X    next if ($_ ne $dirname); # blip past stuff we don't want.
X
X    print out $_ = <in>;        # blip the header
X    print out $_ = <in>;        # blip the divider
X    $prevline = <in>;
X    $directory_count++;
X    return 1;           # keep going
X  }
X  # if we get here, we've hit EOF.  So complain.
X  print stderr "Couldn't find directory $dirname";
X  $prevline = "";
X  return 0;
X}
X
Xsub match {
X  return 0 unless ($file = <>);
X  ($tag, $file) = split(//, $file, 2);
X  return 2 if $file =~ /^(Filename|==)/;
X  return 1 if substr($file,14,1) !~ /[AB]/; # first character is number zero
X  return 2 * do find_match();
X}
X
X# find-match:  Filename to match is in $file.
X
Xsub find_match {
X  while ($prevline lt $file) {  # while haven't found the right place
X    print out $prevline;        # dump the previous line
X    return 0 unless $prevline = <in>; # get the next line
X  }
X  if ($prevline eq $file) {
X    if ($tag eq "-") {
X      $prevline = ""; # delete it
X      ++$deleted;
X      print "-" if !$q;
X    } else {
X      print "." if !$q;
X      ++$unadded;
X    }
X    return 1; 
X  } else {
X    if ($tag eq "+") {
X      print out $file;              # insert the new guy
X      print "+" if !$q;             # let user know
X      ++$added;                     # bump the count.
X    } else {
X      print ":" if !$q;
X      ++$undeleted;
X    }
X  }
X  return 1;
X}
X
X# cleanup
X
X
Xprint   "\n",
X        "$directory_count directories, ",
X        "$undeleted not deleted, ",
X        "$unadded not added, ",
X        "$deleted deleted, ",
X        "$added added.\n" if !$q;
X
Xprint out $prevline;
Xprint out <in>;
Xclose(in);
X
X$? = 0; close(out);
X
Xdie "Error writing output ($!)\n" if $?;
END_OF_FILE
if test 3769 -ne `wc -c <'simupd.pl'`; then
    echo shar: \"'simupd.pl'\" unpacked with wrong size!
fi
# end of 'simupd.pl'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0


