diff options
author | Elliott Hughes <enh@google.com> | 2021-01-26 09:59:27 -0800 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2021-01-26 18:56:46 -0600 |
commit | 612ad45d51ca39df671c4b50906cd9606117fc53 (patch) | |
tree | 893648daaf2b72806073005c15f08afc6ad1546a /toys/pending/tftpd.c | |
parent | 2b4abd05efcc96061eaa87a6fdbc3f7121fd2c08 (diff) | |
download | toybox-612ad45d51ca39df671c4b50906cd9606117fc53.tar.gz |
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).
Diffstat (limited to 'toys/pending/tftpd.c')
-rw-r--r-- | toys/pending/tftpd.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/toys/pending/tftpd.c b/toys/pending/tftpd.c index b5d0558f..f945aba6 100644 --- a/toys/pending/tftpd.c +++ b/toys/pending/tftpd.c @@ -102,8 +102,8 @@ static void do_action(struct sockaddr *srcaddr, struct sockaddr *dstaddr, if (TT.pw) xsetuser(TT.pw); if (opcode == TFTPD_OP_RRQ) fd = open(file, O_RDONLY, 0666); - else fd = open(file, ((toys.optflags & FLAG_c) ? - (O_WRONLY|O_TRUNC|O_CREAT) : (O_WRONLY|O_TRUNC)) , 0666); + else fd = open(file, + FLAG(c) ? (O_WRONLY|O_TRUNC|O_CREAT) : (O_WRONLY|O_TRUNC), 0666); if (fd < 0) { g_errpkt[3] = TFTPD_ER_NOSUCHFILE; send_errpkt(dstaddr, socklen, "can't open file"); @@ -263,9 +263,9 @@ void tftpd_main(void) // request is either upload or Download. opcode = buf[1]; if (((opcode != TFTPD_OP_RRQ) && (opcode != TFTPD_OP_WRQ)) - || ((opcode == TFTPD_OP_WRQ) && (toys.optflags & FLAG_r))) { + || ((opcode == TFTPD_OP_WRQ) && FLAG(r))) { send_errpkt((struct sockaddr*)&dstaddr, socklen, - (opcode == TFTPD_OP_WRQ) ? "write error" : "packet format error"); + (opcode == TFTPD_OP_WRQ) ? "write error" : "packet format error"); return; } @@ -304,5 +304,5 @@ void tftpd_main(void) //do send / receive file. do_action((struct sockaddr*)&srcaddr, (struct sockaddr*)&dstaddr, socklen, toybuf + 2, opcode, tsize, blksize); - if (CFG_TOYBOX_FREE) close(STDIN_FILENO); + if (CFG_TOYBOX_FREE) close(0); } |