]> code.citadel.org Git - citadel.git/blobdiff - webcit/subst.h
* defines may now be ored or anded
[citadel.git] / webcit / subst.h
index d1157d87ab90f1515e7097acd639fad108855f35..adfaf8b380de4f31854793be71f53570f9cb9274 100644 (file)
@@ -15,8 +15,10 @@ extern HashList *LocalTemplateCache;
 #define TYPE_GETTEXT 5
 #define TYPE_BSTR 6
 #define TYPE_SUBTEMPLATE 7
+#define TYPE_INTDEFINE 8
 #define MAXPARAM  20
 
+#define IS_NUMBER(a) ((a == TYPE_LONG) || (a == TYPE_PREFINT) || (a == TYPE_INTDEFINE))
 
 /*
  * \brief Values for wcs_type
@@ -46,14 +48,15 @@ enum {
 #define CTX_MIME_ATACH 10
 #define CTX_FILELIST 11
 #define CTX_STRBUF 12
-#define CTX_LONGVECTOR 13
-#define CTX_ROOMS 14
-#define CTX_FLOORS 15
-#define CTX_ITERATE 16
-#define CTX_ICAL 17
-#define CTX_DAVNS 18
+#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_UNKNOWN 19
+#define CTX_UNKNOWN 20
 
 
 /**
@@ -89,6 +92,11 @@ typedef int (*WCPreevalFunc)(WCTemplateToken *Token);
  */
 typedef int (*WCConditionalFunc)(StrBuf *Target, WCTemplputParams *TP);
 
+typedef enum _eBitMask {
+       eNO = 0,
+       eOR,
+       eAND
+}eBitMask;
 
 typedef struct _TemplateParam {
         /* are we a string or a number? */
@@ -98,6 +106,7 @@ typedef struct _TemplateParam {
        long len;
        /* if we're a number: */
        long lvalue;
+       eBitMask MaskBy;
 } TemplateParam;
 
 
@@ -210,6 +219,14 @@ void GetTemplateTokenString(StrBuf *Target,
                            int N,
                            const char **Value, 
                            long *len);
+/**
+ * @return whether @ref GetTemplateTokenString would be able to give you a string
+ */
+int HaveTemplateTokenString(StrBuf *Target, 
+                           WCTemplputParams *TP,
+                           int N,
+                           const char **Value, 
+                           long *len);
 
 
 
@@ -282,6 +299,31 @@ void RegisterConditional(const char *Name, long len,
                         WCConditionalFunc CondF, 
                         int ContextRequired);
 
+/**
+ * @brief register a string that will represent a long value
+ * this will allow to resolve <?...(#"Name")> to Value; that way 
+ * plain strings can be used an lexed in templates without having the 
+ * lookup overhead at runtime.
+ * @param Name The name of the define
+ * @param len length of Name
+ * @param Value the value to associate with Name
+ */
+void RegisterTokenParamDefine(const char *Name, long len, 
+                             long Value);
+/**
+ * teh r0x0r! forward your favourite define from C to the templates with one easy call!
+ */
+#define REGISTERTokenParamDefine(a) RegisterTokenParamDefine(#a, sizeof(#a) - 1, a);
+
+/**
+ * @brief retrieve the long value of a registered string define
+ * @param Name The name of the define
+ * @param len length of Name
+ * @param Value the value to return if not found
+ */
+long GetTokenDefine(const char *Name, 
+                   long len, 
+                   long DefValue);
 
 
 #define IT_NOFLAG 0
@@ -322,7 +364,7 @@ void dbg_print_longvector(long *LongVector);
 
 
 
-#define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, &NoCtx);
+#define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, &NoCtx)
 const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP);
 void url_do_template(void);