+/*
+ * callback to get highest room number when rebuilding control file
+ */
+void control_find_highest(struct ctdlroom *qrbuf, void *data)
+{
+ struct ctdlroom room;
+ struct cdbdata *cdbfr;
+ long *msglist;
+ int num_msgs=0;
+ int c;
+ int room_fixed = 0;
+ int message_fixed = 0;
+
+ if (qrbuf->QRnumber > CitControl.MMnextroom)
+ {
+ CitControl.MMnextroom = qrbuf->QRnumber;
+ room_fixed = 1;
+ }
+
+ CtdlGetRoom (&room, qrbuf->QRname);
+
+ /* Load the message list */
+ cdbfr = cdb_fetch(CDB_MSGLISTS, &room.QRnumber, sizeof(long));
+ if (cdbfr != NULL) {
+ msglist = (long *) cdbfr->ptr;
+ num_msgs = cdbfr->len / sizeof(long);
+ } else {
+ return; /* No messages at all? No further action. */
+ }
+
+ if (num_msgs>0)
+ {
+ for (c=0; c<num_msgs; c++)
+ {
+ if (msglist[c] > CitControl.MMhighest)
+ {
+ CitControl.MMhighest = msglist[c];
+ message_fixed = 1;
+ }
+ }
+ }
+ cdb_free(cdbfr);
+ if (room_fixed)
+ syslog(LOG_INFO, "Control record checking....Fixed room counter\n");
+ if (message_fixed)
+ syslog(LOG_INFO, "Control record checking....Fixed message count\n");
+ return;
+}
+
+
+/*
+ * Callback to get highest user number.
+ */
+
+void control_find_user (struct ctdluser *EachUser, void *out_data)
+{
+ int user_fixed = 0;
+
+ if (EachUser->usernum > CitControl.MMnextuser)
+ {
+ CitControl.MMnextuser = EachUser->usernum;
+ user_fixed = 1;
+ }
+ if(user_fixed)
+ syslog(LOG_INFO, "Control record checking....Fixed user count\n");
+}
+