SCCS-vsn: usr.bin/at/atrun/atrun.c 4.3
-static char *sccsid = "@(#)atrun.c 4.2 (Berkeley) %G%";
+static char *sccsid = "@(#)atrun.c 4.3 (Berkeley) %G%";
/*
* Run programs submitted by at.
*/
#include <stdio.h>
/*
* Run programs submitted by at.
*/
#include <stdio.h>
#include <sys/dir.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/dir.h>
#include <time.h>
#include <sys/stat.h>
-# define DIR "/usr/spool/at"
+# define ATDIR "/usr/spool/at"
# define PDIR "past"
# define LASTF "/usr/spool/at/lasttimedone"
# define PDIR "past"
# define LASTF "/usr/spool/at/lasttimedone"
char **argv;
{
int tt, day, year, uniq;
char **argv;
{
int tt, day, year, uniq;
- struct direct dirent;
- FILE *dirf;
- char file[DIRSIZ+1];
+ struct direct *dirent;
+ DIR *dirp;
- if ((dirf = fopen(".", "r")) == NULL) {
+ if ((dirp = opendir(".")) == NULL) {
fprintf(stderr, "Cannot read at directory\n");
exit(1);
}
fprintf(stderr, "Cannot read at directory\n");
exit(1);
}
- while (fread((char *)&dirent, sizeof(dirent), 1, dirf) == 1) {
- if (dirent.d_ino==0)
+ while ((dirent = readdir(dirp)) != NULL) {
+ if (dirent->d_ino==0)
- strcpyn(file, dirent.d_name, DIRSIZ);
- file[DIRSIZ] = '\0';
- if (sscanf(file, "%2d.%3d.%4d.%2d", &year, &day, &tt, &uniq) != 4)
+ if (sscanf(dirent->d_name, "%2d.%3d.%4d.%2d", &year, &day, &tt, &uniq) != 4)
continue;
if (nowyear < year)
continue;
continue;
if (nowyear < year)
continue;
continue;
if (nowyear==year && nowdate==day && nowtime < tt)
continue;
continue;
if (nowyear==year && nowdate==day && nowtime < tt)
continue;
updatetime(nowtime);
exit(0);
}
updatetime(nowtime);
exit(0);
}