version 1.30.2.1, 2003/03/18 04:06:47 |
version 1.31, 2002/11/20 19:57:19 |
|
|
#include <err.h> |
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <limits.h> |
|
#include <locale.h> |
#include <locale.h> |
#include <pwd.h> |
#include <pwd.h> |
#include <signal.h> |
#include <signal.h> |
|
|
} |
} |
|
|
static void |
static void |
print_job(struct atjob *job, int n, int shortformat) |
print_job(struct atjob *job, int n, struct stat *st, int shortformat) |
{ |
{ |
struct passwd *pw; |
struct passwd *pw; |
struct tm runtime; |
struct tm runtime; |
|
|
(void)printf("%ld.%c\t%s\n", (long)job->runtimer, |
(void)printf("%ld.%c\t%s\n", (long)job->runtimer, |
job->queue, timestr); |
job->queue, timestr); |
} else { |
} else { |
pw = getpwuid(job->uid); |
pw = getpwuid(st->st_uid); |
/* Rank hack shamelessly stolen from lpq */ |
/* Rank hack shamelessly stolen from lpq */ |
if (n / 10 == 1) |
if (n / 10 == 1) |
printf("%3d%-5s", n,"th"); |
printf("%3d%-5s", n,"th"); |
|
|
(void)printf("%-21.18s%-11.8s%10ld.%c %c%s\n", |
(void)printf("%-21.18s%-11.8s%10ld.%c %c%s\n", |
timestr, pw ? pw->pw_name : "???", |
timestr, pw ? pw->pw_name : "???", |
(long)job->runtimer, job->queue, job->queue, |
(long)job->runtimer, job->queue, job->queue, |
(S_IXUSR & job->mode) ? "" : " (done)"); |
(S_IXUSR & st->st_mode) ? "" : " (done)"); |
} |
} |
} |
} |
|
|
|
|
err(EXIT_FAILURE, "malloc"); |
err(EXIT_FAILURE, "malloc"); |
job->runtimer = runtimer; |
job->runtimer = runtimer; |
job->ctime = stbuf.st_ctime; |
job->ctime = stbuf.st_ctime; |
job->uid = stbuf.st_uid; |
|
job->mode = stbuf.st_mode; |
|
job->queue = queue; |
job->queue = queue; |
if (numjobs == maxjobs) { |
if (numjobs == maxjobs) { |
maxjobs *= 2; |
maxjobs *= 2; |
|
|
"Job Queue"); |
"Job Queue"); |
|
|
for (i = 0; i < numjobs; i++) { |
for (i = 0; i < numjobs; i++) { |
print_job(atjobs[i], i + 1, shortformat); |
print_job(atjobs[i], i + 1, &stbuf, shortformat); |
free(atjobs[i]); |
free(atjobs[i]); |
} |
} |
free(atjobs); |
free(atjobs); |
|
|
job_matches = (argc == 0) ? 1 : 0; |
job_matches = (argc == 0) ? 1 : 0; |
if (!job_matches) { |
if (!job_matches) { |
for (i = 0; i < jobs_len; i++) { |
for (i = 0; i < jobs_len; i++) { |
if (jobs[i] != NULL && |
if (strcmp(dirent->d_name, jobs[i]) == 0) { |
strcmp(dirent->d_name, jobs[i]) == 0) { |
|
jobs[i] = NULL; |
jobs[i] = NULL; |
job_matches = 1; |
job_matches = 1; |
break; |
break; |