/* rezrov.c * Extracts resources from a blorb file * Written by Felix Grutzmacher and placed into the public domain */ #include #include /* The following might need changing on your machine */ typedef unsigned int UI32; /* Define this if you're compiling for an Intel machine */ #define _INTEL typedef struct { char usage[4]; UI32 num; UI32 start; } RES_T; #define MAX_RES (256) void extract(RES_T res, FILE *blb); #ifdef _INTEL void endian_transform(UI32 *p); #endif unsigned num_ext = 0; int main(int argc, char *argv[]) { FILE *blb; UI32 num_res=0; RES_T res[MAX_RES]; UI32 i; if(argc<2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } if(!(blb=fopen(argv[1],"rb"))) { perror(argv[1]); exit(2); } fseek(blb, 20, SEEK_SET); if(fread(&num_res, 4, 1, blb)!=1) { if(feof(blb)) fputs("End of file while reading resource index.\n", stderr); else perror("Error getting number of resources"); exit(3); } #ifdef _INTEL endian_transform(&num_res); #endif if(num_res>MAX_RES) num_res=MAX_RES; if(fread(res, sizeof(RES_T), num_res, blb)!=num_res) { if(feof(blb)) fputs("End of file while reading resource index.\n", stderr); else perror("Error reading resource index"); exit(3); } for(i=0; i>24) | ((r>>8)&0x0000ff00) | ((r<<8)&0x00ff0000) | (r<<24); *p=r; } #endif