X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsubst.c;h=6e5ab6fc690248e63532ddf0408ae3c8bfff4cac;hb=715008dfb6283528fcac64dc21b88dcbb237abad;hp=334f4fdc2f965ead34c77fe83a215aa0ffebcaaa;hpb=ee139c6a2f60de4cc962f30ba845f0749fddbd5f;p=citadel.git
diff --git a/webcit/subst.c b/webcit/subst.c
index 334f4fdc2..6e5ab6fc6 100644
--- a/webcit/subst.c
+++ b/webcit/subst.c
@@ -1,6 +1,3 @@
-/*
- * $Id$
- */
#include "sysdep.h"
@@ -21,8 +18,6 @@
extern char *static_dirs[PATH_MAX]; /* Disk representation */
-HashList *WirelessTemplateCache;
-HashList *WirelessLocalTemplateCache;
HashList *TemplateCache;
HashList *LocalTemplateCache;
@@ -34,7 +29,7 @@ HashList *Defines;
int DumpTemplateI18NStrings = 0;
int LoadTemplates = 0;
-int dbg_bactrace_template_errors = 0;
+int dbg_backtrace_template_errors = 0;
WCTemplputParams NoCtx;
StrBuf *I18nDump = NULL;
@@ -76,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);
@@ -112,6 +107,12 @@ const char *CtxNames[] = {
"Context ITERATE",
"Context ICAL",
"Context DavNamespace",
+ "Context TAB",
+ "Context VCARD",
+ "Context SIEVE List",
+ "Context SIEVE Script",
+ "Context MailQ-Item",
+ "Context MailQ-Recipient",
"Context UNKNOWN"
};
@@ -160,7 +161,7 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
}
if (TP->Tokens != NULL)
{
- lprintf(1, "%s [%s] (in '%s' line %ld); %s; [%s]\n",
+ syslog(1, "%s [%s] (in '%s' line %ld); %s; [%s]\n",
Type,
Err,
ChrPtr(TP->Tokens->FileName),
@@ -170,7 +171,7 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
}
else
{
- lprintf(1, "%s: %s;\n",
+ syslog(1, "%s: %s;\n",
Type,
ChrPtr(Error));
}
@@ -237,7 +238,7 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
FreeStrBuf(&Info);
FreeStrBuf(&Error);
/*
- if (dbg_bactrace_template_errors)
+ if (dbg_backtrace_template_errors)
wc_backtrace();
*/
}
@@ -259,7 +260,7 @@ void LogError (StrBuf *Target, const char *Type, const char *Format, ...)
StrBufVAppendPrintf(Error, Format, arg_ptr);
va_end(arg_ptr);
- lprintf(1, ChrPtr(Error));
+ syslog(1, "%s", ChrPtr(Error));
WCC = WC;
if (WCC->WFBuf == NULL) WCC->WFBuf = NewStrBuf();
@@ -272,7 +273,7 @@ void LogError (StrBuf *Target, const char *Type, const char *Format, ...)
FreeStrBuf(&Info);
FreeStrBuf(&Error);
/*
- if (dbg_bactrace_template_errors)
+ if (dbg_backtrace_template_errors)
wc_backtrace();
*/
}
@@ -393,367 +394,6 @@ void FreeWCTemplate(void *vFreeMe)
free(FreeMe);
}
-
-/*
- * debugging function to print array to log
- */
-void VarPrintTransition(void *vVar1, void *vVar2, int odd){}
-
-/*
- * debugging function to print array to log
- */
-void VarPrintEntry(const char *Key, void *vSubst, int odd)
-{
- wcsubst *ptr;
- lprintf(1,"Subst[%s] : ", Key);
- ptr = (wcsubst*) vSubst;
-
- switch(ptr->wcs_type) {
- case WCS_STRING:
- lprintf(1, " -> %s\n", ChrPtr(ptr->wcs_value));
- break;
- case WCS_SERVCMD:
- lprintf(1, " -> Server [%s]\n", ChrPtr(ptr->wcs_value));
- break;
- case WCS_FUNCTION:
- lprintf(1, " -> function at [%0xd]\n", ptr->wcs_function);
- break;
- default:
- lprintf(1," WARNING: invalid type: [%ld]!\n", ptr->wcs_type);
- }
-}
-
-
-
-/*
- * Clear out the list of substitution variables local to this session
- */
-void clear_substs(wcsession *wc) {
-
- if (wc->vars != NULL) {
- DeleteHash(&wc->vars);
- }
-}
-
-/*
- * Clear out the list of substitution variables local to this session
- */
-void clear_local_substs(void) {
- clear_substs (WC);
-}
-
-int NeedNewBuf(int type)
-{
- switch(type) {
- case WCS_STRING:
- case WCS_SERVCMD:
- case WCS_STRBUF:
- return 1;
- case WCS_FUNCTION:
- case WCS_STRBUF_REF:
- case WCS_LONG:
- default:
- return 0;
- }
-}
-
-void FlushPayload(wcsubst *ptr, int reusestrbuf, int type)
-{
- int NeedNew = NeedNewBuf(type);
- switch(ptr->wcs_type) {
- case WCS_STRING:
- case WCS_SERVCMD:
- case WCS_STRBUF:
- if (reusestrbuf && NeedNew) {
- FlushStrBuf(ptr->wcs_value);
- }
- else {
-
- FreeStrBuf(&ptr->wcs_value);
- ptr->wcs_value = NULL;
- }
- break;
- case WCS_FUNCTION:
- ptr->wcs_function = NULL;
- if (reusestrbuf && NeedNew)
- ptr->wcs_value = NewStrBuf();
- break;
- case WCS_STRBUF_REF:
- ptr->wcs_value = NULL;
- if (reusestrbuf && NeedNew)
- ptr->wcs_value = NewStrBuf();
- break;
- case WCS_LONG:
- ptr->lvalue = 0;
- if (reusestrbuf && NeedNew)
- ptr->wcs_value = NewStrBuf();
- break;
- default:
- if (reusestrbuf && NeedNew)
- ptr->wcs_value = NewStrBuf();
- break;
- }
-}
-
-
-/*
- * destructor; kill one entry.
- */
-void deletevar(void *data)
-{
- wcsubst *ptr = (wcsubst*)data;
- FlushPayload(ptr, 0, ptr->wcs_type);
- free(ptr);
-}
-
-
-wcsubst *NewSubstVar(const char *keyname, int keylen, int type)
-{
- wcsubst* ptr;
- wcsession *WCC = WC;
-
- ptr = (wcsubst *) malloc(sizeof(wcsubst));
- memset(ptr, 0, sizeof(wcsubst));
-
- ptr->wcs_type = type;
- safestrncpy(ptr->wcs_key, keyname, sizeof ptr->wcs_key);
- Put(WCC->vars, keyname, keylen, ptr, deletevar);
-
- switch(ptr->wcs_type) {
- case WCS_STRING:
- case WCS_SERVCMD:
- ptr->wcs_value = NewStrBuf();
- break;
- case WCS_STRBUF:
- case WCS_FUNCTION:
- case WCS_STRBUF_REF:
- case WCS_LONG:
- default:
- break;
- }
- return ptr;
-}
-
-
-/*
- * Add a substitution variable (local to this session) (strlen version...)
- * keyname the replacementstring to substitute
- * keytype the kind of the key
- * format the format string ala printf
- * ... the arguments to substitute in the formatstring
- */
-void SVPRINTF(char *keyname, int keytype, const char *format,...)
-{
- va_list arg_ptr;
- void *vPtr;
- wcsubst *ptr = NULL;
- size_t keylen;
- wcsession *WCC = WC;
-
- keylen = strlen(keyname);
- /*
- * First look if we're doing a replacement of
- * an existing key
- */
- /*PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
- if (GetHash(WCC->vars, keyname, keylen, &vPtr)) {
- ptr = (wcsubst*)vPtr;
- FlushPayload(ptr, keytype, keytype);
- ptr->wcs_type = keytype;
- }
- else /** Otherwise allocate a new one */
- {
- ptr = NewSubstVar(keyname, keylen, keytype);
- }
-
- /* Format the string */
- va_start(arg_ptr, format);
- StrBufVAppendPrintf(ptr->wcs_value, format, arg_ptr);
- va_end(arg_ptr);
-}
-
-/*
- * Add a substitution variable (local to this session)
- * keyname the replacementstring to substitute
- * keytype the kind of the key
- * format the format string ala printf
- * ... the arguments to substitute in the formatstring
- */
-void svprintf(char *keyname, size_t keylen, int keytype, const char *format,...)
-{
- va_list arg_ptr;
- void *vPtr;
- wcsubst *ptr = NULL;
- wcsession *WCC = WC;
-
- /*
- * First look if we're doing a replacement of
- * an existing key
- */
- /*PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
- if (GetHash(WCC->vars, keyname, keylen, &vPtr)) {
- ptr = (wcsubst*)vPtr;
- FlushPayload(ptr, 1, keytype);
- ptr->wcs_type = keytype;
- }
- else /** Otherwise allocate a new one */
- {
- ptr = NewSubstVar(keyname, keylen, keytype);
- }
-
- /** Format the string and save it */
- va_start(arg_ptr, format);
- StrBufVAppendPrintf(ptr->wcs_value, format, arg_ptr);
- va_end(arg_ptr);
-}
-
-/*
- * Add a substitution variable (local to this session)
- * keyname the replacementstring to substitute
- * keytype the kind of the key
- * format the format string ala printf
- * ... the arguments to substitute in the formatstring
- */
-void SVPut(char *keyname, size_t keylen, int keytype, char *Data)
-{
- void *vPtr;
- wcsubst *ptr = NULL;
- wcsession *WCC = WC;
-
-
- /*
- * First look if we're doing a replacement of
- * an existing key
- */
- /*PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
- if (GetHash(WCC->vars, keyname, keylen, &vPtr)) {
- ptr = (wcsubst*)vPtr;
- FlushPayload(ptr, 1, keytype);
- ptr->wcs_type = keytype;
- }
- else /** Otherwise allocate a new one */
- {
- ptr = NewSubstVar(keyname, keylen, keytype);
- }
- StrBufAppendBufPlain(ptr->wcs_value, Data, -1, 0);
-}
-
-/**
- * \brief Add a substitution variable (local to this session)
- * \param keyname the replacementstring to substitute
- * \param keytype the kind of the key
- * \param format the format string ala printf
- * \param ... the arguments to substitute in the formatstring
- */
-void SVPutLong(char *keyname, size_t keylen, long Data)
-{
- void *vPtr;
- wcsubst *ptr = NULL;
- wcsession *WCC = WC;
-
-
- /**
- * First look if we're doing a replacement of
- * an existing key
- */
- /*PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
- if (GetHash(WCC->vars, keyname, keylen, &vPtr)) {
- ptr = (wcsubst*)vPtr;
- FlushPayload(ptr, 1, WCS_LONG);
- ptr->wcs_type = WCS_LONG;
- }
- else /** Otherwise allocate a new one */
- {
- ptr = NewSubstVar(keyname, keylen, WCS_LONG);
- }
- ptr->lvalue = Data;
-}
-
-/**
- * \brief Add a substitution variable (local to this session) that does a callback
- * \param keyname the keystring to substitute
- * \param fcn_ptr the function callback to give the substitution string
- */
-void SVCallback(char *keyname, size_t keylen, WCHandlerFunc fcn_ptr)
-{
- wcsubst *ptr;
- void *vPtr;
- wcsession *WCC = WC;
-
- /**
- * First look if we're doing a replacement of
- * an existing key
- */
- /*PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
- if (GetHash(WCC->vars, keyname, keylen, &vPtr)) {
- ptr = (wcsubst*)vPtr;
- FlushPayload(ptr, 1, WCS_FUNCTION);
- ptr->wcs_type = WCS_FUNCTION;
- }
- else /** Otherwise allocate a new one */
- {
- ptr = NewSubstVar(keyname, keylen, WCS_FUNCTION);
- }
-
- ptr->wcs_function = fcn_ptr;
-}
-inline void SVCALLBACK(char *keyname, WCHandlerFunc fcn_ptr)
-{
- SVCallback(keyname, strlen(keyname), fcn_ptr);
-}
-
-
-
-void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref)
-{
- wcsubst *ptr;
- void *vPtr;
- wcsession *WCC = WC;
-
- /**
- * First look if we're doing a replacement of
- * an existing key
- */
- /*PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
- if (GetHash(WCC->vars, keyname, keylen, &vPtr)) {
- ptr = (wcsubst*)vPtr;
- FlushPayload(ptr, 0, (ref)?WCS_STRBUF_REF:WCS_STRBUF);
- ptr->wcs_type = (ref)?WCS_STRBUF_REF:WCS_STRBUF;
- }
- else /** Otherwise allocate a new one */
- {
- ptr = NewSubstVar(keyname, keylen, (ref)?WCS_STRBUF_REF:WCS_STRBUF);
- }
- ptr->wcs_value = (StrBuf*)Buf;
-}
-
-/**
- * \brief back end for print_value_of() ... does a server command
- * \param servcmd server command to execute on the citadel server
- */
-void pvo_do_cmd(StrBuf *Target, StrBuf *servcmd) {
- char buf[SIZ];
- int len;
-
- serv_puts(ChrPtr(servcmd));
- len = serv_getln(buf, sizeof buf);
-
- switch(buf[0]) {
- case '2':
- case '3':
- case '5':
- StrBufAppendPrintf(Target, "%s\n", &buf[4]);
- break;
- case '1':
- _fmout(Target, "CENTER");
- break;
- case '4':
- StrBufAppendPrintf(Target, "%s\n", &buf[4]);
- serv_puts("000");
- break;
- }
-}
-
int HaveTemplateTokenString(StrBuf *Target,
WCTemplputParams *TP,
int N,
@@ -862,7 +502,7 @@ void GetTemplateTokenString(StrBuf *Target,
*Value = ChrPtr(Buf);
*len = StrLength(Buf);
/* we can't free it here, so we put it into the subst so its discarded later on. */
- SVPUTBuf(TKEY(N), Buf, 0);
+ PutRequestLocalMem(Buf, HFreeStrBuf);
break;
default:
@@ -943,129 +583,6 @@ long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long df
}
-
-/**
- * \brief Print the value of a variable
- * \param keyname get a key to print
- */
-void print_value_of(StrBuf *Target, WCTemplputParams *TP)
-
-{
- wcsession *WCC = WC;
- wcsubst *ptr;
- void *vVar;
-
- /*if (WCC->vars != NULL) PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
- /* TODO: depricated! */
- if (TP->Tokens->pName[0] == '=') {
- DoTemplate(TP->Tokens->pName+1, TP->Tokens->NameEnd - 1, NULL, &NoCtx);
- }
-/*/////TODO: if param[1] == "U" -> urlescape
-/// X -> escputs */
- /** Page-local variables */
- if ((WCC->vars!= NULL) && GetHash(WCC->vars, TP->Tokens->pName, TP->Tokens->NameEnd, &vVar)) {
- ptr = (wcsubst*) vVar;
- switch(ptr->wcs_type) {
- case WCS_STRING:
- StrBufAppendBuf(Target, ptr->wcs_value, 0);
- break;
- case WCS_SERVCMD:
- pvo_do_cmd(Target, ptr->wcs_value);
- break;
- case WCS_FUNCTION:
- (*ptr->wcs_function) (Target, TP);
- break;
- case WCS_STRBUF:
- case WCS_STRBUF_REF:
- StrBufAppendBuf(Target, ptr->wcs_value, 0);
- break;
- case WCS_LONG:
- StrBufAppendPrintf(Target, "%ld", ptr->lvalue);
- break;
- default:
- LogTemplateError(
- Target, "Subst", ERR_NAME, TP,
- "WARNING: invalid value in SV-Hash at %s!", TP->Tokens->pName);
- }
- }
- else {
- LogTemplateError(
- Target, "Token", ERR_NAME, TP,
- "didn't find Handler \"%s\"", TP->Tokens->pName);
- wc_backtrace();
- }
-}
-
-int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup)
-{
- wcsession *WCC = WC;
- wcsubst *ptr;
- void *vVar;
-
- if ((WCC->vars!= NULL) && GetHash(WCC->vars, ParamToLookup->Start,
- ParamToLookup->len, &vVar)) {
- ptr = (wcsubst*) vVar;
- switch(ptr->wcs_type) {
- case WCS_STRING:
- case WCS_STRBUF:
- case WCS_STRBUF_REF:
- if (ParamToCompare->Type == TYPE_STR)
- return ((ParamToCompare->len == StrLength(ptr->wcs_value)) &&
- (strcmp(ParamToCompare->Start, ChrPtr(ptr->wcs_value)) == 0));
- else
- return ParamToCompare->lvalue == StrTol(ptr->wcs_value);
- break;
- case WCS_SERVCMD:
- return 1;
- break;
- case WCS_FUNCTION:
- return 1;
- case WCS_LONG:
- if (ParamToCompare->Type == TYPE_STR)
- return 0;
- else
- return ParamToCompare->lvalue == ptr->lvalue;
- break;
- default:
- lprintf(1,"WARNING: invalid value in SV-Hash at %s!\n",
- ParamToLookup->Start);
- }
- }
- return 0;
-}
-
-int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup)
-{
- wcsession *WCC = WC;
- wcsubst *ptr;
- void *vVar;
-
- if ((WCC->vars!= NULL) && GetHash(WCC->vars, ParamToLookup->Start,
- ParamToLookup->len, &vVar)) {
- ptr = (wcsubst*) vVar;
- switch(ptr->wcs_type) {
- case WCS_STRING:
- case WCS_STRBUF:
- case WCS_STRBUF_REF:
- return ((StrLength(Compare) == StrLength(ptr->wcs_value)) &&
- (strcmp(ChrPtr(Compare), ChrPtr(ptr->wcs_value)) == 0));
- case WCS_SERVCMD:
- return 1;
- break;
- case WCS_FUNCTION:
- return 1;
- case WCS_LONG:
- return StrTol(Compare) == ptr->lvalue;
- default:
- lprintf(1,"WARNING: invalid value in SV-Hash at %s!\n",
- ParamToLookup->Start);
- }
- }
- return 0;
-}
-
-
-
/**
* \brief puts string into the template and computes which escape methon we should use
* \param Source the string we should put into the template
@@ -1075,19 +592,19 @@ void StrBufAppendTemplate(StrBuf *Target,
WCTemplputParams *TP,
const StrBuf *Source, int FormatTypeIndex)
{
- wcsession *WCC;
+ const char *pFmt = NULL;
char EscapeAs = ' ';
if ((FormatTypeIndex < TP->Tokens->nParameters) &&
(TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) &&
- (TP->Tokens->Params[FormatTypeIndex]->len == 1)) {
- EscapeAs = *TP->Tokens->Params[FormatTypeIndex]->Start;
+ (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) {
+ pFmt = TP->Tokens->Params[FormatTypeIndex]->Start;
+ EscapeAs = *pFmt;
}
switch(EscapeAs)
{
case 'H':
- WCC = WC;
StrEscAppend(Target, Source, NULL, 0, 2);
break;
case 'X':
@@ -1102,6 +619,12 @@ void StrBufAppendTemplate(StrBuf *Target,
case 'U':
StrBufUrlescAppend(Target, Source, NULL);
break;
+ case 'F':
+ if (pFmt != NULL) pFmt++;
+ else pFmt = "JUSTIFY";
+ if (*pFmt == '\0') pFmt = "JUSTIFY";
+ FmOut(Target, pFmt, Source);
+ break;
default:
StrBufAppendBuf(Target, Source, 0);
}
@@ -1223,7 +746,7 @@ int GetNextParameter(StrBuf *Buf,
}
pche = pch;
if (*pch != quote) {
- lprintf(1, "Error (in '%s' line %ld); "
+ syslog(1, "Error (in '%s' line %ld); "
"evaluating template param [%s] in Token [%s]\n",
ChrPtr(pTmpl->FileName),
Tokens->Line,
@@ -1237,8 +760,10 @@ int GetNextParameter(StrBuf *Buf,
else {
StrBufPeek(Buf, pch, -1, '\0');
if (LoadTemplates > 1) {
- lprintf(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;
@@ -1267,7 +792,7 @@ int GetNextParameter(StrBuf *Buf,
else {
Parm->lvalue = 0;
/* TODO whUT?
- lprintf(1, "Error (in '%s' line %ld); "
+ syslog(1, "Error (in '%s' line %ld); "
"evaluating long template param [%s] in Token [%s]\n",
ChrPtr(pTmpl->FileName),
Tokens->Line,
@@ -1303,8 +828,85 @@ int GetNextParameter(StrBuf *Buf,
Parm->lvalue = *PVal;
}
- else
+ else if (strchr(Parm->Start, '|') != NULL)
+ {
+ const char *Pos;
+ StrBuf *pToken;
+ StrBuf *Match;
+
+ Parm->MaskBy = eOR;
+ pToken = NewStrBufPlain (Parm->Start, Parm->len);
+ Match = NewStrBufPlain (NULL, Parm->len);
+ Pos = ChrPtr(pToken);
+
+ while ((Pos != NULL) && (Pos != StrBufNOTNULL))
+ {
+ StrBufExtract_NextToken(Match, pToken, &Pos, '|');
+ StrBufTrim(Match);
+ if (StrLength (Match) > 0)
+ {
+ if (GetHash(Defines, SKEY(Match), &vPVal) &&
+ (vPVal != NULL))
+ {
+ long *PVal;
+ PVal = (long*) vPVal;
+
+ Parm->lvalue |= *PVal;
+ }
+ else {
+ LogTemplateError(NULL, "Define",
+ Tokens->nParameters,
+ TP,
+ "%s isn't known!!",
+ ChrPtr(Match));
+
+ }
+ }
+ }
+ FreeStrBuf(&pToken);
+ FreeStrBuf(&Match);
+ }
+ else if (strchr(Parm->Start, '&') != NULL)
{
+ const char *Pos;
+ StrBuf *pToken;
+ StrBuf *Match;
+
+ Parm->MaskBy = eAND;
+ pToken = NewStrBufPlain (Parm->Start, Parm->len);
+ Match = NewStrBufPlain (NULL, Parm->len);
+ Pos = ChrPtr(pToken);
+
+ while ((Pos != NULL) && (Pos != StrBufNOTNULL))
+ {
+ StrBufExtract_NextToken(Match, pToken, &Pos, '&');
+ StrBufTrim(Match);
+ if (StrLength (Match) > 0)
+ {
+ if (GetHash(Defines, SKEY(Match), &vPVal) &&
+ (vPVal != NULL))
+ {
+ long *PVal;
+ PVal = (long*) vPVal;
+
+ Parm->lvalue |= *PVal;
+ }
+ else {
+ LogTemplateError(NULL, "Define",
+ Tokens->nParameters,
+ TP,
+ "%s isn't known!!",
+ ChrPtr(Match));
+
+ }
+ }
+ }
+ FreeStrBuf(&Match);
+ FreeStrBuf(&pToken);
+ }
+ else {
+
+
LogTemplateError(NULL, "Define",
Tokens->nParameters,
TP,
@@ -1384,7 +986,7 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
&NewToken->Params[NewToken->nParameters - 1]))
{
NewToken->HaveParameters = 1;
- if (NewToken->nParameters > MAXPARAM) {
+ if (NewToken->nParameters >= MAXPARAM) {
LogTemplateError(
NULL, "Parseerror", ERR_NAME, &TP,
"only [%d] Params allowed in Tokens",
@@ -1418,6 +1020,25 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
switch (NewToken->Flags) {
case 0:
/* If we're able to find out more about the token, do it now while its fresh. */
+ pch = NewToken->pName;
+ while (pch < NewToken->pName + NewToken->NameEnd)
+ {
+ if (((*pch >= 'A') && (*pch <= 'Z')) ||
+ ((*pch >= '0') && (*pch <= '9')) ||
+ (*pch == ':') ||
+ (*pch == '-') ||
+ (*pch == '_'))
+ pch ++;
+ else
+ {
+ LogTemplateError(
+ NULL, "Token Name", ERR_NAME, &TP,
+ "contains illegal char: '%c'",
+ *pch);
+ pch++;
+ }
+
+ }
if (GetHash(GlobalNS, NewToken->pName, NewToken->NameEnd, &vVar)) {
HashHandler *Handler;
Handler = (HashHandler*) vVar;
@@ -1576,27 +1197,72 @@ void *duplicate_template(WCTemplate *OldTemplate)
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;
const char *pS, *pE, *pch, *Err;
long Line;
- int pos;
fd = open(ChrPtr(NewTemplate->FileName), O_RDONLY);
if (fd <= 0) {
- lprintf(1, "ERROR: could not open template '%s' - %s\n",
+ syslog(1, "ERROR: could not open template '%s' - %s\n",
ChrPtr(NewTemplate->FileName), strerror(errno));
return NULL;
}
if (fstat(fd, &statbuf) == -1) {
- lprintf(1, "ERROR: could not stat template '%s' - %s\n",
+ syslog(1, "ERROR: could not stat template '%s' - %s\n",
ChrPtr(NewTemplate->FileName), strerror(errno));
return NULL;
}
@@ -1604,9 +1270,8 @@ void *load_template(WCTemplate *NewTemplate)
NewTemplate->Data = NewStrBufPlain(NULL, statbuf.st_size + 1);
if (StrBufReadBLOB(NewTemplate->Data, &fd, 1, statbuf.st_size, &Err) < 0) {
close(fd);
- lprintf(1, "ERROR: reading template '%s' - %s
\n",
+ syslog(1, "ERROR: reading template '%s' - %s
\n",
ChrPtr(NewTemplate->FileName), strerror(errno));
- //FreeWCTemplate(NewTemplate);/////tODO
return NULL;
}
close(fd);
@@ -1618,11 +1283,10 @@ void *load_template(WCTemplate *NewTemplate)
pE = pS + StrLength(NewTemplate->Data);
while (pch < pE) {
const char *pts, *pte;
- int InQuotes = 0;
- int InDoubleQuotes = 0;
+ char InQuotes = '\0';
+ void *pv;
/** Find one > */
- pos = (-1);
for (; pch < pE; pch ++) {
if ((*pch=='<')&&(*(pch + 1)=='?') &&
!((pch == pS) && /* we must ommit a '))) {
- pch ++;
+ if ((!InQuotes) &&
+ ((*pch == '\'') || (*pch == '"')))
+ {
+ InQuotes = *pch;
+ }
+ else if (InQuotes && (InQuotes == *pch))
+ {
+ InQuotes = '\0';
+ }
+ else if ((InQuotes) &&
+ (*pch == '\\') &&
+ (*(pch + 1) == InQuotes))
+ {
+ pch++;
+ }
+ else if ((!InQuotes) &&
+ (*pch == '>'))
+ {
break;
}
}
if (pch + 1 > pE)
continue;
pte = pch;
- PutNewToken(NewTemplate,
- NewTemplateSubstitute(NewTemplate->Data, pS, pts, pte, Line, NewTemplate));
- pch ++;
+ pv = NewTemplateSubstitute(NewTemplate->Data, pS, pts, pte, Line, NewTemplate);
+ if (pv != NULL) {
+ PutNewToken(NewTemplate, pv);
+ pch ++;
+ }
}
+
+ SanityCheckTemplate(NULL, NewTemplate);
return NewTemplate;
}
@@ -1667,7 +1346,7 @@ const char* PrintTemplate(void *vSubst)
}
-int LoadTemplateDir(const StrBuf *DirName, HashList *wireless, HashList *big, const StrBuf *BaseKey)
+int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
{
int Toplevel;
StrBuf *FileName;
@@ -1680,7 +1359,6 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *wireless, HashList *big, co
int d_type = 0;
int d_namelen;
int d_without_ext;
- int IsMobile;
d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
if (d == NULL) {
@@ -1702,7 +1380,7 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *wireless, HashList *big, co
(filedir_entry != NULL))
{
char *MinorPtr;
- char *PStart;
+
#ifdef _DIRENT_HAVE_D_NAMELEN
d_namelen = filedir_entry->d_namelen;
d_type = filedir_entry->d_type;
@@ -1764,7 +1442,7 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *wireless, HashList *big, co
StrBufAppendBufPlain(SubDirectory, HKEY("/"), 0);
StrBufAppendBufPlain(SubDirectory, filedir_entry->d_name, d_namelen, 0);
- LoadTemplateDir(SubDirectory, wireless, big, SubKey);
+ LoadTemplateDir(SubDirectory, big, SubKey);
break;
case DT_LNK: /* TODO: check whether its a file or a directory */
@@ -1779,12 +1457,6 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *wireless, HashList *big, co
(strcmp(&filedir_entry->d_name[d_without_ext], ".orig") == 0) ||
(strcmp(&filedir_entry->d_name[d_without_ext], ".swp") == 0))
continue; /* Ignore backup files... */
- /* .m.xxx is for mobile useragents! */
- IsMobile = 0;
- if (d_without_ext > 2)
- IsMobile = (filedir_entry->d_name[d_without_ext - 1] == 'm') &&
- (filedir_entry->d_name[d_without_ext - 2] == '.');
- PStart = filedir_entry->d_name;
StrBufPrintf(FileName, "%s/%s", ChrPtr(DirName), filedir_entry->d_name);
MinorPtr = strchr(filedir_entry->d_name, '.');
if (MinorPtr != NULL)
@@ -1798,8 +1470,8 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *wireless, HashList *big, co
StrBufAppendBufPlain(Key, filedir_entry->d_name, MinorPtr - filedir_entry->d_name, 0);
if (LoadTemplates >= 1)
- lprintf(1, "%s %d %s\n", ChrPtr(FileName), IsMobile, ChrPtr(Key));
- prepare_template(FileName, Key, (IsMobile)?wireless:big);
+ syslog(1, "%s %s\n", ChrPtr(FileName), ChrPtr(Key));
+ prepare_template(FileName, Key, big);
default:
break;
}
@@ -1818,7 +1490,7 @@ void InitTemplateCache(void)
int i;
StrBuf *Key;
StrBuf *Dir;
- HashList *Templates[4];
+ HashList *Templates[2];
Dir = NewStrBuf();
Key = NewStrBuf();
@@ -1826,14 +1498,12 @@ void InitTemplateCache(void)
/* Primary Template set... */
StrBufPrintf(Dir, "%s/t", static_dirs[0]);
LoadTemplateDir(Dir,
- WirelessTemplateCache,
TemplateCache,
Key);
/* User local Template set */
StrBufPrintf(Dir, "%s/t", static_dirs[1]);
LoadTemplateDir(Dir,
- WirelessLocalTemplateCache,
LocalTemplateCache,
Key);
@@ -1841,17 +1511,14 @@ void InitTemplateCache(void)
StrBufPrintf(Dir, "%s/dbg", static_dirs[0]);
LoadTemplateDir(Dir,
- WirelessTemplateCache,
TemplateCache,
Key);
- Templates[0] = WirelessTemplateCache;
- Templates[1] = TemplateCache;
- Templates[2] = WirelessLocalTemplateCache;
- Templates[3] = LocalTemplateCache;
+ Templates[0] = TemplateCache;
+ Templates[1] = LocalTemplateCache;
if (LoadTemplates == 0)
- for (i=0; i < 4; i++) {
+ for (i=0; i < 2; i++) {
const char *Key;
long KLen;
HashPos *At;
@@ -1865,7 +1532,7 @@ void InitTemplateCache(void)
&vTemplate) &&
(vTemplate != NULL))
{
- load_template((WCTemplate *)vTemplate);
+ load_template(NULL, (WCTemplate *)vTemplate);
}
DeleteHashPos(&At);
}
@@ -1897,7 +1564,7 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams *TP)
void *vVar;
/* much output, since pName is not terminated...
- lprintf(1,"Doing token: %s\n",Token->pName);
+ syslog(1,"Doing token: %s\n",Token->pName);
*/
switch (TP->Tokens->Flags) {
@@ -1955,7 +1622,9 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams *TP)
}
}
else {
- print_value_of(Target, TP);
+ LogTemplateError(
+ Target, "Token UNKNOWN", ERR_NAME, TP,
+ "You've specified a token that isn't known to webcit.!");
}
}
return 0;
@@ -1979,10 +1648,10 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
if (LoadTemplates != 0) {
if (LoadTemplates > 1)
- lprintf(1, "DBG: ----- loading: [%s] ------ \n",
+ 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,
"
\nError loading Template [%s]\n See Logfile for details\n\n", @@ -2058,25 +1727,19 @@ const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCT TP = &LocalTP; } - if (WC->is_mobile > 0) { - Static = WirelessTemplateCache; - StaticLocal = WirelessLocalTemplateCache; - } - else { - Static = TemplateCache; - StaticLocal = LocalTemplateCache; - } + Static = TemplateCache; + StaticLocal = LocalTemplateCache; if (len == 0) { - lprintf (1, "Can't to load a template with empty name!\n"); + syslog(1, "Can't to load a template with empty name!\n"); StrBufAppendPrintf(Target, "
\nCan't to load a template with empty name!\n"); return NULL; } if (!GetHash(StaticLocal, templatename, len, &vTmpl) && !GetHash(Static, templatename, len, &vTmpl)) { - lprintf (1, "didn't find Template [%s] %ld %ld\n", templatename, len , (long)strlen(templatename)); + syslog(1, "didn't find Template [%s] %ld %ld\n", templatename, len , (long)strlen(templatename)); StrBufAppendPrintf(Target, "
\ndidn't find Template [%s] %ld %ld\n", templatename, len, (long)strlen(templatename)); @@ -2092,6 +1755,24 @@ const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCT } + +void tmplput_Comment(StrBuf *Target, WCTemplputParams *TP) +{ + if (LoadTemplates != 0) + { + StrBuf *Comment; + const char *pch; + long len; + + GetTemplateTokenString(Target, TP, 0, &pch, &len); + Comment = NewStrBufPlain(pch, len); + StrBufAppendBufPlain(Target, HKEY(""), 0); + FreeStrBuf(&Comment); + } +} + /*----------------------------------------------------------------------------- * Iterators */ @@ -2146,6 +1827,7 @@ int preeval_iterate(WCTemplateToken *Token) WCTemplputParams *TP; void *vTmpl; void *vIt; + HashIterator *It; memset(&TPP, 0, sizeof(WCTemplputParams)); TP = &TPP; @@ -2169,6 +1851,16 @@ int preeval_iterate(WCTemplateToken *Token) "referenced here doesn't exist"); } Token->Preeval2 = vIt; + It = (HashIterator *) vIt; + + if (TP->Tokens->nParameters < It->AdditionalParams + 2) { + LogTemplateError( + NULL, "Iterator", ERR_PARM1, TP, + "doesn't work with %d params", + TP->Tokens->nParameters); + } + + return 1; } @@ -2201,7 +1893,7 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP) return; } - if (TP->Tokens->nParameters <= It->AdditionalParams + 2) { + if (TP->Tokens->nParameters < It->AdditionalParams + 2) { LogTemplateError( Target, "Iterator", ERR_PARM1, TP, "doesn't work with %d params", @@ -2213,9 +1905,9 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP) (It->XPectContextType != TP->Filter.ContextType)) { LogTemplateError( Target, "Iterator", ERR_PARM1, TP, - "requires context of type %d, have %d", - It->XPectContextType, - TP->Filter.ContextType); + "requires context of type %s, have %s", + ContextName(It->XPectContextType), + ContextName(TP->Filter.ContextType)); return ; } @@ -2234,8 +1926,10 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP) if (GetHash(SortHash, SKEY(BSort), &vSortBy) && (vSortBy != NULL)) { SortBy = (SortStruct*)vSortBy; + /* first check whether its intended for us... */ + if ((SortBy->ContextType == It->ContextType)&& /** Ok, its us, lets see in which direction we should sort... */ - if (havebstr("SortOrder")) { + (havebstr("SortOrder"))) { int SortOrder; SortOrder = LBSTR("SortOrder"); if (SortOrder != 0) @@ -2341,6 +2035,8 @@ int conditional_ITERATE_LASTN(StrBuf *Target, WCTemplputParams *TP) int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams *TP) { ConditionalStruct *Cond; + int rc = 0; + int res; if ((TP->Tokens->Params[0]->len == 1) && (TP->Tokens->Params[0]->Start[0] == 'X')) @@ -2357,42 +2053,14 @@ int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams *TP if (!CheckContext(Target, &Cond->Filter, TP, "Conditional")) { return 0; } - - if (Cond->CondF(Target, TP) == Neg) - return TP->Tokens->Params[1]->lvalue; - return 0; -} - -int ConditionalVar(StrBuf *Target, WCTemplputParams *TP) -{ - void *vsubst; - wcsubst *subst; - - if (!GetHash(WC->vars, TKEY(2), &vsubst)) - return 0; - subst = (wcsubst*) vsubst; - - switch(subst->wcs_type) { - case WCS_FUNCTION: - return (subst->wcs_function!=NULL); - case WCS_SERVCMD: - lprintf(1, " -> Server [%s]\n", subst->wcs_value);/* TODO */ - return 1; - case WCS_STRING: - case WCS_STRBUF: - case WCS_STRBUF_REF: - if (TP->Tokens->nParameters < 4) - return 1; - return (strcmp(TP->Tokens->Params[3]->Start, ChrPtr(subst->wcs_value)) == 0); - case WCS_LONG: - if (TP->Tokens->nParameters < 4) - return (subst->lvalue != 0); - return (subst->lvalue == TP->Tokens->Params[3]->lvalue); - default: - lprintf(1," WARNING: invalid type: [%ld]!\n", subst->wcs_type); - return -1; - } - return 0; + 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); + return rc; } void RegisterConditional(const char *Name, long len, @@ -2552,15 +2220,21 @@ void tmpl_do_boxed(StrBuf *Target, WCTemplputParams *TP) memcpy (&SubTP, TP, sizeof(WCTemplputParams)); SubTP.Context = Headline; SubTP.Filter.ContextType = CTX_STRBUF; - DoTemplate(HKEY("beginbox"), Target, &SubTP); + DoTemplate(HKEY("box_begin"), Target, &SubTP); DoTemplate(TKEY(0), Target, TP); - DoTemplate(HKEY("endbox"), Target, TP); + DoTemplate(HKEY("box_end"), Target, TP); FreeStrBuf(&Headline); } /*----------------------------------------------------------------------------- * Tabbed-API */ + +typedef struct _tab_struct { + long CurrentTab; + StrBuf *TabTitle; +} tab_struct; + int preeval_do_tabbed(WCTemplateToken *Token) { WCTemplputParams TPP; @@ -2628,6 +2302,11 @@ void tmpl_do_tabbed(StrBuf *Target, WCTemplputParams *TP) { StrBuf **TabNames; int i, ntabs, nTabs; + tab_struct TS; + WCTemplputParams SubTP; + + memset(&TS, 0, sizeof(tab_struct)); + memcpy (&SubTP, &TP, sizeof(WCTemplputParams)); nTabs = ntabs = TP->Tokens->nParameters / 2; TabNames = (StrBuf **) malloc(ntabs * sizeof(StrBuf*)); @@ -2654,17 +2333,35 @@ void tmpl_do_tabbed(StrBuf *Target, WCTemplputParams *TP) nTabs --; } } + memcpy (&SubTP, TP, sizeof(WCTemplputParams)); + SubTP.Filter.ControlContextType = CTX_TAB; + SubTP.ControlContext = &TS; StrTabbedDialog(Target, nTabs, TabNames); for (i = 0; i < ntabs; i++) { - StrBeginTab(Target, i, nTabs); - DoTemplate(TKEY(i * 2 + 1), Target, TP); + memset(&TS, 0, sizeof(tab_struct)); + TS.CurrentTab = i; + TS.TabTitle = TabNames[i]; + StrBeginTab(Target, i, nTabs, TabNames); + DoTemplate(TKEY(i * 2 + 1), Target, &SubTP); StrEndTab(Target, i, nTabs); } for (i = 0; i < ntabs; i++) FreeStrBuf(&TabNames[i]); } +void tmplput_TAB_N(StrBuf *Target, WCTemplputParams *TP) +{ + tab_struct *Ctx = CCTX; + + StrBufAppendPrintf(Target, "%d", Ctx->CurrentTab); +} + +void tmplput_TAB_TITLE(StrBuf *Target, WCTemplputParams *TP) +{ + tab_struct *Ctx = CCTX; + StrBufAppendTemplate(Target, TP, Ctx->TabTitle, 0); +} /*----------------------------------------------------------------------------- * Sorting-API @@ -2692,7 +2389,7 @@ void RegisterSortFunc(const char *name, long len, NewSort->GroupChange = GroupChange; NewSort->ContextType = ContextType; if (ContextType == CTX_NONE) { - lprintf(1, "sorting requires a context. CTX_NONE won't make it.\n"); + syslog(1, "sorting requires a context. CTX_NONE won't make it.\n"); exit(1); } @@ -2703,7 +2400,6 @@ CompareFunc RetrieveSort(WCTemplputParams *TP, const char *OtherPrefix, long OtherPrefixLen, const char *Default, long ldefault, long DefaultDirection) { - int isdefault = 0; const StrBuf *BSort = NULL; SortStruct *SortBy; void *vSortBy; @@ -2737,7 +2433,6 @@ CompareFunc RetrieveSort(WCTemplputParams *TP, if (!GetHash(SortHash, SKEY(BSort), &vSortBy) || (vSortBy == NULL)) { - isdefault = 1; if (!GetHash(SortHash, Default, ldefault, &vSortBy) || (vSortBy == NULL)) { LogTemplateError( @@ -2792,9 +2487,9 @@ enum { }; ConstStr SortIcons[] = { - {HKEY("static/sort_none.gif")}, - {HKEY("static/up_pointer.gif")}, - {HKEY("static/down_pointer.gif")}, + {HKEY("static/webcit_icons/sort_none.gif")}, + {HKEY("static/webcit_icons/up_pointer.gif")}, + {HKEY("static/webcit_icons/down_pointer.gif")}, }; ConstStr SortNextOrder[] = { @@ -2988,7 +2683,7 @@ void dbg_print_longvector(long *LongVector) StrBufAppendPrintf(Buf, "%d: %ld]\n", i, LongVector[i]); } - lprintf(1, ChrPtr(Buf)); + syslog(1, "%s", ChrPtr(Buf)); FreeStrBuf(&Buf); } @@ -3035,22 +2730,27 @@ InitModule_SUBST (void) { memset(&NoCtx, 0, sizeof(WCTemplputParams)); + RegisterNamespace("--", 0, 2, tmplput_Comment, NULL, CTX_NONE); RegisterNamespace("SORT:ICON", 1, 2, tmplput_SORT_ICON, NULL, CTX_NONE); RegisterNamespace("SORT:ORDER", 1, 2, tmplput_SORT_ORDER, NULL, CTX_NONE); RegisterNamespace("SORT:NEXT", 1, 2, tmplput_SORT_NEXT, NULL, CTX_NONE); RegisterNamespace("CONTEXTSTR", 0, 1, tmplput_ContextString, NULL, CTX_STRBUF); - RegisterNamespace("CONTEXTSTRARR", 1, 2, tmplput_ContextStringArray, NULL, CTX_STRBUF); + RegisterNamespace("CONTEXTSTRARR", 1, 2, tmplput_ContextStringArray, NULL, CTX_STRBUFARR); RegisterNamespace("ITERATE", 2, 100, tmpl_iterate_subtmpl, preeval_iterate, CTX_NONE); RegisterNamespace("DOBOXED", 1, 2, tmpl_do_boxed, NULL, CTX_NONE); RegisterNamespace("DOTABBED", 2, 100, tmpl_do_tabbed, preeval_do_tabbed, CTX_NONE); + RegisterControlNS(HKEY("TAB:N"), 0, 0, tmplput_TAB_N, CTX_TAB); + RegisterControlNS(HKEY("TAB:SUBJECT"), 0, 1, tmplput_TAB_TITLE, CTX_TAB); + + RegisterNamespace("LONGVECTOR", 1, 1, tmplput_long_vector, NULL, CTX_LONGVECTOR); - RegisterConditional(HKEY("COND:SUBST"), 3, ConditionalVar, CTX_NONE); RegisterConditional(HKEY("COND:CONTEXTSTR"), 3, ConditionalContextStr, CTX_STRBUF); RegisterConditional(HKEY("COND:CONTEXTSTRARR"), 4, ConditionalContextStrinArray, CTX_STRBUFARR); RegisterConditional(HKEY("COND:LONGVECTOR"), 4, ConditionalLongVector, CTX_LONGVECTOR); + RegisterControlConditional(HKEY("COND:ITERATE:ISGROUPCHANGE"), 2, conditional_ITERATE_ISGROUPCHANGE, CTX_ITERATE); @@ -3077,8 +2777,6 @@ void ServerStartModule_SUBST (void) { - WirelessTemplateCache = NewHash(1, NULL); - WirelessLocalTemplateCache = NewHash(1, NULL); LocalTemplateCache = NewHash(1, NULL); TemplateCache = NewHash(1, NULL); @@ -3100,8 +2798,6 @@ void ServerShutdownModule_SUBST (void) { - DeleteHash(&WirelessTemplateCache); - DeleteHash(&WirelessLocalTemplateCache); DeleteHash(&TemplateCache); DeleteHash(&LocalTemplateCache); @@ -3124,14 +2820,12 @@ void SessionAttachModule_SUBST (wcsession *sess) { - sess->vars = NewHash(1,NULL); } void SessionDetachModule_SUBST (wcsession *sess) { - DeleteHash(&sess->vars); FreeStrBuf(&sess->WFBuf); }