* Structure defentitions for hook tables
*/
-
+typedef struct __LogDebugEntry {
+ CtdlDbgFunction F;
+ const char *Name;
+ long Len;
+} LogDebugEntry;
+HashList *LogDebugEntryTable = NULL;
typedef struct LogFunctionHook LogFunctionHook;
struct LogFunctionHook {
};
extern LogFunctionHook *LogHookTable;
-
typedef struct FixedOutputHook FixedOutputHook;
struct FixedOutputHook {
FixedOutputHook *next;
return ret;
}
+/*
+typedef struct __LogDebugEntry {
+ CtdlDbgFunction F;
+ const char *Name;
+ long Len;
+} LogDebugEntry;
+HashList *LogDebugEntryTable = NULL;
+*/
+void CtdlRegisterDebugFlagHook(const char *Name, long Len, CtdlDbgFunction F)
+{
+ LogDebugEntry *E;
+ if (LogDebugEntryTable == NULL)
+ LogDebugEntryTable = NewHash(1, NULL);
+ E = (LogDebugEntry*) malloc(sizeof(LogDebugEntry));
+ E->F = F;
+ E->Name = Name;
+ E->Len = Len;
+ 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();
+ }
+ }
+ }
+ 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();
+ }
+
+ DeleteHashPos(&Pos);
+ }
+}
+void CtdlDestroyDebugTable(void)
+{
+
+ DeleteHash(&LogDebugEntryTable);
+}
void CtdlRegisterProtoHook(void (*handler) (char *), char *cmd, char *desc)
{
/*
*/
+typedef void (*CtdlDbgFunction) (void);
+
/*
void CtdlDestroyFixedOutputHooks(void);
int PerformFixedOutputHooks(char *, char *, int);
+
+void CtdlRegisterDebugFlagHook(const char *Name, long len, CtdlDbgFunction F);
+void CtdlSetDebugLogFacilities(const char **Str, long n);
+void CtdlDestroyDebugTable(void);
+
#endif /* SERV_EXTENSIONS_H */
char relhome[PATH_MAX]="";
char ctdldir[PATH_MAX]=CTDLDIR;
int syslog_facility = LOG_DAEMON;
+ const char *eDebuglist[] = {NULL, NULL};
#ifdef HAVE_RUN_DIR
struct stat filestats;
#endif
home=1;
break;
- case 'x': /* deprecated */
+ case 'x':
+ eDebuglist [0] = optarg;
break;
case 't': /* deprecated */
initialise_modules(0);
+ eDebuglist[1] = getenv("CITADEL_LOGDEBUG");
+ CtdlSetDebugLogFacilities(eDebuglist, 2);
+
/*
* If we need host auth, start our chkpwd daemon.
*/