summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorEric Andersen2002-04-15 07:40:27 +0000
committerEric Andersen2002-04-15 07:40:27 +0000
commit744ec1d54962d79528eef40dce5913edf9f78c6d (patch)
tree604706c95dc8d150f44513492d10236fa284cce8 /networking
parent9fe5f98de48ec3ef3793a10e76fdf4a99d6038fe (diff)
downloadbusybox-744ec1d54962d79528eef40dce5913edf9f78c6d.zip
busybox-744ec1d54962d79528eef40dce5913edf9f78c6d.tar.gz
Patch from Ben Low <ben@titr.uow.edu.au> to allow tftp to work
with stdin as well as stdout.
Diffstat (limited to 'networking')
-rw-r--r--networking/tftp.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/networking/tftp.c b/networking/tftp.c
index a82415c..ec30725 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -548,17 +548,13 @@ int tftp_main(int argc, char **argv)
if ((cmd == 0) || (optind == argc)) {
show_usage();
}
- if(cmd == tftp_cmd_get) {
- if(localfile == NULL)
- localfile = remotefile;
- if(localfile && strcmp(localfile, "-") == 0) {
- fd = fileno(stdout);
- }
+ if(localfile && strcmp(localfile, "-") == 0) {
+ fd = fileno((cmd==tftp_cmd_get)? stdin : stdout);
}
- if(cmd == tftp_cmd_put)
- if(remotefile == NULL)
- remotefile = localfile;
-
+ if(localfile == NULL)
+ localfile = remotefile;
+ if(remotefile == NULL)
+ remotefile = localfile;
if (fd==-1) {
fd = open(localfile, flags, 0644);
}
@@ -582,7 +578,7 @@ int tftp_main(int argc, char **argv)
result = tftp(cmd, host, remotefile, fd, port, blocksize);
#ifdef CONFIG_FEATURE_CLEAN_UP
- if (fd!=fileno(stdout)) {
+ if (!(fd == fileno(stdout) || fd == fileno(stdin))) {
close(fd);
}
#endif