chiark / gitweb /
copyright dates, contact details, and similar admin fixes
[chiark-utils.git] / cprogs / summer.c
index 5e85111218c6a35567604c31edf2739c3d91adea..66c790a0fe8e6c7810979835a5fd085a0c844bcb 100644 (file)
@@ -1,9 +1,29 @@
 /*
+ * summer - program for summarising (with md5 checksums) filesystem trees
+ *
  * usage:
  *    cat startpoints.list | summer >data.list
  *    summer startpoints... >data.list
  *  prints md5sum of data-list to stderr
  */
+/*
+ * Copyright (C) 2003,2006-2007 Ian Jackson <ian@davenant.greenend.org.uk>
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 3,
+ * or (at your option) any later version.
+ *
+ * This is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this file; if not, consult the Free Software
+ * Foundation's website at www.fsf.org, or the GNU Project website at
+ * www.gnu.org.
+ */
 
 #define _GNU_SOURCE
 
@@ -26,7 +46,7 @@
 #define MAXDEPTH 1024
 #define CSUMXL 32
 
-static int quiet=0, hidectime=0, hideatime=0;
+static int quiet=0, hidectime=0, hideatime=0, hidemtime=0;
 static int hidedirsize=0, hidelinkmtime=0, onefilesystem=0;
 static int filenamefieldsep=' ';
 static FILE *errfile;
@@ -238,14 +258,16 @@ static void node(const char *path, unsigned nodeflags, dev_t fs) {
       pu10();
   }
 
-  if (stab)
-    if (S_ISLNK(stab->st_mode) && hidelinkmtime)
-      printf(" %10s","link");
+  if (!hidemtime) {
+    if (stab)
+      if (S_ISLNK(stab->st_mode) && hidelinkmtime)
+       printf(" %10s","link");
+      else
+       printf(" %10lu",
+              (unsigned long)stab->st_mtime);
     else
-      printf(" %10lu",
-            (unsigned long)stab->st_mtime);
-  else
-    pu10();
+      pu10();
+  }
 
   if (!hidectime) {
     if (stab)
@@ -359,7 +381,7 @@ int main(int argc, const char *const *argv) {
 
   errfile= stderr;
   
-  if ((arg=argv[1]) && *arg++=='-') {
+  while ((arg=argv[1]) && *arg++=='-') {
     while ((c=*arg++)) {
       switch (c) {
       case 'h':
@@ -388,6 +410,9 @@ int main(int argc, const char *const *argv) {
       case 'A':
        hideatime= 1;
        break;
+      case 'M':
+       hidemtime= 1;
+       break;
       case 'f':
        errfile= stdout;
        break;