home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 1992 August
/
info-mac-1992.iso
/
UNIX
/
Unxbin.shar
< prev
next >
Wrap
Text File
|
1992-08-29
|
8KB
|
319 lines
31-Mar-86 22:41:43-PST,8153;000000000001
Return-Path: <werner@ngp.UTEXAS.EDU>
Received: from ngp.UTEXAS.EDU by SUMEX-AIM.ARPA with TCP; Mon 31 Mar 86 22:41:34-PST
Date: Tue, 1 Apr 86 00:18:50 cst
From: werner@ngp.UTEXAS.EDU (Werner Uhrig)
Posted-Date: Tue, 1 Apr 86 00:18:50 cst
Message-Id: <8604010618.AA04248@ngp.UTEXAS.EDU>
Received: by ngp.UTEXAS.EDU (4.22/4.22)
id AA04248; Tue, 1 Apr 86 00:18:50 cst
To: info-mac-request@sumex-aim
Subject: from USENET: unxbin
[don't give me any credit, I'm just the mailman (-: ---Werner]
From barad@brand.UUCP Wed Mar 26 11:33:12 1986
Relay-Version: version B 2.10.2 9/18/84; site ut-ngp.UUCP
Path: ut-ngp!ut-sally!seismo!lll-crg!lll-lcc!qantel!hplabs!sdcrdcf!oberon!brand!barad
From: barad@brand.UUCP (Herb Barad)
Newsgroups: net.sources.mac
Subject: Unxbin sources (related to BinHex)
Message-ID: <195@brand.UUCP>
Date: 26 Mar 86 17:33:12 GMT
Date-Received: 28 Mar 86 13:22:27 GMT
Reply-To: barad@brand.UUCP (Herb Barad)
Organization: U. of So. Calif., Los Angeles
Lines: 289
After getting many requests for unpit, I had Alan Weber repost his
program. While getting these requests, many people also requested
unxbin. I don't know who the original author was, but since the
sources are not too large (~6.5K), I am reposting it here.
Herb Barad
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# README
# 8to6.c
# crc.c
# gethead.c
# unrun.c
# unxbin
# This archive created: Wed Mar 26 09:27:20 1986
export PATH; PATH=/bin:$PATH
echo shar: extracting "'README'" '(1181 characters)'
if test -f 'README'
then
echo shar: will not over-write existing file "'README'"
else
sed 's/^ X//' << \SHAR_EOF > 'README'
XThese programs are a quick hack to convert *.{info,data,rsrc} files from
Xmacget back to something that xbin will accept. The only reason I wrote
Xthese was so that I could post version 4.5 of Switcher.
X
XThese files are in no way optimum, elegant, or pretty. In fact, they might
Xnot even be correct. If you need to do this sort of thing very often, you
Xshould obtain whatever it is everybody else uses ( and post it to the net so
Xthat I can get it! ).
X
XEnough blithering. Here is what is here:
X
X README This file
X
X gethead filter to turn *.info into
X a valid header
X
X crc writes crc of stdin on stdout
X
X unrun filter to change 0x90 into 0x90 0x00.
X needed because I don't do run length
X encoding, because this is all a kludge.
X
X 8to6 filter to convert 8 bit data stream into
X 6 bit data stream that xbin wants. Uses
X worst algorithm I could think of, so don't
X look at it, please!
X
X unxbin shell script to use the above stuff
X
XTo install:
X
X #!/bin/sh
X for i in gethead crc unrun 8to6
X do
X cc $i.c -o /where/you/want/it/in/your/path/$i
X done
X cp unxbin /some/where/in/your/path
X
XTo use:
X
X unxbin file # convert file.{info,data,rsrs} to file.hqx
SHAR_EOF
if test 1181 -ne "`wc -c < 'README'`"
then
echo shar: error transmitting "'README'" '(should have been 1181 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'8to6.c'" '(942 characters)'
if test -f '8to6.c'
then
echo shar: will not over-write existing file "'8to6.c'"
else
sed 's/^ X//' << \SHAR_EOF > '8to6.c'
X/*
X * Convert 8 bit data stream into 6 bit data stream.
X * The approach is very dumb, but I was in a hurry.
X */
X
X#include <stdio.h>
X
Xchar tr[]="!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr";
X
Xgetbit()
X{
X static int c, mask = 0x00;
X static int count;
X
X if ( mask == 0 ) {
X mask = 0x80; c = getchar();
X if ( c == EOF )
X if ( count % 3 == 0 )
X return -1;
X else
X c = 0; /* make everything come out even */
X count++;
X }
X if ( c & mask )
X {
X mask >>= 1; return 1;
X } else {
X mask >>= 1; return 0;
X }
X}
X
Xmain()
X{
X int bits = 0; int c;
X int count; int val;
X
X printf( "(This file must be converted with something)\n:" );
X count = 1;
X while ( ( val = getbit() ) != -1 )
X {
X c = c + c + val; bits++;
X if ( bits == 6 ) {
X bits = 0; putchar( tr[ c ] ); c = 0;
X if ( count++ > 62 ) {
X count = 0; putchar( '\n' );
X }
X }
X }
X if ( bits != 0 )
X write( 2, "no bits\n", 8 );
X putchar( ':' ); putchar( '\n' );
X}
SHAR_EOF
if test 942 -ne "`wc -c < '8to6.c'`"
then
echo shar: error transmitting "'8to6.c'" '(should have been 942 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'crc.c'" '(446 characters)'
if test -f 'crc.c'
then
echo shar: will not over-write existing file "'crc.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'crc.c'
X/*
X * compute the crc used in .hqx files
X */
X#include <stdio.h>
X
Xint crc, temp;
X
Xmain()
X{
X int c;
X
X crc = 0;
X while ( ( c = getchar() ) != EOF )
X docrc( c );
X docrc(0); docrc(0);
X putchar( (crc>>8) & 0xff ); putchar( crc & 0xff );
X}
X
Xdocrc( c )
X int c;
X{
X register int i;
X temp = crc;
X for ( i = 0; i < 8; i++ )
X {
X c <<= 1;
X if ( (temp <<= 1) & 0x10000 )
X temp = (temp & 0xffff) ^ 0x1021;
X temp ^= (c >> 8);
X c &= 0xff;
X }
X crc = temp;
X}
SHAR_EOF
if test 446 -ne "`wc -c < 'crc.c'`"
then
echo shar: error transmitting "'crc.c'" '(should have been 446 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'gethead.c'" '(385 characters)'
if test -f 'gethead.c'
then
echo shar: will not over-write existing file "'gethead.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'gethead.c'
X/*
X * filter to change a foo.info file into a proper header for a .hqx file
X */
X
Xchar head[ 128 ];
X
Xmain()
X{
X int n;
X
X read( 0, head, 128 );
X
X put( 1, 1 );
X
X for ( n = 0; n < head[1]; n++ )
X put( 1, n+2 );
X head[0] = 0; put( 1, 0 );
X put( 4, 65 ); put( 4, 69 );
X put( 2, 63 ); put( 4, 83 );
X put( 4, 87 );
X}
X
Xput( cnt, offset )
X{
X while ( cnt-- > 0 )
X putchar( head[ offset++ ] );
X}
SHAR_EOF
if test 385 -ne "`wc -c < 'gethead.c'`"
then
echo shar: error transmitting "'gethead.c'" '(should have been 385 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'unrun.c'" '(169 characters)'
if test -f 'unrun.c'
then
echo shar: will not over-write existing file "'unrun.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'unrun.c'
X/*
X * remove run length problems
X */
X
X#include <stdio.h>
X
Xmain()
X{
X int c;
X while ( (c = getchar()) != EOF )
X {
X putchar( c );
X if ( c == 0x90 )
X putchar( 0 );
X }
X}
SHAR_EOF
if test 169 -ne "`wc -c < 'unrun.c'`"
then
echo shar: error transmitting "'unrun.c'" '(should have been 169 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'unxbin'" '(403 characters)'
if test -f 'unxbin'
then
echo shar: will not over-write existing file "'unxbin'"
else
sed 's/^ X//' << \SHAR_EOF > 'unxbin'
X:
X# convert foo.info, foo.data, foo.rsrc files to a single file suitable
X# for xbin
X
Xtrap "rm $TMP;echo aborted;exit" 1 2 3 15
XBASENAME=$1 # argument is name of file
XTMP=/tmp/unxbin$$
Xgethead < $BASENAME.info > /tmp/unxbin$$
Xcrc < $TMP >> $TMP
Xcat $BASENAME.data >> $TMP
Xcrc < $BASENAME.data >> $TMP
Xcat $BASENAME.rsrc >> $TMP
Xcrc < $BASENAME.rsrc >> $TMP
Xunrun < $TMP | 8to6 > $BASENAME.hqx
Xrm $TMP
SHAR_EOF
if test 403 -ne "`wc -c < 'unxbin'`"
then
echo shar: error transmitting "'unxbin'" '(should have been 403 characters)'
fi
chmod +x 'unxbin'
fi # end of overwriting check
# End of shell archive
exit 0
--
Herb Barad [USC - Signal and Image Processing Institute]
USENET:
...!sdcrdcf!usc-oberon!brand!barad or
...!{lbl-csam|trwrb|trwspp}!trwspf!herb or
...!{lbl-csam|trwrb|trwspp}!trwspf!brand!barad
ARPANET: barad%brand@usc-ecl.ARPA