* Structure defentitions for hook tables
*/
-
+typedef struct __LogDebugEntry {
+ CtdlDbgFunction F;
+ const char *Name;
+ long Len;
+ const int *LogP;
+} LogDebugEntry;
+HashList *LogDebugEntryTable = NULL;
typedef struct LogFunctionHook LogFunctionHook;
struct LogFunctionHook {
};
extern LogFunctionHook *LogHookTable;
-
typedef struct FixedOutputHook FixedOutputHook;
struct FixedOutputHook {
FixedOutputHook *next;
return ret;
}
+void CtdlRegisterDebugFlagHook(const char *Name, long Len, CtdlDbgFunction F, const int *LogP)
+{
+ LogDebugEntry *E;
+ if (LogDebugEntryTable == NULL)
+ LogDebugEntryTable = NewHash(1, NULL);
+ E = (LogDebugEntry*) malloc(sizeof(LogDebugEntry));
+ E->F = F;
+ E->Name = Name;
+ E->Len = Len;
+ E->LogP = LogP;
+ Put(LogDebugEntryTable, Name, Len, E, NULL);
+
+}
+void CtdlSetDebugLogFacilities(const char **Str, long n)
+{
+ StrBuf *Token = NULL;
+ StrBuf *Buf = NULL;
+ const char *ch;
+ int i;
+ int DoAll = 0;
+ void *vptr;
+
+ for (i=0; i < n; i++){
+ if ((Str[i] != NULL) && !IsEmptyStr(Str[i])) {
+ if (strcmp(Str[i], "all") == 0) {
+ DoAll = 1;
+ continue;
+ }
+ Buf = NewStrBufPlain(Str[i], -1);
+ ch = NULL;
+ if (Token == NULL)
+ Token = NewStrBufPlain(NULL, StrLength(Buf));
+ while ((ch != StrBufNOTNULL) &&
+ StrBufExtract_NextToken(Token, Buf, &ch, ',')) {
+ if (GetHash(LogDebugEntryTable, SKEY(Token), &vptr) &&
+ (vptr != NULL))
+ {
+ LogDebugEntry *E = (LogDebugEntry*)vptr;
+ E->F(1);
+ }
+ }
+ }
+ FreeStrBuf(&Buf);
+ }
+ FreeStrBuf(&Token);
+ if (DoAll) {
+ long HKLen;
+ const char *ch;
+ HashPos *Pos;
+
+ Pos = GetNewHashPos(LogDebugEntryTable, 0);
+ while (GetNextHashPos(LogDebugEntryTable, Pos, &HKLen, &ch, &vptr)) {
+ LogDebugEntry *E = (LogDebugEntry*)vptr;
+ E->F(1);
+ }
+
+ DeleteHashPos(&Pos);
+ }
+}
+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);
+ }
+}
+void CtdlDestroyDebugTable(void)
+{
+
+ DeleteHash(&LogDebugEntryTable);
+}
+
void CtdlRegisterProtoHook(void (*handler) (char *), char *cmd, char *desc)
{
ProtoFunctionHook *p;
CtdlStartTLS (ok_response, nosup_response, error_response);
#endif
}
+
+
+CTDL_MODULE_INIT(modules)
+{
+ if (!threading) {
+ CtdlRegisterProtoHook(cmd_log_get, "LOGP", "Print Log-parameters");
+ CtdlRegisterProtoHook(cmd_log_set, "LOGS", "Set Log-parameters");
+ }
+ return "modules";
+}