]> andersk Git - moira.git/blobdiff - dbck/dbck.qc
Used /bin/sh format instead of /bin/csh format, by accident.
[moira.git] / dbck / dbck.qc
index 4728253e8fec3325620b7bc774eb04b9e5de3a19..5595702aa521627a777270b88c12e21a99f6d1f5 100644 (file)
@@ -1,6 +1,6 @@
 /* $Header$
  *
- * SMS database consistency checker
+ * Moira database consistency checker
  *
  *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
  *  For copying and distribution information, please see the file
 #include "dbck.h"
 
 
-int debug = 1;
+static char dbck_qc_rcsid[] = "$Header$";
+
+
+int debug = 0;
 int mode = MODE_ASK;
 int fast = 0;
-struct hash *users, *machines, *clusters, *lists, *filesys, *nfsphys, *strings;
+int warn = 1;
+int abort = 0;
+struct hash *users, *machines, *clusters, *lists, *filesys, *nfsphys;
+struct hash *strings, *members;
 ##int dcmenable;
-int cleanup();
+struct save_queue *modtables, *sq_create();
+int interrupt();
 
 
 main(argc, argv)
@@ -57,6 +64,13 @@ char **argv;
          case 'f':
              fast++;
              break;
+         case 'w':
+             warn = 0;
+             break;
+         default:
+             printf("Usage: %s [-d level] [-n] [-y] [-p] [-a] [-c] [-f] [-w] [database]\n",
+                    argv[0]);
+             exit(1);
          }
        else
          database = *arg;
@@ -74,9 +88,12 @@ char **argv;
     if (debug)
       printf("Debug level is %d\n", debug);
 
-    signal(SIGHUP, cleanup);
-    signal(SIGQUIT, cleanup);
-    signal(SIGINT, cleanup);
+    setlinebuf(stdout);
+
+    signal(SIGHUP, interrupt);
+    signal(SIGQUIT, interrupt);
+    signal(SIGINT, interrupt);
+    modtables = sq_create();
 
     IIseterr(ingerr);
     printf("Opening database %s...", database);
@@ -94,15 +111,13 @@ char **argv;
        phase2();
        phase3();
     } else {
-       printf("Skipping to counts\n");
        count_only_setup();
     }
     phase4();
 
 ##  end transaction
-##  replace values (value = dcmenable) where values.name = "dcm_enable"
+    cleanup();
     printf("Done.\n");
-##  exit
     exit(0);
 }
 
@@ -111,16 +126,60 @@ int       *num;
 {
     printf("An ingres error occuurred, code %d\n", *num);
     printf("Aborting...\n");
-##  abort
+    if (!abort) {
+       abort++;
+##     abort
+    }
     exit(1);
 }
 
 
-int cleanup()
+int interrupt()
 ##{
-    printf("Signal caught, aborting transaction\n");
-##  abort
+    printf("Signal caught\n");
+    if (prompt("Save database changes")) {
+       /* break out of a retrieve loop */
+       IIbreak();
+##     end transaction
+       cleanup();
+       exit(0);
+    }
+    printf("Aborting transaction\n");
+    if (!abort) {
+       abort++;
+       /* break out of a retrieve loop */
+       IIbreak();
+##     abort
+    }
 ##  replace values (value = dcmenable) where values.name = "dcm_enable"
 ##  exit
     exit(0);
 ##}
+
+
+modified(table)
+char *table;
+{
+    sq_save_unique_string(modtables, table);
+}
+
+cleanup()
+##{
+##  char *tab;
+
+    while (sq_get_data(modtables, &tab)) {
+##     replace tblstats (modtime = "now") where tblstats.table = tab
+    }
+##  replace values (value = dcmenable) where values.name = "dcm_enable"
+##  exit
+##}
+
+
+out_of_mem(msg)
+char *msg;
+{
+    fprintf(stderr, "Out of memory while %s\n", msg);
+##  end transaction    
+    cleanup();
+    exit(1);
+}
This page took 0.171237 seconds and 4 git commands to generate.