Category : File Managers
Archive   : DIRF.ZIP
Filename : DIRF.C
** DIRF V1.0 -- Finds files containing a certain string.
** Compiled with Turbo C, version 1.0
**
** The syntax is: DIRF string [filespec]
** If filespec is omitted, *.* is assumed.
**
** Written by Scott Houck 12 July 1987
*/
#include
#include
#include
#include
#include
/*-------------------*/
/* M Y S T R S T R */
/*-------------------*/
/*
** Returns a pointer to the first occurrence of the substring in the
** string, or NULL if the substring was not found. This function is
** used instead of the Turbo C function strstr because of a bug in
** that function. The bug is that a null pointer is returned if the
** substring occurs at the end of the string.
*/
char *mystrstr(string, substring)
char *string, *substring;
{
char *p1, *p2, *p3;
for (p1 = string; *p1; p1++)
for (p2 = p1, p3 = substring; *p2 == *p3; p2++, p3++)
if (*(p3+1) == '\0')
return (p1); /* the substring was found */
return (NULL); /* the substring was not found */
}
/*-----------*/
/* M A I N */
/*-----------*/
main(argc, argv)
int argc;
char *argv[];
{
int i, done, len, month, day, year, hours, mins, hits = 0;
char *p, filespec[64], ampm;
struct ffblk ffblk;
printf("DIRF V1.0 by Scott Houck\n\n");
if (argc < 2)
{
printf("Syntax: DIRF string [filespec]\n");
exit(0);
}
if (argc == 3)
strcpy(filespec, argv[2]);
else
strcpy(filespec, "*.*");
/*
** If user enters something like "\dos" for the filespec, change
** it to "\dos\*.*"
*/
if (strchr(filespec, '\\') != NULL &&
strchr(filespec, '*') == NULL &&
strchr(filespec, '?') == NULL)
if (filespec[strlen(filespec)-1] == '\\')
strcat(filespec, "*.*");
else
strcat(filespec, "\\*.*");
if (strlen(filespec) > 63)
{
fprintf(stderr, "Filespec is too long\n");
exit(1);
}
printf("Directory of %s\n", filespec);
printf("Files containing string \"%s\"\n\n", argv[1]);
strlwr(argv[1]);
len = strlen(argv[1]);
done = findfirst(filespec, &ffblk, FA_DIREC);
while (!done)
{
if ((p = mystrstr(strlwr(ffblk.ff_name), argv[1])) != NULL)
{
hits++;
/* capitalize the search string in the file */
for (i = 0; i < len; *p++ = toupper(*p), i++);
month = (ffblk.ff_fdate >> 5) & 0x0f;
day = ffblk.ff_fdate & 0x1f;
year = (ffblk.ff_fdate >> 9) + 80;
hours = ffblk.ff_ftime >> 11;
ampm = 'a';
if (hours >= 12)
{
hours -= 12;
ampm = 'p';
}
if (hours == 0)
hours = 12;
mins = (ffblk.ff_ftime >> 5) & 0x3f;
if (ffblk.ff_attrib & FA_DIREC)
printf("%-12s %-8s %2d-%02d-%02d %2d:%02d%c\n",
ffblk.ff_name, "
mins, ampm);
else
printf("%-12s %8ld %2d-%02d-%02d %2d:%02d%c\n",
ffblk.ff_name, ffblk.ff_fsize, month, day, year,
hours, mins, ampm);
}
done = findnext(&ffblk);
}
printf("%s%d file%s found\n", hits == 0 ? "" : "\n", hits,
hits == 1 ? "" : "s");
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/