+/*
+ * Helper function for cmd_conf() to handle boolean values
+ */
+int confbool(char *v)
+{
+ if (IsEmptyStr(v)) return(0);
+ if (atoi(v) != 0) return(1);
+ return(0);
+}
+
+
/*
* Get or set global configuration options
*
{
char cmd[16];
char buf[256];
- int a;
+ int a, i;
+ long ii;
char *confptr;
char confname[128];
while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) {
switch (a) {
case 0:
- safestrncpy(config.c_nodename, buf, sizeof config.c_nodename);
+ CtdlSetConfigStr("c_nodename", buf);
break;
case 1:
- safestrncpy(config.c_fqdn, buf, sizeof config.c_fqdn);
+ CtdlSetConfigStr("c_fqdn", buf);
break;
case 2:
- safestrncpy(config.c_humannode, buf, sizeof config.c_humannode);
+ CtdlSetConfigStr("c_humannode", buf);
break;
case 3:
/* placeholder -- field no longer in use */
break;
case 4:
- config.c_creataide = atoi(buf);
+ CtdlSetConfigInt("c_creataide", atoi(buf));
break;
case 5:
- config.c_sleeping = atoi(buf);
+ CtdlSetConfigInt("c_sleeping", atoi(buf));
break;
case 6:
- config.c_initax = atoi(buf);
- if (config.c_initax < 1)
- config.c_initax = 1;
- if (config.c_initax > 6)
- config.c_initax = 6;
+ i = atoi(buf);
+ if (i < 1) i = 1;
+ if (i > 6) i = 6;
+ CtdlSetConfigInt("c_initax", i);
break;
case 7:
- config.c_regiscall = atoi(buf);
- if (config.c_regiscall != 0)
- config.c_regiscall = 1;
+ CtdlSetConfigInt("c_regiscall", confbool(buf));
break;
case 8:
- config.c_twitdetect = atoi(buf);
- if (config.c_twitdetect != 0)
- config.c_twitdetect = 1;
+ CtdlSetConfigInt("c_twitdetect", confbool(buf));
break;
case 9:
- safestrncpy(config.c_twitroom, buf, sizeof config.c_twitroom);
+ CtdlSetConfigStr("c_twitroom", buf);
break;
case 10:
- safestrncpy(config.c_moreprompt, buf, sizeof config.c_moreprompt);
+ CtdlSetConfigStr("c_moreprompt", buf);
break;
case 11:
- config.c_restrict = atoi(buf);
- if (config.c_restrict != 0)
- config.c_restrict = 1;
+ CtdlSetConfigInt("c_restrict", confbool(buf));
break;
case 12:
- safestrncpy(config.c_site_location, buf, sizeof config.c_site_location);
+ CtdlSetConfigInt("c_site_location", confbool(buf));
break;
case 13:
- safestrncpy(config.c_sysadm, buf, sizeof config.c_sysadm);
+ CtdlSetConfigInt("c_sysadm", confbool(buf));
break;
case 14:
- config.c_maxsessions = atoi(buf);
- if (config.c_maxsessions < 0)
- config.c_maxsessions = 0;
+ i = atoi(buf);
+ if (i < 0) i = 0;
+ CtdlSetConfigInt("c_maxsessions", i);
break;
case 15:
/* placeholder -- field no longer in use */
break;
case 16:
- config.c_userpurge = atoi(buf);
+ CtdlSetConfigInt("c_userpurge", atoi(buf));
break;
case 17:
- config.c_roompurge = atoi(buf);
+ CtdlSetConfigInt("c_roompurge", atoi(buf));
break;
case 18:
- safestrncpy(config.c_logpages, buf, sizeof config.c_logpages);
+ CtdlSetConfigStr("c_logpages", buf);
break;
case 19:
- config.c_createax = atoi(buf);
- if (config.c_createax < 1)
- config.c_createax = 1;
- if (config.c_createax > 6)
- config.c_createax = 6;
+ i = atoi(buf);
+ if (i < 1) i = 1;
+ if (i > 6) i = 6;
+ CtdlSetConfigInt("c_createax", i);
break;
case 20:
- if (atoi(buf) >= 8192)
- config.c_maxmsglen = atoi(buf);
+ ii = atol(buf);
+ if (ii >= 8192) {
+ CtdlSetConfigLong("c_maxmsglen", ii);
+ }
break;
case 21:
- if (atoi(buf) >= 2)
- config.c_min_workers = atoi(buf);
+ i = atoi(buf);
+ if (i >= 3) { // minimum value
+ CtdlSetConfigInt("c_min_workers", i);
+ }
+ break;
case 22:
- if (atoi(buf) >= config.c_min_workers)
- config.c_max_workers = atoi(buf);
+ i = atoi(buf);
+ if (i >= CtdlGetConfigInt("c_min_workers")) { // max must be >= min
+ CtdlSetConfigInt("c_max_workers", i);
+ }
+ break;
case 23:
- config.c_pop3_port = atoi(buf);
+ CtdlSetConfigInt("c_pop3_port", atoi(buf));
break;
case 24:
- config.c_smtp_port = atoi(buf);
+ CtdlSetConfigInt("c_smtp_port", atoi(buf));
break;
case 25:
- config.c_rfc822_strict_from = atoi(buf);
+ CtdlSetConfigInt("c_rfc822_strict_from", atoi(buf));
break;
case 26:
- config.c_aide_zap = atoi(buf);
- if (config.c_aide_zap != 0)
- config.c_aide_zap = 1;
+ CtdlSetConfigInt("c_aide_zap", confbool(buf));
break;
case 27:
- config.c_imap_port = atoi(buf);
+ CtdlSetConfigInt("c_imap_port", atoi(buf));
break;
case 28:
- config.c_net_freq = atol(buf);
+ CtdlSetConfigLong("c_net_freq", atol(buf));
break;
case 29:
- config.c_disable_newu = atoi(buf);
- if (config.c_disable_newu != 0)
- config.c_disable_newu = 1;
+ CtdlSetConfigInt("c_disable_newu", confbool(buf));
break;
case 30:
/* niu */
* Function to go through an ical component set and convert all non-UTC
* date/time properties to UTC. It also strips out any VTIMEZONE
* subcomponents afterwards, because they're irrelevant.
+ *
+ * Copyright (c) 1987-2015 by the citadel.org team
+ *
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*/
icaltimezone *get_default_icaltimezone(void) {
icaltimezone *zone = NULL;
- char *default_zone_name = config.c_default_cal_zone;
- //char *default_zone_name = "America/New_York";
+ char *default_zone_name = CtdlGetConfigStr("c_default_cal_zone");
if (!zone) {
zone = icaltimezone_get_builtin_timezone(default_zone_name);
*/
void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name);
-
-#define SET_CFGSTRBUF(which, buffer) safestrncpy(config.which, ChrPtr(buffer), sizeof(config.which))
-#define SET_CFGSTR(which, buffer) safestrncpy(config.which, buffer, sizeof(config.which))
-
-extern struct config config;
-
-
-#define NODENAME config.c_nodename
-#define FQDN config.c_fqdn
+#define NODENAME CtdlGetConfigStr("c_nodename")
+#define FQDN CtdlGetConfigStr("c_fqdn")
#define CTDLUID ctdluid
-#define CREATAIDE config.c_creataide
-#define REGISCALL config.c_regiscall
-#define TWITDETECT config.c_twitdetect
-#define TWITROOM config.c_twitroom
-#define RESTRICT_INTERNET config.c_restrict
-
-#define CFG_KEY(which) config.which, strlen(config.which)
+#define CREATAIDE CtdlGetConfigInt("c_creataide")
+#define REGISCALL CtdlGetConfigInt("c_regiscall")
+#define TWITDETECT CtdlGetConfigInt("c_twitdetect")
+#define TWITROOM CtdlGetConfigStr("c_twitroom")
+#define RESTRICT_INTERNET CtdlGetConfigInt("c_restrict")
typedef void (*CfgLineParser)(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *rncfg);
typedef void (*CfgLineSerializer)(const CfgLineType *ThisOne, StrBuf *OuptputBuffer, OneRoomNetCfg *rncfg, RoomNetCfgLine *data);
/*
* Message journaling functions.
+ *
+ * Copyright (c) 1987-2015 by the citadel.org team
+ *
+ * This program is open source software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*/
#include <stdio.h>
#include "ctdl_module.h"
#include "citserver.h"
+#include "config.h"
#include "user_ops.h"
#include "serv_vcard.h" /* Needed for vcard_getuser and extract_inet_email_addrs */
#include "internet_addressing.h"
if (jmsg == NULL)
return;
- journal_recps = validate_recipients(config.c_journal_dest, NULL, 0);
+ journal_recps = validate_recipients(CtdlGetConfigStr("c_journal_dest"), NULL, 0);
if (journal_recps != NULL) {
if ( (journal_recps->num_local > 0)
/*
* Implements the message store.
*
- * Copyright (c) 1987-2012 by the citadel.org team
+ * Copyright (c) 1987-2015 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3.
#include "ctdl_module.h"
#include "citserver.h"
#include "control.h"
+#include "config.h"
#include "clientsocket.h"
#include "genstamp.h"
#include "room_ops.h"
if (haschar(mptr, '@') == 0)
{
sanitize_truncated_recipient(mptr);
- cprintf("To: %s@%s", mptr, config.c_fqdn);
+ cprintf("To: %s@%s", mptr, CtdlGetConfigStr("c_fqdn"));
cprintf("%s", nl);
}
else
strcpy(suser, "");
strcpy(luser, "");
strcpy(fuser, "");
- memcpy(snode, CFG_KEY(c_nodename) + 1);
+ memcpy(snode, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")) + 1);
if (mode == MT_RFC822)
OutputRFC822MsgHeaders(
TheMessage,
msgidbuflen = snprintf(msgidbuf, sizeof msgidbuf, "%08lX-%08lX@%s",
(long unsigned int) time(NULL),
(long unsigned int) newmsgid,
- config.c_fqdn
+ CtdlGetConfigStr("c_fqdn")
);
/* Generate an ID if we don't have one already */
if (TWITDETECT) {
if (CCC->user.axlevel == AxProbU) {
strcpy(hold_rm, actual_rm);
- strcpy(actual_rm, config.c_twitroom);
+ strcpy(actual_rm, CtdlGetConfigStr("c_twitroom"));
MSGM_syslog(LOG_DEBUG, "Diverting to twit room\n");
}
}
if (fromaddr != NULL) CM_SetField(msg, erFc822Addr, fromaddr, strlen(fromaddr));
if (room != NULL) CM_SetField(msg, eOriginalRoom, room, strlen(room));
- CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
+ CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
if (to != NULL) {
CM_SetField(msg, eRecipient, to, strlen(to));
recp = validate_recipients(to, NULL, 0);
CM_SetField(msg, eOriginalRoom, CCC->room.QRname, strlen(CCC->room.QRname));
}
- CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
- CM_SetField(msg, eHumanNode, CFG_KEY(c_humannode));
+ CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
+ CM_SetField(msg, eHumanNode, CtdlGetConfigStr("c_humannode"), strlen(CtdlGetConfigStr("c_humannode")));
if (rcplen > 0) {
CM_SetField(msg, eRecipient, recipient, rcplen);
}
else {
StrBuf *MsgBody;
- MsgBody = CtdlReadMessageBodyBuf(HKEY("000"), config.c_maxmsglen, NULL, 0, 0);
+ MsgBody = CtdlReadMessageBodyBuf(HKEY("000"), CtdlGetConfigLong("c_maxmsglen"), NULL, 0, 0);
if (MsgBody != NULL) {
CM_SetAsFieldSB(msg, eMesageText, &MsgBody);
}
msg->cm_format_type = 4;
CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
CM_SetField(msg, eOriginalRoom, req_room, strlen(req_room));
- CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
- CM_SetField(msg, eHumanNode, CFG_KEY(c_humannode));
+ CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
+ CM_SetField(msg, eHumanNode, CtdlGetConfigStr("c_humannode"), strlen(CtdlGetConfigStr("c_humannode")));
msg->cm_flags = flags;
CM_SetAsFieldSB(msg, eMesageText, &encoded_message);
/*
* Server functions which perform operations on room objects.
*
- * Copyright (c) 1987-2012 by the citadel.org team
+ * Copyright (c) 1987-2015 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 3.
int CtdlDoIHavePermissionToReadMessagesInThisRoom(void) {
if ( (!(CC->logged_in))
&& (!(CC->internal_pgm))
- && (!config.c_guest_logins)
+ && (!CtdlGetConfigInt("c_guest_logins"))
) {
return(om_not_logged_in);
}
is_me = 1;
}
- if ((is_me) && (config.c_guest_logins) && (!CC->logged_in)) {
+ if ((is_me) && (CtdlGetConfigInt("c_guest_logins")) && (!CC->logged_in)) {
is_guest = 1;
}
}
/* Force the properties of the Aide room */
- if (!strcasecmp(roombuf->QRname, config.c_aideroom)) {
+ if (!strcasecmp(roombuf->QRname, CtdlGetConfigStr("c_aideroom"))) {
if (userbuf->axlevel >= AxAideU) {
retval = UA_KNOWN | UA_GOTOALLOWED | UA_POSTALLOWED | UA_DELETEALLOWED | UA_REPLYALLOWED;
} else {
/* Listing order of 0 is illegal except for base rooms */
if (qrbuf->QRorder == 0)
if (!(qrbuf->QRflags & QR_MAILBOX) &&
- strncasecmp(qrbuf->QRname, config.c_baseroom, ROOMNAMELEN)
+ strncasecmp(qrbuf->QRname, CtdlGetConfigStr("c_baseroom"), ROOMNAMELEN)
&&
- strncasecmp(qrbuf->QRname, config.c_aideroom, ROOMNAMELEN))
+ strncasecmp(qrbuf->QRname, CtdlGetConfigStr("c_aideroom"), ROOMNAMELEN))
qrbuf->QRorder = 64;
}
/* Know the room ... but not if it's the page log room, or if the
* caller specified that we're only entering this room transiently.
*/
- if ((strcasecmp(CCC->room.QRname, config.c_logpages))
+ if ((strcasecmp(CCC->room.QRname, CtdlGetConfigStr("c_logpages")))
&& (transiently == 0) ) {
vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
vbuf.v_flags = vbuf.v_flags | V_ACCESS;
*/
void convert_room_name_macros(char *towhere, size_t maxlen) {
if (!strcasecmp(towhere, "_BASEROOM_")) {
- safestrncpy(towhere, config.c_baseroom, maxlen);
+ safestrncpy(towhere, CtdlGetConfigStr("c_baseroom"), maxlen);
}
else if (!strcasecmp(towhere, "_MAIL_")) {
safestrncpy(towhere, MAILROOM, maxlen);
safestrncpy(towhere, USERDRAFTROOM, maxlen);
}
else if (!strcasecmp(towhere, "_BITBUCKET_")) {
- safestrncpy(towhere, config.c_twitroom, maxlen);
+ safestrncpy(towhere, CtdlGetConfigStr("c_twitroom"), maxlen);
}
else if (!strcasecmp(towhere, "_CALENDAR_")) {
safestrncpy(towhere, USERCALENDARROOM, maxlen);
}
/* Reject change of floor for baseroom/aideroom */
- if (!strncasecmp(old_name, config.c_baseroom, ROOMNAMELEN) ||
- !strncasecmp(old_name, config.c_aideroom, ROOMNAMELEN)) {
+ if (!strncasecmp(old_name, CtdlGetConfigStr("c_baseroom"), ROOMNAMELEN) ||
+ !strncasecmp(old_name, CtdlGetConfigStr("c_aideroom"), ROOMNAMELEN)) {
new_floor = 0;
}
begin_critical_section(S_CONFIG);
/* If baseroom/aideroom name changes, update config */
- if (!strncasecmp(old_name, config.c_baseroom, ROOMNAMELEN)) {
- safestrncpy(config.c_baseroom, new_name, ROOMNAMELEN);
+ if (!strncasecmp(old_name, CtdlGetConfigStr("c_baseroom"), ROOMNAMELEN)) {
+ safestrncpy(CtdlGetConfigStr("c_baseroom"), new_name, ROOMNAMELEN);
put_config();
}
- if (!strncasecmp(old_name, config.c_aideroom, ROOMNAMELEN)) {
- safestrncpy(config.c_aideroom, new_name, ROOMNAMELEN);
+ if (!strncasecmp(old_name, CtdlGetConfigStr("c_aideroom"), ROOMNAMELEN)) {
+ safestrncpy(CtdlGetConfigStr("c_aideroom"), new_name, ROOMNAMELEN);
put_config();
}
/*
* Thread handling stuff for Citadel server
*
- * Copyright (c) 1987-2011 by the citadel.org team
+ * Copyright (c) 1987-2015 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 3.
#include "modules_init.h"
#include "serv_extensions.h"
#include "ctdl_module.h"
+#include "config.h"
#include "context.h"
#include "threads.h"
* they are all in use.
*/
while (!server_shutting_down) {
- if ((active_workers == num_workers) && (num_workers < config.c_max_workers)) {
+ if ((active_workers == num_workers) && (num_workers < CtdlGetConfigInt("c_max_workers"))) {
CtdlThreadCreate(worker_thread);
}
usleep(1000000);