mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
Import OpenBSD's tip(1) as of today
This commit is contained in:
parent
257c55772d
commit
d391708c06
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/bsd/; revision=161751
|
@ -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.
|
||||
*
|
||||
|
@ -38,19 +34,20 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)biz22.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
|
||||
#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
|
||||
|
@ -58,8 +55,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];
|
||||
|
@ -74,7 +70,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...");
|
||||
|
@ -95,61 +91,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;
|
||||
|
@ -170,14 +160,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();
|
||||
|
@ -191,5 +180,5 @@ detect(s)
|
|||
return (0);
|
||||
}
|
||||
signal(SIGALRM, f);
|
||||
return (timeout == 0);
|
||||
return (dialtimeout == 0);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)biz31.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
|
@ -46,7 +42,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;
|
||||
|
||||
|
@ -56,8 +59,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;
|
||||
|
||||
|
@ -91,7 +93,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);
|
||||
}
|
||||
|
@ -105,37 +107,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;
|
||||
|
||||
|
@ -157,17 +156,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;
|
||||
|
@ -191,8 +189,7 @@ detect(s)
|
|||
}
|
||||
|
||||
static int
|
||||
flush(s)
|
||||
char *s;
|
||||
flush(char *s)
|
||||
{
|
||||
sig_t f;
|
||||
char c;
|
||||
|
@ -215,7 +212,7 @@ flush(s)
|
|||
* call there are gory ways to simulate this.
|
||||
*/
|
||||
static int
|
||||
bizsync(fd)
|
||||
bizsync(int fd)
|
||||
{
|
||||
#ifdef FIOCAPACITY
|
||||
struct capacity b;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -51,19 +47,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 jmp_buf timeoutbuf;
|
||||
|
||||
void cour_disconnect __P((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
|
||||
|
@ -107,19 +106,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);
|
||||
|
@ -130,29 +129,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);
|
||||
|
@ -183,16 +182,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;
|
||||
|
@ -206,7 +205,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;
|
||||
|
@ -265,7 +264,7 @@ cour_connect()
|
|||
* the courier in sync.
|
||||
*/
|
||||
static int
|
||||
coursync()
|
||||
coursync(void)
|
||||
{
|
||||
int already = 0;
|
||||
int len;
|
||||
|
@ -307,10 +306,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)))
|
||||
|
@ -326,7 +322,8 @@ int n;
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
cour_verbose_read()
|
||||
static void
|
||||
cour_verbose_read(void)
|
||||
{
|
||||
int n = 0;
|
||||
char buf[BUFSIZ];
|
||||
|
@ -342,8 +339,8 @@ cour_verbose_read()
|
|||
#endif
|
||||
|
||||
/* Give the courier 50 milliseconds between characters */
|
||||
void
|
||||
cour_nap()
|
||||
static void
|
||||
cour_nap(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)df.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -48,28 +44,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 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;
|
||||
|
@ -102,7 +94,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);
|
||||
|
@ -121,25 +113,22 @@ df_dialer(num, acu, df03)
|
|||
}
|
||||
|
||||
void
|
||||
df_disconnect()
|
||||
df_disconnect(void)
|
||||
{
|
||||
write(FD, "\001", 1);
|
||||
sleep(1);
|
||||
tcflush(FD, TCIOFLUSH);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
df_abort()
|
||||
df_abort(void)
|
||||
{
|
||||
|
||||
df_disconnect();
|
||||
}
|
||||
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
timeout()
|
||||
alrm_timeout(int signo)
|
||||
{
|
||||
|
||||
longjmp(Sjbuf, 1);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)dn11.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -46,14 +42,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;
|
||||
|
@ -116,8 +111,9 @@ dn_dialer(num, acu)
|
|||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
alarmtr()
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
alarmtr(int signo)
|
||||
{
|
||||
alarm(0);
|
||||
longjmp(jmpbuf, 1);
|
||||
|
@ -128,9 +124,8 @@ alarmtr()
|
|||
* hanging up...
|
||||
*/
|
||||
void
|
||||
dn_disconnect()
|
||||
dn_disconnect(void)
|
||||
{
|
||||
|
||||
sleep(2);
|
||||
if (FD > 0)
|
||||
ioctl(FD, TIOCCDTR, 0);
|
||||
|
@ -138,9 +133,8 @@ dn_disconnect()
|
|||
}
|
||||
|
||||
void
|
||||
dn_abort()
|
||||
dn_abort(void)
|
||||
{
|
||||
|
||||
sleep(2);
|
||||
if (child > 0)
|
||||
kill(child, SIGKILL);
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)hayes.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -71,10 +67,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 sigALRM();
|
||||
static int timeout = 0;
|
||||
static int dialtimeout = 0;
|
||||
static jmp_buf timeoutbuf;
|
||||
static char gobble();
|
||||
|
||||
#define DUMBUFLEN 40
|
||||
static char dumbuf[DUMBUFLEN];
|
||||
|
||||
|
@ -84,10 +79,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;
|
||||
|
@ -130,20 +129,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
|
||||
|
@ -156,32 +154,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
|
||||
|
@ -209,8 +205,7 @@ gobble(match)
|
|||
}
|
||||
|
||||
static void
|
||||
error_rep(c)
|
||||
char c;
|
||||
error_rep(char c)
|
||||
{
|
||||
printf("\n\r");
|
||||
switch (c) {
|
||||
|
@ -222,23 +217,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);
|
||||
}
|
||||
|
@ -249,8 +244,8 @@ error_rep(c)
|
|||
/*
|
||||
* set modem back to normal verbose status codes.
|
||||
*/
|
||||
void
|
||||
goodbye()
|
||||
static void
|
||||
goodbye(void)
|
||||
{
|
||||
int len;
|
||||
char c;
|
||||
|
@ -294,8 +289,8 @@ goodbye()
|
|||
|
||||
#define MAXRETRY 5
|
||||
|
||||
int
|
||||
hay_sync()
|
||||
static int
|
||||
hay_sync(void)
|
||||
{
|
||||
int len, retry = 0;
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -52,17 +48,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 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;
|
||||
|
@ -106,19 +107,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);
|
||||
|
@ -129,29 +130,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);
|
||||
|
@ -188,24 +189,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;
|
||||
|
@ -219,7 +220,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;
|
||||
|
@ -278,7 +279,7 @@ t3000_connect()
|
|||
* the t3000 in sync.
|
||||
*/
|
||||
static int
|
||||
t3000_sync()
|
||||
t3000_sync(void)
|
||||
{
|
||||
int already = 0;
|
||||
int len;
|
||||
|
@ -322,11 +323,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)))
|
||||
|
@ -342,7 +340,8 @@ int n;
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
t3000_verbose_read()
|
||||
static void
|
||||
t3000_verbose_read(void)
|
||||
{
|
||||
int n = 0;
|
||||
char buf[BUFSIZ];
|
||||
|
@ -358,8 +357,8 @@ t3000_verbose_read()
|
|||
#endif
|
||||
|
||||
/* Give the t3000 50 milliseconds between characters */
|
||||
void
|
||||
t3000_nap()
|
||||
static void
|
||||
t3000_nap(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)v3451.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -48,13 +44,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;
|
||||
|
@ -128,32 +125,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;
|
||||
|
@ -190,17 +181,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);
|
||||
|
@ -208,8 +198,7 @@ notin(sh, lg)
|
|||
}
|
||||
|
||||
static int
|
||||
prefix(s1, s2)
|
||||
char *s1, *s2;
|
||||
prefix(char *s1, char *s2)
|
||||
{
|
||||
char c;
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)v831.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -47,20 +43,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...");
|
||||
|
@ -119,8 +114,9 @@ v831_dialer(num, acu)
|
|||
return (1);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
alarmtr()
|
||||
alarmtr(int signo)
|
||||
{
|
||||
alarm(0);
|
||||
longjmp(jmpbuf, 1);
|
||||
|
@ -131,7 +127,7 @@ alarmtr()
|
|||
* hanging up...
|
||||
*/
|
||||
void
|
||||
v831_disconnect()
|
||||
v831_disconnect(void)
|
||||
{
|
||||
struct termios cntrl;
|
||||
|
||||
|
@ -151,18 +147,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);
|
||||
|
@ -188,9 +183,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;
|
||||
|
@ -250,8 +243,7 @@ dialit(phonenum, acu)
|
|||
}
|
||||
|
||||
static char *
|
||||
sanitize(s)
|
||||
char *s;
|
||||
sanitize(char *s)
|
||||
{
|
||||
static char buf[128];
|
||||
char *cp;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)ventel.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -51,12 +47,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
|
||||
|
@ -69,9 +66,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;
|
||||
|
@ -106,21 +101,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) {
|
||||
|
@ -138,63 +133,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++) != NULL)
|
||||
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);
|
||||
|
@ -222,7 +213,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];
|
||||
|
@ -263,4 +254,3 @@ vensync(fd)
|
|||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 $
|
||||
#
|
||||
# Files are:
|
||||
# /etc/remote remote host description file
|
||||
|
@ -32,10 +32,9 @@
|
|||
|
||||
PROG= tip
|
||||
LINKS= ${BINDIR}/tip ${BINDIR}/cu
|
||||
MLINKS= tip.1 cu.1
|
||||
CFLAGS+=-I${.CURDIR} -ansi -pedantic \
|
||||
-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
|
||||
.PATH: ${.CURDIR}/aculib
|
||||
SRCS= acu.c acutab.c cmds.c cmdtab.c cu.c hunt.c log.c partab.c \
|
||||
remote.c tip.c tipout.c uucplock.c value.c vars.c \
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,15 +34,15 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)acu.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
|
||||
static acu_t *acu = NOACU;
|
||||
static int conflag;
|
||||
static void acuabort();
|
||||
static acu_t *acutype();
|
||||
static void acuabort(int);
|
||||
static acu_t *acutype(char *);
|
||||
static jmp_buf jmpbuf;
|
||||
/*
|
||||
* Establish connection for tip
|
||||
|
@ -65,7 +61,7 @@ static jmp_buf jmpbuf;
|
|||
* found in the file).
|
||||
*/
|
||||
char *
|
||||
connect()
|
||||
con(void)
|
||||
{
|
||||
char *cp = PN;
|
||||
char *phnum, string[256];
|
||||
|
@ -140,7 +136,7 @@ connect()
|
|||
conflag = (*acu->acu_dialer)(phnum, CU);
|
||||
if (conflag)
|
||||
break;
|
||||
|
||||
|
||||
logent(value(HOST), phnum, acu->acu_name, "call failed");
|
||||
tried++;
|
||||
}
|
||||
|
@ -161,8 +157,7 @@ connect()
|
|||
}
|
||||
|
||||
void
|
||||
disconnect(reason)
|
||||
char *reason;
|
||||
disconnect(char *reason)
|
||||
{
|
||||
if (!conflag) {
|
||||
logent(value(HOST), "", DV, "call terminated");
|
||||
|
@ -172,21 +167,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)
|
||||
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[];
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,66 +34,53 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)acutab.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
|
||||
extern int df02_dialer(), df03_dialer(), df_disconnect(), df_abort(),
|
||||
biz31f_dialer(), biz31_disconnect(), biz31_abort(),
|
||||
biz31w_dialer(),
|
||||
biz22f_dialer(), biz22_disconnect(), biz22_abort(),
|
||||
biz22w_dialer(),
|
||||
ven_dialer(), ven_disconnect(), ven_abort(),
|
||||
hay_dialer(), hay_disconnect(), hay_abort(),
|
||||
cour_dialer(), cour_disconnect(), cour_abort(),
|
||||
t3000_dialer(), t3000_disconnect(), t3000_abort(),
|
||||
v3451_dialer(), v3451_disconnect(), v3451_abort(),
|
||||
v831_dialer(), v831_disconnect(), v831_abort(),
|
||||
dn_dialer(), dn_disconnect(), dn_abort();
|
||||
|
||||
acu_t acutable[] = {
|
||||
#if BIZ1031
|
||||
"biz31f", biz31f_dialer, biz31_disconnect, biz31_abort,
|
||||
"biz31w", biz31w_dialer, biz31_disconnect, biz31_abort,
|
||||
{ "biz31f", biz31f_dialer, biz31_disconnect, biz31_abort },
|
||||
{ "biz31w", biz31w_dialer, biz31_disconnect, biz31_abort },
|
||||
#endif
|
||||
#if BIZ1022
|
||||
"biz22f", biz22f_dialer, biz22_disconnect, biz22_abort,
|
||||
"biz22w", biz22w_dialer, biz22_disconnect, biz22_abort,
|
||||
{ "biz22f", biz22f_dialer, biz22_disconnect, biz22_abort },
|
||||
{ "biz22w", biz22w_dialer, biz22_disconnect, biz22_abort },
|
||||
#endif
|
||||
#if DF02
|
||||
"df02", df02_dialer, df_disconnect, df_abort,
|
||||
{ "df02", df02_dialer, df_disconnect, df_abort },
|
||||
#endif
|
||||
#if DF03
|
||||
"df03", df03_dialer, df_disconnect, df_abort,
|
||||
{ "df03", df03_dialer, df_disconnect, df_abort },
|
||||
#endif
|
||||
#if DN11
|
||||
"dn11", dn_dialer, dn_disconnect, dn_abort,
|
||||
{ "dn11", dn_dialer, dn_disconnect, dn_abort },
|
||||
#endif
|
||||
#ifdef VENTEL
|
||||
"ventel",ven_dialer, ven_disconnect, ven_abort,
|
||||
{ "ventel", ven_dialer, ven_disconnect, ven_abort },
|
||||
#endif
|
||||
#ifdef HAYES
|
||||
"hayes",hay_dialer, hay_disconnect, hay_abort,
|
||||
{ "hayes", hay_dialer, hay_disconnect, hay_abort },
|
||||
#endif
|
||||
#ifdef COURIER
|
||||
"courier",cour_dialer, cour_disconnect, cour_abort,
|
||||
{ "courier", cour_dialer, cour_disconnect, cour_abort },
|
||||
#endif
|
||||
#ifdef T3000
|
||||
"t3000",t3000_dialer, t3000_disconnect, t3000_abort,
|
||||
{ "t3000", t3000_dialer, t3000_disconnect, t3000_abort },
|
||||
#endif
|
||||
#ifdef V3451
|
||||
#ifndef V831
|
||||
"vadic",v3451_dialer, v3451_disconnect, v3451_abort,
|
||||
{ "vadic", v3451_dialer, v3451_disconnect, v3451_abort },
|
||||
#endif
|
||||
"v3451",v3451_dialer, v3451_disconnect, v3451_abort,
|
||||
{ "v3451", v3451_dialer, v3451_disconnect, v3451_abort },
|
||||
#endif
|
||||
#ifdef V831
|
||||
#ifndef V3451
|
||||
"vadic",v831_dialer, v831_disconnect, v831_abort,
|
||||
{ "vadic", v831_dialer, v831_disconnect, v831_abort },
|
||||
#endif
|
||||
"v831",v831_dialer, v831_disconnect, v831_abort,
|
||||
{ "v831", v831_dialer, v831_disconnect, v831_abort },
|
||||
#endif
|
||||
0, 0, 0, 0
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
|
@ -58,20 +54,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
|
||||
|
@ -83,7 +87,7 @@ getfl(c)
|
|||
printf("\r\n%s: cannot creat\r\n", copyname);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* collect parameters
|
||||
*/
|
||||
|
@ -98,11 +102,10 @@ getfl(c)
|
|||
* 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;
|
||||
|
@ -118,7 +121,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");
|
||||
}
|
||||
|
||||
|
@ -128,34 +131,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);
|
||||
|
@ -198,12 +205,14 @@ transfer(buf, fd, eofchars)
|
|||
* FTP - remote ==> local process
|
||||
* send remote input to local process via pipe
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
pipefile()
|
||||
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;
|
||||
|
@ -244,10 +253,10 @@ pipefile()
|
|||
/*
|
||||
* Interrupt service routine for FTP
|
||||
*/
|
||||
void
|
||||
stopsnd()
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
stopsnd(int signo)
|
||||
{
|
||||
|
||||
stop = 1;
|
||||
signal(SIGINT, SIG_IGN);
|
||||
}
|
||||
|
@ -258,14 +267,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
|
||||
*/
|
||||
|
@ -276,11 +283,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);
|
||||
}
|
||||
|
@ -289,17 +296,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);
|
||||
|
@ -320,7 +325,7 @@ transmit(fd, eofchars, command)
|
|||
while (1) {
|
||||
ccount = 0;
|
||||
do {
|
||||
c = getc(fd);
|
||||
c = getc(fp);
|
||||
if (stop)
|
||||
goto out;
|
||||
if (c == EOF)
|
||||
|
@ -332,8 +337,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(' ');
|
||||
|
@ -352,7 +356,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) {
|
||||
|
@ -373,7 +377,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)))
|
||||
|
@ -388,14 +392,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)))
|
||||
|
@ -408,7 +411,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;
|
||||
}
|
||||
|
@ -417,36 +420,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) {
|
||||
|
@ -458,8 +456,9 @@ send(c)
|
|||
}
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
timeout()
|
||||
timeout(int signo)
|
||||
{
|
||||
signal(SIGALRM, timeout);
|
||||
timedout = 1;
|
||||
|
@ -470,16 +469,17 @@ timeout()
|
|||
* Identical to consh() except for where stdout goes.
|
||||
*/
|
||||
void
|
||||
pipeout(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);
|
||||
|
@ -519,19 +519,20 @@ pipeout(c)
|
|||
* Fork a program with:
|
||||
* 0 <-> remote tty in
|
||||
* 1 <-> remote tty out
|
||||
* 2 <-> local tty out
|
||||
* 2 <-> local tty stderr
|
||||
*/
|
||||
void
|
||||
consh(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);
|
||||
|
@ -547,12 +548,9 @@ consh(c)
|
|||
while ((p = wait(&status)) > 0 && p != cpid)
|
||||
;
|
||||
} else {
|
||||
int i;
|
||||
|
||||
dup2(FD, 0);
|
||||
dup2(3, 1);
|
||||
for (i = 3; i < 20; i++)
|
||||
close(i);
|
||||
closefrom(3);
|
||||
signal(SIGINT, SIG_DFL);
|
||||
signal(SIGQUIT, SIG_DFL);
|
||||
execute(buf);
|
||||
|
@ -571,11 +569,13 @@ consh(c)
|
|||
/*
|
||||
* Escape to local shell
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
shell()
|
||||
shell(int c)
|
||||
{
|
||||
int shpid, status;
|
||||
int status;
|
||||
char *cp;
|
||||
pid_t shpid;
|
||||
|
||||
printf("[sh]\r\n");
|
||||
signal(SIGINT, SIG_IGN);
|
||||
|
@ -607,13 +607,14 @@ shell()
|
|||
* 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);
|
||||
|
@ -629,8 +630,9 @@ setscript()
|
|||
* Change current working directory of
|
||||
* local portion of tip
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
chdirectory()
|
||||
chdirectory(int c)
|
||||
{
|
||||
char dirname[PATH_MAX];
|
||||
char *cp = dirname;
|
||||
|
@ -646,11 +648,11 @@ chdirectory()
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -661,8 +663,9 @@ tipabort(msg)
|
|||
exit(0);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
finish()
|
||||
finish(int c)
|
||||
{
|
||||
char *dismsg;
|
||||
|
||||
|
@ -673,17 +676,17 @@ finish()
|
|||
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;
|
||||
|
||||
|
@ -695,10 +698,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;
|
||||
|
@ -721,10 +722,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];
|
||||
|
@ -735,14 +734,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()
|
||||
variable(int c)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
|
@ -751,7 +751,7 @@ variable()
|
|||
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;
|
||||
|
@ -775,18 +775,30 @@ variable()
|
|||
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()
|
||||
listvariables(int c)
|
||||
{
|
||||
value_t *p;
|
||||
char buf[BUFSIZ];
|
||||
|
@ -809,22 +821,21 @@ listvariables()
|
|||
break;
|
||||
case BOOL:
|
||||
printf(" %s\r\n",
|
||||
boolean(p->v_value) == '!' ? "false" : "true");
|
||||
!boolean(p->v_value) ? "false" : "true");
|
||||
break;
|
||||
case CHAR:
|
||||
vis(buf, character(p->v_value), VIS_WHITE|VIS_OCTAL, 0);
|
||||
printf(" %s\r\n", buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn tandem mode on or off for remote tty.
|
||||
*/
|
||||
void
|
||||
tandem(option)
|
||||
char *option;
|
||||
static void
|
||||
tandem(char *option)
|
||||
{
|
||||
struct termios rmtty;
|
||||
|
||||
|
@ -841,12 +852,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()
|
||||
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);
|
||||
|
@ -856,10 +894,8 @@ genbrk()
|
|||
* Suspend tip
|
||||
*/
|
||||
void
|
||||
suspend(c)
|
||||
char c;
|
||||
suspend(int c)
|
||||
{
|
||||
|
||||
unraw();
|
||||
kill(c == CTRL('y') ? getpid() : 0, SIGTSTP);
|
||||
raw();
|
||||
|
@ -868,16 +904,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);
|
||||
|
@ -939,9 +974,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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,15 +34,11 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
|
||||
extern int shell(), getfl(), sendfile(), chdirectory();
|
||||
extern int finish(), help(), pipefile(), pipeout(), consh(), variable();
|
||||
extern int cu_take(), cu_put(), dollar(), genbrk(), suspend(), listvariables();
|
||||
|
||||
esctable_t etable[] = {
|
||||
{ '!', NORM, "shell", shell },
|
||||
{ '<', NORM, "receive file from remote host", getfl },
|
||||
|
|
470
usr.bin/tip/tip/cu.1
Normal file
470
usr.bin/tip/tip/cu.1
Normal file
|
@ -0,0 +1,470 @@
|
|||
.\" $OpenBSD: cu.1,v 1.3 2006/06/07 06:35:59 mbalmer Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1980, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 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. 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.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)tip.1 8.4 (Berkeley) 4/18/94
|
||||
.\"
|
||||
.Dd September 9, 2001
|
||||
.Dt CU 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm cu
|
||||
.Nd call UNIX
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl ehot
|
||||
.Op Fl a Ar acu
|
||||
.Op Fl l Ar line
|
||||
.Op Fl s Ar speed \*(Ba Fl speed
|
||||
.Op Ar phone-number
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
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.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width 4n
|
||||
.It Fl a Ar acu
|
||||
Set the acu.
|
||||
.It Fl e
|
||||
Use even parity.
|
||||
If both
|
||||
.Fl e
|
||||
and
|
||||
.Fl o
|
||||
are given, then no parity is used
|
||||
(the default).
|
||||
.It Fl h
|
||||
Echo characters locally (half-duplex mode).
|
||||
.It Fl l Ar line
|
||||
Specify the line to use.
|
||||
Either of the forms like
|
||||
.Pa tty00
|
||||
or
|
||||
.Pa /dev/tty00
|
||||
are permitted.
|
||||
.It Fl o
|
||||
Use odd parity.
|
||||
If both
|
||||
.Fl e
|
||||
and
|
||||
.Fl o
|
||||
are given, then no parity is used
|
||||
(the default).
|
||||
.It Fl s Ar speed \*(Ba Fl speed
|
||||
Set the speed of the connection.
|
||||
The default is 9600.
|
||||
.It Fl t
|
||||
Connect via a hard-wired connection to a host on a dial-up line.
|
||||
.El
|
||||
.Pp
|
||||
Typed characters are normally transmitted directly to the remote
|
||||
machine (which does the echoing as well).
|
||||
A tilde
|
||||
.Pq Ql ~
|
||||
appearing as the first character of a line is an escape signal; the
|
||||
following are recognized:
|
||||
.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 home directory).
|
||||
.It Ic ~!
|
||||
Escape to a shell (exiting the shell will return to
|
||||
.Nm ) .
|
||||
.It Ic ~\*(Gt
|
||||
Copy file from local to remote.
|
||||
.Nm
|
||||
prompts for the name of a local file to transmit.
|
||||
.It Ic ~\*(Lt
|
||||
Copy file from remote to local.
|
||||
.Nm
|
||||
prompts first for the name of the file to be sent, then for a command
|
||||
to be executed on the remote machine.
|
||||
.It Ic ~p Ar from Op Ar to
|
||||
Send a file to a remote
|
||||
.Ux
|
||||
host.
|
||||
This command causes the remote
|
||||
.Ux
|
||||
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
|
||||
.Sq to
|
||||
file isn't specified, the
|
||||
.Sq from
|
||||
file name is used.
|
||||
This command is actually a
|
||||
.Ux
|
||||
specific version of the
|
||||
.Ic ~\*(Gt
|
||||
command.
|
||||
.It Ic ~t Ar from Op Ar to
|
||||
Take a file from a remote
|
||||
.Ux
|
||||
host.
|
||||
As in the
|
||||
.Ic ~p
|
||||
command, the
|
||||
.Sq to
|
||||
file defaults to the
|
||||
.Sq from
|
||||
file name if it isn't specified.
|
||||
The remote host executes the following command string
|
||||
to send the file to
|
||||
.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
|
||||
process.
|
||||
The command string sent to the local
|
||||
.Ux
|
||||
system is processed by the shell.
|
||||
.It Ic ~$
|
||||
Pipe the output from a local
|
||||
.Ux
|
||||
process to the remote host.
|
||||
The command string sent to the local
|
||||
.Ux
|
||||
system is processed by the shell.
|
||||
.It Ic ~C
|
||||
Fork a child process on the local system to perform special protocols
|
||||
such as \s-1XMODEM\s+1.
|
||||
The child program will be run with the following arrangement of
|
||||
file descriptors:
|
||||
.Bd -literal -offset indent
|
||||
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 don't support the necessary
|
||||
.Fn ioctl
|
||||
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
|
||||
List all variables and their values (if set).
|
||||
.It Ic ~^Z
|
||||
Stop
|
||||
.Nm
|
||||
(only available with job control).
|
||||
.It Ic ~^Y
|
||||
Stop only the
|
||||
.Dq local side
|
||||
of
|
||||
.Nm
|
||||
(only available with job control); the
|
||||
.Dq remote side
|
||||
of
|
||||
.Nm ,
|
||||
the side that displays output from the remote host, is left running.
|
||||
.It Ic ~?
|
||||
Get a summary of the tilde escapes.
|
||||
.El
|
||||
.Pp
|
||||
When
|
||||
.Nm
|
||||
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 the user to the remote machine.
|
||||
.Pp
|
||||
.Nm
|
||||
guards against multiple users connecting to a remote system by opening
|
||||
modems and terminal lines with exclusive access, and by honoring the
|
||||
locking protocol used by
|
||||
.Xr uucico .
|
||||
.Pp
|
||||
During file transfers
|
||||
.Nm
|
||||
provides a running count of the number of lines transferred.
|
||||
When using the
|
||||
.Ic ~\*(Gt
|
||||
and
|
||||
.Ic ~\*(Lt
|
||||
commands, the
|
||||
.Dq eofread
|
||||
and
|
||||
.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 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
|
||||
messages indicating its actions.
|
||||
.Nm
|
||||
supports a variety of auto-call units and modems with the
|
||||
.Ar at
|
||||
capability in system descriptions.
|
||||
.Pp
|
||||
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
|
||||
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.
|
||||
If only one of the two is supported, it is referred to as vadic.
|
||||
.Ss VARIABLES
|
||||
.Nm
|
||||
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
|
||||
.Sq s
|
||||
escape.
|
||||
The syntax for variables is patterned after
|
||||
.Xr vi 1
|
||||
and
|
||||
.Xr Mail 1 .
|
||||
Supplying
|
||||
.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
|
||||
by attaching a
|
||||
.Ql \&?
|
||||
to the end.
|
||||
For example,
|
||||
.Dq escape?
|
||||
displays the current escape character.
|
||||
.Pp
|
||||
Variables are numeric, string, character, or boolean values.
|
||||
Boolean variables are set merely by specifying their name; they may be
|
||||
reset by prepending a
|
||||
.Ql !\&
|
||||
to the name.
|
||||
Other variable types are set by concatenating an
|
||||
.Ql =
|
||||
and the value.
|
||||
The entire assignment must not have any blanks in it.
|
||||
A single set command may be used to interrogate as well as set a
|
||||
number of variables.
|
||||
Certain common variables have abbreviations.
|
||||
The following is a list of common variables, their abbreviations, and
|
||||
their default values:
|
||||
.Bl -tag -width Ar
|
||||
.It Ar baudrate
|
||||
(num) The baud rate at which the connection was established;
|
||||
abbreviated
|
||||
.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
|
||||
.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
|
||||
.Ar off .
|
||||
.It Ar eofread
|
||||
(str) The set of characters which signify an end-of-transmission
|
||||
during a
|
||||
.Ic ~\*(Lt
|
||||
file transfer command; abbreviated
|
||||
.Ar eofr .
|
||||
.It Ar eofwrite
|
||||
(str) The string sent to indicate end-of-transmission during a
|
||||
.Ic ~\*(Gt
|
||||
file transfer command; abbreviated
|
||||
.Ar eofw .
|
||||
.It Ar eol
|
||||
(str) The set of characters which indicate an end-of-line.
|
||||
.Nm
|
||||
will recognize escape characters only after an end-of-line.
|
||||
.It Ar escape
|
||||
(char) The command prefix (escape) character; abbreviated
|
||||
.Ar es ;
|
||||
default value is
|
||||
.Ql ~ .
|
||||
.It Ar exceptions
|
||||
(str) The set of characters which should not be discarded due to the
|
||||
beautification switch; abbreviated
|
||||
.Ar ex ;
|
||||
default value is
|
||||
.Dq \et\en\ef\eb .
|
||||
.It Ar force
|
||||
(char) The character used to force literal data transmission;
|
||||
abbreviated
|
||||
.Ar fo ;
|
||||
default value is
|
||||
.Ql ^P .
|
||||
.It Ar framesize
|
||||
(num) The amount of data (in bytes) to buffer between filesystem
|
||||
writes when receiving files; abbreviated
|
||||
.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
|
||||
.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 Ar raise
|
||||
(bool) Upper case mapping mode; abbreviated
|
||||
.Ar ra ;
|
||||
default value is
|
||||
.Ar off .
|
||||
When this mode is enabled, all lowercase letters will be mapped to
|
||||
uppercase by
|
||||
.Nm
|
||||
for transmission to the remote machine.
|
||||
.It Ar raisechar
|
||||
(char) The input character used to toggle uppercase mapping mode;
|
||||
abbreviated
|
||||
.Ar rc ;
|
||||
default value is
|
||||
.Ql ^A .
|
||||
.It Ar record
|
||||
(str) The name of the file in which a session script is recorded;
|
||||
abbreviated
|
||||
.Ar rec .
|
||||
.It Ar script
|
||||
(bool) Session scripting mode; abbreviated
|
||||
.Ar sc ;
|
||||
default is
|
||||
.Ar off .
|
||||
When
|
||||
.Ar script
|
||||
is
|
||||
.Li true ,
|
||||
.Nm
|
||||
will record everything transmitted by the remote machine in the script
|
||||
record file specified in
|
||||
.Ar record .
|
||||
If the
|
||||
.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
|
||||
.Ar exceptions
|
||||
is used to indicate characters which are an exception to the normal
|
||||
beautification rules.
|
||||
.It Ar tabexpand
|
||||
(bool) Expand tabs to spaces during file transfers; abbreviated
|
||||
.Ar tab ;
|
||||
default value is
|
||||
.Ar false .
|
||||
Each tab is expanded to 8 spaces.
|
||||
.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 .
|
||||
.It Ar verbose
|
||||
(bool) Verbose mode; abbreviated
|
||||
.Ar verb ;
|
||||
default is
|
||||
.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 Fl
|
||||
.It Ev HOME
|
||||
The home directory to use for the
|
||||
.Ic ~c
|
||||
command.
|
||||
.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 "/var/spool/lock/LCK..*" -compact
|
||||
.It Pa /var/log/aculog
|
||||
line access log
|
||||
.It Pa /var/spool/lock/LCK..*
|
||||
lock file to avoid conflicts with
|
||||
.Xr uucp
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr tip 1
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
command appeared in
|
||||
.Bx 4.2 .
|
||||
.Sh BUGS
|
||||
The full set of variables is undocumented and should, probably, be
|
||||
pared down.
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,23 +34,20 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)cu.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* 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];
|
||||
|
@ -63,8 +56,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;
|
||||
|
@ -82,8 +76,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);
|
||||
|
@ -98,10 +91,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':
|
||||
|
@ -133,6 +132,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
|
||||
|
@ -152,24 +152,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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,26 +34,26 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* 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;
|
||||
|
@ -85,7 +81,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) {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
|
@ -50,8 +46,7 @@ static FILE *flog = NULL;
|
|||
* Log file maintenance routines
|
||||
*/
|
||||
void
|
||||
logent(group, num, acu, message)
|
||||
char *group, *num, *acu, *message;
|
||||
logent(char *group, char *num, char *acu, char *message)
|
||||
{
|
||||
char *user, *timestamp;
|
||||
struct passwd *pwd;
|
||||
|
@ -85,7 +80,7 @@ logent(group, num, acu, message)
|
|||
}
|
||||
|
||||
void
|
||||
loginit()
|
||||
loginit(void)
|
||||
{
|
||||
flog = fopen(value(LOG), "a");
|
||||
if (flog == NULL)
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)partab.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
/*
|
||||
|
|
|
@ -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 $ */
|
||||
|
||||
/*
|
||||
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -36,7 +32,7 @@
|
|||
*/
|
||||
|
||||
#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 */
|
||||
|
@ -45,7 +41,7 @@ static char copyright[] =
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)remote.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -72,13 +68,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");
|
||||
|
@ -93,8 +88,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;
|
||||
|
@ -104,18 +99,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;
|
||||
}
|
||||
|
@ -127,6 +122,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)
|
||||
|
@ -186,6 +183,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)
|
||||
|
@ -207,8 +206,7 @@ getremcap(host)
|
|||
}
|
||||
|
||||
char *
|
||||
getremote(host)
|
||||
char *host;
|
||||
getremote(char *host)
|
||||
{
|
||||
char *cp;
|
||||
static char *next;
|
||||
|
|
|
@ -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.
|
||||
.\"
|
||||
|
@ -38,67 +34,31 @@
|
|||
.Dt TIP 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm tip ,
|
||||
.Nm cu
|
||||
.Nm tip
|
||||
.Nd connect to a remote system
|
||||
.Sh SYNOPSIS
|
||||
.Nm tip
|
||||
.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 #
|
||||
.Op Ar phone\-number
|
||||
.Op Ar system-name
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
and
|
||||
.Nm cu
|
||||
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 tip .
|
||||
The
|
||||
.Nm cu
|
||||
interface is included for those people attached to the
|
||||
``call
|
||||
.Ux Ns ''
|
||||
command of
|
||||
.At v7 .
|
||||
This manual page
|
||||
describes only
|
||||
.Nm tip .
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width 4n
|
||||
.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.
|
||||
.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
|
||||
|
@ -120,7 +80,7 @@ is not,
|
|||
will be set to a value of 'tip' with
|
||||
.Ar speed
|
||||
appended.
|
||||
e.g.
|
||||
For example,
|
||||
.Ic tip -1200
|
||||
will set
|
||||
.Ar system-name
|
||||
|
@ -133,104 +93,107 @@ A tilde
|
|||
appearing as the first character of a line is an escape signal; the
|
||||
following are recognized:
|
||||
.Bl -tag -offset indent -width Fl
|
||||
.It Ic \&~^D No or Ic \&~ .
|
||||
Drop the connection and exit (you may still be logged in on the remote
|
||||
machine).
|
||||
.It Ic \&~c Op Ar name
|
||||
.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).
|
||||
.It Ic \&~!
|
||||
Escape to a shell (exiting the shell will return you to
|
||||
.Nm tip Ns ).
|
||||
.It Ic \&~>
|
||||
(no argument implies change to home directory).
|
||||
.It Ic ~!
|
||||
Escape to a shell (exiting the shell will return to
|
||||
.Nm ) .
|
||||
.It Ic ~\*(Gt
|
||||
Copy file from local to remote.
|
||||
.Nm
|
||||
prompts for the name of a local file to transmit.
|
||||
.It Ic \&~<
|
||||
.It Ic ~\*(Lt
|
||||
Copy file from remote to local.
|
||||
.Nm
|
||||
prompts first for the name of the file to be sent, then for a command
|
||||
to be executed on the remote machine.
|
||||
.It Ic \&~p Ar from Op Ar to
|
||||
.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 cat > 'to' ,
|
||||
while
|
||||
.Nm
|
||||
sends it the
|
||||
.Dq 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
|
||||
.Dq to
|
||||
file isn't specified the
|
||||
.Dq 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
|
||||
.It Ic ~t Ar from Op Ar to
|
||||
Take a file from a remote
|
||||
.Ux
|
||||
host.
|
||||
As in the put command the
|
||||
.Dq to
|
||||
As in the
|
||||
.Ic ~p
|
||||
command, the
|
||||
.Sq to
|
||||
file defaults to the
|
||||
.Dq from
|
||||
.Sq from
|
||||
file name if it isn't specified.
|
||||
The remote host executes the command string
|
||||
.Dq cat 'from';echo ^A
|
||||
The remote host executes the following command string
|
||||
to send the file to
|
||||
.Nm tip .
|
||||
.It Ic \&~|
|
||||
.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
|
||||
process.
|
||||
The command string sent to the local
|
||||
.Ux
|
||||
system is processed by the shell.
|
||||
.It Ic \&~$
|
||||
.It Ic ~$
|
||||
Pipe the output from a local
|
||||
.Ux
|
||||
process to the remote host.
|
||||
The command string sent to the local
|
||||
.Ux
|
||||
system is processed by the shell.
|
||||
.It Ic \&~C
|
||||
.It Ic ~C
|
||||
Fork a child process on the local system to perform special protocols
|
||||
such as \s-1XMODEM\s+1.
|
||||
The child program will be run with the following somewhat unusual
|
||||
arrangement of file descriptors:
|
||||
The child program will be run with the following arrangement of
|
||||
file descriptors:
|
||||
.Bd -literal -offset indent
|
||||
0 <-> local tty in
|
||||
1 <-> local tty out
|
||||
2 <-> local tty out
|
||||
3 <-> remote tty in
|
||||
4 <-> remote tty out
|
||||
0 \*(Lt-\*(Gt remote tty in
|
||||
1 \*(Lt-\*(Gt remote tty out
|
||||
2 \*(Lt-\*(Gt local tty stderr
|
||||
.Ed
|
||||
.It Ic \&~#
|
||||
.It Ic ~#
|
||||
Send a
|
||||
.Dv BREAK
|
||||
to the remote system.
|
||||
For systems which don't support the necessary
|
||||
.Fn ioctl
|
||||
call the break is simulated by a sequence of line speed changes and
|
||||
call, the break is simulated by a sequence of line speed changes and
|
||||
DEL characters.
|
||||
.It Ic \&~s
|
||||
.It Ic ~s
|
||||
Set a variable (see the discussion below).
|
||||
.It Ic \&~v
|
||||
.It Ic ~v
|
||||
List all variables and their values (if set).
|
||||
.It Ic \&~^Z
|
||||
.It Ic ~^Z
|
||||
Stop
|
||||
.Nm
|
||||
(only available with job control).
|
||||
.It Ic \&~^Y
|
||||
.It Ic ~^Y
|
||||
Stop only the
|
||||
.Dq local side
|
||||
of
|
||||
|
@ -238,13 +201,13 @@ of
|
|||
(only available with job control); the
|
||||
.Dq remote side
|
||||
of
|
||||
.Nm tip ,
|
||||
.Nm ,
|
||||
the side that displays output from the remote host, is left running.
|
||||
.It Ic \&~?
|
||||
.It Ic ~?
|
||||
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
|
||||
|
@ -256,17 +219,17 @@ The search order is
|
|||
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.
|
||||
.It
|
||||
.It
|
||||
The default
|
||||
.Xr remote 5
|
||||
database,
|
||||
|
@ -279,48 +242,48 @@ See
|
|||
for full documentation on system descriptions.
|
||||
.Pp
|
||||
The
|
||||
.Ar ba
|
||||
.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.,
|
||||
.Ql "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
|
||||
establishes a connection, it sends out the connection message
|
||||
specified in the
|
||||
.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
|
||||
.Nm
|
||||
guards against multiple users connecting to a remote system by opening
|
||||
modems and terminal lines with exclusive access, and by honoring the
|
||||
locking protocol used by
|
||||
.Xr uucico 8 .
|
||||
.Xr uucico .
|
||||
.Pp
|
||||
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
|
||||
.Dq eofread
|
||||
and
|
||||
.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,
|
||||
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
|
||||
|
@ -343,7 +306,7 @@ Racal-Vadic 831 (vadic) units is enabled by default.
|
|||
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
|
||||
.Xr tip 1
|
||||
.Nm tip
|
||||
with the appropriate defines.
|
||||
.Pp
|
||||
Note that if support for both the Racal-Vadic 831 and 3451 is enabled
|
||||
|
@ -367,7 +330,7 @@ as an argument to the set command displays all variables readable by
|
|||
the user.
|
||||
Alternatively, the user may request display of a particular variable
|
||||
by attaching a
|
||||
.Ql ?
|
||||
.Ql \&?
|
||||
to the end.
|
||||
For example,
|
||||
.Dq escape?
|
||||
|
@ -376,7 +339,7 @@ displays the current escape character.
|
|||
Variables are numeric, string, character, or boolean values.
|
||||
Boolean variables are set merely by specifying their name; they may be
|
||||
reset by prepending a
|
||||
.Ql !
|
||||
.Ql \&!
|
||||
to the name.
|
||||
Other variable types are set by concatenating an
|
||||
.Ql =
|
||||
|
@ -387,26 +350,25 @@ number of variables.
|
|||
Variables may be initialized at run time by placing set commands
|
||||
(without the
|
||||
.Ql ~s
|
||||
prefix in a file
|
||||
.Pa .tiprc
|
||||
in one's home directory).
|
||||
The
|
||||
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 Ar
|
||||
.It Ar beautify
|
||||
(bool) Discard unprintable characters when a session is being
|
||||
scripted; abbreviated
|
||||
.Ar be .
|
||||
.It Ar baudrate
|
||||
(num) The baud rate at which the connection was established;
|
||||
abbreviated
|
||||
.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
|
||||
|
@ -418,12 +380,12 @@ waiting for the echo of the last character transmitted; default is
|
|||
.It Ar eofread
|
||||
(str) The set of characters which signify an end-of-transmission
|
||||
during a
|
||||
.Ic ~<
|
||||
.Ic ~\*(Lt
|
||||
file transfer command; abbreviated
|
||||
.Ar eofr .
|
||||
.It Ar eofwrite
|
||||
(str) The string sent to indicate end-of-transmission during a
|
||||
.Ic ~>
|
||||
.Ic ~\*(Gt
|
||||
file transfer command; abbreviated
|
||||
.Ar eofw .
|
||||
.It Ar eol
|
||||
|
@ -451,9 +413,18 @@ default value is
|
|||
(num) The amount of data (in bytes) to buffer between filesystem
|
||||
writes when receiving files; abbreviated
|
||||
.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
|
||||
|
@ -513,6 +484,18 @@ beautification rules.
|
|||
default value is
|
||||
.Ar false .
|
||||
Each tab is expanded to 8 spaces.
|
||||
.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 ;
|
||||
|
@ -525,11 +508,6 @@ transferred during a file transfer operations, and more.
|
|||
.El
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width Fl
|
||||
.It Ev SHELL
|
||||
The name of the shell to use for the
|
||||
.Ic ~!
|
||||
command; default value is
|
||||
.Dq /bin/sh .
|
||||
.It Ev HOME
|
||||
The home directory to use for the
|
||||
.Ic ~c
|
||||
|
@ -538,29 +516,34 @@ 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 "/var/spool/lock/LCK..*" -compact
|
||||
.It Pa /etc/remote
|
||||
global
|
||||
.Xr remote 5
|
||||
database
|
||||
.It Pa /etc/phones
|
||||
default
|
||||
.Xr phones 5
|
||||
file
|
||||
.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..*
|
||||
|
@ -568,12 +551,13 @@ lock file to avoid conflicts with
|
|||
.Xr uucp
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr cu 1 ,
|
||||
.Xr phones 5 ,
|
||||
.Xr remote 5
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
appeared command in
|
||||
command appeared in
|
||||
.Bx 4.2 .
|
||||
.Sh BUGS
|
||||
The full set of variables is undocumented and should, probably, be
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -35,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#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 */
|
||||
|
@ -44,7 +40,7 @@ static char copyright[] =
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -56,29 +52,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;
|
||||
char sbuf[12];
|
||||
|
||||
/* XXX preserve previous braindamaged behavior */
|
||||
setboolean(value(DC), TRUE);
|
||||
|
||||
gid = getgid();
|
||||
egid = getegid();
|
||||
|
@ -101,7 +89,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':
|
||||
|
@ -124,34 +112,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);
|
||||
}
|
||||
|
@ -180,29 +169,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 ((p = connect())) {
|
||||
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
|
||||
|
@ -212,15 +204,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);
|
||||
|
@ -229,13 +222,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)
|
||||
|
@ -244,7 +242,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();
|
||||
|
@ -253,13 +252,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);
|
||||
}
|
||||
|
||||
|
@ -274,7 +277,7 @@ cleanup()
|
|||
static int uidswapped;
|
||||
|
||||
void
|
||||
user_uid()
|
||||
user_uid(void)
|
||||
{
|
||||
if (uidswapped == 0) {
|
||||
seteuid(uid);
|
||||
|
@ -283,7 +286,7 @@ user_uid()
|
|||
}
|
||||
|
||||
void
|
||||
daemon_uid()
|
||||
daemon_uid(void)
|
||||
{
|
||||
|
||||
if (uidswapped) {
|
||||
|
@ -293,7 +296,7 @@ daemon_uid()
|
|||
}
|
||||
|
||||
void
|
||||
shell_uid()
|
||||
shell_uid(void)
|
||||
{
|
||||
setegid(gid);
|
||||
seteuid(uid);
|
||||
|
@ -303,7 +306,7 @@ shell_uid()
|
|||
* put the controlling keyboard into raw mode
|
||||
*/
|
||||
void
|
||||
raw()
|
||||
raw(void)
|
||||
{
|
||||
tcsetattr(0, TCSADRAIN, &term);
|
||||
}
|
||||
|
@ -313,9 +316,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;
|
||||
|
@ -326,10 +330,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;
|
||||
|
@ -354,10 +355,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");
|
||||
|
@ -367,10 +368,12 @@ intprompt()
|
|||
/*
|
||||
* ****TIPIN TIPIN****
|
||||
*/
|
||||
void
|
||||
tipin()
|
||||
static void
|
||||
tipin(void)
|
||||
{
|
||||
char gch, bol = 1;
|
||||
int bol = 1;
|
||||
int gch;
|
||||
char ch;
|
||||
|
||||
/*
|
||||
* Kinda klugey here...
|
||||
|
@ -386,6 +389,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()))
|
||||
|
@ -396,7 +400,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;
|
||||
|
@ -405,9 +410,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,14 +423,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)
|
||||
|
@ -440,21 +447,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)
|
||||
|
@ -463,11 +456,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++;
|
||||
|
@ -475,8 +467,7 @@ size(s)
|
|||
}
|
||||
|
||||
char *
|
||||
interp(s)
|
||||
char *s;
|
||||
interp(char *s)
|
||||
{
|
||||
static char buf[256];
|
||||
char *p = buf, c, *q;
|
||||
|
@ -501,8 +492,7 @@ interp(s)
|
|||
}
|
||||
|
||||
char *
|
||||
ctrl(c)
|
||||
char c;
|
||||
ctrl(char c)
|
||||
{
|
||||
static char s[3];
|
||||
|
||||
|
@ -521,8 +511,7 @@ ctrl(c)
|
|||
* Help command
|
||||
*/
|
||||
void
|
||||
help(c)
|
||||
char c;
|
||||
help(int c)
|
||||
{
|
||||
esctable_t *p;
|
||||
|
||||
|
@ -539,19 +528,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);
|
||||
|
@ -559,7 +549,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];
|
||||
|
@ -570,10 +560,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;
|
||||
|
@ -596,8 +583,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;
|
||||
|
@ -625,5 +611,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;
|
||||
}
|
||||
|
|
|
@ -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 $ */
|
||||
|
||||
/*
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -91,8 +87,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,9 +130,9 @@ typedef
|
|||
typedef
|
||||
struct {
|
||||
char *acu_name;
|
||||
int (*acu_dialer)();
|
||||
int (*acu_disconnect)();
|
||||
int (*acu_abort)();
|
||||
int (*acu_dialer)(char *, char *);
|
||||
void (*acu_disconnect)(void);
|
||||
void (*acu_abort)(void);
|
||||
}
|
||||
acu_t;
|
||||
|
||||
|
@ -150,6 +146,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))
|
||||
|
@ -169,16 +166,16 @@ typedef
|
|||
|
||||
typedef
|
||||
struct {
|
||||
char e_char; /* char to match on */
|
||||
char e_flags; /* experimental, priviledged */
|
||||
char *e_help; /* help string */
|
||||
int (*e_func)(); /* command */
|
||||
char e_char; /* char to match on */
|
||||
char e_flags; /* experimental, 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 */
|
||||
|
@ -227,6 +224,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)
|
||||
|
@ -237,6 +237,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 */
|
||||
|
||||
|
@ -247,7 +248,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 */
|
||||
|
@ -262,7 +264,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 */
|
||||
|
@ -270,43 +271,82 @@ extern int disc; /* current tty discpline */
|
|||
|
||||
extern char *__progname; /* program name */
|
||||
|
||||
extern char *ctrl();
|
||||
extern char *vinterp();
|
||||
extern char *connect();
|
||||
|
||||
char *sname __P((char *s));
|
||||
int any __P((int cc, char *p));
|
||||
int anyof __P((char *s1, char *s2));
|
||||
int args __P((char *buf, char *a[], int num));
|
||||
int escape __P((void));
|
||||
int prompt __P((char *s, char *p, size_t sz));
|
||||
int size __P((char *s));
|
||||
int speed __P((int n));
|
||||
int uu_lock __P((char *ttyname));
|
||||
int uu_unlock __P((char *ttyname));
|
||||
int vstring __P((char *s, char *v));
|
||||
long hunt __P((char *name));
|
||||
void cumain __P((int argc, char *argv[]));
|
||||
void daemon_uid __P((void));
|
||||
void disconnect __P((char *reason));
|
||||
void execute __P((char *s));
|
||||
void logent __P((char *group, char *num, char *acu, char *message));
|
||||
void loginit __P((void));
|
||||
void prtime __P((char *s, time_t a));
|
||||
void parwrite __P((int fd, char *buf, int n));
|
||||
void raw __P((void));
|
||||
void send __P((int c));
|
||||
void setparity __P((char *defparity));
|
||||
void setscript __P((void));
|
||||
void shell_uid __P((void));
|
||||
void tandem __P((char *option));
|
||||
void tipabort __P((char *msg));
|
||||
void tipin __P((void));
|
||||
void tipout __P((void));
|
||||
void transfer __P((char *buf, int fd, char *eofchars));
|
||||
void transmit __P((FILE *fd, char *eofchars, char *command));
|
||||
void ttysetup __P((int speed));
|
||||
void unraw __P((void));
|
||||
void user_uid __P((void));
|
||||
void vinit __P((void));
|
||||
void vlex __P((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 *);
|
||||
int cour_dialer(char *, char *);
|
||||
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);
|
||||
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 variable(int);
|
||||
void ven_disconnect(void);
|
||||
void ven_abort(void);
|
||||
void vinit(void);
|
||||
void vlex(char *);
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,10 +34,11 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)tipout.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
|
||||
/*
|
||||
* tip
|
||||
*
|
||||
|
@ -51,14 +48,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);
|
||||
|
@ -68,8 +70,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;
|
||||
|
@ -98,19 +101,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);
|
||||
}
|
||||
|
@ -119,11 +123,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);
|
||||
|
@ -137,18 +142,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);
|
||||
|
@ -157,7 +163,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);
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)uucplock.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -52,20 +48,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);
|
||||
|
@ -81,7 +76,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");
|
||||
|
@ -98,8 +93,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);
|
||||
|
@ -109,7 +104,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);
|
||||
|
@ -122,8 +117,7 @@ uu_lock(ttyname)
|
|||
}
|
||||
|
||||
int
|
||||
uu_unlock(ttyname)
|
||||
char *ttyname;
|
||||
uu_unlock(char *ttyname)
|
||||
{
|
||||
char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,26 +34,31 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)value.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
|
||||
#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)
|
||||
|
@ -72,20 +73,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);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@ -94,21 +95,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;
|
||||
|
@ -120,19 +116,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;
|
||||
|
@ -141,22 +134,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++;
|
||||
|
@ -171,19 +159,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);
|
||||
|
@ -211,11 +197,9 @@ vtoken(s)
|
|||
}
|
||||
|
||||
static void
|
||||
vprint(p)
|
||||
value_t *p;
|
||||
vprint(value_t *p)
|
||||
{
|
||||
char *cp;
|
||||
extern char *interp(), *ctrl();
|
||||
|
||||
if (col > 0 && col < MIDDLE)
|
||||
while (col++ < MIDDLE)
|
||||
|
@ -235,7 +219,7 @@ vprint(p)
|
|||
printf("%s=", p->v_name);
|
||||
col++;
|
||||
if (p->v_value) {
|
||||
cp = interp(p->v_value, NULL);
|
||||
cp = interp(p->v_value);
|
||||
col += size(cp);
|
||||
printf("%s", cp);
|
||||
}
|
||||
|
@ -263,10 +247,8 @@ vprint(p)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
vaccess(mode, rw)
|
||||
unsigned mode, rw;
|
||||
vaccess(unsigned int mode, unsigned int rw)
|
||||
{
|
||||
if (mode & (rw<<PUBLIC))
|
||||
return (1);
|
||||
|
@ -276,8 +258,7 @@ vaccess(mode, rw)
|
|||
}
|
||||
|
||||
static value_t *
|
||||
vlookup(s)
|
||||
char *s;
|
||||
vlookup(char *s)
|
||||
{
|
||||
value_t *p;
|
||||
|
||||
|
@ -287,15 +268,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 '^':
|
||||
|
@ -336,6 +315,7 @@ vinterp(s, stop)
|
|||
default:
|
||||
*p++ = c;
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
return (c == stop ? s-1 : NULL);
|
||||
}
|
||||
|
@ -344,18 +324,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);
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -38,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
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 /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
|
@ -79,7 +75,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,
|
||||
|
@ -114,5 +110,11 @@ 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, NULL, NULL, NOSTR, NOSTR }
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue