]> code.citadel.org Git - citadel.git/blobdiff - webcit/subst.c
* --pedantic cleanup.
[citadel.git] / webcit / subst.c
index a4c123594a2a3e7f267f9bdd2d6a2ce35e2acfbf..ac0dd07874475cebb21101103975a623f39bb818 100644 (file)
@@ -496,14 +496,14 @@ void GetTemplateTokenString(WCTemplateToken *Tokens,
                break;
        case TYPE_LONG:
        case TYPE_PREFINT:
-               break; ///todo: string to text?
+               break; /* todo: string to text? */
        case TYPE_GETTEXT:
                *Value = _(Tokens->Params[N]->Start);
                *len = strlen(*Value);
                break;
        default:
                break;
-//todo log error
+/*/todo log error */
        }
 }
 
@@ -519,13 +519,13 @@ void print_value_of(StrBuf *Target, WCTemplateToken *Tokens, void *Context, int
        void *vVar;
 
        /*if (WCC->vars != NULL) PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
-       /// TODO: debricated!
+       /* TODO: depricated! */
        if (Tokens->pName[0] == '=') {
                DoTemplate(Tokens->pName+1, Tokens->NameEnd - 1, NULL, NULL, 0);
        }
 
-//////TODO: if param[1] == "U" -> urlescape
-/// X -> escputs
+/*/////TODO: if param[1] == "U" -> urlescape
+/// X -> escputs */
        /** Page-local variables */
        if ((WCC->vars!= NULL) && GetHash(WCC->vars, Tokens->pName, Tokens->NameEnd, &vVar)) {
                ptr = (wcsubst*) vVar;
@@ -1090,7 +1090,6 @@ void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere)
 }
 
 
-///void PrintTemplate(const char *Key, void *vSubst, int odd)
 const char* PrintTemplate(void *vSubst)
 {
        WCTemplate *Tmpl = vSubst;
@@ -1189,8 +1188,9 @@ int EvaluateToken(StrBuf *Target, WCTemplateToken *Tokens, WCTemplate *pTmpl, vo
        long AppendMeLen;
        HashHandler *Handler;
        void *vVar;
-// much output, since pName is not terminated...
-//     lprintf(1,"Doing token: %s\n",Token->pName);
+/* much output, since pName is not terminated...
+       lprintf(1,"Doing token: %s\n",Token->pName);
+*/
 
        switch (Tokens->Flags) {
        case SV_GETTEXT:
@@ -1431,8 +1431,10 @@ void DoTemplate(const char *templatename, long len, StrBuf *Target, void *Contex
                StrBufAppendPrintf(Target, "<pre>\ndidn't find Template [%s] %ld %ld\n</pre>", 
                                   templatename, len, 
                                   (long)strlen(templatename));
-///            dbg_PrintHash(Static, PrintTemplate, NULL);
-//             PrintHash(Static, VarPrintTransition, PrintTemplate);
+#if 0
+               dbg_PrintHash(Static, PrintTemplate, NULL);
+               PrintHash(Static, VarPrintTransition, PrintTemplate);
+#endif
                return;
        }
        if (vTmpl == NULL) 
@@ -1643,7 +1645,7 @@ int ConditionalVar(WCTemplateToken *Tokens, void *Context, int ContextType)
        case WCS_FUNCTION:
                return (subst->wcs_function!=NULL);
        case WCS_SERVCMD:
-               lprintf(1, "  -> Server [%s]\n", subst->wcs_value);////todo
+               lprintf(1, "  -> Server [%s]\n", subst->wcs_value);/* TODO */
                return 1;
        case WCS_STRING:
        case WCS_STRBUF:
@@ -1801,7 +1803,7 @@ CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix,
        const StrBuf *BSort;
        SortStruct *SortBy;
        void *vSortBy;
-       long SortOrder;
+       long SortOrder = -1;
        
        if (havebstr("SortBy")) {
                BSort = sbstr("SortBy");
@@ -1811,7 +1813,15 @@ CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix,
                        BSort = get_room_pref("sort");
                }
                else {
-                       ////todo: nail prefprepend to sort, and lookup this!
+                       /*TODO: nail prefprepend to sort, and lookup this! */
+               }
+               if (BSort != NULL)
+                       putbstr("SortBy", NewStrBufDup(BSort));
+               else {
+                       StrBuf *Buf;
+
+                       BSort = Buf = NewStrBufPlain(Default, ldefault);
+                       putbstr("SortBy", Buf);
                }
        }
 
@@ -1831,12 +1841,21 @@ CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix,
                SortOrder = LBSTR("SortOrder");
        }
        else { /** Try to fallback to our remembered values... */
+               StrBuf *Buf;
                if (SortBy->PrefPrepend == NULL) {
-                       SortOrder = StrTol(get_room_pref("SortOrder"));
+                       Buf = get_room_pref("SortOrder");
+                       SortOrder = StrTol(Buf);
                }
                else {
-                       ////todo: nail prefprepend to sort, and lookup this!
+                       /* TODO: nail prefprepend to sort, and lookup this! */
                }
+
+               if (Buf == NULL)
+                       SortOrder = DefaultDirection;
+
+               Buf = NewStrBufPlain(NULL, 64);
+               StrBufPrintf(Buf, "%ld", SortOrder);
+               putbstr("SortOrder", Buf);
        }
        switch (SortOrder) {
        default:
@@ -1893,7 +1912,7 @@ int GetSortMetric(WCTemplateToken *Tokens, SortStruct **Next, SortStruct **Param
                        BSort = get_room_pref("sort");
                }
                else {
-                       ////todo: nail prefprepend to sort, and lookup this!
+                       /* TODO: nail prefprepend to sort, and lookup this! */
                }
        }
 
@@ -1912,7 +1931,7 @@ int GetSortMetric(WCTemplateToken *Tokens, SortStruct **Next, SortStruct **Param
                        *SortOrder = StrTol(get_room_pref("SortOrder"));
                }
                else {
-                       ////todo: nail prefprepend to sort, and lookup this!
+                       /* TODO: nail prefprepend to sort, and lookup this! */
                }
        }
        if (*SortOrder > 2)
@@ -2105,7 +2124,22 @@ void tmplput_long_vector(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, voi
        }
 }
 
+void dbg_print_longvector(long *LongVector)
+{
+       StrBuf *Buf = NewStrBufPlain(HKEY("Longvector: ["));
+       int nItems = LongVector[0];
+       int i;
 
+       for (i = 0; i < nItems; i++) {
+               if (i + 1 < nItems)
+                       StrBufAppendPrintf(Buf, "%d: %ld | ", i, LongVector[i]);
+               else
+                       StrBufAppendPrintf(Buf, "%d: %ld]\n", i, LongVector[i]);
+
+       }
+       lprintf(1, ChrPtr(Buf));
+       FreeStrBuf(&Buf);
+}
 
 int ConditionalLongVector(WCTemplateToken *Tokens, void *Context, int ContextType)
 {