projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
more ANSI fixes
[unix-history]
/
usr
/
src
/
libexec
/
getty
/
main.c
diff --git
a/usr/src/libexec/getty/main.c
b/usr/src/libexec/getty/main.c
index
8306b17
..
09ba98f
100644
(file)
--- a/
usr/src/libexec/getty/main.c
+++ b/
usr/src/libexec/getty/main.c
@@
-1,39
+1,38
@@
-/*
- * 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 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
*/
#ifndef lint
char copyright[] =
*/
#ifndef lint
char copyright[] =
-"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+"@(#) Copyright (c) 1980
The
Regents of the University of California.\n\
All rights reserved.\n";
All rights reserved.\n";
-#endif
not lint
+#endif
/* not lint */
#ifndef lint
#ifndef lint
-static char sccsid[] = "@(#)main.c 5.10 (Berkeley) %G%";
-#endif not lint
-
-/*
- * getty -- adapt to terminal speed on dialup, and call login
- *
- * Melbourne getty, June 83, kre.
- */
+static char sccsid[] = "@(#)main.c 5.14 (Berkeley) %G%";
+#endif /* not lint */
#define USE_OLD_TTY
#define USE_OLD_TTY
+
#include <sys/param.h>
#include <sys/param.h>
-#include <sys/signal.h>
-#include <sys/file.h>
+#include <sys/stat.h>
+#include <signal.h>
+#include <fcntl.h>
#include <sgtty.h>
#include <sgtty.h>
+#include <time.h>
#include <ctype.h>
#include <setjmp.h>
#include <syslog.h>
#include <ctype.h>
#include <setjmp.h>
#include <syslog.h>
+#include <unistd.h>
#include <ctype.h>
#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
#include "gettytab.h"
#include "pathnames.h"
#include "gettytab.h"
#include "pathnames.h"
-extern char **environ;
-
struct sgttyb tmode = {
0, 0, CERASE, CKILL, 0
};
struct sgttyb tmode = {
0, 0, CERASE, CKILL, 0
};
@@
-46,10
+45,7
@@
struct ltchars ltc = {
CFLUSH, CWERASE, CLNEXT
};
CFLUSH, CWERASE, CLNEXT
};
-int crmod;
-int upper;
-int lower;
-int digit;
+int crmod, digit, lower, upper;
char hostname[MAXHOSTNAMELEN];
char name[16];
char hostname[MAXHOSTNAMELEN];
char name[16];
@@
-93,6
+89,7
@@
char partab[] = {
jmp_buf timeout;
jmp_buf timeout;
+static void
dingdong()
{
dingdong()
{
@@
-103,6
+100,7
@@
dingdong()
jmp_buf intrupt;
jmp_buf intrupt;
+static void
interrupt()
{
interrupt()
{
@@
-111,8
+109,10
@@
interrupt()
}
main(argc, argv)
}
main(argc, argv)
- char *argv[];
+ int argc;
+ char **argv;
{
{
+ extern char **environ;
char *tname;
long allflags;
int repcnt = 0;
char *tname;
long allflags;
int repcnt = 0;
@@
-174,7
+174,7
@@
main(argc, argv)
setdefaults();
ioctl(0, TIOCFLUSH, 0); /* clear out the crap */
ioctl(0, FIONBIO, &off); /* turn off non-blocking mode */
setdefaults();
ioctl(0, TIOCFLUSH, 0); /* clear out the crap */
ioctl(0, FIONBIO, &off); /* turn off non-blocking mode */
- ioctl(0, FIOASYNC, &off); /* ditto for async
hronous
mode */
+ ioctl(0, FIOASYNC, &off); /* ditto for async mode */
if (IS)
tmode.sg_ispeed = speed(IS);
else if (SP)
if (IS)
tmode.sg_ispeed = speed(IS);
else if (SP)
@@
-187,7
+187,6
@@
main(argc, argv)
ioctl(0, TIOCSETP, &tmode);
setchars();
ioctl(0, TIOCSETC, &tc);
ioctl(0, TIOCSETP, &tmode);
setchars();
ioctl(0, TIOCSETC, &tc);
- ioctl(0, TIOCSETD, &ldisp);
if (HC)
ioctl(0, TIOCHPCL, 0);
if (AB) {
if (HC)
ioctl(0, TIOCHPCL, 0);
if (AB) {
@@
-242,6
+241,12
@@
main(argc, argv)
for (i = 0; environ[i] != (char *)0; i++)
env[i] = environ[i];
makeenv(&env[i]);
for (i = 0; environ[i] != (char *)0; i++)
env[i] = environ[i];
makeenv(&env[i]);
+
+ /*
+ * this is what login was doing anyway.
+ * soon we rewrite getty completely.
+ */
+ set_ttydefaults(0);
execle(LO, "login", "-p", name, (char *) 0, env);
syslog(LOG_ERR, "%s: %m", LO);
exit(1);
execle(LO, "login", "-p", name, (char *) 0, env);
syslog(LOG_ERR, "%s: %m", LO);
exit(1);
@@
-256,8
+261,8
@@
main(argc, argv)
getname()
{
getname()
{
+ register int c;
register char *np;
register char *np;
- register c;
char cs;
/*
char cs;
/*
@@
-278,14
+283,11
@@
getname()
PF = 0;
}
ioctl(0, TIOCSETP, &tmode);
PF = 0;
}
ioctl(0, TIOCSETP, &tmode);
- crmod = 0;
- upper = 0;
- lower = 0;
- digit = 0;
+ crmod = digit = lower = upper = 0;
np = name;
for (;;) {
oflush();
np = name;
for (;;) {
oflush();
- if (read(
0
, &cs, 1) <= 0)
+ if (read(
STDIN_FILENO
, &cs, 1) <= 0)
exit(0);
if ((c = cs&0177) == 0)
return (0);
exit(0);
if ((c = cs&0177) == 0)
return (0);
@@
-296,9
+298,9
@@
getname()
break;
}
if (islower(c))
break;
}
if (islower(c))
- lower
++
;
+ lower
= 1
;
else if (isupper(c))
else if (isupper(c))
- upper
++
;
+ upper
= 1
;
else if (c == ERASE || c == '#' || c == '\b') {
if (np > name) {
np--;
else if (c == ERASE || c == '#' || c == '\b') {
if (np > name) {
np--;
@@
-329,7
+331,7
@@
getname()
signal(SIGINT, SIG_IGN);
*np = 0;
if (c == '\r')
signal(SIGINT, SIG_IGN);
*np = 0;
if (c == '\r')
- crmod
++
;
+ crmod
= 1
;
if (upper && !lower && !LC || UC)
for (np = name; *np; np++)
if (isupper(*np))
if (upper && !lower && !LC || UC)
for (np = name; *np; np++)
if (isupper(*np))
@@
-372,11
+374,10
@@
putpad(s)
return;
/*
return;
/*
- * Round up by a half a character frame,
- * and then do the delay.
+ * Round up by a half a character frame, and then do the delay.
* Too bad there are no user program accessible programmed delays.
* Too bad there are no user program accessible programmed delays.
- * Transmitting pad characters slows many
- *
terminals down and also
loads the system.
+ * Transmitting pad characters slows many
terminals down and also
+ * loads the system.
*/
mspc10 = tmspc10[tmode.sg_ospeed];
pad += mspc10 / 2;
*/
mspc10 = tmspc10[tmode.sg_ospeed];
pad += mspc10 / 2;
@@
-387,7
+388,6
@@
putpad(s)
puts(s)
register char *s;
{
puts(s)
register char *s;
{
-
while (*s)
putchr(*s++);
}
while (*s)
putchr(*s++);
}
@@
-408,13
+408,13
@@
putchr(cc)
if (obufcnt >= OBUFSIZ)
oflush();
} else
if (obufcnt >= OBUFSIZ)
oflush();
} else
- write(
1
, &c, 1);
+ write(
STDOUT_FILENO
, &c, 1);
}
oflush()
{
if (obufcnt)
}
oflush()
{
if (obufcnt)
- write(
1
, outbuf, obufcnt);
+ write(
STDOUT_FILENO
, outbuf, obufcnt);
obufcnt = 0;
}
obufcnt = 0;
}
@@
-429,10
+429,9
@@
prompt()
putf(cp)
register char *cp;
{
putf(cp)
register char *cp;
{
- char *slash;
- char datebuffer[60];
extern char editedhost[];
extern char editedhost[];
- extern char *rindex();
+ time_t t;
+ char *slash, db[100];
while (*cp) {
if (*cp != '%') {
while (*cp) {
if (*cp != '%') {
@@
-453,10
+452,15
@@
putf(cp)
puts(editedhost);
break;
puts(editedhost);
break;
- case 'd':
- get_date(datebuffer);
- puts(datebuffer);
+ case 'd': {
+ char fmt[] = "%l:% %P on %A, %d %B %Y";
+
+ fmt[4] = 'M'; /* I *hate* SCCS... */
+ (void)time(&t);
+ (void)strftime(db, sizeof(db), fmt, localtime(&t));
+ puts(db);
break;
break;
+ }
case '%':
putchr('%');
case '%':
putchr('%');