]> arthur.barton.de Git - netatalk.git/blobdiff - bin/cnid/ad_ls.c
Merge branch 'branch-netatalk-2-1' of ssh://netatalk.git.sourceforge.net/gitroot...
[netatalk.git] / bin / cnid / ad_ls.c
index 58ab5d99ac6a3870be7fd108d08f7666f5c16897..cd6545e15c49c9412b179fb3ba3a725605c974ed 100644 (file)
@@ -1,5 +1,5 @@
 /* 
-   $Id: ad_ls.c,v 1.1 2009-09-01 14:28:07 franklahm Exp $
+   $Id: ad_ls.c,v 1.4 2009-10-14 01:38:28 didg Exp $
 
    Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
    
@@ -88,7 +88,7 @@ static const char *check_netatalk_dirs(const char *name)
 }
 
 
-static void usage_ls()
+static void usage_ls(void)
 {
     printf(
         "Usage: ad ls [-dRl[u]] [file|dir, ...]\n\n"
@@ -184,6 +184,8 @@ static void print_flags(char *path, afpvol_t *vol, const struct stat *st)
     uint16_t AFPattributes;
     char type[5] = "----";
     char creator[5] = "----";
+    int i;
+    uint32_t cnid;
 
     if (S_ISDIR(st->st_mode))
         adflags = ADFLAGS_DIR;
@@ -319,7 +321,6 @@ static void print_flags(char *path, afpvol_t *vol, const struct stat *st)
     printf(" %s ", labels[(FinderFlags & FINDERINFO_COLOR) >> 1]);
 
     /* Type & Creator */
-    int i;
     for(i=0; i<4; i++) {
         if (isalnum(type[i]))
             putchar(type[i]);
@@ -336,7 +337,7 @@ static void print_flags(char *path, afpvol_t *vol, const struct stat *st)
     putchar(' '); 
 
     /* CNID */
-    uint32_t cnid = ad_forcegetid(&ad);
+    cnid = ad_forcegetid(&ad);
     if (cnid)
         printf(" %10u ", ntohl(cnid));
     else
@@ -406,7 +407,7 @@ static void print_mode(const struct stat *st)
 #undef TYPE
 #undef MODE
 
-int ad_print(char *path, const struct stat *st, afpvol_t *vol)
+static int ad_print(char *path, const struct stat *st, afpvol_t *vol)
 {
     if ( ! ls_l) {
         printf("%s  ", path);
@@ -431,7 +432,7 @@ int ad_print(char *path, const struct stat *st, afpvol_t *vol)
     return 0;
 }
 
-int ad_ls_r(char *path, afpvol_t *vol)
+static int ad_ls_r(char *path, afpvol_t *vol)
 {
     int ret = 0, cwd, dirprinted = 0, dirempty;
     const char *name;
@@ -519,9 +520,9 @@ int ad_ls_r(char *path, afpvol_t *vol)
             if ((name = check_netatalk_dirs(ep->d_name)) != NULL)
                 continue;
 
-            if (lstat(ep->d_name, &st) < 0) {
+            if ((ret = lstat(ep->d_name, &st)) < 0) {
                 perror("Can't stat");
-                return -1;
+                goto exit;
             }
 
             /* Recursion */
@@ -584,10 +585,11 @@ int ad_ls(int argc, char **argv)
         freevol(&vol);
     }
     else {
+        int havefile = 0;
+
         firstarg = optind;
 
         /* First run: only print files from argv paths */
-        int havefile = 0;
         while(optind < argc) {
             if (stat(argv[optind], &st) != 0)
                 goto next;