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 <afsconfig.h>
11 #include <afs/param.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;
36 if (clock == 0) return "time-not-set ";
39 tm = localtime (&now);
40 this_year = tm->tm_year;
42 tm = localtime(&clock);
43 if (tm->tm_year != this_year)
44 strftime (buffer, 32, "%m/%d/%Y %T", tm);
46 strftime (buffer, 32, "%m/%d %T", tm);
51 #define host(a) (hostOrder ? (a) : ntohl(a))
53 static void PrintEntries (f, hostOrder, indent, e, n)
55 int hostOrder; /* structures in host order */
65 if (e->entries[i] == 0) break;
67 if (i==0) fprintf (f, "%*sids ", indent, "");
68 else if (newline == 0) fprintf (f, "%*s", indent+4, "");
70 if (host(e->entries[i]) == PRBADID) fprintf (f, " EMPTY");
71 else fprintf (f, "%6d", host(e->entries[i]));
77 else fprintf (f, " ");
79 if (newline) fprintf (f, "\n");
82 int pr_PrintEntry (f, hostOrder, ea, e, indent)
84 int hostOrder; /* structures in host order */
91 if (e->cellid) fprintf (f, "cellid == %d\n", host(e->cellid));
92 for (i=0; i<sizeof(e->reserved)/sizeof(e->reserved[0]); i++)
94 fprintf (f, "reserved field [%d] not zero: %d\n",
95 i, host(e->reserved[i]));
97 fprintf (f, "%*s", indent, "");
98 fprintf (f, "Entry at %d: flags 0x%x, id %di, next %d.\n",
99 ea, host(e->flags), host(e->id), host(e->next));
100 #ifdef PR_REMEMBER_TIMES
101 fprintf (f, "%*s", indent, "");
102 fprintf (f, "c:%s ", pr_TimeToString(host(e->createTime)));
103 fprintf (f, "a:%s ", pr_TimeToString(host(e->addTime)));
104 fprintf (f, "r:%s ", pr_TimeToString(host(e->removeTime)));
105 fprintf (f, "n:%s\n", pr_TimeToString(host(e->changeTime)));
107 if (host(e->flags) & PRCONT)
108 PrintEntries (f, hostOrder, indent, e, COSIZE);
109 else { /* regular entry */
110 PrintEntries (f, hostOrder, indent, e, PRSIZE);
111 fprintf (f, "%*s", indent, "");
112 fprintf (f, "hash (id %d name %d). Owner %di, creator %di\n",
113 host(e->nextID), host(e->nextName),
114 host(e->owner), host(e->creator));
115 fprintf (f, "%*s", indent, "");
116 fprintf (f, "quota groups %d, foreign users %d. Mem: %d, inst: %d\n",
117 host(e->ngroups), host(e->nusers),
118 host(e->count), host(e->instance));
119 fprintf (f, "%*s", indent, "");
120 fprintf (f, "Owned chain %d, next owned %d, inst ptrs(%d %d %d).\n",
121 host(e->owned), host(e->nextOwned),
122 host(e->parent), host(e->sibling), host(e->child));
123 fprintf (f, "%*s", indent, "");
124 if (strlen (e->name) >= PR_MAXNAMELEN)
125 fprintf (f, "NAME TOO LONG: ");
126 fprintf (f, "Name is '%.*s'\n", PR_MAXNAMELEN, e->name);