home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
PPPBCKP
/
SRC15B50.ZIP
/
PPPURGE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1997-04-27
|
1KB
|
56 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <dos.h>
#include <dir.h>
#include <time.h>
#include <process.h>
#include <sys/stat.h>
#include "version.h"
#pragma warn -par
void main(int argc, char *argv[])
{
char s[121], buf[MAXPATH];
int f1, howmany = 0, kbytes = 0;
unsigned int KEEPSENT = 99;
long age;
struct ffblk ff;
struct stat fileinfo;
fprintf(stderr, "\n\nPPP Sent Packet Purger %s", VERSION);
fprintf(stderr, "\nContact Frank Reid at edare@abs.net or 1@8213.WWIVnet for support\n");
if (!argv[1]) {
printf("\n ■ Run PPPurge <days> to delete packets older than <days>.\n\n ");
exit(0);
}
KEEPSENT = atoi(argv[1]);
printf("\n ■ Purging sent packets older than %d days.", KEEPSENT);
getcwd(buf,MAXPATH);
sprintf(s, "%s\\SENT\\*.*",buf);
f1 = findfirst(s, &ff, 0);
while (f1 == 0) {
sprintf(s, "%s\\SENT\\%s",buf, ff.ff_name);
if (stat(s, &fileinfo) == 0) {
age = (time(NULL) - fileinfo.st_atime);
if (age > (86400L * (KEEPSENT+1))) {
kbytes += fileinfo.st_size/1024;
++howmany;
unlink(s);
}
}
f1 = findnext(&ff);
}
printf("\n ■ Deleted %dKB in %d files.\n\n", kbytes, howmany);
exit(0);
}