]> andersk Git - moira.git/blame - dbck/phase3.qc
Used /bin/sh format instead of /bin/csh format, by accident.
[moira.git] / dbck / phase3.qc
CommitLineData
d2543f8c 1/* $Header$
2 *
3 * (c) Copyright 1988 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
5 * <mit-copyright.h>.
6 */
7
8#include <mit-copyright.h>
9#include "dbck.h"
10
11#define NULL 0
12
6489a1ab 13static char phase3_qc_rcsid[] = "$Header$";
14
d2543f8c 15
16empty_list_check(id, l, hint)
17int id, hint;
18struct list *l;
19{
20 if (l->members == 0 && l->list_id != 0)
21 printf("Warning: List %s is empty\n", l->name);
22}
23
24
25/* Used by other parts of the program to check that a string_id is good.
26 * This returns TRUE if it is, or FALSE if it is not, and as a side effect
27 * increments the string reference count.
28 */
29
c692f986 30struct string *string_check(id)
d2543f8c 31int id;
32{
33 register struct string *s;
34
35 s = (struct string *) hash_lookup(strings, id);
36 if (s == NULL)
c692f986 37 return(s);
d2543f8c 38 s->refc++;
c692f986 39 return(s);
d2543f8c 40}
41
42
43unref_string_check(id, s, hint)
44int id, hint;
45struct string *s;
46{
47 if (s->refc == 0) {
48 printf("Unreferenced string %s id %d\n", s->name, id);
49 if (single_fix("Delete", 1))
50 single_delete("strings", "string_id", id);
51 }
52}
53
54
55noclu_mach_check(id, m, hint)
56int id, hint;
57struct machine *m;
58{
6489a1ab 59 if (m->clucount == 0 && m->mach_id != 0)
d2543f8c 60 printf("Warning: machine %s is not in any clusters\n", m->name);
61}
62
63
64phase3()
65##{
66 printf("Phase 3 - Finding unused objects\n");
67
38e6880d 68 if (warn) {
69 dprintf("Checking machines...\n");
70 hash_step(machines, noclu_mach_check, NULL);
d2543f8c 71
38e6880d 72 dprintf("Checking lists...\n");
73 hash_step(lists, empty_list_check, NULL);
74 }
d2543f8c 75
76 dprintf("Checking strings...\n");
77 hash_step(strings, unref_string_check, NULL);
78
79##}
80
This page took 0.08925 seconds and 5 git commands to generate.