Renamed all groupdav_() functions to dav_()
[citadel.git] / webcit / subst.c
index 9a0be445f4f495be998a9a105fc09bb801fbcfb8..f1a01cf55807ce286e726afdbe55b60223d5e3bd 100644 (file)
@@ -71,7 +71,7 @@ typedef struct _HashHandler {
        WCHandlerFunc HandlerFunc;
 }HashHandler;
 
-void *load_template(WCTemplate *NewTemplate);
+void *load_template(StrBuf *Target, WCTemplate *NewTemplate);
 int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams *TP);
 
 
@@ -758,8 +758,10 @@ int GetNextParameter(StrBuf *Buf,
                else {
                        StrBufPeek(Buf, pch, -1, '\0');         
                        if (LoadTemplates > 1) {                        
-                               syslog(1, "DBG: got param [%s] %ld %ld\n", 
-                                       pchs, pche - pchs, strlen(pchs));
+                               syslog(1,
+                                       "DBG: got param [%s] %d %d\n", 
+                                       pchs, pche - pchs, strlen(pchs)
+                               );
                        }
                        Parm->Start = pchs;
                        Parm->len = pche - pchs;
@@ -1194,7 +1196,7 @@ void *duplicate_template(WCTemplate *OldTemplate)
 }
 
 
-void SanityCheckTemplate(WCTemplate *CheckMe)
+void SanityCheckTemplate(StrBuf *Target, WCTemplate *CheckMe)
 {
        int i = 0;
        int j;
@@ -1224,10 +1226,17 @@ void SanityCheckTemplate(WCTemplate *CheckMe)
                        }
                        if (!FoundConditionalEnd)
                        {
-                               syslog(1, "ERROR: Conditional without Endconditional: '%s'\n",
-                                      ChrPtr(CheckMe->Tokens[i]->FlatToken));
+                               WCTemplputParams TP;
+                               memset(&TP, 0, sizeof(WCTemplputParams));
+                               TP.Tokens = CheckMe->Tokens[i];
+                               LogTemplateError(
+                                       Target, "Token", ERR_PARM1, &TP,
+                                       "Conditional without Endconditional"
+                                       );
                        }
                        break;
+               default:
+                       break;
                }
        }
 }
@@ -1236,7 +1245,7 @@ void SanityCheckTemplate(WCTemplate *CheckMe)
  * \brief Display a variable-substituted template
  * \param templatename template file to load
  */
-void *load_template(WCTemplate *NewTemplate)
+void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
 {
        int fd;
        struct stat statbuf;
@@ -1322,7 +1331,7 @@ void *load_template(WCTemplate *NewTemplate)
                }
        }
 
-       SanityCheckTemplate(NewTemplate);
+       SanityCheckTemplate(NULL, NewTemplate);
        return NewTemplate;
 }
 
@@ -1521,7 +1530,7 @@ void InitTemplateCache(void)
                                              &vTemplate) && 
                               (vTemplate != NULL))
                        {
-                               load_template((WCTemplate *)vTemplate);
+                               load_template(NULL, (WCTemplate *)vTemplate);
                        }
                        DeleteHashPos(&At);
                }
@@ -1640,7 +1649,7 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
                        syslog(1, "DBG: ----- loading:  [%s] ------ \n", 
                                ChrPtr(Tmpl->FileName));
                pTmpl = duplicate_template(Tmpl);
-               if(load_template(pTmpl) == NULL) {
+               if(load_template(Target, pTmpl) == NULL) {
                        StrBufAppendPrintf(
                                Target, 
                                "<pre>\nError loading Template [%s]\n See Logfile for details\n</pre>\n",