3 * (c) Copyright 1988 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
8 #include <mit-copyright.h>
12 static char phase4_qc_rcsid[] = "$Header$";
15 count_boxes(id, u, boxes)
22 if (u->potype == 'P') {
23 if (i = (int) hash_lookup(boxes, u->pobox_id))
24 hash_store(boxes, u->pobox_id, i+1);
26 printf("User %s(%s) has pobox on non-POP server %d\n",
27 u->fullname, u->login, u->pobox_id);
28 printf("Not fixing this error\n");
34 ##check_box_counts(id, cnt, counts)
38 ## int oldval, rowcount;
40 oldval = (int) hash_lookup(counts, id);
43 printf("Count wrong on POBox machine %s; is %d in db, counted %d\n",
44 ((struct machine *) hash_lookup(machines, id))->name,
46 if (single_fix("Update", 1)) {
47 ## range of s is serverhosts
48 ## replace s (value1 = cnt) where
49 ## s.service = "POP" and s.mach_id = id
50 ## inquire_equel(rowcount = "rowcount")
52 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
54 printf("Not fixed\n");
55 modified("serverhosts");
61 ##check_nfs_counts(id, n, hint)
68 if (n->allocated != val) {
69 printf("Count wrong on NFSphys %s:%s; is %d in db, counted %d\n",
70 ((struct machine *) hash_lookup(machines, n->mach_id))->name,
71 n->dir, n->allocated, val);
72 if (single_fix("Update", 1)) {
73 ## replace nfsphys (allocated = val) where nfsphys.nfsphys_id = id
74 ## inquire_equel(rowcount = "rowcount")
76 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
78 printf("Not fixed\n");
87 struct hash *boxes, *counts;
90 printf("Phase 4 - Checking counts\n");
92 dprintf("Doing POBoxes...\n");
93 boxes = create_hash(10);
94 counts = create_hash(10);
95 ## retrieve (id = serverhosts.mach_id, cnt = serverhosts.value1)
96 ## where serverhosts.service = "POP" {
97 hash_store(boxes, id, 1);
98 hash_store(counts, id, cnt);
100 hash_step(users, count_boxes, boxes);
101 hash_step(boxes, check_box_counts, counts);
103 dprintf("Doing NFSphys...\n");
104 hash_step(nfsphys, check_nfs_counts, 0);
110 ## int id, status, id2, id3;
111 ## char name[33], last[17], first[17], buf[257];
112 struct save_queue *sq;
117 dprintf("Loading users...\n");
118 users = create_hash(10000);
119 ## range of u is users
120 ## retrieve (id = u.users_id, name = u.login, last = u.#last,
121 ## first = u.#first, status = u.#status, buf = u.potype,
122 ## id2 = u.pop_id, id3 = u.box_id)
123 ## where u.potype = "POP" {
124 u = (struct user *) malloc(sizeof(struct user));
126 out_of_mem("storing users");
127 strcpy(u->login, strtrim(name));
129 sprintf(buf, "%s, %s", strtrim(last), strtrim(first));
130 u->fullname = strsave(buf);
143 hash_store(users, id, u);
146 dprintf("Loading machines...\n");
147 machines = create_hash(1000);
148 ## range of m is machine
149 ## retrieve (id = m.mach_id, name = m.#name) {
150 m = (struct machine *) malloc(sizeof(struct machine));
152 out_of_mem("storing machines");
153 strcpy(m->name, strtrim(name));
155 hash_store(machines, id, m);
158 dprintf("Loading nfsphys...\n");
159 nfsphys = create_hash(500);
160 ## retrieve (id = nfsphys.nfsphys_id, name = nfsphys.dir,
161 ## id2 = nfsphys.mach_id, id3 = nfsphys.allocated) {
162 n = (struct nfsphys *) malloc(sizeof(struct nfsphys));
164 out_of_mem("storing nfsphys");
165 strcpy(n->dir, strtrim(name));
170 hash_store(nfsphys, id, n);
173 dprintf("Counting quotas...\n");
174 ## retrieve (id = quota.phys_id, id2 = quota.quota) {
175 if (n = (struct nfsphys *) hash_lookup(nfsphys, id)) {