home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1992 August / info-mac-1992.iso / UNIX / Unxbin.shar < prev    next >
Text File  |  1992-08-29  |  8KB  |  319 lines

  1. 31-Mar-86 22:41:43-PST,8153;000000000001
  2. Return-Path: <werner@ngp.UTEXAS.EDU>
  3. Received: from ngp.UTEXAS.EDU by SUMEX-AIM.ARPA with TCP; Mon 31 Mar 86 22:41:34-PST
  4. Date: Tue, 1 Apr 86 00:18:50 cst
  5. From: werner@ngp.UTEXAS.EDU (Werner Uhrig)
  6. Posted-Date: Tue, 1 Apr 86 00:18:50 cst
  7. Message-Id: <8604010618.AA04248@ngp.UTEXAS.EDU>
  8. Received: by ngp.UTEXAS.EDU (4.22/4.22)
  9.     id AA04248; Tue, 1 Apr 86 00:18:50 cst
  10. To: info-mac-request@sumex-aim
  11. Subject: from USENET: unxbin
  12.  
  13. [don't give me any credit, I'm just the mailman  (-: ---Werner]
  14.  
  15. From barad@brand.UUCP  Wed Mar 26 11:33:12 1986
  16. Relay-Version: version B 2.10.2 9/18/84; site ut-ngp.UUCP
  17. Path: ut-ngp!ut-sally!seismo!lll-crg!lll-lcc!qantel!hplabs!sdcrdcf!oberon!brand!barad
  18. From: barad@brand.UUCP (Herb Barad)
  19. Newsgroups: net.sources.mac
  20. Subject: Unxbin sources (related to BinHex)
  21. Message-ID: <195@brand.UUCP>
  22. Date: 26 Mar 86 17:33:12 GMT
  23. Date-Received: 28 Mar 86 13:22:27 GMT
  24. Reply-To: barad@brand.UUCP (Herb Barad)
  25. Organization: U. of So. Calif., Los Angeles
  26. Lines: 289
  27.  
  28. After getting many requests for unpit, I had Alan Weber repost his
  29. program.  While getting these requests, many people also requested
  30. unxbin.  I don't know who the original author was, but since the
  31. sources are not too large (~6.5K), I am reposting it here.
  32.  
  33.                         Herb Barad
  34.  
  35. #! /bin/sh
  36. # This is a shell archive, meaning:
  37. # 1. Remove everything above the #! /bin/sh line.
  38. # 2. Save the resulting text in a file.
  39. # 3. Execute the file with /bin/sh (not csh) to create the files:
  40. #    README
  41. #    8to6.c
  42. #    crc.c
  43. #    gethead.c
  44. #    unrun.c
  45. #    unxbin
  46. # This archive created: Wed Mar 26 09:27:20 1986
  47. export PATH; PATH=/bin:$PATH
  48. echo shar: extracting "'README'" '(1181 characters)'
  49. if test -f 'README'
  50. then
  51.     echo shar: will not over-write existing file "'README'"
  52. else
  53. sed 's/^    X//' << \SHAR_EOF > 'README'
  54.     XThese programs are a quick hack to convert *.{info,data,rsrc} files from
  55.     Xmacget back to something that xbin will accept.  The only reason I wrote
  56.     Xthese was so that I could post version 4.5 of Switcher.
  57.     X
  58.     XThese files are in no way optimum, elegant, or pretty.  In fact, they might
  59.     Xnot even be correct.  If you need to do this sort of thing very often, you
  60.     Xshould obtain whatever it is everybody else uses ( and post it to the net so
  61.     Xthat I can get it! ).
  62.     X
  63.     XEnough blithering.  Here is what is here:
  64.     X
  65.     X    README            This file
  66.     X
  67.     X    gethead            filter to turn *.info into
  68.     X                a valid header
  69.     X
  70.     X    crc            writes crc of stdin on stdout
  71.     X
  72.     X    unrun            filter to change 0x90 into 0x90 0x00.
  73.     X                needed because I don't do run length
  74.     X                encoding, because this is all a kludge.
  75.     X
  76.     X    8to6            filter to convert 8 bit data stream into
  77.     X                6 bit data stream that xbin wants.  Uses
  78.     X                worst algorithm I could think of, so don't
  79.     X                look at it, please!
  80.     X
  81.     X    unxbin            shell script to use the above stuff
  82.     X
  83.     XTo install:
  84.     X
  85.     X    #!/bin/sh
  86.     X    for i in gethead crc unrun 8to6
  87.     X    do
  88.     X        cc $i.c -o /where/you/want/it/in/your/path/$i
  89.     X    done
  90.     X    cp unxbin /some/where/in/your/path
  91.     X
  92.     XTo use:
  93.     X
  94.     X    unxbin file    # convert file.{info,data,rsrs} to file.hqx
  95. SHAR_EOF
  96. if test 1181 -ne "`wc -c < 'README'`"
  97. then
  98.     echo shar: error transmitting "'README'" '(should have been 1181 characters)'
  99. fi
  100. fi # end of overwriting check
  101. echo shar: extracting "'8to6.c'" '(942 characters)'
  102. if test -f '8to6.c'
  103. then
  104.     echo shar: will not over-write existing file "'8to6.c'"
  105. else
  106. sed 's/^    X//' << \SHAR_EOF > '8to6.c'
  107.     X/*
  108.     X * Convert 8 bit data stream into 6 bit data stream.  
  109.     X * The approach is very dumb, but I was in a hurry.
  110.     X */
  111.     X
  112.     X#include <stdio.h>
  113.     X
  114.     Xchar tr[]="!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr";
  115.     X
  116.     Xgetbit()
  117.     X{
  118.     X    static int c, mask = 0x00;
  119.     X    static int count;
  120.     X
  121.     X    if ( mask == 0 ) {
  122.     X        mask = 0x80; c = getchar();
  123.     X        if ( c == EOF )
  124.     X            if ( count % 3 == 0 )
  125.     X                return -1;
  126.     X            else
  127.     X                c = 0;    /* make everything come out even */
  128.     X        count++;
  129.     X    }
  130.     X    if ( c & mask )
  131.     X    {
  132.     X        mask >>= 1; return 1;
  133.     X    } else {
  134.     X        mask >>= 1; return 0;
  135.     X    }
  136.     X}
  137.     X
  138.     Xmain()
  139.     X{
  140.     X    int bits = 0; int c;
  141.     X    int count; int val;
  142.     X
  143.     X    printf( "(This file must be converted with something)\n:" );
  144.     X    count = 1;
  145.     X    while ( ( val = getbit() ) != -1 )
  146.     X    {
  147.     X        c = c + c + val; bits++;
  148.     X        if ( bits == 6 ) {
  149.     X            bits = 0; putchar( tr[ c ] ); c = 0;
  150.     X            if ( count++ > 62 ) {
  151.     X                count = 0; putchar( '\n' );
  152.     X            }
  153.     X        }
  154.     X    }
  155.     X    if ( bits != 0 )
  156.     X        write( 2, "no bits\n", 8 );
  157.     X    putchar( ':' ); putchar( '\n' );
  158.     X}
  159. SHAR_EOF
  160. if test 942 -ne "`wc -c < '8to6.c'`"
  161. then
  162.     echo shar: error transmitting "'8to6.c'" '(should have been 942 characters)'
  163. fi
  164. fi # end of overwriting check
  165. echo shar: extracting "'crc.c'" '(446 characters)'
  166. if test -f 'crc.c'
  167. then
  168.     echo shar: will not over-write existing file "'crc.c'"
  169. else
  170. sed 's/^    X//' << \SHAR_EOF > 'crc.c'
  171.     X/*
  172.     X * compute the crc used in .hqx files
  173.     X */
  174.     X#include <stdio.h>
  175.     X
  176.     Xint crc, temp;
  177.     X
  178.     Xmain()
  179.     X{
  180.     X    int c;
  181.     X
  182.     X    crc = 0;
  183.     X    while ( ( c = getchar() ) != EOF )
  184.     X        docrc( c );
  185.     X    docrc(0); docrc(0);
  186.     X    putchar( (crc>>8) & 0xff ); putchar( crc & 0xff );
  187.     X}
  188.     X
  189.     Xdocrc( c )
  190.     X    int c;
  191.     X{
  192.     X    register int i;
  193.     X    temp = crc;
  194.     X    for ( i = 0; i < 8; i++ )
  195.     X    {
  196.     X        c <<= 1;
  197.     X        if ( (temp <<= 1) & 0x10000 )
  198.     X            temp = (temp & 0xffff) ^ 0x1021;
  199.     X        temp ^= (c >> 8);
  200.     X        c &= 0xff;
  201.     X    }
  202.     X    crc = temp;
  203.     X}
  204. SHAR_EOF
  205. if test 446 -ne "`wc -c < 'crc.c'`"
  206. then
  207.     echo shar: error transmitting "'crc.c'" '(should have been 446 characters)'
  208. fi
  209. fi # end of overwriting check
  210. echo shar: extracting "'gethead.c'" '(385 characters)'
  211. if test -f 'gethead.c'
  212. then
  213.     echo shar: will not over-write existing file "'gethead.c'"
  214. else
  215. sed 's/^    X//' << \SHAR_EOF > 'gethead.c'
  216.     X/*
  217.     X * filter to change a foo.info file into a proper header for a .hqx file
  218.     X */
  219.     X
  220.     Xchar head[ 128 ];
  221.     X
  222.     Xmain()
  223.     X{
  224.     X    int n;
  225.     X
  226.     X    read( 0, head, 128 );
  227.     X
  228.     X    put( 1, 1 );
  229.     X
  230.     X    for ( n = 0; n < head[1]; n++ )
  231.     X        put( 1, n+2 );
  232.     X    head[0] = 0; put( 1, 0 );
  233.     X    put( 4, 65 ); put( 4, 69 );
  234.     X    put( 2, 63 ); put( 4, 83 );
  235.     X    put( 4, 87 );
  236.     X}
  237.     X
  238.     Xput( cnt, offset )
  239.     X{
  240.     X    while ( cnt-- > 0 )
  241.     X        putchar( head[ offset++ ] );
  242.     X}
  243. SHAR_EOF
  244. if test 385 -ne "`wc -c < 'gethead.c'`"
  245. then
  246.     echo shar: error transmitting "'gethead.c'" '(should have been 385 characters)'
  247. fi
  248. fi # end of overwriting check
  249. echo shar: extracting "'unrun.c'" '(169 characters)'
  250. if test -f 'unrun.c'
  251. then
  252.     echo shar: will not over-write existing file "'unrun.c'"
  253. else
  254. sed 's/^    X//' << \SHAR_EOF > 'unrun.c'
  255.     X/*
  256.     X * remove run length problems
  257.     X */
  258.     X
  259.     X#include <stdio.h>
  260.     X
  261.     Xmain()
  262.     X{
  263.     X    int c;
  264.     X    while ( (c = getchar()) != EOF )
  265.     X    {
  266.     X        putchar( c );
  267.     X        if ( c == 0x90 )
  268.     X            putchar( 0 );
  269.     X    }
  270.     X}
  271. SHAR_EOF
  272. if test 169 -ne "`wc -c < 'unrun.c'`"
  273. then
  274.     echo shar: error transmitting "'unrun.c'" '(should have been 169 characters)'
  275. fi
  276. fi # end of overwriting check
  277. echo shar: extracting "'unxbin'" '(403 characters)'
  278. if test -f 'unxbin'
  279. then
  280.     echo shar: will not over-write existing file "'unxbin'"
  281. else
  282. sed 's/^    X//' << \SHAR_EOF > 'unxbin'
  283.     X:
  284.     X# convert foo.info, foo.data, foo.rsrc files to a single file suitable
  285.     X# for xbin
  286.     X
  287.     Xtrap "rm $TMP;echo aborted;exit" 1 2 3 15
  288.     XBASENAME=$1                # argument is name of file
  289.     XTMP=/tmp/unxbin$$
  290.     Xgethead < $BASENAME.info > /tmp/unxbin$$
  291.     Xcrc < $TMP >> $TMP
  292.     Xcat $BASENAME.data >> $TMP
  293.     Xcrc < $BASENAME.data >> $TMP
  294.     Xcat $BASENAME.rsrc >> $TMP
  295.     Xcrc < $BASENAME.rsrc >> $TMP
  296.     Xunrun < $TMP | 8to6 > $BASENAME.hqx
  297.     Xrm $TMP
  298. SHAR_EOF
  299. if test 403 -ne "`wc -c < 'unxbin'`"
  300. then
  301.     echo shar: error transmitting "'unxbin'" '(should have been 403 characters)'
  302. fi
  303. chmod +x 'unxbin'
  304. fi # end of overwriting check
  305. #    End of shell archive
  306. exit 0
  307. -- 
  308. Herb Barad    [USC - Signal and Image Processing Institute]
  309.  
  310. USENET:
  311.  
  312. ...!sdcrdcf!usc-oberon!brand!barad            or
  313. ...!{lbl-csam|trwrb|trwspp}!trwspf!herb            or
  314. ...!{lbl-csam|trwrb|trwspp}!trwspf!brand!barad
  315.  
  316. ARPANET:    barad%brand@usc-ecl.ARPA
  317.  
  318.  
  319.