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 */
34 typedef struct _TemplateParam {
41 /* make a template token a lookup key: */
42 #define TKEY(a) Tokens->Params[a]->Start, Tokens->Params[a]->len
43 typedef struct _TemplateToken {
44 const StrBuf *FileName; /* Reference to print error messages; not to be freed */
47 const char *pTokenStart;
50 const char *pTokenEnd;
59 TemplateParam *Params[MAXPARAM];
62 typedef void (*WCHandlerFunc)();
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 ???*/
84 #define CTX_NODECONF 7
85 #define CTX_USERLIST 8
87 #define CTX_MIME_ATACH 10
89 #define CTX_LONGVECTOR 13
92 void RegisterNS(const char *NSName, long len,
95 WCHandlerFunc HandlerFunc,
97 #define RegisterNamespace(a, b, c, d, e) RegisterNS(a, sizeof(a)-1, b, c, d, e)
99 typedef int (*WCConditionalFunc)(WCTemplateToken *Token, void *Context, int ContextType);
100 typedef struct _ConditionalStruct {
101 const char *PlainName;
104 WCConditionalFunc CondF;
106 void RegisterConditional(const char *Name, long len,
108 WCConditionalFunc CondF,
109 int ContextRequired);
113 typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context, WCTemplateToken *Token);
114 typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType);
115 typedef void (*HashDestructorFunc) (HashList **KillMe);
116 void RegisterITERATOR(const char *Name, long len, /* Our identifier */
117 int AdditionalParams, /* doe we use more parameters? */
118 HashList *StaticList, /* pointer to webcit lifetime hashlists */
119 RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */
120 SubTemplFunc DoSubTempl, /* call this function on each iteration for svput & friends */
121 HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */
122 int ContextType, /* which context do we provide to the subtemplate? */
123 int XPectContextType); /* which context do we expct to be called in? */
124 #define RegisterIterator(a, b, c, d, e, f, g, h) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h)
126 void GetTemplateTokenString(WCTemplateToken *Tokens,
132 void SVPut(char *keyname, size_t keylen, int keytype, char *Data);
133 #define svput(a, b, c) SVPut(a, sizeof(a) - 1, b, c)
134 void SVPutLong(char *keyname, size_t keylen, long Data);
135 #define svputlong(a, b) SVPutLong(a, sizeof(a) - 1, b)
136 void svprintf(char *keyname, size_t keylen, int keytype, const char *format,...) __attribute__((__format__(__printf__,4,5)));
137 void SVPRINTF(char *keyname, int keytype, const char *format,...) __attribute__((__format__(__printf__,3,4)));
138 void SVCALLBACK(char *keyname, WCHandlerFunc fcn_ptr);
139 void SVCallback(char *keyname, size_t keylen, WCHandlerFunc fcn_ptr);
140 #define svcallback(a, b) SVCallback(a, sizeof(a) - 1, b)
142 void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref);
143 #define SVPutBuf(a, b, c); SVPUTBuf(a, sizeof(a) - 1, b, c)
145 void DoTemplate(const char *templatename, long len, StrBuf *Target, void *Context, int ContextType);
146 #define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, b, 0);
147 void url_do_template(void);
149 int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
150 int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
152 void StrBufAppendTemplate(StrBuf *Target,
154 WCTemplateToken *Tokens,
155 void *Context, int ContextType,
156 const StrBuf *Source, int FormatTypeIndex);
157 CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix,
158 const char *Default, long ldefault, long DefaultDirection);
159 void RegisterSortFunc(const char *name, long len,
160 const char *prepend, long preplen,
165 void dbg_print_longvector(long *LongVector);