[comp.lang.perl] Anonymous Contact Service Software Posted

csu@alembic.acs.com (Dave Mack) (07/08/90)

Immediately following this article, I will post the ACS software to
alt.sources. It will be in three parts. The source is in a uuencoded,
compressed tar file. This annpouncement has been crossposted to comp.lang.perl
because most of the ACS code is written in Perl and may be of interest
to Perl hackers, but the source itself will only be posted to alt.sources.

This distribution also includes the complete source for smail2.5,
because I had to make a minor modification to it to get things to
work properly. You can build a completely vanilla smail2.5 using the
instructions and Makefile in the "mailer" subdirectory. Building the
ACS version is automatic when you invoke the Makefile in the ACS
toplevel directory, or when you use "make -f Makefile.acs install" in
the "mailer" subdirectory.

To assist in unpacking this distribution, I'm enclosing a Perl script
I wrote called uumerge, which will take a split uuencoded file, strip
headers and trailers off, and uudecode the concatenated chunks.
Simply save the ACS software articles in files (acs.part[1-3], for
example), then say "uumerge acs.part*". Make sure that the pieces
on the command line are in the right order. This should result in
the production of a file called "acs1.0.tar.Z", which you should be
able to uncompress and untar. Please do the latter in a new directory,
as the tar file doesn't provide an acs toplevel directory.

--------------------------uumerge: cut here --------------------------------
#! /usr/local/bin/perl
#
# Combine split uuencoded files into a single data stream with
# e-mail garbage removed and pipe into uudecode. The uuencoded
# files must be in the correct order on the command line - in
# particular the first file must contain the "begin" line and
# the last file must contain the "end" line.
#
# WARNING: this code relies on uuencode putting out all lines
# of the form "M[61 ASCII characters]\n" for every line of the
# file except the last few before the "end" line. If you come
# across a uuencoded file that doesn't do this, you'll need to
# modify the code to handle it.
#
# DISCLAIMER: You use this code at your own risk. Also, don't
# take this is as a sterling example of Perl programming. Corrections
# and improvements welcome. You may do whatever you like with this
# code as long as you leave in some reminder of who the original
# culprit^H^H^H^H^H^H^Hauthor was.
#
# Usage: uumerge filename [filename...]
# Requires Perl 3.0 - my copy is at patchlevel 18
#
# Dave Mack csu@alembic.ACS.COM
#
# TODO: modify to allow more than one collection of files on
#	command line.
#
# KNOWN BUGS: 
#
# If some bozo puts a line beginning with "M" in the body of one
# of the intermediate/last chunks, uumerge will assume that uuencoded
# part starts there.
#
# If the last chunk only contains the last two or three lines of
# the uuencoded file (the ones that don't start with "M"), uumerge
# will die.
#
# CHANGES
#
# PATCH 1:
# It appears that some versions of uudecode are too stupid to skip
# past the lines preceding the "begin" line, so feeding a one-part
# uuencoded file to uumerge will bomb.
#
if ($#ARGV < 0 ) {
	print "Usage: uumerge filename [filename...]\n";
	exit 1;
}

$| = 1;
# open a pipe into uudecode
open(DECO,"|uudecode") || die "Can't pipe into uudecode\n";

# if we only have one file, pump it straight into uudecode and die
if ( $#ARGV == 0 ) {
	open(FIRST,"<$ARGV[0]") || die "Can't open $ARGV[0] for input\n";

	while ( <FIRST> ) {
		# skip past everything before the "begin" line
		next unless /^begin [0-9]/;
		last;
	}
	die "$ARGV[0] doesn't contain \"begin\"\n" if eof(FIRST);
	
	print DECO $_; # the begin line

	while ( <FIRST> ) {
		print DECO $_ unless /^end/;
		if ( /^end/ ) {
			print DECO $_;
			last;
		}
		die "$ARGV[0] doesn't contain \"end\"\n" if eof(FIRST);
	}

	# done with file
	close(FIRST);
	exit 0;
}

# process the first file - make sure we have a "begin" line

open(FIRST,"<$ARGV[0]") || die "Can't open $ARGV[0] for input\n";

while ( <FIRST> ) {
	# skip past everything before the "begin" line
	next unless /^begin [0-9]/;
	last;
}
die "First file on command line doesn't contain \"begin\"\n" if eof(FIRST);
	
print DECO $_; # the begin line

# the remaining "real" uuencoded lines in this file should begin with "M"
while ( <FIRST> ) {
	if ( /^M/ ) {
		print DECO $_;
	}
	else {
		last;
	}
}

# done with the first file
close(FIRST);

# do all except the last file
$maxindex = $#ARGV;
$curr = 1;

while ( $curr < $maxindex ) {
	open(CURR,"<$ARGV[$curr]") || die "Can't open $ARGV[$curr]\n";
	# skip the header junk
	while ( <CURR> ) {
		next unless /^$/;
		last;
	}
	# at the body of the message - start looking for /^M/
	while ( <CURR> ) {
		next unless /^M/;
		last;
	}
	die "$ARGV[$curr] isn't a uuencoded file\n" if eof(CURR);
	# OK, we're at the start of the good stuff (probably)
	print DECO $_;
	while ( <CURR> ) {
		if (/^M/) {
			print DECO $_;
		}
		else {
			last;
		}
	}
	# done with current file
	close(CURR);
	$curr++;
}

# time to do the last file in the set
$curr = $maxindex;
open(CURR,"<$ARGV[$curr]") || die "Can't open $ARGV[$curr]\n";
# skip the header junk
while ( <CURR> ) {
	next unless /^$/;
	last;
}
# at the body of the message - start looking for /^M/
while ( <CURR> ) {
	next unless /^M/;
	last;
}
# OK, we're at the start of the good stuff (probably)
print DECO $_;
while ( <CURR> ) {
	print DECO $_ unless /^end/;
	if ( /^end/ ) {
		print DECO $_;
		last;
	}
	die "Last file on command line doesn't contain \"end\"\n" if eof(CURR);
}
# done with final file
close(CURR);
# close the pipe to uudecode and exit
close(DECO);
exit(0);

eckert@medusa.informatik.uni-erlangen.de (Toerless Eckert) (07/13/90)

csu@alembic.acs.com (Dave Mack):
> Immediately following this article, I will post the ACS software to
> alt.sources. It will be in three parts. The source is in a uuencoded,
> compressed tar file. This annpouncement has been crossposted to comp.lang.perl
> because most of the ACS code is written in Perl and may be of interest
> to Perl hackers, but the source itself will only be posted to alt.sources.

This is a flame:

I've never heart of ACS, and neither your article nor the following
three parts of the sources contain any explanation as to what this software is,
until you unpack the whole stuff.

Why can't you people never learn that there are humans out there who
don't know your program, but would like to before deciding wether to
unpack the program or not. 

So please: At the start of the first file of a sources contribution:
"What is this stuff:....."

Thanks.
-- 

Toerless Eckert          | /C=de/A=dbp/P=uni-erlangen/OU=informatik/S=eckert
V.4: Noah's ark of Unix  | X.400 ^ Internet> eckert@informatik.uni-erlangen.de