* New function CtdlDelConfig() to delete a config db record
authorArt Cancro <ajc@citadel.org>
Fri, 1 Jan 2016 22:57:17 +0000 (17:57 -0500)
committerArt Cancro <ajc@citadel.org>
Fri, 1 Jan 2016 22:57:17 +0000 (17:57 -0500)
* Updated Berkeley DB hook to syslog properly when db version >= 5.0
* Updated startup banner copyright year to 1987-2016

citadel/config.c
citadel/config.h
citadel/database.c
citadel/server_main.c

index b6c386b6e56dc7c0ee9d31ed8ea909860ca903c1..a993a63ee1cb52ee5a64aceba5ae57a334b87fcc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Read and write the citadel.config file
  *
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2016 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.
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include <sys/utsname.h>
 #include <libcitadel.h>
+#include <assert.h>
 #include "config.h"
 #include "ctdl_module.h"
 
@@ -356,9 +357,6 @@ void CtdlSetConfigStr(char *key, char *value)
        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);
 
@@ -395,6 +393,32 @@ void CtdlSetConfigInt(char *key, int value)
 }
 
 
+
+/*
+ * Delete a system config value.
+ */
+void CtdlDelConfig(char *key)
+{
+       int key_len = strlen(key);
+
+       if (IsEmptyStr(key)) return;
+
+       /* Delete from the database. */
+       cdb_delete(CDB_CONFIG, key, key_len);
+
+       /* Delete from the in-memory cache */
+       HashPos *Pos = GetNewHashPos(ctdlconfig, 1);
+       if (GetHashPosFromKey(ctdlconfig, key, key_len, Pos)) {
+               DeleteEntryFromHash(ctdlconfig, Pos);
+       }
+       DeleteHashPos(&Pos);
+
+       assert(Pos == NULL);    // no memory leaks allowed
+}
+
+
+
+
 /*
  * Fetch a system config value.  Caller does *not* own the returned value and may not alter it.
  */
@@ -406,16 +430,9 @@ char *CtdlGetConfigStr(char *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;
        }
 
@@ -424,7 +441,6 @@ char *CtdlGetConfigStr(char *key)
        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);
        }
 
@@ -432,7 +448,6 @@ char *CtdlGetConfigStr(char *key)
        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;
 }
 
index 293593b817a89763489ca1f272892e2c561abea6..999fe7e76ba6182b3bed6fc25900e55c35336615 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2016 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.
@@ -112,6 +112,7 @@ int CtdlGetConfigInt(char *);
 long CtdlGetConfigLong(char *);
 void CtdlSetConfigInt(char *key, int value);
 void CtdlSetConfigLong(char *key, long value);
+void CtdlDelConfig(char *key);
 
 char *CtdlGetSysConfig(char *sysconfname);
 void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
index de1be0d2ca34666e5e9a53c308262353eafb3e56..b35b012651b55127ba8271a810c82b76fb7aa9e9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This is a data store backend for the Citadel server which uses Berkeley DB.
  *
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2016 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.
@@ -281,7 +281,7 @@ void open_databases(void)
        dbenv->set_paniccall(dbenv, dbpanic);
        dbenv->set_errcall(dbenv, cdb_verbose_err);
        dbenv->set_errpfx(dbenv, "ctdl");
-#if (DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR >= 3)
+#if (DB_VERSION_MAJOR > 4) || ( (DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR >= 3) )
        dbenv->set_msgcall(dbenv, cdb_verbose_log);
 #endif
        dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK, 1);
index a015876e5beedd803790e92aa0dda78093a5825d..443fdd3bb4db68a9633072b910f8a098320ba352 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * citserver's main() function lives here.
  * 
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2016 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.
@@ -198,7 +198,7 @@ int main(int argc, char **argv)
        syslog(LOG_NOTICE,
                "*** Citadel server engine v%d.%02d (build %s) ***",
                (REV_LEVEL/100), (REV_LEVEL%100), svn_revision());
-       syslog(LOG_NOTICE, "Copyright (C) 1987-2015 by the Citadel development team.");
+       syslog(LOG_NOTICE, "Copyright (C) 1987-2016 by the Citadel development team.");
        syslog(LOG_NOTICE, "This program is distributed under the terms of the GNU "
                                        "General Public License.");
        syslog(LOG_NOTICE, " ");