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>
20 pr_TimeToString(time_t clock)
23 static char buffer[32];
24 static int this_year = 0;
27 return "time-not-set ";
31 this_year = tm->tm_year;
33 tm = localtime(&clock);
34 if (tm->tm_year != this_year)
35 strftime(buffer, 32, "%m/%d/%Y %H:%M:%S", tm);
37 strftime(buffer, 32, "%m/%d %H:%M:%S", tm);
41 #define host(a) (hostOrder ? (a) : ntohl(a))
43 #define PRINT_COMMON_FIELDS(e) \
47 fprintf(f, "cellid == %d\n", host((e)->cellid)); \
48 for (i = 0; i < sizeof((e)->reserved) / sizeof((e)->reserved[0]); i++) \
49 if ((e)->reserved[i]) \
50 fprintf(f, "reserved field [%d] not zero: %d\n", i, \
51 host((e)->reserved[i])); \
52 fprintf(f, "%*s", indent, ""); \
53 fprintf(f, "Entry at %d: flags 0x%x, id %di, next %d.\n", ea, \
54 host((e)->flags), host((e)->id), host((e)->next)); \
57 #define PRINT_IDS(e) \
61 for (i = 0; i < sizeof((e)->entries)/sizeof((e)->entries[0]); i++) { \
62 if ((e)->entries[i] == 0) \
65 fprintf(f, "%*sids ", indent, ""); \
66 else if (newline == 0) \
67 fprintf(f, "%*s", indent + 4, ""); \
68 if (host((e)->entries[i]) == PRBADID) \
69 fprintf(f, " EMPTY"); \
71 fprintf(f, "%6d", host((e)->entries[i])); \
85 pr_PrintEntry(FILE *f, int hostOrder, afs_int32 ea, struct prentry *e,
88 /* In case we are given the wrong type of entry. */
89 if ((host(e->flags) & PRTYPE) == PRCONT) {
91 memcpy(&c, e, sizeof(c));
92 return pr_PrintContEntry(f, hostOrder, ea, &c, indent);
95 PRINT_COMMON_FIELDS(e);
96 fprintf(f, "%*s", indent, "");
97 fprintf(f, "c:%s ", pr_TimeToString(host(e->createTime)));
98 fprintf(f, "a:%s ", pr_TimeToString(host(e->addTime)));
99 fprintf(f, "r:%s ", pr_TimeToString(host(e->removeTime)));
100 fprintf(f, "n:%s\n", pr_TimeToString(host(e->changeTime)));
102 fprintf(f, "%*s", indent, "");
103 fprintf(f, "hash (id %d name %d). Owner %di, creator %di\n",
104 host(e->nextID), host(e->nextName), host(e->owner),
106 fprintf(f, "%*s", indent, "");
107 #if defined(SUPERGROUPS)
108 fprintf(f, "quota groups %d, foreign users %d. Mem: %d, cntsg: %d\n",
109 host(e->ngroups), host(e->nusers), host(e->count),
112 fprintf(f, "quota groups %d, foreign users %d. Mem: %d, inst: %d\n",
113 host(e->ngroups), host(e->nusers), host(e->count),
116 fprintf(f, "%*s", indent, "");
117 #if defined(SUPERGROUPS)
118 fprintf(f, "Owned chain %d, next owned %d, nextsg %d, sg (%d %d).\n",
119 host(e->owned), host(e->nextOwned), host(e->parent),
120 host(e->sibling), host(e->child));
122 fprintf(f, "Owned chain %d, next owned %d, inst ptrs(%d %d %d).\n",
123 host(e->owned), host(e->nextOwned), host(e->parent),
124 host(e->sibling), host(e->child));
126 fprintf(f, "%*s", indent, "");
127 if (strlen(e->name) >= PR_MAXNAMELEN)
128 fprintf(f, "NAME TOO LONG: ");
129 fprintf(f, "Name is '%.*s'\n", PR_MAXNAMELEN, e->name);
134 pr_PrintContEntry(FILE *f, int hostOrder, afs_int32 ea, struct contentry *c, int indent)
136 PRINT_COMMON_FIELDS(c);
137 /* Print the reserved fields for compatibility with older versions.
138 * They should always be zero, checked in PRINT_COMMON_FIELDS(). */
139 fprintf(f, "%*s", indent, "");
140 fprintf(f, "c:%s ", pr_TimeToString(host((c)->reserved[0])));
141 fprintf(f, "a:%s ", pr_TimeToString(host((c)->reserved[1])));
142 fprintf(f, "r:%s ", pr_TimeToString(host((c)->reserved[2])));
143 fprintf(f, "n:%s\n", pr_TimeToString(host((c)->reserved[3])));