Update getty.

This commit is contained in:
Serge
2022-06-19 20:44:39 -07:00
parent 552f5ed4c2
commit c6f46414ed
6 changed files with 57 additions and 31 deletions

View File

@@ -153,6 +153,7 @@ int chroot(const char *path);
int fsync(int fd);
int getpagesize(void);
int symlink(const char *target, const char *linkpath);
int vhangup(void);
#ifndef _VA_LIST_
# ifdef __GNUC__

View File

@@ -5,6 +5,7 @@
*/
#include <stdio.h>
#include <sys/time.h>
#include "gettytab.h"
static char *days[] = {
"Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"
@@ -18,7 +19,7 @@ static char *months[] = {
#define AM "am"
#define PM "pm"
get_date(datebuffer)
void get_date(datebuffer)
char *datebuffer;
{
register struct tm *tmp;

View File

@@ -5,19 +5,24 @@
*/
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include "gettytab.h"
#define TABBUFSIZ 512
static char *tbuf;
int hopcount; /* detect infinite loops in termcap, init 0 */
char *getstr();
static int namatch(char *np);
static int nchktc(void);
/*
* Get an entry for terminal name in buffer bp,
* from the termcap file. Parse is very rudimentary;
* we just notice escaped newlines.
*/
getent(bp, name)
int getent(bp, name)
char *bp, *name;
{
register char *cp;
@@ -76,7 +81,8 @@ getent(bp, name)
* Note that this works because of the left to right scan.
*/
#define MAXHOP 32
nchktc()
int nchktc()
{
register char *p, *q;
char tcname[16]; /* name of similar terminal */
@@ -123,7 +129,7 @@ nchktc()
* against each such name. The normal : terminator after the last
* name (before the first field) stops us.
*/
namatch(np)
int namatch(np)
char *np;
{
register char *Np, *Bp;
@@ -203,7 +209,7 @@ getnum(id)
* of the buffer. Return 1 if we find the option, or 0 if it is
* not given.
*/
getflag(id)
int getflag(id)
char *id;
{
register char *bp = tbuf;

View File

@@ -108,3 +108,13 @@ extern struct gettyflags gettyflags[];
extern struct gettynums gettynums[];
extern struct gettystrs gettystrs[];
extern int hopcount;
void gettable(char *name, char *buf, char *area);
void gendefaults(void);
void setdefaults(void);
int speed(long val);
void setchars(void);
char *portselector(void);
void edithost(char *pat);
void makeenv(char *env[]);
void get_date(char *datebuffer);

View File

@@ -15,7 +15,10 @@
#include <ctype.h>
#include <setjmp.h>
#include <syslog.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/file.h>
#include <sys/stat.h>
#include "gettytab.h"
extern char **environ;
@@ -42,8 +45,6 @@ char name[16];
char dev[] = "/dev/";
char ctty[] = "/dev/console";
char ttyn[32];
char *portselector();
char *ttyname();
#define OBUFSIZ 128
#define TABBUFSIZ 512
@@ -78,6 +79,13 @@ char partab[] = {
#define KILL tmode.sg_kill
#define EOT tc.t_eofc
static void putpad(char *s);
static void putf(char *cp);
static int getname(void);
static void oflush(void);
static void putchr(int cc);
static void prompt(void);
jmp_buf timeout;
void dingdong(sig)
@@ -97,7 +105,7 @@ void interrupt(sig)
longjmp(intrupt, 1);
}
main(argc, argv)
int main(argc, argv)
char *argv[];
{
register char *tname;
@@ -155,7 +163,7 @@ main(argc, argv)
tname = "default";
if (argc > 1)
tname = argv[1];
ioctl(0, TIOCGETP, &tmode);
ioctl(0, TIOCGETP, &tmode);
for (;;) {
int ldisp = NTTYDISC;
@@ -241,10 +249,10 @@ void putstr(s)
putchr(*s++);
}
getname()
int getname()
{
register char *np;
register c;
register int c;
char cs;
/*
@@ -325,11 +333,11 @@ short tmspc10[] = {
0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5, 15
};
putpad(s)
void putpad(s)
register char *s;
{
register pad = 0;
register mspc10;
register int pad = 0;
register int mspc10;
if (isdigit(*s)) {
while (isdigit(*s)) {
@@ -370,7 +378,7 @@ putpad(s)
char outbuf[OBUFSIZ];
int obufcnt = 0;
putchr(cc)
void putchr(cc)
{
char c;
@@ -387,22 +395,21 @@ putchr(cc)
write(1, &c, 1);
}
oflush()
void oflush()
{
if (obufcnt)
write(1, outbuf, obufcnt);
obufcnt = 0;
}
prompt()
void prompt()
{
putf(LM);
if (CO)
putchr('\n');
}
putf(cp)
void putf(cp)
register char *cp;
{
char *ttyn, *slash;

View File

@@ -6,7 +6,9 @@
* specifies the terms and conditions for redistribution.
*/
#include <string.h>
#include <strings.h>
#include <sgtty.h>
#include <unistd.h>
#include "gettytab.h"
extern struct sgttyb tmode;
@@ -16,13 +18,13 @@ extern struct ltchars ltc;
/*
* Get a table entry.
*/
gettable(name, buf, area)
void gettable(name, buf, area)
char *name, *buf, *area;
{
register struct gettystrs *sp;
register struct gettynums *np;
register struct gettyflags *fp;
register n;
register int n;
hopcount = 0; /* new lookup, start fresh */
if (getent(buf, name) != 1)
@@ -50,7 +52,7 @@ gettable(name, buf, area)
}
}
gendefaults()
void gendefaults()
{
register struct gettystrs *sp;
register struct gettynums *np;
@@ -69,7 +71,7 @@ gendefaults()
fp->defalt = fp->invrt;
}
setdefaults()
void setdefaults()
{
register struct gettystrs *sp;
register struct gettynums *np;
@@ -101,7 +103,7 @@ charvars[] = {
&ltc.t_werasc, &ltc.t_lnextc, 0
};
setchars()
void setchars()
{
register int i;
register char *p;
@@ -179,7 +181,7 @@ setflags(n)
char editedhost[32];
edithost(pat)
void edithost(pat)
register char *pat;
{
register char *host = HN;
@@ -253,7 +255,7 @@ struct speedtab {
0
};
speed(val)
int speed(val)
long val;
{
register struct speedtab *sp;
@@ -268,22 +270,21 @@ speed(val)
return (B300); /* default in impossible cases */
}
makeenv(env)
void makeenv(env)
char *env[];
{
static char termbuf[128] = "TERM=";
register char *p, *q;
register char **ep;
char *index();
ep = env;
if (TT && *TT) {
strcat(termbuf, TT);
*ep++ = termbuf;
}
if (p = EV) {
if ((p = EV)) {
q = p;
while (q = index(q, ',')) {
while ((q = index(q, ','))) {
*q++ = '\0';
*ep++ = p;
p = q;