* give the URL params into the templates with BSTR and COND:BSTR
authorWilfried Göesgens <willi@citadel.org>
Thu, 11 Sep 2008 12:15:11 +0000 (12:15 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 11 Sep 2008 12:15:11 +0000 (12:15 +0000)
webcit/webcit.c

index 166842da332b6bd5c6013db0372fb560a9ae54c3..1704cfb934196fe7c34ac19eade15a14bfa44328 100644 (file)
@@ -1848,6 +1848,25 @@ void tmplput_offer_start_page(StrBuf *Target, int nArgs, WCTemplateToken *Tokens
        offer_start_page();
 }
 
+
+int ConditionalBstr(WCTemplateToken *Tokens, void *Context)
+{
+       if(Tokens->nParameters == 1)
+               return HaveBstr(Tokens->Params[0]->Start, 
+                               Tokens->Params[0]->len);
+       else
+               return strcmp(Bstr(Tokens->Params[0]->Start, 
+                                  Tokens->Params[0]->len),
+                             Tokens->Params[1]->Start) == 0;
+}
+
+void tmplput_bstr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
+{
+       StrBufAppendBuf(Target, 
+                       SBstr(Tokens->Params[0]->Start, 
+                             Tokens->Params[0]->len), 0);
+}
+
 void 
 InitModule_WEBCIT
 (void)
@@ -1863,6 +1882,8 @@ InitModule_WEBCIT
        WebcitAddUrlHandler(HKEY("mimepart_download"), download_mimepart, NEED_URL);
        WebcitAddUrlHandler(HKEY("diagnostics"), diagnostics, NEED_URL);
        RegisterConditional(HKEY("COND:IMPMSG"), 0, ConditionalImportantMesage);
+       RegisterConditional(HKEY("COND:BSTR"), 1, ConditionalBstr);
+       RegisterNamespace("BSTR", 1, 2, tmplput_bstr);
        RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage);
        RegisterNamespace("OFFERSTARTPAGE", 0, 0, tmplput_offer_start_page);
 }