WARNSify, KNFify, using ANSI string functions, cleanup .Nm usage

This commit is contained in:
lukem 1997-11-22 07:28:39 +00:00
parent 6b7391ff96
commit e37283e126
27 changed files with 819 additions and 582 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.10 1997/10/24 09:01:07 lukem Exp $
# $NetBSD: Makefile,v 1.11 1997/11/22 07:28:39 lukem Exp $
# @(#)Makefile 8.1 (Berkeley) 6/6/93
#
# Files are:
@ -31,9 +31,8 @@
# explicitly to remcap.c if not 1024
# CONNECT enable ~C command (connect pgm to remote)
WARNS= 0
PROG= tip
CPPFLAGS+=-I${.CURDIR} -ansi -pedantic \
CPPFLAGS+=-I${.CURDIR} \
-DDEFBR=1200 -DDEFFS=BUFSIZ -DACULOG -DPRISTINE -DCONNECT \
-DV831 -DVENTEL -DHAYES -DCOURIER -DT3000
.PATH: ${.CURDIR}/aculib

View File

@ -1,4 +1,4 @@
/* $NetBSD: acu.c,v 1.4 1996/12/29 10:34:03 cgd Exp $ */
/* $NetBSD: acu.c,v 1.5 1997/11/22 07:28:40 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,20 +33,23 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)acu.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: acu.c,v 1.4 1996/12/29 10:34:03 cgd Exp $";
__RCSID("$NetBSD: acu.c,v 1.5 1997/11/22 07:28:40 lukem Exp $");
#endif /* not lint */
#include "tip.h"
static acu_t *acu = NOACU;
static acu_t *acu = NULL;
static int conflag;
static void acuabort();
static acu_t *acutype();
static jmp_buf jmpbuf;
static void acuabort __P((int));
static acu_t *acutype __P((char *));
/*
* Establish connection for tip
*
@ -66,16 +69,21 @@ static jmp_buf jmpbuf;
char *
connect()
{
register char *cp = PN;
char *cp = PN;
char *phnum, string[256];
FILE *fd;
int tried = 0;
#if __GNUC__ /* XXX pacify gcc */
(void)&cp;
(void)&tried;
#endif
if (!DU) { /* regular connect message */
if (CM != NOSTR)
pwrite(FD, CM, size(CM));
if (CM != NULL)
pwrite(FD, CM, strlen(CM));
logent(value(HOST), "", DV, "call completed");
return (NOSTR);
return (NULL);
}
/*
* @ =>'s use data base in PHONES environment variable
@ -88,16 +96,16 @@ connect()
signal(SIGQUIT, SIG_IGN);
printf("\ncall aborted\n");
logent(value(HOST), "", "", "call aborted");
if (acu != NOACU) {
if (acu != NULL) {
setboolean(value(VERBOSE), FALSE);
if (conflag)
disconnect(NOSTR);
disconnect(NULL);
else
(*acu->acu_abort)();
}
return ("interrupt");
}
if ((acu = acutype(AT)) == NOACU)
if ((acu = acutype(AT)) == NULL)
return ("unknown ACU type");
if (*cp != '@') {
while (*cp) {
@ -106,23 +114,23 @@ connect()
if (*cp)
*cp++ = '\0';
if (conflag = (*acu->acu_dialer)(phnum, CU)) {
if (CM != NOSTR)
pwrite(FD, CM, size(CM));
if ((conflag = (*acu->acu_dialer)(phnum, CU)) != 0) {
if (CM != NULL)
pwrite(FD, CM, strlen(CM));
logent(value(HOST), phnum, acu->acu_name,
"call completed");
return (NOSTR);
return (NULL);
} else
logent(value(HOST), phnum, acu->acu_name,
"call failed");
tried++;
}
} else {
if ((fd = fopen(PH, "r")) == NOFILE) {
if ((fd = fopen(PH, "r")) == NULL) {
printf("%s: ", PH);
return ("can't open phone number file");
}
while (fgets(string, sizeof(string), fd) != NOSTR) {
while (fgets(string, sizeof(string), fd) != NULL) {
for (cp = string; !any(*cp, " \t\n"); cp++)
;
if (*cp == '\n') {
@ -143,13 +151,13 @@ connect()
if (*cp)
*cp++ = '\0';
if (conflag = (*acu->acu_dialer)(phnum, CU)) {
if ((conflag = (*acu->acu_dialer)(phnum, CU)) != 0) {
fclose(fd);
if (CM != NOSTR)
pwrite(FD, CM, size(CM));
if (CM != NULL)
pwrite(FD, CM, strlen(CM));
logent(value(HOST), phnum, acu->acu_name,
"call completed");
return (NOSTR);
return (NULL);
} else
logent(value(HOST), phnum, acu->acu_name,
"call failed");
@ -164,6 +172,7 @@ connect()
return (tried ? "call failed" : "missing phone number");
}
void
disconnect(reason)
char *reason;
{
@ -171,7 +180,7 @@ disconnect(reason)
logent(value(HOST), "", DV, "call terminated");
return;
}
if (reason == NOSTR) {
if (reason == NULL) {
logent(value(HOST), "", acu->acu_name, "call terminated");
if (boolean(value(VERBOSE)))
printf("\r\ndisconnecting...");
@ -182,6 +191,7 @@ disconnect(reason)
static void
acuabort(s)
int s;
{
signal(s, SIG_IGN);
longjmp(jmpbuf, 1);
@ -189,13 +199,12 @@ acuabort(s)
static acu_t *
acutype(s)
register char *s;
char *s;
{
register acu_t *p;
extern acu_t acutable[];
acu_t *p;
for (p = acutable; p->acu_name != '\0'; p++)
if (!strcmp(s, p->acu_name))
return (p);
return (NOACU);
return (NULL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: biz22.c,v 1.6 1997/02/11 09:24:11 mrg Exp $ */
/* $NetBSD: biz22.c,v 1.7 1997/11/22 07:28:52 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,22 +33,25 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)biz22.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: biz22.c,v 1.6 1997/02/11 09:24:11 mrg Exp $";
__RCSID("$NetBSD: biz22.c,v 1.7 1997/11/22 07:28:52 lukem Exp $");
#endif /* not lint */
#include "tip.h"
#define DISCONNECT_CMD "\20\04" /* disconnection string */
static void sigALRM();
static int timeout = 0;
static int btimeout = 0;
static jmp_buf timeoutbuf;
static int cmd(), detect();
static int biz_dialer __P((char *, char *));
static int cmd __P((char *));
static int detect __P((char *));
static void sigALRM __P((int));
/*
* Dial up on a BIZCOMP Model 1022 with either
@ -59,7 +62,7 @@ static int
biz_dialer(num, mod)
char *num, *mod;
{
register int connected = 0;
int connected = 0;
char cbuf[40];
if (boolean(value(VERBOSE)))
@ -93,19 +96,20 @@ biz_dialer(num, mod)
*/
connected = detect("1\r");
#ifdef ACULOG
if (timeout) {
if (btimeout) {
char line[80];
(void)snprintf(line, sizeof line, "%d second dial timeout",
number(value(DIALTIMEOUT)));
(int)number(value(DIALTIMEOUT)));
logent(value(HOST), num, "biz1022", line);
}
#endif
if (timeout)
if (btimeout)
biz22_disconnect(); /* insurance */
return (connected);
}
int
biz22w_dialer(num, acu)
char *num, *acu;
{
@ -113,6 +117,7 @@ biz22w_dialer(num, acu)
return (biz_dialer(num, "W"));
}
int
biz22f_dialer(num, acu)
char *num, *acu;
{
@ -120,15 +125,16 @@ biz22f_dialer(num, acu)
return (biz_dialer(num, "V"));
}
void
biz22_disconnect()
{
int rw = 2;
write(FD, DISCONNECT_CMD, 4);
sleep(2);
tcflush(FD, TCIOFLUSH);
}
void
biz22_abort()
{
@ -136,16 +142,17 @@ biz22_abort()
}
static void
sigALRM()
sigALRM(dummy)
int dummy;
{
timeout = 1;
btimeout = 1;
longjmp(timeoutbuf, 1);
}
static int
cmd(s)
register char *s;
char *s;
{
sig_t f;
char c;
@ -167,13 +174,17 @@ cmd(s)
static int
detect(s)
register char *s;
char *s;
{
sig_t f;
char c;
#if __GNUC__ /* XXX pacify gcc */
(void)&s;
#endif
f = signal(SIGALRM, sigALRM);
timeout = 0;
btimeout = 0;
while (*s) {
if (setjmp(timeoutbuf)) {
biz22_abort();
@ -187,5 +198,5 @@ detect(s)
return (0);
}
signal(SIGALRM, f);
return (timeout == 0);
return (btimeout == 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: biz31.c,v 1.5 1997/02/11 09:24:14 mrg Exp $ */
/* $NetBSD: biz31.c,v 1.6 1997/11/22 07:28:53 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)biz31.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: biz31.c,v 1.5 1997/02/11 09:24:14 mrg Exp $";
__RCSID("$NetBSD: biz31.c,v 1.6 1997/11/22 07:28:53 lukem Exp $");
#endif /* not lint */
#include "tip.h"
@ -58,7 +59,7 @@ static int
biz_dialer(num, mod)
char *num, *mod;
{
register int connected = 0;
int connected = 0;
if (!bizsync(FD)) {
logent(value(HOST), "", "biz", "out of sync");
@ -134,7 +135,7 @@ biz31_abort()
static int
echo(s)
register char *s;
char *s;
{
char c;
@ -166,7 +167,7 @@ sigALRM()
static int
detect(s)
register char *s;
char *s;
{
sig_t f;
char c;
@ -191,7 +192,7 @@ detect(s)
static int
flush(s)
register char *s;
char *s;
{
sig_t f;
char c;
@ -226,7 +227,7 @@ bizsync(fd)
# define chars(b) (b)
# define IOCTL FIONREAD
#endif
register int already = 0;
int already = 0;
char buf[10];
retry:

View File

@ -1,4 +1,4 @@
/* $NetBSD: courier.c,v 1.7 1997/02/11 09:24:16 mrg Exp $ */
/* $NetBSD: courier.c,v 1.8 1997/11/22 07:28:53 lukem Exp $ */
/*
* Copyright (c) 1986, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: courier.c,v 1.7 1997/02/11 09:24:16 mrg Exp $";
__RCSID("$NetBSD: courier.c,v 1.8 1997/11/22 07:28:53 lukem Exp $");
#endif /* not lint */
/*
@ -45,23 +46,30 @@ static char rcsid[] = "$NetBSD: courier.c,v 1.7 1997/02/11 09:24:16 mrg Exp $";
* Derived from Hayes driver.
*/
#include "tip.h"
#include <sys/ioctl.h>
#include <stdio.h>
#define MAXRETRY 5
static void sigALRM();
static int timeout = 0;
static int connected = 0;
static jmp_buf timeoutbuf, intbuf;
static int coursync(), cour_connect(), cour_swallow();
static void cour_napx();
static jmp_buf timeoutbuf;
static int cour_connect __P((void));
static void cour_nap __P((void));
static void cour_napx __P((int));
static int cour_swallow __P((char *));
static int coursync __P((void));
#ifdef DEBUG
static void cour_verbose_read __P((void));
#endif
static void cour_write __P((int, char *, int));
static void sigALRM __P((int));
int
cour_dialer(num, acu)
register char *num;
char *num;
char *acu;
{
register char *cp;
char *cp;
#ifdef ACULOG
char line[80];
#endif
@ -105,7 +113,7 @@ badsynch:
#ifdef ACULOG
if (timeout) {
(void)snprintf(line, sizeof line, "%d second dial timeout",
number(value(DIALTIMEOUT)));
(int)number(value(DIALTIMEOUT)));
logent(value(HOST), num, "cour", line);
}
#endif
@ -114,6 +122,7 @@ badsynch:
return (connected);
}
void
cour_disconnect()
{
/* first hang up the modem*/
@ -124,6 +133,7 @@ cour_disconnect()
close(FD);
}
void
cour_abort()
{
cour_write(FD, "\r", 1); /* send anything to abort the call */
@ -131,7 +141,8 @@ cour_abort()
}
static void
sigALRM()
sigALRM(dummy)
int dummy;
{
printf("\07timeout waiting for reply\n");
timeout = 1;
@ -140,11 +151,15 @@ sigALRM()
static int
cour_swallow(match)
register char *match;
{
char *match;
{
sig_t f;
char c;
#if __GNUC__ /* XXX pacify gcc */
(void)&match;
#endif
f = signal(SIGALRM, sigALRM);
timeout = 0;
do {
@ -177,12 +192,12 @@ struct baud_msg {
char *msg;
int baud;
} baud_msg[] = {
"", B300,
" 1200", B1200,
" 2400", B2400,
" 9600", B9600,
" 9600/ARQ", B9600,
0, 0,
{ "", B300 },
{ " 1200", B1200 },
{ " 2400", B2400 },
{ " 9600", B9600 },
{ " 9600/ARQ", B9600 },
{ 0, 0 }
};
static int
@ -194,12 +209,17 @@ cour_connect()
struct baud_msg *bm;
sig_t f;
#if __GNUC__ /* XXX pacify gcc */
(void)&nc;
(void)&nl;
#endif
if (cour_swallow("\r\n") == 0)
return (0);
f = signal(SIGALRM, sigALRM);
again:
nc = 0; nl = sizeof(dialer_buf)-1;
bzero(dialer_buf, sizeof(dialer_buf));
memset(dialer_buf, 0, sizeof(dialer_buf));
timeout = 0;
for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) {
if (setjmp(timeoutbuf))
@ -249,9 +269,7 @@ again:
putchar(c);
#endif
}
error1:
printf("%s\r\n", dialer_buf);
error:
signal(SIGALRM, f);
return (0);
}
@ -270,7 +288,7 @@ coursync()
while (already++ < MAXRETRY) {
tcflush(FD, TCIOFLUSH);
cour_write(FD, "\rAT Z\r", 6); /* reset modem */
bzero(buf, sizeof(buf));
memset(buf, 0, sizeof(buf));
sleep(1);
ioctl(FD, FIONREAD, &len);
if (len) {
@ -279,8 +297,8 @@ coursync()
buf[len] = '\0';
printf("coursync: (\"%s\")\n\r", buf);
#endif
if (index(buf, '0') ||
(index(buf, 'O') && index(buf, 'K')))
if (strchr(buf, '0') ||
(strchr(buf, 'O') && strchr(buf, 'K')))
return(1);
}
/*
@ -302,10 +320,11 @@ coursync()
return (0);
}
static void
cour_write(fd, cp, n)
int fd;
char *cp;
int n;
int fd;
char *cp;
int n;
{
#ifdef notdef
if (boolean(value(VERBOSE)))
@ -321,6 +340,7 @@ int n;
}
#ifdef DEBUG
static void
cour_verbose_read()
{
int n = 0;
@ -347,12 +367,13 @@ static napms = 50; /* Give the courier 50 milliseconds between characters */
static int ringring;
void
cour_nap()
{
int omask;
struct itimerval itv, oitv;
register struct itimerval *itp = &itv;
struct itimerval *itp = &itv;
struct sigvec vec, ovec;
timerclear(&itp->it_interval);
@ -375,7 +396,8 @@ cour_nap()
}
static void
cour_napx()
cour_napx(dummy)
int dummy;
{
ringring = 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: df.c,v 1.4 1995/10/29 00:49:51 pk Exp $ */
/* $NetBSD: df.c,v 1.5 1997/11/22 07:28:54 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)df.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: df.c,v 1.4 1995/10/29 00:49:51 pk Exp $";
__RCSID("$NetBSD: df.c,v 1.5 1997/11/22 07:28:54 lukem Exp $");
#endif /* not lint */
/*
@ -47,8 +48,11 @@ static char rcsid[] = "$NetBSD: df.c,v 1.4 1995/10/29 00:49:51 pk Exp $";
#include "tip.h"
static jmp_buf Sjbuf;
static void timeout();
static int df_dialer __P((char *, char *, int));
static void timeout __P((int));
int
df02_dialer(num, acu)
char *num, *acu;
{
@ -56,6 +60,7 @@ df02_dialer(num, acu)
return (df_dialer(num, acu, 0));
}
int
df03_dialer(num, acu)
char *num, *acu;
{
@ -63,15 +68,20 @@ df03_dialer(num, acu)
return (df_dialer(num, acu, 1));
}
static int
df_dialer(num, acu, df03)
char *num, *acu;
int df03;
{
register int f = FD;
int f = FD;
struct termios cntrl;
int speed = 0, rw = 2;
int speed = 0;
char c = '\0';
#if __GNUC__ /* XXX pacify gcc */
(void)&speed;
#endif
tcgetattr(f, &cntrl);
cntrl.c_cflag |= HUPCL;
tcsetattr(f, TCSANOW, &cntrl);
@ -116,9 +126,9 @@ df_dialer(num, acu, df03)
return (c == 'A');
}
void
df_disconnect()
{
int rw = 2;
write(FD, "\001", 1);
sleep(1);
@ -126,6 +136,7 @@ df_disconnect()
}
void
df_abort()
{
@ -134,7 +145,8 @@ df_abort()
static void
timeout()
timeout(dummy)
int dummy;
{
longjmp(Sjbuf, 1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dn11.c,v 1.4 1995/10/29 00:49:53 pk Exp $ */
/* $NetBSD: dn11.c,v 1.5 1997/11/22 07:28:55 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dn11.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: dn11.c,v 1.4 1995/10/29 00:49:53 pk Exp $";
__RCSID("$NetBSD: dn11.c,v 1.5 1997/11/22 07:28:55 lukem Exp $");
#endif /* not lint */
/*
@ -45,18 +46,17 @@ static char rcsid[] = "$NetBSD: dn11.c,v 1.4 1995/10/29 00:49:53 pk Exp $";
*/
#include "tip.h"
int dn_abort();
void alarmtr();
static jmp_buf jmpbuf;
static int child = -1, dn;
static void alarmtr __P((int));
int
dn_dialer(num, acu)
char *num, *acu;
{
extern errno;
char *p, *q, phone[40];
int lt, nw, connected = 1;
register int timelim;
int lt, nw;
int timelim;
struct termios cntrl;
if (boolean(value(VERBOSE)))
@ -116,8 +116,9 @@ dn_dialer(num, acu)
return (1);
}
void
alarmtr()
static void
alarmtr(dummy)
int dummy;
{
alarm(0);
longjmp(jmpbuf, 1);
@ -127,6 +128,7 @@ alarmtr()
* Insurance, for some reason we don't seem to be
* hanging up...
*/
void
dn_disconnect()
{
@ -136,6 +138,7 @@ dn_disconnect()
close(FD);
}
void
dn_abort()
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: hayes.c,v 1.6 1997/02/11 09:24:17 mrg Exp $ */
/* $NetBSD: hayes.c,v 1.7 1997/11/22 07:28:56 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)hayes.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: hayes.c,v 1.6 1997/02/11 09:24:17 mrg Exp $";
__RCSID("$NetBSD: hayes.c,v 1.7 1997/11/22 07:28:56 lukem Exp $");
#endif /* not lint */
/*
@ -65,15 +66,10 @@ static char rcsid[] = "$NetBSD: hayes.c,v 1.6 1997/02/11 09:24:17 mrg Exp $";
*/
#include "tip.h"
#include <termios.h>
#include <sys/ioctl.h>
#define min(a,b) ((a < b) ? a : b)
static void sigALRM();
static int timeout = 0;
static jmp_buf timeoutbuf;
static char gobble();
#define DUMBUFLEN 40
static char dumbuf[DUMBUFLEN];
@ -83,12 +79,19 @@ static char dumbuf[DUMBUFLEN];
#define FAILED 4
static int state = IDLE;
static void error_rep __P((char));
static char gobble __P((char *));
static void goodbye __P((void));
static int hay_sync __P((void));
static void sigALRM __P((int));
int
hay_dialer(num, acu)
register char *num;
char *num;
char *acu;
{
register char *cp;
register int connected = 0;
char *cp;
int connected = 0;
char dummy;
struct termios cntrl;
#ifdef ACULOG
@ -130,7 +133,7 @@ hay_dialer(num, acu)
#ifdef ACULOG
if (timeout) {
(void)snprintf(line, sizeof line, "%d second dial timeout",
number(value(DIALTIMEOUT)));
(int)number(value(DIALTIMEOUT)));
logent(value(HOST), num, "hayes", line);
}
#endif
@ -140,10 +143,9 @@ hay_dialer(num, acu)
}
void
hay_disconnect()
{
char c;
int len, rlen;
/* first hang up the modem*/
#ifdef DEBUG
@ -155,17 +157,17 @@ hay_disconnect()
goodbye();
}
void
hay_abort()
{
char c;
write(FD, "\r", 1); /* send anything to abort the call */
hay_disconnect();
}
static void
sigALRM()
sigALRM(dummy)
int dummy;
{
printf("\07timeout waiting for reply\n\r");
@ -175,12 +177,16 @@ sigALRM()
static char
gobble(match)
register char *match;
char *match;
{
char c;
sig_t f;
int i, status = 0;
#if __GNUC__ /* XXX pacify gcc */
(void)&status;
#endif
f = signal(SIGALRM, sigALRM);
timeout = 0;
#ifdef DEBUG
@ -209,8 +215,9 @@ gobble(match)
return (status);
}
static void
error_rep(c)
register char c;
char c;
{
printf("\n\r");
switch (c) {
@ -249,9 +256,10 @@ error_rep(c)
/*
* set modem back to normal verbose status codes.
*/
void
goodbye()
{
int len, rlen;
int len;
char c;
tcflush(FD, TCIOFLUSH);
@ -293,6 +301,7 @@ goodbye()
#define MAXRETRY 5
int
hay_sync()
{
int len, retry = 0;
@ -303,8 +312,8 @@ hay_sync()
ioctl(FD, FIONREAD, &len);
if (len) {
len = read(FD, dumbuf, min(len, DUMBUFLEN));
if (index(dumbuf, '0') ||
(index(dumbuf, 'O') && index(dumbuf, 'K')))
if (strchr(dumbuf, '0') ||
(strchr(dumbuf, 'O') && strchr(dumbuf, 'K')))
return(1);
#ifdef DEBUG
dumbuf[len] = '\0';

View File

@ -1,4 +1,4 @@
/* $NetBSD: t3000.c,v 1.5 1997/02/11 09:24:18 mrg Exp $ */
/* $NetBSD: t3000.c,v 1.6 1997/11/22 07:28:57 lukem Exp $ */
/*
* Copyright (c) 1992, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: t3000.c,v 1.5 1997/02/11 09:24:18 mrg Exp $";
__RCSID("$NetBSD: t3000.c,v 1.6 1997/11/22 07:28:57 lukem Exp $");
#endif /* not lint */
/*
@ -46,23 +47,26 @@ static char rcsid[] = "$NetBSD: t3000.c,v 1.5 1997/02/11 09:24:18 mrg Exp $";
*/
#include "tip.h"
#include <sys/ioctl.h>
#include <stdio.h>
#define MAXRETRY 5
static void sigALRM();
static int timeout = 0;
static int connected = 0;
static jmp_buf timeoutbuf, intbuf;
static int t3000_sync(), t3000_connect(), t3000_swallow();
static void t3000_napx();
static jmp_buf timeoutbuf;
static void sigALRM __P((int));
static int t3000_connect __P((void));
static void t3000_nap __P((void));
static void t3000_napx __P((int));
static int t3000_swallow __P((char *));
static int t3000_sync __P((void));
static void t3000_write __P((int, char *, int));
int
t3000_dialer(num, acu)
register char *num;
char *num;
char *acu;
{
register char *cp;
char *cp;
struct termios cntrl;
#ifdef ACULOG
char line[80];
@ -106,7 +110,7 @@ badsynch:
#ifdef ACULOG
if (timeout) {
(void)snprintf(line, sizeof line, "%d second dial timeout",
number(value(DIALTIMEOUT)));
(int)number(value(DIALTIMEOUT)));
logent(value(HOST), num, "t3000", line);
}
#endif
@ -115,6 +119,7 @@ badsynch:
return (connected);
}
void
t3000_disconnect()
{
/* first hang up the modem*/
@ -125,6 +130,7 @@ t3000_disconnect()
close(FD);
}
void
t3000_abort()
{
t3000_write(FD, "\r", 1); /* send anything to abort the call */
@ -132,7 +138,8 @@ t3000_abort()
}
static void
sigALRM()
sigALRM(dummy)
int dummy;
{
printf("\07timeout waiting for reply\n");
timeout = 1;
@ -141,11 +148,15 @@ sigALRM()
static int
t3000_swallow(match)
register char *match;
{
char *match;
{
sig_t f;
char c;
#if __GNUC__ /* XXX pacify gcc */
(void)&match;
#endif
f = signal(SIGALRM, sigALRM);
timeout = 0;
do {
@ -184,20 +195,20 @@ struct tbaud_msg {
int baud;
int baud2;
} tbaud_msg[] = {
"", B300, 0,
" 1200", B1200, 0,
" 2400", B2400, 0,
" 4800", B4800, 0,
" 9600", B9600, 0,
" 14400", B19200, B9600,
" 19200", B19200, B9600,
" 38400", B38400, B9600,
" 57600", B38400, B9600,
" 7512", B9600, 0,
" 1275", B2400, 0,
" 7200", B9600, 0,
" 12000", B19200, B9600,
0, 0, 0,
{ "", B300, 0 },
{ " 1200", B1200, 0 },
{ " 2400", B2400, 0 },
{ " 4800", B4800, 0 },
{ " 9600", B9600, 0 },
{ " 14400", B19200, B9600 },
{ " 19200", B19200, B9600 },
{ " 38400", B38400, B9600 },
{ " 57600", B38400, B9600 },
{ " 7512", B9600, 0 },
{ " 1275", B2400, 0 },
{ " 7200", B9600, 0 },
{ " 12000", B19200, B9600 },
{ 0, 0, 0 },
};
static int
@ -209,12 +220,17 @@ t3000_connect()
struct tbaud_msg *bm;
sig_t f;
#if __GNUC__ /* XXX pacify gcc */
(void)&nc;
(void)&nl;
#endif
if (t3000_swallow("\r\n") == 0)
return (0);
f = signal(SIGALRM, sigALRM);
again:
nc = 0; nl = sizeof(dialer_buf)-1;
bzero(dialer_buf, sizeof(dialer_buf));
memset(dialer_buf, 0, sizeof(dialer_buf));
timeout = 0;
for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) {
if (setjmp(timeoutbuf))
@ -264,9 +280,7 @@ again:
putchar(c);
#endif
}
error1:
printf("%s\r\n", dialer_buf);
error:
signal(SIGALRM, f);
return (0);
}
@ -285,7 +299,7 @@ t3000_sync()
while (already++ < MAXRETRY) {
tcflush(FD, TCIOFLUSH);
t3000_write(FD, "\rAT Z\r", 6); /* reset modem */
bzero(buf, sizeof(buf));
memset(buf, 0, sizeof(buf));
sleep(2);
ioctl(FD, FIONREAD, &len);
#if 1
@ -297,8 +311,8 @@ if (len == 0) len = 1;
buf[len] = '\0';
printf("t3000_sync: (\"%s\")\n\r", buf);
#endif
if (index(buf, '0') ||
(index(buf, 'O') && index(buf, 'K')))
if (strchr(buf, '0') ||
(strchr(buf, 'O') && strchr(buf, 'K')))
return(1);
}
/*
@ -320,10 +334,11 @@ if (len == 0) len = 1;
return (0);
}
static void
t3000_write(fd, cp, n)
int fd;
char *cp;
int n;
int fd;
char *cp;
int n;
{
#ifdef notdef
if (boolean(value(VERBOSE)))
@ -365,12 +380,13 @@ static napms = 50; /* Give the t3000 50 milliseconds between characters */
static int ringring;
static void
t3000_nap()
{
int omask;
struct itimerval itv, oitv;
register struct itimerval *itp = &itv;
struct itimerval *itp = &itv;
struct sigvec vec, ovec;
timerclear(&itp->it_interval);
@ -393,7 +409,8 @@ t3000_nap()
}
static void
t3000_napx()
t3000_napx(dummy)
int dummy;
{
ringring = 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: v3451.c,v 1.6 1997/02/11 09:24:20 mrg Exp $ */
/* $NetBSD: v3451.c,v 1.7 1997/11/22 07:28:57 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)v3451.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: v3451.c,v 1.6 1997/02/11 09:24:20 mrg Exp $";
__RCSID("$NetBSD: v3451.c,v 1.7 1997/11/22 07:28:57 lukem Exp $");
#endif /* not lint */
/*
@ -47,21 +48,22 @@ static char rcsid[] = "$NetBSD: v3451.c,v 1.6 1997/02/11 09:24:20 mrg Exp $";
static jmp_buf Sjbuf;
static int expect(), notin(), prefix();
static void vawrite(), alarmtr();
static void alarmtr __P((int));
static int expect __P((char *));
static int notin __P((char *, char *));
static int prefix __P((char *, char *));
static void vawrite __P((char *, int));
int
v3451_dialer(num, acu)
register char *num;
char *num;
char *acu;
{
sig_t func;
int ok;
int slow = number(value(BAUDRATE)) < 1200, rw = 2;
int slow = number(value(BAUDRATE)) < 1200;
char phone[50];
struct termios cntrl;
#ifdef ACULOG
char line[80];
#endif
/*
* Get in synch
@ -128,12 +130,14 @@ v3451_dialer(num, acu)
return (1);
}
void
v3451_disconnect()
{
close(FD);
}
void
v3451_abort()
{
@ -142,7 +146,7 @@ v3451_abort()
static void
vawrite(cp, delay)
register char *cp;
char *cp;
int delay;
{
@ -150,14 +154,20 @@ vawrite(cp, delay)
write(FD, cp, 1);
}
static
static int
expect(cp)
register char *cp;
char *cp;
{
char buf[300];
register char *rp = buf;
char *rp = buf;
int timeout = 30, online = 0;
#if __GNUC__ /* XXX pacify gcc */
(void)&online;
(void)&rp;
(void)&timeout;
#endif
if (strcmp(cp, "\"\"") == 0)
return (1);
*rp = 0;
@ -190,7 +200,8 @@ expect(cp)
}
static void
alarmtr()
alarmtr(dummy)
int dummy;
{
longjmp(Sjbuf, 1);
}
@ -206,11 +217,11 @@ notin(sh, lg)
return (1);
}
static
static int
prefix(s1, s2)
register char *s1, *s2;
char *s1, *s2;
{
register char c;
char c;
while ((c = *s1++) == *s2++)
if (c == '\0')

View File

@ -1,4 +1,4 @@
/* $NetBSD: v831.c,v 1.5 1996/12/29 10:42:01 cgd Exp $ */
/* $NetBSD: v831.c,v 1.6 1997/11/22 07:28:58 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,33 +33,32 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)v831.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: v831.c,v 1.5 1996/12/29 10:42:01 cgd Exp $";
__RCSID("$NetBSD: v831.c,v 1.6 1997/11/22 07:28:58 lukem Exp $");
#endif /* not lint */
/*
* Routines for dialing up on Vadic 831
*/
#include "tip.h"
#include <termios.h>
int v831_abort();
static void alarmtr();
static int dialit();
static char *sanitize();
extern int errno;
static jmp_buf jmpbuf;
static int child = -1;
static void alarmtr __P((int));
static int dialit __P((char *, char *));
static char *sanitize __P((char *));
int
v831_dialer(num, acu)
char *num, *acu;
{
int status, pid, connected = 1;
register int timelim;
int status, pid;
int timelim;
if (boolean(value(VERBOSE)))
printf("\nstarting call...");
@ -119,7 +118,8 @@ v831_dialer(num, acu)
}
static void
alarmtr()
alarmtr(dummy)
int dummy;
{
alarm(0);
longjmp(jmpbuf, 1);
@ -129,6 +129,7 @@ alarmtr()
* Insurance, for some reason we don't seem to be
* hanging up...
*/
void
v831_disconnect()
{
struct termios cntrl;
@ -148,6 +149,7 @@ v831_disconnect()
close(FD);
}
void
v831_abort()
{
@ -186,13 +188,13 @@ struct vaconfig {
static int
dialit(phonenum, acu)
register char *phonenum;
char *phonenum;
char *acu;
{
register struct vaconfig *vp;
struct vaconfig *vp;
struct termios cntrl;
char c;
int i, two = 2;
int i;
phonenum = sanitize(phonenum);
#ifdef DEBUG
@ -248,10 +250,10 @@ dialit(phonenum, acu)
static char *
sanitize(s)
register char *s;
char *s;
{
static char buf[128];
register char *cp;
char *cp;
for (cp = buf; *s; s++) {
if (!isdigit(*s) && *s == '<' && *s != '_')

View File

@ -1,4 +1,4 @@
/* $NetBSD: ventel.c,v 1.6 1997/02/11 09:24:21 mrg Exp $ */
/* $NetBSD: ventel.c,v 1.7 1997/11/22 07:28:59 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)ventel.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: ventel.c,v 1.6 1997/02/11 09:24:21 mrg Exp $";
__RCSID("$NetBSD: ventel.c,v 1.7 1997/11/22 07:28:59 lukem Exp $");
#endif /* not lint */
/*
@ -45,35 +46,32 @@ static char rcsid[] = "$NetBSD: ventel.c,v 1.6 1997/02/11 09:24:21 mrg Exp $";
* The Ventel is expected to be strapped for local echo (just like uucp)
*/
#include "tip.h"
#include <termios.h>
#include <sys/ioctl.h>
#define MAXRETRY 5
static void sigALRM();
static int timeout = 0;
static jmp_buf timeoutbuf;
static int gobble(), vensync();
static void echo();
static void echo __P((char *));
static int gobble __P((char, char *));
static void sigALRM __P((int));
static int vensync __P((int));
/*
* some sleep calls have been replaced by this macro
* some sleep calls have been replaced by usleep(DELAYUS)
* because some ventel modems require two <cr>s in less than
* a second in order to 'wake up'... yes, it is dirty...
* a second in order to 'wake up'
*/
#define delay(num,denom) busyloop(CPUSPEED*num/denom)
#define CPUSPEED 1000000 /* VAX 780 is 1MIPS */
#define DELAY(n) { register long N = (n); while (--N > 0); }
busyloop(n) { DELAY(n); }
#define DELAYUS 100000 /* delay in microseconds */
int
ven_dialer(num, acu)
register char *num;
char *num;
char *acu;
{
register char *cp;
register int connected = 0;
char *msg, *index(), line[80];
char *cp;
int connected = 0;
char *msg, line[80];
struct termios cntrl;
/*
@ -94,10 +92,10 @@ ven_dialer(num, acu)
tcsetattr(FD, TCSANOW, &cntrl);
echo("#k$\r$\n$D$I$A$L$:$ ");
for (cp = num; *cp; cp++) {
delay(1, 10);
usleep(DELAYUS);
write(FD, cp, 1);
}
delay(1, 10);
usleep(DELAYUS);
write(FD, "\r", 1);
gobble('\n', line);
if (gobble('\n', line))
@ -106,7 +104,7 @@ ven_dialer(num, acu)
#ifdef ACULOG
if (timeout) {
(void)snprintf(line, sizeof line, "%d second dial timeout",
number(value(DIALTIMEOUT)));
(int)number(value(DIALTIMEOUT)));
logent(value(HOST), num, "ventel", line);
}
#endif
@ -115,10 +113,10 @@ ven_dialer(num, acu)
if (connected || timeout || !boolean(value(VERBOSE)))
return (connected);
/* call failed, parse response for user */
cp = index(line, '\r');
cp = strchr(line, '\r');
if (cp)
*cp = '\0';
for (cp = line; cp = index(cp, ' '); cp++)
for (cp = line; (cp = strchr(cp, ' ')) != NULL; cp++)
if (cp[1] == ' ')
break;
if (cp) {
@ -135,12 +133,14 @@ ven_dialer(num, acu)
return (connected);
}
void
ven_disconnect()
{
close(FD);
}
void
ven_abort()
{
@ -150,11 +150,11 @@ ven_abort()
static void
echo(s)
register char *s;
char *s;
{
char c;
while (c = *s++) switch (c) {
while ((c = *s++) != 0) switch (c) {
case '$':
read(FD, &c, 1);
@ -173,7 +173,8 @@ echo(s)
}
static void
sigALRM()
sigALRM(dummy)
int dummy;
{
printf("\07timeout waiting for reply\n");
timeout = 1;
@ -182,13 +183,17 @@ sigALRM()
static int
gobble(match, response)
register char match;
char match;
char response[];
{
register char *cp = response;
char *cp = response;
sig_t f;
char c;
#if __GNUC__ /* XXX pacify gcc */
(void)&cp;
#endif
f = signal(SIGALRM, sigALRM);
timeout = 0;
do {
@ -219,6 +224,7 @@ gobble(match, response)
*/
static int
vensync(fd)
int fd;
{
int already = 0, nread;
char buf[60];
@ -241,7 +247,7 @@ vensync(fd)
* so the modem can frame the incoming characters.
*/
write(fd, "\r", 1);
delay(1,10);
usleep(DELAYUS);
write(fd, "\r", 1);
sleep(2);
if (ioctl(fd, FIONREAD, (caddr_t)&nread) < 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: acutab.c,v 1.3 1994/12/08 09:30:41 jtc Exp $ */
/* $NetBSD: acutab.c,v 1.4 1997/11/22 07:28:40 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,70 +33,57 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)acutab.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: acutab.c,v 1.3 1994/12/08 09:30:41 jtc Exp $";
__RCSID("$NetBSD: acutab.c,v 1.4 1997/11/22 07:28:40 lukem Exp $");
#endif /* not lint */
#include "tip.h"
extern int df02_dialer(), df03_dialer(), df_disconnect(), df_abort(),
biz31f_dialer(), biz31_disconnect(), biz31_abort(),
biz31w_dialer(),
biz22f_dialer(), biz22_disconnect(), biz22_abort(),
biz22w_dialer(),
ven_dialer(), ven_disconnect(), ven_abort(),
hay_dialer(), hay_disconnect(), hay_abort(),
cour_dialer(), cour_disconnect(), cour_abort(),
t3000_dialer(), t3000_disconnect(), t3000_abort(),
v3451_dialer(), v3451_disconnect(), v3451_abort(),
v831_dialer(), v831_disconnect(), v831_abort(),
dn_dialer(), dn_disconnect(), dn_abort();
acu_t acutable[] = {
#if BIZ1031
"biz31f", biz31f_dialer, biz31_disconnect, biz31_abort,
"biz31w", biz31w_dialer, biz31_disconnect, biz31_abort,
{ "biz31f", biz31f_dialer, biz31_disconnect, biz31_abort },
{ "biz31w", biz31w_dialer, biz31_disconnect, biz31_abort },
#endif
#if BIZ1022
"biz22f", biz22f_dialer, biz22_disconnect, biz22_abort,
"biz22w", biz22w_dialer, biz22_disconnect, biz22_abort,
{ "biz22f", biz22f_dialer, biz22_disconnect, biz22_abort },
{ "biz22w", biz22w_dialer, biz22_disconnect, biz22_abort },
#endif
#if DF02
"df02", df02_dialer, df_disconnect, df_abort,
{ "df02", df02_dialer, df_disconnect, df_abort },
#endif
#if DF03
"df03", df03_dialer, df_disconnect, df_abort,
{ "df03", df03_dialer, df_disconnect, df_abort },
#endif
#if DN11
"dn11", dn_dialer, dn_disconnect, dn_abort,
{ "dn11", dn_dialer, dn_disconnect, dn_abort },
#endif
#ifdef VENTEL
"ventel",ven_dialer, ven_disconnect, ven_abort,
{ "ventel", ven_dialer, ven_disconnect, ven_abort },
#endif
#ifdef HAYES
"hayes",hay_dialer, hay_disconnect, hay_abort,
{ "hayes", hay_dialer, hay_disconnect, hay_abort },
#endif
#ifdef COURIER
"courier",cour_dialer, cour_disconnect, cour_abort,
{ "courier", cour_dialer, cour_disconnect, cour_abort },
#endif
#ifdef T3000
"t3000",t3000_dialer, t3000_disconnect, t3000_abort,
{ "t3000", t3000_dialer, t3000_disconnect, t3000_abort },
#endif
#ifdef V3451
#ifndef V831
"vadic",v3451_dialer, v3451_disconnect, v3451_abort,
{ "vadic", v3451_dialer, v3451_disconnect, v3451_abort },
#endif
"v3451",v3451_dialer, v3451_disconnect, v3451_abort,
{ "v3451", v3451_dialer, v3451_disconnect, v3451_abort },
#endif
#ifdef V831
#ifndef V3451
"vadic",v831_dialer, v831_disconnect, v831_abort,
{ "vadic", v831_dialer, v831_disconnect, v831_abort },
#endif
"v831",v831_dialer, v831_disconnect, v831_abort,
{ "v831", v831_dialer, v831_disconnect, v831_abort },
#endif
0, 0, 0, 0
{ 0, 0, 0, 0 }
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmds.c,v 1.7 1997/02/11 09:24:03 mrg Exp $ */
/* $NetBSD: cmds.c,v 1.8 1997/11/22 07:28:41 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: cmds.c,v 1.7 1997/02/11 09:24:03 mrg Exp $";
__RCSID("$NetBSD: cmds.c,v 1.8 1997/11/22 07:28:41 lukem Exp $");
#endif /* not lint */
#include "tip.h"
@ -55,18 +56,24 @@ char null = '\0';
char *sep[] = { "second", "minute", "hour" };
static char *argv[10]; /* argument vector for take and put */
void timeout(); /* timeout function called on alarm */
void stopsnd(); /* SIGINT handler during file transfers */
void intcopy(); /* interrupt routine for file transfers */
int args __P((char *, char **));
int anyof __P((char *, char *));
void execute __P((char *));
void intcopy __P((int));
void prtime __P((char *, time_t));
void stopsnd __P((int));
void transfer __P((char *, int, char *));
void transmit __P((FILE *, char *, char *));
/*
* FTP - remote ==> local
* get a file from the remote host
*/
void
getfl(c)
char c;
{
char buf[256], *cp, *expand();
char buf[256], *cp;
putchar(c);
/*
@ -93,11 +100,12 @@ getfl(c)
/*
* Cu-like take command
*/
void
cu_take(cc)
char cc;
{
int fd, argc;
char line[BUFSIZ], *expand(), *cp;
char line[BUFSIZ], *cp;
if (prompt("[take] ", copyname))
return;
@ -121,18 +129,25 @@ static jmp_buf intbuf;
* Bulk transfer routine --
* used by getfl(), cu_take(), and pipefile()
*/
void
transfer(buf, fd, eofchars)
char *buf, *eofchars;
char *buf;
int fd;
char *eofchars;
{
register int ct;
int ct;
char c, buffer[BUFSIZ];
register char *p = buffer;
register int cnt, eof;
char *p = buffer;
int cnt, eof;
time_t start;
sig_t f;
char r;
pwrite(FD, buf, size(buf));
#if __GNUC__ /* XXX pacify gcc */
(void)&p;
#endif
pwrite(FD, buf, strlen(buf));
quit = 0;
kill(pid, SIGIOT);
read(repdes[0], (char *)&ccc, 1); /* Wait until read process stops */
@ -173,7 +188,7 @@ transfer(buf, fd, eofchars)
p = buffer;
}
}
if (cnt = (p-buffer))
if ((cnt = (p-buffer)) != 0)
if (write(fd, buffer, cnt) != cnt)
printf("\r\nwrite error\r\n");
@ -189,12 +204,13 @@ transfer(buf, fd, eofchars)
* FTP - remote ==> local process
* send remote input to local process via pipe
*/
pipefile()
void
pipefile(dummy)
char dummy;
{
int cpid, pdes[2];
char buf[256];
int status, p;
extern int errno;
if (prompt("Local command? ", buf))
return;
@ -220,7 +236,7 @@ pipefile()
;
}
} else {
register int f;
int f;
dup2(pdes[0], 0);
close(pdes[0]);
@ -236,7 +252,8 @@ pipefile()
* Interrupt service routine for FTP
*/
void
stopsnd()
stopsnd(dummy)
int dummy;
{
stop = 1;
@ -248,12 +265,12 @@ stopsnd()
* send local file to remote host
* terminate transmission with pseudo EOF sequence
*/
void
sendfile(cc)
char cc;
{
FILE *fd;
char *fnamex;
char *expand();
putchar(cc);
/*
@ -279,6 +296,7 @@ sendfile(cc)
* Bulk transfer routine to remote host --
* used by sendfile() and cu_put()
*/
void
transmit(fd, eofchars, command)
FILE *fd;
char *eofchars, *command;
@ -346,7 +364,8 @@ transmit(fd, eofchars, command)
read(FD, (char *)&c, 1);
if (timedout || stop) {
if (timedout)
printf("\r\ntimed out at eol\r\n");
printf(
"\r\ntimed out at eol\r\n");
alarm(0);
goto out;
}
@ -376,13 +395,13 @@ out:
/*
* Cu-like put command
*/
void
cu_put(cc)
char cc;
{
FILE *fd;
char line[BUFSIZ];
int argc;
char *expand();
char *copynamex;
if (prompt("[put] ", copyname))
@ -409,6 +428,7 @@ cu_put(cc)
* FTP - send single character
* wait for echo & handle timeout
*/
void
send(c)
char c;
{
@ -443,9 +463,10 @@ tryagain:
}
void
timeout()
alrmtimeout(dummy)
int dummy;
{
signal(SIGALRM, timeout);
signal(SIGALRM, alrmtimeout);
timedout = 1;
}
@ -453,11 +474,13 @@ timeout()
* Stolen from consh() -- puts a remote file on the output of a local command.
* Identical to consh() except for where stdout goes.
*/
void
pipeout(c)
char c;
{
char buf[256];
int cpid, status, p;
time_t start;
time_t start = 0;
putchar(c);
if (prompt("Local command? ", buf))
@ -478,7 +501,7 @@ pipeout(c)
while ((p = wait(&status)) > 0 && p != cpid)
;
} else {
register int i;
int i;
dup2(FD, 1);
for (i = 3; i < 20; i++)
@ -504,11 +527,13 @@ pipeout(c)
* 1 <-> remote tty out
* 2 <-> local tty out
*/
void
consh(c)
char c;
{
char buf[256];
int cpid, status, p;
time_t start;
time_t start = 0;
putchar(c);
if (prompt("Local command? ", buf))
@ -529,7 +554,7 @@ consh(c)
while ((p = wait(&status)) > 0 && p != cpid)
;
} else {
register int i;
int i;
dup2(FD, 0);
dup2(3, 1);
@ -553,34 +578,41 @@ consh(c)
/*
* Escape to local shell
*/
shell()
void
shell(dummy)
char dummy;
{
int shpid, status;
extern char **environ;
char *cp;
printf("[sh]\r\n");
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
unraw();
if (shpid = fork()) {
switch (shpid = fork()) {
default:
while (shpid != wait(&status));
raw();
printf("\r\n!\r\n");
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
return;
} else {
break;
case 0:
signal(SIGQUIT, SIG_DFL);
signal(SIGINT, SIG_DFL);
if ((cp = rindex(value(SHELL), '/')) == NULL)
if ((cp = strrchr(value(SHELL), '/')) == NULL)
cp = value(SHELL);
else
cp++;
shell_uid();
execl(value(SHELL), cp, 0);
printf("\r\ncan't execl!\r\n");
exit(1);
fprintf(stderr, "\r\n");
err(1, "can't execl");
/* NOTREACHED */
case -1:
fprintf(stderr, "\r\n");
err(1, "can't fork");
/* NOTREACHED */
}
}
@ -588,6 +620,7 @@ shell()
* TIPIN portion of scripting
* initiate the conversation with TIPOUT
*/
void
setscript()
{
char c;
@ -596,7 +629,7 @@ setscript()
*/
kill(pid, SIGEMT);
if (boolean(value(SCRIPT)))
write(fildes[1], value(RECORD), size(value(RECORD)));
write(fildes[1], value(RECORD), strlen(value(RECORD)));
write(fildes[1], "\n", 1);
/*
* wait for TIPOUT to finish
@ -610,10 +643,12 @@ setscript()
* Change current working directory of
* local portion of tip
*/
chdirectory()
void
chdirectory(dummy)
char dummy;
{
char dirname[80];
register char *cp = dirname;
char *cp = dirname;
if (prompt("[cd] ", dirname)) {
if (stoprompt)
@ -625,13 +660,14 @@ chdirectory()
printf("!\r\n");
}
void
tipabort(msg)
char *msg;
{
kill(pid, SIGTERM);
disconnect(msg);
if (msg != NOSTR)
if (msg != NULL)
printf("\r\n%s", msg);
printf("\r\n[EOT]\r\n");
daemon_uid();
@ -640,31 +676,35 @@ tipabort(msg)
exit(0);
}
finish()
void
finish(dummy)
char dummy;
{
char *dismsg;
if ((dismsg = value(DISCONNECT)) != NOSTR) {
if ((dismsg = value(DISCONNECT)) != NULL) {
write(FD, dismsg, strlen(dismsg));
sleep(5);
}
tipabort(NOSTR);
tipabort(NULL);
}
void
intcopy()
intcopy(dummy)
int dummy;
{
raw();
quit = 1;
longjmp(intbuf, 1);
}
void
execute(s)
char *s;
{
register char *cp;
char *cp;
if ((cp = rindex(value(SHELL), '/')) == NULL)
if ((cp = strrchr(value(SHELL), '/')) == NULL)
cp = value(SHELL);
else
cp++;
@ -672,12 +712,13 @@ execute(s)
execl(value(SHELL), cp, "-c", s, 0);
}
int
args(buf, a)
char *buf, *a[];
{
register char *p = buf, *start;
register char **parg = a;
register int n = 0;
char *p = buf, *start;
char **parg = a;
int n = 0;
do {
while (*p && (*p == ' ' || *p == '\t'))
@ -696,11 +737,12 @@ args(buf, a)
return(n);
}
void
prtime(s, a)
char *s;
time_t a;
{
register i;
int i;
int nums[3];
for (i = 0; i < 3; i++) {
@ -709,13 +751,15 @@ prtime(s, a)
}
printf("%s", s);
while (--i >= 0)
if (nums[i] || i == 0 && nums[1] == 0 && nums[2] == 0)
if (nums[i] || (i == 0 && nums[1] == 0 && nums[2] == 0))
printf("%d %s%c ", nums[i], sep[i],
nums[i] == 1 ? '\0' : 's');
printf("\r\n!\r\n");
}
variable()
void
variable(dummy)
char dummy;
{
char buf[256];
@ -754,13 +798,14 @@ variable()
}
if (vtable[PARITY].v_access&CHANGED) {
vtable[PARITY].v_access &= ~CHANGED;
setparity();
setparity(NULL); /* XXX what is the correct arg? */
}
}
/*
* Turn tandem mode on or off for remote tty.
*/
void
tandem(option)
char *option;
{
@ -781,7 +826,9 @@ tandem(option)
/*
* Send a break.
*/
genbrk()
void
genbrk(dummy)
char dummy;
{
ioctl(FD, TIOCSBRK, NULL);
@ -792,6 +839,7 @@ genbrk()
/*
* Suspend tip
*/
void
suspend(c)
char c;
{
@ -811,22 +859,20 @@ expand(name)
{
static char xname[BUFSIZ];
char cmdbuf[BUFSIZ];
register int pid, l, rc;
register char *cp, *Shell;
int s, pivec[2], (*sigint)();
int pid, l;
char *cp, *Shell;
int s, pivec[2];
if (!anyof(name, "~{[*?$`'\"\\"))
return(name);
/* sigint = signal(SIGINT, SIG_IGN); */
if (pipe(pivec) < 0) {
perror("pipe");
/* signal(SIGINT, sigint) */
return(name);
}
(void)snprintf(cmdbuf, sizeof cmdbuf, "echo %s", name);
if ((pid = vfork()) == 0) {
Shell = value(SHELL);
if (Shell == NOSTR)
if (Shell == NULL)
Shell = _PATH_BSHELL;
close(pivec[0]);
close(1);
@ -841,7 +887,7 @@ expand(name)
perror("fork");
close(pivec[0]);
close(pivec[1]);
return(NOSTR);
return(NULL);
}
close(pivec[1]);
l = read(pivec[0], xname, BUFSIZ);
@ -851,19 +897,19 @@ expand(name)
s &= 0377;
if (s != 0 && s != SIGPIPE) {
fprintf(stderr, "\"Echo\" failed\n");
return(NOSTR);
return(NULL);
}
if (l < 0) {
perror("read");
return(NOSTR);
return(NULL);
}
if (l == 0) {
fprintf(stderr, "\"%s\": No match\n", name);
return(NOSTR);
return(NULL);
}
if (l == BUFSIZ) {
fprintf(stderr, "Buffer overflow expanding \"%s\"\n", name);
return(NOSTR);
return(NULL);
}
xname[l] = 0;
for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--)
@ -876,12 +922,13 @@ expand(name)
* Are any of the characters in the two strings the same?
*/
int
anyof(s1, s2)
register char *s1, *s2;
char *s1, *s2;
{
register int c;
int c;
while (c = *s1++)
while ((c = *s1++))
if (any(c, s2))
return(1);
return(0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmdtab.c,v 1.3 1994/12/08 09:30:46 jtc Exp $ */
/* $NetBSD: cmdtab.c,v 1.4 1997/11/22 07:28:42 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,19 +33,16 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: cmdtab.c,v 1.3 1994/12/08 09:30:46 jtc Exp $";
__RCSID("$NetBSD: cmdtab.c,v 1.4 1997/11/22 07:28:42 lukem Exp $");
#endif /* not lint */
#include "tip.h"
extern int shell(), getfl(), sendfile(), chdirectory();
extern int finish(), help(), pipefile(), pipeout(), consh(), variable();
extern int cu_take(), cu_put(), dollar(), genbrk(), suspend();
esctable_t etable[] = {
{ '!', NORM, "shell", shell },
{ '<', NORM, "receive file from remote host", getfl },

View File

@ -1,4 +1,4 @@
/* $NetBSD: cu.c,v 1.5 1997/02/11 09:24:05 mrg Exp $ */
/* $NetBSD: cu.c,v 1.6 1997/11/22 07:28:42 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,31 +33,32 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cu.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: cu.c,v 1.5 1997/02/11 09:24:05 mrg Exp $";
__RCSID("$NetBSD: cu.c,v 1.6 1997/11/22 07:28:42 lukem Exp $");
#endif /* not lint */
#include "tip.h"
void cleanup();
/*
* Botch the interface to look like cu's
*/
int
cumain(argc, argv)
char *argv[];
{
register int i;
int i;
static char sbuf[12];
if (argc < 2) {
printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
fprintf(stderr,
"usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
exit(8);
}
CU = DV = NOSTR;
CU = DV = NULL;
BR = DEFBR;
for (; argc > 1; argv++, argc--) {
if (argv[1][0] != '-')
@ -108,7 +109,7 @@ cumain(argc, argv)
* The "cu" host name is used to define the
* attributes of the generic dialer.
*/
(void)snprintf(sbuf, sizeof sbuf, "cu%d", BR);
(void)snprintf(sbuf, sizeof sbuf, "cu%d", (int)BR);
if ((i = hunt(sbuf)) == 0) {
printf("all ports busy\n");
exit(3);
@ -134,4 +135,5 @@ cumain(argc, argv)
}
if (!HW)
ttysetup(speed(BR));
exit(0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: hunt.c,v 1.7 1997/05/14 00:20:01 mellon Exp $ */
/* $NetBSD: hunt.c,v 1.8 1997/11/22 07:28:43 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,39 +33,40 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: hunt.c,v 1.7 1997/05/14 00:20:01 mellon Exp $";
__RCSID("$NetBSD: hunt.c,v 1.8 1997/11/22 07:28:43 lukem Exp $");
#endif /* not lint */
#include "tip.h"
extern char *getremote();
extern char *rindex();
static jmp_buf deadline;
static int deadfl;
void dead __P((int));
void
dead()
dead(dummy)
int dummy;
{
deadfl = 1;
longjmp(deadline, 1);
}
long
int
hunt(name)
char *name;
{
register char *cp;
char *cp;
sig_t f;
f = signal(SIGALRM, dead);
while (cp = getremote(name)) {
while ((cp = getremote(name)) != NULL) {
deadfl = 0;
uucplock = rindex(cp, '/')+1;
uucplock = strrchr(cp, '/')+1;
if (uu_lock(uucplock) < 0)
continue;
/*
@ -95,10 +96,10 @@ hunt(name)
tcsetattr(FD, TCSAFLUSH, &cntrl);
ioctl(FD, TIOCEXCL, 0);
signal(SIGALRM, SIG_DFL);
return ((long)cp);
return (cp != NULL);
}
(void)uu_unlock(uucplock);
}
signal(SIGALRM, f);
return (deadfl ? -1 : (long)cp);
return (deadfl ? -1 : cp != NULL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: log.c,v 1.4 1994/12/24 17:56:28 cgd Exp $ */
/* $NetBSD: log.c,v 1.5 1997/11/22 07:28:44 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: log.c,v 1.4 1994/12/24 17:56:28 cgd Exp $";
__RCSID("$NetBSD: log.c,v 1.5 1997/11/22 07:28:44 lukem Exp $");
#endif /* not lint */
#include "tip.h"
@ -49,6 +50,7 @@ static FILE *flog = NULL;
* Log file maintenance routines
*/
void
logent(group, num, acu, message)
char *group, *num, *acu, *message;
{
@ -62,8 +64,8 @@ logent(group, num, acu, message)
perror("tip: flock");
return;
}
if ((user = getlogin()) == NOSTR)
if ((pwd = getpwuid(getuid())) == NOPWD)
if ((user = getlogin()) == NULL)
if ((pwd = getpwuid(getuid())) == NULL)
user = "???";
else
user = pwd->pw_name;
@ -82,6 +84,7 @@ logent(group, num, acu, message)
(void) flock(fileno(flog), LOCK_UN);
}
void
loginit()
{
flog = fopen(value(LOG), "a");

View File

@ -1,4 +1,4 @@
/* $NetBSD: partab.c,v 1.4 1996/12/29 10:38:21 cgd Exp $ */
/* $NetBSD: partab.c,v 1.5 1997/11/22 07:28:44 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)partab.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: partab.c,v 1.4 1996/12/29 10:38:21 cgd Exp $";
__RCSID("$NetBSD: partab.c,v 1.5 1997/11/22 07:28:44 lukem Exp $");
#endif /* not lint */
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: remote.c,v 1.6 1997/05/14 00:20:03 mellon Exp $ */
/* $NetBSD: remote.c,v 1.7 1997/11/22 07:28:45 lukem Exp $ */
/*
* Copyright (c) 1992, 1993
@ -34,22 +34,19 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1992, 1993\n\
The Regents of the University of California. All rights reserved.\n";
__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)remote.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: remote.c,v 1.6 1997/05/14 00:20:03 mellon Exp $";
__RCSID("$NetBSD: remote.c,v 1.7 1997/11/22 07:28:45 lukem Exp $");
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include "pathnames.h"
#include "tip.h"
@ -71,11 +68,13 @@ static char *db_array[3] = { _PATH_REMOTE, 0, 0 };
#define cgetflag(f) (cgetcap(bp, f, ':') != NULL)
static
static void getremcap __P((char *));
static void
getremcap(host)
register char *host;
char *host;
{
register char **p, ***q;
char **p, ***q;
char *bp;
char *rempath;
int stat;
@ -92,7 +91,7 @@ getremcap(host)
if ((stat = cgetent(&bp, db_array, host)) < 0) {
if (DV ||
host[0] == '/' && access(DV = host, R_OK | W_OK) == 0) {
(host[0] == '/' && access(DV = host, R_OK | W_OK) == 0)) {
CU = DV;
HO = host;
HW = 1;
@ -129,13 +128,13 @@ getremcap(host)
DU = 0;
else
DU = cgetflag("du");
if (DV == NOSTR) {
if (DV == NULL) {
fprintf(stderr, "%s: missing device spec\n", host);
exit(3);
}
if (DU && CU == NOSTR)
if (DU && CU == NULL)
CU = DV;
if (DU && PN == NOSTR) {
if (DU && PN == NULL) {
fprintf(stderr, "%s: missing phone number\n", host);
exit(3);
}
@ -147,7 +146,7 @@ getremcap(host)
* from the description file
*/
if (!HW)
HW = (CU == NOSTR) || (DU && equal(DV, CU));
HW = (CU == NULL) || (DU && equal(DV, CU));
HO = host;
/*
* see if uppercase mode should be turned on initially
@ -178,17 +177,17 @@ getremcap(host)
setboolean(value(HALFDUPLEX), 1);
if (cgetflag("dc"))
DC = 1;
if (RE == NOSTR)
if (RE == NULL)
RE = (char *)"tip.record";
if (EX == NOSTR)
if (EX == NULL)
EX = (char *)"\t\n\b\f";
if (ES != NOSTR)
if (ES != NULL)
vstring("es", ES);
if (FO != NOSTR)
if (FO != NULL)
vstring("fo", FO);
if (PR != NOSTR)
if (PR != NULL)
vstring("pr", PR);
if (RC != NOSTR)
if (RC != NULL)
vstring("rc", RC);
if (cgetnum(bp, "dl", &DL) == -1)
DL = 0;
@ -202,12 +201,12 @@ char *
getremote(host)
char *host;
{
register char *cp;
char *cp;
static char *next;
static int lookedup = 0;
if (!lookedup) {
if (host == NOSTR && (host = getenv("HOST")) == NOSTR) {
if (host == NULL && (host = getenv("HOST")) == NULL) {
fprintf(stderr, "tip: no host specified\n");
exit(3);
}
@ -219,11 +218,11 @@ getremote(host)
* We return a new device each time we're called (to allow
* a rotary action to be simulated)
*/
if (next == NOSTR)
return (NOSTR);
if ((cp = index(next, ',')) == NULL) {
if (next == NULL)
return (NULL);
if ((cp = strchr(next, ',')) == NULL) {
DV = next;
next = NOSTR;
next = NULL;
} else {
*cp++ = '\0';
DV = next;

View File

@ -1,4 +1,4 @@
.\" $NetBSD: tip.1,v 1.7 1994/12/08 09:31:05 jtc Exp $
.\" $NetBSD: tip.1,v 1.8 1997/11/22 07:28:46 lukem Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@ -41,11 +41,11 @@
.\" .Nm cu
.Nd connect to a remote system
.Sh SYNOPSIS
.Nm tip
.Nm
.Op Fl v
.Fl Ns Ns Ar speed
.Ar system\-name
.Nm tip
.Nm ""
.Op Fl v
.Fl Ns Ns Ar speed
.Ar phone\-number
@ -57,7 +57,7 @@
.\" .Op Fl l Ar line
.\" .Op Fl #
.Sh DESCRIPTION
.Nm Tip
.Nm
.\" and
.\" .Nm cu
establish a full-duplex connection to another machine,
@ -100,11 +100,11 @@ Escape to a shell (exiting the shell will
return you to tip).
.It Ic \&~>
Copy file from local to remote.
.Nm Tip
.Nm
prompts for the name of a local file to transmit.
.It Ic \&~<
Copy file from remote to local.
.Nm Tip
.Nm
prompts first for the name of the file to be sent, then for
a command to be executed on the remote machine.
.It Ic \&~p Ar from Op Ar to
@ -113,7 +113,7 @@ Send a file to a remote
host. The put command causes the remote
.Ux
system to run the command string ``cat > 'to''', while
.Nm tip
.Nm
sends it the ``from''
file. If the ``to'' file isn't specified the ``from'' file name is used.
This command is actually a
@ -127,7 +127,7 @@ As in the put command the ``to'' file
defaults to the ``from'' file name if it isn't specified.
The remote host
executes the command string ``cat 'from';echo ^A'' to send the file to
.Nm tip .
.Nm "" .
.It Ic \&~|
Pipe the output from a remote command to a local
.Ux
@ -170,20 +170,20 @@ characters.
Set a variable (see the discussion below).
.It Ic \&~^Z
Stop
.Nm tip
.Nm
(only available with job control).
.It Ic \&~^Y
Stop only the ``local side'' of
.Nm tip
.Nm
(only available with job control);
the ``remote side'' of
.Nm tip ,
.Nm "" ,
the side that displays output from the remote host, is left running.
.It Ic \&~?
Get a summary of the tilde escapes
.El
.Pp
.Nm Tip
.Nm
uses the file
.Pa /etc/remote
to find how to reach a particular
@ -198,7 +198,7 @@ to be used may be specified on the command line, e.g.
.Ql "tip -300 mds" .
.Pp
When
.Nm tip
.Nm
establishes a connection it sends out a
connection message to the remote system; the default value, if any,
is defined in
@ -207,21 +207,21 @@ is defined in
.Xr remote 5 ) .
.Pp
When
.Nm tip
.Nm
prompts for an argument (e.g. during setup of
a file transfer) the line typed may be edited with the standard
erase and kill characters. A null line in response to a prompt,
or an interrupt, will abort the dialogue and return you to the
remote machine.
.Pp
.Nm Tip
.Nm
guards against multiple users connecting to a remote system
by opening modems and terminal lines with exclusive access,
and by honoring the locking protocol used by
.Xr uucico 8 .
.Pp
During file transfers
.Nm tip
.Nm
provides a running count of the number of lines transferred.
When using the ~> and ~< commands, the ``eofread'' and ``eofwrite''
variables are used to recognize end-of-file when reading, and
@ -229,15 +229,15 @@ specify end-of-file when writing (see below). File transfers
normally depend on tandem mode for flow control. If the remote
system does not support tandem mode, ``echocheck'' may be set
to indicate
.Nm tip
.Nm
should synchronize with the remote system on the echo of each
transmitted character.
.Pp
When
.Nm tip
.Nm
must dial a phone number to connect to a system it will print
various messages indicating its actions.
.Nm Tip
.Nm
supports the
.Tn DEC DN Ns-11
and
@ -249,7 +249,7 @@ and
Ventel 212+, Racal-Vadic 3451, and
Bizcomp 1031 and 1032 integral call unit/modems.
.Ss VARIABLES
.Nm Tip
.Nm
maintains a set of
.Ar variables
which control its operation.
@ -278,7 +278,7 @@ Variables may be initialized at run time by placing set commands
in one's home directory). The
.Fl v
option causes
.Nm tip
.Nm
to display the sets as they are made.
Certain common variables have abbreviations.
The following is a list of common variables,
@ -310,7 +310,7 @@ a ~> file transfer command; abbreviated
.Ar eofw .
.It Ar eol
(str) The set of characters which indicate an end-of-line.
.Nm Tip
.Nm
will recognize escape characters only after an end-of-line.
.It Ar escape
(char) The command prefix (escape) character; abbreviated
@ -347,7 +347,7 @@ default value is
.Ar off .
When this mode is enabled, all lower case letters will be mapped to
upper case by
.Nm tip
.Nm
for transmission to the remote machine.
.It Ar raisechar
(char) The input character used to toggle upper case mapping mode;
@ -368,7 +368,7 @@ When
.Ar script
is
.Li true ,
.Nm tip
.Nm
will record everything transmitted by the remote machine in
the script record file specified in
.Ar record .
@ -394,13 +394,13 @@ Each tab is expanded to 8 spaces.
default is
.Ar true .
When verbose mode is enabled,
.Nm tip
.Nm
prints messages while dialing, shows the current number
of lines transferred during a file transfer operations,
and more.
.El
.Sh ENVIRONMENT
.Nm Tip
.Nm
uses the following environment variables:
.Bl -tag -width Fl
.It Ev SHELL
@ -445,7 +445,7 @@ Diagnostics are, hopefully, self explanatory.
.Xr phones 5
.Sh HISTORY
The
.Nm tip
.Nm
appeared command in
.Bx 4.2 .
.Sh BUGS

View File

@ -1,4 +1,4 @@
/* $NetBSD: tip.c,v 1.14 1997/05/14 00:20:05 mellon Exp $ */
/* $NetBSD: tip.c,v 1.15 1997/11/22 07:28:47 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,17 +33,17 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
__COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: tip.c,v 1.14 1997/05/14 00:20:05 mellon Exp $";
__RCSID("$NetBSD: tip.c,v 1.15 1997/11/22 07:28:47 lukem Exp $");
#endif /* not lint */
/*
@ -64,25 +64,29 @@ int rates[] = {
};
int disc = TTYDISC; /* tip normally runs this way */
void intprompt();
void timeout();
void cleanup();
char *sname();
int escape __P((void));
int main __P((int, char **));
void intprompt __P((int));
void tipin __P((void));
char PNbuf[256]; /* This limits the size of a number */
int
main(argc, argv)
int argc;
char *argv[];
{
char *system = NOSTR;
register int i;
register char *p;
char *system = NULL;
int i;
char *p;
char sbuf[12];
gid = getgid();
egid = getegid();
uid = getuid();
euid = geteuid();
if (equal(sname(argv[0]), "cu")) {
if (equal(basename(argv[0]), "cu")) {
cumode = 1;
cumain(argc, argv);
goto cucommon;
@ -97,6 +101,7 @@ main(argc, argv)
exit(1);
}
/* XXX: use getopt */
for (; argc > 1; argv++, argc--) {
if (argv[1][0] != '-')
system = argv[1];
@ -117,7 +122,7 @@ main(argc, argv)
}
}
if (system == NOSTR)
if (system == NULL)
goto notnumber;
if (isalpha(*system))
goto notnumber;
@ -135,7 +140,7 @@ main(argc, argv)
for (p = system; *p; p++)
*p = '\0';
PN = PNbuf;
(void)snprintf(sbuf, sizeof sbuf, "tip%d", BR);
(void)snprintf(sbuf, sizeof sbuf, "tip%d", (int)BR);
system = sbuf;
notnumber:
@ -169,12 +174,12 @@ notnumber:
* Kludge, their's no easy way to get the initialization
* in the right order, so force it here
*/
if ((PH = getenv("PHONES")) == NOSTR)
if ((PH = getenv("PHONES")) == NULL)
PH = _PATH_PHONES;
vinit(); /* init variables */
setparity("even"); /* set the parity table */
if ((i = speed(number(value(BAUDRATE)))) == 0) {
printf("tip: bad baud rate %d\n", number(value(BAUDRATE)));
printf("tip: bad baud rate %d\n", (int)number(value(BAUDRATE)));
daemon_uid();
(void)uu_unlock(uucplock);
exit(3);
@ -187,7 +192,7 @@ notnumber:
*/
if (HW)
ttysetup(i);
if (p = connect()) {
if ((p = connect()) != NULL) {
printf("\07%s\n[EOT]\n", p);
daemon_uid();
(void)uu_unlock(uucplock);
@ -215,7 +220,7 @@ cucommon:
raw();
pipe(fildes); pipe(repdes);
(void)signal(SIGALRM, timeout);
(void)signal(SIGALRM, alrmtimeout);
/*
* Everything's set up now:
@ -225,15 +230,23 @@ cucommon:
* so, fork one process for local side and one for remote.
*/
printf(cumode ? "Connected\r\n" : "\07connected\r\n");
if (pid = fork())
switch (pid = fork()) {
default:
tipin();
else
break;
case 0:
tipout();
break;
case -1:
err(1, "can't fork");
}
/*NOTREACHED*/
exit(0); /* XXX: pacify gcc */
}
void
cleanup()
cleanup(dummy)
int dummy;
{
daemon_uid();
@ -253,6 +266,7 @@ cleanup()
*/
static int uidswapped;
void
user_uid()
{
if (uidswapped == 0) {
@ -261,6 +275,7 @@ user_uid()
}
}
void
daemon_uid()
{
@ -270,6 +285,7 @@ daemon_uid()
}
}
void
shell_uid()
{
seteuid(uid);
@ -278,6 +294,7 @@ shell_uid()
/*
* put the controlling keyboard into raw mode
*/
void
raw()
{
tcsetattr(0, TCSADRAIN, &term);
@ -287,6 +304,7 @@ raw()
/*
* return keyboard to normal mode
*/
void
unraw()
{
tcsetattr(0, TCSADRAIN, &defterm);
@ -299,14 +317,19 @@ static jmp_buf promptbuf;
* in from the terminal. Handles signals & allows use of
* normal erase and kill characters.
*/
int
prompt(s, p)
char *s;
register char *p;
char *p;
{
register int c;
register char *b = p;
int c;
char *b = p;
sig_t oint, oquit;
#if __GNUC__ /* XXX: pacify gcc */
(void)&p;
#endif
stoprompt = 0;
oint = signal(SIGINT, intprompt);
oquit = signal(SIGQUIT, SIG_IGN);
@ -327,7 +350,8 @@ prompt(s, p)
* Interrupt service routine during prompting
*/
void
intprompt()
intprompt(dummy)
int dummy;
{
(void)signal(SIGINT, SIG_IGN);
@ -339,6 +363,7 @@ intprompt()
/*
* ****TIPIN TIPIN****
*/
void
tipin()
{
char gch, bol = 1;
@ -380,16 +405,15 @@ tipin()
}
}
extern esctable_t etable[];
/*
* Escape handler --
* called on recognition of ``escapec'' at the beginning of a line
*/
int
escape()
{
register char gch;
register esctable_t *p;
char gch;
esctable_t *p;
char c = character(value(ESCAPE));
gch = (getchar()&STRIP_PAR);
@ -407,10 +431,11 @@ escape()
return (gch);
}
int
speed(n)
int n;
{
register int *p;
int *p;
for (p = rates; *p != -1; p++)
if (*p == n)
@ -418,8 +443,9 @@ speed(n)
return 0;
}
int
any(c, p)
register char c, *p;
char c, *p;
{
while (p && *p)
if (*p++ == c)
@ -427,24 +453,14 @@ any(c, p)
return (0);
}
size(s)
register char *s;
{
register int i = 0;
while (s && *s++)
i++;
return (i);
}
char *
interp(s)
register char *s;
char *s;
{
static char buf[256];
register char *p = buf, c, *q;
char *p = buf, c, *q;
while (c = *s++) {
while ((c = *s++) != 0) {
for (q = "\nn\rr\tt\ff\033E\bb"; *q; q++)
if (*q++ == c) {
*p++ = '\\'; *p++ = *q;
@ -483,10 +499,11 @@ ctrl(c)
/*
* Help command
*/
void
help(c)
char c;
{
register esctable_t *p;
esctable_t *p;
printf("%c\r\n", c);
for (p = etable; p->e_char; p++) {
@ -501,6 +518,7 @@ help(c)
/*
* Set up the "remote" tty's state
*/
void
ttysetup(speed)
int speed;
{
@ -523,22 +541,6 @@ ttysetup(speed)
tcsetattr(FD, TCSAFLUSH, &cntrl);
}
/*
* Return "simple" name from a file name,
* strip leading directories.
*/
char *
sname(s)
register char *s;
{
register char *p = s;
while (*s)
if (*s++ == '/')
p = s;
return (p);
}
static char partab[0200];
/*
@ -546,14 +548,14 @@ static char partab[0200];
* We are doing 8 bit wide output, so we just generate a character
* with the right parity and output it.
*/
void
pwrite(fd, buf, n)
int fd;
char *buf;
register int n;
int n;
{
register int i;
register char *bp;
extern int errno;
int i;
char *bp;
bp = buf;
if (bits8 == 0)
@ -572,14 +574,14 @@ pwrite(fd, buf, n)
/*
* Build a parity table with appropriate high-order bit.
*/
void
setparity(defparity)
char *defparity;
{
register int i, flip, clr, set;
int i, flip, clr, set;
char *parity;
extern unsigned char evenpartab[];
if (value(PARITY) == NOSTR)
if (value(PARITY) == NULL)
value(PARITY) = defparity;
parity = value(PARITY);
if (equal(parity, "none")) {
@ -601,5 +603,5 @@ setparity(defparity)
(void) fflush(stderr);
}
for (i = 0; i < 0200; i++)
partab[i] = (evenpartab[i] ^ flip | set) & clr;
partab[i] = ((evenpartab[i] ^ flip) | set) & clr;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */
/* $NetBSD: tip.h,v 1.8 1997/11/22 07:28:48 lukem Exp $ */
/*
* Copyright (c) 1989, 1993
@ -41,20 +41,26 @@
*/
#include <sys/types.h>
#include <machine/endian.h>
#include <sys/dir.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <machine/endian.h>
#include <termios.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <libgen.h>
#include <pwd.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
#include <ctype.h>
#include <setjmp.h>
#include <termios.h>
#include <unistd.h>
#include <errno.h>
/*
* Remote host attributes
@ -101,6 +107,10 @@ typedef
char v_access; /* protection of touchy ones */
char *v_abrev; /* possible abreviation */
char *v_value; /* casted to a union later */
/*
* XXX: this assumes that the storage space
* of a pointer >= that of a long
*/
}
value_t;
@ -131,9 +141,9 @@ typedef
typedef
struct {
char *acu_name;
int (*acu_dialer)();
int (*acu_disconnect)();
int (*acu_abort)();
int (*acu_dialer) __P((char *, char *));
void (*acu_disconnect) __P((void));
void (*acu_abort) __P((void));
}
acu_t;
@ -166,10 +176,10 @@ typedef
typedef
struct {
char e_char; /* char to match on */
char e_flags; /* experimental, priviledged */
char *e_help; /* help string */
int (*e_func)(); /* command */
char e_char; /* char to match on */
char e_flags; /* experimental, priviledged */
char *e_help; /* help string */
void (*e_func) __P((char)); /* command */
}
esctable_t;
@ -188,6 +198,8 @@ extern value_t vtable[]; /* variable table */
/*
* Definition of indices into variable table so
* value(DEFINE) turns into a static address.
*
* XXX: keep in sync with vtable[] in vars.c
*/
#define BEAUTIFY 0
@ -224,12 +236,6 @@ extern value_t vtable[]; /* variable table */
#define LECHO 31
#define PARITY 32
#define NOVAL ((value_t *)NULL)
#define NOACU ((acu_t *)NULL)
#define NOSTR ((char *)NULL)
#define NOFILE ((FILE *)NULL)
#define NOPWD ((struct passwd *)0)
struct termios term; /* current mode of terminal */
struct termios defterm; /* initial mode of terminal */
struct termios defchars; /* current mode with initial chars */
@ -263,6 +269,89 @@ char *uucplock; /* name of lock file for uucp's */
int odisc; /* initial tty line discipline */
extern int disc; /* current tty discpline */
extern char *ctrl();
extern char *vinterp();
extern char *connect();
extern acu_t acutable[];
extern esctable_t etable[];
extern unsigned char evenpartab[];
void alrmtimeout __P((int));
int any __P((char, char *));
void chdirectory __P((char));
void cleanup __P((int));
char *connect __P((void));
void consh __P((char));
char *ctrl __P((char));
int cumain __P((int, char **));
void cu_put __P((char));
void cu_take __P((char));
void daemon_uid __P((void));
void disconnect __P((char *));
char *expand __P((char *));
void finish __P((char));
void genbrk __P((char));
void getfl __P((char));
char *getremote __P((char *));
void help __P((char));
int hunt __P((char *));
char *interp __P((char *));
void logent __P((char *, char *, char *, char *));
void loginit __P((void));
void pipefile __P((char));
void pipeout __P((char));
int prompt __P((char *, char *));
void pwrite __P((int, char *, int));
void raw __P((void));
void send __P((char));
void sendfile __P((char));
void setparity __P((char *));
void setscript __P((void));
void shell __P((char));
void shell_uid __P((void));
int speed __P((int));
void suspend __P((char));
void tandem __P((char *));
void tipabort __P((char *));
void tipout __P((void));
void ttysetup __P((int));
void unraw __P((void));
void user_uid __P((void));
int uu_lock __P((char *));
int uu_unlock __P((char *));
void variable __P((char));
void vinit __P((void));
char *vinterp __P((char *, char));
void vlex __P((char *));
int vstring __P((char *, char *));
void biz22_abort __P((void));
void biz22_disconnect __P((void));
int biz22f_dialer __P((char *, char *));
int biz22w_dialer __P((char *, char *));
void biz31_abort __P((void));
void biz31_disconnect __P((void));
int biz31f_dialer __P((char *, char *));
int biz31w_dialer __P((char *, char *));
void cour_abort __P((void));
int cour_dialer __P((char *, char *));
void cour_disconnect __P((void));
int df02_dialer __P((char *, char *));
int df03_dialer __P((char *, char *));
void df_abort __P((void));
void df_disconnect __P((void));
void dn_abort __P((void));
int dn_dialer __P((char *, char *));
void dn_disconnect __P((void));
void hay_abort __P((void));
int hay_dialer __P((char *, char *));
void hay_disconnect __P((void));
void t3000_abort __P((void));
int t3000_dialer __P((char *, char *));
void t3000_disconnect __P((void));
void v3451_abort __P((void));
int v3451_dialer __P((char *, char *));
void v3451_disconnect __P((void));
void v831_abort __P((void));
int v831_dialer __P((char *, char *));
void v831_disconnect __P((void));
void ven_abort __P((void));
int ven_dialer __P((char *, char *));
void ven_disconnect __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: tipout.c,v 1.5 1996/12/29 10:34:12 cgd Exp $ */
/* $NetBSD: tipout.c,v 1.6 1997/11/22 07:28:48 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)tipout.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: tipout.c,v 1.5 1996/12/29 10:34:12 cgd Exp $";
__RCSID("$NetBSD: tipout.c,v 1.6 1997/11/22 07:28:48 lukem Exp $");
#endif /* not lint */
#include "tip.h"
@ -50,12 +51,18 @@ static char rcsid[] = "$NetBSD: tipout.c,v 1.5 1996/12/29 10:34:12 cgd Exp $";
static jmp_buf sigbuf;
void intEMT __P((int));
void intIOT __P((int));
void intSYS __P((int));
void intTERM __P((int));
/*
* TIPOUT wait state routine --
* sent by TIPIN when it wants to posses the remote host
*/
void
intIOT()
intIOT(dummy)
int dummy;
{
write(repdes[1],&ccc,1);
@ -68,10 +75,11 @@ intIOT()
* accepts script file name over the pipe and acts accordingly
*/
void
intEMT()
intEMT(dummy)
int dummy;
{
char c, line[256];
register char *pline = line;
char *pline = line;
char reply;
read(fildes[0], &c, 1);
@ -98,7 +106,8 @@ intEMT()
}
void
intTERM()
intTERM(dummy)
int dummy;
{
if (boolean(value(SCRIPT)) && fscript != NULL)
@ -107,7 +116,8 @@ intTERM()
}
void
intSYS()
intSYS(dummy)
int dummy;
{
setboolean(value(BEAUTIFY), !boolean(value(BEAUTIFY)));
@ -117,12 +127,12 @@ intSYS()
/*
* ****TIPOUT TIPOUT****
*/
void
tipout()
{
char buf[BUFSIZ];
register char *cp;
register int cnt;
extern int errno;
char *cp;
int cnt;
int omask;
signal(SIGINT, SIG_IGN);
@ -139,7 +149,7 @@ tipout()
/* lost carrier */
if (cnt < 0 && errno == EIO) {
sigblock(sigmask(SIGTERM));
intTERM();
intTERM(0);
/*NOTREACHED*/
}
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: uucplock.c,v 1.8 1997/08/25 19:32:02 kleink Exp $ */
/* $NetBSD: uucplock.c,v 1.9 1997/11/22 07:28:49 lukem Exp $ */
/*
* Copyright (c) 1988, 1993
@ -33,21 +33,16 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)uucplock.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: uucplock.c,v 1.8 1997/08/25 19:32:02 kleink Exp $";
__RCSID("$NetBSD: uucplock.c,v 1.9 1997/11/22 07:28:49 lukem Exp $");
#endif /* not lint */
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/dir.h>
#include <errno.h>
#include "pathnames.h"
#include "tip.h"
/*
* uucp style locking routines
@ -55,6 +50,7 @@ static char rcsid[] = "$NetBSD: uucplock.c,v 1.8 1997/08/25 19:32:02 kleink Exp
* -1 - failure
*/
int
uu_lock(ttyname)
char *ttyname;
{
@ -117,6 +113,7 @@ uu_lock(ttyname)
return(0);
}
int
uu_unlock(ttyname)
char *ttyname;
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: value.c,v 1.6 1997/02/11 09:24:09 mrg Exp $ */
/* $NetBSD: value.c,v 1.7 1997/11/22 07:28:50 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,33 +33,40 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)value.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: value.c,v 1.6 1997/02/11 09:24:09 mrg Exp $";
__RCSID("$NetBSD: value.c,v 1.7 1997/11/22 07:28:50 lukem Exp $");
#endif /* not lint */
#include "tip.h"
#define MIDDLE 35
static value_t *vlookup();
static int col = 0;
static int vaccess __P((unsigned, unsigned));
static void vassign __P((value_t *, char *));
static value_t *vlookup __P((char *));
static void vprint __P((value_t *));
static void vtoken __P((char *));
/*
* Variable manipulation
*/
void
vinit()
{
register value_t *p;
register char *cp;
value_t *p;
char *cp;
FILE *f;
char file[256];
char file[MAXPATHLEN];
for (p = vtable; p->v_name != NULL; p++) {
if (p->v_type&ENVIRON)
if (cp = getenv(p->v_name))
if ((cp = getenv(p->v_name)) != NULL)
p->v_value = cp;
if (p->v_type&IREMOTE)
setnumber(p->v_value, *address(p->v_value));
@ -68,16 +75,14 @@ vinit()
* Read the .tiprc file in the HOME directory
* for sets
*/
/* 8 == 1 + strlen("/.tiprc") */
(void)strncpy(file, value(HOME), sizeof(file) - 8);
strcat(file, "/.tiprc"); /* XXX strcat is safe */
snprintf(file, sizeof(file), "%s/.tiprc", value(HOME));
if ((f = fopen(file, "r")) != NULL) {
register char *tp;
char *tp;
while (fgets(file, sizeof(file)-1, f) != NULL) {
if (vflag)
printf("set %s", file);
if (tp = rindex(file, '\n'))
if ((tp = strrchr(file, '\n')) != NULL)
*tp = '\0';
vlex(file);
}
@ -89,11 +94,9 @@ vinit()
vtable[EXCEPTIONS].v_access &= ~(WRITE<<PUBLIC);
}
static int vaccess();
/*VARARGS1*/
void
vassign(p, v)
register value_t *p;
value_t *p;
char *v;
{
@ -108,7 +111,7 @@ vassign(p, v)
return;
if (!(p->v_type&(ENVIRON|INIT)))
free(p->v_value);
if ((p->v_value = strdup(v)) == NOSTR) {
if ((p->v_value = strdup(v)) == NULL) {
printf("out of core\r\n");
return;
}
@ -135,23 +138,21 @@ vassign(p, v)
p->v_access |= CHANGED;
}
static void vprint();
static void vtoken();
void
vlex(s)
register char *s;
char *s;
{
register value_t *p;
value_t *p;
if (equal(s, "all")) {
for (p = vtable; p->v_name; p++)
if (vaccess(p->v_access, READ))
vprint(p);
} else {
register char *cp;
char *cp;
do {
if (cp = vinterp(s, ' '))
if ((cp = vinterp(s, ' ')) != NULL)
cp++;
vtoken(s);
s = cp;
@ -165,18 +166,17 @@ vlex(s)
static void
vtoken(s)
register char *s;
char *s;
{
register value_t *p;
register char *cp;
char *expand();
value_t *p;
char *cp;
if (cp = index(s, '=')) {
if ((cp = strchr(s, '=')) != NULL) {
*cp = '\0';
if (p = vlookup(s)) {
if ((p = vlookup(s)) != NULL) {
cp++;
if (p->v_type&NUMBER)
vassign(p, atoi(cp));
vassign(p, (char *)atoi(cp));
else {
if (strcmp(s, "record") == 0)
cp = expand(cp);
@ -184,7 +184,7 @@ vtoken(s)
}
return;
}
} else if (cp = index(s, '?')) {
} else if ((cp = strchr(s, '?')) != NULL) {
*cp = '\0';
if ((p = vlookup(s)) && vaccess(p->v_access, READ)) {
vprint(p);
@ -195,7 +195,7 @@ vtoken(s)
p = vlookup(s);
else
p = vlookup(s+1);
if (p != NOVAL) {
if (p != NULL) {
vassign(p, s);
return;
}
@ -205,15 +205,14 @@ vtoken(s)
static void
vprint(p)
register value_t *p;
value_t *p;
{
register char *cp;
extern char *interp(), *ctrl();
char *cp;
if (col > 0 && col < MIDDLE)
while (col++ < MIDDLE)
putchar(' ');
col += size(p->v_name);
col += strlen(p->v_name);
switch (p->v_type&TMASK) {
case BOOL:
@ -228,15 +227,15 @@ vprint(p)
printf("%s=", p->v_name);
col++;
if (p->v_value) {
cp = interp(p->v_value, NULL);
col += size(cp);
cp = interp(p->v_value);
col += strlen(cp);
printf("%s", cp);
}
break;
case NUMBER:
col += 6;
printf("%s=%-5d", p->v_name, number(p->v_value));
printf("%s=%-5d", p->v_name, (int)number(p->v_value));
break;
case CHAR:
@ -244,7 +243,7 @@ vprint(p)
col++;
if (p->v_value) {
cp = ctrl(character(p->v_value));
col += size(cp);
col += strlen(cp);
printf("%s", cp);
}
break;
@ -259,7 +258,7 @@ vprint(p)
static int
vaccess(mode, rw)
register unsigned mode, rw;
unsigned mode, rw;
{
if (mode & (rw<<PUBLIC))
return (1);
@ -270,9 +269,9 @@ vaccess(mode, rw)
static value_t *
vlookup(s)
register char *s;
char *s;
{
register value_t *p;
value_t *p;
for (p = vtable; p->v_name; p++)
if (equal(p->v_name, s) || (p->v_abrev && equal(p->v_abrev, s)))
@ -282,10 +281,10 @@ vlookup(s)
char *
vinterp(s, stop)
register char *s;
char *s;
char stop;
{
register char *p = s, c;
char *p = s, c;
int num;
while ((c = *s++) && c != stop)
@ -304,7 +303,7 @@ vinterp(s, stop)
if (c >= '0' && c <= '7')
num = (num<<3)+(c-'0');
else {
register char *q = "n\nr\rt\tb\bf\f";
char *q = "n\nr\rt\tb\bf\f";
for (; *q; q++)
if (c == *q++) {
@ -337,18 +336,18 @@ vinterp(s, stop)
* assign variable s with value v (for NUMBER or STRING or CHAR types)
*/
int
vstring(s,v)
register char *s;
register char *v;
char *s;
char *v;
{
register value_t *p;
char *expand();
value_t *p;
p = vlookup(s);
if (p == 0)
return (1);
if (p->v_type&NUMBER)
vassign(p, atoi(v));
vassign(p, (char *)atoi(v));
else {
if (strcmp(s, "record") == 0)
v = expand(v);

View File

@ -1,4 +1,4 @@
/* $NetBSD: vars.c,v 1.4 1997/05/17 20:17:38 pk Exp $ */
/* $NetBSD: vars.c,v 1.5 1997/11/22 07:28:51 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93";
#endif
static char rcsid[] = "$NetBSD: vars.c,v 1.4 1997/05/17 20:17:38 pk Exp $";
__RCSID("$NetBSD: vars.c,v 1.5 1997/11/22 07:28:51 lukem Exp $");
#endif /* not lint */
#include "tip.h"
@ -58,7 +59,7 @@ value_t vtable[] = {
{ "eofwrite", STRING|IREMOTE|INIT, (READ|WRITE)<<PUBLIC,
"eofw", (char *)&OE },
{ "eol", STRING|IREMOTE|INIT, (READ|WRITE)<<PUBLIC,
NOSTR, (char *)&EL },
NULL, (char *)&EL },
{ "escape", CHAR, (READ|WRITE)<<PUBLIC,
"es", (char *)'~' },
{ "exceptions", STRING|INIT|IREMOTE, (READ|WRITE)<<PUBLIC,
@ -70,9 +71,9 @@ value_t vtable[] = {
{ "host", STRING|IREMOTE|INIT, READ<<PUBLIC,
"ho", (char *)&HO },
{ "log", STRING|INIT, (READ|WRITE)<<ROOT,
NOSTR, _PATH_ACULOG },
NULL, _PATH_ACULOG },
{ "phones", STRING|INIT|IREMOTE, READ<<PUBLIC,
NOSTR, (char *)&PH },
NULL, (char *)&PH },
{ "prompt", CHAR, (READ|WRITE)<<PUBLIC,
"pr", (char *)'\n' },
{ "raise", BOOL, (READ|WRITE)<<PUBLIC,
@ -82,7 +83,7 @@ value_t vtable[] = {
{ "record", STRING|INIT|IREMOTE, (READ|WRITE)<<PUBLIC,
"rec", (char *)&RE },
{ "remote", STRING|INIT|IREMOTE, READ<<PUBLIC,
NOSTR, (char *)&RM },
NULL, (char *)&RM },
{ "script", BOOL, (READ|WRITE)<<PUBLIC,
"sc", (char *)FALSE },
{ "tabexpand", BOOL, (READ|WRITE)<<PUBLIC,
@ -92,7 +93,7 @@ value_t vtable[] = {
{ "SHELL", STRING|ENVIRON|INIT, (READ|WRITE)<<PUBLIC,
NULL, _PATH_BSHELL },
{ "HOME", STRING|ENVIRON, (READ|WRITE)<<PUBLIC,
NOSTR, NOSTR },
NULL, NULL },
{ "echocheck", BOOL, (READ|WRITE)<<PUBLIC,
"ec", (char *)FALSE },
{ "disconnect", STRING|IREMOTE|INIT, (READ|WRITE)<<PUBLIC,
@ -113,5 +114,5 @@ value_t vtable[] = {
"le", (char *)FALSE },
{ "parity", STRING|INIT|IREMOTE, (READ|WRITE)<<PUBLIC,
"par", (char *)&PA },
{ NOSTR, 0, 0, NOSTR, NOSTR }
{ NULL, 0, 0, NULL, NULL }
};