]> code.citadel.org Git - citadel.git/blobdiff - webcit/subst.c
* Templatize IGNet Node Config
[citadel.git] / webcit / subst.c
index 38f1bae356a1631921c6cb999a617c58b1a23707..32000bb3fc4f7c59b8fe89a55191c37589dcde07 100644 (file)
@@ -376,7 +376,7 @@ inline void SVCALLBACK(char *keyname, var_callback_fptr fcn_ptr)
 
 
 
-void SVPUTBuf(const char *keyname, int keylen, StrBuf *Buf, int ref)
+void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref)
 {
        wcsubst *ptr;
        void *vPtr;
@@ -396,7 +396,7 @@ void SVPUTBuf(const char *keyname, int keylen, StrBuf *Buf, int ref)
        {
                ptr = NewSubstVar(keyname, keylen, (ref)?WCS_STRBUF_REF:WCS_STRBUF);
        }
-       ptr->wcs_value = Buf;
+       ptr->wcs_value = (StrBuf*)Buf;
 }
 
 /**
@@ -1010,6 +1010,8 @@ void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere)
                const char *pts, *pte;
                int InQuotes = 0;
                int InDoubleQuotes = 0;
+
+               /** Find one <? > */
                pos = (-1);
                for (; pch < pE; pch ++) {
                        if ((*pch=='<')&&(*(pch + 1)=='?'))
@@ -1019,6 +1021,8 @@ void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere)
                if (pch >= pE)
                        continue;
                pts = pch;
+
+               /** Found one? parse it. */
                for (; pch < pE - 1; pch ++) {
                        if (*pch == '"')
                                InDoubleQuotes = ! InDoubleQuotes;
@@ -1237,8 +1241,21 @@ void tmpl_iterate_subtmpl(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, vo
        if (!GetHash(Iterators, 
                     Tokens->Params[0]->Start,
                     Tokens->Params[0]->len,
-                    &vIt))
+                    &vIt)) {
+               lprintf(1, "unknown Iterator [%s] (in line %ld); "
+                       " [%s]\n", 
+                       Tokens->Params[0]->Start,
+                       Tokens->Line,
+                       ChrPtr(Tokens->FlatToken));
+               StrBufAppendPrintf(
+                       Target,
+                       "<pre>\nunknown Iterator [%s] (in line %ld); \n"
+                       " [%s]\n</pre>", 
+                       Tokens->Params[0]->Start,
+                       Tokens->Line,
+                       ChrPtr(Tokens->FlatToken));
                return;
+       }
 
        It = (HashIterator*) vIt;
 
@@ -1282,7 +1299,7 @@ void tmpl_iterate_subtmpl(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, vo
        FreeStrBuf(&SubBuf);
        DeleteHashPos(&it);
        if (It->Destructor != NULL)
-               It->Destructor(List);
+               It->Destructor(&List);
 }
 
 int ConditionalVar(WCTemplateToken *Tokens, void *Context)