#include typedef struct { int files; char **filenames; struct { int file:8; int offset:24; } allkanji[94*94]; } indexinfo; #if 0 main(ac,ag) char **ag; { char buf[4096]; int code=strtol(ag[1],NULL,16); read_index(ag[2]); searchcode(code,buf); puts(buf); } #endif read_index(indexfile) char *indexfile; { FILE *fd; char buf[256]; int len,allfile,i; if((fd=fopen(indexfile,"r"))==NULL){ fprintf(stderr,"Index file %s is not foune\n",indexfile); exit(1); } fgets(buf,256,fd); if(strncmp(buf,"TYPE1",5)){ fprintf(stderr,"%s is not a index file\n",indexfile); exit(1); } allfile=atoi(buf+6); filenames=malloc(allfile*sizeof(char *)); for(i=0;i>8)&255)-0x21)*94+((code&255)-0x21); if((fd=fopen(filenames[allkanji[koffset].file],"r"))==NULL){ fprintf(stderr,"Can't open file %s\n",filenames[allkanji[koffset].file]); exit(1); } fseek(fd,allkanji[koffset].offset,0); fgets(buf,4096,fd); fclose(fd); }