/* sfx2lzh.c ========================================================================== Convert Self dissolving LHARChive to a LHARChive 22Jan90 - CS ========================================================================== Usage: sfx2lzh infile[.sfx] [outfile[.lzh]] */ #include #include #include #define BUFFER_SIZE 0x4000 char buf[BUFFER_SIZE]; int main(int argc, char ** argv) { FILE * fin, * fout = 0; char infile[64], outfile[64]; int size, c, i, ck; char * cp; if(argc < 2) { printf("Usage: %s infile[.sfx] [outfile[.lzh]]\n\n", argv[0]); printf("Purpose: Converts self dissolving LHARChive to an LHARChive\n"); exit(1); } strcpy(infile,argv[1]); strcpy(outfile,argv[argc-1]); /* Open the input file in binary mode, default extension of .SFX */ if (strchr(infile,'.') == 0) strcat(infile,".sfx"); if ( (fin = fopen(infile,"rb")) == 0) { printf("Can't open %s\n",infile); exit(1); } if (strchr(outfile,'.') == 0) strcat(outfile,".lzh"); /* First buffer must contain at least one valid LHARC entry header */ size = fread(buf,1,BUFFER_SIZE,fin); if(size) { cp = buf; while(1) { cp = memchr(cp,'-',size); if(cp != 0 && cp < &buf[size]) { if(strncmp(cp,"-LH0-",5) || strncmp(cp,"-LH1-",5) ) { /* verify that this is a valid header */ /* by calculating its checksum */ ck = 0; for(i=0; i