home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / comm / reflo101.lha / Reflow.c < prev    next >
C/C++ Source or Header  |  1992-09-06  |  1KB  |  55 lines

  1. #include <exec/types.h>
  2. #include <stdio.h>
  3.  
  4. main(int argc, char **argv)
  5. {
  6.    FILE *fp,*ofp;
  7.    UBYTE buf[200];
  8.    BOOL fulline=FALSE;
  9.  
  10.    if (argc != 3 || *argv[1]=='?')
  11.    {
  12.       printf("\x1b[4mReflow V1.01 for PManager 3.00 by Johan Billing!\n\x1b[0m"
  13.              "Usage: Reflow <Infile> <Outfile>\n");
  14.       exit(0);
  15.    }
  16.  
  17.    if(!(fp=fopen(argv[1],"r")))
  18.    {
  19.       printf("Unable to open file '%s' for reading!\n",argv[1]);
  20.       exit(0);
  21.    }
  22.  
  23.    if(!(ofp=fopen(argv[2],"w")))
  24.    {
  25.       printf("Unable to open file '%s' for writing!\n",argv[2]);
  26.       fclose(fp);
  27.       exit(0);
  28.    }
  29.  
  30.    while(!feof(fp))
  31.    {
  32.       if(fgets(buf,99,fp))
  33.       {
  34.          if(buf[0] != 10 && buf[0] != 32 && strlen(buf) > 65)
  35.          {
  36.             if(buf[strlen(buf)-2] == 32) buf[strlen(buf)-1]=0;
  37.             else                         buf[strlen(buf)-1]=32;
  38.             fulline=TRUE;
  39.          }
  40.          else
  41.          {
  42.             if(fulline && buf[0]==10)
  43.             {
  44.                strcat(buf,"\n");
  45.             }
  46.             fulline=FALSE;
  47.          }
  48.          fprintf(ofp,"%s",buf);
  49.       }
  50.    }
  51.  
  52.    fclose(fp);
  53.    fclose(ofp);
  54. }
  55.