home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 June
/
SIMTEL_0692.cdr
/
msdos
/
dirutl
/
since_w.arc
/
SINCE.C
next >
Wrap
C/C++ Source or Header
|
1986-12-21
|
4KB
|
119 lines
#include <stdio.h>
#include <direct.h>
#include <dos.h>
struct dosdta {
unsigned char rsv[21]; /* reserved for DOS */
unsigned char attrib; /* attribute found */
unsigned int ftime; /* file's time */
unsigned int fdate; /* file's date */
long fsize; /* file size */
unsigned char fspec[13]; /* file name.typ,0 */
};
unsigned int when = 0;
char *amonth[] = { "January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December" };
int dmonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
void main(argc,argv)
int argc;
char **argv;
{
union REGS regs;
char holddir[65];
unsigned int mm,dd,yy;
if(argc != 4) {
fprintf(stderr,"Format is: since mm dd yy\n");
exit(100);
}
mm = atoi(argv[1]);
dd = atoi(argv[2]);
yy = atoi(argv[3]);
if((mm < 1) || (mm > 12)) {
fprintf(stderr,"When did they change the number of months in a year?\n");
exit(4);
}
if((( mm != 2) && (dmonth[mm-1] < dd)) || ((mm == 2) && (dd > 29))) {
fprintf(stderr,"When did they change the number of days in %s?\n",amonth[mm-1]);
exit(4);
}
if(((yy < 1980) && (yy > 99)) || (yy < 80)) {
fprintf(stderr,"Bad year, must be >= 1980 or >79 and < 100\n");
exit(4);
}
printf("Files since %02.2d-%02.2d-%d\t",mm,dd,yy);
if (yy >= 1980) yy -= 1980;
else yy -= 80;
yy <<= 9;
mm <<= 5;
when = ( yy | mm | dd);
printf("x\'%4.4x\'\n",when);
regs.x.ax = 0x4700; /* get current directory */
regs.x.si = (short)&holddir[1]; /* where to put it */
regs.x.dx = 0; /* default drive */
intdos(®s,®s); /* do it ... */
holddir[0] = '\\'; /* start off with backslash */
findmod("/"); /* start at root directory */
chdir(holddir); /* change to original directory */
}
findmod(s)
char *s;
{
static char allstr[] = "*.*";
struct dosdta my_dta;
char holddir[65];
union REGS regs;
unsigned i,k;
chdir(s); /* change to specified directory */
regs.x.si = (short)&holddir[1]; /* area to hold current directory */
regs.x.ax = 0x4700; /* get current directory function */
regs.x.dx = 0; /* default drive */
intdos(®s,®s);
holddir[0] = '\\';
if(holddir[1] == '\0') holddir[0] = '\0';
regs.x.dx = (short)&my_dta; /* new DTA */
regs.x.ax = 0x1a00; /* set DTA function */
intdos(®s,®s); /* do it ... */
regs.x.ax = 0x4e00; /* find first */
regs.x.dx = (short)&allstr[0]; /* *.* */
regs.x.cx = 0x10; /* include subdirectories */
intdos(®s,®s); /* do it */
while(regs.x.cflag == 0) {
if((my_dta.attrib & 0x10) && (my_dta.fspec[0] != '.')) {
findmod(my_dta.fspec);
chdir("..");
regs.x.dx = (short)&my_dta; /* new DTA */
regs.x.ax = 0x1a00; /* set DTA function */
intdos(®s,®s); /* do it ... */
}
else
if(my_dta.fdate >= when) {
k = (my_dta.fdate >> 9) + 1980;
printf("%02.2d-%02.2d-%d\t%s\\%s\n",
((my_dta.fdate & 0x1e0) >> 5),
(my_dta.fdate & 0x1f),
k,
holddir,my_dta.fspec);
}
regs.x.ax = 0x4f00; /* find first */
intdos(®s,®s); /* do it */
}
}