OSDN Git Service

Added -v option that prints version and copyright.
authorresver <resver@60bc1c72-a15a-11de-b98f-4500b42dc123>
Tue, 1 Mar 2011 05:35:14 +0000 (05:35 +0000)
committerresver <resver@60bc1c72-a15a-11de-b98f-4500b42dc123>
Tue, 1 Mar 2011 05:35:14 +0000 (05:35 +0000)
git-svn-id: http://exfat.googlecode.com/svn/trunk@213 60bc1c72-a15a-11de-b98f-4500b42dc123

dump/main.c
fsck/main.c
fuse/main.c
label/main.c
mkfs/main.c

index cec8d91..98bfe4f 100644 (file)
@@ -143,7 +143,7 @@ static int dump_full(const char* spec, int used_sectors)
 
 static void usage(const char* prog)
 {
-       fprintf(stderr, "Usage: %s [-s] [-u] <device>\n", prog);
+       fprintf(stderr, "Usage: %s [-s] [-u] [-v] <device>\n", prog);
        exit(1);
 }
 
@@ -154,12 +154,20 @@ int main(int argc, char* argv[])
        int sb_only = 0;
        int used_sectors = 0;
 
+       printf("dumpexfat %u.%u.%u\n",
+                       EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
+
        for (pp = argv + 1; *pp; pp++)
        {
                if (strcmp(*pp, "-s") == 0)
                        sb_only = 1;
                else if (strcmp(*pp, "-u") == 0)
                        used_sectors = 1;
+               else if (strcmp(*pp, "-v") == 0)
+               {
+                       puts("Copyright (C) 2010  Andrew Nayenko");
+                       return 0;
+               }
                else if (spec == NULL)
                        spec = *pp;
                else
index b0d8f3c..8eac2af 100644 (file)
@@ -113,22 +113,40 @@ static void fsck(struct exfat* ef)
        dirck(ef, "");
 }
 
+static void usage(const char* prog)
+{
+       fprintf(stderr, "Usage: %s [-v] <device>\n", prog);
+       exit(1);
+}
+
 int main(int argc, char* argv[])
 {
+       char** pp;
+       const char* spec = NULL;
        struct exfat ef;
 
-       if (argc != 2)
-       {
-               fprintf(stderr, "Usage: %s <device>\n", argv[0]);
-               return 1;
-       }
        printf("exfatfsck %u.%u.%u\n",
                        EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
 
-       if (exfat_mount(&ef, argv[1], "ro") != 0)
+       for (pp = argv + 1; *pp; pp++)
+       {
+               if (strcmp(*pp, "-v") == 0)
+               {
+                       puts("Copyright (C) 2009  Andrew Nayenko");
+                       return 0;
+               }
+               else if (spec == NULL)
+                       spec = *pp;
+               else
+                       usage(argv[0]);
+       }
+       if (spec == NULL)
+               usage(argv[0]);
+
+       if (exfat_mount(&ef, spec, "ro") != 0)
                return 1;
 
-       printf("Checking file system on %s.\n", argv[1]);
+       printf("Checking file system on %s.\n", spec);
        fsck(&ef);
        exfat_unmount(&ef);
        printf("Totally %"PRIu64" directories and %"PRIu64" files.\n",
index 61c7ff2..fe5666b 100644 (file)
@@ -258,7 +258,7 @@ static void fuse_exfat_destroy(void* unused)
 
 static void usage(const char* prog)
 {
-       fprintf(stderr, "Usage: %s [-d] [-o options] <device> <dir>\n", prog);
+       fprintf(stderr, "Usage: %s [-d] [-o options] [-v] <device> <dir>\n", prog);
        exit(1);
 }
 
@@ -398,6 +398,12 @@ int main(int argc, char* argv[])
                }
                else if (strcmp(*pp, "-d") == 0)
                        debug = 1;
+               else if (strcmp(*pp, "-v") == 0)
+               {
+                       free(mount_options);
+                       puts("Copyright (C) 2009  Andrew Nayenko");
+                       return 0;
+               }
                else if (spec == NULL)
                        spec = *pp;
                else if (mount_point == NULL)
index 73a753f..b4ee541 100644 (file)
 */
 
 #include <stdio.h>
+#include <string.h>
 #include <exfat.h>
 
 int main(int argc, char* argv[])
 {
+       char** pp;
        struct exfat ef;
        int rc = 0;
 
+       for (pp = argv + 1; *pp; pp++)
+               if (strcmp(*pp, "-v") == 0)
+               {
+                       printf("exfatlabel %u.%u.%u\n", EXFAT_VERSION_MAJOR,
+                                       EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
+                       puts("Copyright (C) 2011  Andrew Nayenko");
+                       return 0;
+               }
+
        if (argc != 2 && argc != 3)
        {
-               fprintf(stderr, "Usage: %s <device> [label]\n", argv[0]);
+               fprintf(stderr, "Usage: %s [-v] <device> [label]\n", argv[0]);
                return 1;
        }
 
index 7830ff8..782aa8a 100644 (file)
@@ -2,7 +2,7 @@
        main.c (15.08.10)
        Creates exFAT file system.
 
-       Copyright (C) 2009, 2010  Andrew Nayenko
+       Copyright (C) 2010  Andrew Nayenko
 
        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
@@ -360,7 +360,7 @@ static void usage(const char* prog)
 {
        fprintf(stderr, "Usage: %s [-i volume-id] [-n label] "
                        "[-p partition-first-sector] "
-                       "[-s sectors-per-cluster] <device>\n", prog);
+                       "[-s sectors-per-cluster] [-v] <device>\n", prog);
        exit(1);
 }
 
@@ -373,6 +373,9 @@ int main(int argc, char* argv[])
        uint32_t volume_serial = 0;
        int first_sector = 0;
 
+       printf("mkexfatfs %u.%u.%u\n",
+                       EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
+
        for (pp = argv + 1; *pp; pp++)
        {
                if (strcmp(*pp, "-s") == 0)
@@ -409,19 +412,18 @@ int main(int argc, char* argv[])
                                usage(argv[0]);
                        first_sector = atoi(*pp);
                }
-               else if (**pp == '-')
+               else if (strcmp(*pp, "-v") == 0)
                {
-                       exfat_error("unrecognized option `%s'", *pp);
-                       return 1;
+                       puts("Copyright (C) 2010  Andrew Nayenko");
+                       return 0;
                }
-               else
+               else if (spec == NULL)
                        spec = *pp;
+               else
+                       usage(argv[0]);
        }
        if (spec == NULL)
                usage(argv[0]);
 
-       printf("mkexfatfs %u.%u.%u\n",
-                       EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
-
        return mkfs(spec, 9, spc_bits, volume_label, volume_serial, first_sector);
 }