X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsubst.h;h=86b76d69070cb39638c9da72b9ba6506b200587f;hb=82f8cebefd325c7eb8b98c6025bd43633fa9cd90;hp=3bf4917490473e9e0316606013f4118ad1fc35ec;hpb=715008dfb6283528fcac64dc21b88dcbb237abad;p=citadel.git diff --git a/webcit/subst.h b/webcit/subst.h index 3bf491749..86b76d690 100644 --- a/webcit/subst.h +++ b/webcit/subst.h @@ -14,11 +14,12 @@ extern HashList *LocalTemplateCache; #define TYPE_STR 1 #define TYPE_LONG 2 #define TYPE_PREFSTR 3 -#define TYPE_PREFINT 4 -#define TYPE_GETTEXT 5 -#define TYPE_BSTR 6 -#define TYPE_SUBTEMPLATE 7 -#define TYPE_INTDEFINE 8 +#define TYPE_ROOMPREFSTR 4 +#define TYPE_PREFINT 5 +#define TYPE_GETTEXT 6 +#define TYPE_BSTR 7 +#define TYPE_SUBTEMPLATE 8 +#define TYPE_INTDEFINE 9 #define MAXPARAM 25 #define IS_NUMBER(a) ((a == TYPE_LONG) || (a == TYPE_PREFINT) || (a == TYPE_INTDEFINE)) @@ -35,38 +36,21 @@ enum { 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_INETCFG 3 -#define CTX_VNOTE 4 -#define CTX_WHO 5 -#define CTX_PREF 6 -#define CTX_NODECONF 7 -#define CTX_USERLIST 8 -#define CTX_MAILSUM 9 -#define CTX_MIME_ATACH 10 -#define CTX_FILELIST 11 -#define CTX_STRBUF 12 -#define CTX_STRBUFARR 13 -#define CTX_LONGVECTOR 14 -#define CTX_ROOMS 15 -#define CTX_FLOORS 16 -#define CTX_ITERATE 17 -#define CTX_ICAL 18 -#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_UNKNOWN 25 +typedef int CtxType; +typedef struct __CtxTypeStruct { + CtxType Type; + StrBuf *Name; +} CtxTypeStruct; + +CtxTypeStruct *GetContextType(CtxType Type); +void RegisterContextType(const char *name, long len, CtxType *TheCtx); +#define RegisterCTX(a) RegisterContextType(#a, sizeof(#a) - 1, &a) + +extern CtxType CTX_STRBUF; +extern CtxType CTX_STRBUFARR; +extern CtxType CTX_LONGVECTOR; /** * @ingroup subst @@ -76,8 +60,7 @@ enum { * if not, we will log/print an error and refuse to call it. */ typedef struct _contexts { - int ContextType; /* do we require a User Context ? */ - int ControlContextType; /* are we inside of a control structure? */ + CtxType ContextType; /* do we require a User Context ? */ int nMinArgs; /* How many arguments do we need at least? */ int nMaxArgs; /* up to how many arguments can we handle? */ } ContextFilter; @@ -96,6 +79,9 @@ typedef int (*WCPreevalFunc)(WCTemplateToken *Token); /* make a template token a lookup key: */ #define TKEY(a) TP->Tokens->Params[a]->Start, TP->Tokens->Params[a]->len +void *GetContextPayload(WCTemplputParams *TP, CtxType ContextType); +#define CTX(a) GetContextPayload(TP, a) + /** * @ingroup subst * this is the signature of a conditional function @@ -164,9 +150,9 @@ struct WCTemplateToken { struct WCTemplputParams { ContextFilter Filter; void *Context; - void *ControlContext; int nArgs; WCTemplateToken *Tokens; + WCTemplputParams *Sub, *Super; }; @@ -282,6 +268,11 @@ void StrBufAppendTemplate(StrBuf *Target, const StrBuf *Source, int FormatTypeIndex); +void StrBufAppendTemplateStr(StrBuf *Target, + WCTemplputParams *TP, + const char *Source, + int FormatTypeIndex); + #define RegisterNamespace(a, b, c, d, e, f) RegisterNS(a, sizeof(a)-1, b, c, d, e, f) /** @@ -356,12 +347,20 @@ void RegisterITERATOR(const char *Name, long len, /* Our identifier */ RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */ SubTemplFunc DoSubTempl, /* call this function on each iteration for svput & friends */ HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */ - int ContextType, /* which context do we provide to the subtemplate? */ - int XPectContextType, /* which context do we expct to be called in? */ + CtxType ContextType, /* which context do we provide to the subtemplate? */ + CtxType XPectContextType, /* which context do we expct to be called in? */ int Flags); +void StackContext(WCTemplputParams *Super, + WCTemplputParams *Sub, + void *Context, + CtxType ContextType, + int nArgs, + WCTemplateToken *Tokens); + +void UnStackContext(WCTemplputParams *Sub); @@ -374,7 +373,7 @@ void RegisterSortFunc(const char *name, long len, CompareFunc Forward, CompareFunc Reverse, CompareFunc GroupChange, - long ContextType); + CtxType ContextType); void dbg_print_longvector(long *LongVector);