X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fcontrol.c;h=f03aea7b35d4662a8f7eafc324525c4a4582383c;hb=104a4e1d569154afc9ff6a218d76d42dd3870b7b;hp=75d15143cc3866560767f2ee5fdbe00a12f4434b;hpb=07f9de6655fff874dfd1ccbc882e121dca6957ad;p=citadel.git diff --git a/citadel/control.c b/citadel/control.c index 75d15143c..f03aea7b3 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "citadel.h" #include "server.h" #include "control.h" @@ -37,8 +38,9 @@ #include "config.h" #include "msgbase.h" #include "citserver.h" -#include "tools.h" #include "room_ops.h" +#include "user_ops.h" +#include "database.h" #ifndef HAVE_SNPRINTF #include "snprintf.h" @@ -47,7 +49,7 @@ struct CitControl CitControl; extern struct config config; FILE *control_fp = NULL; - +long control_highest_user = 0; /* @@ -70,6 +72,55 @@ void lock_control(void) #endif } +/* + * 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; + + + if (qrbuf->QRnumber > CitControl.MMnextroom) + CitControl.MMnextroom = qrbuf->QRnumber; + + getroom (&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 CitControl.MMhighest) + CitControl.MMhighest = msglist[c]; + } + } + cdb_free(cdbfr); + return; +} + + +/* + * Callback to get highest user number. + */ + +void control_find_user (struct ctdluser *EachUser, void *out_data) +{ + if (EachUser->usernum > CitControl.MMnextuser) + CitControl.MMnextuser = EachUser->usernum; +} + /* * get_control - read the control record into memory. @@ -102,6 +153,9 @@ void get_control(void) lock_control(); fchown(fileno(control_fp), config.c_ctdluid, -1); memset(&CitControl, 0, sizeof(struct CitControl)); + // Find highest room number and message number. + ForEachRoom(control_find_highest, NULL); + ForEachUser(control_find_user, NULL); fwrite(&CitControl, sizeof(struct CitControl), 1, control_fp); rewind(control_fp); @@ -275,6 +329,9 @@ void cmd_conf(char *argbuf) cprintf("%s\n", config.c_master_user); cprintf("%s\n", config.c_master_pass); cprintf("%s\n", config.c_pager_program); + cprintf("%d\n", config.c_imap_keep_from); + cprintf("%d\n", config.c_xmpp_c2s_port); + cprintf("%d\n", config.c_xmpp_s2s_port); cprintf("000\n"); } @@ -513,6 +570,15 @@ void cmd_conf(char *argbuf) buf, sizeof config.c_pager_program); break; + case 61: + config.c_imap_keep_from = atoi(buf); + break; + case 62: + config.c_xmpp_c2s_port = atoi(buf); + break; + case 63: + config.c_xmpp_s2s_port = atoi(buf); + break; } ++a; }