nmrpd_args::filename -> file_local
authorJoseph C. Lehner <joseph.c.lehner@gmail.com>
Fri, 12 Feb 2016 13:16:55 +0000 (14:16 +0100)
committerJoseph C. Lehner <joseph.c.lehner@gmail.com>
Fri, 12 Feb 2016 13:16:55 +0000 (14:16 +0100)
main.c
nmrp.c
nmrpd.h
tftp.c

diff --git a/main.c b/main.c
index 36e0e4255c944f24ab7507226372ba6dceae03dd..45b406fbcdb668ce608ee308a15eb79e1b6542e7 100644 (file)
--- a/main.c
+++ b/main.c
@@ -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;
        }
diff --git a/nmrp.c b/nmrp.c
index 947329bd9e4b8d3d4513dac77bee579aa7e2ad73..e412a4f6f9222f9e1eb7f24e4c881d176524fa18 100644 (file)
--- a/nmrp.c
+++ b/nmrp.c
@@ -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);
diff --git a/nmrpd.h b/nmrpd.h
index ec39203ef89945c5d7476b7f52590f316cccdc8c..1e0997f9781bde83e3eb9f79c4b16d6f8820b8cf 100644 (file)
--- a/nmrpd.h
+++ b/nmrpd.h
@@ -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;
diff --git a/tftp.c b/tftp.c
index cbc9eba79635b842ea341d7869bcf4b5fda0aac7..e18c0aab665c22aaa618c4e2cb9eee372b25bb57 100644 (file)
--- a/tftp.c
+++ b/tftp.c
@@ -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) {