home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d919 / txtcvt.lha / TxtCvt / TxtCvt.c < prev    next >
C/C++ Source or Header  |  1993-10-04  |  1KB  |  77 lines

  1. /*
  2.     TxtCvt
  3.     Convert PC document files of Microsoft Word for DOS & Windows & Windows Write
  4.     to a pure ASCII-format 
  5.  
  6.     N Fisketjøn 190793
  7. */
  8.  
  9. #include "txtcvt.h"
  10.  
  11. extern getfiletype(FILE *ifp);
  12. extern readmsfile(FILE *ifp, FILE *ofp, int filetype);
  13.  
  14. void version(void)
  15. {
  16.     printf("$VER: TxtCvt 1.0");
  17. }
  18.  
  19. void main (argc,argv)
  20. int argc;
  21. char *argv[];
  22. {
  23.     FILE *ifp;
  24.     FILE *ofp;
  25.     int filetype;
  26.  
  27.     if (argc != 3) {
  28.         printf("Usage: TxtCvt \033[3minputfile\033[0m \033[3moutputfile\033[0m\n");
  29.         exit(0);
  30.     }
  31.     else {
  32.         ifp=fopen(argv[1],"r");
  33.         if(ifp == NULL) {
  34.             printf("Inputfile not found.\n");
  35.         }
  36.         else {
  37.             filetype = getfiletype(ifp);
  38.             if(filetype == NULL) {
  39.                 printf("Unable to determine input filetype.\n");
  40.             }
  41.             else {
  42.                 ofp=fopen(argv[2],"w");
  43.                 if(ofp == NULL) {
  44.                     printf("Unable to open outputfile '%s'.\n",argv[2]);
  45.                 }
  46.                 else {
  47.                     printf("Reading '%s'...\n",argv[1]);
  48.                     switch (filetype) {
  49.                         case DOSWORD: {
  50.                             readmsfile(ifp, ofp, filetype);
  51.                             break;
  52.                         }
  53.                         case WINWORD1: {
  54.                             readmsfile(ifp, ofp, filetype);
  55.                             break;
  56.                         }
  57.                         case WINWORD2: {
  58.                             readmsfile(ifp, ofp, filetype);
  59.                             break;
  60.                         }
  61.                         case WINWRITE: {
  62.                             readmsfile(ifp, ofp, filetype);
  63.                             break;
  64.                         }
  65.                         default: {
  66.                             printf("Unable to process inputfile\n");
  67.                             break;
  68.                         }
  69.                     }
  70.                     fclose(ofp);
  71.                 }
  72.             }
  73.             fclose(ifp);
  74.         }
  75.     }
  76. }
  77.