+ add flag to print backtraces in template logging error...
authorWilfried Göesgens <willi@citadel.org>
Sun, 18 Jan 2009 19:33:45 +0000 (19:33 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 18 Jan 2009 19:33:45 +0000 (19:33 +0000)
* we need to substitute all contexts..

webcit/messages.c
webcit/subst.c
webcit/webserver.c

index 015e36187ac86ab10c84e46a21b379cb660da29f..b679a5ebb4c006b1e7233aa6d441e7c683f1edc8 100644 (file)
@@ -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) &&
index 249a88699fc391c4ae76dd5e7aeac8bce6d76537..309bf53ffc08c9b95241d2d7c282d90d752e5d9a 100644 (file)
@@ -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);
 }
 
 /*-----------------------------------------------------------------------------
index 4a32ae20a40e69661b57962e52b1210a88e89ad0..edd3c85cf627a95a199d01a4e65df8a51b3fc639 100644 (file)
@@ -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;