home *** CD-ROM | disk | FTP | other *** search
/ The AGA Experience 2 / agavol2.iso / software / utilities / emulation / gameboy / vgb_amiga / vgb_amiga_0.3 / conv.c < prev    next >
C/C++ Source or Header  |  1995-10-19  |  861b  |  35 lines

  1. #include <string.h>
  2. #include <stdio.h>
  3.  
  4. #define BUFSIZE 16384
  5.  
  6. int main(int argc,char *argv[])
  7. {
  8.   FILE *InFile,*OutFile;
  9.   char Buffer[BUFSIZE];
  10.  
  11.   if(argc==1)
  12.   {
  13.     puts("GameBoy Snapshot Converter by Marat Fayzullin  (C)FMS 1995");
  14.     puts("Usage: conv <infile> [<outfile>]");
  15.     return(0);
  16.   }
  17.   if(argc>3)
  18.   { printf("%s: Wrong number of arguments\n",argv[0]);return(0); }
  19.  
  20.   if(!(InFile=fopen(argv[1],"rb")))
  21.   { printf("%s: Can't open file %s\n",argv[0],argv[1]);return(1); }
  22.   OutFile=(argc==2)? stdout:fopen(argv[2],"wb");
  23.   if(!OutFile&&(argc>2))
  24.   { printf("%s: Can't open file %s\n",argv[0],argv[1]);return(1); }
  25.  
  26.   if(fread(Buffer,1,512,InFile)!=512)
  27.   { printf("%s: Short input file\n",argv[0]);return(1); }
  28.  
  29.   while(!feof(InFile))
  30.     fwrite(Buffer,1,fread(Buffer,1,BUFSIZE,InFile),OutFile);
  31.   
  32.   fclose(InFile);fclose(OutFile);return(0);
  33. }
  34.  
  35.