Resolve merge conflicts.

This commit is contained in:
ru 2006-08-31 14:14:30 +00:00
parent f4be069346
commit 37ec4940b5
28 changed files with 1035 additions and 1166 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: biz22.c,v 1.7 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: biz22.c,v 1.13 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: biz22.c,v 1.6 1997/02/11 09:24:11 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)biz22.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: biz22.c,v 1.7 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: biz22.c,v 1.13 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -48,12 +44,13 @@ static char rcsid[] = "$OpenBSD: biz22.c,v 1.7 2001/10/24 18:38:58 millert Exp $
#define DISCONNECT_CMD "\20\04" /* disconnection string */
static void sigALRM();
static int timeout = 0;
static int dialtimeout = 0;
static jmp_buf timeoutbuf;
static int cmd(), detect();
void biz22_disconnect();
static int biz_dialer(char *, char *);
static void sigALRM(int);
static int cmd(char *);
static int detect(char *);
/*
* Dial up on a BIZCOMP Model 1022 with either
@ -61,8 +58,7 @@ void biz22_disconnect();
* pulse dialing (mod = "W")
*/
static int
biz_dialer(num, mod)
char *num, *mod;
biz_dialer(char *num, char *mod)
{
int connected = 0;
char cbuf[40];
@ -77,7 +73,7 @@ biz_dialer(num, mod)
printf("can't initialize bizcomp...");
return (0);
}
(void)strcpy(cbuf, "\02.\r");
(void)strlcpy(cbuf, "\02.\r", sizeof cbuf);
cbuf[1] = *mod;
if (cmd(cbuf)) {
printf("can't set dialing mode...");
@ -98,61 +94,55 @@ biz_dialer(num, mod)
*/
connected = detect("1\r");
#ifdef ACULOG
if (timeout) {
if (dialtimeout) {
char line[80];
(void)sprintf(line, "%ld second dial timeout",
(void)snprintf(line, sizeof line, "%ld second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "biz1022", line);
}
#endif
if (timeout)
if (dialtimeout)
biz22_disconnect(); /* insurance */
return (connected);
}
int
biz22w_dialer(num, acu)
char *num, *acu;
biz22w_dialer(char *num, char *acu)
{
return (biz_dialer(num, "W"));
}
int
biz22f_dialer(num, acu)
char *num, *acu;
biz22f_dialer(char *num, char *acu)
{
return (biz_dialer(num, "V"));
}
void
biz22_disconnect()
biz22_disconnect(void)
{
write(FD, DISCONNECT_CMD, 4);
write(FD, DISCONNECT_CMD, sizeof(DISCONNECT_CMD)-1);
sleep(2);
tcflush(FD, TCIOFLUSH);
}
void
biz22_abort()
biz22_abort(void)
{
write(FD, "\02", 1);
}
/*ARGSUSED*/
static void
sigALRM()
sigALRM(int signo)
{
timeout = 1;
dialtimeout = 1;
longjmp(timeoutbuf, 1);
}
static int
cmd(s)
char *s;
cmd(char *s)
{
sig_t f;
char c;
@ -173,14 +163,13 @@ cmd(s)
}
static int
detect(s)
char *s;
detect(char *s)
{
sig_t f;
char c;
f = signal(SIGALRM, sigALRM);
timeout = 0;
dialtimeout = 0;
while (*s) {
if (setjmp(timeoutbuf)) {
biz22_abort();
@ -194,5 +183,5 @@ detect(s)
return (0);
}
signal(SIGALRM, f);
return (timeout == 0);
return (dialtimeout == 0);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: biz31.c,v 1.6 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: biz31.c,v 1.10 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: biz31.c,v 1.5 1997/02/11 09:24:14 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)biz31.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: biz31.c,v 1.6 2001/10/24 18:38:58 millert Exp $";
static char rcsid[] = "$OpenBSD: biz31.c,v 1.10 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -49,7 +45,14 @@ static char rcsid[] = "$OpenBSD: biz31.c,v 1.6 2001/10/24 18:38:58 millert Exp $
#define MAXRETRY 3 /* sync up retry count */
#define DISCONNECT_CMD "\21\25\11\24" /* disconnection string */
static void sigALRM();
static int biz_dialer(char *, char *);
static int bizsync(int);
static int echo(char *);
static void sigALRM(int);
static int detect(char *);
static int flush(char *);
static int bizsync(int);
static int timeout = 0;
static jmp_buf timeoutbuf;
@ -59,8 +62,7 @@ static jmp_buf timeoutbuf;
* pulse dialing (mod = "w")
*/
static int
biz_dialer(num, mod)
char *num, *mod;
biz_dialer(char *num, char *mod)
{
int connected = 0;
@ -94,7 +96,7 @@ biz_dialer(num, mod)
if (timeout) {
char line[80];
(void)sprintf(line, "%ld second dial timeout",
(void)snprintf(line, sizeof line, "%ld second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "biz", line);
}
@ -108,37 +110,34 @@ biz_dialer(num, mod)
return (connected);
}
biz31w_dialer(num, acu)
char *num, *acu;
int
biz31w_dialer(char *num, char *acu)
{
return (biz_dialer(num, "w"));
}
biz31f_dialer(num, acu)
char *num, *acu;
int
biz31f_dialer(char *num, char *acu)
{
return (biz_dialer(num, "f"));
}
biz31_disconnect()
void
biz31_disconnect(void)
{
write(FD, DISCONNECT_CMD, 4);
write(FD, DISCONNECT_CMD, sizeof(DISCONNECT_CMD)-1);
sleep(2);
tcflush(FD, TCIOFLUSH);
}
biz31_abort()
void
biz31_abort(void)
{
write(FD, "\33", 1);
}
static int
echo(s)
char *s;
echo(char *s)
{
char c;
@ -160,17 +159,16 @@ echo(s)
}
}
/*ARGSUSED*/
static void
sigALRM()
sigALRM(int signo)
{
timeout = 1;
longjmp(timeoutbuf, 1);
}
static int
detect(s)
char *s;
detect(char *s)
{
sig_t f;
char c;
@ -194,8 +192,7 @@ detect(s)
}
static int
flush(s)
char *s;
flush(char *s)
{
sig_t f;
char c;
@ -218,7 +215,7 @@ flush(s)
* call there are gory ways to simulate this.
*/
static int
bizsync(fd)
bizsync(int fd)
{
#ifdef FIOCAPACITY
struct capacity b;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: courier.c,v 1.9 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: courier.c,v 1.15 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: courier.c,v 1.7 1997/02/11 09:24:16 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: courier.c,v 1.9 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: courier.c,v 1.15 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -54,20 +50,22 @@ static char rcsid[] = "$OpenBSD: courier.c,v 1.9 2001/10/24 18:38:58 millert Exp
#define MAXRETRY 5
static void sigALRM();
static int timeout = 0;
static int dialtimeout = 0;
static int connected = 0;
static jmp_buf timeoutbuf, intbuf;
static int coursync(), cour_connect(), cour_swallow();
void cour_nap();
static void cour_write(int fd, char *cp, int n);
static jmp_buf timeoutbuf;
void cour_disconnect(void);
static void sigALRM(int);
static int cour_swallow(char *);
static int cour_connect(void);
static int coursync(void);
static void cour_write(int, char *, int);
static void cour_nap(void);
#ifdef DEBUG
static void cour_verbose_read(void);
#endif
int
cour_dialer(num, acu)
char *num;
char *acu;
cour_dialer(char *num, char *acu)
{
char *cp;
#ifdef ACULOG
@ -111,19 +109,19 @@ cour_dialer(num, acu)
cour_write(FD, "\r", 1);
connected = cour_connect();
#ifdef ACULOG
if (timeout) {
(void)sprintf(line, "%ld second dial timeout",
if (dialtimeout) {
(void)snprintf(line, sizeof line, "%ld second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "cour", line);
}
#endif
if (timeout)
if (dialtimeout)
cour_disconnect();
return (connected);
}
void
cour_disconnect()
cour_disconnect(void)
{
/* first hang up the modem*/
ioctl(FD, TIOCCDTR, 0);
@ -134,29 +132,29 @@ cour_disconnect()
}
void
cour_abort()
cour_abort(void)
{
cour_write(FD, "\r", 1); /* send anything to abort the call */
cour_disconnect();
}
/*ARGSUSED*/
static void
sigALRM()
sigALRM(int signo)
{
printf("\07timeout waiting for reply\n");
timeout = 1;
dialtimeout = 1;
longjmp(timeoutbuf, 1);
}
static int
cour_swallow(match)
char *match;
cour_swallow(char *match)
{
sig_t f;
char c;
f = signal(SIGALRM, sigALRM);
timeout = 0;
dialtimeout = 0;
do {
if (*match =='\0') {
signal(SIGALRM, f);
@ -187,16 +185,16 @@ 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
cour_connect()
cour_connect(void)
{
char c;
int nc, nl, n;
@ -210,7 +208,7 @@ cour_connect()
again:
nc = 0; nl = sizeof(dialer_buf)-1;
bzero(dialer_buf, sizeof(dialer_buf));
timeout = 0;
dialtimeout = 0;
for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) {
if (setjmp(timeoutbuf))
break;
@ -269,7 +267,7 @@ cour_connect()
* the courier in sync.
*/
static int
coursync()
coursync(void)
{
int already = 0;
int len;
@ -311,10 +309,7 @@ coursync()
}
static void
cour_write(fd, cp, n)
int fd;
char *cp;
int n;
cour_write(int fd, char *cp, int n)
{
#ifdef notdef
if (boolean(value(VERBOSE)))
@ -330,7 +325,8 @@ int n;
}
#ifdef DEBUG
cour_verbose_read()
static void
cour_verbose_read(void)
{
int n = 0;
char buf[BUFSIZ];
@ -346,8 +342,8 @@ cour_verbose_read()
#endif
/* Give the courier 50 milliseconds between characters */
void
cour_nap()
static void
cour_nap(void)
{
struct timespec ts;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: df.c,v 1.5 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: df.c,v 1.9 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: df.c,v 1.4 1995/10/29 00:49:51 pk Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)df.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: df.c,v 1.5 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: df.c,v 1.9 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -51,29 +47,24 @@ static char rcsid[] = "$OpenBSD: df.c,v 1.5 2001/10/24 18:38:58 millert Exp $";
#include "tip.h"
static jmp_buf Sjbuf;
static void timeout();
static void df_disconnect(void);
static int df_dialer(char *, char *, int);
static void alrm_timeout(int);
int
df02_dialer(num, acu)
char *num, *acu;
df02_dialer(char *num, char *acu)
{
return (df_dialer(num, acu, 0));
}
int
df03_dialer(num, acu)
char *num, *acu;
df03_dialer(char *num, char *acu)
{
return (df_dialer(num, acu, 1));
}
int
df_dialer(num, acu, df03)
char *num, *acu;
int df03;
static int
df_dialer(char *num, char *acu, int df03)
{
int f = FD;
struct termios cntrl;
@ -106,7 +97,7 @@ df_dialer(num, acu, df03)
ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
}
#endif
signal(SIGALRM, timeout);
signal(SIGALRM, alrm_timeout);
alarm(5 * strlen(num) + 10);
tcflush(f, TCIOFLUSH);
write(f, "\001", 1);
@ -124,7 +115,7 @@ df_dialer(num, acu, df03)
return (c == 'A');
}
static void
void
df_disconnect(void)
{
write(FD, "\001", 1);
@ -132,18 +123,15 @@ df_disconnect(void)
tcflush(FD, TCIOFLUSH);
}
void
df_abort()
df_abort(void)
{
df_disconnect();
}
/*ARGSUSED*/
static void
timeout()
alrm_timeout(int signo)
{
longjmp(Sjbuf, 1);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dn11.c,v 1.5 2001/11/19 19:02:16 mpech Exp $ */
/* $OpenBSD: dn11.c,v 1.9 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: dn11.c,v 1.4 1995/10/29 00:49:53 pk Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)dn11.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: dn11.c,v 1.5 2001/11/19 19:02:16 mpech Exp $";
static const char rcsid[] = "$OpenBSD: dn11.c,v 1.9 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -49,14 +45,13 @@ static char rcsid[] = "$OpenBSD: dn11.c,v 1.5 2001/11/19 19:02:16 mpech Exp $";
*/
#include "tip.h"
void dn_abort();
void alarmtr();
static jmp_buf jmpbuf;
static int child = -1, dn;
static pid_t child = -1, dn;
static void alarmtr(int);
int
dn_dialer(num, acu)
char *num, *acu;
dn_dialer(char *num, char *acu)
{
int lt, nw;
int timelim;
@ -119,8 +114,9 @@ dn_dialer(num, acu)
return (1);
}
void
alarmtr()
/*ARGSUSED*/
static void
alarmtr(int signo)
{
alarm(0);
longjmp(jmpbuf, 1);
@ -131,9 +127,8 @@ alarmtr()
* hanging up...
*/
void
dn_disconnect()
dn_disconnect(void)
{
sleep(2);
if (FD > 0)
ioctl(FD, TIOCCDTR, 0);
@ -141,9 +136,8 @@ dn_disconnect()
}
void
dn_abort()
dn_abort(void)
{
sleep(2);
if (child > 0)
kill(child, SIGKILL);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hayes.c,v 1.8 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: hayes.c,v 1.13 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: hayes.c,v 1.6 1997/02/11 09:24:17 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)hayes.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: hayes.c,v 1.8 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: hayes.c,v 1.13 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -74,12 +70,9 @@ static char rcsid[] = "$OpenBSD: hayes.c,v 1.8 2001/10/24 18:38:58 millert Exp $
#define min(a,b) ((a < b) ? a : b)
static void error_rep(char c);
static void goodbye(void);
static void sigALRM();
static int timeout = 0;
static int dialtimeout = 0;
static jmp_buf timeoutbuf;
static char gobble();
#define DUMBUFLEN 40
static char dumbuf[DUMBUFLEN];
@ -89,10 +82,14 @@ static char dumbuf[DUMBUFLEN];
#define FAILED 4
static int state = IDLE;
static void sigALRM(int);
static char gobble(char *);
static void error_rep(char);
static void goodbye(void);
static int hay_sync(void);
int
hay_dialer(num, acu)
char *num;
char *acu;
hay_dialer(char *num, char *acu)
{
char *cp;
int connected = 0;
@ -135,20 +132,19 @@ hay_dialer(num, acu)
}
tcflush(FD, TCIOFLUSH);
#ifdef ACULOG
if (timeout) {
(void)sprintf(line, "%ld second dial timeout",
if (dialtimeout) {
(void)snprintf(line, sizeof line, "%ld second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "hayes", line);
}
#endif
if (timeout)
if (dialtimeout)
hay_disconnect(); /* insurance */
return (connected);
}
void
hay_disconnect()
hay_disconnect(void)
{
/* first hang up the modem*/
#ifdef DEBUG
@ -161,32 +157,30 @@ hay_disconnect()
}
void
hay_abort()
hay_abort(void)
{
write(FD, "\r", 1); /* send anything to abort the call */
hay_disconnect();
}
/*ARGSUSED*/
static void
sigALRM()
sigALRM(int signo)
{
printf("\07timeout waiting for reply\n\r");
timeout = 1;
dialtimeout = 1;
longjmp(timeoutbuf, 1);
}
static char
gobble(match)
char *match;
gobble(char *match)
{
char c;
sig_t f;
int i, status = 0;
f = signal(SIGALRM, sigALRM);
timeout = 0;
dialtimeout = 0;
#ifdef DEBUG
printf("\ngobble: waiting for %s\n", match);
#endif
@ -214,8 +208,7 @@ gobble(match)
}
static void
error_rep(c)
char c;
error_rep(char c)
{
printf("\n\r");
switch (c) {
@ -227,23 +220,23 @@ error_rep(c)
case '1':
printf("CONNECT");
break;
case '2':
printf("RING");
break;
case '3':
printf("NO CARRIER");
break;
case '4':
printf("ERROR in input");
break;
case '5':
printf("CONNECT 1200");
break;
default:
printf("Unknown Modem error: %c (0x%x)", c, c);
}
@ -299,8 +292,8 @@ goodbye(void)
#define MAXRETRY 5
int
hay_sync()
static int
hay_sync(void)
{
int len, retry = 0;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: t3000.c,v 1.9 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: t3000.c,v 1.14 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: t3000.c,v 1.5 1997/02/11 09:24:18 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: t3000.c,v 1.9 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: t3000.c,v 1.14 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -55,18 +51,22 @@ static char rcsid[] = "$OpenBSD: t3000.c,v 1.9 2001/10/24 18:38:58 millert Exp $
#define MAXRETRY 5
static void sigALRM();
static int timeout = 0;
static int dialtimeout = 0;
static int connected = 0;
static jmp_buf timeoutbuf, intbuf;
static int t3000_sync(), t3000_connect(), t3000_swallow();
static void t3000_nap();
static int t3000_write(int fd, char *cp, int n);
static jmp_buf timeoutbuf;
static void sigALRM(int);
static int t3000_swallow(char *);
static int t3000_connect(void);
static int t3000_sync(void);
static void t3000_write(int, char *, int);
static void t3000_nap(void);
#ifdef DEBUG
static void t3000_verbose_read(void);
#endif
int
t3000_dialer(num, acu)
char *num;
char *acu;
t3000_dialer(char *num, char *acu)
{
char *cp;
struct termios cntrl;
@ -110,19 +110,19 @@ t3000_dialer(num, acu)
t3000_write(FD, "\r", 1);
connected = t3000_connect();
#ifdef ACULOG
if (timeout) {
(void)sprintf(line, "%ld second dial timeout",
if (dialtimeout) {
(void)snprintf(line, sizeof line, "%ld second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "t3000", line);
}
#endif
if (timeout)
if (dialtimeout)
t3000_disconnect();
return (connected);
}
void
t3000_disconnect()
t3000_disconnect(void)
{
/* first hang up the modem*/
ioctl(FD, TIOCCDTR, 0);
@ -133,29 +133,29 @@ t3000_disconnect()
}
void
t3000_abort()
t3000_abort(void)
{
t3000_write(FD, "\r", 1); /* send anything to abort the call */
t3000_disconnect();
}
/*ARGSUSED*/
static void
sigALRM()
sigALRM(int signo)
{
printf("\07timeout waiting for reply\n");
timeout = 1;
dialtimeout = 1;
longjmp(timeoutbuf, 1);
}
static int
t3000_swallow(match)
char *match;
t3000_swallow(char *match)
{
sig_t f;
char c;
f = signal(SIGALRM, sigALRM);
timeout = 0;
dialtimeout = 0;
do {
if (*match =='\0') {
signal(SIGALRM, f);
@ -192,24 +192,24 @@ 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
t3000_connect()
t3000_connect(void)
{
char c;
int nc, nl, n;
@ -223,7 +223,7 @@ t3000_connect()
again:
nc = 0; nl = sizeof(dialer_buf)-1;
bzero(dialer_buf, sizeof(dialer_buf));
timeout = 0;
dialtimeout = 0;
for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) {
if (setjmp(timeoutbuf))
break;
@ -282,7 +282,7 @@ t3000_connect()
* the t3000 in sync.
*/
static int
t3000_sync()
t3000_sync(void)
{
int already = 0;
int len;
@ -326,11 +326,8 @@ if (len == 0) len = 1;
return (0);
}
static int
t3000_write(fd, cp, n)
int fd;
char *cp;
int n;
static void
t3000_write(int fd, char *cp, int n)
{
#ifdef notdef
if (boolean(value(VERBOSE)))
@ -346,7 +343,8 @@ int n;
}
#ifdef DEBUG
t3000_verbose_read()
static void
t3000_verbose_read(void)
{
int n = 0;
char buf[BUFSIZ];
@ -362,8 +360,8 @@ t3000_verbose_read()
#endif
/* Give the t3000 50 milliseconds between characters */
void
t3000_nap()
static void
t3000_nap(void)
{
struct timespec ts;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: v3451.c,v 1.6 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: v3451.c,v 1.9 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: v3451.c,v 1.6 1997/02/11 09:24:20 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)v3451.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: v3451.c,v 1.6 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: v3451.c,v 1.9 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -51,13 +47,14 @@ static char rcsid[] = "$OpenBSD: v3451.c,v 1.6 2001/10/24 18:38:58 millert Exp $
static jmp_buf Sjbuf;
static int expect(), notin(), prefix();
static void vawrite(), alarmtr();
static void vawrite(char *, int);
static int expect(char *);
static void alarmtr(int);
static int notin(char *, char *);
static int prefix(char *, char *);
int
v3451_dialer(num, acu)
char *num;
char *acu;
v3451_dialer(char *num, char *acu)
{
sig_t func;
int ok;
@ -131,32 +128,26 @@ v3451_dialer(num, acu)
}
void
v3451_disconnect()
v3451_disconnect(void)
{
close(FD);
}
void
v3451_abort()
v3451_abort(void)
{
close(FD);
}
static void
vawrite(cp, delay)
char *cp;
int delay;
vawrite(char *cp, int delay)
{
for (; *cp; sleep(delay), cp++)
write(FD, cp, 1);
}
static int
expect(cp)
char *cp;
expect(char *cp)
{
char buf[300];
char *rp = buf;
@ -193,17 +184,16 @@ expect(cp)
return (1);
}
/*ARGSUSED*/
static void
alarmtr()
alarmtr(int signo)
{
longjmp(Sjbuf, 1);
}
static int
notin(sh, lg)
char *sh, *lg;
notin(char *sh, char *lg)
{
for (; *lg; lg++)
if (prefix(sh, lg))
return (0);
@ -211,8 +201,7 @@ notin(sh, lg)
}
static int
prefix(s1, s2)
char *s1, *s2;
prefix(char *s1, char *s2)
{
char c;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: v831.c,v 1.6 2001/11/19 19:02:16 mpech Exp $ */
/* $OpenBSD: v831.c,v 1.11 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: v831.c,v 1.5 1996/12/29 10:42:01 cgd Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)v831.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: v831.c,v 1.6 2001/11/19 19:02:16 mpech Exp $";
static const char rcsid[] = "$OpenBSD: v831.c,v 1.11 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -50,20 +46,19 @@ static char rcsid[] = "$OpenBSD: v831.c,v 1.6 2001/11/19 19:02:16 mpech Exp $";
#include "tip.h"
#include <termios.h>
void v831_abort();
static void alarmtr();
static int dialit();
static char *sanitize();
static jmp_buf jmpbuf;
static int child = -1;
static pid_t child = -1;
static void alarmtr(int);
static int dialit(char *, char *);
static char * sanitize(char *);
int
v831_dialer(num, acu)
char *num, *acu;
v831_dialer(char *num, char *acu)
{
int status, pid;
int status;
int timelim;
pid_t pid;
if (boolean(value(VERBOSE)))
printf("\nstarting call...");
@ -122,8 +117,9 @@ v831_dialer(num, acu)
return (1);
}
/*ARGSUSED*/
static void
alarmtr()
alarmtr(int signo)
{
alarm(0);
longjmp(jmpbuf, 1);
@ -134,7 +130,7 @@ alarmtr()
* hanging up...
*/
void
v831_disconnect()
v831_disconnect(void)
{
struct termios cntrl;
@ -154,18 +150,17 @@ v831_disconnect()
}
void
v831_abort()
v831_abort(void)
{
#ifdef DEBUG
printf("[abort: AC=%d]\n", AC);
#endif
sleep(2);
if (child > 0)
kill(child, SIGKILL);
if (AC > 0)
if (FD > 0)
ioctl(FD, TIOCNXCL, NULL);
close(AC);
close(AC);
if (FD > 0)
ioctl(FD, TIOCCDTR, 0);
close(FD);
@ -191,9 +186,7 @@ struct vaconfig {
#define ETX 03
static int
dialit(phonenum, acu)
char *phonenum;
char *acu;
dialit(char *phonenum, char *acu)
{
struct vaconfig *vp;
struct termios cntrl;
@ -253,8 +246,7 @@ dialit(phonenum, acu)
}
static char *
sanitize(s)
char *s;
sanitize(char *s)
{
static char buf[128];
char *cp;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ventel.c,v 1.7 2001/11/19 19:02:16 mpech Exp $ */
/* $OpenBSD: ventel.c,v 1.12 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: ventel.c,v 1.6 1997/02/11 09:24:21 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)ventel.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: ventel.c,v 1.7 2001/11/19 19:02:16 mpech Exp $";
static const char rcsid[] = "$OpenBSD: ventel.c,v 1.12 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -54,12 +50,13 @@ static char rcsid[] = "$OpenBSD: ventel.c,v 1.7 2001/11/19 19:02:16 mpech Exp $"
#define MAXRETRY 5
static void sigALRM();
static int timeout = 0;
static int dialtimeout = 0;
static jmp_buf timeoutbuf;
static int gobble(), vensync();
static void echo();
static void echo(char *);
static void sigALRM(int);
static int gobble(char, char *);
static int vensync(int);
/*
* some sleep calls have been replaced by this macro
@ -72,9 +69,7 @@ static void echo();
#define busyloop(n) do { DELAY(n); } while (0)
int
ven_dialer(num, acu)
char *num;
char *acu;
ven_dialer(char *num, char *acu)
{
char *cp;
int connected = 0;
@ -109,21 +104,21 @@ ven_dialer(num, acu)
connected = gobble('!', line);
tcflush(FD, TCIOFLUSH);
#ifdef ACULOG
if (timeout) {
(void)sprintf(line, "%ld second dial timeout",
if (dialtimeout) {
(void)snprintf(line, sizeof line, "%ld second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "ventel", line);
}
#endif
if (timeout)
if (dialtimeout)
ven_disconnect(); /* insurance */
if (connected || timeout || !boolean(value(VERBOSE)))
if (connected || dialtimeout || !boolean(value(VERBOSE)))
return (connected);
/* call failed, parse response for user */
cp = strchr(line, '\r');
if (cp)
*cp = '\0';
for (cp = line; cp = strchr(cp, ' '); cp++)
for (cp = line; (cp = strchr(cp, ' ')) != NULL; cp++)
if (cp[1] == ' ')
break;
if (cp) {
@ -141,63 +136,59 @@ ven_dialer(num, acu)
}
void
ven_disconnect()
ven_disconnect(void)
{
close(FD);
}
void
ven_abort()
ven_abort(void)
{
write(FD, "\03", 1);
close(FD);
}
static void
echo(s)
char *s;
echo(char *s)
{
char c;
while (c = *s++) switch (c) {
while ((c = *s++) != '\0')
switch (c) {
case '$':
read(FD, &c, 1);
s++;
break;
case '$':
read(FD, &c, 1);
s++;
break;
case '#':
c = *s++;
write(FD, &c, 1);
break;
case '#':
c = *s++;
write(FD, &c, 1);
break;
default:
write(FD, &c, 1);
read(FD, &c, 1);
}
default:
write(FD, &c, 1);
read(FD, &c, 1);
}
}
/*ARGSUSED*/
static void
sigALRM()
sigALRM(int signo)
{
printf("\07timeout waiting for reply\n");
timeout = 1;
dialtimeout = 1;
longjmp(timeoutbuf, 1);
}
static int
gobble(match, response)
char match;
char response[];
gobble(char match, char response[])
{
char *cp = response;
sig_t f;
char c;
f = signal(SIGALRM, sigALRM);
timeout = 0;
dialtimeout = 0;
do {
if (setjmp(timeoutbuf)) {
signal(SIGALRM, f);
@ -225,7 +216,7 @@ gobble(match, response)
* there are gory ways to simulate this.
*/
static int
vensync(fd)
vensync(int fd)
{
int already = 0, nread;
char buf[60];
@ -266,4 +257,3 @@ vensync(fd)
}
return (0);
}

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.9 2001/09/23 06:15:30 pvalchev Exp $
# $OpenBSD: Makefile,v 1.11 2006/05/25 08:41:52 jmc Exp $
# $FreeBSD$
#
# Files are:
@ -33,10 +33,9 @@
PROG= tip
LINKS= ${BINDIR}/tip ${BINDIR}/cu
MLINKS= tip.1 cu.1
CFLAGS+=-I${.CURDIR} \
-DDEFBR=9600 -DDEFFS=BUFSIZ -DACULOG -DPRISTINE -DCONNECT \
-DV831 -DVENTEL -DHAYES -DCOURIER -DT3000
MAN= tip.1 cu.1
CFLAGS+=-I${.CURDIR} -DDEFBR=9600 -DDEFFS=BUFSIZ -DACULOG -DPRISTINE \
-DCONNECT -DV831 -DVENTEL -DHAYES -DCOURIER -DT3000
WARNS?= 0
.PATH: ${.CURDIR}/../libacu
SRCS= acu.c acutab.c cmds.c cmdtab.c cu.c hunt.c log.c partab.c \

View File

@ -1,4 +1,4 @@
/* $OpenBSD: acu.c,v 1.7 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: acu.c,v 1.12 2006/03/17 14:43:06 moritz Exp $ */
/* $NetBSD: acu.c,v 1.4 1996/12/29 10:34:03 cgd Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)acu.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: acu.c,v 1.7 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: acu.c,v 1.12 2006/03/17 14:43:06 moritz Exp $";
#endif
#endif /* not lint */
@ -67,8 +63,8 @@ static jmp_buf jmpbuf;
* for a single host acting as a rotary (in the order
* found in the file).
*/
const char *
connect()
char *
con(void)
{
char *cp = PN;
char *phnum, string[256];
@ -143,7 +139,7 @@ connect()
conflag = (*acu->acu_dialer)(phnum, CU);
if (conflag)
break;
logent(value(HOST), phnum, acu->acu_name, "call failed");
tried++;
}
@ -164,8 +160,7 @@ connect()
}
void
disconnect(reason)
char *reason;
disconnect(char *reason)
{
if (!conflag) {
logent(value(HOST), "", DV, "call terminated");
@ -175,22 +170,20 @@ disconnect(reason)
logent(value(HOST), "", acu->acu_name, "call terminated");
if (boolean(value(VERBOSE)))
printf("\r\ndisconnecting...");
} else
} else
logent(value(HOST), "", acu->acu_name, reason);
(*acu->acu_disconnect)();
}
static void
acuabort(s)
int s;
acuabort(int s)
{
signal(s, SIG_IGN);
longjmp(jmpbuf, 1);
}
static acu_t *
acutype(s)
char *s;
acutype(char *s)
{
acu_t *p;
extern acu_t acutable[];

View File

@ -1,4 +1,4 @@
/* $OpenBSD: acutab.c,v 1.2 1996/06/26 05:40:41 deraadt Exp $ */
/* $OpenBSD: acutab.c,v 1.5 2006/03/17 19:17:13 moritz Exp $ */
/* $NetBSD: acutab.c,v 1.3 1994/12/08 09:30:41 jtc Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)acutab.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: acutab.c,v 1.2 1996/06/26 05:40:41 deraadt Exp $";
static const char rcsid[] = "$OpenBSD: acutab.c,v 1.5 2006/03/17 19:17:13 moritz Exp $";
#endif
#endif /* not lint */
@ -48,46 +44,46 @@ static char rcsid[] = "$OpenBSD: acutab.c,v 1.2 1996/06/26 05:40:41 deraadt Exp
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 @@
/* $OpenBSD: cmds.c,v 1.13 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: cmds.c,v 1.26 2006/06/06 23:24:52 deraadt Exp $ */
/* $NetBSD: cmds.c,v 1.7 1997/02/11 09:24:03 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: cmds.c,v 1.13 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: cmds.c,v 1.26 2006/06/06 23:24:52 deraadt Exp $";
#endif
#endif /* not lint */
@ -61,20 +57,28 @@ 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 */
static void transfer(char *, int, char *);
static void stopsnd(int); /* SIGINT handler during file transfers */
static void intcopy(int); /* interrupt routine for file transfers */
static void transmit(FILE *, char *, char *);
static void send(int);
static void execute(char *);
static int args(char *, char **, int);
static void prtime(char *, time_t);
static void tandem(char *);
static void hardwareflow(char *);
void linedisc(char *);
static int anyof(char *, char *);
/*
* FTP - remote ==> local
* get a file from the remote host
*/
void
getfl(c)
char c;
getfl(int c)
{
char buf[256], *cp, *expand();
char buf[256], *cp;
putchar(c);
/*
* get the UNIX receiving file's name
@ -86,7 +90,7 @@ getfl(c)
printf("\r\n%s: cannot creat\r\n", copyname);
return;
}
/*
* collect parameters
*/
@ -95,18 +99,16 @@ getfl(c)
return;
}
transfer(buf, sfd, value(EOFREAD));
return;
}
/*
* Cu-like take command
*/
void
cu_take(cc)
char cc;
cu_take(int c)
{
int fd, argc;
char line[BUFSIZ], *expand(), *cp;
char line[BUFSIZ], *cp;
if (prompt("[take] ", copyname, sizeof(copyname)))
return;
@ -122,7 +124,7 @@ cu_take(cc)
printf("\r\n%s: cannot create\r\n", argv[1]);
return;
}
(void)snprintf(line, sizeof(line), "cat %s;echo \01", argv[0]);
(void)snprintf(line, sizeof(line), "cat %s;echo ''|tr '\\012' '\\01'", argv[0]);
transfer(line, fd, "\01");
}
@ -132,34 +134,38 @@ static jmp_buf intbuf;
* Bulk transfer routine --
* used by getfl(), cu_take(), and pipefile()
*/
void
transfer(buf, fd, eofchars)
char *buf, *eofchars;
int fd;
static void
transfer(char *buf, int fd, char *eofchars)
{
int ct;
int ct, eof;
char c, buffer[BUFSIZ];
char *p = buffer;
int cnt, eof;
size_t cnt;
time_t start;
sig_t f;
char r;
if (number(value(FRAMESIZE)) > BUFSIZ || number(value(FRAMESIZE)) < 1) {
printf("framesize must be >= 1 and <= %d\r\n", BUFSIZ);
close(fd);
return;
}
parwrite(FD, buf, size(buf));
quit = 0;
kill(pid, SIGIOT);
kill(tipout_pid, SIGIOT);
read(repdes[0], (char *)&ccc, 1); /* Wait until read process stops */
/*
* finish command
*/
r = '\r';
parwrite(FD, &r, 1);
do
read(FD, &c, 1);
read(FD, &c, 1);
while ((c&STRIP_PAR) != '\n');
tcsetattr(0, TCSAFLUSH, &defchars);
(void) setjmp(intbuf);
f = signal(SIGINT, intcopy);
start = time(0);
@ -202,12 +208,14 @@ transfer(buf, fd, eofchars)
* FTP - remote ==> local process
* send remote input to local process via pipe
*/
/*ARGSUSED*/
void
pipefile(char c)
pipefile(int c)
{
int cpid, pdes[2];
int pdes[2];
char buf[256];
int status, p;
pid_t cpid;
if (prompt("Local command? ", buf, sizeof(buf)))
return;
@ -248,10 +256,10 @@ pipefile(char c)
/*
* Interrupt service routine for FTP
*/
void
stopsnd()
/*ARGSUSED*/
static void
stopsnd(int signo)
{
stop = 1;
signal(SIGINT, SIG_IGN);
}
@ -262,14 +270,12 @@ stopsnd()
* terminate transmission with pseudo EOF sequence
*/
void
sendfile(cc)
char cc;
sendfile(int c)
{
FILE *fd;
FILE *fp;
char *fnamex;
char *expand();
putchar(cc);
putchar(c);
/*
* get file name
*/
@ -280,11 +286,11 @@ sendfile(cc)
* look up file
*/
fnamex = expand(fname);
if ((fd = fopen(fnamex, "r")) == NULL) {
if ((fp = fopen(fnamex, "r")) == NULL) {
printf("%s: cannot open\r\n", fname);
return;
}
transmit(fd, value(EOFWRITE), NULL);
transmit(fp, value(EOFWRITE), NULL);
if (!boolean(value(ECHOCHECK)))
tcdrain(FD);
}
@ -293,17 +299,15 @@ sendfile(cc)
* Bulk transfer routine to remote host --
* used by sendfile() and cu_put()
*/
void
transmit(fd, eofchars, command)
FILE *fd;
char *eofchars, *command;
static void
transmit(FILE *fp, char *eofchars, char *command)
{
char *pc, lastc;
int c, ccount, lcount;
time_t start_t, stop_t;
sig_t f;
kill(pid, SIGIOT); /* put TIPOUT into a wait state */
kill(tipout_pid, SIGIOT); /* put TIPOUT into a wait state */
stop = 0;
f = signal(SIGINT, stopsnd);
tcsetattr(0, TCSAFLUSH, &defchars);
@ -324,7 +328,7 @@ transmit(fd, eofchars, command)
while (1) {
ccount = 0;
do {
c = getc(fd);
c = getc(fp);
if (stop)
goto out;
if (c == EOF)
@ -336,8 +340,7 @@ transmit(fd, eofchars, command)
if (c == '\n') {
if (!boolean(value(RAWFTP)))
c = '\r';
}
else if (c == '\t') {
} else if (c == '\t') {
if (!boolean(value(RAWFTP))) {
if (boolean(value(TABEXPAND))) {
send(' ');
@ -356,7 +359,7 @@ transmit(fd, eofchars, command)
printf("\r%d", ++lcount);
if (boolean(value(ECHOCHECK))) {
timedout = 0;
alarm((long)value(ETIMEOUT));
alarm((unsigned int)lvalue(ETIMEOUT));
do { /* wait for prompt */
read(FD, (char *)&c, 1);
if (timedout || stop) {
@ -377,7 +380,7 @@ transmit(fd, eofchars, command)
send(*pc);
}
stop_t = time(0);
fclose(fd);
fclose(fp);
signal(SIGINT, f);
if (boolean(value(VERBOSE))) {
if (boolean(value(RAWFTP)))
@ -392,14 +395,13 @@ transmit(fd, eofchars, command)
/*
* Cu-like put command
*/
/*ARGSUSED*/
void
cu_put(cc)
char cc;
cu_put(int c)
{
FILE *fd;
FILE *fp;
char line[BUFSIZ];
int argc;
char *expand();
char *copynamex;
if (prompt("[put] ", copyname, sizeof(copyname)))
@ -412,7 +414,7 @@ cu_put(cc)
if (argc == 1)
argv[1] = argv[0];
copynamex = expand(argv[0]);
if ((fd = fopen(copynamex, "r")) == NULL) {
if ((fp = fopen(copynamex, "r")) == NULL) {
printf("%s: cannot open\r\n", copynamex);
return;
}
@ -421,36 +423,31 @@ cu_put(cc)
else
(void)snprintf(line, sizeof(line),
"stty -echo;cat>%s;stty echo\r", argv[1]);
transmit(fd, "\04", line);
transmit(fp, "\04", line);
}
/*
* FTP - send single character
* wait for echo & handle timeout
*/
void
send(c)
int c;
static void
send(int c)
{
char cc;
int retry = 0;
cc = c;
parwrite(FD, &cc, 1);
#ifdef notdef
if (number(value(CDELAY)) > 0 && c != '\r')
nap(number(value(CDELAY)));
#endif
usleep(number(value(CDELAY)));
if (!boolean(value(ECHOCHECK))) {
#ifdef notdef
if (number(value(LDELAY)) > 0 && c == '\r')
nap(number(value(LDELAY)));
#endif
usleep(number(value(LDELAY)));
return;
}
tryagain:
timedout = 0;
alarm((long)value(ETIMEOUT));
alarm((unsigned int)lvalue(ETIMEOUT));
read(FD, &cc, 1);
alarm(0);
if (timedout) {
@ -462,8 +459,9 @@ send(c)
}
}
/*ARGSUSED*/
void
timeout()
timeout(int signo)
{
signal(SIGALRM, timeout);
timedout = 1;
@ -474,16 +472,17 @@ timeout()
* Identical to consh() except for where stdout goes.
*/
void
pipeout(char c)
pipeout(int c)
{
char buf[256];
int cpid, status, p;
int status, p;
pid_t cpid;
time_t start = time(NULL);
putchar(c);
if (prompt("Local command? ", buf, sizeof(buf)))
return;
kill(pid, SIGIOT); /* put TIPOUT into a wait state */
kill(tipout_pid, SIGIOT); /* put TIPOUT into a wait state */
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
tcsetattr(0, TCSAFLUSH, &defchars);
@ -523,19 +522,20 @@ pipeout(char c)
* Fork a program with:
* 0 <-> remote tty in
* 1 <-> remote tty out
* 2 <-> local tty out
* 2 <-> local tty stderr
*/
void
consh(char c)
consh(int c)
{
char buf[256];
int cpid, status, p;
int status, p;
pid_t cpid;
time_t start = time(NULL);
putchar(c);
if (prompt("Local command? ", buf, sizeof(buf)))
return;
kill(pid, SIGIOT); /* put TIPOUT into a wait state */
kill(tipout_pid, SIGIOT); /* put TIPOUT into a wait state */
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
tcsetattr(0, TCSAFLUSH, &defchars);
@ -575,11 +575,13 @@ consh(char c)
/*
* Escape to local shell
*/
/*ARGSUSED*/
void
shell(char c)
shell(int c)
{
int shpid, status;
int status;
char *cp;
pid_t shpid;
printf("[sh]\r\n");
signal(SIGINT, SIG_IGN);
@ -611,13 +613,14 @@ shell(char c)
* initiate the conversation with TIPOUT
*/
void
setscript()
setscript(void)
{
char c;
/*
* enable TIPOUT side for dialogue
*/
kill(pid, SIGEMT);
kill(tipout_pid, SIGEMT);
if (boolean(value(SCRIPT)))
write(fildes[1], value(RECORD), size(value(RECORD)));
write(fildes[1], "\n", 1);
@ -633,8 +636,9 @@ setscript()
* Change current working directory of
* local portion of tip
*/
/*ARGSUSED*/
void
chdirectory(char c)
chdirectory(int c)
{
char dirname[PATH_MAX];
char *cp = dirname;
@ -650,11 +654,11 @@ chdirectory(char c)
}
void
tipabort(msg)
char *msg;
tipabort(char *msg)
{
kill(pid, SIGTERM);
signal(SIGTERM, SIG_IGN);
kill(tipout_pid, SIGTERM);
disconnect(msg);
if (msg != NOSTR)
printf("\r\n%s", msg);
@ -665,8 +669,9 @@ tipabort(msg)
exit(0);
}
/*ARGSUSED*/
void
finish(char c)
finish(int c)
{
char *dismsg;
@ -677,17 +682,17 @@ finish(char c)
tipabort(NOSTR);
}
void
intcopy()
/*ARGSUSED*/
static void
intcopy(int signo)
{
raw();
quit = 1;
longjmp(intbuf, 1);
}
void
execute(s)
char *s;
static void
execute(char *s)
{
char *cp;
@ -699,10 +704,8 @@ execute(s)
execl(value(SHELL), cp, "-c", s, (char *)NULL);
}
int
args(buf, a, num)
char *buf, *a[];
int num;
static int
args(char *buf, char *a[], int num)
{
char *p = buf, *start;
char **parg = a;
@ -725,10 +728,8 @@ args(buf, a, num)
return(n);
}
void
prtime(s, a)
char *s;
time_t a;
static void
prtime(char *s, time_t a)
{
int i;
int nums[3];
@ -739,14 +740,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");
}
/*ARGSUSED*/
void
variable(char c)
variable(int c)
{
char buf[256];
@ -755,7 +757,7 @@ variable(char c)
vlex(buf);
if (vtable[BEAUTIFY].v_access&CHANGED) {
vtable[BEAUTIFY].v_access &= ~CHANGED;
kill(pid, SIGSYS);
kill(tipout_pid, SIGSYS);
}
if (vtable[SCRIPT].v_access&CHANGED) {
vtable[SCRIPT].v_access &= ~CHANGED;
@ -779,18 +781,30 @@ variable(char c)
else
tandem("off");
}
if (vtable[LECHO].v_access&CHANGED) {
vtable[LECHO].v_access &= ~CHANGED;
HD = boolean(value(LECHO));
}
if (vtable[LECHO].v_access&CHANGED) {
vtable[LECHO].v_access &= ~CHANGED;
HD = boolean(value(LECHO));
}
if (vtable[PARITY].v_access&CHANGED) {
vtable[PARITY].v_access &= ~CHANGED;
setparity(NOSTR);
}
if (vtable[HARDWAREFLOW].v_access&CHANGED) {
vtable[HARDWAREFLOW].v_access &= ~CHANGED;
if (boolean(value(HARDWAREFLOW)))
hardwareflow("on");
else
hardwareflow("off");
}
if (vtable[LINEDISC].v_access&CHANGED) {
vtable[LINEDISC].v_access &= ~CHANGED;
linedisc(NOSTR);
}
}
/*ARGSUSED*/
void
listvariables(char c)
listvariables(int c)
{
value_t *p;
char *buf;
@ -819,22 +833,21 @@ listvariables(char c)
break;
case BOOL:
printf(" %s\r\n",
boolean(p->v_value) == '!' ? "false" : "true");
!boolean(p->v_value) ? "false" : "true");
break;
case CHAR:
vis(charbuf, character(p->v_value), VIS_WHITE, 0);
printf(" %s\r\n", charbuf);
break;
}
}
}
}
/*
* Turn tandem mode on or off for remote tty.
*/
void
tandem(option)
char *option;
static void
tandem(char *option)
{
struct termios rmtty;
@ -851,12 +864,39 @@ tandem(option)
}
/*
* Send a break.
* Turn hardware flow control on or off for remote tty.
*/
static void
hardwareflow(char *option)
{
struct termios rmtty;
tcgetattr(FD, &rmtty);
if (strcmp(option, "on") == 0)
rmtty.c_iflag |= CRTSCTS;
else
rmtty.c_iflag &= ~CRTSCTS;
tcsetattr(FD, TCSADRAIN, &rmtty);
}
/*
* Change line discipline to the specified one.
*/
void
genbrk(char c)
linedisc(char *option)
{
int ld = (int)value(LINEDISC);
ioctl(FD, TIOCSETD, &ld);
}
/*
* Send a break.
*/
/*ARGSUSED*/
void
genbrk(int c)
{
ioctl(FD, TIOCSBRK, NULL);
sleep(1);
ioctl(FD, TIOCCBRK, NULL);
@ -866,10 +906,8 @@ genbrk(char c)
* Suspend tip
*/
void
suspend(c)
char c;
suspend(int c)
{
unraw();
kill(c == CTRL('y') ? getpid() : 0, SIGTSTP);
raw();
@ -878,16 +916,15 @@ suspend(c)
/*
* expand a file name if it includes shell meta characters
*/
char *
expand(name)
char name[];
expand(char name[])
{
static char xname[BUFSIZ];
char cmdbuf[BUFSIZ];
int pid, l;
int l;
char *cp, *Shell;
int s, pivec[2];
pid_t pid;
if (!anyof(name, "~{[*?$`'\"\\"))
return(name);
@ -949,9 +986,8 @@ expand(name)
/*
* Are any of the characters in the two strings the same?
*/
int
anyof(s1, s2)
char *s1, *s2;
static int
anyof(char *s1, char *s2)
{
int c;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cmdtab.c,v 1.3 2001/09/09 17:58:41 millert Exp $ */
/* $OpenBSD: cmdtab.c,v 1.7 2006/03/17 14:43:06 moritz Exp $ */
/* $NetBSD: cmdtab.c,v 1.3 1994/12/08 09:30:46 jtc Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: cmdtab.c,v 1.3 2001/09/09 17:58:41 millert Exp $";
static const char rcsid[] = "$OpenBSD: cmdtab.c,v 1.7 2006/03/17 14:43:06 moritz Exp $";
#endif
#endif /* not lint */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cu.c,v 1.10 2001/09/26 06:07:28 pvalchev Exp $ */
/* $OpenBSD: cu.c,v 1.19 2006/05/25 08:41:52 jmc Exp $ */
/* $NetBSD: cu.c,v 1.5 1997/02/11 09:24:05 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,24 +36,21 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)cu.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: cu.c,v 1.10 2001/09/26 06:07:28 pvalchev Exp $";
static const char rcsid[] = "$OpenBSD: cu.c,v 1.19 2006/05/25 08:41:52 jmc Exp $";
#endif
#endif /* not lint */
#include "tip.h"
void cleanup();
void cuusage();
static void cuusage(void);
/*
* Botch the interface to look like cu's
*/
void
cumain(argc, argv)
int argc;
char *argv[];
cumain(int argc, char *argv[])
{
int ch, i;
int ch, i, parity;
long l;
char *cp;
static char sbuf[12];
@ -66,8 +59,9 @@ cumain(argc, argv)
cuusage();
CU = DV = NOSTR;
BR = DEFBR;
parity = 0; /* none */
while ((ch = getopt(argc, argv, "a:l:s:htoe0123456789")) != -1) {
switch(ch) {
switch (ch) {
case 'a':
CU = optarg;
break;
@ -85,8 +79,7 @@ cumain(argc, argv)
break;
case 's':
l = strtol(optarg, &cp, 10);
if (*cp != '\0' || l < 0 || l >= INT_MAX ||
speed((int)l) == 0) {
if (*cp != '\0' || l < 0 || l >= INT_MAX) {
fprintf(stderr, "%s: unsupported speed %s\n",
__progname, optarg);
exit(3);
@ -101,10 +94,16 @@ cumain(argc, argv)
HW = 1, DU = -1;
break;
case 'o':
setparity("odd");
if (parity != 0)
parity = 0; /* -e -o */
else
parity = 1; /* odd */
break;
case 'e':
setparity("even");
if (parity != 0)
parity = 0; /* -o -e */
else
parity = -1; /* even */
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
@ -136,6 +135,7 @@ cumain(argc, argv)
signal(SIGQUIT, cleanup);
signal(SIGHUP, cleanup);
signal(SIGTERM, cleanup);
signal(SIGCHLD, SIG_DFL);
/*
* The "cu" host name is used to define the
@ -155,24 +155,44 @@ cumain(argc, argv)
loginit();
user_uid();
vinit();
setparity("none");
switch (parity) {
case -1:
setparity("even");
break;
case 1:
setparity("odd");
break;
default:
setparity("none");
break;
}
setboolean(value(VERBOSE), FALSE);
if (HW)
ttysetup(speed(BR));
if (connect()) {
if (HW && ttysetup(BR)) {
fprintf(stderr, "%s: unsupported speed %ld\n",
__progname, BR);
daemon_uid();
(void)uu_unlock(uucplock);
exit(3);
}
if (con()) {
printf("Connect failed\n");
daemon_uid();
(void)uu_unlock(uucplock);
exit(1);
}
if (!HW)
ttysetup(speed(BR));
if (!HW && ttysetup(BR)) {
fprintf(stderr, "%s: unsupported speed %ld\n",
__progname, BR);
daemon_uid();
(void)uu_unlock(uucplock);
exit(3);
}
}
void
cuusage()
static void
cuusage(void)
{
fprintf(stderr, "usage: cu [-ehot] [-a acu] [-l line] [-s speed] [-#] "
"[phone-number]\n");
fprintf(stderr, "usage: cu [-ehot] [-a acu] [-l line] "
"[-s speed | -speed] [phone-number]\n");
exit(8);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: hunt.c,v 1.8 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: hunt.c,v 1.13 2006/03/17 19:39:46 deraadt Exp $ */
/* $NetBSD: hunt.c,v 1.6 1997/04/20 00:02:10 mellon Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,27 +36,27 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: hunt.c,v 1.8 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: hunt.c,v 1.13 2006/03/17 19:39:46 deraadt Exp $";
#endif
#endif /* not lint */
#include "tip.h"
extern char *getremote();
static jmp_buf deadline;
static int deadfl;
void
dead()
static void dead(int);
/*ARGSUSED*/
static void
dead(int signo)
{
deadfl = 1;
longjmp(deadline, 1);
}
long
hunt(name)
char *name;
hunt(char *name)
{
char *cp;
sig_t f;
@ -88,7 +84,7 @@ hunt(name)
if (setjmp(deadline) == 0) {
alarm(10);
FD = open(cp, (O_RDWR |
(boolean(value(DC)) ? O_NONBLOCK : 0)));
(boolean(value(DC)) ? O_NONBLOCK : 0)));
}
alarm(0);
if (FD < 0) {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.5 2001/09/09 19:30:49 millert Exp $ */
/* $OpenBSD: log.c,v 1.8 2006/03/16 19:32:46 deraadt Exp $ */
/* $NetBSD: log.c,v 1.4 1994/12/24 17:56:28 cgd Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: log.c,v 1.5 2001/09/09 19:30:49 millert Exp $";
static const char rcsid[] = "$OpenBSD: log.c,v 1.8 2006/03/16 19:32:46 deraadt Exp $";
#endif
#endif /* not lint */
@ -53,9 +49,7 @@ static FILE *flog = NULL;
* Log file maintenance routines
*/
void
logent(group, num, acu, message)
char *group;
const char *num, *acu, *message;
logent(char *group, char *num, char *acu, char *message)
{
char *user, *timestamp;
struct passwd *pwd;
@ -89,7 +83,7 @@ logent(group, num, acu, message)
}
void
loginit()
loginit(void)
{
flog = fopen(value(LOG), "a");
if (flog == NULL)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: partab.c,v 1.3 1997/04/02 01:47:02 millert Exp $ */
/* $OpenBSD: partab.c,v 1.5 2003/06/03 02:56:18 millert Exp $ */
/* $NetBSD: partab.c,v 1.4 1996/12/29 10:38:21 cgd Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)partab.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: partab.c,v 1.3 1997/04/02 01:47:02 millert Exp $";
static const char rcsid[] = "$OpenBSD: partab.c,v 1.5 2003/06/03 02:56:18 millert Exp $";
#endif
#endif /* not lint */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pathnames.h,v 1.2 1996/06/26 05:40:45 deraadt Exp $ */
/* $OpenBSD: pathnames.h,v 1.3 2003/06/03 02:56:18 millert Exp $ */
/* $NetBSD: pathnames.h,v 1.3 1994/12/08 09:30:59 jtc Exp $ */
/* $FreeBSD$ */
@ -14,11 +14,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: remote.c,v 1.10 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: remote.c,v 1.16 2006/06/06 23:24:52 deraadt Exp $ */
/* $NetBSD: remote.c,v 1.5 1997/04/20 00:02:45 mellon Exp $ */
/*
@ -14,11 +14,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -39,7 +35,7 @@
__FBSDID("$FreeBSD$");
#ifndef lint
static char copyright[] =
static const char copyright[] =
"@(#) Copyright (c) 1992, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
@ -47,7 +43,7 @@ static char copyright[] =
#ifndef lint
#if 0
static char sccsid[] = "@(#)remote.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: remote.c,v 1.10 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: remote.c,v 1.16 2006/06/06 23:24:52 deraadt Exp $";
#endif
#endif /* not lint */
@ -75,13 +71,12 @@ static char *db_array[3] = { _PATH_REMOTE, 0, 0 };
#define cgetflag(f) (cgetcap(bp, f, ':') != NULL)
static void getremcap(char *);
static void
getremcap(host)
char *host;
getremcap(char *host)
{
char **p, ***q;
char *bp;
char *rempath;
char **p, ***q, *bp, *rempath;
int stat;
rempath = getenv("REMOTE");
@ -96,8 +91,8 @@ getremcap(host)
}
if ((stat = cgetent(&bp, db_array, host)) < 0) {
if (DV ||
host[0] == '/' && access(DV = host, R_OK | W_OK) == 0) {
if ((DV != NULL) ||
(host[0] == '/' && access(DV = host, R_OK | W_OK) == 0)) {
CU = DV;
HO = host;
HW = 1;
@ -107,18 +102,18 @@ getremcap(host)
FS = DEFFS;
return;
}
switch(stat) {
switch (stat) {
case -1:
fprintf(stderr, "%s: unknown host %s\n", __progname,
host);
break;
case -2:
fprintf(stderr,
fprintf(stderr,
"%s: can't open host description file\n",
__progname);
break;
case -3:
fprintf(stderr,
fprintf(stderr,
"%s: possible reference loop in host description file\n", __progname);
break;
}
@ -130,6 +125,8 @@ getremcap(host)
cgetstr(bp, *p, *q);
if (!BR && (cgetnum(bp, "br", &BR) == -1))
BR = DEFBR;
if (!LD && (cgetnum(bp, "ld", &LD) == -1))
LD = TTYDISC;
if (cgetnum(bp, "fs", &FS) == -1)
FS = DEFFS;
if (DU < 0)
@ -189,6 +186,8 @@ getremcap(host)
setboolean(value(HALFDUPLEX), 1);
if (cgetflag("dc"))
setboolean(value(DC), 1);
if (cgetflag("hf"))
setboolean(value(HARDWAREFLOW), 1);
if (RE == NOSTR)
RE = (char *)"tip.record";
if (EX == NOSTR)
@ -210,8 +209,7 @@ getremcap(host)
}
char *
getremote(host)
char *host;
getremote(char *host)
{
char *cp;
static char *next;

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: tip.1,v 1.19 2001/09/23 06:15:30 pvalchev Exp $
.\" $OpenBSD: tip.1,v 1.37 2006/06/07 06:35:59 mbalmer Exp $
.\" $NetBSD: tip.1,v 1.7 1994/12/08 09:31:05 jtc Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
@ -12,11 +12,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
@ -39,70 +35,31 @@
.Dt TIP 1
.Os
.Sh NAME
.Nm tip ,
.Nm cu
.Nm tip
.Nd connect to a remote system
.Sh SYNOPSIS
.Nm
.Op Fl nv
.Op Fl Ar speed
.Op Ar system-name
.Nm cu
.Op Fl ehot
.Op Fl a Ar acu
.Op Fl l Ar line
.Op Fl s Ar speed
.Op Fl Ar #
.Op Ar phone-number
.Sh DESCRIPTION
The
.Nm
and
.Nm cu
utilities
establish a full-duplex connection to another machine, giving the
establishes a full-duplex connection to another machine, giving the
appearance of being logged in directly on the remote CPU.
It goes without saying that you must have a login on the machine (or
equivalent) to which you wish to connect.
The preferred interface is
.Nm .
The
.Nm cu
interface is included for those people attached to the
.Dq call Ux
command of
.At v7 .
This manual page
describes only
.Nm .
.Pp
The options are as follows:
.Bl -tag -width ".Fl s Ar speed"
.It Fl a Ar acu
Set the acu.
.It Fl l Ar line
For
.Nm cu ,
specify the line to use.
Either of the forms like
.Pa tty00
or
.Pa /dev/tty00
are permitted.
.Bl -tag -width 4n
.It Fl n
No escape (disable tilde).
.It Fl s Ar speed
For
.Nm cu ,
set the speed of the connection.
Defaults to 9600.
.It Fl v
Set verbose mode.
.El
.Pp
If
.Ar speed
is specified it will override any baudrate specified in the system
is specified, it will override any baudrate specified in the system
description being used.
.Pp
If neither
@ -121,17 +78,14 @@ is specified but
.Ar system-name
is not,
.Ar system-name
will be set to a value of
.Dq Li tip
with
will be set to a value of 'tip' with
.Ar speed
appended.
E.g.,
.Nm Fl 1200
For example,
.Ic tip -1200
will set
.Ar system-name
to
.Dq Li tip1200 .
to 'tip1200'.
.Pp
Typed characters are normally transmitted directly to the remote
machine (which does the echoing as well).
@ -139,70 +93,67 @@ A tilde
.Pq Ql ~
appearing as the first character of a line is an escape signal; the
following are recognized:
.Bl -tag -width indent
.It Xo
.Ic ~^D
or
.Ic ~.
.Xc
Drop the connection and exit (you may still be logged in on the remote
machine).
.Bl -tag -offset indent -width Fl
.It Ic ~^D No or Ic ~.
Drop the connection and exit.
Only the connection is dropped \(en the login session is not terminated.
.It Ic ~c Op Ar name
Change directory to
.Ar name
(no argument implies change to your home directory).
(no argument implies change to home directory).
.It Ic ~!
Escape to a shell (exiting the shell will return you to
Escape to a shell (exiting the shell will return to
.Nm ) .
.It Ic ~>
.It Ic ~\*(Gt
Copy file from local to remote.
The
.Nm
utility
prompts for the name of a local file to transmit.
.It Ic ~<
.It Ic ~\*(Lt
Copy file from remote to local.
The
.Nm
utility
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
Send a file to a remote
.Ux
host.
The put command causes the remote
This command causes the remote
.Ux
system to run the command string
.Dq Nm cat Li \&> Ar to ,
while
.Nm
sends it the
.Ar from
file.
system to run the following command string,
sending it the
.Sq from
file:
.Bd -literal -offset indent
stty -echo; cat \*(Gt 'to'; stty echo
.Ed
.Pp
If the
.Ar to
file is not specified, the
.Ar from
.Sq to
file isn't specified, the
.Sq from
file name is used.
this command is actually a
This command is actually a
.Ux
specific version of the
.Ic ~>
.Ic ~\*(Gt
command.
.It Ic ~t Ar from Op Ar to
Take a file from a remote
.Ux
host.
As in the put command, the
.Ar to
As in the
.Ic ~p
command, the
.Sq to
file defaults to the
.Ar from
file name if it is not specified.
The remote host executes the command string
.Dq Nm cat Ar from ; Nm echo Li ^A
.Sq from
file name if it isn't specified.
The remote host executes the following command string
to send the file to
.Nm .
.Nm :
.Bd -literal -offset indent
cat 'from'; echo '' | tr '\e012' '\e01'
.Ed
.It Ic ~|
Pipe the output from a remote command to a local
.Ux
@ -219,24 +170,22 @@ The command string sent to the local
system is processed by the shell.
.It Ic ~C
Fork a child process on the local system to perform special protocols
such as
.Tn XMODEM .
The child program will be run with the following
arrangement of file descriptors:
such as \s-1XMODEM\s+1.
The child program will be run with the following arrangement of
file descriptors:
.Bd -literal -offset indent
0 <-> remote tty in
1 <-> remote tty out
2 <-> local tty out
0 \*(Lt-\*(Gt remote tty in
1 \*(Lt-\*(Gt remote tty out
2 \*(Lt-\*(Gt local tty stderr
.Ed
.It Ic ~#
Send a
.Dv BREAK
to the remote system.
For systems which do not support the necessary
For systems which don't support the necessary
.Fn ioctl
call the break is simulated by a sequence of line speed changes and
.Dv DEL
characters.
call, the break is simulated by a sequence of line speed changes and
DEL characters.
.It Ic ~s
Set a variable (see the discussion below).
.It Ic ~v
@ -247,11 +196,11 @@ Stop
(only available with job control).
.It Ic ~^Y
Stop only the
.Dq "local side"
.Dq local side
of
.Nm
(only available with job control); the
.Dq "remote side"
.Dq remote side
of
.Nm ,
the side that displays output from the remote host, is left running.
@ -259,25 +208,25 @@ the side that displays output from the remote host, is left running.
Get a summary of the tilde escapes.
.El
.Pp
To find the system description and thus the operating characteristics
To find the system description, and thus the operating characteristics
of
.Ar system-name ,
.Nm
searches for a system description with a name identical to
.Ar system-name .
The search order is as follows:
The search order is
.Bl -enum -offset indent
.It
If the environment variable
.Ev REMOTE
does not start with a
.Ql \&/
.Ql /
it is assumed to be a system description, and is considered first.
.It
If the environment variable
.Ev REMOTE
begins with a
.Ql \&/
.Ql /
it is assumed to be a path to a
.Xr remote 5
database, and the specified database is searched.
@ -294,96 +243,90 @@ See
for full documentation on system descriptions.
.Pp
The
.Va br
.Ar br
capability is used in system descriptions to specify the baud rate
with which to establish a connection.
If the value specified is not suitable, the baud rate to be used may
be given on the command line, e.g.,
.Dq Li "tip -300 mds" .
be given on the command line, e.g.\&
.Ql tip -300 mds .
.Pp
When
.Nm
establishes a connection, it sends out the connection message
specified in the
.Va cm
.Ar cm
capability of the system description being used.
.Pp
When
.Nm
prompts for an argument (e.g., during setup of a file transfer), the
prompts for an argument, for example 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.
dialogue and return the user to the remote machine.
.Pp
The
.Nm
utility
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 Pq Pa ports/net/freebsd-uucp .
.Xr uucico .
.Pp
During file transfers,
During file transfers
.Nm
provides a running count of the number of lines transferred.
When using the
.Ic ~>
.Ic ~\*(Gt
and
.Ic ~<
.Ic ~\*(Lt
commands, the
.Va eofread
.Dq eofread
and
.Va eofwrite
.Dq eofwrite
variables are used to recognize end-of-file when reading, and 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,
.Va echocheck
may be set to indicate that
File transfers normally depend on hardwareflow or tandem mode for flow control.
If the remote system does not support hardwareflow or tandem mode,
.Dq echocheck
may be set to indicate
.Nm
should synchronize with the remote system on the echo of each
transmitted character.
.Pp
When
.Nm
must dial a phone number to connect to a system, it will print various
must dial a phone number to connect to a system it will print various
messages indicating its actions.
The
.Nm
utility
supports a variety of auto-call units and modems with the
.Va at
.Ar at
capability in system descriptions.
.Pp
Support for Ventel 212+ (ventel), Hayes AT-style (hayes),
Support for Ventel 212+ (ventel), Hayes AT-style (hayes),
USRobotics Courier (courier), Telebit T3000 (t3000) and
Racal-Vadic 831 (vadic) units is enabled by default.
.Pp
Support for Bizcomp 1031[fw] (biz31[fw]), Bizcomp 1022[fw]
(biz22[fw]), DEC DF0[23]-AC (df0[23]), DEC DN-11 (dn11) and
Racal-Vadic 3451 (v3451) units can be added by recompiling
.Nm
.Nm tip
with the appropriate defines.
.Pp
Note that if support for both the Racal-Vadic 831 and 3451 is enabled,
they are referred to as the v831 and v3451, respectively.
Note that if support for both the Racal-Vadic 831 and 3451 is enabled
they are referred to as the v831 and v3451 respectively.
If only one of the two is supported, it is referred to as vadic.
.Ss Variables
The
.Ss VARIABLES
.Nm
utility
maintains a set of variables which control its operation.
Some of these variables are read-only to normal users (root is allowed
to change anything of interest).
Variables may be displayed and set through the
.Ic ~s
.Sq s
escape.
The syntax for variables is patterned after
.Xr vi 1
and
.Xr Mail 1 .
Supplying
.Dq Li all
.Dq all
as an argument to the set command displays all variables readable by
the user.
Alternatively, the user may request display of a particular variable
@ -391,7 +334,7 @@ by attaching a
.Ql \&?
to the end.
For example,
.Dq Li escape?
.Dq escape?
displays the current escape character.
.Pp
Variables are numeric, string, character, or boolean values.
@ -407,171 +350,165 @@ A single set command may be used to interrogate as well as set a
number of variables.
Variables may be initialized at run time by placing set commands
(without the
.Ic ~s
prefix in a file
.Pa .tiprc
in one's home directory).
The
.Ql ~s
prefix) in the initialization file
.Pa ~/.tiprc ;
the
.Fl v
option causes
option additionally causes
.Nm
to display the sets as they are made.
Certain common variables have abbreviations.
The following is a list of common variables, their abbreviations, and
their default values:
.Bl -tag -width indent
.It Va beautify
.Pq Vt bool
Discard unprintable characters when a session is being
scripted; abbreviated
.Va be .
.It Va baudrate
.Pq Vt num
The baud rate at which the connection was established;
.Bl -tag -width Ar
.It Ar baudrate
(num) The baud rate at which the connection was established;
abbreviated
.Va ba .
.It Va dialtimeout
.Pq Vt num
When dialing a phone number, the time (in seconds) to wait for a
.Ar ba .
.It Ar beautify
(bool) Discard unprintable characters when a session is being
scripted; abbreviated
.Ar be .
.It Ar dialtimeout
(num) When dialing a phone number, the time (in seconds) to wait for a
connection to be established; abbreviated
.Va dial .
.It Va echocheck
.Pq Vt bool
Synchronize with the remote host during file transfer by
.Ar dial .
.It Ar echocheck
(bool) Synchronize with the remote host during file transfer by
waiting for the echo of the last character transmitted; default is
.Cm off .
.It Va eofread
.Pq Vt str
The set of characters which signify an end-of-transmission
.Ar off .
.It Ar eofread
(str) The set of characters which signify an end-of-transmission
during a
.Ic ~<
.Ic ~\*(Lt
file transfer command; abbreviated
.Va eofr .
.It Va eofwrite
.Pq Vt str
The string sent to indicate end-of-transmission during a
.Ic ~>
.Ar eofr .
.It Ar eofwrite
(str) The string sent to indicate end-of-transmission during a
.Ic ~\*(Gt
file transfer command; abbreviated
.Va eofw .
.It Va eol
.Pq Vt str
The set of characters which indicate an end-of-line.
The
.Ar eofw .
.It Ar eol
(str) The set of characters which indicate an end-of-line.
.Nm
utility
will recognize escape characters only after an end-of-line.
.It Va escape
.Pq Vt char
The command prefix (escape) character; abbreviated
.Va es ;
.It Ar escape
(char) The command prefix (escape) character; abbreviated
.Ar es ;
default value is
.Ql ~ .
.It Va exceptions
.Pq Vt str
The set of characters which should not be discarded due to the
.It Ar exceptions
(str) The set of characters which should not be discarded due to the
beautification switch; abbreviated
.Va ex ;
.Ar ex ;
default value is
.Dq Li \et\en\ef\eb .
.It Va force
.Pq Vt char
The character used to force literal data transmission;
.Dq \et\en\ef\eb .
.It Ar force
(char) The character used to force literal data transmission;
abbreviated
.Va fo ;
.Ar fo ;
default value is
.Ql ^P .
.It Va framesize
.Pq Vt num
The amount of data (in bytes) to buffer between file system
.It Ar framesize
(num) The amount of data (in bytes) to buffer between filesystem
writes when receiving files; abbreviated
.Va fr .
.It Va host
.Pq Vt str
The name of the host to which you are connected; abbreviated
.Va ho .
.It Va prompt
.Pq Vt char
The character which indicates an end-of-line on the remote
.Ar fr .
.It Ar hardwareflow
(bool) Whether hardware flow control (CRTSCTS) is enabled for the
connection; abbreviated
.Ar hf ;
default value is
.Ql off .
.It Ar host
(str) The name of the host to which you are connected; abbreviated
.Ar ho .
.It Ar linedisc
(num) The line discipline to use; abbreviated
.Ar ld .
.It Ar prompt
(char) The character which indicates an end-of-line on the remote
host; abbreviated
.Va pr ;
.Ar pr ;
default value is
.Ql \en .
This value is used to synchronize during data transfers.
The count of lines transferred during a file transfer command is based
on receipt of this character.
.It Va raise
.Pq Vt bool
Upper case mapping mode; abbreviated
.Va ra ;
.It Ar raise
(bool) Upper case mapping mode; abbreviated
.Ar ra ;
default value is
.Cm off .
.Ar off .
When this mode is enabled, all lowercase letters will be mapped to
uppercase by
.Nm
for transmission to the remote machine.
.It Va raisechar
.Pq Vt char
The input character used to toggle uppercase mapping mode;
.It Ar raisechar
(char) The input character used to toggle uppercase mapping mode;
abbreviated
.Va rc ;
.Ar rc ;
default value is
.Ql ^A .
.It Va record
.Pq Vt str
The name of the file in which a session script is recorded;
.It Ar record
(str) The name of the file in which a session script is recorded;
abbreviated
.Va rec ;
.Ar rec ;
default value is
.Pa tip.record .
.It Va script
.Pq Vt bool
Session scripting mode; abbreviated
.Va sc ;
.Dq tip.record .
.It Ar script
(bool) Session scripting mode; abbreviated
.Ar sc ;
default is
.Cm off .
.Ar off .
When
.Va script
.Ar script
is
.Cm true ,
.Li true ,
.Nm
will record everything transmitted by the remote machine in the script
record file specified in
.Va record .
.Ar record .
If the
.Va beautify
.Ar beautify
switch is on, only printable
.Tn ASCII
characters will be included in the script file (those characters
between 040 and 0177).
The variable
.Va exceptions
.Ar exceptions
is used to indicate characters which are an exception to the normal
beautification rules.
.It Va tabexpand
.Pq Vt bool
Expand tabs to spaces during file transfers; abbreviated
.Va tab ;
.It Ar tabexpand
(bool) Expand tabs to spaces during file transfers; abbreviated
.Ar tab ;
default value is
.Cm false .
.Ar false .
Each tab is expanded to 8 spaces.
.It Va verbose
.Pq Vt bool
Verbose mode; abbreviated
.Va verb ;
.It Ar tandem
(bool) Use XON/XOFF flow control to throttle data from the remote host;
abbreviated
.Ar ta .
The default value is
.Ar true
unless the
.Ar nt
capability has been specified in
.Pa /etc/remote ,
in which case the default value is
.Ar false .
.It Ar verbose
(bool) Verbose mode; abbreviated
.Ar verb ;
default is
.Cm true .
.Ar true .
When verbose mode is enabled,
.Nm
prints messages while dialing, shows the current number of lines
transferred during a file transfer operations, and more.
.El
.Sh ENVIRONMENT
.Bl -tag -width indent
.It Ev SHELL
The name of the shell to use for the
.Ic ~!
command; default value is
.Pa /bin/sh .
.Bl -tag -width Fl
.It Ev HOME
The home directory to use for the
.Ic ~c
@ -580,36 +517,42 @@ command.
The default value for
.Ar system-name
if none is specified via the command line.
.It Ev REMOTE
A system description, or an absolute path to a
.Xr remote 5
system description database.
.It Ev PHONES
A path to a
.Xr phones 5
database.
.It Ev REMOTE
A system description, or an absolute path to a
.Xr remote 5
system description database.
.It Ev SHELL
The name of the shell to use for the
.Ic ~!\&
command; default value is
.Dq /bin/sh .
.El
.Sh FILES
.Bl -tag -width ".Pa /var/spool/lock/LCK..*" -compact
.It Pa /etc/remote
global
.Xr remote 5
database
.It Pa /etc/phones
default
.Xr phones 5
file
.Bl -tag -width "/var/spool/lock/LCK..*" -compact
.It Pa ~/.tiprc
initialization file
.It Pa tip.record
record file
.It Pa /etc/phones
default
.Xr phones 5
file
.It Pa /etc/remote
global
.Xr remote 5
database
.It Pa /var/log/aculog
line access log
.It Pa /var/spool/lock/LCK..*
lock file to avoid conflicts with
.Xr uucp 1 Pq Pa ports/net/freebsd-uucp
.Xr uucp
.El
.Sh SEE ALSO
.Xr cu 1 ,
.Xr phones 5 ,
.Xr remote 5
.Sh HISTORY

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tip.c,v 1.15 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: tip.c,v 1.30 2006/08/18 03:06:18 jason Exp $ */
/* $NetBSD: tip.c,v 1.13 1997/04/20 00:03:05 mellon Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -38,7 +34,7 @@
__FBSDID("$FreeBSD$");
#ifndef lint
static char copyright[] =
static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
@ -46,7 +42,7 @@ static char copyright[] =
#ifndef lint
#if 0
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: tip.c,v 1.15 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: tip.c,v 1.30 2006/08/18 03:06:18 jason Exp $";
#endif
#endif /* not lint */
@ -59,30 +55,21 @@ static char rcsid[] = "$OpenBSD: tip.c,v 1.15 2001/10/24 18:38:58 millert Exp $"
#include "tip.h"
#include "pathnames.h"
/*
* Baud rate mapping table
*/
int rates[] = {
0, 50, 75, 110, 134, 150, 200, 300, 600,
1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, -1
};
int disc = TTYDISC; /* tip normally runs this way */
void intprompt();
void timeout();
void cleanup();
char PNbuf[256]; /* This limits the size of a number */
static void intprompt(int);
static void tipin(void);
static int escape(void);
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
char *system = NOSTR;
char *sys = NOSTR, sbuf[12], *p;
int i;
char *p;
const char *p2;
char sbuf[12];
/* XXX preserve previous braindamaged behavior */
setboolean(value(DC), TRUE);
gid = getgid();
egid = getegid();
@ -105,7 +92,7 @@ main(argc, argv)
for (; argc > 1; argv++, argc--) {
if (argv[1][0] != '-')
system = argv[1];
sys = argv[1];
else switch (argv[1][1]) {
case 'v':
@ -128,34 +115,35 @@ main(argc, argv)
}
}
if (system == NOSTR)
if (sys == NOSTR)
goto notnumber;
if (isalpha(*system))
if (isalpha(*sys))
goto notnumber;
/*
* System name is really a phone number...
* Copy the number then stomp on the original (in case the number
* is private, we don't want 'ps' or 'w' to find it).
*/
if (strlen(system) > sizeof PNbuf - 1) {
if (strlen(sys) > sizeof PNbuf - 1) {
fprintf(stderr, "%s: phone number too long (max = %d bytes)\n",
__progname, (int)sizeof(PNbuf) - 1);
exit(1);
}
strncpy( PNbuf, system, sizeof PNbuf - 1 );
for (p = system; *p; p++)
strlcpy(PNbuf, sys, sizeof PNbuf - 1);
for (p = sys; *p; p++)
*p = '\0';
PN = PNbuf;
(void)snprintf(sbuf, sizeof(sbuf), "tip%ld", BR);
system = sbuf;
sys = sbuf;
notnumber:
(void)signal(SIGINT, cleanup);
(void)signal(SIGQUIT, cleanup);
(void)signal(SIGHUP, cleanup);
(void)signal(SIGTERM, cleanup);
(void)signal(SIGCHLD, SIG_DFL);
if ((i = hunt(system)) == 0) {
if ((i = hunt(sys)) == 0) {
printf("all ports busy\n");
exit(3);
}
@ -184,29 +172,32 @@ main(argc, argv)
PH = _PATH_PHONES;
vinit(); /* init variables */
setparity("none"); /* set the parity table */
if ((i = speed(number(value(BAUDRATE)))) == 0) {
printf("%s: bad baud rate %ld\n", __progname,
number(value(BAUDRATE)));
daemon_uid();
(void)uu_unlock(uucplock);
exit(3);
}
/*
* Hardwired connections require the
* line speed set before they make any transmissions
* (this is particularly true of things like a DF03-AC)
*/
if (HW)
ttysetup(i);
if ((p2 = connect())) {
printf("\07%s\n[EOT]\n", p2);
if (HW && ttysetup(number(value(BAUDRATE)))) {
fprintf(stderr, "%s: bad baud rate %ld\n", __progname,
number(value(BAUDRATE)));
daemon_uid();
(void)uu_unlock(uucplock);
exit(3);
}
if ((p = con())) {
printf("\07%s\n[EOT]\n", p);
daemon_uid();
(void)uu_unlock(uucplock);
exit(1);
}
if (!HW)
ttysetup(i);
if (!HW && ttysetup(number(value(BAUDRATE)))) {
fprintf(stderr, "%s: bad baud rate %ld\n", __progname,
number(value(BAUDRATE)));
daemon_uid();
(void)uu_unlock(uucplock);
exit(3);
}
cucommon:
/*
* From here down the code is shared with
@ -216,15 +207,16 @@ main(argc, argv)
i = fcntl(FD, F_GETFL);
if (i == -1) {
perror("fcntl");
cleanup();
cleanup(0);
}
i = fcntl(FD, F_SETFL, i & ~O_NONBLOCK);
if (i == -1) {
perror("fcntl");
cleanup();
cleanup(0);
}
tcgetattr(0, &defterm);
gotdefterm = 1;
term = defterm;
term.c_lflag &= ~(ICANON|IEXTEN|ECHO);
term.c_iflag &= ~(INPCK|ICRNL);
@ -233,13 +225,18 @@ main(argc, argv)
term.c_cc[VTIME] = 0;
defchars = term;
term.c_cc[VINTR] = term.c_cc[VQUIT] = term.c_cc[VSUSP] =
term.c_cc[VDSUSP] = term.c_cc[VDISCARD] =
term.c_cc[VLNEXT] = _POSIX_VDISABLE;
term.c_cc[VDSUSP] = term.c_cc[VDISCARD] =
term.c_cc[VLNEXT] = _POSIX_VDISABLE;
raw();
pipe(fildes); pipe(repdes);
(void)signal(SIGALRM, timeout);
if (value(LINEDISC) != TTYDISC) {
int ld = (int)value(LINEDISC);
ioctl(FD, TIOCSETD, &ld);
}
/*
* Everything's set up now:
* connection established (hardwired or dialup)
@ -248,7 +245,8 @@ main(argc, argv)
* so, fork one process for local side and one for remote.
*/
printf(cumode ? "Connected\r\n" : "\07connected\r\n");
if ((pid = fork()))
tipin_pid = getpid();
if ((tipout_pid = fork()))
tipin();
else
tipout();
@ -257,13 +255,17 @@ main(argc, argv)
}
void
cleanup()
cleanup(int signo)
{
daemon_uid();
(void)uu_unlock(uucplock);
if (odisc)
ioctl(0, TIOCSETD, (char *)&odisc);
ioctl(0, TIOCSETD, &odisc);
unraw();
if (signo && tipout_pid) {
kill(tipout_pid, signo);
wait(NULL);
}
exit(0);
}
@ -278,7 +280,7 @@ cleanup()
static int uidswapped;
void
user_uid()
user_uid(void)
{
if (uidswapped == 0) {
seteuid(uid);
@ -287,7 +289,7 @@ user_uid()
}
void
daemon_uid()
daemon_uid(void)
{
if (uidswapped) {
@ -297,7 +299,7 @@ daemon_uid()
}
void
shell_uid()
shell_uid(void)
{
setegid(gid);
seteuid(uid);
@ -307,7 +309,7 @@ shell_uid()
* put the controlling keyboard into raw mode
*/
void
raw()
raw(void)
{
tcsetattr(0, TCSADRAIN, &term);
}
@ -317,9 +319,10 @@ raw()
* return keyboard to normal mode
*/
void
unraw()
unraw(void)
{
tcsetattr(0, TCSADRAIN, &defterm);
if (gotdefterm)
tcsetattr(0, TCSADRAIN, &defterm);
}
static jmp_buf promptbuf;
@ -330,10 +333,7 @@ static jmp_buf promptbuf;
* normal erase and kill characters.
*/
int
prompt(s, p, sz)
char *s;
char *p;
size_t sz;
prompt(char *s, char *p, size_t sz)
{
int c;
char *b = p;
@ -358,10 +358,10 @@ prompt(s, p, sz)
/*
* Interrupt service routine during prompting
*/
void
intprompt()
/*ARGSUSED*/
static void
intprompt(int signo)
{
(void)signal(SIGINT, SIG_IGN);
stoprompt = 1;
printf("\r\n");
@ -371,10 +371,12 @@ intprompt()
/*
* ****TIPIN TIPIN****
*/
void
tipin()
static void
tipin(void)
{
char gch, bol = 1;
int bol = 1;
int gch;
char ch;
/*
* Kinda klugey here...
@ -390,6 +392,7 @@ tipin()
while (1) {
gch = getchar()&STRIP_PAR;
/* XXX does not check for EOF */
if ((gch == character(value(ESCAPE))) && bol) {
if (!noesc) {
if (!(gch = escape()))
@ -400,7 +403,8 @@ tipin()
continue;
} else if (gch == '\r') {
bol = 1;
parwrite(FD, &gch, 1);
ch = gch;
parwrite(FD, &ch, 1);
if (boolean(value(HALFDUPLEX)))
printf("\r\n");
continue;
@ -409,9 +413,10 @@ tipin()
bol = any(gch, value(EOL));
if (boolean(value(RAISE)) && islower(gch))
gch = toupper(gch);
parwrite(FD, &gch, 1);
ch = gch;
parwrite(FD, &ch, 1);
if (boolean(value(HALFDUPLEX)))
printf("%c", gch);
printf("%c", ch);
}
}
@ -421,14 +426,15 @@ extern esctable_t etable[];
* Escape handler --
* called on recognition of ``escapec'' at the beginning of a line
*/
int
escape()
static int
escape(void)
{
char gch;
int gch;
esctable_t *p;
char c = character(value(ESCAPE));
gch = (getchar()&STRIP_PAR);
/* XXX does not check for EOF */
for (p = etable; p->e_char; p++)
if (p->e_char == gch) {
if ((p->e_flags&PRIV) && uid)
@ -444,21 +450,7 @@ escape()
}
int
speed(n)
int n;
{
int *p;
for (p = rates; *p != -1; p++)
if (*p == n)
return n;
return 0;
}
int
any(cc, p)
int cc;
char *p;
any(int cc, char *p)
{
char c = cc;
while (p && *p)
@ -467,11 +459,10 @@ any(cc, p)
return (0);
}
int
size(s)
char *s;
size_t
size(char *s)
{
int i = 0;
size_t i = 0;
while (s && *s++)
i++;
@ -479,8 +470,7 @@ size(s)
}
char *
interp(s)
char *s;
interp(char *s)
{
static char buf[256];
char *p = buf, c, *q;
@ -505,8 +495,7 @@ interp(s)
}
char *
ctrl(c)
char c;
ctrl(char c)
{
static char s[3];
@ -525,8 +514,7 @@ ctrl(c)
* Help command
*/
void
help(c)
char c;
help(int c)
{
esctable_t *p;
@ -543,19 +531,20 @@ help(c)
/*
* Set up the "remote" tty's state
*/
void
ttysetup(speed)
int speed;
int
ttysetup(int speed)
{
struct termios cntrl;
tcgetattr(FD, &cntrl);
cfsetospeed(&cntrl, speed);
cfsetispeed(&cntrl, speed);
if (tcgetattr(FD, &cntrl))
return (-1);
cfsetspeed(&cntrl, speed);
cntrl.c_cflag &= ~(CSIZE|PARENB);
cntrl.c_cflag |= CS8;
if (boolean(value(DC)))
cntrl.c_cflag |= CLOCAL;
if (boolean(value(HARDWAREFLOW)))
cntrl.c_cflag |= CRTSCTS;
cntrl.c_iflag &= ~(ISTRIP|ICRNL);
cntrl.c_oflag &= ~OPOST;
cntrl.c_lflag &= ~(ICANON|ISIG|IEXTEN|ECHO);
@ -563,7 +552,7 @@ ttysetup(speed)
cntrl.c_cc[VTIME] = 0;
if (boolean(value(TAND)))
cntrl.c_iflag |= IXOFF;
tcsetattr(FD, TCSAFLUSH, &cntrl);
return (tcsetattr(FD, TCSAFLUSH, &cntrl));
}
static char partab[0200];
@ -574,10 +563,7 @@ static char partab[0200];
* with the right parity and output it.
*/
void
parwrite(fd, buf, n)
int fd;
char *buf;
int n;
parwrite(int fd, char *buf, size_t n)
{
int i;
char *bp;
@ -600,8 +586,7 @@ parwrite(fd, buf, n)
* Build a parity table with appropriate high-order bit.
*/
void
setparity(defparity)
char *defparity;
setparity(char *defparity)
{
int i, flip, clr, set;
char *parity;
@ -629,5 +614,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 @@
/* $OpenBSD: tip.h,v 1.11 2001/09/09 19:30:49 millert Exp $ */
/* $OpenBSD: tip.h,v 1.27 2006/08/18 03:06:18 jason Exp $ */
/* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */
/* $FreeBSD$ */
@ -15,11 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -92,8 +88,8 @@ char *PR; /* remote prompt */
long DL; /* line delay for file transfers to remote */
long CL; /* char delay for file transfers to remote */
long ET; /* echocheck timeout */
long LD; /* line disc */
short HD; /* this host is half duplex - do local echo */
short DC; /* this host is directly connected. */
/*
* String value table
@ -134,10 +130,10 @@ typedef
*/
typedef
struct {
const char *acu_name;
int (*acu_dialer)(char *, char *);
void (*acu_disconnect)(void);
void (*acu_abort)(void);
char *acu_name;
int (*acu_dialer)(char *, char *);
void (*acu_disconnect)(void);
void (*acu_abort)(void);
}
acu_t;
@ -151,6 +147,7 @@ typedef
*/
#define value(v) vtable[v].v_value
#define lvalue(v) (long)vtable[v].v_value
#define number(v) ((long)(v))
#define boolean(v) ((short)(long)(v))
@ -170,16 +167,16 @@ typedef
typedef
struct {
char e_char; /* char to match on */
char e_flags; /* experimental, priviledged */
const char *e_help; /* help string */
void (*e_func)(char); /* command */
char e_char; /* char to match on */
char e_flags; /* experimental, privileged */
char *e_help; /* help string */
void (*e_func)(int); /* command */
}
esctable_t;
#define NORM 00 /* normal protection, execute anyone */
#define EXP 01 /* experimental, mark it with a `*' on help */
#define PRIV 02 /* priviledged, root execute only */
#define PRIV 02 /* privileged, root execute only */
extern int vflag; /* verbose during reading of .tiprc file */
extern int noesc; /* no escape `~' char */
@ -228,6 +225,9 @@ extern value_t vtable[]; /* variable table */
#define HALFDUPLEX 30
#define LECHO 31
#define PARITY 32
#define HARDWAREFLOW 33
#define LINEDISC 34
#define DC 35
#define NOVAL ((value_t *)NULL)
#define NOACU ((acu_t *)NULL)
@ -238,6 +238,7 @@ extern value_t vtable[]; /* variable table */
struct termios term; /* current mode of terminal */
struct termios defterm; /* initial mode of terminal */
struct termios defchars; /* current mode with initial chars */
int gotdefterm;
FILE *fscript; /* FILE for scripting */
@ -248,7 +249,8 @@ int AC; /* open file descriptor to dialer (v831 only) */
int vflag; /* print .tiprc initialization sequence */
int noesc; /* no `~' escape char */
int sfd; /* for ~< operation */
int pid; /* pid of tipout */
pid_t tipin_pid; /* pid of tipin */
pid_t tipout_pid; /* pid of tipout */
uid_t uid, euid; /* real and effective user id's */
gid_t gid, egid; /* real and effective group id's */
int stop; /* stop transfer session flag */
@ -263,7 +265,6 @@ int bits8; /* terminal is is 8-bit mode */
char fname[PATH_MAX]; /* file name buffer for ~< */
char copyname[PATH_MAX]; /* file name buffer for ~> */
char ccc; /* synchronization character */
char ch; /* for tipout */
char *uucplock; /* name of lock file for uucp's */
int odisc; /* initial tty line discipline */
@ -271,68 +272,82 @@ extern int disc; /* current tty discpline */
extern char *__progname; /* program name */
extern char *ctrl(char);
extern char *vinterp(char *, char);
extern const char *connect(void);
char *sname(char *s);
int any(int cc, char *p);
int anyof(char *s1, char *s2);
int args(char *buf, char *a[], int num);
int escape(void);
int prompt(char *s, char *p, size_t sz);
int size(char *s);
int speed(int n);
int uu_lock(char *_ttyname);
int uu_unlock(char *_ttyname);
int vstring(char *s, char *v);
long hunt(char *name);
void cumain(int argc, char *argv[]);
void daemon_uid(void);
void disconnect(char *reason);
void execute(char *s);
char *interp(char *s);
void logent(char *group, const char *num, const char *acu, const char *message);
void loginit(void);
void prtime(char *s, time_t a);
void parwrite(int fd, char *buf, int n);
void raw(void);
void send(int c);
void setparity(char *defparity);
void setscript(void);
void shell_uid(void);
void tandem(char *option);
void tipabort(char *msg);
void tipin(void);
void tipout(void);
void transfer(char *buf, int fd, char *eofchars);
void transmit(FILE *fd, char *eofchars, char *command);
void ttysetup(int _speed);
void unraw(void);
void user_uid(void);
void vinit(void);
void vlex(char *s);
char *con(void);
char *ctrl(char);
char *expand(char *);
char *getremote(char *);
char *interp(char *);
int any(int, char *);
int biz22w_dialer(char *, char *);
int biz22f_dialer(char *, char *);
int biz31w_dialer(char *, char *);
int biz31f_dialer(char *, char *);
void biz31f_disconnect(void);
void biz31f_abort(void);
int ven_dialer(char *, char *);
void ven_disconnect(void);
void ven_abort(void);
int hay_dialer(char *, char *);
void hay_disconnect(void);
void hay_abort(void);
int cour_dialer(char *, char *);
void cour_disconnect(void);
void cour_abort(void);
int df02_dialer(char *, char *);
int df03_dialer(char *, char *);
int dn_dialer(char *, char *);
int hay_dialer(char *, char *);
int prompt(char *, char *, size_t);
size_t size(char *);
int t3000_dialer(char *, char *);
int ttysetup(int);
int uu_lock(char *);
int uu_unlock(char *);
int v3451_dialer(char *, char *);
int v831_dialer(char *, char *);
int ven_dialer(char *, char *);
int vstring(char *, char *);
long hunt(char *);
void biz22_disconnect(void);
void biz22_abort(void);
void biz31_disconnect(void);
void biz31_abort(void);
void chdirectory(int);
void cleanup(int);
void consh(int);
void cour_abort(void);
void cour_disconnect(void);
void cu_put(int);
void cu_take(int);
void cumain(int, char **);
void daemon_uid(void);
void df_abort(void);
void df_disconnect(void);
void disconnect(char *);
void dn_abort(void);
void dn_disconnect(void);
void finish(int);
void genbrk(int);
void getfl(int);
void hay_abort(void);
void hay_disconnect(void);
void help(int);
void listvariables(int);
void logent(char *, char *, char *, char *);
void loginit(void);
void parwrite(int, char *, size_t);
void pipefile(int);
void pipeout(int);
void raw(void);
void sendfile(int);
void setparity(char *);
void setscript(void);
void shell(int);
void shell_uid(void);
void suspend(int);
void t3000_disconnect(void);
void t3000_abort(void);
int v831_dialer(char *, char *);
void timeout(int);
void tipabort(char *);
void tipout(void);
void user_uid(void);
void unraw(void);
void v3451_abort(void);
void v3451_disconnect(void);
void v831_disconnect(void);
void v831_abort(void);
void shell(char c), getfl(char c), sendfile(char c), chdirectory(char c);
void finish(char c), help(char c), pipefile(char c), pipeout(char c);
void consh(char c), variable(char c), cu_take(char c), cu_put(char c);
void dollar(char c), genbrk(char c), suspend(char c), listvariables(char c);
void variable(int);
void ven_disconnect(void);
void ven_abort(void);
void vinit(void);
void vlex(char *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tipout.c,v 1.8 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: tipout.c,v 1.18 2006/05/31 07:03:08 jason Exp $ */
/* $NetBSD: tipout.c,v 1.5 1996/12/29 10:34:12 cgd Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,11 +36,12 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)tipout.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: tipout.c,v 1.8 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: tipout.c,v 1.18 2006/05/31 07:03:08 jason Exp $";
#endif
#endif /* not lint */
#include "tip.h"
/*
* tip
*
@ -54,14 +51,19 @@ static char rcsid[] = "$OpenBSD: tipout.c,v 1.8 2001/10/24 18:38:58 millert Exp
static jmp_buf sigbuf;
static void intIOT(int);
static void intEMT(int);
static void intTERM(int);
static void intSYS(int);
/*
* TIPOUT wait state routine --
* sent by TIPIN when it wants to posses the remote host
*/
void
intIOT()
/*ARGSUSED*/
static void
intIOT(int signo)
{
write(repdes[1],&ccc,1);
read(fildes[0], &ccc,1);
longjmp(sigbuf, 1);
@ -71,8 +73,9 @@ intIOT()
* Scripting command interpreter --
* accepts script file name over the pipe and acts accordingly
*/
void
intEMT()
/*ARGSUSED*/
static void
intEMT(int signo)
{
char c, line[256];
char *pline = line;
@ -101,19 +104,20 @@ intEMT()
longjmp(sigbuf, 1);
}
void
intTERM()
static void
intTERM(int signo)
{
if (boolean(value(SCRIPT)) && fscript != NULL)
fclose(fscript);
if (signo && tipin_pid)
kill(tipin_pid, signo);
exit(0);
}
void
intSYS()
/*ARGSUSED*/
static void
intSYS(int signo)
{
setboolean(value(BEAUTIFY), !boolean(value(BEAUTIFY)));
longjmp(sigbuf, 1);
}
@ -122,11 +126,12 @@ intSYS()
* ****TIPOUT TIPOUT****
*/
void
tipout()
tipout(void)
{
char buf[BUFSIZ];
char *cp;
int cnt;
ssize_t scnt;
size_t cnt;
sigset_t mask, omask;
signal(SIGINT, SIG_IGN);
@ -140,18 +145,19 @@ tipout()
sigprocmask(SIG_BLOCK, NULL, &omask);
for (;;) {
sigprocmask(SIG_SETMASK, &omask, NULL);
cnt = read(FD, buf, BUFSIZ);
if (cnt <= 0) {
scnt = read(FD, buf, BUFSIZ);
if (scnt <= 0) {
/* lost carrier */
if (cnt < 0 && errno == EIO) {
if (scnt == 0 || (scnt < 0 && errno == EIO)) {
sigemptyset(&mask);
sigaddset(&mask, SIGTERM);
sigprocmask(SIG_BLOCK, &mask, NULL);
intTERM();
intTERM(0);
/*NOTREACHED*/
}
continue;
}
cnt = scnt;
sigemptyset(&mask);
sigaddset(&mask, SIGEMT);
sigaddset(&mask, SIGTERM);
@ -160,7 +166,7 @@ tipout()
sigprocmask(SIG_BLOCK, &mask, NULL);
for (cp = buf; cp < buf + cnt; cp++)
*cp &= STRIP_PAR;
write(1, buf, cnt);
write(STDOUT_FILENO, buf, cnt);
if (boolean(value(SCRIPT)) && fscript != NULL) {
if (!boolean(value(BEAUTIFY))) {
fwrite(buf, 1, cnt, fscript);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uucplock.c,v 1.6 1998/07/13 02:11:44 millert Exp $ */
/* $OpenBSD: uucplock.c,v 1.11 2006/03/16 19:32:46 deraadt Exp $ */
/* $NetBSD: uucplock.c,v 1.7 1997/02/11 09:24:08 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)uucplock.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: uucplock.c,v 1.6 1998/07/13 02:11:44 millert Exp $";
static const char rcsid[] = "$OpenBSD: uucplock.c,v 1.11 2006/03/16 19:32:46 deraadt Exp $";
#endif
#endif /* not lint */
@ -55,20 +51,19 @@ static char rcsid[] = "$OpenBSD: uucplock.c,v 1.6 1998/07/13 02:11:44 millert Ex
#include <errno.h>
#include "pathnames.h"
/*
/*
* uucp style locking routines
* return: 0 - success
* -1 - failure
* -1 - failure
*/
int
uu_lock(ttyname)
char *ttyname;
uu_lock(char *ttyname)
{
int fd, pid;
int fd, len;
char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];
char text_pid[81];
int len;
pid_t pid;
(void)snprintf(tbuf, sizeof tbuf, _PATH_LOCKDIRNAME, ttyname);
fd = open(tbuf, O_RDWR|O_CREAT|O_EXCL, 0660);
@ -84,7 +79,7 @@ uu_lock(ttyname)
return(-1);
}
len = read(fd, text_pid, sizeof(text_pid)-1);
if(len<=0) {
if (len<=0) {
perror(tbuf);
(void)close(fd);
fprintf(stderr, "Can't read lock file.\n");
@ -101,8 +96,8 @@ uu_lock(ttyname)
* The process that locked the file isn't running, so
* we'll lock it ourselves
*/
fprintf(stderr, "Stale lock on %s PID=%d... overriding.\n",
ttyname, pid);
fprintf(stderr, "Stale lock on %s PID=%ld... overriding.\n",
ttyname, (long)pid);
if (lseek(fd, (off_t)0, SEEK_SET) < 0) {
perror(tbuf);
(void)close(fd);
@ -112,7 +107,7 @@ uu_lock(ttyname)
/* fall out and finish the locking process */
}
pid = getpid();
(void)sprintf(text_pid, "%10d\n", pid);
(void)snprintf(text_pid, sizeof text_pid, "%10ld\n", (long)pid);
len = strlen(text_pid);
if (write(fd, text_pid, len) != len) {
(void)close(fd);
@ -125,8 +120,7 @@ uu_lock(ttyname)
}
int
uu_unlock(ttyname)
char *ttyname;
uu_unlock(char *ttyname)
{
char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];

View File

@ -1,4 +1,4 @@
/* $OpenBSD: value.c,v 1.7 2001/10/24 18:38:58 millert Exp $ */
/* $OpenBSD: value.c,v 1.14 2006/03/17 22:02:58 moritz Exp $ */
/* $NetBSD: value.c,v 1.6 1997/02/11 09:24:09 mrg Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)value.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: value.c,v 1.7 2001/10/24 18:38:58 millert Exp $";
static const char rcsid[] = "$OpenBSD: value.c,v 1.14 2006/03/17 22:02:58 moritz Exp $";
#endif
#endif /* not lint */
@ -48,19 +44,24 @@ static char rcsid[] = "$OpenBSD: value.c,v 1.7 2001/10/24 18:38:58 millert Exp $
#define MIDDLE 35
static value_t *vlookup();
static int col = 0;
static value_t *vlookup(char *);
static void vassign(value_t *, char *);
static void vtoken(char *);
static void vprint(value_t *);
static int vaccess(unsigned int, unsigned int);
static char *vinterp(char *, int);
static size_t col = 0;
/*
* Variable manipulation
*/
void
vinit()
vinit(void)
{
char file[FILENAME_MAX], *cp;
value_t *p;
char *cp;
FILE *f;
char file[FILENAME_MAX];
FILE *fp;
for (p = vtable; p->v_name != NULL; p++) {
if (p->v_type&ENVIRON)
@ -75,20 +76,20 @@ vinit()
*/
if (strlen(value(HOME)) + sizeof("/.tiprc") > sizeof(file)) {
(void)fprintf(stderr, "Home directory path too long: %s\n",
value(HOME));
value(HOME));
} else {
snprintf(file, sizeof file, "%s/.tiprc", value(HOME));
if ((f = fopen(file, "r")) != NULL) {
if ((fp = fopen(file, "r")) != NULL) {
char *tp;
while (fgets(file, sizeof(file)-1, f) != NULL) {
while (fgets(file, sizeof(file)-1, fp) != NULL) {
if (vflag)
printf("set %s", file);
if ((tp = strrchr(file, '\n')))
*tp = '\0';
vlex(file);
}
fclose(f);
fclose(fp);
}
}
/*
@ -97,21 +98,16 @@ vinit()
vtable[EXCEPTIONS].v_access &= ~(WRITE<<PUBLIC);
}
static int vaccess();
/*VARARGS1*/
void
vassign(p, v)
value_t *p;
char *v;
static void
vassign(value_t *p, char *v)
{
if (!vaccess(p->v_access, WRITE)) {
printf("access denied\r\n");
return;
}
switch (p->v_type&TMASK) {
switch (p->v_type&TMASK) {
case STRING:
if (p->v_value && equal(p->v_value, v))
return;
@ -123,19 +119,16 @@ vassign(p, v)
}
p->v_type &= ~(ENVIRON|INIT);
break;
case NUMBER:
if (number(p->v_value) == number(v))
return;
setnumber(p->v_value, number(v));
break;
case BOOL:
if (boolean(p->v_value) == (*v != '!'))
return;
setboolean(p->v_value, (*v != '!'));
break;
case CHAR:
if (character(p->v_value) == *v)
return;
@ -144,22 +137,17 @@ vassign(p, v)
p->v_access |= CHANGED;
}
static void vprint();
static void vtoken();
void
vlex(s)
char *s;
vlex(char *s)
{
value_t *p;
char *cp;
if (equal(s, "all")) {
for (p = vtable; p->v_name; p++)
if (vaccess(p->v_access, READ))
vprint(p);
} else {
char *cp;
do {
if ((cp = vinterp(s, ' ')))
cp++;
@ -174,19 +162,17 @@ vlex(s)
}
static void
vtoken(s)
char *s;
vtoken(char *s)
{
value_t *p;
char *cp;
char *expand();
if ((cp = strchr(s, '='))) {
*cp = '\0';
if ((p = vlookup(s))) {
cp++;
if (p->v_type&NUMBER)
vassign(p, atoi(cp));
vassign(p, (char *)atoi(cp));
else {
if (strcmp(s, "record") == 0)
cp = expand(cp);
@ -214,8 +200,7 @@ vtoken(s)
}
static void
vprint(p)
value_t *p;
vprint(value_t *p)
{
char *cp;
@ -265,10 +250,8 @@ vprint(p)
}
}
static int
vaccess(mode, rw)
unsigned mode, rw;
vaccess(unsigned int mode, unsigned int rw)
{
if (mode & (rw<<PUBLIC))
return (1);
@ -278,8 +261,7 @@ vaccess(mode, rw)
}
static value_t *
vlookup(s)
char *s;
vlookup(char *s)
{
value_t *p;
@ -289,15 +271,13 @@ vlookup(s)
return (NULL);
}
char *
vinterp(s, stop)
char *s;
char stop;
static char *
vinterp(char *s, int stop)
{
char *p = s, c;
int num;
while ((c = *s++) && c != stop)
while ((c = *s++) && c != stop) {
switch (c) {
case '^':
@ -338,6 +318,7 @@ vinterp(s, stop)
default:
*p++ = c;
}
}
*p = '\0';
return (c == stop ? s-1 : NULL);
}
@ -346,18 +327,15 @@ vinterp(s, stop)
* assign variable s with value v (for NUMBER or STRING or CHAR types)
*/
int
vstring(s,v)
char *s;
char *v;
vstring(char *s, char *v)
{
value_t *p;
char *expand();
p = vlookup(s);
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 @@
/* $OpenBSD: vars.c,v 1.2 1996/06/26 05:40:50 deraadt Exp $ */
/* $OpenBSD: vars.c,v 1.8 2006/08/18 03:06:18 jason Exp $ */
/* $NetBSD: vars.c,v 1.3 1994/12/08 09:31:19 jtc Exp $ */
/*
@ -13,11 +13,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93";
static char rcsid[] = "$OpenBSD: vars.c,v 1.2 1996/06/26 05:40:50 deraadt Exp $";
static const char rcsid[] = "$OpenBSD: vars.c,v 1.8 2006/08/18 03:06:18 jason Exp $";
#endif
#endif /* not lint */
@ -82,7 +78,7 @@ value_t vtable[] = {
{ "raise", BOOL, (READ|WRITE)<<PUBLIC,
"ra", (char *)FALSE },
{ "raisechar", CHAR, (READ|WRITE)<<PUBLIC,
"rc", (char *)CTRL('a') },
"rc", NOSTR },
{ "record", STRING|INIT|IREMOTE, (READ|WRITE)<<PUBLIC,
"rec", (char *)&RE },
{ "remote", STRING|INIT|IREMOTE, READ<<PUBLIC,
@ -117,6 +113,12 @@ value_t vtable[] = {
"le", (char *)FALSE },
{ "parity", STRING|INIT|IREMOTE, (READ|WRITE)<<PUBLIC,
"par", (char *)&PA },
{ "hardwareflow", BOOL, (READ|WRITE)<<PUBLIC,
"hf", (char *)FALSE },
{ "linedisc", NUMBER|IREMOTE|INIT, (READ|WRITE)<<PUBLIC,
"ld", (char *)&LD },
{ "direct", BOOL, (READ<<PUBLIC)|(WRITE<<ROOT),
"dc", (char *)FALSE },
{ NOSTR, 0, 0,
NOSTR, NOSTR }
};