nmrpd_args::filename -> file_local

This commit is contained in:
Joseph C. Lehner 2016-02-12 14:16:55 +01:00
parent 9fd1b968b4
commit 98607d141b
4 changed files with 13 additions and 13 deletions

8
main.c
View file

@ -71,7 +71,7 @@ int main(int argc, char **argv)
.rx_timeout = 200,
.ul_timeout = 120000,
.tftpcmd = NULL,
.filename = NULL,
.file_local = NULL,
.ipaddr = NULL,
.ipmask = "255.255.255.0",
.intf = NULL,
@ -102,7 +102,7 @@ int main(int argc, char **argv)
args.tftpcmd = optarg;
break;
case 'f':
args.filename = optarg;
args.file_local = optarg;
break;
case 'i':
args.intf = optarg;
@ -148,7 +148,7 @@ int main(int argc, char **argv)
goto out;
#ifdef NMRPFLASH_TFTP_TEST
case 'U':
if (args.ipaddr && args.filename) {
if (args.ipaddr && args.file_local) {
val = tftp_put(&args);
goto out;
}
@ -161,7 +161,7 @@ int main(int argc, char **argv)
}
}
if ((!args.filename && !args.tftpcmd) || !args.intf || !args.ipaddr) {
if ((!args.file_local && !args.tftpcmd) || !args.intf || !args.ipaddr) {
usage(stderr);
return 1;
}

10
nmrp.c
View file

@ -310,8 +310,8 @@ int nmrp_do(struct nmrpd_args *args)
return 1;
}
if (strcmp(args->filename, "-") && access(args->filename, R_OK) == -1) {
fprintf(stderr, "Error accessing file '%s'.\n", args->filename);
if (strcmp(args->file_local, "-") && access(args->file_local, R_OK) == -1) {
fprintf(stderr, "Error accessing file '%s'.\n", args->file_local);
return 1;
}
@ -461,11 +461,11 @@ int nmrp_do(struct nmrpd_args *args)
}
}
if (!err && args->filename) {
if (!strcmp(args->filename, "-")) {
if (!err && args->file_local) {
if (!strcmp(args->file_local, "-")) {
printf("Uploading from stdin ... ");
} else {
printf("Uploading %s ... ", args->filename);
printf("Uploading %s ... ", args->file_local);
}
fflush(stdout);
err = tftp_put(args);

View file

@ -59,7 +59,7 @@ struct nmrpd_args {
unsigned rx_timeout;
unsigned ul_timeout;
const char *tftpcmd;
const char *filename;
const char *file_local;
const char *ipaddr;
const char *ipmask;
const char *intf;

6
tftp.c
View file

@ -234,10 +234,10 @@ int tftp_put(struct nmrpd_args *args)
sock = -1;
ret = -1;
if (!strcmp(args->filename, "-")) {
if (!strcmp(args->file_local, "-")) {
fd = STDIN_FILENO;
} else {
fd = open(args->filename, O_RDONLY);
fd = open(args->file_local, O_RDONLY);
if (fd < 0) {
perror("open");
ret = fd;
@ -267,7 +267,7 @@ int tftp_put(struct nmrpd_args *args)
/* Not really, but this way the loop sends our WRQ before receiving */
timeout = 1;
pkt_mkwrq(tx, args->filename);
pkt_mkwrq(tx, args->file_local);
do {
if (!timeout && pkt_num(rx) == ACK) {