+/**
+ * @defgroup subst Template processing functions
+ */
extern HashList *Conditionals;
extern HashList *GlobalNS;
#define TYPE_BSTR 6
#define TYPE_SUBTEMPLATE 7
#define TYPE_INTDEFINE 8
-#define MAXPARAM 20
+#define MAXPARAM 25
#define IS_NUMBER(a) ((a == TYPE_LONG) || (a == TYPE_PREFINT) || (a == TYPE_INTDEFINE))
WCS_LONG /* its an integer */
};
-#define CTX TP->Context
-#define CCTX TP->ControlContext
-
#define CTX_NONE 0
#define CTX_SITECFG 1
#define CTX_SESSION 2
#define CTX_DAVNS 19
#define CTX_TAB 20
#define CTX_VCARD 21
+#define CTX_SIEVELIST 22
+#define CTX_SIEVESCRIPT 23
+#define CTX_MAILQITEM 24
+#define CTX_MAILQ_RCPT 25
+#define CTX_SRVLOG 26
-#define CTX_UNKNOWN 22
+#define CTX_UNKNOWN 27
/**
+ * @ingroup subst
* ContextFilter resembles our RTTI information. With this structure
* we can make shure a tmplput function can live with the environment
* we call it in.
*/
typedef struct _contexts {
int ContextType; /* do we require a User Context ? */
- int ControlContextType; /* are we inside of a control structure? */
int nMinArgs; /* How many arguments do we need at least? */
int nMaxArgs; /* up to how many arguments can we handle? */
} ContextFilter;
/* make a template token a lookup key: */
#define TKEY(a) TP->Tokens->Params[a]->Start, TP->Tokens->Params[a]->len
+void *GetContextPayload(WCTemplputParams *TP, int ContextType);
+#define CTX(a) GetContextPayload(TP, a)
+
/**
+ * @ingroup subst
* this is the signature of a conditional function
* Note: Target is just passed in for error messages; don't write onto it in regular cases.
*/
/**
+ * @ingroup subst
* Representation of a token; everything thats inbetween <? and >
*/
struct WCTemplateToken {
struct WCTemplputParams {
ContextFilter Filter;
void *Context;
- void *ControlContext;
int nArgs;
WCTemplateToken *Tokens;
+ WCTemplputParams *Sub, *Super;
};
#define ERR_PARM1 1
#define ERR_PARM2 2
/**
- * @Brief log an error while evaluating a token; print it to the actual template
+ * @ingroup subst
+ * @brief log an error while evaluating a token; print it to the actual template
* @param Target your Target Buffer to print the error message next to the log
* @param Type What sort of thing are we talking about? Tokens? Conditionals?
* @param TP grab our set of default information here
/**
- * @Brief log an error while in global context; print it to Wildfire / Target
+ * @ingroup subst
+ * @brief log an error while in global context; print it to Wildfire / Target
* @param Target your Target Buffer to print the error message next to the log
* @param Type What sort of thing are we talking about? Tokens? Conditionals?
* @param Format for the custom error message
void LogError (StrBuf *Target, const char *Type, const char *Format, ...);
/**
- * @Brief get the actual value of a token parameter
+ * @ingroup subst
+ * @brief get the actual value of a token parameter
* in your tmplputs or conditionals use this function to access parameters that can also be
* retrieved from dynamic facilities:
* _ -> Gettext; retrieve this token from the i18n facilities
const char **Value,
long *len);
/**
+ * @ingroup subst
* @return whether @ref GetTemplateTokenString would be able to give you a string
*/
int HaveTemplateTokenString(StrBuf *Target,
/**
- * @Brief get the actual integer value of a token parameter
+ * @ingroup subst
+ * @brief get the actual integer value of a token parameter
* in your tmplputs or conditionals use this function to access parameters that can also be
* retrieved from dynamic facilities:
* _ -> Gettext; retrieve this token from the i18n facilities
int N, long dflt);
/**
- * @Brief put a token value into the template
+ * @brief put a token value into the template
* use this function to append your strings into a Template.
* it can escape your string according to the token at FormattypeIndex:
* H: de-QP and utf8-ify
#define RegisterNamespace(a, b, c, d, e, f) RegisterNS(a, sizeof(a)-1, b, c, d, e, f)
/**
- * @Brief register a template token handler
+ * @ingroup subst
+ * @brief register a template token handler
* call this function in your InitModule_MODULENAME which will be called at the server start
* @param nMinArgs how much parameters does your token require at least?
* @param nMaxArgs how many parameters does your token accept?
int ContextRequired);
/**
- * @Brief register a conditional token <pair> handler
+ * @ingroup subst
+ * @brief register a conditional token <pair> handler
* call this function in your InitModule_MODULENAME which will be called at the server start
* conditionals can be ? or ! with a pair or % similar to an implicit if
* @param Name whats the name of your conditional? should start with COND:
int ContextRequired);
/**
+ * @ingroup subst
* @brief register a string that will represent a long value
* this will allow to resolve <?...(#"Name")> to Value; that way
* plain strings can be used an lexed in templates without having the
#define REGISTERTokenParamDefine(a) RegisterTokenParamDefine(#a, sizeof(#a) - 1, a);
/**
+ * @ingroup subst
* @brief retrieve the long value of a registered string define
* @param Name The name of the define
* @param len length of Name
+void StackContext(WCTemplputParams *Super,
+ WCTemplputParams *Sub,
+ void *Context,
+ int ContextType,
+ int nArgs,
+ WCTemplateToken *Tokens);
+
+void UnStackContext(WCTemplputParams *Sub);