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 WCTemplateToken WCTemplateToken;
34 typedef struct WCTemplputParams WCTemplputParams;
35 typedef void (*WCHandlerFunc)(StrBuf *Target, WCTemplputParams *TP);
37 typedef struct _TemplateParam {
44 /* make a template token a lookup key: */
45 #define TKEY(a) TP->Tokens->Params[a]->Start, TP->Tokens->Params[a]->len
46 struct WCTemplateToken {
47 const StrBuf *FileName; /* Reference to print error messages; not to be freed */
50 const char *pTokenStart;
53 const char *pTokenEnd;
62 TemplateParam *Params[MAXPARAM];
67 * \brief Dynamic content for variable substitution in templates
69 typedef struct _wcsubst {
70 int wcs_type; /* which type of Substitution are we */
71 char wcs_key[32]; /* copy of our hashkey for debugging */
72 StrBuf *wcs_value; /* if we're a string, keep it here */
73 long lvalue; /* type long? keep data here */
74 int ContextRequired; /* do we require a context type? */
75 WCHandlerFunc wcs_function; /* funcion hook ???*/
78 struct WCTemplputParams {
80 WCTemplateToken *Tokens;
86 extern WCTemplputParams NoCtx;
88 #define CTX TP->Context
99 #define CTX_NODECONF 7
100 #define CTX_USERLIST 8
101 #define CTX_MAILSUM 9
102 #define CTX_MIME_ATACH 10
103 #define CTX_FILELIST 11
104 #define CTX_STRBUF 12
105 #define CTX_LONGVECTOR 13
107 #define CTX_FLOORS 15
109 void RegisterNS(const char *NSName, long len,
112 WCHandlerFunc HandlerFunc,
113 int ContextRequired);
114 #define RegisterNamespace(a, b, c, d, e) RegisterNS(a, sizeof(a)-1, b, c, d, e)
116 typedef int (*WCConditionalFunc)(StrBuf *Target, WCTemplputParams *TP);
117 typedef struct _ConditionalStruct {
118 const char *PlainName;
121 WCConditionalFunc CondF;
123 void RegisterConditional(const char *Name, long len,
125 WCConditionalFunc CondF,
126 int ContextRequired);
130 typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, WCTemplputParams *TP);
131 typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, WCTemplputParams *TP);
132 typedef void (*HashDestructorFunc) (HashList **KillMe);
133 void RegisterITERATOR(const char *Name, long len, /* Our identifier */
134 int AdditionalParams, /* doe we use more parameters? */
135 HashList *StaticList, /* pointer to webcit lifetime hashlists */
136 RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */
137 SubTemplFunc DoSubTempl, /* call this function on each iteration for svput & friends */
138 HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */
139 int ContextType, /* which context do we provide to the subtemplate? */
140 int XPectContextType, /* which context do we expct to be called in? */
144 #define IT_FLAG_DETECT_GROUPCHANGE (1<<0)
146 #define RegisterIterator(a, b, c, d, e, f, g, h, i) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h, i)
148 void GetTemplateTokenString(WCTemplputParams *TP,
154 void SVPut(char *keyname, size_t keylen, int keytype, char *Data);
155 #define svput(a, b, c) SVPut(a, sizeof(a) - 1, b, c)
156 void SVPutLong(char *keyname, size_t keylen, long Data);
157 #define svputlong(a, b) SVPutLong(a, sizeof(a) - 1, b)
158 void svprintf(char *keyname, size_t keylen, int keytype, const char *format,...) __attribute__((__format__(__printf__,4,5)));
159 void SVPRINTF(char *keyname, int keytype, const char *format,...) __attribute__((__format__(__printf__,3,4)));
160 void SVCALLBACK(char *keyname, WCHandlerFunc fcn_ptr);
161 void SVCallback(char *keyname, size_t keylen, WCHandlerFunc fcn_ptr);
162 #define svcallback(a, b) SVCallback(a, sizeof(a) - 1, b)
164 void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref);
165 #define SVPutBuf(a, b, c); SVPUTBuf(a, sizeof(a) - 1, b, c)
167 void DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP);
168 #define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, &NoCtx);
169 void url_do_template(void);
171 int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
172 int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
174 void StrBufAppendTemplate(StrBuf *Target,
175 WCTemplputParams *TP,
176 const StrBuf *Source,
177 int FormatTypeIndex);
178 CompareFunc RetrieveSort(WCTemplputParams *TP,
179 const char *OtherPrefix, long OtherPrefixLen,
180 const char *Default, long ldefault,
181 long DefaultDirection);
182 void RegisterSortFunc(const char *name, long len,
183 const char *prepend, long preplen,
186 CompareFunc GroupChange,
189 void dbg_print_longvector(long *LongVector);
195 void LogTemplateError (StrBuf *Target,
198 WCTemplputParams *TP,
199 const char *Format, ...);