X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsubst.h;h=75bbf3e33d7d4346f8f9b322f5238550e84820cd;hb=5d38a76f8f06640e3a3f097d584ac52336110f7c;hp=b44b33a5217061a3a01a8753d3d1a748a46d2070;hpb=652b652cad9114c63dc064cb208d926bd403ca7a;p=citadel.git diff --git a/webcit/subst.h b/webcit/subst.h index b44b33a52..75bbf3e33 100644 --- a/webcit/subst.h +++ b/webcit/subst.h @@ -35,39 +35,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_SRVLOG 26 - -#define CTX_UNKNOWN 27 +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 @@ -77,8 +59,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; @@ -97,6 +78,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 @@ -165,9 +149,9 @@ struct WCTemplateToken { struct WCTemplputParams { ContextFilter Filter; void *Context; - void *ControlContext; int nArgs; WCTemplateToken *Tokens; + WCTemplputParams *Sub, *Super; }; @@ -357,12 +341,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); @@ -375,7 +367,7 @@ void RegisterSortFunc(const char *name, long len, CompareFunc Forward, CompareFunc Reverse, CompareFunc GroupChange, - long ContextType); + CtxType ContextType); void dbg_print_longvector(long *LongVector);