2 extern HashList *Conditionals;
3 extern HashList *GlobalNS;
4 extern HashList *Iterators;
5 extern HashList *WirelessTemplateCache;
6 extern HashList *WirelessLocalTemplateCache;
7 extern HashList *TemplateCache;
8 extern HashList *LocalTemplateCache;
13 #define TYPE_PREFSTR 3
14 #define TYPE_PREFINT 4
15 #define TYPE_GETTEXT 5
17 #define TYPE_SUBTEMPLATE 7
22 * \brief Values for wcs_type
25 WCS_STRING, /* its a string */
26 WCS_FUNCTION, /* its a function callback */
27 WCS_SERVCMD, /* its a command to send to the citadel server */
28 WCS_STRBUF, /* its a strbuf we own */
29 WCS_STRBUF_REF, /* its a strbuf we mustn't free */
30 WCS_LONG /* its an integer */
33 typedef struct _contexts {
34 int ContextType; /* do we require a context type? */
35 int ControlContextType;
41 typedef struct WCTemplateToken WCTemplateToken;
42 typedef struct WCTemplputParams WCTemplputParams;
43 typedef void (*WCHandlerFunc)(StrBuf *Target, WCTemplputParams *TP);
45 typedef struct _TemplateParam {
52 /* make a template token a lookup key: */
53 #define TKEY(a) TP->Tokens->Params[a]->Start, TP->Tokens->Params[a]->len
54 struct WCTemplateToken {
55 const StrBuf *FileName; /* Reference to print error messages; not to be freed */
58 const char *pTokenStart;
61 const char *pTokenEnd;
70 TemplateParam *Params[MAXPARAM];
75 * \brief Dynamic content for variable substitution in templates
77 typedef struct _wcsubst {
79 int wcs_type; /* which type of Substitution are we */
80 char wcs_key[32]; /* copy of our hashkey for debugging */
81 StrBuf *wcs_value; /* if we're a string, keep it here */
82 long lvalue; /* type long? keep data here */
83 WCHandlerFunc wcs_function; /* funcion hook ???*/
86 struct WCTemplputParams {
91 WCTemplateToken *Tokens;
95 extern WCTemplputParams NoCtx;
97 #define CTX TP->Context
98 #define CCTX TP->ControlContext
103 #define CTX_SITECFG 1
104 #define CTX_SESSION 2
105 #define CTX_INETCFG 3
109 #define CTX_NODECONF 7
110 #define CTX_USERLIST 8
111 #define CTX_MAILSUM 9
112 #define CTX_MIME_ATACH 10
113 #define CTX_FILELIST 11
114 #define CTX_STRBUF 12
115 #define CTX_LONGVECTOR 13
117 #define CTX_FLOORS 15
118 #define CTX_ITERATE 16
120 void RegisterNS(const char *NSName, long len,
123 WCHandlerFunc HandlerFunc,
124 int ContextRequired);
125 #define RegisterNamespace(a, b, c, d, e) RegisterNS(a, sizeof(a)-1, b, c, d, e)
127 typedef int (*WCConditionalFunc)(StrBuf *Target, WCTemplputParams *TP);
128 typedef struct _ConditionalStruct {
129 ContextFilter Filter;
130 const char *PlainName;
132 WCConditionalFunc CondF;
134 void RegisterConditional(const char *Name, long len,
136 WCConditionalFunc CondF,
137 int ContextRequired);
141 typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, WCTemplputParams *TP);
142 typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, WCTemplputParams *TP);
143 typedef void (*HashDestructorFunc) (HashList **KillMe);
144 void RegisterITERATOR(const char *Name, long len, /* Our identifier */
145 int AdditionalParams, /* doe we use more parameters? */
146 HashList *StaticList, /* pointer to webcit lifetime hashlists */
147 RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */
148 SubTemplFunc DoSubTempl, /* call this function on each iteration for svput & friends */
149 HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */
150 int ContextType, /* which context do we provide to the subtemplate? */
151 int XPectContextType, /* which context do we expct to be called in? */
155 #define IT_FLAG_DETECT_GROUPCHANGE (1<<0)
157 #define RegisterIterator(a, b, c, d, e, f, g, h, i) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h, i)
159 void GetTemplateTokenString(WCTemplputParams *TP,
165 void SVPut(char *keyname, size_t keylen, int keytype, char *Data);
166 #define svput(a, b, c) SVPut(a, sizeof(a) - 1, b, c)
167 void SVPutLong(char *keyname, size_t keylen, long Data);
168 #define svputlong(a, b) SVPutLong(a, sizeof(a) - 1, b)
169 void svprintf(char *keyname, size_t keylen, int keytype, const char *format,...) __attribute__((__format__(__printf__,4,5)));
170 void SVPRINTF(char *keyname, int keytype, const char *format,...) __attribute__((__format__(__printf__,3,4)));
171 void SVCALLBACK(char *keyname, WCHandlerFunc fcn_ptr);
172 void SVCallback(char *keyname, size_t keylen, WCHandlerFunc fcn_ptr);
173 #define svcallback(a, b) SVCallback(a, sizeof(a) - 1, b)
175 void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref);
176 #define SVPutBuf(a, b, c); SVPUTBuf(a, sizeof(a) - 1, b, c)
178 void DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP);
179 #define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, &NoCtx);
180 void url_do_template(void);
182 int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
183 int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
185 void StrBufAppendTemplate(StrBuf *Target,
186 WCTemplputParams *TP,
187 const StrBuf *Source,
188 int FormatTypeIndex);
189 CompareFunc RetrieveSort(WCTemplputParams *TP,
190 const char *OtherPrefix, long OtherPrefixLen,
191 const char *Default, long ldefault,
192 long DefaultDirection);
193 void RegisterSortFunc(const char *name, long len,
194 const char *prepend, long preplen,
197 CompareFunc GroupChange,
200 void dbg_print_longvector(long *LongVector);
206 void LogTemplateError (StrBuf *Target,
209 WCTemplputParams *TP,
210 const char *Format, ...);