]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/control.c
Blockquotes are now rendered to console as dim instead of italic
[citadel.git] / citadel / server / control.c
index 27bc05b01e52ceded4715719327b59281520ecdd..a6ff329016082ac1886caa9a5a154d0a2d7d353e 100644 (file)
@@ -1,7 +1,7 @@
 //
 // This module handles states which are global to the entire server.
 //
-// Copyright (c) 1987-2023 by the citadel.org team
+// Copyright (c) 1987-2024 by the citadel.org team
 //
 // This program is open source software.  Use, duplication, or disclosure
 // is subject to the terms of the GNU General Public License, version 3.
@@ -14,6 +14,7 @@
 #include "config.h"
 #include "citserver.h"
 #include "user_ops.h"
+#include "room_ops.h"
 
 long control_highest_user = 0;
 
@@ -47,7 +48,6 @@ struct cfh {
 // 2 = show inconsistencies but don't repair them, continue execution
 void control_find_highest(struct ctdlroom *qrbuf, void *data) {
        struct cfh *cfh = (struct cfh *)data;
-       struct cdbdata *cdbfr;
        long *msglist;
        int num_msgs=0;
        int c;
@@ -57,15 +57,7 @@ void control_find_highest(struct ctdlroom *qrbuf, void *data) {
        }
 
        // Load the message list
-       cdbfr = cdb_fetch(CDB_MSGLISTS, &qrbuf->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.
-       }
-
+       num_msgs = CtdlFetchMsgList(qrbuf->QRnumber, &msglist);
        if (num_msgs > 0) {
                for (c=0; c<num_msgs; c++) {
                        if (msglist[c] > cfh->highest_msgnum_found) {
@@ -73,8 +65,7 @@ void control_find_highest(struct ctdlroom *qrbuf, void *data) {
                        }
                }
        }
-
-       cdb_free(cdbfr);
+       free(msglist);
 }
 
 
@@ -235,7 +226,7 @@ void cmd_conf(char *argbuf) {
                cprintf("%s\n",         CtdlGetConfigStr("c_nodename"));
                cprintf("%s\n",         CtdlGetConfigStr("c_fqdn"));
                cprintf("%s\n",         CtdlGetConfigStr("c_humannode"));
-               cprintf("xxx\n");       // placeholder -- field no longer in use
+               cprintf("xxx\n");
                cprintf("%d\n",         CtdlGetConfigInt("c_creataide"));
                cprintf("%d\n",         CtdlGetConfigInt("c_sleeping"));
                cprintf("%d\n",         CtdlGetConfigInt("c_initax"));
@@ -247,7 +238,7 @@ void cmd_conf(char *argbuf) {
                cprintf("%s\n",         CtdlGetConfigStr("c_site_location"));
                cprintf("%s\n",         CtdlGetConfigStr("c_sysadm"));
                cprintf("%d\n",         CtdlGetConfigInt("c_maxsessions"));
-               cprintf("xxx\n");       // placeholder -- field no longer in use
+               cprintf("xxx\n");
                cprintf("%d\n",         CtdlGetConfigInt("c_userpurge"));
                cprintf("%d\n",         CtdlGetConfigInt("c_roompurge"));
                cprintf("%s\n",         CtdlGetConfigStr("c_logpages"));
@@ -262,7 +253,7 @@ void cmd_conf(char *argbuf) {
                cprintf("%d\n",         CtdlGetConfigInt("c_imap_port"));
                cprintf("%ld\n",        CtdlGetConfigLong("c_net_freq"));
                cprintf("%d\n",         CtdlGetConfigInt("c_disable_newu"));
-               cprintf("1\n");         // niu
+               cprintf("1\n");
                cprintf("%d\n",         CtdlGetConfigInt("c_purge_hour"));
                cprintf("%s\n",         CtdlGetConfigStr("c_ldap_host"));
                cprintf("%d\n",         CtdlGetConfigInt("c_ldap_port"));
@@ -275,7 +266,7 @@ void cmd_conf(char *argbuf) {
                cprintf("%d\n",         CtdlGetConfigInt("c_pop3s_port"));
                cprintf("%d\n",         CtdlGetConfigInt("c_smtps_port"));
                cprintf("%d\n",         CtdlGetConfigInt("c_enable_fulltext"));
-               cprintf("%d\n",         CtdlGetConfigInt("c_auto_cull"));
+               cprintf("1\n");
                cprintf("1\n");
                cprintf("%d\n",         CtdlGetConfigInt("c_allow_spoofing"));
                cprintf("%d\n",         CtdlGetConfigInt("c_journal_email"));
@@ -465,7 +456,7 @@ void cmd_conf(char *argbuf) {
                                CtdlSetConfigInt("c_enable_fulltext", confbool(buf));
                                break;
                        case 43:
-                               CtdlSetConfigInt("c_auto_cull", confbool(buf));
+                               // niu
                                break;
                        case 44:
                                // niu
@@ -579,13 +570,14 @@ void cmd_conf(char *argbuf) {
                        len = strlen(confptr);
                        cprintf("%d %s\n", LISTING_FOLLOWS, confname);
                        client_write(confptr, len);
-                       if ((len > 0) && (confptr[len - 1] != 10))
+                       if ((len > 0) && (confptr[len - 1] != 10)) {
                                client_write("\n", 1);
+                       }
                        cprintf("000\n");
                        free(confptr);
-               } else {
-                       cprintf("%d No such configuration.\n",
-                               ERROR + ILLEGAL_VALUE);
+               }
+               else {
+                       cprintf("%d No such configuration.\n", ERROR + ILLEGAL_VALUE);
                }
        }
 
@@ -648,21 +640,20 @@ void cmd_conf(char *argbuf) {
 
        // CONF LISTVAL - list configuration variables in the database and their values
        else if (!strcasecmp(cmd, "LISTVAL")) {
-               struct cdbdata *cdbcfg;
+               struct cdbkeyval cdbcfg;
                int keylen = 0;
                char *key = NULL;
                char *value = NULL;
        
                cprintf("%d all configuration variables\n", LISTING_FOLLOWS);
                cdb_rewind(CDB_CONFIG);
-               while (cdbcfg = cdb_next_item(CDB_CONFIG), cdbcfg != NULL) {
-                       if (cdbcfg->len < 1020) {
-                               keylen = strlen(cdbcfg->ptr);
-                               key = cdbcfg->ptr;
-                               value = cdbcfg->ptr + keylen + 1;
+               while (cdbcfg = cdb_next_item(CDB_CONFIG), cdbcfg.val.ptr!=NULL) {      // MUST read to the end
+                       if (cdbcfg.val.len < 1020) {
+                               keylen = strlen(cdbcfg.val.ptr);
+                               key = cdbcfg.val.ptr;
+                               value = cdbcfg.val.ptr + keylen + 1;
                                cprintf("%s|%s\n", key, value);
                        }
-                       cdb_free(cdbcfg);
                }
                cprintf("000\n");
        }
@@ -727,8 +718,7 @@ void cmd_gvdn(char *argbuf) {
                StrBufExtract_NextToken(CfgToken, Line, &PPos, '|');
                if (GetHash(CfgNameHash, SKEY(CfgToken), &vptr) && (vptr != NULL)) {
                        pCfg = (ConfType *) vptr;
-                       if (pCfg->Type <= min)
-                       {
+                       if (pCfg->Type <= min) {
                                Put(List, SKEY(Cfg), Cfg, HFreeStrBuf);
                                Cfg = NULL;
                        }
@@ -758,8 +748,9 @@ char *ctdl_module_init_control(void) {
                int i;
 
                CfgNameHash = NewHash(1, NULL);
-               for (i = 0; CfgNames[i].Name.Key != NULL; i++)
+               for (i = 0; CfgNames[i].Name.Key != NULL; i++) {
                        Put(CfgNameHash, CKEY(CfgNames[i].Name), &CfgNames[i], reference_free_handler);
+               }
 
                CtdlRegisterProtoHook(cmd_gvdn, "GVDN", "get valid domain names");
                CtdlRegisterProtoHook(cmd_conf, "CONF", "get/set system configuration");