* Copyright (c) 1980 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific written prior permission. This software
* is provided ``as is'' without express or implied warranty.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)leave.c 5.2 (Berkeley) %G%";
* Reminds you when you have to leave.
* Leave prompts for input and goes away if you hit return.
* It nags you like a mother hen.
long when
, now
, diff
, hours
, minutes
;
if ((cp
= getlogin()) == NULL
) {
fputs("leave: You are not logged in.\n", stderr
);
printf("When do you have to leave? ");
buff
[read(0, buff
, sizeof buff
)] = 0;
if (!gethm(cp
, &hours
, &minutes
))
if (minutes
< 0 || minutes
> 59)
if (!gethm(cp
, &hours
, &minutes
))
if (hours
< 0 || hours
> 12 || minutes
< 0 || minutes
> 59)
nv
[2] -= 12; /* do am/pm bit */
fprintf(stderr
, "That time has already passed!\n");
fprintf(stderr
, "usage: leave [[+]hhmm]\n");
while ((c
= *cp
++) != '\0') {
tod
= tod
* 10 + (c
- '0');
char *msg1
, *msg2
, *msg3
, *msg4
;
int slp1
, slp2
, slp3
, slp4
;
msg1
= "You have to leave in 5 minutes";
msg2
= "Just one more minute!";
msg4
= "You're going to be late!";
whenleave
= ctime(&daytime
);
printf("Alarm set for %s", whenleave
);
signal(SIGQUIT
, SIG_IGN
);
signal(SIGTERM
, SIG_IGN
);
signal(SIGTTOU
, SIG_IGN
);
printf("That was the last time I'll tell you. Bye.\n");
printf("\7\7\7%s\n", msg
);
* delay is like sleep but does it in 100 sec pieces and
if (strcmp(origlogin
, l
) != 0)
ufd
= open("/etc/utmp",0);
seek(ufd
, ttyn(0)*sizeof(ubuf
), 0);
read(ufd
, &ubuf
, sizeof(ubuf
));
ubuf
.ut_name
[sizeof(ubuf
.ut_name
)] = 0;