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 >
Wrap
C/C++ Source or Header
|
1995-10-19
|
861b
|
35 lines
#include <string.h>
#include <stdio.h>
#define BUFSIZE 16384
int main(int argc,char *argv[])
{
FILE *InFile,*OutFile;
char Buffer[BUFSIZE];
if(argc==1)
{
puts("GameBoy Snapshot Converter by Marat Fayzullin (C)FMS 1995");
puts("Usage: conv <infile> [<outfile>]");
return(0);
}
if(argc>3)
{ printf("%s: Wrong number of arguments\n",argv[0]);return(0); }
if(!(InFile=fopen(argv[1],"rb")))
{ printf("%s: Can't open file %s\n",argv[0],argv[1]);return(1); }
OutFile=(argc==2)? stdout:fopen(argv[2],"wb");
if(!OutFile&&(argc>2))
{ printf("%s: Can't open file %s\n",argv[0],argv[1]);return(1); }
if(fread(Buffer,1,512,InFile)!=512)
{ printf("%s: Short input file\n",argv[0]);return(1); }
while(!feof(InFile))
fwrite(Buffer,1,fread(Buffer,1,BUFSIZE,InFile),OutFile);
fclose(InFile);fclose(OutFile);return(0);
}