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;
|
||||
}
|
||||
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
|
|
14
tftp.c
14
tftp.c
|
@ -232,11 +232,15 @@ int tftp_put(struct nmrpd_args *args)
|
|||
sock = -1;
|
||||
ret = -1;
|
||||
|
||||
fd = open(args->filename, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
perror("open");
|
||||
ret = fd;
|
||||
goto cleanup;
|
||||
if (!strcmp(args->filename, "-")) {
|
||||
fd = STDIN_FILENO;
|
||||
} else {
|
||||
fd = open(args->filename, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
perror("open");
|
||||
ret = fd;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
|
|
Loading…
Add table
Reference in a new issue