home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume3 / totri / totri.c < prev    next >
C/C++ Source or Header  |  1989-02-03  |  691b  |  36 lines

  1. /* totri - convert all "funny" characters to ANSI C trigraph sequences.
  2.  *         currently implemented as a filter, but a rewritten main
  3.  *         could allow a more sophisticated interface.
  4.  *
  5.  *  This source donated to the public domain by John P. Nelson 1988
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <strings.h>
  10.  
  11. char *trichar = "=(/)'<!>-";
  12. char *translate = "#[\\]^{|}~";
  13. main()
  14.     {
  15.     process(stdin, stdout);
  16.     }
  17.  
  18. process(in, out)
  19. FILE *in, *out;
  20.     {
  21.     int c;
  22.     char *ptr;
  23.  
  24.     while ((c = getchar(in)) != EOF)
  25.     {
  26.     if (ptr = strchr(translate, c))
  27.         {
  28.         putc('?', out);
  29.         putc('?', out);
  30.         putc(trichar[ptr - translate], out);
  31.         }
  32.     else
  33.         putc(c, out);
  34.     }
  35.     }
  36.