+ new way to retrieve integers from templates (bstr, pref...)
[citadel.git] / webcit / subst.h
index 466e6aee2d64b005dd883b7e70eeb6f2ab5bb70d..cc620e14fb8e35d54501d0a7622f8d9961574067 100644 (file)
@@ -51,6 +51,8 @@ enum {
 #define CTX_FLOORS 15
 #define CTX_ITERATE 16
 
+#define CTX_UNKNOWN 17
+
 
 /**
  * ContextFilter resembles our RTTI information. With this structure
@@ -163,8 +165,15 @@ typedef struct _ConditionalStruct {
        WCConditionalFunc CondF;
 } ConditionalStruct;
 
-
-
+/** IterateStruct TODO: SHOULD BE PRIVATE */
+typedef struct _iteratestruct {
+        int GroupChange;
+        int oddeven;  
+        const char *Key;
+        long KeyLen;
+        int n;
+        int LastN;
+}IterateStruct;
 
 typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, WCTemplputParams *TP);
 typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, WCTemplputParams *TP);
@@ -173,7 +182,7 @@ typedef void (*HashDestructorFunc) (HashList **KillMe);
 
 extern WCTemplputParams NoCtx;
 
-
+#define HAVE_PARAM(a) (TP->Tokens->nParameters > a)
 
 
 #define ERR_NAME 0
@@ -205,11 +214,31 @@ void LogTemplateError (StrBuf *Target,
  * \param Value reference to the string of the token; don't free me.
  * \param len the length of Value
  */
-void GetTemplateTokenString(WCTemplputParams *TP,
+void GetTemplateTokenString(StrBuf *Target, 
+                           WCTemplputParams *TP,
                            int N,
                            const char **Value, 
                            long *len);
 
+
+
+/**
+ * \Brief get the actual integer value of a token parameter
+ * in your tmplputs or conditionals use this function to access parameters that can also be 
+ * retrieved from dynamic facilities:
+ *  _ -> Gettext; retrieve this token from the i18n facilities
+ *  : -> lookup a setting of that name
+ *  B -> bstr; an URL-Parameter
+ *  = -> subtemplate; parse a template by this name, and treat its content as this tokens value 
+ * 
+ * \param N which token do you want to lookup?
+ * \param dflt default value to be retrieved if not found in preferences
+ * \returns the long value
+ */
+long GetTemplateTokenNumber(StrBuf *Target, 
+                           WCTemplputParams *TP, 
+                           int N, long dflt);
+
 /**
  * \Brief put a token value into the template
  * use this function to append your strings into a Template. 
@@ -282,7 +311,7 @@ void dbg_print_longvector(long *LongVector);
 
 
 #define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, &NoCtx);
-void DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP);
+const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP);
 void url_do_template(void);