[fa.info-mac] Useful C utility

info-mac@uw-beaver (12/25/84)

From: Joel Malman <malman@bbn-labs-b>

For all those Mac users on ArpaNet TACs trying to use BinHex:

You probably know that you can not easily use macput and macget through the
TAC.  What  you  can  do  is  to read the BinHex program into a MacTerminal
document, but wait.... The TAC does funny things with trailing  blanks.  It
was suggested that if you append a vertical bar (|) to the end of each line
BinHex  would  not  mind,  therefore  the  trailing  spaces  would not be a
problem. 

Here  is  a  tiny  C  program (which can be used as a filter) to append the
vertical bar to the end of every line. 

#include <stdio.h>
main()
{
        char s[100];
        for (;;) {
 
        if (gets(s) == 0)
           exit (0);
        printf ("%s|\n", s);
        }
}

Once you compile this program (I called it hexfilter), you can use it like:

$ cat freeware.hcx | hexfilter > freeware.bar

              - or -

$ hexfilter < freeware.hcx > freeware.bar


You  can  then  "cat"  freeware.bar into a MacTerminal document and run the
BinHex program to convert it  into  a  Mac  application.  Mac  Get/Put  not
required. 

Hope this helps.

joel