aboutsummaryrefslogtreecommitdiff
path: root/networking/tftp.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-04-13 09:30:25 +0000
committerEric Andersen <andersen@codepoet.org>2002-04-13 09:30:25 +0000
commita66a43e8ef1e55c2415aa7084365cce3fb8f931a (patch)
tree04d785696700dd92b807648550396e965cfaada8 /networking/tftp.c
parentd75ac02a4ffb6c843794d8f7d745ee083bdb0516 (diff)
downloadbusybox-w32-a66a43e8ef1e55c2415aa7084365cce3fb8f931a.tar.gz
busybox-w32-a66a43e8ef1e55c2415aa7084365cce3fb8f931a.tar.bz2
busybox-w32-a66a43e8ef1e55c2415aa7084365cce3fb8f931a.zip
Teach tftp to direct the fetched file to stdout when the
user specifies "-l -" -Erik
Diffstat (limited to 'networking/tftp.c')
-rw-r--r--networking/tftp.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/networking/tftp.c b/networking/tftp.c
index c03776459..a82415c60 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -548,15 +548,20 @@ 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(cmd == tftp_cmd_get) {
552 if(localfile == NULL) 552 if(localfile == NULL)
553 localfile = remotefile; 553 localfile = remotefile;
554 554 if(localfile && strcmp(localfile, "-") == 0) {
555 fd = fileno(stdout);
556 }
557 }
555 if(cmd == tftp_cmd_put) 558 if(cmd == tftp_cmd_put)
556 if(remotefile == NULL) 559 if(remotefile == NULL)
557 remotefile = localfile; 560 remotefile = localfile;
558 561
559 fd = open(localfile, flags, 0644); 562 if (fd==-1) {
563 fd = open(localfile, flags, 0644);
564 }
560 if (fd < 0) { 565 if (fd < 0) {
561 perror_msg_and_die("local file"); 566 perror_msg_and_die("local file");
562 } 567 }
@@ -577,7 +582,9 @@ int tftp_main(int argc, char **argv)
577 result = tftp(cmd, host, remotefile, fd, port, blocksize); 582 result = tftp(cmd, host, remotefile, fd, port, blocksize);
578 583
579#ifdef CONFIG_FEATURE_CLEAN_UP 584#ifdef CONFIG_FEATURE_CLEAN_UP
580 close(fd); 585 if (fd!=fileno(stdout)) {
586 close(fd);
587 }
581#endif 588#endif
582 return(result); 589 return(result);
583} 590}