]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
windows portability fix (review by mgraff)
authorEvan Hunt <each@isc.org>
Sun, 19 Jul 2009 05:26:05 +0000 (05:26 +0000)
committerEvan Hunt <each@isc.org>
Sun, 19 Jul 2009 05:26:05 +0000 (05:26 +0000)
bin/dnssec/dnssec-revoke.c
bin/dnssec/dnssec-settime.c

index a1bef44cd7f5e6953427c3259ada0ba017e2523f..613ceec45d2029a2a5eaab1c0fd5f266d2fbc1d0 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dnssec-revoke.c,v 1.5 2009/07/19 04:18:04 each Exp $ */
+/* $Id: dnssec-revoke.c,v 1.6 2009/07/19 05:26:05 each Exp $ */
 
 /*! \file */
 
@@ -133,6 +133,7 @@ main(int argc, char **argv) {
 #endif
 
                dir = strdup(argv[isc_commandline_index]);
+               filename = dir;
 
                /* Figure out the directory name from the key name */
                slash = strrchr(dir, '/');
@@ -142,16 +143,15 @@ main(int argc, char **argv) {
                    (slash == NULL && backslash != NULL))
                        slash = backslash;
 #endif
-               if (slash != NULL)
+               if (slash != NULL) {
                        *slash++ = '\0';
-               else {
+                       filename = slash;
+               } else {
                        free(dir);
                        dir = strdup(".");
                }
        }
 
-       filename = argv[isc_commandline_index];
-
        if (ectx == NULL)
                setup_entropy(mctx, NULL, &ectx);
        result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
index c1199c562be6ec609f8f4b82a78ef4ccfa6a3f05..26ba8656c5d7ac9e6352c28e0842a18e4c619367 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dnssec-settime.c,v 1.3 2009/07/19 05:06:48 each Exp $ */
+/* $Id: dnssec-settime.c,v 1.4 2009/07/19 05:26:05 each Exp $ */
 
 /*! \file */
 
@@ -179,9 +179,33 @@ main(int argc, char **argv) {
        if (argc > isc_commandline_index + 1)
                fatal("Extraneous arguments");
 
-       if (directory == NULL)
-               directory = dirname(argv[isc_commandline_index]);
-       filename = basename(argv[isc_commandline_index]);
+       if (directory == NULL) {
+               char *slash;
+#ifdef _WIN32
+               char *backslash;
+#endif
+
+               directory = strdup(argv[isc_commandline_index]);
+               filename = directory;
+
+               /* Figure out the directory name from the key name */
+               slash = strrchr(directory, '/');
+#ifdef _WIN32
+               backslash = strrchr(directory, '\\');
+               if ((slash != NULL && backslash != NULL && backslash > slash) ||
+                   (slash == NULL && backslash != NULL))
+                       slash = backslash;
+#endif
+               if (slash != NULL) {
+                       *slash++ = '\0';
+                       filename = slash;
+               } else {
+                       free(directory);
+                       directory = strdup(".");
+               }
+       }
+
+       filename = argv[isc_commandline_index];
 
        if (ectx == NULL)
                setup_entropy(mctx, NULL, &ectx);