]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/ctdlproto/serv_syscmds.c
more places where we can use cm_lengths;
[citadel.git] / citadel / modules / ctdlproto / serv_syscmds.c
index daf5c9f388d7897ad71328a0c7471810af0ab852..3b21bc4fbd1d6dcfb79f4f1d591f3fe7990de943 100644 (file)
  * GNU General Public License for more details.
  */
 
-#include "sysdep.h"
-#include <stdlib.h>
-#include <unistd.h>
 #include <stdio.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
-#if HAVE_BACKTRACE
-#include <execinfo.h>
-#endif
-
-#include <ctype.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
 #include <libcitadel.h>
-#include "citadel.h"
-#include "server.h"
-#include "sysdep_decls.h"
-#include "threads.h"
-#include "citserver.h"
-#include "config.h"
-#include "database.h"
-#include "housekeeping.h"
-#include "user_ops.h"
-#include "msgbase.h"
-#include "support.h"
-#include "locate_host.h"
-#include "room_ops.h"
-#include "control.h"
-#include "euidindex.h"
-#include "context.h"
-#include "svn_revision.h"
+
+#include "serv_extensions.h"
 #include "ctdl_module.h"
 
+void cmd_log_get(char *argbuf)
+{
+       long HKLen;
+       const char *ch;
+       HashPos *Pos;
+       void *vptr;
+
+       if (CtdlAccessCheck(ac_aide)) return;
+
+       cprintf("%d Log modules enabled:\n", LISTING_FOLLOWS);
+
+       Pos = GetNewHashPos(LogDebugEntryTable, 0);
+
+       while (GetNextHashPos(LogDebugEntryTable, Pos, &HKLen, &ch, &vptr)) {
+               LogDebugEntry *E = (LogDebugEntry*)vptr;
+               cprintf("%s|%d\n", ch, *E->LogP);
+       }
+       
+       DeleteHashPos(&Pos);
+       cprintf("000\n");
+}
+void cmd_log_set(char *argbuf)
+{
+       void *vptr;
+       int lset;
+       int wlen;
+       char which[SIZ] = "";
+
+       if (CtdlAccessCheck(ac_aide)) return;
+
+       wlen = extract_token(which, argbuf, 0, '|', sizeof(which));
+       if (wlen < 0) wlen = 0;
+       lset = extract_int(argbuf, 1);
+       if (lset != 0) lset = 1;
+       if (GetHash(LogDebugEntryTable, which, wlen, &vptr) && 
+           (vptr != NULL))
+       {
+               LogDebugEntry *E = (LogDebugEntry*)vptr;
+               E->F(lset);
+               cprintf("%d %s|%d\n", CIT_OK, which, lset);
+       }
+       else {
+               cprintf("%d Log setting %s not known\n", 
+                       ERROR, which);
+       }
+}
 
 
 /*
@@ -146,6 +145,16 @@ void cmd_scdn(char *argbuf)
        cprintf(Reply, state, ScheduledShutdown);
 }
 
+/*
+ * Manually initiate log file cull.
+ */
+void cmd_cull(char *argbuf) {
+       if (CtdlAccessCheck(ac_internal)) return;
+       cdb_cull_logs();
+       cprintf("%d Database log file cull completed.\n", CIT_OK);
+}
+
+
 
 /*****************************************************************************/
 /*                      MODULE INITIALIZATION STUFF                          */
@@ -154,9 +163,14 @@ void cmd_scdn(char *argbuf)
 CTDL_MODULE_INIT(syscmd)
 {
        if (!threading) {
+               CtdlRegisterProtoHook(cmd_log_get, "LOGP", "Print Log-parameters");
+               CtdlRegisterProtoHook(cmd_log_set, "LOGS", "Set Log-parameters");
+
                CtdlRegisterProtoHook(cmd_down, "DOWN", "perform a server shutdown");
                CtdlRegisterProtoHook(cmd_halt, "HALT", "halt the server without exiting the server process");
                CtdlRegisterProtoHook(cmd_scdn, "SCDN", "schedule or cancel a server shutdown");
+
+               CtdlRegisterProtoHook(cmd_cull, "CULL", "Cull database logs");
        }
         /* return our id for the Log */
        return "syscmd";