#include #define LF 10 #define CR 13 #define SOURCE "/home/jskim/public_html/animal/Keywords/han.dat" #define HTML_DIR "/home/jskim/public_html/animal/Dic" #define THUMNAIL_DIR "/home/jskim/public_html/animal/PIX" /* this is for URL */ #define IMG_DIR "../PIX" #define BUTTON_DIR "/~jskim/img" #define SOUND_DIR "../SOUND" #define MOVIE_DIR "../AnimMovie" #define SEARCH_CGI "http://bioinfo.kordic.re.kr/animal/APAsrch3.cgi" #define CUT_WHEN 150 typedef struct { char han[100]; char syn[100]; char eng[100]; char sci[100]; char dsc[10000]; char snd[1024]; char mov[1024]; } DATA; main() { FILE *fin, *flist, *fidx; DATA dat; char line[1024]; char buf[1024]; char first[100]; char last[100]; int cnt; int i; int Update = 0; if ( (fin = fopen(SOURCE, "r")) == NULL ) { printf("Can't open source file [%s]\n", SOURCE); exit(0); } sprintf(buf, "%s/index.html", HTML_DIR); if ( (fidx = fopen(buf, "w")) == NULL ) { printf("Can't open source file [index.html]\n"); exit(0); } fprintf(fidx, "µ¿¹°±×¸²Ã¢°í: µ¿¹°¸í\n\n"); fprintf(fidx, "\n"); fprintf(fidx, "\n"); fprintf(fidx, "

µ¿¹°±×¸²Ã¢°í: °¡³ª´Ù¼ø µ¿¹°¸í


\n"); sprintf(buf, "%s/index0.html", HTML_DIR); if ( (flist = fopen(buf, "w")) == NULL ) { printf("Can't open source file [index0.html]\n"); exit(0); } fprintf(flist, "µ¿¹°±×¸²Ã¢°í: µ¿¹°¸í 1\n\n"); fprintf(flist, "

µ¿¹°±×¸²Ã¢°í: °¡³ª´Ù¼ø µ¿¹°¸í 1

\n
    \n"); dat.eng[0] = '\0'; dat.syn[0] = '\0'; dat.sci[0] = '\0'; dat.snd[0] = '\0'; dat.mov[0] = '\0'; dat.dsc[0] = '\0'; cnt = 0; while (fgets(line, 256, fin)) { if (!strncasecmp(line, "#Han=", 5)) { if (cnt > 0) { if ( (cnt%CUT_WHEN) == 1) strcpy(first, dat.han); strcpy(buf, dat.eng); for (i=0; i < strlen(buf); i++) if (buf[i] == '*') buf[i] = ' '; fprintf(flist, "
  1. %s (%s", dat.han, dat.han, buf); if (strlen(dat.sci) > 0) fprintf(flist, " : %s)\n", dat.sci); else fprintf(flist, ")\n"); if (Update) { makeonehtml(dat); Update = 0; } dat.eng[0] = '\0'; dat.syn[0] = '\0'; dat.sci[0] = '\0'; dat.snd[0] = '\0'; dat.mov[0] = '\0'; dat.dsc[0] = '\0'; if ( (cnt%CUT_WHEN) == 0 ) { fprintf(flist, "
\n ¸ñ·ÏÀ¸·Î ´Ù½Ã µ¹¾Æ°©´Ï´Ù.\n", BUTTON_DIR); fprintf(flist, "\n"); fclose(flist); strcpy(last, dat.han); fprintf(fidx, "¸ñ·Ï %d
", (int)cnt/CUT_WHEN - 1, (int)cnt/CUT_WHEN); fprintf(fidx, "(%s ~ %s)

\n", first, last); sprintf(buf, "%s/index%d.html", HTML_DIR, (int) cnt/CUT_WHEN); if ( (flist = fopen(buf, "w")) == NULL ) { printf("Can't open source file [index%d.html]\n", (int) cnt/CUT_WHEN); exit(0); } fprintf(flist, "µ¿¹°±×¸²Ã¢°í: µ¿¹°¸í %d\n\n", (int) cnt/CUT_WHEN + 1); fprintf(flist, "

µ¿¹°±×¸²Ã¢°í: °¡³ª´Ù¼ø µ¿¹°¸í %d

\n
    \n", (int) cnt/CUT_WHEN + 1, cnt+1); } } strcpy(dat.han, line+5); trim(dat.han); cnt++; } else if (!strncasecmp(line, "#Eng=", 5)) { strcpy(dat.eng, line+5); trim(dat.eng); } else if (!strncasecmp(line, "#Sci=", 5)) { strcpy(dat.sci, line+5); trim(dat.sci); } else if (!strncasecmp(line, "#Syn=", 5)) { strcpy(dat.syn, line+5); trim(dat.syn); } else if (!strncasecmp(line, "#mov=", 5)) { strcpy(dat.mov, line+5); trim(dat.mov); } else if (!strncasecmp(line, "#snd=", 5)) { strcpy(dat.snd, line+5); trim(dat.snd); } else if (!strncasecmp(line, "#dsc=", 5)) strcpy(dat.dsc, line+5); else if (!strncasecmp(line, "#Update=Y", 9)) Update = 1; else if ( !strcmp(line, "\n") || !strcmp(line, " \n") || !strcmp(line, " \n") || !strcmp(line, " \n") ) strcat(dat.dsc, "

    "); else strcat(dat.dsc, line); } strcpy(buf, dat.eng); for (i=0; i < strlen(buf); i++) if (buf[i] == '*') buf[i] = ' '; fprintf(flist, "

  1. %s (%s", dat.han, dat.han, buf); if (strlen(dat.sci) > 0) fprintf(flist, " : %s)\n", dat.sci); else fprintf(flist, ")\n"); if (Update) { makeonehtml(dat); Update = 0; } strcpy(last, dat.han); fprintf(fidx, "¸ñ·Ï %d
    ", (int)cnt/CUT_WHEN, (int)cnt/CUT_WHEN + 1); fprintf(fidx, "(%s ~ %s)

    \n", first, last); fprintf(flist, "

\n ¸ñ·ÏÀ¸·Î ´Ù½Ã µ¹¾Æ°©´Ï´Ù.\n", BUTTON_DIR); fprintf(flist, "\n"); fclose(flist); fprintf(fidx, "
µ¿¹°±×¸²Ã¢°í | µ¿È­»ó |\n"); fprintf(fidx, "µ¿¹°¼Ò¸® | \n"); fprintf(fidx, "¿µ¾îÀ̸§¿­¶÷ | \n"); fprintf(fidx, "Á¶¾ð/Àǰß"); fprintf(fidx,"

Copyright (C) 1998, µ¿¹°±×¸²Ã¢°í\n"); fclose(fidx); fclose(fin); } makeonehtml(d) DATA d; { FILE *fp; char buf[256]; char *ptr; int i; sprintf(buf, "%s/%s.html", HTML_DIR, d.han); if ( (fp = fopen(buf, "w")) == NULL ) { printf("[%s] ÆÄÀÏÀ» ¸¸µé ¼ö ¾ø½À´Ï´Ù.\n", buf); return (0); } fprintf(fp,"%s (%s)\n",d.han,d.eng); fprintf(fp,"

\n"); fprintf(fp, "
µ¿¹°±×¸²Ã¢°í µ¿¹°»çÀü : %s\n", d.han); strcpy(buf, d.eng); for (i=0; i < strlen(buf); i++) { if (buf[i] == ',') { buf[i] = '\0'; trim(buf); break; } else if (buf[i] == ' ') buf[i] = '+'; } fprintf(fp,"
"); if (buf[0] != '*') fprintf(fp,"", buf); if ( mkchkImageName(buf) ) /* buf contains + chars in the place of space */ fprintf(fp,"\"%s\"", d.han, IMG_DIR, buf); else fprintf(fp,"\"ÁغñµÈ", BUTTON_DIR); fprintf(fp, "\n

\n", BUTTON_DIR); if (strlen(d.syn) > 0) fprintf(fp, "%s (%s)
\n", d.han, d.syn); else fprintf(fp, "%s
\n", d.han); strcpy(buf, d.eng); while ( (char *) ptr = (char *) strstr(buf, ",") ) { *ptr = '\0'; if (buf[0] == '*') fprintf(fp, "%s, \n", buf+1); else { for (i=0; i < strlen(buf); i++) if (buf[i] == ' ') buf[i] = '+'; fprintf(fp, "", SEARCH_CGI, buf); for (i=0; i < strlen(buf); i++) if (buf[i] == '+') buf[i] = ' '; fprintf(fp, "%s, \n", buf); } strcpy(buf, ptr+1); trim(buf); } if (buf[0] == '*') fprintf(fp, "%s
\n", buf+1); else { for (i=0; i < strlen(buf); i++) if (buf[i] == ' ') buf[i] = '+'; fprintf(fp, "", SEARCH_CGI, buf); for (i=0; i < strlen(buf); i++) if (buf[i] == '+') buf[i] = ' '; fprintf(fp, "%s
\n", buf); } fprintf(fp, "%s\n

", d.sci); PrintDescription(fp, d.dsc); fprintf(fp, "\n\n

"); if (strlen(d.snd) > 0) { i = 1; strcpy(buf, d.snd); while ( (char *) ptr = (char *)strstr(buf, ",") ) { *ptr = '\0'; fprintf(fp, " %d ", SOUND_DIR, buf, BUTTON_DIR, i++); strcpy(buf, ptr+1); trim(buf); } fprintf(fp, " %d ", SOUND_DIR, buf, BUTTON_DIR, i++); } if (strlen(d.mov) > 0) { i = 1; strcpy(buf, d.mov); while ( (char *) ptr = (char *)strstr(buf, ",") ) { *ptr = '\0'; fprintf(fp, " %d ", MOVIE_DIR, buf, BUTTON_DIR, i++); strcpy(buf, ptr+1); trim(buf); } fprintf(fp, " %d ", MOVIE_DIR, buf, BUTTON_DIR, i++); } fprintf(fp, "


\n"); fprintf(fp,"
\n

\n"); fprintf(fp,"Copyright (C) 1998, µ¿¹°±×¸²Ã¢°í\n"); fprintf(fp,"\n"); fclose(fp); } int PrintDescription(FILE *fp, char *s) { int i, len; len = strlen(s); if (len <=0) return 0; for (i = 0; i < len; i++) { if (s[i] == '[') fprintf(fp, "["); else if (s[i] == ']') fprintf(fp, "]"); else fputc(s[i], fp); } return 0; } int mkchkImageName(s) char *s; { FILE *fp; int i; char *ptr; char buf[256]; trim(s); (int) s[0] = toupper((int) s[0]); for (i=0; i