exit(CTDLEXIT_HOME);
}
- memset(&config, 0, sizeof(struct legacy_config));
+ memset(&lconfig, 0, sizeof(struct legacy_config));
cfp = fopen(file_citadel_config, "rb");
if (cfp != NULL) {
- if (CtdlGetConfigLong("c_config_created_or_migrated") <= 0) {
+ if (CtdlGetConfigLong("c_config_created_or_migrated") > 0) {
fprintf(stderr, "Citadel Server found BOTH legacy and new configurations present.\n");
fprintf(stderr, "Exiting to prevent data corruption.\n");
exit(CTDLEXIT_CONFIG);
}
- rv = fread((char *) &config, sizeof(struct legacy_config), 1, cfp);
+ rv = fread((char *) &lconfig, sizeof(struct legacy_config), 1, cfp);
if (rv != 1)
{
fprintf(stderr,
/* Only allow LDAP auth mode if we actually have LDAP support */
#ifndef HAVE_LDAP
- if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+ if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
fprintf(stderr, "Your system is configured for LDAP authentication,\n"
"but you are running a server built without OpenLDAP support.\n");
exit(CTDL_EXIT_UNSUP_AUTH);
int key_len = strlen(key);
int value_len = strlen(value);
+ /* FIXME we are noisy logging for now */
+ syslog(LOG_DEBUG, "\033[31mSET CONFIG: '%s' = '%s'\033[0m", key, value);
+
/* Save it in memory */
Put(ctdlconfig, key, key_len, strdup(value), NULL);
struct cdbdata *cdb;
int key_len = strlen(key);
+ if (IsEmptyStr(key)) return(NULL);
+
+ /* Temporary hack to make sure we didn't mess up any porting - FIXME remove this after testing thoroughly */
+ if (!strncmp(key, "config", 6)) {
+ syslog(LOG_EMERG, "You requested a key starting with 'config' which probably means a porting error: %s", key);
+ abort();
+ }
+
/* First look in memory */
if (GetHash(ctdlconfig, key, key_len, (void *)&value))
{
+ if (strcmp(key, "c_min_workers")) syslog(LOG_DEBUG, "\033[32mGET CONFIG: '%s' = '%s'\033[0m", key, value);
return value;
}
cdb = cdb_fetch(CDB_CONFIG, key, key_len);
if (cdb == NULL) { /* nope, not there either. */
+ syslog(LOG_DEBUG, "\033[32mGET CONFIG: '%s' = NULL\033[0m", key);
return(NULL);
}
value = strdup(cdb->ptr + key_len + 1); /* The key was stored there too; skip past it */
cdb_free(cdb);
Put(ctdlconfig, key, key_len, value, NULL);
+ syslog(LOG_DEBUG, "\033[32mGET CONFIG: '%s' = '%s'\033[0m", key, value);
return value;
}
+/*
+ * Fetch a system config value - integer
+ */
+int CtdlGetConfigInt(char *key)
+{
+ char *s = CtdlGetConfigStr(key);
+ if (s) return atoi(s);
+ return 0;
+}
+
+
+/*
+ * Fetch a system config value - long integer
+ */
+long CtdlGetConfigLong(char *key)
+{
+ char *s = CtdlGetConfigStr(key);
+ if (s) return atol(s);
+ return 0;
+}