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
21 * \brief Values for wcs_type
24 WCS_STRING, /* its a string */
25 WCS_FUNCTION, /* its a function callback */
26 WCS_SERVCMD, /* its a command to send to the citadel server */
27 WCS_STRBUF, /* its a strbuf we own */
28 WCS_STRBUF_REF, /* its a strbuf we mustn't free */
29 WCS_LONG /* its an integer */
32 typedef struct WCTemplateToken WCTemplateToken;
33 typedef struct WCTemplputParams WCTemplputParams;
34 typedef void (*WCHandlerFunc)(StrBuf *Target, WCTemplputParams *TP);
36 typedef struct _TemplateParam {
43 /* make a template token a lookup key: */
44 #define TKEY(a) TP->Tokens->Params[a]->Start, TP->Tokens->Params[a]->len
45 struct WCTemplateToken {
46 const StrBuf *FileName; /* Reference to print error messages; not to be freed */
49 const char *pTokenStart;
52 const char *pTokenEnd;
61 TemplateParam *Params[MAXPARAM];
66 * \brief Dynamic content for variable substitution in templates
68 typedef struct _wcsubst {
69 int wcs_type; /* which type of Substitution are we */
70 char wcs_key[32]; /* copy of our hashkey for debugging */
71 StrBuf *wcs_value; /* if we're a string, keep it here */
72 long lvalue; /* type long? keep data here */
73 int ContextRequired; /* do we require a context type? */
74 WCHandlerFunc wcs_function; /* funcion hook ???*/
77 struct WCTemplputParams {
79 WCTemplateToken *Tokens;
85 extern WCTemplputParams NoCtx;
87 #define CTX TP->Context
98 #define CTX_NODECONF 7
99 #define CTX_USERLIST 8
100 #define CTX_MAILSUM 9
101 #define CTX_MIME_ATACH 10
102 #define CTX_FILELIST 11
103 #define CTX_STRBUF 12
104 #define CTX_LONGVECTOR 13
107 void RegisterNS(const char *NSName, long len,
110 WCHandlerFunc HandlerFunc,
111 int ContextRequired);
112 #define RegisterNamespace(a, b, c, d, e) RegisterNS(a, sizeof(a)-1, b, c, d, e)
114 typedef int (*WCConditionalFunc)(StrBuf *Target, WCTemplputParams *TP);
115 typedef struct _ConditionalStruct {
116 const char *PlainName;
119 WCConditionalFunc CondF;
121 void RegisterConditional(const char *Name, long len,
123 WCConditionalFunc CondF,
124 int ContextRequired);
128 typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, WCTemplputParams *TP);
129 typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, WCTemplputParams *TP);
130 typedef void (*HashDestructorFunc) (HashList **KillMe);
131 void RegisterITERATOR(const char *Name, long len, /* Our identifier */
132 int AdditionalParams, /* doe we use more parameters? */
133 HashList *StaticList, /* pointer to webcit lifetime hashlists */
134 RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */
135 SubTemplFunc DoSubTempl, /* call this function on each iteration for svput & friends */
136 HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */
137 int ContextType, /* which context do we provide to the subtemplate? */
138 int XPectContextType, /* which context do we expct to be called in? */
142 #define IT_FLAG_DETECT_GROUPCHANGE (1<<0)
144 #define RegisterIterator(a, b, c, d, e, f, g, h, i) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h, i)
146 void GetTemplateTokenString(WCTemplputParams *TP,
152 void SVPut(char *keyname, size_t keylen, int keytype, char *Data);
153 #define svput(a, b, c) SVPut(a, sizeof(a) - 1, b, c)
154 void SVPutLong(char *keyname, size_t keylen, long Data);
155 #define svputlong(a, b) SVPutLong(a, sizeof(a) - 1, b)
156 void svprintf(char *keyname, size_t keylen, int keytype, const char *format,...) __attribute__((__format__(__printf__,4,5)));
157 void SVPRINTF(char *keyname, int keytype, const char *format,...) __attribute__((__format__(__printf__,3,4)));
158 void SVCALLBACK(char *keyname, WCHandlerFunc fcn_ptr);
159 void SVCallback(char *keyname, size_t keylen, WCHandlerFunc fcn_ptr);
160 #define svcallback(a, b) SVCallback(a, sizeof(a) - 1, b)
162 void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref);
163 #define SVPutBuf(a, b, c); SVPUTBuf(a, sizeof(a) - 1, b, c)
165 void DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP);
166 #define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, &NoCtx);
167 void url_do_template(void);
169 int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
170 int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
172 void StrBufAppendTemplate(StrBuf *Target,
173 WCTemplputParams *TP,
174 const StrBuf *Source,
175 int FormatTypeIndex);
176 CompareFunc RetrieveSort(WCTemplputParams *TP,
177 const char *OtherPrefix, long OtherPrefixLen,
178 const char *Default, long ldefault,
179 long DefaultDirection);
180 void RegisterSortFunc(const char *name, long len,
181 const char *prepend, long preplen,
184 CompareFunc GroupChange,
187 void dbg_print_longvector(long *LongVector);
193 void LogTemplateError (StrBuf *Target,
196 WCTemplputParams *TP,
197 const char *Format, ...);