Teach tftp to direct the fetched file to stdout when the

user specifies "-l -"
 -Erik
This commit is contained in:
Eric Andersen 2002-04-13 09:30:25 +00:00
parent d75ac02a4f
commit a66a43e8ef

View File

@ -548,15 +548,20 @@ int tftp_main(int argc, char **argv)
if ((cmd == 0) || (optind == argc)) { if ((cmd == 0) || (optind == argc)) {
show_usage(); show_usage();
} }
if(cmd == tftp_cmd_get) if(cmd == tftp_cmd_get) {
if(localfile == NULL) if(localfile == NULL)
localfile = remotefile; localfile = remotefile;
if(localfile && strcmp(localfile, "-") == 0) {
fd = fileno(stdout);
}
}
if(cmd == tftp_cmd_put) if(cmd == tftp_cmd_put)
if(remotefile == NULL) if(remotefile == NULL)
remotefile = localfile; remotefile = localfile;
if (fd==-1) {
fd = open(localfile, flags, 0644); fd = open(localfile, flags, 0644);
}
if (fd < 0) { if (fd < 0) {
perror_msg_and_die("local file"); 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); result = tftp(cmd, host, remotefile, fd, port, blocksize);
#ifdef CONFIG_FEATURE_CLEAN_UP #ifdef CONFIG_FEATURE_CLEAN_UP
if (fd!=fileno(stdout)) {
close(fd); close(fd);
}
#endif #endif
return(result); return(result);
} }