]> code.citadel.org Git - citadel.git/blobdiff - webcit/subst.h
* made wc_subst private. todo solved.
[citadel.git] / webcit / subst.h
index 743aac03a97f332430a8971613d44d8bdb1057e1..ad8fb61b54d55cf98b5dae192e422d449aece903 100644 (file)
@@ -78,21 +78,6 @@ typedef void (*WCHandlerFunc)(StrBuf *Target, WCTemplputParams *TP);
 /* make a template token a lookup key: */
 #define TKEY(a) TP->Tokens->Params[a]->Start, TP->Tokens->Params[a]->len
 
-/* TODO: wcsubst should be private! */
-
-/*
- * \brief Dynamic content for variable substitution in templates
- */
-typedef struct _wcsubst {
-       ContextFilter Filter;
-       int wcs_type;                       /* which type of Substitution are we */
-       char wcs_key[32];                   /* copy of our hashkey for debugging */
-       StrBuf *wcs_value;                  /* if we're a string, keep it here */
-       long lvalue;                        /* type long? keep data here */
-       WCHandlerFunc wcs_function; /* funcion hook ???*/
-} wcsubst;
-
-
 /**
  * this is the signature of a conditional function 
  * Note: Target is just passed in for error messages; don't write onto it in regular cases.
@@ -165,15 +150,6 @@ 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);
@@ -182,7 +158,7 @@ typedef void (*HashDestructorFunc) (HashList **KillMe);
 
 extern WCTemplputParams NoCtx;
 
-
+#define HAVE_PARAM(a) (TP->Tokens->nParameters > a)
 
 
 #define ERR_NAME 0
@@ -214,11 +190,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. 
@@ -291,7 +287,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);