/* * NewImg.c * for Bioinfo Animal Pictures Archive * jskim@bulls.kordic.re.kr */ #include #include #include #include #define NEW_IMG_DIR "New" #define HTML_TEMPLATE "HTMLSrc/NewImg.html" #define CGI_PREVIEW "preview.cgi" #define CGI_VIEW "ViewImg.cgi" #define CGI_MAIL "uu2mail.cgi" main() { FILE *fp; DIR *dirp; struct dirent *direntp; char *ptr; char line[256]; printf("content-type: text/html\n\n"); /* HTML Header */ fp = fopen(HTML_TEMPLATE, "r"); if (fp == NULL) { printf("HTML template error\n"); exit(0); } while (fgets(line, 256, fp)) { if (!strncasecmp(line, "__RESULT__", 10)) { printf("
    \n"); dirp = opendir( NEW_IMG_DIR ); while ( (direntp = readdir( dirp )) != NULL ) { ptr = (char *) strstr(direntp->d_name, "."); if (!strcasecmp(ptr+1, "JPG") || !strcasecmp(ptr+1, "gif")) PrintImgInfo(direntp->d_name); } } else printf("%s", line); } printf("
\n"); closedir( dirp ); fclose(fp); exit(0); } int PrintImgInfo(char *name) { char path[256]; /* path */ struct stat stat; sprintf(path, "%s/%s", NEW_IMG_DIR, name); lstat(path, &stat); printf( "
  • \n", CGI_PREVIEW, path); printf( "\t\n", CGI_VIEW, path); printf( "\t%s (%dbytes)\n", name, stat.st_size ); printf( "[mail it]\n", CGI_MAIL, path); return 0; }