Deleted Added
full compact
at.c (82722) at.c (87208)
1/*
2 * at.c : Put file into atrun queue
3 * Copyright (C) 1993, 1994 Thomas Koenig
4 *
5 * Atrun & Atq modifications
6 * Copyright (C) 1993 David Parsons
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef lint
30static const char rcsid[] =
1/*
2 * at.c : Put file into atrun queue
3 * Copyright (C) 1993, 1994 Thomas Koenig
4 *
5 * Atrun & Atq modifications
6 * Copyright (C) 1993 David Parsons
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef lint
30static const char rcsid[] =
31 "$FreeBSD: head/usr.bin/at/at.c 82722 2001-09-01 07:35:25Z kris $";
31 "$FreeBSD: head/usr.bin/at/at.c 87208 2001-12-02 12:26:18Z markm $";
32#endif /* not lint */
33
34#define _USE_BSD 1
35
36/* System Headers */
37
38#include <sys/types.h>
39#include <sys/stat.h>

--- 53 unchanged lines hidden (view full) ---

93
94#define SIZE 255
95#define TIMESIZE 50
96
97enum { ATQ, ATRM, AT, BATCH, CAT }; /* what program we want to run */
98
99/* File scope variables */
100
32#endif /* not lint */
33
34#define _USE_BSD 1
35
36/* System Headers */
37
38#include <sys/types.h>
39#include <sys/stat.h>

--- 53 unchanged lines hidden (view full) ---

93
94#define SIZE 255
95#define TIMESIZE 50
96
97enum { ATQ, ATRM, AT, BATCH, CAT }; /* what program we want to run */
98
99/* File scope variables */
100
101char *no_export[] =
101const char *no_export[] =
102{
103 "TERM", "TERMCAP", "DISPLAY", "_"
104} ;
105static int send_mail = 0;
106
107/* External variables */
108
109extern char **environ;

--- 7 unchanged lines hidden (view full) ---

117
118/* Function declarations */
119
120static void sigc(int signo);
121static void alarmc(int signo);
122static char *cwdname(void);
123static void writefile(time_t runtimer, char queue);
124static void list_jobs(void);
102{
103 "TERM", "TERMCAP", "DISPLAY", "_"
104} ;
105static int send_mail = 0;
106
107/* External variables */
108
109extern char **environ;

--- 7 unchanged lines hidden (view full) ---

117
118/* Function declarations */
119
120static void sigc(int signo);
121static void alarmc(int signo);
122static char *cwdname(void);
123static void writefile(time_t runtimer, char queue);
124static void list_jobs(void);
125static long nextjob(void);
125
126/* Signal catching functions */
127
126
127/* Signal catching functions */
128
128static void sigc(int signo)
129static void sigc(int signo __unused)
129{
130/* If the user presses ^C, remove the spool file and exit
131 */
132 if (fcreated)
133 {
134 PRIV_START
135 unlink(atfile);
136 PRIV_END
137 }
138
139 _exit(EXIT_FAILURE);
140}
141
130{
131/* If the user presses ^C, remove the spool file and exit
132 */
133 if (fcreated)
134 {
135 PRIV_START
136 unlink(atfile);
137 PRIV_END
138 }
139
140 _exit(EXIT_FAILURE);
141}
142
142static void alarmc(int signo)
143static void alarmc(int signo __unused)
143{
144 char buf[1024];
145
146 /* Time out after some seconds. */
147 strlcpy(buf, namep, sizeof(buf));
148 strlcat(buf, ": file locking timed out\n", sizeof(buf));
149 write(STDERR_FILENO, buf, strlen(buf));
150 sigc(0);

--- 204 unchanged lines hidden (view full) ---

355 int export = 1;
356 char *eqp;
357
358 eqp = strchr(*atenv, '=');
359 if (ap == NULL)
360 eqp = *atenv;
361 else
362 {
144{
145 char buf[1024];
146
147 /* Time out after some seconds. */
148 strlcpy(buf, namep, sizeof(buf));
149 strlcat(buf, ": file locking timed out\n", sizeof(buf));
150 write(STDERR_FILENO, buf, strlen(buf));
151 sigc(0);

--- 204 unchanged lines hidden (view full) ---

356 int export = 1;
357 char *eqp;
358
359 eqp = strchr(*atenv, '=');
360 if (ap == NULL)
361 eqp = *atenv;
362 else
363 {
363 int i;
364 size_t i;
364 for (i=0; i<sizeof(no_export)/sizeof(no_export[0]); i++)
365 {
366 export = export
367 && (strncmp(*atenv, no_export[i],
368 (size_t) (eqp-*atenv)) != 0);
369 }
370 eqp++;
371 }

--- 119 unchanged lines hidden (view full) ---

491 if(sscanf(dirent->d_name, "%c%5lx%8lx", &queue, &jobno, &ctm)!=3)
492 continue;
493
494 if (atqueue && (queue != atqueue))
495 continue;
496
497 runtimer = 60*(time_t) ctm;
498 runtime = *localtime(&runtimer);
365 for (i=0; i<sizeof(no_export)/sizeof(no_export[0]); i++)
366 {
367 export = export
368 && (strncmp(*atenv, no_export[i],
369 (size_t) (eqp-*atenv)) != 0);
370 }
371 eqp++;
372 }

--- 119 unchanged lines hidden (view full) ---

492 if(sscanf(dirent->d_name, "%c%5lx%8lx", &queue, &jobno, &ctm)!=3)
493 continue;
494
495 if (atqueue && (queue != atqueue))
496 continue;
497
498 runtimer = 60*(time_t) ctm;
499 runtime = *localtime(&runtimer);
499 strftime(timestr, TIMESIZE, "%X %x", &runtime);
500 strftime(timestr, TIMESIZE, "%+", &runtime);
500 if (first) {
501 printf("Date\t\t\tOwner\tQueue\tJob#\n");
502 first=0;
503 }
504 pw = getpwuid(buf.st_uid);
505
506 printf("%s\t%s\t%c%s\t%ld\n",
507 timestr,

--- 88 unchanged lines hidden (view full) ---

596int
597main(int argc, char **argv)
598{
599 int c;
600 char queue = DEFAULT_AT_QUEUE;
601 char queue_set = 0;
602 char *pgm;
603
501 if (first) {
502 printf("Date\t\t\tOwner\tQueue\tJob#\n");
503 first=0;
504 }
505 pw = getpwuid(buf.st_uid);
506
507 printf("%s\t%s\t%c%s\t%ld\n",
508 timestr,

--- 88 unchanged lines hidden (view full) ---

597int
598main(int argc, char **argv)
599{
600 int c;
601 char queue = DEFAULT_AT_QUEUE;
602 char queue_set = 0;
603 char *pgm;
604
604 enum { ATQ, ATRM, AT, BATCH, CAT }; /* what program we want to run */
605 int program = AT; /* our default program */
605 int program = AT; /* our default program */
606 char *options = "q:f:mvldbVc"; /* default options for at */
606 const char *options = "q:f:mvldbVc";/* default options for at */
607 int disp_version = 0;
608 time_t timer;
609
610 RELINQUISH_PRIVS
611
612 /* Eat any leading paths
613 */
614 if ((pgm = strrchr(argv[0], '/')) == NULL)

--- 154 unchanged lines hidden ---
607 int disp_version = 0;
608 time_t timer;
609
610 RELINQUISH_PRIVS
611
612 /* Eat any leading paths
613 */
614 if ((pgm = strrchr(argv[0], '/')) == NULL)

--- 154 unchanged lines hidden ---