home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / or / or_asc2ps.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  1.3 KB  |  82 lines

  1. /* or_asc2ps.c: convert ascii to printable string  */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/or/RCS/or_asc2ps.c,v 6.0 1991/12/18 20:23:08 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/or/RCS/or_asc2ps.c,v 6.0 1991/12/18 20:23:08 jpo Rel $
  9.  *
  10.  * $Log: or_asc2ps.c,v $
  11.  * Revision 6.0  1991/12/18  20:23:08  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16.  
  17.  
  18. #include "util.h"
  19. #include "or.h"
  20.  
  21. int    real987    = NOTOK;
  22.  
  23. int or_asc2ps (ascii, ps)
  24. char    *ascii;
  25. char    *ps;
  26. {
  27.     register char       *p, *q;
  28.     int            converted;
  29.     PP_DBG (("Lib/or_asc2ps()"));
  30.  
  31.     q = ps;
  32.     converted = OK;
  33.     for (p = ascii; *p != '\0'; p++) {
  34.         
  35.     if (or_isps (*p) && *p != ')' && *p != '(')
  36.         *q++ = *p;
  37.     else {
  38.         converted = NOTOK;
  39.         *q++ = '(';
  40.         switch (*p) {
  41.             case '@':
  42.             *q++ = 'a';
  43.             break;
  44.             case '%':
  45.             *q++ = 'p';
  46.             break;
  47.             case '!':
  48.             *q++ = 'b';
  49.             break;
  50.             case '"':
  51.             *q++ = 'q';
  52.             break;
  53.             case '_':
  54.             *q++ = 'u';
  55.             break;
  56.             case '(':
  57.             if (real987 == NOTOK) {
  58.                 *q++ = 'l';
  59.                 break;
  60.             }
  61.             case ')':
  62.             if (real987 == NOTOK) {
  63.                 *q++ = 'r';
  64.                 break;
  65.             }
  66.             default:
  67.             (void) sprintf (q, "%03d", *p);
  68.             q = q + 3;
  69.             break;
  70.  
  71.         }        /* end of switch */
  72.  
  73.         *q++ = ')';
  74.  
  75.     }  /* end of if */
  76.  
  77.     }  /* end of for */
  78.  
  79.     *q = '\0';
  80.     return converted;
  81. }
  82.