home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / txttoipf.zip / TXTTOIPF.C < prev    next >
Text File  |  1994-04-19  |  4KB  |  151 lines

  1. /*
  2.  
  3.     txttoipf - a program to convert ascii files to ipf files.
  4.  
  5.     Program by Dennis Frost
  6.  
  7.     Email:
  8.           dfrost@wvuvphs1.hsc.wvu.edu
  9.           dlfrost@miavx1.acs.muohio.edu
  10.  
  11. */
  12. #include <stdio.h>
  13.  
  14. void main(int argc, char *argv[])
  15. {
  16. FILE *inputfile, *outputfile;
  17. char c;
  18.  
  19. if (argc != 3)
  20.     {
  21.     printf("txttoipf textfile ipffile\n\n");
  22.     printf("Program by Dennis Frost\n\n");
  23.     printf("Email:\n");
  24.     printf("      dfrost@wvuvphs1.hsc.wvu.edu\n");
  25.     printf("      dlfrost@miavx1.acs.muohio.edu\n");
  26.     exit(-1);
  27.     }
  28.  
  29. if (( inputfile = fopen(argv[1], "r")) == NULL)
  30.     {
  31.     printf("Cannot open file %s\n",argv[1]);
  32.     exit(-2);
  33.     }
  34.  
  35. if (( outputfile = fopen(argv[2], "w")) == NULL)
  36.     {
  37.     printf("Cannot open file %s\n",argv[2]);
  38.     exit(-3);
  39.     }
  40.  
  41.  
  42. while( ! feof( inputfile) )
  43.     { 
  44.     c = fgetc(inputfile);
  45.     switch( c )
  46.         {
  47.         case '&':
  48.             fputs("&.",outputfile);
  49.             break;
  50.         case ':':
  51.             fputs("&colon.",outputfile);
  52.             break;
  53.         case '^':
  54.             fputs("&caret.",outputfile);
  55.             break;
  56.         case ',':
  57.             fputs("&comma.",outputfile);
  58.             break;
  59.         case ''':
  60.             fputs("&apos.",outputfile);
  61.             break;
  62.         case '*':
  63.             fputs("&asterisk.",outputfile);
  64.             break;
  65.         case '\\':
  66.             fputs("&bslash.",outputfile);
  67.             break;
  68.         case '"':
  69.             fputs("&cdq.",outputfile);
  70.             break;
  71.         case '-':
  72.             fputs("&dash.",outputfile);
  73.             break;
  74.         case '$':
  75.             fputs("&dollar.",outputfile);
  76.             break;
  77.         case '.':
  78.             fputs("&per.",outputfile);
  79.             break;
  80.         case '=':
  81.             fputs("&eq.",outputfile);
  82.             break;
  83.         case '!':
  84.             fputs("&xclm.",outputfile);
  85.             break;
  86.         case '>':
  87.             fputs(">sym.",outputfile);
  88.             break;
  89.         case '<':
  90.             fputs("<sym.",outputfile);
  91.             break;
  92.         case '{':
  93.             fputs("&lbrace.",outputfile);
  94.             break;
  95.         case '[':
  96.             fputs("&lbracket.",outputfile);
  97.             break;
  98.         case '(':
  99.             fputs("&lpar.",outputfile);
  100.             break;
  101.         case '#':
  102.             fputs("&numsign.",outputfile);
  103.             break;
  104.         case '`':
  105.             fputs("&osq.",outputfile);
  106.             break;
  107.         case '%':
  108.             fputs("&percent.",outputfile);
  109.             break;
  110.         case '+':
  111.             fputs("&plus.",outputfile);
  112.             break;
  113.         case '}':
  114.             fputs("&rbrace.",outputfile);
  115.             break;
  116.         case ']':
  117.             fputs("&rbracket.",outputfile);
  118.             break;
  119.         case ')':
  120.             fputs("&rpar.",outputfile);
  121.             break;
  122.         case ';':
  123.             fputs("&semi.",outputfile);
  124.             break;
  125.         case '/':
  126.             fputs("&slash.",outputfile);
  127.             break;
  128.         case '@':
  129.             fputs("&atsign.",outputfile);
  130.             break;
  131.         case '|':
  132.             fputs("&splitvbar.",outputfile);
  133.             break;
  134.         case '~':
  135.             fputs("&tilde.",outputfile);
  136.             break;
  137.         case '_':
  138.             fputs("&us.",outputfile);
  139.             break;
  140.         default:
  141.             fputc(c,outputfile);
  142.             break;
  143.          }     /* End Switch */
  144.     } /* End While */
  145.  
  146. fclose(inputfile);
  147. fclose(outputfile);
  148. exit(0);
  149. }
  150.  
  151.