aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-04-15 07:40:27 +0000
committerEric Andersen <andersen@codepoet.org>2002-04-15 07:40:27 +0000
commit744ec1d54962d79528eef40dce5913edf9f78c6d (patch)
tree604706c95dc8d150f44513492d10236fa284cce8
parent9fe5f98de48ec3ef3793a10e76fdf4a99d6038fe (diff)
downloadbusybox-w32-744ec1d54962d79528eef40dce5913edf9f78c6d.tar.gz
busybox-w32-744ec1d54962d79528eef40dce5913edf9f78c6d.tar.bz2
busybox-w32-744ec1d54962d79528eef40dce5913edf9f78c6d.zip
Patch from Ben Low <ben@titr.uow.edu.au> to allow tftp to work
with stdin as well as stdout.
-rw-r--r--networking/tftp.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/networking/tftp.c b/networking/tftp.c
index a82415c60..ec30725d2 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -548,17 +548,13 @@ int tftp_main(int argc, char **argv)
548 if ((cmd == 0) || (optind == argc)) { 548 if ((cmd == 0) || (optind == argc)) {
549 show_usage(); 549 show_usage();
550 } 550 }
551 if(cmd == tftp_cmd_get) { 551 if(localfile && strcmp(localfile, "-") == 0) {
552 if(localfile == NULL) 552 fd = fileno((cmd==tftp_cmd_get)? stdin : stdout);
553 localfile = remotefile;
554 if(localfile && strcmp(localfile, "-") == 0) {
555 fd = fileno(stdout);
556 }
557 } 553 }
558 if(cmd == tftp_cmd_put) 554 if(localfile == NULL)
559 if(remotefile == NULL) 555 localfile = remotefile;
560 remotefile = localfile; 556 if(remotefile == NULL)
561 557 remotefile = localfile;
562 if (fd==-1) { 558 if (fd==-1) {
563 fd = open(localfile, flags, 0644); 559 fd = open(localfile, flags, 0644);
564 } 560 }
@@ -582,7 +578,7 @@ int tftp_main(int argc, char **argv)
582 result = tftp(cmd, host, remotefile, fd, port, blocksize); 578 result = tftp(cmd, host, remotefile, fd, port, blocksize);
583 579
584#ifdef CONFIG_FEATURE_CLEAN_UP 580#ifdef CONFIG_FEATURE_CLEAN_UP
585 if (fd!=fileno(stdout)) { 581 if (!(fd == fileno(stdout) || fd == fileno(stdin))) {
586 close(fd); 582 close(fd);
587 } 583 }
588#endif 584#endif