Fix lots of warnings all over the place, make inbound buffers of FMOUT const.
[citadel.git] / webcit / subst.c
index 49723377ae23f235662e81b9fb3e52a679063530..4048579ed244c31d4d65b7c126f6638808723508 100644 (file)
@@ -109,6 +109,8 @@ const char *CtxNames[]  = {
        "Context DavNamespace",
        "Context TAB",
        "Context VCARD",
+       "Context SIEVE List",
+       "Context SIEVE Script",
        "Context UNKNOWN"
 };
 
@@ -390,35 +392,6 @@ void FreeWCTemplate(void *vFreeMe)
        free(FreeMe);
 }
 
-
-
-/**
- * \brief back end for print_value_of() ... does a server command
- * \param servcmd server command to execute on the citadel server
- */
-void pvo_do_cmd(StrBuf *Target, StrBuf *servcmd) {
-       char buf[SIZ];
-       int len;
-
-       serv_puts(ChrPtr(servcmd));
-       len = serv_getln(buf, sizeof buf);
-
-       switch(buf[0]) {
-               case '2':
-               case '3':
-               case '5':
-                       StrBufAppendPrintf(Target, "%s\n", &buf[4]);
-                       break;
-               case '1':
-                       _fmout(Target, "CENTER");
-                       break;
-               case '4':
-                       StrBufAppendPrintf(Target, "%s\n", &buf[4]);
-                       serv_puts("000");
-                       break;
-       }
-}
-
 int HaveTemplateTokenString(StrBuf *Target, 
                            WCTemplputParams *TP,
                            int N,
@@ -617,19 +590,19 @@ void StrBufAppendTemplate(StrBuf *Target,
                          WCTemplputParams *TP,
                          const StrBuf *Source, int FormatTypeIndex)
 {
-        wcsession *WCC;
+       const char *pFmt = NULL;
        char EscapeAs = ' ';
 
        if ((FormatTypeIndex < TP->Tokens->nParameters) &&
            (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) &&
-           (TP->Tokens->Params[FormatTypeIndex]->len == 1)) {
-               EscapeAs = *TP->Tokens->Params[FormatTypeIndex]->Start;
+           (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) {
+               pFmt = TP->Tokens->Params[FormatTypeIndex]->Start;
+               EscapeAs = *pFmt;
        }
 
        switch(EscapeAs)
        {
        case 'H':
-               WCC = WC;
                StrEscAppend(Target, Source, NULL, 0, 2);
                break;
        case 'X':
@@ -644,6 +617,12 @@ void StrBufAppendTemplate(StrBuf *Target,
        case 'U':
                StrBufUrlescAppend(Target, Source, NULL);
                break;
+       case 'F':
+               if (pFmt != NULL)       pFmt++;
+               else                    pFmt = "JUSTIFY";
+               if (*pFmt == '\0')      pFmt = "JUSTIFY";
+               FmOut(Target, pFmt, Source);
+               break;
        default:
                StrBufAppendBuf(Target, Source, 0);
        }
@@ -1205,7 +1184,6 @@ void *load_template(WCTemplate *NewTemplate)
        struct stat statbuf;
        const char *pS, *pE, *pch, *Err;
        long Line;
-       int pos;
 
        fd = open(ChrPtr(NewTemplate->FileName), O_RDONLY);
        if (fd <= 0) {
@@ -1225,7 +1203,6 @@ void *load_template(WCTemplate *NewTemplate)
                close(fd);
                syslog(1, "ERROR: reading template '%s' - %s<br>\n",
                        ChrPtr(NewTemplate->FileName), strerror(errno));
-               //FreeWCTemplate(NewTemplate);/////tODO
                return NULL;
        }
        close(fd);
@@ -1242,7 +1219,6 @@ void *load_template(WCTemplate *NewTemplate)
                void *pv;
 
                /** Find one <? > */
-               pos = (-1);
                for (; pch < pE; pch ++) {
                        if ((*pch=='<')&&(*(pch + 1)=='?') &&
                            !((pch == pS) && /* we must ommit a <?xml */
@@ -1323,7 +1299,7 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
               (filedir_entry != NULL))
        {
                char *MinorPtr;
-               char *PStart;
+
 #ifdef _DIRENT_HAVE_D_NAMELEN
                d_namelen = filedir_entry->d_namelen;
                d_type = filedir_entry->d_type;
@@ -1400,7 +1376,6 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
                            (strcmp(&filedir_entry->d_name[d_without_ext], ".orig") == 0) ||
                            (strcmp(&filedir_entry->d_name[d_without_ext], ".swp") == 0))
                                continue; /* Ignore backup files... */
-                       PStart = filedir_entry->d_name;
                        StrBufPrintf(FileName, "%s/%s", ChrPtr(DirName),  filedir_entry->d_name);
                        MinorPtr = strchr(filedir_entry->d_name, '.');
                        if (MinorPtr != NULL)
@@ -2164,9 +2139,9 @@ void tmpl_do_boxed(StrBuf *Target, WCTemplputParams *TP)
        memcpy (&SubTP, TP, sizeof(WCTemplputParams));
        SubTP.Context = Headline;
        SubTP.Filter.ContextType = CTX_STRBUF;
-       DoTemplate(HKEY("beginbox"), Target, &SubTP);
+       DoTemplate(HKEY("box_begin"), Target, &SubTP);
        DoTemplate(TKEY(0), Target, TP);
-       DoTemplate(HKEY("endbox"), Target, TP);
+       DoTemplate(HKEY("box_end"), Target, TP);
        FreeStrBuf(&Headline);
 }
 
@@ -2344,7 +2319,6 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
                         const char *OtherPrefix, long OtherPrefixLen,
                         const char *Default, long ldefault, long DefaultDirection)
 {
-       int isdefault = 0;
        const StrBuf *BSort = NULL;
        SortStruct *SortBy;
        void *vSortBy;
@@ -2378,7 +2352,6 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
 
        if (!GetHash(SortHash, SKEY(BSort), &vSortBy) || 
            (vSortBy == NULL)) {
-               isdefault = 1;
                if (!GetHash(SortHash, Default, ldefault, &vSortBy) || 
                    (vSortBy == NULL)) {
                        LogTemplateError(
@@ -2433,9 +2406,9 @@ enum {
 };
 
 ConstStr SortIcons[] = {
-       {HKEY("static/sort_none.gif")},
-       {HKEY("static/up_pointer.gif")},
-       {HKEY("static/down_pointer.gif")},
+       {HKEY("static/webcit_icons/sort_none.gif")},
+       {HKEY("static/webcit_icons/up_pointer.gif")},
+       {HKEY("static/webcit_icons/down_pointer.gif")},
 };
 
 ConstStr SortNextOrder[] = {