/* genlineshtml.c * by: Prem Sobel, 2008 Dec 20 * * This program generates an html file for viewing all images * in the current directory of type: *.gif, *.jpg, *.png * * This source code is free to all who wish to use it. * * To use program put copy of executable in a directory containing only * line image files, then execute program. This will generate file zzz.html * which contains a table with rows conisting of the name and image of each * image file in the directory. */ #include #include #include #include static struct _finddata_t fileinfo; static num_cells; void add_cell(FILE *fp, char *pix_fn) { // take care of entry for this pix num_cells++; fprintf(fp, "%s\n", pix_fn, pix_fn); } void do_extension(FILE *fp, char *ext) { long h, num=0; num_cells = 0; h = _findfirst(ext, &fileinfo); if(h>=0) { add_cell(fp, fileinfo.name); while(!_findnext(h, &fileinfo)) { add_cell(fp, fileinfo.name); } } _findclose(h); printf(" %d %s\n", num_cells, ext); } main() { char *fn="ZZZ.html"; static FILE *fp; fp = fopen(fn,"w"); if(!fp) { printf("@@@ unable to open file %s\n", fn); exit(1); } fprintf(fp, "\n"); fprintf(fp, "\nZZZ\n"); fprintf(fp, "\n\n"); fprintf(fp, "

ZZZ

\n\n"); fprintf(fp, "\n"); do_extension(fp, "*.gif"); do_extension(fp, "*.jpg"); do_extension(fp, "*.png"); fprintf(fp, "
\n\n \n\n"); fclose(fp); return 0; }