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);
"Context VCARD",
"Context SIEVE List",
"Context SIEVE Script",
+ "Context MailQ-Item",
+ "Context MailQ-Recipient",
+ "Context ServLogStatus",
"Context UNKNOWN"
};
}
-/**
- * \brief puts string into the template and computes which escape methon we should use
- * \param Source the string we should put into the template
- * \param FormatTypeIndex where should we look for escape types if?
+/*
+ * puts string into the template and computes which escape methon we should use
+ * Source = the string we should put into the template
+ * FormatTypeIndex = where should we look for escape types if?
*/
void StrBufAppendTemplate(StrBuf *Target,
WCTemplputParams *TP,
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;
return NewTemplate;
}
+
+void SanityCheckTemplate(StrBuf *Target, WCTemplate *CheckMe)
+{
+ int i = 0;
+ int j;
+ int FoundConditionalEnd;
+
+ for (i = 0; i < CheckMe->nTokensUsed; i++)
+ {
+ switch(CheckMe->Tokens[i]->Flags)
+ {
+ case SV_CONDITIONAL:
+ case SV_NEG_CONDITIONAL:
+ FoundConditionalEnd = 0;
+ if ((CheckMe->Tokens[i]->Params[0]->len == 1) &&
+ (CheckMe->Tokens[i]->Params[0]->Start[0] == 'X'))
+ break;
+ for (j = i + 1; j < CheckMe->nTokensUsed; j++)
+ {
+ if (((CheckMe->Tokens[j]->Flags == SV_CONDITIONAL) ||
+ (CheckMe->Tokens[j]->Flags == SV_NEG_CONDITIONAL)) &&
+ (CheckMe->Tokens[i]->Params[1]->lvalue ==
+ CheckMe->Tokens[j]->Params[1]->lvalue))
+ {
+ FoundConditionalEnd = 1;
+ break;
+ }
+
+ }
+ if (!FoundConditionalEnd)
+ {
+ WCTemplputParams TP;
+ memset(&TP, 0, sizeof(WCTemplputParams));
+ TP.Tokens = CheckMe->Tokens[i];
+ LogTemplateError(
+ Target, "Token", ERR_PARM1, &TP,
+ "Conditional without Endconditional"
+ );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
+
/**
* \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;
pch ++;
}
}
+
+ SanityCheckTemplate(NULL, NewTemplate);
return NewTemplate;
}
&vTemplate) &&
(vTemplate != NULL))
{
- load_template((WCTemplate *)vTemplate);
+ load_template(NULL, (WCTemplate *)vTemplate);
}
DeleteHashPos(&At);
}
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",