From 612ad45d51ca39df671c4b50906cd9606117fc53 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 26 Jan 2021 09:59:27 -0800 Subject: getty/telnet/tftpd: minor cleanup. Remove STDIN_FILENO and use FLAG(). Use xsetspeed() rather than have a duplicate table. Inline getty's print_prompt(). There's still a lot of cleanup needed here, in particular use of toybuf and removal of the inappropriately-named HOSTNAME_SIZE (and ideally sharing that logic with login(1) which already contains a better implementation of it). --- toys/pending/telnet.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'toys/pending/telnet.c') diff --git a/toys/pending/telnet.c b/toys/pending/telnet.c index 3e040864..b4d5c72f 100644 --- a/toys/pending/telnet.c +++ b/toys/pending/telnet.c @@ -107,7 +107,7 @@ static void handle_esc(void) " z suspend telnet\r\n" " e exit telnet\r\n", 114); - if (read(STDIN_FILENO, &input, 1) <= 0) { + if (read(0, &input, 1) <= 0) { if(TT.term_ok) tcsetattr(0, TCSADRAIN, &TT.def_term); exit(0); } @@ -258,7 +258,7 @@ static int read_server(int len) } } while (TT.pbuff < len); - if (i) xwrite(STDIN_FILENO, toybuf, i); + if (i) xwrite(0, toybuf, i); return 0; } @@ -310,7 +310,7 @@ void telnet_main(void) setsockopt(TT.sfd, SOL_SOCKET, SO_REUSEADDR, &set, sizeof(set)); setsockopt(TT.sfd, SOL_SOCKET, SO_KEEPALIVE, &set, sizeof(set)); - pfds[0].fd = STDIN_FILENO; + pfds[0].fd = 0; pfds[0].events = POLLIN; pfds[1].fd = TT.sfd; pfds[1].events = POLLIN; @@ -325,7 +325,7 @@ void telnet_main(void) continue; } if(pfds[0].revents) { - len = read(STDIN_FILENO, TT.buff, DATABUFSIZE); + len = read(0, TT.buff, DATABUFSIZE); if(len > 0) write_server(len); else return; } -- cgit v1.2.3