#include "RandomImage.h" int e_name_comp(A, B) DATABUF *A; DATABUF *B; { return(strcasecmp(A->e_name, B->e_name)); } main() { FILE *fp; /* data file pointer */ FILE *tmpfp; /* temporory file pointer */ int fd; /* file descriptor to store the result */ char line[256]; /* line buffer */ char buf[128]; /* line buffer */ DATABUF res[8192]; /* result data */ int i, j; /* for general purpose */ int cnt; /* number of catalogs */ if ( (fp = fopen(RAW_DATA_FILE, "r")) == NULL) { printf("data file open failed.\n"); fclose(fp); exit(1); } i = 0; while (fgets(line, 256, fp)) { sscanf(line, "%s %s %s", res[i].h_name, res[i].e_name, res[i].imgFName); /* file error check */ strcpy(buf, PIX_DIR); strcat(buf, res[i].imgFName); if ( (tmpfp=fopen(buf, "r")) == NULL) { printf("±×¸² µð·ºÅ丮¿¡ [%s] ÆÄÀÏÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.\n", buf); exit(1); } fclose(tmpfp); res[i].an = i++; } fclose(fp); /* open file descriptor to store the result, han-eng catalog */ if ( (fd=open(SYS_CATALOG, O_WRONLY | O_CREAT, 0644)) < 0) { printf("Hangul file open failed.\n"); exit(1); } cnt = i; /* set the total catalog number */ /* write result to the han-eng file */ write(fd, (char *) &cnt, sizeof(int)); write(fd, (char *) &res, cnt*sizeof(DATABUF)); close(fd); /* open file descriptor to store the result, han-eng catalog */ if ( (fd=open(SYS_CATALOG_ENG, O_WRONLY | O_CREAT, 0644)) < 0) { printf("English file open failed.\n"); exit(1); } /* write result to the eng-han file */ qsort(res, cnt, sizeof(DATABUF), e_name_comp); /* sort by English name */ for (i=0; i