]> andersk Git - moira.git/blobdiff - dbck/phase4.pc
second code style cleanup: void/void * usage, proper #includes. try to
[moira.git] / dbck / phase4.pc
index a6ee75f487565590771d11ca6e1063b32352a670..9aba12e09a2eb208eb82c4e340afadb99c972dba 100644 (file)
@@ -1,29 +1,38 @@
-/* $Header$
+/* $Id$
  *
- *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+ * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
 #include <mit-copyright.h>
-#include <stdlib.h>
 #include <moira.h>
 #include "dbck.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
 EXEC SQL INCLUDE sqlca;
 
-static char phase4_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
 
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
-count_boxes(int id, struct user *u, struct hash *boxes)
+void count_boxes(int id, void *user, void *boxes);
+void check_box_counts(int id, void *cnt, void *counts);
+void check_nfs_counts(int id, void *nfsphys, void *hint);
+
+void count_boxes(int id, void *user, void *boxes)
 {
+  struct user *u = user;
   int i;
 
   if (u->potype == 'P')
     {
       if ((i = (int) hash_lookup(boxes, u->pobox_id)))
        {
-         if (hash_store(boxes, u->pobox_id, i + 1) == -1)
+         if (hash_store(boxes, u->pobox_id, (void *)(i + 1)) == -1)
            out_of_mem("storing poboxes in hash table");
        }
       else
@@ -36,19 +45,19 @@ count_boxes(int id, struct user *u, struct hash *boxes)
 }
 
 
-check_box_counts(int id, int cnt, struct hash *counts)
+void check_box_counts(int id, void *cnt, void *counts)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  int oldval, rowcount, iid = id, icnt = cnt;
+  int oldval, rowcount, iid = id, icnt = (int)cnt;
   EXEC SQL END DECLARE SECTION;
 
   oldval = (int) hash_lookup(counts, id);
-  cnt--;
-  if (oldval != cnt)
+  icnt--;
+  if (oldval != icnt)
     {
       printf("Count wrong on POBox machine %s; is %d in db, counted %d\n",
             ((struct machine *) hash_lookup(machines, id))->name,
-            oldval, cnt);
+            oldval, icnt);
       if (single_fix("Update", 1))
        {
          EXEC SQL UPDATE serverhosts SET value1 = :icnt
@@ -64,8 +73,9 @@ check_box_counts(int id, int cnt, struct hash *counts)
 }
 
 
-check_nfs_counts(int id, struct nfsphys *n, int hint)
+void check_nfs_counts(int id, void *nfsphys, void *hint)
 {
+  struct nfsphys *n = nfsphys;
   EXEC SQL BEGIN DECLARE SECTION;
   int iid = id, val, rowcount;
   EXEC SQL END DECLARE SECTION;
@@ -91,7 +101,7 @@ check_nfs_counts(int id, struct nfsphys *n, int hint)
 }
 
 
-phase4(void)
+void phase4(void)
 {
   struct hash *boxes, *counts;
   int id, cnt;
@@ -111,9 +121,9 @@ phase4(void)
       if (sqlca.sqlcode)
        break;
 
-      if (hash_store(boxes, id, 1) == -1)
+      if (hash_store(boxes, id, (void *)1) == -1)
        out_of_mem("storing poboxes");
-      if (hash_store(counts, id, cnt) == -1)
+      if (hash_store(counts, id, (void *)cnt) == -1)
        out_of_mem("storing pobox counts in hash table");
     }
   EXEC SQL CLOSE csr401;
@@ -125,13 +135,12 @@ phase4(void)
 }
 
 
-count_only_setup(void)
+void count_only_setup(void)
 {
   EXEC SQL BEGIN DECLARE SECTION;
   int id, status, id2, id3;
   char name[33], last[17], first[17], buf[257];
   EXEC SQL END DECLARE SECTION;
-  struct save_queue *sq;
   struct user *u;
   struct nfsphys *n;
   struct machine *m;
@@ -156,7 +165,7 @@ count_only_setup(void)
       strcpy(u->login, strtrim(name));
       u->potype = buf[0];
       sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
-      u->fullname = strsave(buf);
+      u->fullname = strdup(buf);
       u->status = status;
       u->users_id = id;
       switch (u->potype)
@@ -230,7 +239,7 @@ count_only_setup(void)
       if (sqlca.sqlcode)
        break;
 
-      if (n = (struct nfsphys  *) hash_lookup(nfsphys, id))
+      if ((n = hash_lookup(nfsphys, id)))
        n->count += id2;
     }
   EXEC SQL CLOSE csr405;
This page took 0.493758 seconds and 4 git commands to generate.