From 257b0a4aad71f1702efdbfb0981957816d51ce21 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sun, 18 Jan 2009 19:33:45 +0000 Subject: [PATCH] + add flag to print backtraces in template logging error... * we need to substitute all contexts.. --- webcit/messages.c | 6 +++--- webcit/subst.c | 20 ++++++++++++++++---- webcit/webserver.c | 6 ++++-- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/webcit/messages.c b/webcit/messages.c index 015e36187..b679a5ebb 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -12,7 +12,7 @@ HashList *MsgHeaderHandler = NULL; HashList *MsgEvaluators = NULL; HashList *MimeRenderHandler = NULL; -int analyze_msg = 0; +int dbg_analyze_msg = 0; #define SUBJ_COL_WIDTH_PCT 50 /**< Mailbox view column width */ #define SENDER_COL_WIDTH_PCT 30 /**< Mailbox view column width */ @@ -109,7 +109,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in StrBufCutLeft(Buf, StrLength(HdrToken) + 1); #ifdef TECH_PREVIEW - if (analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf)); + if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf)); #endif /* look up one of the examine_* functions to parse the content */ if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) && @@ -136,7 +136,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in if (StrLength(HdrToken) > 0) { StrBufCutLeft(Buf, StrLength(HdrToken) + 1); #ifdef TECH_PREVIEW - if (analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf)); + if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf)); #endif /* the examine*'s know how to do with mime headers too... */ if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) && diff --git a/webcit/subst.c b/webcit/subst.c index 249a88699..309bf53ff 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -33,6 +33,7 @@ HashList *Conditionals; HashList *SortHash; int LoadTemplates = 0; +int dbg_bactrace_template_errors = 0; WCTemplputParams NoCtx; #define SV_GETTEXT 1 @@ -174,6 +175,9 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu Type, ChrPtr(Error)); } + if (dbg_bactrace_template_errors) + wc_backtrace(); + } @@ -1470,7 +1474,7 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams *TP) -void ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, void *Context, int ContextType) +void ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams *CallingTP) { WCTemplate *pTmpl = Tmpl; int done = 0; @@ -1479,8 +1483,10 @@ void ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, void *Context, int Contex long len; WCTemplputParams TP; - TP.Context = Context; - TP.Filter.ContextType = ContextType; + memcpy(&TP.Filter, &CallingTP->Filter, sizeof(ContextFilter)); + + TP.Context = CallingTP->Context; + TP.ControlContext = CallingTP->ControlContext; if (LoadTemplates != 0) { if (LoadTemplates > 1) @@ -1548,12 +1554,18 @@ void ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, void *Context, int Contex */ void DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP) { + WCTemplputParams LocalTP; HashList *Static; HashList *StaticLocal; void *vTmpl; if (Target == NULL) Target = WC->WBuf; + if (TP == NULL) { + memset(&LocalTP, 0, sizeof(WCTemplputParams)); + TP = &LocalTP; + } + if (WC->is_mobile) { Static = WirelessTemplateCache; StaticLocal = WirelessLocalTemplateCache; @@ -1584,7 +1596,7 @@ void DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputPa } if (vTmpl == NULL) return; - ProcessTemplate(vTmpl, Target, TP->Context, TP->Filter.ContextType); + ProcessTemplate(vTmpl, Target, TP); } /*----------------------------------------------------------------------------- diff --git a/webcit/webserver.c b/webcit/webserver.c index 4a32ae20a..edd3c85cf 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -610,7 +610,8 @@ void spawn_another_worker_thread() const char foobuf[32]; const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return foobuf;} #endif -extern int analyze_msg; +extern int dbg_analyze_msg; +extern int dbg_bactrace_template_errors; void InitTemplateCache(void); extern int LoadTemplates; extern void LoadZoneFiles(void); @@ -713,7 +714,8 @@ int main(int argc, char **argv) break; case 'T': LoadTemplates = atoi(optarg); - analyze_msg = (LoadTemplates && 0x2) != 0; + dbg_analyze_msg = (LoadTemplates && (1<<1)) != 0; + dbg_bactrace_template_errors = (LoadTemplates && (1<<2)) != 0; break; case 'Z': DisableGzip = 1; -- 2.39.2