[comp.sys.apple] Unpacking stuff

c60c-3aw@widow.berkeley.edu (Andy McFadden) (12/12/88)

I've had a lot of people ask me about how to unpack stuff, MicroEMACS in
particular.  Here's the general idea (hopefully 5000 people won't post the
same thing...)

The biggest problem with posting binaries is that mailers throw spasms when
they get a lot of non-ascii characters (hi-bit set; please no debates on
what is or isn't ascii, okay?)  This suggests that binary data should be
converted to ascii data; the obvious way to do this is to print the file in
its hexadecimal representation (i.e., the byte $8D becomes two bytes, the
character "8" and the character "D").

It would also be nice if the files would unpack themselves.  Glen Bredon's
"executioner" program creates such files, which are unpacked by issuing
the "EXEC" command from DOS 3.3 or BASIC.SYSTEM under ProDOS.

There are a couple of problems with this scheme, namely that UNIX systems
terminate lines with linefeeds instead of carraige returns, and mailers/
newsgroups/posters put a lot of stuff at the beginning and the end.  A
brief UNIX shell script (included at the end of this posting) strips the
headers and footers, and translates the linefeeds to carriage returns.

Since it would be rather annoying to have to upload many files separately,
and you want postings to be as small as possible, a program called BLU
(Binary II Library Utility) is used to compress the files and combine them
into a single file (terminated with .BNY or .BQY).  While there are many
programs which can extract from Binary II files, most don't uncompress them,
so having a copy of BLU is almost a necessity.

You can get BLU just about anywhere; try the Apple2-L server, anonymous FTP
via husc6.harvard.edu or another site, a local BBS or users group, etc.  I
believe that it will only run on a //c, enhanced //e, or //gs, but there is
a program called ALU which should also work.  Note that you can get the
compression/uncompression programs separately; they are called "SQ3" and
"USQ2".

Thus, for most programs, you would:
1) Strip the garbage and translate the linefeeds from the files.
2) Download them to your computer.
3) Type "EXEC <filename>" on the files.  You should now have a binary file.
4) In most cases, you would then run BLU and use the E)xtract from Binary II
   files option.  At this stage you should have all of the stuff you need.

Special instructions from MicroEMACS:

You need to download the 5 MicroEMACS articles and the 3 MicroEMACS Docs
articles to your computer (would probably be wise to start a new disk...)
You will also need the MicroEMACS intro file; it contained a short BASIC
program which you will need.

Note that "stripexec" isn't going to work for the BASIC program; you should
extract that one yourself (or just print it out and type it in... it's not
very complicated).  This brings up an interesting point: some programs have
the BASIC lines at the end of the last file.  If you use stripexec on this
file you will strip the lines from the file, and it won't work right.

You should follow the steps above, but after executing all of the text files,
you should run the BASIC program.  This combines the 8 segments into two
large ones, which you should then process with BLU.

This should leave you with a whole bunch of files.  To start up MicroEMACS,
you should execute it from a ProDOS 16 command shell (like APW, ECP, etc).
If you don't have one, ECP 16 is available from most Public Domain program
sources (the harvard site has it...)

Good luck.

-- 
c60c-3aw@widow.berkeley.edu (Andy McFadden)

---------- cut here ----------- "stripexec" ----------------------------------
#
#  This shell script removes all lines above 'CALL -151' and all
#  lines below 'E00G' in an executioner converted Usenet posting.
#  It also appends 2 linefeeds after 'E00G' and proceeds to convert
#  all linefeeds to carriage returns which apple 2's prefer.  
#  Wildcard filenames are allowed with each extracted file having
#  a '.exec' tail added.  
#  The shell script is a kludge, but it works fine.  
#  Tested with an Apple //c using kermit and xmodem on a microvax
#  running Ultrix 2.0-1.  [also works on a Sun with BSD 4.3 +atm]
#  Written by Paul Nakada   This program is free.  Please distribute freely
#

if ($#argv == 0) then
    echo 'usage: stripexec filename'
    exit
endif

foreach file ($argv)
   set newfile=`echo $file .exec | tr -d ' '`
   echo '...stripping header and trailer from' $file '...'
   echo '... placing extracted file in' $newfile '...'
   awk '/CALL/, /E00G/ { print $0 ; if ($0 == "E00G") printf ("\n\n"); }'\
$file | tr '\012' '\015' > $newfile
end