* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)leave.c 5.1 (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
, tod
, now
, diff
, hours
, minutes
;
strcpy(origlogin
, getlogin());
printf("When do you have to leave? ");
buff
[read(0, buff
, sizeof buff
)] = 0;
if (*cp
< '0' || *cp
> '9')
if (minutes
< 0 || minutes
> 59)
if (*cp
< '0' || *cp
> '9')
if (hours
< 0 || hours
> 12 || minutes
< 0 || minutes
> 59)
nv
[2] -= 12; /* do am/pm bit */
printf("That time has already passed!\n");
printf("usage: leave [[+]hhmm]\n");
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
, getlogin()))
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;