summaryrefslogtreecommitdiff
path: root/networking/telnet.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-09-11 19:51:11 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-09-11 19:51:11 +0000
commit08ea11ab0749a7977e6d47cd0fa7b3c9cc10af32 (patch)
tree84049bf86fbcbe95ad0443816efd07f8c02c1288 /networking/telnet.c
parent9725daa03a7806b1c9c5a3c511dfe2ff9f97dd26 (diff)
downloadbusybox-w32-08ea11ab0749a7977e6d47cd0fa7b3c9cc10af32.tar.gz
busybox-w32-08ea11ab0749a7977e6d47cd0fa7b3c9cc10af32.tar.bz2
busybox-w32-08ea11ab0749a7977e6d47cd0fa7b3c9cc10af32.zip
runsvd: shrink by Vladimir
*: use unified trivial signal handler function old new delta record_signo - 10 +10 process_stdin 433 443 +10 bbunpack 383 391 +8 wc_main 598 605 +7 conescape 293 296 +3 nmeter_main 670 672 +2 fallbackSort 1717 1719 +2 bb_got_signal - 1 +1 microcom_main 713 712 -1 signalled 2 - -2 pack_gzip 1661 1659 -2 evalvar 1376 1374 -2 compare_keys 737 735 -2 parse_command 1460 1456 -4 expand 1748 1744 -4 s_term 37 29 -8 s_hangup 8 - -8 fgotsig 10 - -10 find_pair 187 169 -18 signal_handler 190 170 -20 runsvdir_main 1701 1583 -118 ------------------------------------------------------------------------------ (add/remove: 2/3 grow/shrink: 6/10 up/down: 43/-199) Total: -156 bytes
Diffstat (limited to 'networking/telnet.c')
-rw-r--r--networking/telnet.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/networking/telnet.c b/networking/telnet.c
index 63ee38088..5d7ecef3b 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -60,7 +60,6 @@ struct globals {
60 byte telwish; /* DO, DONT, WILL, WONT */ 60 byte telwish; /* DO, DONT, WILL, WONT */
61 byte charmode; 61 byte charmode;
62 byte telflags; 62 byte telflags;
63 byte gotsig;
64 byte do_termios; 63 byte do_termios;
65#if ENABLE_FEATURE_TELNET_TTYPE 64#if ENABLE_FEATURE_TELNET_TTYPE
66 char *ttype; 65 char *ttype;
@@ -113,7 +112,7 @@ static void conescape(void)
113{ 112{
114 char b; 113 char b;
115 114
116 if (G.gotsig) /* came from line mode... go raw */ 115 if (bb_got_signal) /* came from line mode... go raw */
117 rawmode(); 116 rawmode();
118 117
119 write_str(1, "\r\nConsole escape. Commands are:\r\n\n" 118 write_str(1, "\r\nConsole escape. Commands are:\r\n\n"
@@ -127,13 +126,13 @@ static void conescape(void)
127 126
128 switch (b) { 127 switch (b) {
129 case 'l': 128 case 'l':
130 if (!G.gotsig) { 129 if (!bb_got_signal) {
131 do_linemode(); 130 do_linemode();
132 goto rrturn; 131 goto rrturn;
133 } 132 }
134 break; 133 break;
135 case 'c': 134 case 'c':
136 if (G.gotsig) { 135 if (bb_got_signal) {
137 will_charmode(); 136 will_charmode();
138 goto rrturn; 137 goto rrturn;
139 } 138 }
@@ -149,11 +148,11 @@ static void conescape(void)
149 148
150 write_str(1, "continuing...\r\n"); 149 write_str(1, "continuing...\r\n");
151 150
152 if (G.gotsig) 151 if (bb_got_signal)
153 cookmode(); 152 cookmode();
154 153
155 rrturn: 154 rrturn:
156 G.gotsig = 0; 155 bb_got_signal = 0;
157 156
158} 157}
159 158
@@ -524,12 +523,6 @@ static int subneg(byte c)
524 return FALSE; 523 return FALSE;
525} 524}
526 525
527static void fgotsig(int sig)
528{
529 G.gotsig = sig;
530}
531
532
533static void rawmode(void) 526static void rawmode(void)
534{ 527{
535 if (G.do_termios) 528 if (G.do_termios)
@@ -592,7 +585,7 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
592 585
593 setsockopt(netfd, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1)); 586 setsockopt(netfd, SOL_SOCKET, SO_KEEPALIVE, &const_int_1, sizeof(const_int_1));
594 587
595 signal(SIGINT, fgotsig); 588 signal(SIGINT, record_signo);
596 589
597#ifdef USE_POLL 590#ifdef USE_POLL
598 ufds[0].fd = 0; ufds[1].fd = netfd; 591 ufds[0].fd = 0; ufds[1].fd = netfd;
@@ -617,7 +610,7 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
617 /* timeout */ 610 /* timeout */
618 case -1: 611 case -1:
619 /* error, ignore and/or log something, bay go to loop */ 612 /* error, ignore and/or log something, bay go to loop */
620 if (G.gotsig) 613 if (bb_got_signal)
621 conescape(); 614 conescape();
622 else 615 else
623 sleep(1); 616 sleep(1);