aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2002-04-13 09:30:25 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2002-04-13 09:30:25 +0000
commit34a02c12154e5a3580480213201f0c5ea558ab60 (patch)
tree04d785696700dd92b807648550396e965cfaada8
parent759fd3643afed8a66924fb419588dc711e604754 (diff)
downloadbusybox-w32-34a02c12154e5a3580480213201f0c5ea558ab60.tar.gz
busybox-w32-34a02c12154e5a3580480213201f0c5ea558ab60.tar.bz2
busybox-w32-34a02c12154e5a3580480213201f0c5ea558ab60.zip
Teach tftp to direct the fetched file to stdout when the
user specifies "-l -" -Erik git-svn-id: svn://busybox.net/trunk/busybox@4604 69ca8d6d-28ef-0310-b511-8ec308f3f277
-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}