2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afs/param.h>
11 #include <afsconfig.h>
16 #include <sys/types.h>
20 #include <netinet/in.h>
26 #ifdef PR_REMEMBER_TIMES
31 static char *pr_TimeToString (time_t clock)
33 static char buffer[32];
34 static int this_year = 0;
37 if (clock == 0) return "time-not-set ";
40 tm = localtime (&now);
41 this_year = tm->tm_year;
43 tm = localtime(&clock);
44 if (tm->tm_year != this_year)
45 strftime (buffer, 32, "%m/%d/%Y %T", tm);
47 strftime (buffer, 32, "%m/%d %T", tm);
52 #define host(a) (hostOrder ? (a) : ntohl(a))
54 static void PrintEntries (f, hostOrder, indent, e, n)
56 int hostOrder; /* structures in host order */
66 if (e->entries[i] == 0) break;
68 if (i==0) fprintf (f, "%*sids ", indent, "");
69 else if (newline == 0) fprintf (f, "%*s", indent+4, "");
71 if (host(e->entries[i]) == PRBADID) fprintf (f, " EMPTY");
72 else fprintf (f, "%6d", host(e->entries[i]));
78 else fprintf (f, " ");
80 if (newline) fprintf (f, "\n");
83 int pr_PrintEntry (f, hostOrder, ea, e, indent)
85 int hostOrder; /* structures in host order */
92 if (e->cellid) fprintf (f, "cellid == %d\n", host(e->cellid));
93 for (i=0; i<sizeof(e->reserved)/sizeof(e->reserved[0]); i++)
95 fprintf (f, "reserved field [%d] not zero: %d\n",
96 i, host(e->reserved[i]));
98 fprintf (f, "%*s", indent, "");
99 fprintf (f, "Entry at %d: flags 0x%x, id %di, next %d.\n",
100 ea, host(e->flags), host(e->id), host(e->next));
101 #ifdef PR_REMEMBER_TIMES
102 fprintf (f, "%*s", indent, "");
103 fprintf (f, "c:%s ", pr_TimeToString(host(e->createTime)));
104 fprintf (f, "a:%s ", pr_TimeToString(host(e->addTime)));
105 fprintf (f, "r:%s ", pr_TimeToString(host(e->removeTime)));
106 fprintf (f, "n:%s\n", pr_TimeToString(host(e->changeTime)));
108 if (host(e->flags) & PRCONT)
109 PrintEntries (f, hostOrder, indent, e, COSIZE);
110 else { /* regular entry */
111 PrintEntries (f, hostOrder, indent, e, PRSIZE);
112 fprintf (f, "%*s", indent, "");
113 fprintf (f, "hash (id %d name %d). Owner %di, creator %di\n",
114 host(e->nextID), host(e->nextName),
115 host(e->owner), host(e->creator));
116 fprintf (f, "%*s", indent, "");
117 fprintf (f, "quota groups %d, foreign users %d. Mem: %d, inst: %d\n",
118 host(e->ngroups), host(e->nusers),
119 host(e->count), host(e->instance));
120 fprintf (f, "%*s", indent, "");
121 fprintf (f, "Owned chain %d, next owned %d, inst ptrs(%d %d %d).\n",
122 host(e->owned), host(e->nextOwned),
123 host(e->parent), host(e->sibling), host(e->child));
124 fprintf (f, "%*s", indent, "");
125 if (strlen (e->name) >= PR_MAXNAMELEN)
126 fprintf (f, "NAME TOO LONG: ");
127 fprintf (f, "Name is '%.*s'\n", PR_MAXNAMELEN, e->name);