- while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
- memset(usbuf, 0, sizeof(struct ctdluser));
- memcpy(usbuf, cdbus->ptr,
- ((cdbus->len > sizeof(struct ctdluser)) ?
- sizeof(struct ctdluser) : cdbus->len));
- cdb_free(cdbus);
- if (usbuf->usernum == number) {
- cdb_close_cursor(CDB_USERS);
- return (0);
- }
+ CtdlLogPrintf(CTDL_INFO, "User %ld maps to %s\n", number, cdbun->ptr);
+ r = getuser(usbuf, cdbun->ptr);
+ cdb_free(cdbun);
+ return(r);
+}
+
+
+
+/*
+ * Helper function for rebuild_usersbynumber()
+ */
+void rebuild_ubn_for_user(struct ctdluser *usbuf, void *data) {
+
+ struct ubnlist {
+ struct ubnlist *next;
+ char username[USERNAME_SIZE];
+ long usernum;
+ };
+
+ static struct ubnlist *u = NULL;
+ struct ubnlist *ptr = NULL;
+
+ /* Lazy programming here. Call this function as a ForEachUser backend
+ * in order to queue up the room names, or call it with a null user
+ * to make it do the processing.
+ */
+ if (usbuf != NULL) {
+ ptr = (struct ubnlist *) malloc(sizeof (struct ubnlist));
+ if (ptr == NULL) return;
+
+ ptr->usernum = usbuf->usernum;
+ safestrncpy(ptr->username, usbuf->fullname, sizeof ptr->username);
+ ptr->next = u;
+ u = ptr;
+ return;