Support reading from stdin using "-f -"
This commit is contained in:
parent
c21921c5ce
commit
936219b598
2 changed files with 10 additions and 6 deletions
2
nmrp.c
2
nmrp.c
|
@ -290,7 +290,7 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access(args->filename, R_OK) == -1) {
|
if (strcmp(args->filename, "-") && access(args->filename, R_OK) == -1) {
|
||||||
fprintf(stderr, "Error accessing file '%s'.\n", args->filename);
|
fprintf(stderr, "Error accessing file '%s'.\n", args->filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
14
tftp.c
14
tftp.c
|
@ -232,11 +232,15 @@ int tftp_put(struct nmrpd_args *args)
|
||||||
sock = -1;
|
sock = -1;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
fd = open(args->filename, O_RDONLY);
|
if (!strcmp(args->filename, "-")) {
|
||||||
if (fd < 0) {
|
fd = STDIN_FILENO;
|
||||||
perror("open");
|
} else {
|
||||||
ret = fd;
|
fd = open(args->filename, O_RDONLY);
|
||||||
goto cleanup;
|
if (fd < 0) {
|
||||||
|
perror("open");
|
||||||
|
ret = fd;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
|
|
Loading…
Add table
Reference in a new issue