aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-04-07 15:02:20 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-04-07 15:02:20 +0200
commit2f094ae82106e91cb210e79ddc2e5285377b549e (patch)
treec76bacf7490a92aceda4113acc98bb9da45cd864
parente0afe0a9fd610b1972fdaa444ca39af0b0be6ec4 (diff)
downloadbusybox-w32-2f094ae82106e91cb210e79ddc2e5285377b549e.tar.gz
busybox-w32-2f094ae82106e91cb210e79ddc2e5285377b549e.tar.bz2
busybox-w32-2f094ae82106e91cb210e79ddc2e5285377b549e.zip
telnet: move winsize detection closer to I/O loop, delete non-functioning debug code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/bb_askpass.c12
-rw-r--r--networking/telnet.c17
2 files changed, 6 insertions, 23 deletions
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c
index aae35ec41..5599c82ef 100644
--- a/libbb/bb_askpass.c
+++ b/libbb/bb_askpass.c
@@ -37,15 +37,6 @@ char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt)
37 37
38 tcgetattr(fd, &oldtio); 38 tcgetattr(fd, &oldtio);
39 tio = oldtio; 39 tio = oldtio;
40#if 0
41 /* Switch off UPPERCASE->lowercase conversion (never used since 198x)
42 * and XON/XOFF (why we want to mess with this??)
43 */
44# ifndef IUCLC
45# define IUCLC 0
46# endif
47 tio.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
48#endif
49 /* Switch off echo */ 40 /* Switch off echo */
50 tio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL); 41 tio.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL);
51 tcsetattr(fd, TCSANOW, &tio); 42 tcsetattr(fd, TCSANOW, &tio);
@@ -66,9 +57,8 @@ char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt)
66 while (1) { 57 while (1) {
67 int r = read(fd, &ret[i], 1); 58 int r = read(fd, &ret[i], 1);
68 if ((i == 0 && r == 0) /* EOF (^D) with no password */ 59 if ((i == 0 && r == 0) /* EOF (^D) with no password */
69 || r < 0 60 || r < 0 /* read is interrupted by timeout or ^C */
70 ) { 61 ) {
71 /* read is interrupted by timeout or ^C */
72 ret = NULL; 62 ret = NULL;
73 break; 63 break;
74 } 64 }
diff --git a/networking/telnet.c b/networking/telnet.c
index 8b0df7f5c..15d6a08d8 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -89,12 +89,6 @@
89# define TELOPT_NAWS 31 /* window size */ 89# define TELOPT_NAWS 31 /* window size */
90#endif 90#endif
91 91
92#ifdef DOTRACE
93# define TRACE(x, y) do { if (x) printf y; } while (0)
94#else
95# define TRACE(x, y)
96#endif
97
98enum { 92enum {
99 DATABUFSIZE = 128, 93 DATABUFSIZE = 128,
100 IACBUFSIZE = 128, 94 IACBUFSIZE = 128,
@@ -627,10 +621,6 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
627 621
628 INIT_G(); 622 INIT_G();
629 623
630#if ENABLE_FEATURE_TELNET_WIDTH
631 get_terminal_width_height(0, &G.win_width, &G.win_height);
632#endif
633
634#if ENABLE_FEATURE_TELNET_TTYPE 624#if ENABLE_FEATURE_TELNET_TTYPE
635 G.ttype = getenv("TERM"); 625 G.ttype = getenv("TERM");
636#endif 626#endif
@@ -661,6 +651,11 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
661 651
662 setsockopt_keepalive(netfd); 652 setsockopt_keepalive(netfd);
663 653
654#if ENABLE_FEATURE_TELNET_WIDTH
655 get_terminal_width_height(0, &G.win_width, &G.win_height);
656//TODO: support dynamic resize?
657#endif
658
664 signal(SIGINT, record_signo); 659 signal(SIGINT, record_signo);
665 660
666 ufds[0].fd = STDIN_FILENO; 661 ufds[0].fd = STDIN_FILENO;
@@ -684,7 +679,6 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
684 len = safe_read(STDIN_FILENO, G.buf, DATABUFSIZE); 679 len = safe_read(STDIN_FILENO, G.buf, DATABUFSIZE);
685 if (len <= 0) 680 if (len <= 0)
686 doexit(EXIT_SUCCESS); 681 doexit(EXIT_SUCCESS);
687 TRACE(0, ("Read con: %d\n", len));
688 handle_net_output(len); 682 handle_net_output(len);
689 } 683 }
690 684
@@ -694,7 +688,6 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
694 full_write1_str("Connection closed by foreign host\r\n"); 688 full_write1_str("Connection closed by foreign host\r\n");
695 doexit(EXIT_FAILURE); 689 doexit(EXIT_FAILURE);
696 } 690 }
697 TRACE(0, ("Read netfd (%d): %d\n", netfd, len));
698 handle_net_input(len); 691 handle_net_input(len);
699 } 692 }
700 } /* while (1) */ 693 } /* while (1) */