/* * preview.c * for Bioinfo Animal Pictures Archive * jskim@bulls.kordic.re.kr */ #include "preview.h" int main() { FILE *fp; char *srcFile, *srcPath; char previewFile[256]; char FilePath[256]; getentry entries[5]; int scaleFactor; /* Resizing Scale Down Factor */ 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, "animal5/Wswart37-3wolf.jpg"); strcpy(entries[1].name, "scaleFactor"); strcpy(entries[1].val, "104"); #else i = ProcessGetMethod( entries ); #endif for (x = 0; x <= i; x++) { if (!strcmp(entries[x].name, "img")) { strcpy(FilePath, entries[x].val); strcpy(buf, entries[x].val); while (ptr = (char *)strstr(buf, "/")) { strcpy(buf, ptr+1); } srcFile = (char *) malloc(strlen(buf)+1); strcpy(srcFile, buf); strcpy(buf, entries[x].val); ptr = (char *) strstr(buf, srcFile); *ptr = '\0'; srcPath = (char *) malloc(strlen(buf)+1); strcpy(srcPath, buf); continue; } if (!strcmp(entries[x].name, "scaleFactor")) { scaleFactor = atoi(entries[x].val); continue; } } if ( !(scaleFactor == 2 || scaleFactor == 4 || scaleFactor == 8)) { scaleFactor = 2; /* Default to 2 */ } printf("\n"); printf("
\n"); printf("\n");
exit(1);
}
}
}
else if (strstr(srcFile, ".gif") || strstr(srcFile, ".GIF"))
{
strcpy(previewFile, buf);
sprintf(buf, "-s%d.gif", scaleFactor);
strcat(previewFile, buf);
sprintf(buf, "%s/%s", PREVIEW_DIR, previewFile);
if ( (fp=fopen(buf, "r")) == NULL )
{
sprintf(buf, "%s %s%s | %s -scale 1/%d -gif > %s/%s",\
CJPEG, srcPath, srcFile, DJPEG, scaleFactor,\
PREVIEW_DIR, previewFile);
if (system(buf) == -1)
{
printf("problem in preview...
\n");
printf("",\
srcPath, srcFile);
printf("Click here to see full image
\n");
exit(1);
}
}
}
else
{
printf("The Image %s cannot be previewed.
\n", srcFile);
printf("", srcPath, srcFile);
printf("Click here to see full image
\n"); exit(0); } printf("
| ", srcPath, srcFile);
printf(" |
\n"); switch(scaleFactor) { case 2: printf("[Preview 1/4 size] ", srcPath, srcFile); printf("[Preview 1/8 size]
", srcPath, srcFile); break; case 4: printf("[Preview 1/2 size] ", srcPath, srcFile); printf("[Preview 1/8 size]
", srcPath, srcFile); break; case 8: printf("[Preview 1/2 size] ", srcPath, srcFile); printf("[Preview 1/4 size]
", srcPath, srcFile); break; default: break; } printf("
\n", URL_HOME); printf("
\n\n");
while (1)
{
strcpy(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, 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, buf);
strcat(srcFileDesc, ".html");
if ( (fp=fopen(srcFileDesc, "r")) == NULL ) ;
else
{
printf("");
while(fgets(buf2, 256, fp))
if (!(strstr(buf2, "
|