chiark / gitweb /
more options for backup
[chiark-utils.git] / cprogs / summer.c
index ee396c6f56f644ef9fdeda7cb52fb22680ee2e26..773719fb038715a0445b77db249fe5366125e05f 100644 (file)
@@ -25,7 +25,9 @@
 #define MAXDEPTH 1024
 #define CSUMXL 32
 
-static int quiet=0, hidectime=0, filenamefieldsep=' ';
+static int quiet=0, hidectime=0, hideatime=0;
+static int hidedirsizelinkcount=0, hidelinkmtime=0;
+static int filenamefieldsep=' ';
 static FILE *errfile;
 
 static void fn_escaped(FILE *f, const char *fn) {
@@ -160,14 +162,28 @@ static int item(const char *path, const struct stat *stab,
     else linktarg[r]= 0;
   }
 
-  printf(" %10lu %4d %4o %10ld %10ld %10lu %10lu",
-        (unsigned long)stab->st_size,
-        (int)stab->st_nlink,
+  if (S_ISDIR(stab->st_mode) && hidedirsizelinkcount)
+    printf(" %10s %4s","dir","dir");
+  else
+    printf(" %10lu %4d", 
+          (unsigned long)stab->st_size,
+          (int)stab->st_nlink);
+
+  printf(" %4o %10ld %10ld",
         (unsigned)stab->st_mode & 07777U,
         (unsigned long)stab->st_uid,
-        (unsigned long)stab->st_gid,
-        (unsigned long)stab->st_atime,
-        (unsigned long)stab->st_mtime);
+        (unsigned long)stab->st_gid);
+
+  if (!hideatime)
+    printf(" %10lu",
+          (unsigned long)stab->st_atime);
+
+  if (S_ISLNK(stab->st_mode) && hidelinkmtime)
+    printf(" %10s","link");
+  else
+    printf(" %10lu",
+          (unsigned long)stab->st_mtime);
+
   if (!hidectime)
     printf(" %10lu",
           (unsigned long)stab->st_ctime);
@@ -232,9 +248,18 @@ int main(int argc, const char *const *argv) {
       case 't':
        filenamefieldsep= '\t';
        break;
+      case 'D':
+       hidedirsizelinkcount= 1;
+       break;
+      case 'b':
+       hidelinkmtime= 1;
+       break;
       case 'C':
        hidectime= 1;
        break;
+      case 'A':
+       hideatime= 1;
+       break;
       case 'f':
        errfile= stdout;
        break;