]> andersk Git - moira.git/blobdiff - dbck/phase1.pc
Use mrcl_connect() so we send a query version.
[moira.git] / dbck / phase1.pc
index 52b06b758fbe060027accb9783f1916cc3fa48f4..6eb3881cc009184f3228257c38edb0e1441041ea 100644 (file)
@@ -1,29 +1,54 @@
-/* $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 <moira.h>
+#include "dbck.h"
+
 #include <stdio.h>
 #include <stdlib.h>
-#include "dbck.h"
+#include <string.h>
 EXEC SQL INCLUDE sqlca;
 
-static char phase1_qc_rcsid[] = "$Header$";
+RCSID("$Header$");
 
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
-
-int show_user_id(struct user *u)
+int show_user_id(void *user);
+void handle_duplicate_logins(struct save_queue *sq);
+void fix_user_id(void *user);
+void cant_fix(void *id);
+int show_mach_id(void *machine);
+int show_mach_name(void *machine);
+void fix_mach_id(void *machine);
+int show_snet_name(void *subnet);
+int show_clu_id(void *cluster);
+int show_clu_name(void *cluster);
+void fix_clu_id(void *cluster);
+int show_list_id(void *list);
+int show_list_name(void *list);
+void fix_list_id(void *list);
+int show_fs_id(void *filesys);
+void fix_fs_id(void *filesys);
+int show_fs_name(void *fs);
+int show_np_id(void *nfsphys);
+void fix_np_id(void *nfsphys);
+int show_str_id(void *string);
+int print_str_id(void *id);
+void print_dup_map(int key, void *data, void *hint);
+
+int show_user_id(void *user)
 {
+  struct user *u = user;
   printf("User %s (%s, status %d) has duplicate ID\n",
         u->login, u->fullname, u->status);
   return 0;
 }
 
-handle_duplicate_logins(struct save_queue *sq)
+void handle_duplicate_logins(struct save_queue *sq)
 {
   struct user *u, *uu, *tmp;
 
@@ -45,9 +70,9 @@ handle_duplicate_logins(struct save_queue *sq)
              printf("User %s (%s, status %d) have duplicate logins\n",
                     uu->login, uu->fullname, uu->status);
              if (!strcmp(u->fullname, uu->fullname) &&
-                 single_fix("Delete the second one"))
+                 single_fix("Delete the second one", 0))
                single_delete("users", "users_id", uu->users_id);
-             else if (single_fix("Unregister the second one"))
+             else if (single_fix("Unregister the second one", 0))
                {
                  EXEC SQL BEGIN DECLARE SECTION;
                  int id = uu->users_id, rowcount;
@@ -73,131 +98,146 @@ handle_duplicate_logins(struct save_queue *sq)
     }
 }
 
-fix_user_id(struct user *u)
+void fix_user_id(void *user)
 {
+  struct user *u = user;
   u->users_id = generic_fix_id("users", "users_id", "login",
                               u->users_id, u->login);
 }
 
 
-cant_fix(int id)
+void cant_fix(void *id)
 {
   printf("Sorry, don't know how to fix that\n");
 }
 
-int show_mach_id(struct machine *m)
+int show_mach_id(void *machine)
 {
+  struct machine *m = machine;
   printf("Machine %s has duplicate ID %d\n", m->name, m->mach_id);
   return 0;
 }
 
-int show_mach_name(struct machine *m)
+int show_mach_name(void *machine)
 {
+  struct machine *m = machine;
   printf("Machine %s (%d) has duplicate name\n", m->name, m->mach_id);
   return 0;
 }
 
-fix_mach_id(struct machine *m)
+void fix_mach_id(void *machine)
 {
+  struct machine *m = machine;
   m->mach_id = generic_fix_id("machine", "mach_id", "name",
                              m->mach_id, m->name);
 }
 
-int show_snet_name(struct subnet *s)
+int show_snet_name(void *subnet)
 {
+  struct subnet *s = subnet;
   printf("Subnet %s (%d) has duplicate name\n", s->name, s->snet_id);
   return 0;
 }
 
-int show_clu_id(struct cluster *c)
+int show_clu_id(void *cluster)
 {
+  struct cluster *c = cluster;
   printf("Cluster %s has duplicate ID %d\n", c->name, c->clu_id);
   return 0;
 }
 
-int show_clu_name(struct cluster *c)
+int show_clu_name(void *cluster)
 {
+  struct cluster *c = cluster;
   printf("Cluster %s (%d) has duplicate name\n", c->name, c->clu_id);
   return 0;
 }
 
-fix_clu_id(struct cluster *c)
+void fix_clu_id(void *cluster)
 {
+  struct cluster *c = cluster;
   c->clu_id = generic_fix_id("cluster", "clu_id", "name", c->clu_id, c->name);
 }
 
-int show_list_id(struct list *l)
+int show_list_id(void *list)
 {
+  struct list *l = list;
   printf("List %s has duplicate ID %d\n", l->name, l->list_id);
   return 0;
 }
 
-int show_list_name(struct list *l)
+int show_list_name(void *list)
 {
+  struct list *l = list;
   printf("List %s (%d) has duplicate name\n", l->name, l->list_id);
   return 0;
 }
 
-fix_list_id(struct list *l)
+void fix_list_id(void *list)
 {
+  struct list *l = list;
   l->list_id = generic_fix_id("list", "list_id", "name", l->list_id, l->name);
 }
 
-int show_fs_id(struct filesys *f)
+int show_fs_id(void *filesys)
 {
+  struct filesys *f = filesys;
   printf("Filesys %s has duplicate ID %d\n", f->name, f->filsys_id);
   return 0;
 }
 
-fix_fs_id(struct filesys *f)
+void fix_fs_id(void *filesys)
 {
+  struct filesys *f = filesys;
   f->filsys_id = generic_fix_id("filesys", "filsys_id", "label",
                                f->filsys_id, f->name);
 }
 
-int show_fs_name(struct filesys *fs)
+int show_fs_name(void *filesys)
 {
+  struct filesys *fs = filesys;
   printf("Filesys %s (%d) has duplicate name\n", fs->name, fs->filsys_id);
   return 0;
 }
 
-int show_np_id(struct nfsphys *n)
+int show_np_id(void *nfsphys)
 {
+  struct nfsphys *n = nfsphys;
   printf("NfsPhys %s:%s has duplicate ID %d\n",
         ((struct machine *)hash_lookup(machines, n->mach_id))->name,
         n->dir, n->nfsphys_id);
   return 0;
 }
 
-fix_np_id(struct nfsphys *n)
+void fix_np_id(void *nfsphys)
 {
+  struct nfsphys *n = nfsphys;
   n->nfsphys_id = generic_fix_id("nfsphys", "nfsphys_id", "dir",
                                 n->nfsphys_id, n->dir);
 }
 
-int show_str_id(struct string *s)
+int show_str_id(void *string)
 {
+  struct string *s = string;
   printf("String %s has duplicate ID %d\n", s->name, s->string_id);
   return 0;
 }
 
-int print_str_id(int id)
+int print_str_id(void *id)
 {
-  printf("String %d is a duplicate\n", id);
+  printf("String %d is a duplicate\n", (int)id);
   return 0;
 }
 
-print_dup_map(int key, int data, char *hint)
+void print_dup_map(int key, void *data, void *hint)
 {
-  printf("String %d is a duplicate of string %d\n", key, data);
+  printf("String %d is a duplicate of string %d\n", key, (int)data);
 }
 
-phase1(void)
+void phase1(void)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  char name[81], name1[81], last[17], first[17], buf[257];
-  int id, id1, id2, id3, aid, aid2, status;
-  int sid, sid2, sid3, sid4, sid5;
+  int id;
   EXEC SQL END DECLARE SECTION;
   int i, q, retval, tmp;
   struct save_queue *sq;
@@ -209,6 +249,7 @@ phase1(void)
   struct string *s;
   struct filesys *f;
   struct nfsphys *n;
+  struct printserver *ps;
 
   printf("Phase 1 - Looking for duplicates\n");
 
@@ -233,23 +274,27 @@ phase1(void)
   q = 0;
   while (1)
     {
+      EXEC SQL BEGIN DECLARE SECTION;
+      int id1, id2;
+      EXEC SQL END DECLARE SECTION;
+
       EXEC SQL FETCH csr116 INTO :id1, :id2;
       if (sqlca.sqlcode)
        break;
       q++;
       /*  If id2 is already stored, skip this row. */
-      i = int_hash_lookup(string_dups, id2);
+      i = (int)hash_lookup(string_dups, id2);
       if (i > 0)
        continue;
       /*  Follow the chain of id1 equivalent IDs back to the lowest one. */
       id = id1;
-      while ((tmp = int_hash_lookup(string_dups, id)) > 0)
+      while ((tmp = (int)hash_lookup(string_dups, id)) > 0)
        id = tmp;
-      int_hash_store(string_dups, id2, id);
+      hash_store(string_dups, id2, (void *)id);
     }
   EXEC SQL CLOSE csr116;
   dprintf("found %d duplicates\n", q);
-  int_hash_step(string_dups, print_dup_map, NULL);
+  hash_step(string_dups, print_dup_map, NULL);
   /* We don't want to delete the duplicates now because if the dbck
      is cancelled, a LOT of state will be lost. So, we'll just let
      them not get marked as used and then phase3 will clean them up */
@@ -266,6 +311,11 @@ phase1(void)
   q = 0;
   while (1)
     {
+      EXEC SQL BEGIN DECLARE SECTION;
+      int id;
+      char buf[STRINGS_STRING_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
       EXEC SQL FETCH csr101 INTO :id, :buf;
       if (sqlca.sqlcode)
        break;
@@ -273,7 +323,7 @@ phase1(void)
       s = malloc(sizeof(struct string));
       if (!s)
        out_of_mem("storing strings");
-      s->name = strsave(strtrim(buf));
+      s->name = strdup(strtrim(buf));
       s->string_id = id;
       s->refc = 0;
       retval = hash_store(strings, id, s);
@@ -299,48 +349,60 @@ phase1(void)
 
   EXEC SQL DECLARE csr102 CURSOR FOR
     SELECT users_id, login, last, first, status, potype, pop_id, box_id,
-    modby, fmodby, pmodby, comments, sigwho FROM users
+    imap_id, modby, fmodby, pmodby, comments, sigwho FROM users
     ORDER BY users_id;
   EXEC SQL OPEN csr102;
   while (1)
     {
-      EXEC SQL FETCH csr102 INTO :id, :name, :last, :first, :status,
-       :buf, :id2, :id3, :sid, :sid2, :sid3, :sid4, :sid5;
+      EXEC SQL BEGIN DECLARE SECTION;
+      char login[USERS_LOGIN_SIZE], nbuf[USERS_FIRST_SIZE + USERS_LAST_SIZE];
+      char last[USERS_LAST_SIZE], first[USERS_FIRST_SIZE];
+      char potype[USERS_POTYPE_SIZE];
+      int users_id, status, pop_id, box_id, imap_id, modby, fmodby, pmodby;
+      int comments, sigwho;
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr102 INTO :users_id, :login, :last, :first,
+       :status, :potype, :pop_id, :box_id, :imap_id, :modby, :fmodby,
+       :pmodby, :comments, :sigwho;
       if (sqlca.sqlcode)
        break;
 
       u = malloc(sizeof(struct user));
       if (!u)
        out_of_mem("storing users");
-      strcpy(u->login, strtrim(name));
-      u->potype = buf[0];
-      sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
-      u->fullname = strsave(buf);
+      strcpy(u->login, strtrim(login));
+      u->potype = potype[0];
+      sprintf(nbuf, "%s, %s", strtrim(last), strtrim(first));
+      u->fullname = strdup(nbuf);
       u->status = status;
-      u->users_id = id;
-      u->modby = sid;
-      u->fmodby = sid2;
-      u->pmodby = sid3;
-      u->comment = sid4;
-      u->sigwho = sid5;
+      u->users_id = users_id;
+      u->modby = modby;
+      u->fmodby = fmodby;
+      u->pmodby = pmodby;
+      u->comment = comments;
+      u->sigwho = sigwho;
       switch (u->potype)
        {
        case 'P':
-         u->pobox_id = id2;
+         u->pobox_id = pop_id;
          break;
        case 'S':
          /*  If potype is SMTP, box_id is a string_id for the strings tbl */
-         u->pobox_id = id3;
+         u->pobox_id = box_id;
+         break;
+       case 'I':
+         u->pobox_id = imap_id;
          break;
        default:
          u->pobox_id = 0;
        }
-      retval = hash_store(users, id, u);
+      retval = hash_store(users, users_id, u);
       if (retval == -1)
        out_of_mem("storing users in hash table");
       else if (retval == 1)
        {
-         sq_save_data(sq, hash_lookup(users, id));
+         sq_save_data(sq, hash_lookup(users, users_id));
          sq_save_data(sq, u);
        }
     }
@@ -417,8 +479,13 @@ phase1(void)
   EXEC SQL OPEN csr104;
   while (1)
     {
-      EXEC SQL FETCH csr104 INTO :id, :name, :id2, :buf, :id3, :sid2,
-       :sid3, :sid4, :sid;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int mach_id, snet_id, owner_id, acomment, ocomment, creator, modby;
+      char name[MACHINE_NAME_SIZE], owner_type[MACHINE_OWNER_TYPE_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr104 INTO :mach_id, :name, :snet_id,
+       :owner_type, :owner_id, :acomment, :ocomment, :creator, :modby;
       if (sqlca.sqlcode)
        break;
 
@@ -426,21 +493,21 @@ phase1(void)
       if (!m)
        out_of_mem("storing machines");
       strcpy(m->name, strtrim(name));
-      m->owner_type = buf[0];
-      m->owner_id = id3;
-      m->snet_id = id2;
-      m->mach_id = id;
+      m->owner_type = owner_type[0];
+      m->owner_id = owner_id;
+      m->snet_id = snet_id;
+      m->mach_id = mach_id;
       m->clucount = 0;
-      m->acomment = sid2;
-      m->ocomment = sid3;
-      m->creator = sid4;
-      m->modby = sid;
-      retval = hash_store(machines, id, m);
+      m->acomment = acomment;
+      m->ocomment = ocomment;
+      m->creator = creator;
+      m->modby = modby;
+      retval = hash_store(machines, mach_id, m);
       if (retval == -1)
        out_of_mem("storing machines in hash table");
       else if (retval == 1)
        {
-         sq_save_data(sq, hash_lookup(machines, id));
+         sq_save_data(sq, hash_lookup(machines, mach_id));
          sq_save_data(sq, m);
        }
     }
@@ -449,6 +516,11 @@ phase1(void)
 
   if (!fast)
     {
+      EXEC SQL BEGIN DECLARE SECTION;
+      char name[HOSTALIAS_NAME_SIZE];
+      int id1, id2;
+      EXEC SQL END DECLARE SECTION;
+
       sq = sq_create();
       if (!sq)
        out_of_mem("looking for duplicate machine names");
@@ -512,7 +584,13 @@ phase1(void)
   EXEC SQL OPEN csr115;
   while (1)
     {
-      EXEC SQL FETCH csr115 INTO :id, :name, :buf, :id2, :sid;
+      EXEC SQL BEGIN DECLARE SECTION;
+      char name[SUBNET_NAME_SIZE], owner_type[SUBNET_OWNER_TYPE_SIZE];
+      int snet_id, owner_id, modby;
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr115 INTO :snet_id, :name, :owner_type,
+       :owner_id, :modby;
       if (sqlca.sqlcode)
        break;
 
@@ -520,11 +598,11 @@ phase1(void)
       if (!sn)
        out_of_mem("storing subnets");
       strcpy(sn->name, strtrim(name));
-      sn->owner_type = buf[0];
-      sn->owner_id = id2;
-      sn->snet_id = id;
-      sn->modby = sid;
-      retval = hash_store(subnets, id, sn);
+      sn->owner_type = owner_type[0];
+      sn->owner_id = owner_id;
+      sn->snet_id = snet_id;
+      sn->modby = modby;
+      retval = hash_store(subnets, snet_id, sn);
       if (retval == -1)
        out_of_mem("storing subnets in hash table");
       else if (retval == 1)
@@ -569,7 +647,12 @@ phase1(void)
   EXEC SQL OPEN csr106;
   while (1)
     {
-      EXEC SQL FETCH csr106 INTO :id, :name, :sid;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int clu_id, modby;
+      char name[CLUSTERS_NAME_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr106 INTO :clu_id, :name, :modby;
       if (sqlca.sqlcode)
        break;
 
@@ -577,14 +660,14 @@ phase1(void)
       if (!c)
        out_of_mem("storing clusters");
       strcpy(c->name, strtrim(name));
-      c->clu_id = id;
-      c->modby = sid;
-      retval = hash_store(clusters, id, c);
+      c->clu_id = clu_id;
+      c->modby = modby;
+      retval = hash_store(clusters, clu_id, c);
       if (retval == -1)
        out_of_mem("storing clusters in hash table");
       else if (retval == 1)
        {
-         sq_save_data(sq, hash_lookup(clusters, id));
+         sq_save_data(sq, hash_lookup(clusters, clu_id));
          sq_save_data(sq, c);
        }
     }
@@ -620,28 +703,39 @@ phase1(void)
     out_of_mem("loading lists");
 
   EXEC SQL DECLARE csr108 CURSOR FOR
-    SELECT list_id, name, acl_id, acl_type, modby  FROM list
+    SELECT list_id, name, acl_id, acl_type, memacl_id, memacl_type, modby
+    FROM list
     ORDER BY list_id;
   EXEC SQL OPEN csr108;
   while (1)
     {
-      EXEC SQL FETCH csr108 INTO :id, :name, :aid, :buf, :sid;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int list_id, acl_id, memacl_id, modby;
+      char name[LIST_NAME_SIZE], acl_type[LIST_ACL_TYPE_SIZE];
+      char memacl_type[LIST_ACL_TYPE_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr108 INTO :list_id, :name, :acl_id, :acl_type, 
+       :memacl_id, :memacl_type, :modby;
       if (sqlca.sqlcode)
        break;
       l = malloc(sizeof(struct list));
       if (!l)
        out_of_mem("storing lists");
       strcpy(l->name, strtrim(name));
-      l->acl_type = buf[0];
-      l->acl_id = aid;
-      l->list_id = id;
+      l->acl_type = acl_type[0];
+      l->acl_id = acl_id;
+      l->memacl_type = memacl_type[0];
+      l->memacl_id = memacl_id;
+      l->list_id = list_id;
+      l->modby = modby;
       l->members = 0;
-      retval = hash_store(lists, id, l);
+      retval = hash_store(lists, list_id, l);
       if (retval == -1)
        out_of_mem("storing lists in hash table");
       else if (retval == 1)
        {
-         sq_save_data(sq, hash_lookup(lists, id));
+         sq_save_data(sq, hash_lookup(lists, list_id));
          sq_save_data(sq, l);
        }
     }
@@ -682,28 +776,34 @@ phase1(void)
   EXEC SQL OPEN csr110;
   while (1)
     {
-      EXEC SQL FETCH csr110 INTO :id, :name, :aid, :aid2, :id2, :id3,
-       :buf, :name1, :sid;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int filsys_id, owner, owners, phys_id, mach_id, modby;
+      char label[FILESYS_LABEL_SIZE], type[FILESYS_TYPE_SIZE];
+      char name[FILESYS_NAME_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr110 INTO :filsys_id, :label, :owner, :owners,
+       :phys_id, :mach_id, :type, :name, :modby;
       if (sqlca.sqlcode)
        break;
 
       f = malloc(sizeof(struct filesys));
       if (!f)
        out_of_mem("storing filesystems");
-      strcpy(f->name, strtrim(name));
-      strcpy(f->dir, strtrim(name1));
-      f->filsys_id = id;
-      f->owner = aid;
-      f->owners = aid2;
-      f->phys_id = id2;
-      f->mach_id = id3;
-      f->type = buf[0];
-      retval = hash_store(filesys, id, f);
+      strcpy(f->name, strtrim(label));
+      strcpy(f->dir, strtrim(name));
+      f->filsys_id = filsys_id;
+      f->owner = owner;
+      f->owners = owners;
+      f->phys_id = phys_id;
+      f->mach_id = mach_id;
+      f->type = type[0];
+      retval = hash_store(filesys, filsys_id, f);
       if (retval == -1)
        out_of_mem("storing filesys in hash table");
       else if (retval == 1)
        {
-         sq_save_data(sq, hash_lookup(filesys, id));
+         sq_save_data(sq, hash_lookup(filesys, filsys_id));
          sq_save_data(sq, f);
        }
     }
@@ -744,24 +844,31 @@ phase1(void)
   EXEC SQL OPEN csr111;
   while (1)
     {
-      EXEC SQL FETCH csr111 INTO :id, :name, :id2, :id3, :sid;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int nfsphys_id, mach_id, allocated, modby;
+      char dir[NFSPHYS_DIR_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr111 INTO :nfsphys_id, :dir, :mach_id,
+       :allocated, :modby;
       if (sqlca.sqlcode)
        break;
 
       n = malloc(sizeof(struct nfsphys));
       if (!n)
        out_of_mem("storing nfsphys");
-      strcpy(n->dir, strtrim(name));
-      n->mach_id = id2;
-      n->nfsphys_id = id;
-      n->allocated = id3;
+      strcpy(n->dir, strtrim(dir));
+      n->mach_id = mach_id;
+      n->nfsphys_id = nfsphys_id;
+      n->allocated = allocated;
+      n->modby = modby;
       n->count = 0;
-      retval = hash_store(nfsphys, id, n);
+      retval = hash_store(nfsphys, nfsphys_id, n);
       if (retval == -1)
        out_of_mem("storing nfsphys in hash table");
       else if (retval == 1)
        {
-         sq_save_data(sq, hash_lookup(nfsphys, id));
+         sq_save_data(sq, hash_lookup(nfsphys, nfsphys_id));
          sq_save_data(sq, n);
        }
     }
@@ -769,20 +876,93 @@ phase1(void)
 
   generic_fix(sq, show_np_id, "Change ID", fix_np_id, 0);
 
-  dprintf("Checking printcap...\n");
+  if (!fast)
+    {
+      dprintf("Checking printers...\n");
+
+      EXEC SQL DECLARE csr119 CURSOR FOR
+       SELECT p1.name FROM printers p1, printers p2
+       WHERE ( p1.name = p2.name AND p1.rowid < p2.rowid )
+       OR ( p1.name = p2.duplexname );
+      EXEC SQL OPEN csr119;
+      while (1)
+       {
+         EXEC SQL BEGIN DECLARE SECTION;
+         char name[PRINTERS_NAME_SIZE];
+         EXEC SQL END DECLARE SECTION;
+
+         EXEC SQL FETCH csr119 INTO :name;
+         if (sqlca.sqlcode)
+           break;
+
+         printf("Printer %s has duplicate name\n", name);
+         cant_fix(0);
+       }
+      EXEC SQL CLOSE csr119;
+    }
+
+  dprintf("Loading printservers...\n");
+  printservers = create_hash(100);
+  if (!printservers)
+    out_of_mem("loading printservers");
 
-  EXEC SQL DECLARE csr119 CURSOR FOR
-    SELECT p1.name FROM printcap p1, printcap p2
-    WHERE p1.name = p2.name AND p1.rowid < p2.rowid;
-  EXEC SQL OPEN csr119;
+  EXEC SQL DECLARE csr_ps CURSOR FOR
+    SELECT mach_id, printer_types, owner_type, owner_id, lpc_acl, modby
+    FROM printservers;
+  EXEC SQL OPEN csr_ps;
   while (1)
     {
-      EXEC SQL FETCH csr119 INTO :name;
+      EXEC SQL BEGIN DECLARE SECTION;
+      int mach_id, printer_types, owner_id, lpc_acl, modby;
+      char owner_type[PRINTSERVERS_OWNER_TYPE_SIZE];
+      EXEC SQL END DECLARE SECTION;
+
+      EXEC SQL FETCH csr_ps INTO :mach_id, :printer_types, :owner_type,
+       :owner_id, :lpc_acl, :modby;
       if (sqlca.sqlcode)
        break;
 
-      printf("Printer %s has duplicate name\n", name);
-      cant_fix(0);
+      ps = malloc(sizeof(struct printserver));
+      if (!ps)
+       out_of_mem("storing printserver");
+      ps->mach_id = mach_id;
+      ps->printer_types = printer_types;
+      ps->owner_type = owner_type[0];
+      ps->owner_id = owner_id;
+      ps->lpc_acl = lpc_acl;
+      ps->modby = modby;
+      retval = hash_store(printservers, mach_id, ps);
+      if (retval == -1)
+       out_of_mem("storing printserver in hash table");
+      else if (retval == 1)
+       {
+         printf("Duplicate printserver mach_id %d\n", mach_id);
+         cant_fix(0);
+       }
+    }
+  EXEC SQL CLOSE csr_ps;
+
+  if (!fast)
+    {
+      dprintf("Checking zephyr...\n");
+      
+      EXEC SQL DECLARE csr120 CURSOR FOR
+       SELECT z1.class FROM zephyr z1, zephyr z2
+       WHERE (z1.class = z2.class AND z1.rowid < z1.rowid);
+      EXEC SQL OPEN csr120;
+      while (1)
+       {
+         EXEC SQL BEGIN DECLARE SECTION;
+         char class[ZEPHYR_CLASS_SIZE];
+         EXEC SQL END DECLARE SECTION;
+
+         EXEC SQL FETCH csr120 INTO :class;
+         if (sqlca.sqlcode)
+           break;
+
+         printf("Zephyr class %s has duplicate name\n", class);
+         cant_fix(0);
+       }
+      EXEC SQL CLOSE csr120;
     }
-  EXEC SQL CLOSE csr119;
 }
This page took 0.067168 seconds and 4 git commands to generate.