/* wildcard.c */ /* Author: * Guntram Blohm * Buchenstrasse 19 * 7904 Erbach, West Germany * Tel. ++49-7305-6997 * sorry - no regular network connection */ /* this program implements wildcard expansion for elvis/dos. It works * like UNIX echo, but uses the dos wildcard conventions * (*.* matches all files, * matches files without extension only, * filespecs may contain drive letters, wildcards not allowed in directory * names). * * It is also #included into ctags.c, ref.c, ...; in this case, * we don't want a main function here. */ #include #include #ifdef __TURBOC__ #include #endif #ifdef M_I86 #define findfirst(a,b,c) _dos_findfirst(a,c,b) #define findnext _dos_findnext #define ffblk find_t #define ff_name name #include #endif #ifdef M68000 #include #include #define findfirst(a,b,c) (Fsetdta(b), (Fsfirst(a,c))) #define findnext(x) (Fsnext()) #define ff_name d_fname #endif #define MAXFILES 1000 int pstrcmp(); extern char *calloc(); char *files[MAXFILES]; int nfiles; #ifndef WILDCARD_NO_MAIN main(argc, argv) char **argv; { int i; for (i=1; i=buf) { if (*filespec=='?' || *filespec=='*') wildcard=1; if (*filespec=='/' || *filespec=='\\' || *filespec==':') break; } if (!wildcard) addfile(buf); else { lastn=nfiles; filespec++; if ((err=findfirst(buf, &findbuf, 0))!=0) addfile(buf); while (!err) { strcpy(filespec, findbuf.ff_name); addfile(buf); err=findnext(&findbuf); } if (lastn!=nfiles) qsort(files+lastn, nfiles-lastn, sizeof(char *), pstrcmp); } } addfile(buf) char *buf; { char *p; for (p=buf; *p; p++) *p=tolower(*p); if (nfiles