diff options
author | Eric Andersen | 2002-04-13 09:30:25 +0000 |
---|---|---|
committer | Eric Andersen | 2002-04-13 09:30:25 +0000 |
commit | a66a43e8ef1e55c2415aa7084365cce3fb8f931a (patch) | |
tree | 04d785696700dd92b807648550396e965cfaada8 /networking/tftp.c | |
parent | d75ac02a4ffb6c843794d8f7d745ee083bdb0516 (diff) | |
download | busybox-a66a43e8ef1e55c2415aa7084365cce3fb8f931a.zip busybox-a66a43e8ef1e55c2415aa7084365cce3fb8f931a.tar.gz |
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.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/networking/tftp.c b/networking/tftp.c index c037764..a82415c 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -548,15 +548,20 @@ int tftp_main(int argc, char **argv) if ((cmd == 0) || (optind == argc)) { show_usage(); } - if(cmd == tftp_cmd_get) + if(cmd == tftp_cmd_get) { if(localfile == NULL) localfile = remotefile; - + if(localfile && strcmp(localfile, "-") == 0) { + fd = fileno(stdout); + } + } if(cmd == tftp_cmd_put) if(remotefile == NULL) remotefile = localfile; - fd = open(localfile, flags, 0644); + if (fd==-1) { + fd = open(localfile, flags, 0644); + } if (fd < 0) { perror_msg_and_die("local file"); } @@ -577,7 +582,9 @@ int tftp_main(int argc, char **argv) result = tftp(cmd, host, remotefile, fd, port, blocksize); #ifdef CONFIG_FEATURE_CLEAN_UP - close(fd); + if (fd!=fileno(stdout)) { + close(fd); + } #endif return(result); } |