From 34a02c12154e5a3580480213201f0c5ea558ab60 Mon Sep 17 00:00:00 2001 From: andersen Date: Sat, 13 Apr 2002 09:30:25 +0000 Subject: 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 --- networking/tftp.c | 15 +++++++++++---- 1 file 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) 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); } -- cgit v1.2.3-55-g6feb