/* genfontcgihtml.c, 2009 Feb 14 * (C) Copyright Prem Sobel, 2005-2009. All Rights Reseeved. * * This program generates an HTML file for viewing all image files * of types: *.jpg, *.gif, *.png in a directory. Clicking on each * image invokes a cgi program which tiles that image and puts * text with a range of colors on top of it (to see which colors * can best be seen on that tiled image). */ #include #include #include #include static int row_size=4; static num_cells, mod_cells; static struct _finddata_t fileinfo; static char *cgiurl = "http://premsobel.info/cgi/tilefont.pl"; static char *fn = "zzz.html"; static char *title = "title"; static char Usage[] = "Usage: genfontcgihtml [-r row_size] [-f filename] " "[-c cgiurl] [-t title]\n" " (default row_size is 4)\n"; void fail(char *msg) { fprintf(stderr,"*** %s\n",msg); exit(1); } // fail void add_cell(FILE *fp_dir, char *pix_fn) { char fn_html[_MAX_PATH]; // take care of rows in fp_dir if(!mod_cells) { if(num_cells) fprintf(fp_dir, "\n\n"); fprintf(fp_dir, "\n"); } num_cells++; if(++mod_cells>=row_size) mod_cells=0; // take care of entry in fp_dir for this pix fprintf(fp_dir, "\n", pix_fn); /* fprintf(fp_dir, "%s
\n", pix_fn, cgiurl, pix_fn); fprintf(fp_dir, "
\n", pix_fn); */ } // add_cell void do_extension(FILE *fp_dir, char *ext) { long h, num=0; num_cells = 0; h = _findfirst(ext, &fileinfo); if(h>=0) { add_cell(fp_dir, fileinfo.name); while(!_findnext(h, &fileinfo)) { add_cell(fp_dir, fileinfo.name); } } _findclose(h); printf(" %d %s\n", num_cells, ext); } // do_extension int main(int argc, char* argv[]) { FILE *fp_dir; int n, m; // examine command line arguments for(n=1;n\n"); fprintf(fp_dir, "\n\n"); fprintf(fp_dir, " %s\n", title); fprintf(fp_dir, " \n", cgiurl); fprintf(fp_dir, "\n\n\n"); fprintf(fp_dir, "

%s

\n\n", title); fprintf(fp_dir, "\n\n"); do_extension(fp_dir, "*.jpg"); do_extension(fp_dir, "*.gif"); do_extension(fp_dir, "*.png"); fprintf(fp_dir, "\n\n"); fprintf(fp_dir, "
\n\n \n\n"); fclose(fp_dir); return 0; } // main