/* splitter.c - splits ROM files */
/* Version 1.0 28-DEC-95 */
/* Copyright © 1995 Sean Riddle */
/* Freely distributable on any medium given all copyrights are retained */
/* by the author and no charge greater than $7.00 is made for obtaining */
/* this software */
/* Please send all bug reports and update ideas to: */
/* sriddle@ionet.net */
/* latest version at: */
/* Please don't hurl on my URL! */
/* usage: splitter [] */
/* where size (default 4096) is number of bytes per file */
/* compiled on Amiga SAS/C 6.56 */
#include
#include
#include
#include
void main(int argc, char *argv[]) {
struct stat st1;
FILE *fp1,*fp2;
unsigned char *buf1;
int i;
int size=4096;
int numfiles;
char outfile[256];
char temp[20];
if((argc==2)||(argc==3)) {
if(argc==3)
size=atoi(argv[2]);
if(!stat(argv[1],&st1)) {
if(buf1=(unsigned char *)malloc(st1.st_size)) {
if(fp1=fopen(argv[1],"rb")) {
if(fread(buf1,st1.st_size,1,fp1)) {
fclose(fp1);
numfiles=(st1.st_size/size);
if(st1.st_size%size)
numfiles++;
if(argv[1][strlen(argv[1])-4]=='.')
argv[1][strlen(argv[1])-4]=NULL;
strcpy(temp,"\%s.\%0");
if(numfiles<10)
strcat(temp,"1.1");
else if(numfiles<100)
strcat(temp,"2.2");
else if(numfiles<1000)
strcat(temp,"3.3");
else
strcat(temp,"4.4");
strcat(temp,"d");
for(i=0;i'\n",argv[0]);
}