/* * ViewImg.c * for Bioinfo Animal Pictures Archive * jskim@bulls.kordic.re.kr */ #include "ViewImg.h" #include "NameSearch/AD_Buf.h" int lang = 0; /* 0 for English, 1 for Korean */ int main() { FILE *ftemplate; FILE *ftmp; char srcFile[256]; char srcPath[256]; char srcFileDesc[256]; getentry entries[5]; char buf[256]; char *ptr; register int i, x; printf("content-type: text/html\n\n"); /* HTML Header */ #ifdef FILEOUT printf("Debugging Mode\n"); i = 2; strcpy(entries[0].name, "img"); strcpy(entries[0].val, "animal3/Dolphins-s095239.jpg"); #else i = ProcessGetMethod( entries ); #endif for (x = 0; x <= i; x++) { if (!strcasecmp(entries[x].name, "img")) { strcpy(buf, entries[x].val); while (ptr = (char *)strstr(buf, "/")) { strcpy(buf, ptr+1); } strcpy(srcFile, buf); strcpy(buf, entries[x].val); ptr = (char *) strstr(buf, srcFile); *ptr = '\0'; strcpy(srcPath, buf); continue; } if (!strcasecmp(entries[x].name, "Lang")) { if (!strcasecmp(entries[x].val, "Korean")) lang = 1; continue; } } if (lang == 1) ftemplate = fopen(TEMPLATE_HAN, "r"); else ftemplate = fopen(TEMPLATE_ENG, "r"); if (ftemplate == NULL) { printf("template open error!!!."); exit(0); } while ( fgets(buf, 256, ftemplate) ) { if ( ptr = (char *)strstr(buf, "___IMAGE_PATH___") ) { *ptr = '\0'; printf("%s%s%s%s", buf, srcPath, srcFile, ptr+16); } else if ( ptr = (char *)strstr(buf, "___IMAGE_NAME___") ) { *ptr = '\0'; printf("%s%s%s", buf, srcFile, ptr+16); } else if ( ptr = (char *)strstr(buf, "___DESCRIPTION_FILE___") ) { *ptr = '\0'; printf("%s", buf); PrintDescFile(srcPath, srcFile); printf("%s", ptr+22); } else if ( ptr = (char *)strstr(buf, "___NODL_JAVASCRIPT___") ) { char tmpbuf[256]; if ( strstr(srcFile, "Jose_Sierra_Jr")) { printf("\n", srcFile); ftmp = fopen("HTMLSrc/NoD_L.javascript", "r"); if (ftmp == NULL) continue; while ( fgets(tmpbuf, 256, ftmp) ) { printf("%s", tmpbuf); } fclose(ftmp); } } else printf("%s", buf); } fclose(ftemplate); exit(0); } int PrintDescFile(srcPath, srcFile) char *srcPath; char *srcFile; { FILE *fp; char srcFileDesc[256]; char buf[256]; char buf2[256]; int i; strcpy(buf, srcFile); for (i = strlen(srcFile); i > 0; i--) { if (buf[i] == '.') { buf[i] = '\0'; break; } } while (1) { strcpy(srcFileDesc, srcPath); strcat(srcFileDesc, buf); strcat(srcFileDesc, ".txt"); if ( (fp=fopen(srcFileDesc, "r")) == NULL ) ; else { printf("
\n");
while(fgets(buf2, 256, fp))
PrintLink(buf2);
printf("\n");
fclose(fp);
break;
}
strcpy(srcFileDesc, srcPath);
strcat(srcFileDesc, buf);
strcat(srcFileDesc, ".TXT");
if ( (fp=fopen(srcFileDesc, "r")) == NULL ) ;
else
{
printf("\n");
while(fgets(buf2, 256, fp))
PrintLink(buf2);
printf("\n");
fclose(fp);
break;
}
strcpy(srcFileDesc, srcPath);
strcat(srcFileDesc, buf);
strcat(srcFileDesc, ".html");
if ( (fp=fopen(srcFileDesc, "r")) == NULL ) ;
else
{
printf("| \n");
while(fgets(buf2, 256, fp))
if (!(strstr(buf2, " |
\n"); printf("
\n