]> arthur.barton.de Git - netatalk.git/blobdiff - bin/adv1tov2/adv1tov2.c
Remove bdb env on exit
[netatalk.git] / bin / adv1tov2 / adv1tov2.c
index c52ff072e5264092963dae0f5da39dd6810d11bb..eade898b5d3fba6a8f89e88dd2574ff7f83a76f7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: adv1tov2.c,v 1.3 2001-06-29 14:14:46 rufustfirefly Exp $
+ * $Id: adv1tov2.c,v 1.5 2009-10-14 01:38:28 didg Exp $
  * v1tov2: given a root directory, run down and convert all the
  * files/directories into appledouble v2.
  */
@@ -8,6 +8,7 @@
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
 
+#include <atalk/adouble.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <dirent.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/param.h>
+#include <errno.h>
+#include <string.h>
 
-#include <atalk/adouble.h>
+#include <atalk/util.h>
 
 #if AD_VERSION == AD_VERSION2
+#if 0
 /* translate characters */
-static int xlate(char *name, int flags) {
+static void xlate(char *name, int flags) {
   static const char hexdig[] = "0123456789abcdef";
   char upath[MAXPATHLEN + 1];
   char *m, *u;
@@ -52,21 +56,21 @@ static int xlate(char *name, int flags) {
       rename(ad_path(name, flags), ad_path(upath, flags)); /* rename rfork */
   }
 }
-
+#endif
 
 #define MAXDESCEND 0xFFFF
 /* recursively descend subdirectories. 
  * oh the stack space we use up! */
-void descend(DIR *dp)
+static void descend(DIR *dp)
 {
   DIR *dpnew;
   struct dirent *de;
-  unsigned char *m, *u;
   struct stat st;
   struct adouble ad;
   int flags;
   static int count = 0;
 
+  ad_init(&ad, AD_VERSION2, 0);
   if (count++ > MAXDESCEND) {
     fprintf(stderr, "FAILURE: too many subdirectories! possible infinite recursion.");
     return;
@@ -93,11 +97,11 @@ void descend(DIR *dp)
     }
 
     if (ad_open(de->d_name, flags, O_RDWR, 0, &ad) < 0) {
-      fprintf(stderr, "FAILURE: can't convert %s\n", de->d_name);
+      if (errno != ENOENT)
+          fprintf(stderr, "\nFAILURE: can't convert %s, %s\n", fullpathname(de->d_name), strerror(errno));
       continue;
     }
     ad_close(&ad, ADFLAGS_HF);
-    xlate(de->d_name, flags);
     fputc('.', stderr);
   }
   putc(')', stderr);
@@ -109,6 +113,7 @@ int main(int argc, char **argv)
   DIR           *dp;
   struct adouble ad;
  
+  ad_init(&ad, AD_VERSION2, 0);
   if (argc != 2) {
     fprintf(stderr, "%s <directory>\n", *argv);
     return -1;
@@ -132,7 +137,6 @@ int main(int argc, char **argv)
   closedir(dp);
   chdir("..");
 
-  xlate(argv[1], ADFLAGS_HF | ADFLAGS_DIR);
   putc('\n', stderr);
   return 0;
 }