diff options
Diffstat (limited to 'usr/src/cmd/tip/remcap.c')
| -rw-r--r-- | usr/src/cmd/tip/remcap.c | 117 |
1 files changed, 62 insertions, 55 deletions
diff --git a/usr/src/cmd/tip/remcap.c b/usr/src/cmd/tip/remcap.c index ee515cf077..5159d8b4e2 100644 --- a/usr/src/cmd/tip/remcap.c +++ b/usr/src/cmd/tip/remcap.c @@ -1,14 +1,14 @@ /* - * Copyright (c) 2000,2001 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2001 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ -/* from UCB 4.8 6/25/83 */ /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ + #pragma ident "%Z%%M% %I% %E% SMI" /* @@ -24,6 +24,11 @@ #include <ctype.h> #endif +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <ctype.h> + #ifndef BUFSIZ #define BUFSIZ 1024 #endif @@ -56,13 +61,20 @@ char *RM; * doesn't, and because living w/o it is not hard. */ -static char *tbuf; -static int hopcount; /* detect infinite loops in termcap, init 0 */ -char *tskip(); -char *tgetstr(); -char *tdecode(); -char *getenv(); -static char *remotefile; +static char *tbuf; +static int hopcount; /* detect infinite loops in termcap, init 0 */ +static char *remotefile; + +static char *tskip(char *); +static char *tdecode(char *, char **); + +char *tgetstr(char *, char **); +int getent(char *, char *, char *, int); +int tnchktc(void); +int tnamatch(char *); + +extern void myperm(void); +extern void userperm(void); /* * If we use a user specified entry to get the device name, @@ -75,9 +87,8 @@ int trusted_device = 0; * from the termcap file. Parse is very rudimentary; * we just notice escaped newlines. */ -tgetent(bp, name, len) - char *bp, *name; - int len; +int +tgetent(char *bp, char *name, int len) { char lbuf[BUFSIZ], *cp, *p; int rc1, rc2; @@ -101,22 +112,21 @@ tgetent(bp, name, len) while (*p++ != ':') ; if (strlen(bp) + strlen(p) >= len) { - write(2, "Remcap entry too long\n", 23); + (void) write(2, "Remcap entry too long\n", 23); return (-1); } - strcat(bp, p); + (void) strcat(bp, p); } tbuf = bp; return (1); } } -getent(bp, name, cp, len) - char *bp, *name, *cp; - int len; +int +getent(char *bp, char *name, char *cp, int len) { - register int c; - register int i = 0, cnt = 0; + int c; + int i = 0, cnt = 0; char ibuf[BUFSIZ], *cp2; int tf; int safe = 1; /* reset only when we open the user's $REMOTE */ @@ -136,7 +146,7 @@ getent(bp, name, cp, len) if (cp2 == (char *)0 || strcmp(name, cp2) == 0) { if (strstr(cp, "dv=") != 0) trusted_device = 0; - strncpy(bp, cp, len-1); + (void) strncpy(bp, cp, len-1); bp[len-1] = '\0'; return (tnchktc()); } else @@ -161,7 +171,7 @@ getent(bp, name, cp, len) if (i == cnt) { cnt = read(tf, ibuf, BUFSIZ); if (cnt <= 0) { - close(tf); + (void) close(tf); return (0); } i = 0; @@ -175,7 +185,7 @@ getent(bp, name, cp, len) break; } if (cp >= bp+len) { - write(2, "Remcap entry too long\n", 23); + (void) write(2, "Remcap entry too long\n", 23); break; } else *cp++ = c; @@ -192,7 +202,7 @@ getent(bp, name, cp, len) */ if (!safe && strstr(bp, "dv=") != 0) trusted_device = 0; - close(tf); + (void) close(tf); return (tnchktc()); } } @@ -205,32 +215,32 @@ getent(bp, name, cp, len) * entries to say "like an HP2621 but doesn't turn on the labels". * Note that this works because of the left to right scan. */ -tnchktc() +int +tnchktc(void) { - register char *p, *q; + char *p, *q; char tcname[64]; /* name of similar terminal */ char tcbuf[BUFSIZ]; char *holdtbuf = tbuf; int l; - char *cp; p = tbuf + strlen(tbuf) - 2; /* before the last colon */ while (*--p != ':') if (p < tbuf) { - write(2, "Bad remcap entry\n", 18); + (void) write(2, "Bad remcap entry\n", 18); return (0); } p++; /* p now points to beginning of last field */ if (p[0] != 't' || p[1] != 'c') return (1); - strlcpy(tcname, p+3, sizeof (tcname)); + (void) strlcpy(tcname, p+3, sizeof (tcname)); q = tcname; while (*q && *q != ':') q++; *q = 0; if (++hopcount > MAXHOP) { - write(2, "Infinite tc= loop\n", 18); + (void) write(2, "Infinite tc= loop\n", 18); return (0); } if (getent(tcbuf, tcname, remotefile, sizeof (tcbuf)) != 1) { @@ -243,10 +253,10 @@ tnchktc() ; l = p - holdtbuf + strlen(q); if (l > BUFSIZ) { - write(2, "Remcap entry too long\n", 23); + (void) write(2, "Remcap entry too long\n", 23); q[BUFSIZ - (p-holdtbuf)] = 0; } - strcpy(p, q); + (void) strcpy(p, q); tbuf = holdtbuf; return (1); } @@ -257,10 +267,10 @@ tnchktc() * against each such name. The normal : terminator after the last * name (before the first field) stops us. */ -tnamatch(np) - char *np; +int +tnamatch(char *np) { - register char *Np, *Bp; + char *Np, *Bp; Bp = tbuf; if (*Bp == '#') @@ -284,8 +294,7 @@ tnamatch(np) * into the termcap file in octal. */ static char * -tskip(bp) - register char *bp; +tskip(char *bp) { while (*bp && *bp != ':') @@ -308,11 +317,11 @@ tskip(bp) * a # character. If the option is not found we return -1. * Note that we handle octal numbers beginning with 0. */ -tgetnum(id) - char *id; +int +tgetnum(char *id) { - register int i, base; - register char *bp = tbuf; + int i, base; + char *bp = tbuf; for (;;) { bp = tskip(bp); @@ -341,10 +350,10 @@ tgetnum(id) * of the buffer. Return 1 if we find the option, or 0 if it is * not given. */ -tgetflag(id) - char *id; +int +tgetflag(char *id) { - register char *bp = tbuf; + char *bp = tbuf; for (;;) { bp = tskip(bp); @@ -368,10 +377,9 @@ tgetflag(id) * No checking on area overflow. */ char * -tgetstr(id, area) - char *id, **area; +tgetstr(char *id, char **area) { - register char *bp = tbuf; + char *bp = tbuf; for (;;) { bp = tskip(bp); @@ -393,17 +401,15 @@ tgetstr(id, area) * string capability escapes. */ static char * -tdecode(str, area) - register char *str; - char **area; +tdecode(char *str, char **area) { - register char *cp; - register int c; - register char *dp; + char *cp; + int c; + char *dp; int i; cp = *area; - while ((c = *str++) && c != ':') { + while ((c = *str++) != 0 && c != ':') { switch (c) { case '^': @@ -425,7 +431,8 @@ nextc: c -= '0', i = 2; do c <<= 3, c |= *str++ - '0'; - while (--i && isdigit(*str)); + while (--i && isdigit(*str)) + ; } break; } |
