Add prototypes, usage(). Use err(3).
This commit is contained in:
parent
15f3549108
commit
804d2dab87
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28365
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)acucommon.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -42,6 +46,8 @@ static char sccsid[] = "@(#)acucommon.c 8.1 (Berkeley) 6/6/93";
|
||||
#include "tipconf.h"
|
||||
#include "tip.h"
|
||||
|
||||
#include <err.h>
|
||||
|
||||
#if HAVE_SELECT
|
||||
#include <sys/types.h>
|
||||
#include <sys/times.h>
|
||||
@ -161,12 +167,12 @@ int acu_setspeed (int speed)
|
||||
#else /* HAVE TERMIOS */
|
||||
struct sgttyb sb;
|
||||
if (ioctl(FD, TIOCGETP, &sb) < 0) {
|
||||
perror("TIOCGETP");
|
||||
warn("TIOCGETP");
|
||||
}
|
||||
else {
|
||||
sb.sg_ispeed = sb.sg_ospeed = speed;
|
||||
if (ioctl(FD, TIOCSETP, &sb) < 0) {
|
||||
perror("TIOCSETP");
|
||||
warn("TIOCSETP");
|
||||
}
|
||||
else
|
||||
++rc;
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)unidialer.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -46,6 +50,7 @@ static char sccsid[] = "@(#)unidialer.c 8.1 (Berkeley) 6/6/93";
|
||||
|
||||
#include <sys/times.h>
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -184,13 +189,13 @@ static int getmodemparms (const char *modem)
|
||||
if ((stat = cgetent (&bp, db_array, (char *)modem)) < 0) {
|
||||
switch (stat) {
|
||||
case -1:
|
||||
fprintf (stderr, "tip: unknown modem %s\n", modem);
|
||||
warnx ("unknown modem %s", modem);
|
||||
break;
|
||||
case -2:
|
||||
fprintf (stderr, "tip: can't open modem description file\n");
|
||||
warnx ("can't open modem description file");
|
||||
break;
|
||||
case -3:
|
||||
fprintf (stderr, "tip: possible reference loop in modem description file\n");
|
||||
warnx ("possible reference loop in modem description file");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)ventel.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -41,6 +45,7 @@ static char sccsid[] = "@(#)ventel.c 8.1 (Berkeley) 6/6/93";
|
||||
*/
|
||||
#include "tipconf.h"
|
||||
#include "tip.h"
|
||||
#include <err.h>
|
||||
|
||||
#define MAXRETRY 5
|
||||
|
||||
@ -235,7 +240,7 @@ vensync(fd)
|
||||
write(fd, "\r", 1);
|
||||
sleep(2);
|
||||
if (ioctl(fd, FIONREAD, (caddr_t)&nread) < 0) {
|
||||
perror("tip: ioctl");
|
||||
warn("ioctl");
|
||||
continue;
|
||||
}
|
||||
while (nread > 0) {
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)acu.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "tipconf.h"
|
||||
@ -106,7 +110,7 @@ connect()
|
||||
if (*cp)
|
||||
*cp++ = '\0';
|
||||
|
||||
if (conflag = (*acu->acu_dialer)(phnum, CU)) {
|
||||
if ((conflag = (*acu->acu_dialer)(phnum, CU))) {
|
||||
if (CM != NOSTR)
|
||||
pwrite(FD, CM, size(CM));
|
||||
logent(value(HOST), phnum, acu->acu_name,
|
||||
@ -143,7 +147,7 @@ connect()
|
||||
if (*cp)
|
||||
*cp++ = '\0';
|
||||
|
||||
if (conflag = (*acu->acu_dialer)(phnum, CU)) {
|
||||
if ((conflag = (*acu->acu_dialer)(phnum, CU))) {
|
||||
fclose(fd);
|
||||
if (CM != NOSTR)
|
||||
pwrite(FD, CM, size(CM));
|
||||
@ -164,6 +168,7 @@ connect()
|
||||
return (tried ? "call failed" : "missing phone number");
|
||||
}
|
||||
|
||||
void
|
||||
disconnect(reason)
|
||||
char *reason;
|
||||
{
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)acutab.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "tipconf.h"
|
||||
|
@ -32,13 +32,20 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "tipconf.h"
|
||||
#include "tip.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
@ -56,6 +63,27 @@ static char *argv[10]; /* argument vector for take and put */
|
||||
void timeout(); /* timeout function called on alarm */
|
||||
void stopsnd(); /* SIGINT handler during file transfers */
|
||||
void intcopy(); /* interrupt routine for file transfers */
|
||||
int anyof __P((char *, char *));
|
||||
void suspend __P((char));
|
||||
void genbrk __P((void));
|
||||
void tandem __P((char *));
|
||||
void variable __P((void));
|
||||
void prtime __P((char *, time_t));
|
||||
int args __P((char *, char **));
|
||||
void execute __P((char *));
|
||||
void finish __P((void));
|
||||
void tipabort __P((char *));
|
||||
void chdirectory __P((void));
|
||||
void shell __P((void));
|
||||
void send __P((char));
|
||||
void cu_put __P((char));
|
||||
void transmit __P((FILE *, char *, char *));
|
||||
void sendfile __P((char));
|
||||
void pipefile __P((void));
|
||||
void transfer __P((char *, int, char *));
|
||||
void xfer __P((char *, int, char *));
|
||||
void cu_take __P((char));
|
||||
void getfl __P((char));
|
||||
|
||||
void
|
||||
usedefchars ()
|
||||
@ -99,6 +127,7 @@ flush_remote ()
|
||||
* FTP - remote ==> local
|
||||
* get a file from the remote host
|
||||
*/
|
||||
void
|
||||
getfl(c)
|
||||
char c;
|
||||
{
|
||||
@ -129,6 +158,7 @@ getfl(c)
|
||||
/*
|
||||
* Cu-like take command
|
||||
*/
|
||||
void
|
||||
cu_take(cc)
|
||||
char cc;
|
||||
{
|
||||
@ -154,6 +184,7 @@ cu_take(cc)
|
||||
|
||||
extern jmp_buf intbuf;
|
||||
|
||||
void
|
||||
xfer(buf, fd, eofchars)
|
||||
char *buf, *eofchars;
|
||||
{
|
||||
@ -168,12 +199,12 @@ xfer(buf, fd, eofchars)
|
||||
v = boolean(value(VERBOSE));
|
||||
|
||||
if ((ff = fdopen (fd, "w")) == NULL) {
|
||||
perror("file open");
|
||||
warn("file open");
|
||||
return;
|
||||
}
|
||||
if ((cnt = number(value(FRAMESIZE))) != BUFSIZ)
|
||||
if (setvbuf(ff, NULL, _IOFBF, cnt) != 0) {
|
||||
perror("file allocation");
|
||||
warn("file allocation");
|
||||
(void)fclose(ff);
|
||||
return;
|
||||
}
|
||||
@ -240,12 +271,12 @@ static jmp_buf intbuf;
|
||||
* Bulk transfer routine --
|
||||
* used by getfl(), cu_take(), and pipefile()
|
||||
*/
|
||||
void
|
||||
transfer(buf, fd, eofchars)
|
||||
char *buf, *eofchars;
|
||||
{
|
||||
register int ct;
|
||||
char c, buffer[BUFSIZ];
|
||||
register char *p = buffer;
|
||||
char c;
|
||||
register int cnt, eof, v;
|
||||
time_t start;
|
||||
sig_t f;
|
||||
@ -255,12 +286,12 @@ transfer(buf, fd, eofchars)
|
||||
v = boolean(value(VERBOSE));
|
||||
|
||||
if ((ff = fdopen (fd, "w")) == NULL) {
|
||||
perror("file open");
|
||||
warn("file open");
|
||||
return;
|
||||
}
|
||||
if ((cnt = number(value(FRAMESIZE))) != BUFSIZ)
|
||||
if (setvbuf(ff, NULL, _IOFBF, cnt) != 0) {
|
||||
perror("file allocation");
|
||||
warn("file allocation");
|
||||
(void)fclose(ff);
|
||||
return;
|
||||
}
|
||||
@ -309,6 +340,7 @@ transfer(buf, fd, eofchars)
|
||||
* FTP - remote ==> local process
|
||||
* send remote input to local process via pipe
|
||||
*/
|
||||
void
|
||||
pipefile()
|
||||
{
|
||||
int cpid, pdes[2];
|
||||
@ -368,6 +400,7 @@ stopsnd()
|
||||
* send local file to remote host
|
||||
* terminate transmission with pseudo EOF sequence
|
||||
*/
|
||||
void
|
||||
sendfile(cc)
|
||||
char cc;
|
||||
{
|
||||
@ -400,6 +433,7 @@ sendfile(cc)
|
||||
* Bulk transfer routine to remote host --
|
||||
* used by sendfile() and cu_put()
|
||||
*/
|
||||
void
|
||||
transmit(fd, eofchars, command)
|
||||
FILE *fd;
|
||||
char *eofchars, *command;
|
||||
@ -495,6 +529,7 @@ transmit(fd, eofchars, command)
|
||||
/*
|
||||
* Cu-like put command
|
||||
*/
|
||||
void
|
||||
cu_put(cc)
|
||||
char cc;
|
||||
{
|
||||
@ -528,6 +563,7 @@ cu_put(cc)
|
||||
* FTP - send single character
|
||||
* wait for echo & handle timeout
|
||||
*/
|
||||
void
|
||||
send(c)
|
||||
char c;
|
||||
{
|
||||
@ -572,6 +608,7 @@ timeout()
|
||||
* Stolen from consh() -- puts a remote file on the output of a local command.
|
||||
* Identical to consh() except for where stdout goes.
|
||||
*/
|
||||
void
|
||||
pipeout(c)
|
||||
{
|
||||
char buf[256];
|
||||
@ -675,6 +712,7 @@ tiplink (char *cmd, unsigned int flags)
|
||||
* 1 <-> remote tty out
|
||||
* 2 <-> local tty out
|
||||
*/
|
||||
void
|
||||
consh(c)
|
||||
{
|
||||
char buf[256];
|
||||
@ -688,17 +726,17 @@ consh(c)
|
||||
/*
|
||||
* Escape to local shell
|
||||
*/
|
||||
void
|
||||
shell()
|
||||
{
|
||||
int shpid, status;
|
||||
extern char **environ;
|
||||
char *cp;
|
||||
|
||||
printf("[sh]\r\n");
|
||||
signal(SIGINT, SIG_IGN);
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
unraw();
|
||||
if (shpid = fork()) {
|
||||
if ((shpid = fork())) {
|
||||
while (shpid != wait(&status));
|
||||
raw();
|
||||
printf("\r\n!\r\n");
|
||||
@ -723,6 +761,7 @@ shell()
|
||||
* TIPIN portion of scripting
|
||||
* initiate the conversation with TIPOUT
|
||||
*/
|
||||
void
|
||||
setscript()
|
||||
{
|
||||
char c;
|
||||
@ -745,6 +784,7 @@ setscript()
|
||||
* Change current working directory of
|
||||
* local portion of tip
|
||||
*/
|
||||
void
|
||||
chdirectory()
|
||||
{
|
||||
char dirname[80];
|
||||
@ -760,6 +800,7 @@ chdirectory()
|
||||
printf("!\r\n");
|
||||
}
|
||||
|
||||
void
|
||||
tipabort(msg)
|
||||
char *msg;
|
||||
{
|
||||
@ -775,6 +816,7 @@ tipabort(msg)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
finish()
|
||||
{
|
||||
char *abortmsg = NOSTR, *dismsg;
|
||||
@ -798,6 +840,7 @@ intcopy()
|
||||
longjmp(intbuf, 1);
|
||||
}
|
||||
|
||||
void
|
||||
execute(s)
|
||||
char *s;
|
||||
{
|
||||
@ -811,6 +854,7 @@ execute(s)
|
||||
execl(value(SHELL), cp, "-c", s, 0);
|
||||
}
|
||||
|
||||
int
|
||||
args(buf, a)
|
||||
char *buf, *a[];
|
||||
{
|
||||
@ -835,6 +879,7 @@ args(buf, a)
|
||||
return(n);
|
||||
}
|
||||
|
||||
void
|
||||
prtime(s, a)
|
||||
char *s;
|
||||
time_t a;
|
||||
@ -848,12 +893,13 @@ 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");
|
||||
}
|
||||
|
||||
void
|
||||
variable()
|
||||
{
|
||||
char buf[256];
|
||||
@ -893,13 +939,14 @@ variable()
|
||||
}
|
||||
if (vtable[PARITY].v_access&CHANGED) {
|
||||
vtable[PARITY].v_access &= ~CHANGED;
|
||||
setparity();
|
||||
setparity(value(PARITY));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn tandem mode on or off for remote tty.
|
||||
*/
|
||||
void
|
||||
tandem(option)
|
||||
char *option;
|
||||
{
|
||||
@ -935,6 +982,7 @@ tandem(option)
|
||||
/*
|
||||
* Send a break.
|
||||
*/
|
||||
void
|
||||
genbrk()
|
||||
{
|
||||
|
||||
@ -946,6 +994,7 @@ genbrk()
|
||||
/*
|
||||
* Suspend tip
|
||||
*/
|
||||
void
|
||||
suspend(c)
|
||||
char c;
|
||||
{
|
||||
@ -965,15 +1014,15 @@ expand(name)
|
||||
{
|
||||
static char xname[BUFSIZ];
|
||||
char cmdbuf[BUFSIZ];
|
||||
register int pid, l, rc;
|
||||
register int pid, l;
|
||||
register char *cp, *Shell;
|
||||
int s, pivec[2], (*sigint)();
|
||||
int s, pivec[2] /*, (*sigint)()*/;
|
||||
|
||||
if (!anyof(name, "~{[*?$`'\"\\"))
|
||||
return(name);
|
||||
/* sigint = signal(SIGINT, SIG_IGN); */
|
||||
if (pipe(pivec) < 0) {
|
||||
perror("pipe");
|
||||
warn("pipe");
|
||||
/* signal(SIGINT, sigint) */
|
||||
return(name);
|
||||
}
|
||||
@ -992,7 +1041,7 @@ expand(name)
|
||||
_exit(1);
|
||||
}
|
||||
if (pid == -1) {
|
||||
perror("fork");
|
||||
warn("fork");
|
||||
close(pivec[0]);
|
||||
close(pivec[1]);
|
||||
return(NOSTR);
|
||||
@ -1008,7 +1057,7 @@ expand(name)
|
||||
return(NOSTR);
|
||||
}
|
||||
if (l < 0) {
|
||||
perror("read");
|
||||
warn("read");
|
||||
return(NOSTR);
|
||||
}
|
||||
if (l == 0) {
|
||||
@ -1030,12 +1079,13 @@ expand(name)
|
||||
* Are any of the characters in the two strings the same?
|
||||
*/
|
||||
|
||||
int
|
||||
anyof(s1, s2)
|
||||
register char *s1, *s2;
|
||||
{
|
||||
register int c;
|
||||
|
||||
while (c = *s1++)
|
||||
while ((c = *s1++))
|
||||
if (any(c, s2))
|
||||
return(1);
|
||||
return(0);
|
||||
|
@ -32,14 +32,18 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "tipconf.h"
|
||||
#include "tip.h"
|
||||
|
||||
extern int shell(), getfl(), sendfile(), chdirectory();
|
||||
extern int finish(), help(), pipefile(), pipeout(), consh(), variable();
|
||||
extern int finish(), help(), pipefile(), pipeout(), variable();
|
||||
extern int cu_take(), cu_put(), dollar(), genbrk(), suspend();
|
||||
|
||||
esctable_t etable[] = {
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cu.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "tipconf.h"
|
||||
|
@ -32,10 +32,15 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <err.h>
|
||||
#include <libutil.h>
|
||||
#include "tipconf.h"
|
||||
#include "tip.h"
|
||||
@ -53,6 +58,7 @@ dead()
|
||||
longjmp(deadline, 1);
|
||||
}
|
||||
|
||||
int
|
||||
hunt(name)
|
||||
char *name;
|
||||
{
|
||||
@ -61,7 +67,7 @@ hunt(name)
|
||||
int res;
|
||||
|
||||
f = signal(SIGALRM, dead);
|
||||
while (cp = getremote(name)) {
|
||||
while ((cp = getremote(name))) {
|
||||
deadfl = 0;
|
||||
uucplock = rindex(cp, '/')+1;
|
||||
if ((res = uu_lock(uucplock)) != UU_LOCK_OK) {
|
||||
@ -84,7 +90,7 @@ hunt(name)
|
||||
}
|
||||
alarm(0);
|
||||
if (FD < 0) {
|
||||
perror(cp);
|
||||
warn("%s", cp);
|
||||
deadfl = 1;
|
||||
}
|
||||
if (!deadfl) {
|
||||
|
@ -32,11 +32,16 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "tipconf.h"
|
||||
#include "tip.h"
|
||||
#include <err.h>
|
||||
|
||||
#if ACULOG
|
||||
static FILE *flog = NULL;
|
||||
@ -45,6 +50,7 @@ static FILE *flog = NULL;
|
||||
* Log file maintenance routines
|
||||
*/
|
||||
|
||||
void
|
||||
logent(group, num, acu, message)
|
||||
char *group, *num, *acu, *message;
|
||||
{
|
||||
@ -55,7 +61,7 @@ logent(group, num, acu, message)
|
||||
if (flog == NULL)
|
||||
return;
|
||||
if (flock(fileno(flog), LOCK_EX) < 0) {
|
||||
perror("tip: flock");
|
||||
warn("flock");
|
||||
return;
|
||||
}
|
||||
if ((user = getlogin()) == NOSTR)
|
||||
@ -78,6 +84,7 @@ logent(group, num, acu, message)
|
||||
(void) flock(fileno(flog), LOCK_UN);
|
||||
}
|
||||
|
||||
void
|
||||
loginit()
|
||||
{
|
||||
flog = fopen(value(LOG), "a");
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)partab.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -33,16 +33,21 @@
|
||||
*/
|
||||
|
||||
#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 */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)remote.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/syslimits.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -68,6 +73,8 @@ static char *db_array[3] = { _PATH_REMOTE, 0, 0 };
|
||||
|
||||
#define cgetflag(f) (cgetcap(bp, f, ':') != NULL)
|
||||
|
||||
static void getremcap __P((char *));
|
||||
|
||||
/*
|
||||
Expand the start tilde sequence at the start of the
|
||||
specified path. Optionally, free space allocated to
|
||||
@ -99,9 +106,10 @@ expand_tilde (char **path, void (*free) (char *p))
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static
|
||||
static void
|
||||
getremcap(host)
|
||||
register char *host;
|
||||
{
|
||||
@ -122,7 +130,7 @@ getremcap(host)
|
||||
|
||||
if ((stat = cgetent(&bp, db_array, host)) < 0) {
|
||||
if (DV ||
|
||||
host[0] == '/' && access(DV = host, R_OK | W_OK) == 0) {
|
||||
(host[0] == '/' && access(DV = host, R_OK | W_OK) == 0)) {
|
||||
CU = DV;
|
||||
HO = host;
|
||||
HW = 1;
|
||||
@ -134,15 +142,13 @@ getremcap(host)
|
||||
}
|
||||
switch(stat) {
|
||||
case -1:
|
||||
fprintf(stderr, "tip: unknown host %s\n", host);
|
||||
warnx("unknown host %s", host);
|
||||
break;
|
||||
case -2:
|
||||
fprintf(stderr,
|
||||
"tip: can't open host description file\n");
|
||||
warnx("can't open host description file");
|
||||
break;
|
||||
case -3:
|
||||
fprintf(stderr,
|
||||
"tip: possible reference loop in host description file\n");
|
||||
warnx("possible reference loop in host description file");
|
||||
break;
|
||||
}
|
||||
exit(3);
|
||||
@ -260,10 +266,8 @@ getremote(host)
|
||||
static int lookedup = 0;
|
||||
|
||||
if (!lookedup) {
|
||||
if (host == NOSTR && (host = getenv("HOST")) == NOSTR) {
|
||||
fprintf(stderr, "tip: no host specified\n");
|
||||
exit(3);
|
||||
}
|
||||
if (host == NOSTR && (host = getenv("HOST")) == NOSTR)
|
||||
errx(3, "no host specified");
|
||||
getremcap(host);
|
||||
next = DV;
|
||||
lookedup++;
|
||||
|
@ -32,13 +32,17 @@
|
||||
*/
|
||||
|
||||
#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 */
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -53,6 +57,7 @@ void ttysetup (int speed);
|
||||
* cu phone-number [-s speed] [-l line] [-a acu]
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include "tipconf.h"
|
||||
#include "tip.h"
|
||||
#include "pathnames.h"
|
||||
@ -78,6 +83,18 @@ void tipdone();
|
||||
char *sname();
|
||||
char PNbuf[256]; /* This limits the size of a number */
|
||||
|
||||
static void usage __P((void));
|
||||
void setparity __P((char *));
|
||||
void pwrite __P((int, char *, int));
|
||||
char escape __P((void));
|
||||
void tipin __P((void));
|
||||
int prompt __P((char *, char *));
|
||||
void unraw __P((void));
|
||||
void shell_uid __P((void));
|
||||
void daemon_uid __P((void));
|
||||
void user_uid __P((void));
|
||||
int speed __P((int));
|
||||
|
||||
void
|
||||
main(argc, argv)
|
||||
char *argv[];
|
||||
@ -100,14 +117,10 @@ main(argc, argv)
|
||||
}
|
||||
#endif /* INCLUDE_CU_INTERFACE */
|
||||
|
||||
if (argc > 4) {
|
||||
fprintf(stderr, "usage: tip [-v] [-speed] [system-name]\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!isatty(0)) {
|
||||
fprintf(stderr, "tip: must be interactive\n");
|
||||
exit(1);
|
||||
}
|
||||
if (argc > 4)
|
||||
usage();
|
||||
if (!isatty(0))
|
||||
errx(1, "must be interactive");
|
||||
|
||||
for (; argc > 1; argv++, argc--) {
|
||||
if (argv[1][0] != '-')
|
||||
@ -124,7 +137,7 @@ main(argc, argv)
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "tip: %s, unknown option\n", argv[1]);
|
||||
warnx("%s, unknown option", argv[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -138,11 +151,8 @@ main(argc, argv)
|
||||
* 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) {
|
||||
fprintf(stderr, "tip: phone number too long (max = %d bytes)\n",
|
||||
sizeof PNbuf - 1);
|
||||
exit(1);
|
||||
}
|
||||
if (strlen(system) > sizeof PNbuf - 1)
|
||||
errx(1, "phone number too long (max = %d bytes)", sizeof PNbuf - 1);
|
||||
strncpy( PNbuf, system, sizeof PNbuf - 1 );
|
||||
for (p = system; *p; p++)
|
||||
*p = '\0';
|
||||
@ -199,7 +209,7 @@ main(argc, argv)
|
||||
*/
|
||||
if (HW)
|
||||
ttysetup(i);
|
||||
if (p = connect()) {
|
||||
if ((p = connect())) {
|
||||
printf("\07%s\n[EOT]\n", p);
|
||||
daemon_uid();
|
||||
(void)uu_unlock(uucplock);
|
||||
@ -207,7 +217,7 @@ main(argc, argv)
|
||||
}
|
||||
if (!HW)
|
||||
ttysetup(i);
|
||||
cucommon:
|
||||
/* cucommon:*/
|
||||
/*
|
||||
* From here down the code is shared with
|
||||
* the "cu" version of tip.
|
||||
@ -258,13 +268,20 @@ main(argc, argv)
|
||||
tipabort ("login failed");
|
||||
}
|
||||
|
||||
if (pid = fork())
|
||||
if ((pid = fork()))
|
||||
tipin();
|
||||
else
|
||||
tipout();
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "usage: tip [-v] [-speed] [system-name]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
@ -293,6 +310,7 @@ tipdone()
|
||||
*/
|
||||
static int uidswapped;
|
||||
|
||||
void
|
||||
user_uid()
|
||||
{
|
||||
if (uidswapped == 0) {
|
||||
@ -301,18 +319,18 @@ user_uid()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
daemon_uid()
|
||||
{
|
||||
|
||||
if (uidswapped) {
|
||||
seteuid(euid);
|
||||
uidswapped = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
shell_uid()
|
||||
{
|
||||
|
||||
seteuid(uid);
|
||||
}
|
||||
|
||||
@ -337,6 +355,7 @@ raw ()
|
||||
/*
|
||||
* return keyboard to normal mode
|
||||
*/
|
||||
void
|
||||
unraw()
|
||||
{
|
||||
#if HAVE_TERMIOS
|
||||
@ -357,6 +376,7 @@ static jmp_buf promptbuf;
|
||||
* in from the terminal. Handles signals & allows use of
|
||||
* normal erase and kill characters.
|
||||
*/
|
||||
int
|
||||
prompt(s, p)
|
||||
char *s;
|
||||
register char *p;
|
||||
@ -396,6 +416,7 @@ intprompt()
|
||||
/*
|
||||
* ****TIPIN TIPIN****
|
||||
*/
|
||||
void
|
||||
tipin()
|
||||
{
|
||||
int i;
|
||||
@ -451,6 +472,7 @@ extern esctable_t etable[];
|
||||
* Escape handler --
|
||||
* called on recognition of ``escapec'' at the beginning of a line
|
||||
*/
|
||||
char
|
||||
escape()
|
||||
{
|
||||
register char gch;
|
||||
@ -476,6 +498,7 @@ escape()
|
||||
return (gch);
|
||||
}
|
||||
|
||||
int
|
||||
speed(n)
|
||||
int n;
|
||||
{
|
||||
@ -491,6 +514,7 @@ speed(n)
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
any(c, p)
|
||||
register char c, *p;
|
||||
{
|
||||
@ -500,6 +524,7 @@ any(c, p)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
size(s)
|
||||
register char *s;
|
||||
{
|
||||
@ -517,7 +542,7 @@ interp(s)
|
||||
static char buf[256];
|
||||
register char *p = buf, c, *q;
|
||||
|
||||
while (c = *s++) {
|
||||
while ((c = *s++)) {
|
||||
for (q = "\nn\rr\tt\ff\033E\bb"; *q; q++)
|
||||
if (*q++ == c) {
|
||||
*p++ = '\\'; *p++ = *q;
|
||||
@ -556,6 +581,7 @@ ctrl(c)
|
||||
/*
|
||||
* Help command
|
||||
*/
|
||||
void
|
||||
help(c)
|
||||
char c;
|
||||
{
|
||||
@ -628,6 +654,7 @@ static int bits8;
|
||||
* We are doing 8 bit wide output, so we just generate a character
|
||||
* with the right parity and output it.
|
||||
*/
|
||||
void
|
||||
pwrite(fd, buf, n)
|
||||
int fd;
|
||||
char *buf;
|
||||
@ -655,6 +682,7 @@ pwrite(fd, buf, n)
|
||||
/*
|
||||
* Build a parity table with appropriate high-order bit.
|
||||
*/
|
||||
void
|
||||
setparity(defparity)
|
||||
char *defparity;
|
||||
{
|
||||
|
@ -202,6 +202,8 @@ extern value_t vtable[]; /* variable table */
|
||||
#if !ACULOG
|
||||
#define logent(a, b, c, d)
|
||||
#define loginit()
|
||||
#else
|
||||
void logent __P((char *, char *, char *, char*));
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -296,8 +298,24 @@ extern int disc; /* current tty discpline */
|
||||
extern char *ctrl();
|
||||
extern char *vinterp();
|
||||
extern char *connect();
|
||||
|
||||
int tipabort __P((char *));
|
||||
extern int size __P((char *));
|
||||
extern int any __P((char, char *));
|
||||
extern void setscript __P((void));
|
||||
extern void tipout __P((void));
|
||||
extern void vinit __P((void));
|
||||
extern void loginit __P((void));
|
||||
extern int hunt __P((char *));
|
||||
extern int vstring __P((char *, char *));
|
||||
extern void setparity __P((char *));
|
||||
extern void vlex __P((char *));
|
||||
extern void daemon_uid __P((void));
|
||||
extern void disconnect __P((char *));
|
||||
extern void shell_uid __P((void));
|
||||
extern void unraw __P((void));
|
||||
extern void pwrite __P((int, char *, int));
|
||||
extern int prompt __P((char *, char *));
|
||||
extern void consh __P((int));
|
||||
extern void tipabort __P((char *));
|
||||
|
||||
#define TL_VERBOSE 0x00000001
|
||||
#define TL_SIGNAL_TIPOUT 0x00000002
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)tipout.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
@ -112,6 +116,7 @@ intSYS()
|
||||
/*
|
||||
* ****TIPOUT TIPOUT****
|
||||
*/
|
||||
void
|
||||
tipout()
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)value.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "tip.h"
|
||||
@ -40,11 +44,16 @@ static char sccsid[] = "@(#)value.c 8.1 (Berkeley) 6/6/93";
|
||||
#define MIDDLE 35
|
||||
|
||||
static value_t *vlookup();
|
||||
int vstring __P((char *, char *));
|
||||
void vlex __P((char *));
|
||||
void vassign __P((value_t *, char *));
|
||||
|
||||
static int col = 0;
|
||||
|
||||
/*
|
||||
* Variable manipulation
|
||||
*/
|
||||
void
|
||||
vinit()
|
||||
{
|
||||
register value_t *p;
|
||||
@ -54,7 +63,7 @@ vinit()
|
||||
|
||||
for (p = vtable; p->v_name != NULL; p++) {
|
||||
if (p->v_type&ENVIRON)
|
||||
if (cp = getenv(p->v_name))
|
||||
if ((cp = getenv(p->v_name)))
|
||||
p->v_value = cp;
|
||||
if (p->v_type&IREMOTE)
|
||||
number(p->v_value) = *address(p->v_value);
|
||||
@ -71,7 +80,7 @@ vinit()
|
||||
while (fgets(file, sizeof(file)-1, f) != NULL) {
|
||||
if (vflag)
|
||||
printf("set %s", file);
|
||||
if (tp = rindex(file, '\n'))
|
||||
if ((tp = rindex(file, '\n')))
|
||||
*tp = '\0';
|
||||
vlex(file);
|
||||
}
|
||||
@ -86,6 +95,7 @@ vinit()
|
||||
static int vaccess();
|
||||
|
||||
/*VARARGS1*/
|
||||
void
|
||||
vassign(p, v)
|
||||
register value_t *p;
|
||||
char *v;
|
||||
@ -132,6 +142,7 @@ vassign(p, v)
|
||||
|
||||
static void vprint();
|
||||
|
||||
void
|
||||
vlex(s)
|
||||
register char *s;
|
||||
{
|
||||
@ -146,7 +157,7 @@ vlex(s)
|
||||
register char *cp;
|
||||
|
||||
do {
|
||||
if (cp = vinterp(s, ' '))
|
||||
if ((cp = vinterp(s, ' ')))
|
||||
cp++;
|
||||
vtoken(s);
|
||||
s = cp;
|
||||
@ -166,9 +177,9 @@ vtoken(s)
|
||||
register char *cp;
|
||||
char *expand();
|
||||
|
||||
if (cp = index(s, '=')) {
|
||||
if ((cp = index(s, '='))) {
|
||||
*cp = '\0';
|
||||
if (p = vlookup(s)) {
|
||||
if ((p = vlookup(s))) {
|
||||
cp++;
|
||||
if (p->v_type&NUMBER)
|
||||
vassign(p, atoi(cp));
|
||||
@ -179,7 +190,7 @@ vtoken(s)
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (cp = index(s, '?')) {
|
||||
} else if ((cp = index(s, '?'))) {
|
||||
*cp = '\0';
|
||||
if ((p = vlookup(s)) && vaccess(p->v_access, READ)) {
|
||||
vprint(p);
|
||||
@ -332,6 +343,7 @@ vinterp(s, stop)
|
||||
* assign variable s with value v (for NUMBER or STRING or CHAR types)
|
||||
*/
|
||||
|
||||
int
|
||||
vstring(s,v)
|
||||
register char *s;
|
||||
register char *v;
|
||||
|
@ -32,7 +32,11 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)vars.c 8.1 (Berkeley) 6/6/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "tipconf.h"
|
||||
|
Loading…
Reference in New Issue
Block a user