telnet: finish style cleanup bits

This commit is contained in:
Denis Vlasenko 2007-03-19 14:52:26 +00:00
parent f24cdf1554
commit 54e3d1f00d

View File

@ -72,7 +72,8 @@ struct globals {
int win_width, win_height; int win_width, win_height;
#endif #endif
/* same buffer used both for network and console read/write */ /* same buffer used both for network and console read/write */
char buf[DATABUFSIZE]; /* allocating so static size is smaller */ char buf[DATABUFSIZE];
/* buffer to handle telnet negotiations */
char iacbuf[IACBUFSIZE]; char iacbuf[IACBUFSIZE];
struct termios termios_def; struct termios termios_def;
struct termios termios_raw; struct termios termios_raw;
@ -97,8 +98,7 @@ static void iacflush(void)
#define write_str(fd, str) write(fd, str, sizeof(str) - 1) #define write_str(fd, str) write(fd, str, sizeof(str) - 1)
static void /* buffer to handle telnet negotiations */ static void doexit(int ev)
doexit(int ev)
{ {
cookmode(); cookmode();
exit(ev); exit(ev);
@ -151,6 +151,7 @@ static void conescape(void)
G.gotsig = 0; G.gotsig = 0;
} }
static void handlenetoutput(int len) static void handlenetoutput(int len)
{ {
/* here we could do smart tricks how to handle 0xFF:s in output /* here we could do smart tricks how to handle 0xFF:s in output
@ -191,7 +192,6 @@ static void handlenetoutput(int len)
write(G.netfd, outbuf, j); write(G.netfd, outbuf, j);
} }
static void handlenetinput(int len) static void handlenetinput(int len)
{ {
int i; int i;
@ -266,15 +266,11 @@ static void handlenetinput(int len)
write(1, G.buf, len); write(1, G.buf, len);
} }
/* ******************************* */
static void putiac(int c) static void putiac(int c)
{ {
G.iacbuf[G.iaclen++] = c; G.iacbuf[G.iaclen++] = c;
} }
static void putiac2(byte wwdd, byte c) static void putiac2(byte wwdd, byte c)
{ {
if (G.iaclen + 3 > IACBUFSIZE) if (G.iaclen + 3 > IACBUFSIZE)
@ -354,24 +350,17 @@ static void putiac_naws(byte c, int x, int y)
} }
#endif #endif
/* void putiacstring (subneg strings) */
/* ******************************* */
static char const escapecharis[] = "\r\nEscape character is "; static char const escapecharis[] = "\r\nEscape character is ";
static void setConMode(void) static void setConMode(void)
{ {
if (G.telflags & UF_ECHO) if (G.telflags & UF_ECHO) {
{
if (G.charmode == CHM_TRY) { if (G.charmode == CHM_TRY) {
G.charmode = CHM_ON; G.charmode = CHM_ON;
printf("\r\nEntering character mode%s'^]'.\r\n", escapecharis); printf("\r\nEntering character mode%s'^]'.\r\n", escapecharis);
rawmode(); rawmode();
} }
} } else {
else
{
if (G.charmode != CHM_OFF) { if (G.charmode != CHM_OFF) {
G.charmode = CHM_OFF; G.charmode = CHM_OFF;
printf("\r\nEntering line mode%s'^C'.\r\n", escapecharis); printf("\r\nEntering line mode%s'^C'.\r\n", escapecharis);
@ -380,8 +369,6 @@ static void setConMode(void)
} }
} }
/* ******************************* */
static void will_charmode(void) static void will_charmode(void)
{ {
G.charmode = CHM_TRY; G.charmode = CHM_TRY;
@ -404,8 +391,6 @@ static void do_linemode(void)
iacflush(); iacflush();
} }
/* ******************************* */
static void to_notsup(char c) static void to_notsup(char c)
{ {
if (G.telwish == WILL) if (G.telwish == WILL)
@ -517,11 +502,7 @@ static void telopt(byte c)
} }
} }
/* ******************************* */
/* subnegotiation -- ignore all (except TTYPE,NAWS) */ /* subnegotiation -- ignore all (except TTYPE,NAWS) */
static int subneg(byte c) static int subneg(byte c)
{ {
switch (G.telstate) { switch (G.telstate) {
@ -548,8 +529,6 @@ static int subneg(byte c)
return FALSE; return FALSE;
} }
/* ******************************* */
static void fgotsig(int sig) static void fgotsig(int sig)
{ {
G.gotsig = sig; G.gotsig = sig;
@ -558,12 +537,14 @@ static void fgotsig(int sig)
static void rawmode(void) static void rawmode(void)
{ {
if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_raw); if (G.do_termios)
tcsetattr(0, TCSADRAIN, &G.termios_raw);
} }
static void cookmode(void) static void cookmode(void)
{ {
if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_def); if (G.do_termios)
tcsetattr(0, TCSADRAIN, &G.termios_def);
} }
void BUG_telnet_globals_too_big(void); void BUG_telnet_globals_too_big(void);