/* This program may be freely distributed , copied,and modified so long as a fee is not charged. However, I reserve all rights available to me under The Copyright Act. If you find any bugs please feel free to contact me. David DeGeorge Princeton,New Jersey March 1987 USENET: ....princeton!idacrd!dld COMPUSERVE: 74176,3210 GENIE: DEGEORGE */ #define MAIN #include "makersh.h" #include "globals.h" #ifdef GEM main() { #else main(argc,argv) char **argv; { #endif int i,*p,j; char *q,*r1,mesag[80]; int oneflag; int size; long where,z,w,*r,lseek(); #ifdef GEM begin(); getfiles(&in,&out); #else if ( argc != 3) /* get input and output */ error("",USAGE); if(( in = fopen(argv[1],"rb"))== NULL){ sprintf(mesag,"Can't open %s for reading\n",argv[1]); error(mesag,FATAL); } if((out = fopen(argv[2],"w"))==NULL){ sprintf(mesag,"Can't open %s for writing\n",argv[2]); error(mesag,FATAL); } if ( access(argv[2],EXISTS) == 0){ sprintf(mesag,"%s exists",argv[2]); error(mesag,WARN); } #endif size = fread(&rheader,1,sizeof(rheader),in); /* read the header */ if ( size != sizeof(rheader)) error("Error in|reading header",FATAL); /* check if resource file */ if((long)(rheader.rsh_rssize) != lseek(fileno(in),0L,2)) error("Resource file is not|the correct length",WARN); stradds =(long *)malloc(MAXSTR*4); nullnes(stradds,"Space for string addresses"); head = malloc(rheader.rsh_rssize); nullnes(head,"Resource file"); fseek(in,0L,0); /* Read the whole file into memory */ fread(head,1,rheader.rsh_rssize,in); #ifdef GEM makeitems(); display(); #endif bbadds = (long *)malloc(4*rheader.rsh_nbb); nullnes(bbadds,"Bitblock addresses"); objs = (OBJECT *)( head + rheader.rsh_object); teds = (TEDINFO *)( head + rheader.rsh_tedinfo); bitblks = (BITBLK *)( head + rheader.rsh_bitblk); iconblks = ( ICONBLK *)(head + rheader.rsh_iconblk); /* lets do the strings */ q = ( char *) ( head + rheader.rsh_string); r1 = ( char *) ( head + rheader.rsh_imdata); j = 0; oneflag = 1; /* for the first time thru */ fprintf(out,"\nchar *rs_strings[]={"); /* apparently the images are right after the strings */ /* So that's how we know when to stop */ while( q < r1 ){ if( q == r1-1) *q = '\0'; /* There may be an extra byte because the images must start on a word boundary */ if (oneflag == 0) fprintf(out,",\n\"%s\"",q); else{ oneflag = 0; fprintf(out,"\n\"%s\"",q); } stradds[nstrings]=(long)(q-head); j += 1 + strlen(q); #ifdef GEM progress(0,j); #endif q += 1 + strlen(q); nstrings++; if ( nstrings == strmax){ strmax += MAXSTR; stradds= (long *)realloc(stradds,4*strmax); nullnes(stradds,"Realloting string adds"); } } fprintf(out,"\n};\n"); /* write out the objects next */ fprintf(out,"\nOBJECT rs_object[]={\n"); for ( i=0 ; i