After running a "make unifdef", commit the resultant diffs.

This code is now a complete sunset of the crypto (master) code.
This commit is contained in:
Mark Murray 2001-11-30 22:03:20 +00:00
parent 1bd0b24685
commit e895047b95
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=87153
8 changed files with 324 additions and 1063 deletions

View File

@ -56,9 +56,6 @@ extern int diagnostic; /* telnet diagnostic capabilities */
#ifdef BFTPDAEMON
extern int bftpd; /* behave as bftp daemon */
#endif /* BFTPDAEMON */
#if defined(SecurID)
extern int require_SecurID;
#endif
extern slcfun slctab[NSLC + 1]; /* slc mapping table */
@ -90,12 +87,12 @@ extern int SYNCHing; /* we are in TELNET SYNCH mode */
extern void
_termstat P((void)),
add_slc P((int, int, int)),
add_slc P((char, char, cc_t)),
check_slc P((void)),
change_slc P((int, int, int)),
change_slc P((char, char, cc_t)),
cleanup P((int)),
clientstat P((int, int, int)),
copy_termbuf P((char *, int)),
copy_termbuf P((char *, size_t)),
deferslc P((void)),
defer_terminit P((void)),
do_opt_slc P((unsigned char *, int)),
@ -103,8 +100,8 @@ extern void
dooption P((int)),
dontoption P((int)),
edithost P((char *, char *)),
fatal P((int, char *)),
fatalperror P((int, char *)),
fatal P((int, const char *)),
fatalperror P((int, const char *)),
get_slc_defaults P((void)),
init_env P((void)),
init_termbuf P((void)),
@ -114,10 +111,11 @@ extern void
netclear P((void)),
netflush P((void)),
#ifdef DIAGNOSTICS
printoption P((char *, int)),
printdata P((char *, char *, int)),
printsub P((int, unsigned char *, int)),
printoption P((const char *, int)),
printdata P((const char *, char *, int)),
printsub P((char, unsigned char *, int)),
#endif
process_slc P((unsigned char, unsigned char, cc_t)),
ptyflush P((void)),
putchr P((int)),
putf P((char *, char *)),
@ -179,6 +177,7 @@ extern void
int output_data __P((const char *, ...)) __printflike(1, 2);
void output_datalen __P((const char *, int));
void startslave __P((char *, int, char *));

View File

@ -31,13 +31,13 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static const char sccsid[] = "@(#)slc.c 8.2 (Berkeley) 5/30/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include "telnetd.h"
@ -56,10 +56,10 @@ static unsigned char slcbuf[NSLC*6]; /* buffer for slc negotiation */
*
* Write out the current special characters to the client.
*/
void
send_slc()
void
send_slc(void)
{
register int i;
int i;
/*
* Send out list of triplets of special characters
@ -80,10 +80,10 @@ send_slc()
*
* Set pty special characters to all the defaults.
*/
void
default_slc()
static void
default_slc(void)
{
register int i;
int i;
for (i = 1; i <= NSLC; i++) {
slctab[i].current.val = slctab[i].defset.val;
@ -105,10 +105,10 @@ default_slc()
*
* Initialize the slc mapping table.
*/
void
get_slc_defaults()
void
get_slc_defaults(void)
{
register int i;
int i;
init_termbuf();
@ -127,10 +127,8 @@ get_slc_defaults()
*
* Add an slc triplet to the slc buffer.
*/
void
add_slc(func, flag, val)
register char func, flag;
register cc_t val;
void
add_slc(char func, char flag, cc_t val)
{
if ((*slcptr++ = (unsigned char)func) == 0xff)
@ -152,9 +150,8 @@ add_slc(func, flag, val)
* The parameter getit is non-zero if it is necessary to grab a copy
* of the terminal control structures.
*/
void
start_slc(getit)
register int getit;
void
start_slc(int getit)
{
slcchange = 0;
@ -171,11 +168,10 @@ start_slc(getit)
*
* Finish up the slc negotiation. If something to send, then send it.
*/
int
end_slc(bufp)
register unsigned char **bufp;
int
end_slc(unsigned char **bufp)
{
register int len;
int len;
/*
* If a change has occured, store the new terminal control
@ -217,12 +213,10 @@ end_slc(bufp)
*
* Figure out what to do about the client's slc
*/
void
process_slc(func, flag, val)
register unsigned char func, flag;
register cc_t val;
void
process_slc(unsigned char func, unsigned char flag, cc_t val)
{
register int hislevel, mylevel, ack;
int hislevel, mylevel, ack;
/*
* Ensure that we know something about this function
@ -283,12 +277,10 @@ process_slc(func, flag, val)
* Process a request to change one of our special characters.
* Compare client's request with what we are capable of supporting.
*/
void
change_slc(func, flag, val)
register char func, flag;
register cc_t val;
void
change_slc(char func, char flag, cc_t val)
{
register int hislevel, mylevel;
int hislevel, mylevel;
hislevel = flag & SLC_LEVELBITS;
mylevel = slctab[(int)func].defset.flag & SLC_LEVELBITS;
@ -393,10 +385,10 @@ cc_t oldeofc = '\004';
* likely to have changed. If a local change occurs, kick the support level
* and flags up to the defaults.
*/
void
check_slc()
void
check_slc(void)
{
register int i;
int i;
for (i = 1; i <= NSLC; i++) {
#if defined(USE_TERMIO) && (VEOF == VMIN)
@ -436,14 +428,12 @@ check_slc()
*
* ptr points to the beginning of the buffer, len is the length.
*/
void
do_opt_slc(ptr, len)
register unsigned char *ptr;
register int len;
void
do_opt_slc(unsigned char *ptr, int len)
{
register unsigned char func, flag;
unsigned char func, flag;
cc_t val;
register unsigned char *end = ptr + len;
unsigned char *end = ptr + len;
if (terminit()) { /* go ahead */
while (ptr < end) {
@ -477,8 +467,8 @@ do_opt_slc(ptr, len)
*
* Do slc stuff that was deferred.
*/
void
deferslc()
void
deferslc(void)
{
if (def_slcbuf) {
start_slc(1);

View File

@ -31,13 +31,13 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static const char sccsid[] = "@(#)state.c 8.5 (Berkeley) 5/30/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <stdarg.h>
#include "telnetd.h"
@ -83,10 +83,12 @@ unsigned char *subsave;
#define TS_DO 7 /* do " */
#define TS_DONT 8 /* dont " */
void
telrcv()
static void doclientstat(void);
void
telrcv(void)
{
register int c;
int c;
static int state = TS_DATA;
while (ncc > 0) {
@ -404,9 +406,8 @@ gotiac: switch (c) {
* is complete.
*
*/
void
send_do(option, init)
int option, init;
void
send_do(int option, int init)
{
if (init) {
if ((do_dont_resp[option] == 0 && his_state_is_will(option)) ||
@ -428,16 +429,11 @@ send_do(option, init)
DIAG(TD_OPTIONS, printoption("td: send do", option));
}
#ifdef LINEMODE
extern void doclientstat();
#endif
void
willoption(option)
int option;
void
willoption(int option)
{
int changeok = 0;
void (*func)() = 0;
void (*func)(void) = 0;
/*
* process input from peer.
@ -603,9 +599,8 @@ willoption(option)
(*func)();
} /* end of willoption */
void
send_dont(option, init)
int option, init;
void
send_dont(int option, int init)
{
if (init) {
if ((do_dont_resp[option] == 0 && his_state_is_wont(option)) ||
@ -619,9 +614,8 @@ send_dont(option, init)
DIAG(TD_OPTIONS, printoption("td: send dont", option));
}
void
wontoption(option)
int option;
void
wontoption(int option)
{
/*
* Process client input.
@ -742,9 +736,8 @@ wontoption(option)
} /* end of wontoption */
void
send_will(option, init)
int option, init;
void
send_will(int option, int init)
{
if (init) {
if ((will_wont_resp[option] == 0 && my_state_is_will(option))||
@ -769,9 +762,8 @@ send_will(option, init)
int turn_on_sga = 0;
#endif
void
dooption(option)
int option;
void
dooption(int option)
{
int changeok = 0;
@ -895,9 +887,8 @@ dooption(option)
} /* end of dooption */
void
send_wont(option, init)
int option, init;
void
send_wont(int option, int init)
{
if (init) {
if ((will_wont_resp[option] == 0 && my_state_is_wont(option)) ||
@ -911,9 +902,8 @@ send_wont(option, init)
DIAG(TD_OPTIONS, printoption("td: send wont", option));
}
void
dontoption(option)
int option;
void
dontoption(int option)
{
/*
* Process client input.
@ -1017,17 +1007,17 @@ int env_ovalue = -1;
* Window size
* Terminal speed
*/
void
suboption()
void
suboption(void)
{
register int subchar;
int subchar;
DIAG(TD_OPTIONS, {netflush(); printsub('<', subpointer, SB_LEN()+2);});
subchar = SB_GET();
switch (subchar) {
case TELOPT_TSPEED: {
register int xspeed, rspeed;
int xspeed, rspeed;
if (his_state_is_wont(TELOPT_TSPEED)) /* Ignore if option disabled */
break;
@ -1065,7 +1055,7 @@ suboption()
while ((terminaltype < (terminalname + sizeof terminalname-1)) &&
!SB_EOF()) {
register int c;
int c;
c = SB_GET();
if (isupper(c)) {
@ -1079,7 +1069,7 @@ suboption()
} /* end of case TELOPT_TTYPE */
case TELOPT_NAWS: {
register int xwinsize, ywinsize;
int xwinsize, ywinsize;
if (his_state_is_wont(TELOPT_NAWS)) /* Ignore if option disabled */
break;
@ -1104,7 +1094,7 @@ suboption()
#ifdef LINEMODE
case TELOPT_LINEMODE: {
register int request;
int request;
if (his_state_is_wont(TELOPT_LINEMODE)) /* Ignore if option disabled */
break;
@ -1184,8 +1174,8 @@ suboption()
case TELOPT_NEW_ENVIRON:
#endif
case TELOPT_OLD_ENVIRON: {
register int c;
register char *cp, *varp, *valp;
int c;
char *cp, *varp, *valp;
if (SB_EOF())
return;
@ -1216,7 +1206,7 @@ suboption()
* reversed.
*/
if (env_ovar < 0) {
register int last = -1; /* invalid value */
int last = -1; /* invalid value */
int empty = 0;
int got_var = 0, got_value = 0, got_uservar = 0;
@ -1373,20 +1363,20 @@ suboption()
} /* end of suboption */
void
doclientstat()
static void
doclientstat(void)
{
clientstat(TELOPT_LINEMODE, WILL, 0);
}
#define ADD(c) *ncp++ = c
#define ADD_DATA(c) { *ncp++ = c; if (c == SE || c == IAC) *ncp++ = c; }
void
send_status()
void
send_status(void)
{
unsigned char statusbuf[256];
register unsigned char *ncp;
register unsigned char i;
unsigned char *ncp;
unsigned char i;
ncp = statusbuf;

File diff suppressed because it is too large Load Diff

View File

@ -31,59 +31,32 @@
* SUCH DAMAGE.
*/
#ifndef lint
static const char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include "telnetd.h"
#include "pathnames.h"
#include <err.h>
#include <arpa/inet.h>
#include <sys/mman.h>
#include <err.h>
#include <libutil.h>
#include <paths.h>
#include <termcap.h>
#include <utmp.h>
#if defined(SecurID)
int require_SecurID = 0;
#endif
#include <arpa/inet.h>
#include <libtelnet/misc.h>
char remote_hostname[MAXHOSTNAMELEN];
int utmp_len = sizeof(remote_hostname) - 1;
size_t utmp_len = sizeof(remote_hostname) - 1;
int registerd_host_only = 0;
#ifdef STREAMSPTY
# include <stropts.h>
# include <termio.h>
/* make sure we don't get the bsd version */
# include "/usr/include/sys/tty.h"
# include <sys/ptyvar.h>
/*
* Because of the way ptyibuf is used with streams messages, we need
* ptyibuf+1 to be on a full-word boundary. The following weirdness
* is simply to make that happen.
*/
long ptyibufbuf[BUFSIZ/sizeof(long)+1];
char *ptyibuf = ((char *)&ptyibufbuf[1])-1;
char *ptyip = ((char *)&ptyibufbuf[1])-1;
char ptyibuf2[BUFSIZ];
unsigned char ctlbuf[BUFSIZ];
struct strbuf strbufc, strbufd;
#else /* ! STREAMPTY */
/*
* I/O data buffers,
@ -92,25 +65,21 @@ struct strbuf strbufc, strbufd;
char ptyibuf[BUFSIZ], *ptyip = ptyibuf;
char ptyibuf2[BUFSIZ];
# include <termcap.h>
int readstream(int p, char *ibuf, int bufsize);
void doit(struct sockaddr *who);
int terminaltypeok(char *s);
void startslave(char *host, int autologin, char *autoname);
#endif /* ! STREAMPTY */
int readstream(int, char *, int);
void doit(struct sockaddr *);
int terminaltypeok(char *);
int hostinfo = 1; /* do we print login banner? */
int debug = 0;
int keepalive = 1;
char *altlogin;
const char *altlogin;
void doit __P((struct sockaddr *));
int terminaltypeok __P((char *));
void startslave __P((char *, int, char *));
extern void usage P((void));
static void _gettermname __P((void));
/*
* The string to pass to getopt(). We do it this way so
@ -128,22 +97,30 @@ char valid_opts[] = {
#endif
#ifdef LINEMODE
'l',
#endif
#ifdef SecurID
's',
#endif
'\0'
};
int family = AF_INET;
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 256
#endif /* MAXHOSTNAMELEN */
char *hostname;
char host_name[MAXHOSTNAMELEN];
extern void telnet P((int, int, char *));
int level;
char user_name[256];
int
main(argc, argv)
char *argv[];
main(int argc, char *argv[])
{
struct sockaddr_storage from;
int on = 1, fromlen;
register int ch;
int ch;
#if defined(IPPROTO_IP) && defined(IP_TOS)
int tos = -1;
#endif
@ -236,12 +213,6 @@ main(argc, argv)
altlogin = optarg;
break;
#ifdef SecurID
case 's':
/* SecurID required */
require_SecurID = 1;
break;
#endif /* SecurID */
case 'S':
#ifdef HAS_GETTOS
if ((tos = parsetos(optarg, "tcp")) < 0)
@ -254,9 +225,7 @@ main(argc, argv)
break;
case 'u':
utmp_len = atoi(optarg);
if (utmp_len < 0)
utmp_len = -utmp_len;
utmp_len = (size_t)atoi(optarg);
if (utmp_len >= sizeof(remote_hostname))
utmp_len = sizeof(remote_hostname) - 1;
break;
@ -290,7 +259,7 @@ main(argc, argv)
if (debug) {
int s, ns, foo, error;
char *service = "telnet";
const char *service = "telnet";
struct addrinfo hints, *res;
if (argc > 1) {
@ -392,9 +361,6 @@ usage()
#endif
fprintf(stderr, " [-n]");
fprintf(stderr, "\n\t");
#ifdef SecurID
fprintf(stderr, " [-s]");
#endif
#ifdef HAS_GETTOS
fprintf(stderr, " [-S tos]");
#endif
@ -413,12 +379,13 @@ static unsigned char ttytype_sbbuf[] = {
IAC, SB, TELOPT_TTYPE, TELQUAL_SEND, IAC, SE
};
int
getterminaltype(name)
char *name;
#define undef2 __unused
static int
getterminaltype(char *name undef2)
{
int retval = -1;
void _gettermname();
settimer(baseline);
@ -533,8 +500,8 @@ getterminaltype(name)
return(retval);
} /* end of getterminaltype */
void
_gettermname()
static void
_gettermname(void)
{
/*
* If the client turned off the option,
@ -551,9 +518,8 @@ _gettermname()
ttloop();
}
int
terminaltypeok(s)
char *s;
int
terminaltypeok(char *s)
{
char buf[1024];
@ -572,25 +538,13 @@ terminaltypeok(s)
return(1);
}
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 256
#endif /* MAXHOSTNAMELEN */
char *hostname;
char host_name[MAXHOSTNAMELEN];
extern void telnet P((int, int, char *));
int level;
char user_name[256];
/*
* Get a pty, scan input lines.
*/
void
doit(who)
struct sockaddr *who;
void
doit(struct sockaddr *who)
{
int err;
int err_; /* XXX */
int ptynum;
/*
@ -624,10 +578,10 @@ doit(who)
trimdomain(remote_hostname, UT_HOSTSIZE);
if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len)
err = getnameinfo(who, who->sa_len, remote_hostname,
err_ = getnameinfo(who, who->sa_len, remote_hostname,
sizeof(remote_hostname), NULL, 0,
NI_NUMERICHOST|NI_WITHSCOPEID);
/* XXX: do 'err' check */
/* XXX: do 'err_' check */
(void) gethostname(host_name, sizeof(host_name) - 1);
host_name[sizeof(host_name) - 1] = '\0';
@ -651,10 +605,8 @@ doit(who)
* Main loop. Select from pty and network, and
* hand data to telnet receiver finite state machine.
*/
void
telnet(f, p, host)
int f, p;
char *host;
void
telnet(int f, int p, char *host)
{
int on = 1;
#define TABBUFSIZ 512
@ -761,12 +713,10 @@ telnet(f, p, host)
if (my_state_is_wont(TELOPT_ECHO))
send_will(TELOPT_ECHO, 1);
#ifndef STREAMSPTY
/*
* Turn on packet mode
*/
(void) ioctl(p, TIOCPKT, (char *)&on);
#endif
#if defined(LINEMODE) && defined(KLUDGELINEMODE)
/*
@ -808,7 +758,7 @@ telnet(f, p, host)
#ifdef TIOCNOTTY
{
register int t;
int t;
t = open(_PATH_TTY, O_RDWR);
if (t >= 0) {
(void) ioctl(t, TIOCNOTTY, (char *)0);
@ -826,7 +776,6 @@ telnet(f, p, host)
*/
if (getent(defent, "default") == 1) {
char *Getstr();
char *cp=defstrs;
HE = Getstr("he", &cp);
@ -835,9 +784,9 @@ telnet(f, p, host)
if (HN && *HN)
(void) strlcpy(host_name, HN, sizeof(host_name));
if (IM == 0)
IM = "";
IM = strdup("");
} else {
IM = DEFAULT_IM;
IM = strdup(DEFAULT_IM);
HE = 0;
}
edithost(HE, host_name);
@ -868,7 +817,7 @@ telnet(f, p, host)
nfd = ((f > p) ? f : p) + 1;
for (;;) {
fd_set ibits, obits, xbits;
register int c;
int c;
if (ncc < 0 && pcc < 0)
break;
@ -989,11 +938,7 @@ telnet(f, p, host)
* Something to read from the pty...
*/
if (FD_ISSET(p, &ibits)) {
#ifndef STREAMSPTY
pcc = read(p, ptyibuf, BUFSIZ);
#else
pcc = readstream(p, ptyibuf, BUFSIZ);
#endif
/*
* On some systems, if we try to read something
* off the master side before the slave side is
@ -1088,114 +1033,16 @@ telnet(f, p, host)
# endif
#endif
#ifdef STREAMSPTY
int flowison = -1; /* current state of flow: -1 is unknown */
int readstream(p, ibuf, bufsize)
int p;
char *ibuf;
int bufsize;
{
int flags = 0;
int ret = 0;
struct termios *tsp;
struct termio *tp;
struct iocblk *ip;
char vstop, vstart;
int ixon;
int newflow;
strbufc.maxlen = BUFSIZ;
strbufc.buf = (char *)ctlbuf;
strbufd.maxlen = bufsize-1;
strbufd.len = 0;
strbufd.buf = ibuf+1;
ibuf[0] = 0;
ret = getmsg(p, &strbufc, &strbufd, &flags);
if (ret < 0) /* error of some sort -- probably EAGAIN */
return(-1);
if (strbufc.len <= 0 || ctlbuf[0] == M_DATA) {
/* data message */
if (strbufd.len > 0) { /* real data */
return(strbufd.len + 1); /* count header char */
} else {
/* nothing there */
errno = EAGAIN;
return(-1);
}
}
/*
* It's a control message. Return 1, to look at the flag we set
*/
switch (ctlbuf[0]) {
case M_FLUSH:
if (ibuf[1] & FLUSHW)
ibuf[0] = TIOCPKT_FLUSHWRITE;
return(1);
case M_IOCTL:
ip = (struct iocblk *) (ibuf+1);
switch (ip->ioc_cmd) {
case TCSETS:
case TCSETSW:
case TCSETSF:
tsp = (struct termios *)
(ibuf+1 + sizeof(struct iocblk));
vstop = tsp->c_cc[VSTOP];
vstart = tsp->c_cc[VSTART];
ixon = tsp->c_iflag & IXON;
break;
case TCSETA:
case TCSETAW:
case TCSETAF:
tp = (struct termio *) (ibuf+1 + sizeof(struct iocblk));
vstop = tp->c_cc[VSTOP];
vstart = tp->c_cc[VSTART];
ixon = tp->c_iflag & IXON;
break;
default:
errno = EAGAIN;
return(-1);
}
newflow = (ixon && (vstart == 021) && (vstop == 023)) ? 1 : 0;
if (newflow != flowison) { /* it's a change */
flowison = newflow;
ibuf[0] = newflow ? TIOCPKT_DOSTOP : TIOCPKT_NOSTOP;
return(1);
}
}
/* nothing worth doing anything about */
errno = EAGAIN;
return(-1);
}
#endif /* STREAMSPTY */
/*
* Send interrupt to process on other side of pty.
* If it is in raw mode, just write NULL;
* otherwise, write intr char.
*/
void
interrupt()
void
interrupt(void)
{
ptyflush(); /* half-hearted */
#if defined(STREAMSPTY) && defined(TIOCSIGNAL)
/* Streams PTY style ioctl to post a signal */
{
int sig = SIGINT;
(void) ioctl(pty, TIOCSIGNAL, &sig);
(void) ioctl(pty, I_FLUSH, FLUSHR);
}
#else
#ifdef TCSIG
(void) ioctl(pty, TCSIG, (char *)SIGINT);
#else /* TCSIG */
@ -1203,7 +1050,6 @@ interrupt()
*pfrontp++ = slctab[SLC_IP].sptr ?
(unsigned char)*slctab[SLC_IP].sptr : '\177';
#endif /* TCSIG */
#endif
}
/*
@ -1211,8 +1057,8 @@ interrupt()
* If it is in raw mode, just write NULL;
* otherwise, write quit char.
*/
void
sendbrk()
void
sendbrk(void)
{
ptyflush(); /* half-hearted */
#ifdef TCSIG
@ -1224,8 +1070,8 @@ sendbrk()
#endif /* TCSIG */
}
void
sendsusp()
void
sendsusp(void)
{
#ifdef SIGTSTP
ptyflush(); /* half-hearted */
@ -1242,8 +1088,8 @@ sendsusp()
* When we get an AYT, if ^T is enabled, use that. Otherwise,
* just send back "[Yes]".
*/
void
recv_ayt()
void
recv_ayt(void)
{
#if defined(SIGINFO) && defined(TCSIG)
if (slctab[SLC_AYT].sptr && *slctab[SLC_AYT].sptr != _POSIX_VDISABLE) {
@ -1254,8 +1100,8 @@ recv_ayt()
output_data("\r\n[Yes]\r\n");
}
void
doeof()
void
doeof(void)
{
init_termbuf();

View File

@ -31,6 +31,7 @@
* SUCH DAMAGE.
*
* @(#)telnetd.h 8.1 (Berkeley) 6/4/93
* $FreeBSD$
*/
@ -45,5 +46,4 @@
/* other external variables */
extern char **environ;
extern int errno;
extern const char *altlogin;

View File

@ -31,16 +31,17 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifndef lint
#if 0
static const char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include "telnetd.h"
/*
* local variables
*/
@ -129,8 +130,8 @@ static int _terminit = 0;
* then linemode is off, if server won't SGA, then linemode
* is on.
*/
void
localstat()
void
localstat(void)
{
int need_will_echo = 0;
@ -181,6 +182,7 @@ localstat()
}
}
/*
* Do echo mode handling as soon as we know what the
* linemode is going to be.
@ -333,8 +335,8 @@ localstat()
*
* Check for changes to flow control
*/
void
flowstat()
void
flowstat(void)
{
if (his_state_is_will(TELOPT_LFLOW)) {
if (tty_flowmode() != flowmode) {
@ -363,9 +365,8 @@ flowstat()
* at a time, and if using kludge linemode, then only linemode may be
* affected.
*/
void
clientstat(code, parm1, parm2)
register int code, parm1, parm2;
void
clientstat(int code, int parm1, int parm2)
{
/*
@ -440,7 +441,7 @@ clientstat(code, parm1, parm2)
case LM_MODE:
{
register int ack, changed;
int ack, changed;
/*
* Client has sent along a mode mask. If it agrees with
@ -565,8 +566,8 @@ clientstat(code, parm1, parm2)
* function is called when the pty state has been processed for the first time.
* It calls other functions that do things that were deferred in each module.
*/
void
defer_terminit()
void
defer_terminit(void)
{
/*
@ -600,8 +601,8 @@ defer_terminit()
*
* Returns true if the pty state has been processed yet.
*/
int
terminit()
int
terminit(void)
{
return(_terminit);

View File

@ -47,6 +47,7 @@ static const char rcsid[] =
#define PRINTOPTIONS
#include "telnetd.h"
/*
* utility functions performing io related tasks
*/
@ -88,11 +89,10 @@ ttloop()
/*
* Check a descriptor to see if out of band data exists on it.
*/
int
stilloob(s)
int s; /* socket number */
int
stilloob(int s)
{
static struct timeval timeout = { 0 };
static struct timeval timeout = { 0, 0 };
fd_set excepts;
int value;
@ -113,8 +113,8 @@ stilloob(s)
}
}
void
ptyflush()
void
ptyflush(void)
{
int n;
@ -144,9 +144,8 @@ ptyflush()
* if the current address is a TELNET IAC ("I Am a Command")
* character.
*/
char *
nextitem(current)
char *current;
static char *
nextitem(char *current)
{
if ((*current&0xff) != IAC) {
return current+1;
@ -159,7 +158,7 @@ nextitem(current)
return current+3;
case SB: /* loop forever looking for the SE */
{
register char *look = current+2;
char *look = current+2;
for (;;) {
if ((*look++&0xff) == IAC) {
@ -174,7 +173,6 @@ nextitem(current)
}
} /* end of nextitem */
/*
* netclear()
*
@ -191,10 +189,10 @@ nextitem(current)
* caller should be setting the urgent data pointer AFTER calling
* us in any case.
*/
void
netclear()
void
netclear(void)
{
register char *thisitem, *next;
char *thisitem, *next;
char *good;
#define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \
((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
@ -236,8 +234,8 @@ netclear()
* Send as much data as possible to the network,
* handling requests for urgent data.
*/
void
netflush()
void
netflush(void)
{
int n;
extern int not42;
@ -295,10 +293,8 @@ netflush()
*/
void
fatal(f, msg)
int f;
char *msg;
void
fatal(int f, const char *msg)
{
char buf[BUFSIZ];
@ -308,12 +304,10 @@ fatal(f, msg)
exit(1);
}
void
fatalperror(f, msg)
int f;
char *msg;
void
fatalperror(int f, const char *msg)
{
char buf[BUFSIZ], *strerror();
char buf[BUFSIZ];
(void) snprintf(buf, sizeof(buf), "%s: %s", msg, strerror(errno));
fatal(f, buf);
@ -321,15 +315,13 @@ fatalperror(f, msg)
char editedhost[32];
void
edithost(pat, host)
register char *pat;
register char *host;
void
edithost(char *pat, char *host)
{
register char *res = editedhost;
char *res = editedhost;
if (!pat)
pat = "";
pat = strdup("");
while (*pat) {
switch (*pat) {
@ -363,18 +355,16 @@ edithost(pat, host)
static char *putlocation;
void
putstr(s)
register char *s;
static void
putstr(const char *s)
{
while (*s)
putchr(*s++);
}
void
putchr(cc)
int cc;
void
putchr(int cc)
{
*putlocation++ = cc;
}
@ -382,18 +372,11 @@ putchr(cc)
#ifdef __FreeBSD__
static char fmtstr[] = { "%+" };
#else
/*
* This is split on two lines so that SCCS will not see the M
* between two % signs and expand it...
*/
static char fmtstr[] = { "%l:%M\
%P on %A, %d %B %Y" };
static char fmtstr[] = { "%l:%M%P on %A, %d %B %Y" };
#endif
void
putf(cp, where)
register char *cp;
char *where;
void
putf(char *cp, char *where)
{
char *slash;
time_t t;
@ -474,10 +457,8 @@ putf(cp, where)
/*
* Print telnet options and commands in plain text, if possible.
*/
void
printoption(fmt, option)
register char *fmt;
register int option;
void
printoption(const char *fmt, int option)
{
if (TELOPT_OK(option))
output_data("%s %s\r\n", fmt, TELOPT(option));
@ -488,13 +469,10 @@ printoption(fmt, option)
return;
}
void
printsub(direction, pointer, length)
char direction; /* '<' or '>' */
unsigned char *pointer; /* where suboption data sits */
int length; /* length of suboption data */
void
printsub(char direction, unsigned char *pointer, int length)
{
register int i = 0;
int i = 0;
if (!(diagnostic & TD_OPTIONS))
return;
@ -503,7 +481,7 @@ printsub(direction, pointer, length)
output_data("td: %s suboption ",
direction == '<' ? "recv" : "send");
if (length >= 3) {
register int j;
int j;
i = pointer[length-2];
j = pointer[length-1];
@ -723,8 +701,8 @@ printsub(direction, pointer, length)
break;
case TELOPT_STATUS: {
register char *cp;
register int j, k;
const char *cp;
int j, k;
output_data("STATUS");
@ -825,7 +803,7 @@ printsub(direction, pointer, length)
output_data("INFO ");
env_common:
{
register int noquote = 2;
int noquote = 2;
for (i = 2; i < length; i++ ) {
switch (pointer[i]) {
case NEW_ENV_VAR:
@ -888,13 +866,10 @@ printsub(direction, pointer, length)
/*
* Dump a data buffer in hex and ascii to the output data stream.
*/
void
printdata(tag, ptr, cnt)
register char *tag;
register char *ptr;
register int cnt;
void
printdata(const char *tag, char *ptr, int cnt)
{
register int i;
int i;
char xbuf[30];
while (cnt) {