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>
17 #include <sys/types.h>
21 #include <netinet/in.h>
34 #ifdef PR_REMEMBER_TIMES
40 pr_TimeToString(time_t clock)
43 static char buffer[32];
44 static int this_year = 0;
47 return "time-not-set ";
51 this_year = tm->tm_year;
53 tm = localtime(&clock);
54 if (tm->tm_year != this_year)
55 strftime(buffer, 32, "%m/%d/%Y %T", tm);
57 strftime(buffer, 32, "%m/%d %T", tm);
62 #define host(a) (hostOrder ? (a) : ntohl(a))
65 PrintEntries(FILE *f, int hostOrder, int indent, struct prentry *e, int n)
71 for (i = 0; i < n; i++) {
72 if (e->entries[i] == 0)
76 fprintf(f, "%*sids ", indent, "");
77 else if (newline == 0)
78 fprintf(f, "%*s", indent + 4, "");
80 if (host(e->entries[i]) == PRBADID)
83 fprintf(f, "%6d", host(e->entries[i]));
96 pr_PrintEntry(FILE *f, int hostOrder, afs_int32 ea, struct prentry *e, int indent)
101 fprintf(f, "cellid == %d\n", host(e->cellid));
102 for (i = 0; i < sizeof(e->reserved) / sizeof(e->reserved[0]); i++)
104 fprintf(f, "reserved field [%d] not zero: %d\n", i,
105 host(e->reserved[i]));
107 fprintf(f, "%*s", indent, "");
108 fprintf(f, "Entry at %d: flags 0x%x, id %di, next %d.\n", ea,
109 host(e->flags), host(e->id), host(e->next));
110 #ifdef PR_REMEMBER_TIMES
111 fprintf(f, "%*s", indent, "");
112 fprintf(f, "c:%s ", pr_TimeToString(host(e->createTime)));
113 fprintf(f, "a:%s ", pr_TimeToString(host(e->addTime)));
114 fprintf(f, "r:%s ", pr_TimeToString(host(e->removeTime)));
115 fprintf(f, "n:%s\n", pr_TimeToString(host(e->changeTime)));
117 if (host(e->flags) & PRCONT)
118 PrintEntries(f, hostOrder, indent, e, COSIZE);
119 else { /* regular entry */
120 PrintEntries(f, hostOrder, indent, e, PRSIZE);
121 fprintf(f, "%*s", indent, "");
122 fprintf(f, "hash (id %d name %d). Owner %di, creator %di\n",
123 host(e->nextID), host(e->nextName), host(e->owner),
125 fprintf(f, "%*s", indent, "");
126 #if defined(SUPERGROUPS)
127 fprintf(f, "quota groups %d, foreign users %d. Mem: %d, cntsg: %d\n",
128 host(e->ngroups), host(e->nusers), host(e->count),
131 fprintf(f, "quota groups %d, foreign users %d. Mem: %d, inst: %d\n",
132 host(e->ngroups), host(e->nusers), host(e->count),
135 fprintf(f, "%*s", indent, "");
136 #if defined(SUPERGROUPS)
137 fprintf(f, "Owned chain %d, next owned %d, nextsg %d, sg (%d %d).\n",
138 host(e->owned), host(e->nextOwned), host(e->parent),
139 host(e->sibling), host(e->child));
141 fprintf(f, "Owned chain %d, next owned %d, inst ptrs(%d %d %d).\n",
142 host(e->owned), host(e->nextOwned), host(e->parent),
143 host(e->sibling), host(e->child));
145 fprintf(f, "%*s", indent, "");
146 if (strlen(e->name) >= PR_MAXNAMELEN)
147 fprintf(f, "NAME TOO LONG: ");
148 fprintf(f, "Name is '%.*s'\n", PR_MAXNAMELEN, e->name);