//----- // // HFI - Commandlineversion - WATCOM C/C++ 11.0 // 04.1998 by bingen@gmx.de - use m.bat to compile // upd 1.05 - 06.1998 - sorting mainindex, if no subs no mainindexlink // //----- #include #include #include #include #include #include #define TRUE 1 #define FALSE 0 #define MAXWERT 2000 //soviele files sollten wohl reichen, oder? #define MAX_PATH 500 //laengste rekursion #define MAX_FNLEN 255 //laengster filename #define MAX_DIRS 500 #define PROGVERSION "1.05" //na was wohl? #define COPYR "(c)1998 by -BiNGEN- (bingen@gmx.de)" #define COMMENTSTR "\n" #define METASTR "\n" #define VERSIONSTR "HFI "PROGVERSION"/"OS_VERSION #ifdef WINNT #define OS_VERSION "winnt32" #endif #ifdef DOS4G #define OS_VERSION "dos4gw" #endif char outframe[20]; char mainframe[20]; char colorstr[100]; char fnames[MAXWERT][MAX_FNLEN]; int anz_fnames; char spec[15][15]; int anz_spec; char dirnames[MAX_DIRS][MAX_PATH]; int anz_dirs; int home_len; int subs; /*****************************************************************************/ void makeframe(char *path ,char *filename) { FILE *stream; char akt_file[MAX_PATH]; sprintf(akt_file,"%s\\%s", path, mainframe); if((stream=fopen(akt_file,"w"))!=NULL) { fputs("\n", stream); fputs(METASTR, stream); fputs(COMMENTSTR, stream); fputs("Index of ", stream); fputs(&path[home_len], stream); fputs("\n", stream); fputs("\n", stream); fputs("\n", stream); fputs("\n\n", stream); fclose(stream); } else printf("..can't open %s\n", akt_file); } /*****************************************************************************/ long buildarray(char *path) { struct _finddata_t fileinfo; long handle, bytes; int rc; char tausch[MAX_FNLEN]; char akt_file[MAX_PATH]; register int i, j; anz_fnames=0; bytes=0L; for(i=0;iMAXWERT-1) { printf("*.file-overflow! (more than %d files)\n", MAXWERT); break; } else { if (strcmp(fileinfo.name,"..")!=0 && strcmp(fileinfo.name,".")!=0 && !(fileinfo.attrib&_A_SUBDIR)) { strcpy(fnames[anz_fnames++], fileinfo.name); bytes+=fileinfo.size; } } rc=_findnext(handle, &fileinfo); } _findclose(handle); } // fuer die paar strings reicht ein bubblesort for(i=0;i0) { strcpy(tausch, fnames[i]); strcpy(fnames[i], fnames[j]); strcpy(fnames[j], tausch); } } } return(bytes); } /*****************************************************************************/ void usage(void) { printf(".compiled with watcom c/c++ 11.0. edited with zeus32 2.60.\n"); printf(" (the dos4gw-version needs dos4gw.exe, the winnt-version windows95/nt)\n\n"); printf(".status: freeware. use as often as you want.\n"); printf(".update: if any... check out http://www.lastresort.net.\n\n"); printf(".description:\nthis cute, little program builds a html-index of the files in a directory.\n"); printf("it uses frames. on the left are the filenames, right the file itself.\n\n"); printf(".main purpose:\ncreating indexes for cd-rom's with jpg's or other media.\n\n"); //printf("[more]\n\n"); getch(); printf(".arguments:\n -?, /? - this help.\n"); printf(" /s - include all subdirs.\n"); printf(" /t[x] - filetypes (i=jpg,gif (default) / t=txt,doc / s=wav,mid,mp3).\n"); printf(" (h=htm,html / m=avi,mpg,mov / *=all filetypes).\n\n"); printf(".example: hfi /th /tt (make index with all htm/txt/doc files).\n"); exit(0); } /*****************************************************************************/ char *makedots(char *in) { register int i; char out[MAX_FNLEN]=""; for(i=0;iMAX_DIRS-1) printf("*.dir-overflow! (more than %d dirs)\n", MAX_DIRS); else strcpy(dirnames[anz_dirs++], path); // geht zwar, aber nicht unbedingt sinnvoll //strlen(&path[home_len])==0?strcpy(outstr,"\\"): strcpy(outstr,&path[home_len]); makeframe(path, fnames[0]); printf("..processing %s (%i bytes)\n", path, bytes); fputs("\n", stream); fputs(METASTR, stream); fputs("\n", stream); fputs("Index of ", stream); fputs(&path[home_len], stream); fputs("\n\nIndex of ", stream); fputs(&path[home_len], stream); fputs("
\n", stream); // nur wenn mit subs if(subs) { strcpy(dotstr, &path[home_len]); sprintf(outstr, "MainIndex
\n", makedots(dotstr)); fputs(outstr, stream); } for(i=0;i%s
\n", fnames[i], fnames[i]); fputs(outstr, stream); } fputs("
Top of Page\n", stream); fputs("
\n", stream); fclose(stream); } else printf("..can't open %s\n", akt_file); } else printf("..no matching files in %s\n", path); } /*****************************************************************************/ void scandirs(char *path) { struct find_t fileinfo; char akt_pfad[MAX_PATH]; strcpy(akt_pfad, path); strcat(akt_pfad, "\\*.*"); if (_dos_findfirst(akt_pfad, _A_SUBDIR ,&fileinfo)==0) { do { if (strcmp(fileinfo.name,"..")!=0) { if (strlen(path)+strlen(fileinfo.name)>=MAX_PATH) { printf("..path: %s sub: %s\n..recursion too deep!\n", akt_pfad, fileinfo.name); } else { if(strcmp(fileinfo.name,".")==0) { // darum gehts eigentlich =;-) makepage(path); } else { // kleine rekursion :-) strcpy(akt_pfad, path); strcat(akt_pfad, "\\"); strcat(akt_pfad, fileinfo.name); scandirs(akt_pfad); } } } } while ((_dos_findnext(&fileinfo)==0)); } } /*****************************************************************************/ char *tweakdirname(char *in, char *path) { register int i, k=strlen(in)-strlen(path); for(i=strlen(path)+1;i0) { strcpy(tausch, dirnames[i]); strcpy(dirnames[i], dirnames[j]); strcpy(dirnames[j], tausch); } } } strcpy(outfile, path); strcat(outfile, "\\index.htm"); if((stream=fopen(outfile,"w"))!=NULL) { printf("..building mainindex %s\n", outfile); fputs("\n", stream); fputs(METASTR, stream); fputs(COMMENTSTR, stream); fputs("Index created by ", stream); fputs(VERSIONSTR, stream); fputs("\n", stream); fputs(">\n

Index created by ", stream); fputs(VERSIONSTR, stream); fputs("


\n", stream); for(i=0;i%s
\n", dirnames[i], mainframe, dirnames[i]); fputs(outstr, stream); } fputs("
\n", stream); fclose(stream); } else printf("..can't open %s\n", outfile); } } /*****************************************************************************/ void main(int argc, char *argv[]) { char homedir[MAX_FNLEN]; register int i; anz_spec=anz_dirs=0; subs=FALSE; printf("\nHFI "PROGVERSION" - html-file-indexer ("OS_VERSION")\n"); printf(COPYR" * use /? for help.\n\n"); // gibts argumente dafuer? ;-) for (i=1;i