]> code.citadel.org Git - citadel.git/blobdiff - webcit/subst.c
MAILINGLIST: add facility to choose the default room email alias.
[citadel.git] / webcit / subst.c
index 95e7d47a9746c935f1bb1bc5d7a54dc15e72d834..130b1a12ac61bd7e2811d485d7775c11527f4803 100644 (file)
@@ -163,6 +163,8 @@ void StackDynamicContext(WCTemplputParams *Super,
                Sub->Sub = Super->Sub;
                Super->Sub = Sub;
        }
+       if (Sub->Sub != NULL)
+               Sub->Sub->Super = Sub;
        Sub->Super = Super;
        
        Sub->Context = Context;
@@ -179,6 +181,10 @@ void UnStackContext(WCTemplputParams *Sub)
        {
                Sub->Super->Sub = Sub->Sub;
        }
+       if (Sub->Sub != NULL)
+       {
+               Sub->Sub->Super = Sub->Super;
+       }
 }
 void UnStackDynamicContext(StrBuf *Target, WCTemplputParams **TPP)
 {
@@ -315,9 +321,6 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
 */
 }
 
-
-
-
 void LogError (StrBuf *Target, const char *Type, const char *Format, ...)
 {
        wcsession *WCC;
@@ -392,7 +395,7 @@ int CheckContext(StrBuf *Target, ContextFilter *Need, WCTemplputParams *TP, cons
                        return 1;
 
                 LogTemplateError(
-                        Target, ErrType, ERR_PARM1, TP,
+                        Target, ErrType, ERR_NAME, TP,
                        "  WARNING: requires Context: [%s], have [%s]!", 
                        ContextName(Need->ContextType), 
                        ContextName(TP->Filter.ContextType));
@@ -1801,6 +1804,8 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
        WCTemplputParams TP;
        WCTemplputParams *TPtr = &TP;
 
+       memset(TPtr, 0, sizeof(WCTemplputParams));
+
        memcpy(&TP.Filter, &CallingTP->Filter, sizeof(ContextFilter));
 
        TP.Context = CallingTP->Context;
@@ -1851,7 +1856,7 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
                        else if (TokenRc < 0)
                        {
                                if ((TPtr != &TP) &&
-                                   (TPtr->ExitCTXID == TokenRc))
+                                   (TPtr->ExitCTXID == -TokenRc))
                                {
                                        UnStackDynamicContext(Target, &TPtr);
                                }
@@ -1872,10 +1877,15 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
                                                pTmpl->Tokens[i]->Flags, 
                                                TokenRc, 
                                                &TPtr);
-                                       if (rc == -TokenRc)
+                                       if (-rc == TokenRc)
                                        {
                                                TokenRc = 0;
                                                state = eNext;
+                                               if ((TPtr != &TP) &&
+                                                   (TPtr->ExitCTXID == - rc))
+                                               {
+                                                       UnStackDynamicContext(Target, &TPtr);
+                                               }
                                        }
                                }
                        }
@@ -2249,10 +2259,12 @@ int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams **T
        res = Cond->CondF(Target, TP);
        if (res == Neg)
                rc = TP->Tokens->Params[1]->lvalue;
+
        if (LoadTemplates > 5) 
                syslog(1, "<%s> : %d %d==%d\n", 
                        ChrPtr(TP->Tokens->FlatToken), 
                        rc, res, Neg);
+
        if (TP->Sub != NULL)
        {
                *TPP = TP->Sub;