+ /* Do the bulk of the membership quickly.
+ * Add PRSIZE members into the user/group record. After that, we
+ * require the use of continuation records, but we assume this is
+ * few enough that we do this the slow way (AddToEntry).
+ */
+ for (p = &(users->data[users->size - 1]); p >= users->data; p--) {
+ for (b = *p; b; b = b->next) {
+ if ((u = (struct entry *)b->data)->members == 0)
+ continue;
+ pos = FindByID(0, u->id);
+ pr_Read(0, 0, pos, &uentry, sizeof(uentry));
+ for (t=0, m=u->members; m && t<PRSIZE; m=m->unext, t++)
+ uentry.entries[t] = htonl(m->group->id);
+ uentry.count = htonl(t);
+ pr_Write(0, 0, pos, &uentry, sizeof(uentry));
+ if (m) {
+ pr_ReadEntry(0, 0, pos, &uentry);
+ while (m) {
+ AddToEntry(0, &uentry, pos, m->group->id);
+ m = m->unext;
+ }
+ }
+ }
+ }
+ for (p = &(groups->data[groups->size - 1]); p >= groups->data; p--) {
+ for (b = *p; b; b = b->next) {
+ if ((g = (struct entry *)b->data)->members == 0)
+ continue;
+ pos = FindByID(0, g->id);
+ pr_Read(0, 0, pos, &gentry, sizeof(gentry));
+ for (t=0, m=g->members; m && t<PRSIZE; m=m->gnext, t++)
+ gentry.entries[t] = htonl(m->user->id);
+ gentry.count = htonl(t);
+ pr_Write(0, 0, pos, &gentry, sizeof(gentry));
+ if (m) {
+ pr_ReadEntry(0, 0, pos, &gentry);
+ while (m) {
+ AddToEntry(0, &gentry, pos, m->user->id);
+ m = m->gnext;
+ }
+ }
+ }
+ }