/*  win2ami v 1.0.1 - Copyright © 2001 Kalle Räisänen.
    Converts Windows-textfiles to Unix/Amiga format.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <string.h>
#include <exec/types.h>
#define CR    13
#define TRUE 1
#define FALSE 0
static UBYTE *VersTag = "\0 $VER: win2ami 1.0.1";
int compare(char *s, char *t)
{
   int i = 0;

   while(s[i] == t[i]){
      if(s[i] == '\0')
         return 1;
      i++;
   }
   return 0;
}

main(int argc, char *argv[])
{
   FILE *file, *file2;
   int ch, show = FALSE;

   if(argc > 2) {
      if((argc > 3) && (compare(argv[3], "--show") || compare(argv[3], "-s")))
         show = TRUE;
      else
         printf("%s: working...",argv[0]);
      if((file = fopen(argv[1], "r")) && (file2 = fopen(argv[2], "w"))) {
         while ((ch = fgetc(file)) != EOF) {
            if(show)
               printf("%c", ch);
            if((ch) != CR)
               putc(ch, file2);
         }
         fclose(file);
         fclose(file2);
         printf("\n%s: done\n",argv[0]);
      }
      else
         printf("\n%s: File-error.\n",argv[0], argv[1]);
   }
   else
      printf("\nUsage %s source destination [--show|-s]\n\n",argv[0]);
}
