From 47bcaaabae789a2f20de958b84714ff2e23dc5bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Mon, 24 Nov 2008 22:14:03 +0000 Subject: [PATCH] * remove old (replaced) code * name it Tokens consistantly... * use the generic token escaping logic * QP-Decode Mime Name --- webcit/auth.c | 6 +- webcit/gettext.c | 7 +- webcit/inetconf.c | 221 +----------- webcit/messages.c | 28 +- webcit/msg_renderers.c | 106 +++--- webcit/notes.c | 20 +- webcit/preferences.c | 92 ++--- webcit/roomops.c | 8 +- webcit/siteconfig.c | 787 +---------------------------------------- webcit/subst.c | 162 ++++----- webcit/useredit.c | 286 +-------------- 11 files changed, 250 insertions(+), 1473 deletions(-) diff --git a/webcit/auth.c b/webcit/auth.c index 73a39ba62..be6b00ef3 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -884,17 +884,17 @@ void changepw(void) } } -int ConditionalAide(WCTemplateToken *Token, void *Context, int ContextType) +int ConditionalAide(WCTemplateToken *Tokens, void *Context, int ContextType) { return (WC->is_aide == 0); } -int ConditionalRoomAide(WCTemplateToken *Token, void *Context, int ContextType) +int ConditionalRoomAide(WCTemplateToken *Tokens, void *Context, int ContextType) { return (WC->is_room_aide == 0); } -int ConditionalRoomAcessDelete(WCTemplateToken *Token, void *Context, int ContextType) +int ConditionalRoomAcessDelete(WCTemplateToken *Tokens, void *Context, int ContextType) { struct wcsession *WCC = WC; return ( (WCC->is_room_aide) || (WCC->is_mailbox) || (WCC->room_flags2 & QR2_COLLABDEL) ); diff --git a/webcit/gettext.c b/webcit/gettext.c index 0994161e7..1402983c0 100644 --- a/webcit/gettext.c +++ b/webcit/gettext.c @@ -205,7 +205,7 @@ void httplang_to_locale(StrBuf *LocaleString) * depending on the browser locale change the sequence of the * language chooser. */ -void offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) { +void offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { int i; #ifndef HAVE_USELOCALE char *Lang = getenv("LANG"); @@ -366,10 +366,9 @@ void preset_locale(void) #endif /* ENABLE_NLS */ -void TmplGettext(StrBuf *Target, int nTokens, WCTemplateToken *Token) +void TmplGettext(StrBuf *Target, int nTokens, WCTemplateToken *Tokens) { - StrBufAppendBufPlain(Target, _(Token->Params[0]->Start), -1, 0); - + StrBufAppendBufPlain(Target, _(Tokens->Params[0]->Start), -1, 0); } diff --git a/webcit/inetconf.c b/webcit/inetconf.c index 191f90e76..8814784fb 100644 --- a/webcit/inetconf.c +++ b/webcit/inetconf.c @@ -7,212 +7,6 @@ #include "webcit.h" #include "webserver.h" -/* - * display the inet config dialog - */ -void display_inetconf(void) -{ - char buf[SIZ]; - char ename[SIZ]; - char etype[SIZ]; - int i; - int which; - int bg = 0; - - enum { - ic_localhost, - ic_directory, - ic_smarthost, - ic_rbl, - ic_spamass, - ic_masq, - ic_clamav, - ic_max - }; - - char *ic_spec[ic_max]; - char *ic_misc; - char *ic_keyword[ic_max]; - char *ic_boxtitle[ic_max]; - char *ic_desc[ic_max]; - - /* These are server config keywords; do not localize! */ - ic_keyword[0] = "localhost"; - ic_keyword[1] = "directory"; - ic_keyword[2] = "smarthost"; - ic_keyword[3] = "rbl"; - ic_keyword[4] = "spamassassin"; - ic_keyword[5] = "masqdomain"; - ic_keyword[6] = "clamav"; - - ic_boxtitle[0] = _("Local host aliases"); - ic_boxtitle[1] = _("Directory domains"); - ic_boxtitle[2] = _("Smart hosts"); - ic_boxtitle[3] = _("RBL hosts"); - ic_boxtitle[4] = _("SpamAssassin hosts"); - ic_boxtitle[5] = _("Masqueradable domains"); - ic_boxtitle[6] = _("ClamAV clamd hosts"); - - ic_desc[0] = _("(domains for which this host receives mail)"); - ic_desc[1] = _("(domains mapped with the Global Address Book)"); - ic_desc[2] = _("(if present, forward all outbound mail to one of these hosts)"); - ic_desc[3] = _("(hosts running a Realtime Blackhole List)"); - ic_desc[4] = _("(hosts running the SpamAssassin service)"); - ic_desc[5] = _("(Domains as which users are allowed to masquerade)"); - ic_desc[6] = _("(hosts running the ClamAV clamd service)"); - - for (i=0; i= 0) { - ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2); - if (!IsEmptyStr(ic_spec[which])) strcat(ic_spec[which], "\n"); - strcat(ic_spec[which], ename); - } - else { - ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2); - if (!IsEmptyStr(ic_misc)) strcat(ic_misc, "\n"); - strcat(ic_misc, buf); - } - - } - - output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n"); - wprintf("

"); - wprintf(_("Internet configuration")); - wprintf("

"); - wprintf("
\n"); - - wprintf("
\n"); - - wprintf("
" - " " - "
\n"); - for (which=0; which"); - } - svput("BOXTITLE", WCS_STRING, ic_boxtitle[which]); - do_template("beginboxx", NULL); - wprintf(""); - escputs(ic_desc[which]); - wprintf("
"); - wprintf("\n"); - bg = 0; - if (!IsEmptyStr(ic_spec[which])) { - for (i=0; i", - (bg ? "even" : "odd") - ); - wprintf("\n"); - } - - } - wprintf("\n"); - wprintf("\n", WC->nonce); - wprintf("
"); - extract_token(buf, ic_spec[which], i, '\n', sizeof buf); - escputs(buf); - wprintf("" - "" - "", - _("Delete this entry?")); - wprintf(_("Delete")); - wprintf("
" - "" - "", ic_keyword[which]); - wprintf("" - "" - "
\n"); - do_template("endbox", NULL); - wprintf("
"); - } - wprintf("
\n"); - wDumpContent(1); - - for (i=0; iImportantMessage, _("%s has been deleted."), ename); - } - else { - if (!IsEmptyStr(newconfig)) strcat(newconfig, "\n"); - strcat(newconfig, buf); - } - } - - serv_printf("CONF PUTSYS|application/x-citadel-internet-config"); - serv_getln(buf, SIZ); - if (buf[0] == '4') { - serv_puts(newconfig); - if (!strcasecmp(bstr("oper"), "add")) { - serv_printf("%s|%s", bstr("ename"), bstr("etype") ); - sprintf(WC->ImportantMessage, _("%s added."), bstr("ename")); - } - serv_puts("000"); - } - - display_inetconf(); - - free(buf); - free(ename); - free(etype); - free(newconfig); -} typedef enum _e_cfg { ic_localhost, @@ -251,7 +45,7 @@ ConstStrBuf CfgNames[] = { void load_inetconf(void) { struct wcsession *WCC = WC; - StrBuf *Buf, *Token, *Value; + StrBuf *Buf, *CfgToken, *Value; void *vHash; HashList *Hash; char nnn[64]; @@ -270,14 +64,14 @@ void load_inetconf(void) if (buf[0] == '1') { Buf = NewStrBuf(); - Token = NewStrBuf(); + CfgToken = NewStrBuf(); while ((len = StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000"))) { Value = NewStrBuf(); - StrBufExtract_token(Token, Buf, 1, '|'); + StrBufExtract_token(CfgToken, Buf, 1, '|'); StrBufExtract_token(Value, Buf, 0, '|'); - GetHash(WCC->InetCfg, ChrPtr(Token), StrLength(Token), &vHash); + GetHash(WCC->InetCfg, ChrPtr(CfgToken), StrLength(CfgToken), &vHash); Hash = (HashList*) vHash; if (Hash == NULL) { lprintf(1, "ERROR Loading inet config line: [%s]\n", @@ -290,7 +84,7 @@ void load_inetconf(void) Put(Hash, nnn, nUsed, Value, HFreeStrBuf); } FreeStrBuf(&Buf); - FreeStrBuf(&Token); + FreeStrBuf(&CfgToken); } } @@ -381,12 +175,12 @@ void new_save_inetconf(void) { url_do_template(); } -void InetCfgSubst(StrBuf *TemplBuffer, void *vContext, WCTemplateToken *Token) +void InetCfgSubst(StrBuf *TemplBuffer, void *vContext, WCTemplateToken *Tokens) { SVPutBuf("SERVCFG:INET:HOSTNAME", vContext, 1); } -void DeleteInetConfHash(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void DeleteInetConfHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct wcsession *WCC = WC; @@ -415,7 +209,6 @@ void InitModule_INETCONF (void) { - WebcitAddUrlHandler(HKEY("display_inetconf"), display_inetconf, 0); WebcitAddUrlHandler(HKEY("save_inetconf"), new_save_inetconf, AJAX); RegisterIterator("SERVCFG:INET", 1, NULL, GetInetConfHash, InetCfgSubst, NULL, CTX_INETCFG, CTX_NONE); RegisterNamespace("SERVCFG:FLUSHINETCFG",0, 0, DeleteInetConfHash, CTX_NONE); diff --git a/webcit/messages.c b/webcit/messages.c index 1cc4fa7a8..0ad1b776e 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -230,7 +230,7 @@ int summcmp_rdate(const void *s1, const void *s2) { */ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *PartNum) { StrBuf *Buf; - StrBuf *Token; + StrBuf *HdrToken; StrBuf *FoundCharset; HashPos *it; void *vMime; @@ -260,7 +260,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in /** begin everythingamundo table */ - Token = NewStrBuf(); + HdrToken = NewStrBuf(); Msg = (message_summary *)malloc(sizeof(message_summary)); memset(Msg, 0, sizeof(message_summary)); Msg->msgnum = msgnum; @@ -280,7 +280,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in StrBufAppendPrintf(Target, " (1)

\n"); StrBufAppendPrintf(Target, "
\n"); FreeStrBuf(&Buf); - FreeStrBuf(&Token); + FreeStrBuf(&HdrToken); DestroyMessageSummary(Msg); FreeStrBuf(&FoundCharset); return 0; @@ -295,11 +295,11 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in state ++; break; } - StrBufExtract_token(Token, Buf, 0, '='); - StrBufCutLeft(Buf, StrLength(Token) + 1); + StrBufExtract_token(HdrToken, Buf, 0, '='); + StrBufCutLeft(Buf, StrLength(HdrToken) + 1); - lprintf(1, ":: [%s] = [%s]\n", ChrPtr(Token), ChrPtr(Buf)); - if (GetHash(MsgHeaderHandler, SKEY(Token), &vHdr) && + lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf)); + if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) && (vHdr != NULL)) { Hdr = (headereval*)vHdr; Hdr->evaluator(Msg, Buf, FoundCharset); @@ -307,7 +307,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in state++; } } - else lprintf(1, "don't know how to handle message header[%s]\n", ChrPtr(Token)); + else lprintf(1, "don't know how to handle message header[%s]\n", ChrPtr(HdrToken)); break; case 1:/* Message Mime Header */ if (StrLength(Buf) == 0) { @@ -319,11 +319,11 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in } else { - StrBufExtract_token(Token, Buf, 0, ':'); - if (StrLength(Token) > 0) { - StrBufCutLeft(Buf, StrLength(Token) + 1); - lprintf(1, ":: [%s] = [%s]\n", ChrPtr(Token), ChrPtr(Buf)); - if (GetHash(MsgHeaderHandler, SKEY(Token), &vHdr) && + StrBufExtract_token(HdrToken, Buf, 0, ':'); + if (StrLength(HdrToken) > 0) { + StrBufCutLeft(Buf, StrLength(HdrToken) + 1); + lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf)); + if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) && (vHdr != NULL)) { Hdr = (headereval*)vHdr; Hdr->evaluator(Msg, Buf, FoundCharset); @@ -420,7 +420,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in DestroyMessageSummary(Msg); FreeStrBuf(&FoundCharset); - FreeStrBuf(&Token); + FreeStrBuf(&HdrToken); FreeStrBuf(&Buf); return 1; } diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index f294c5e35..ae4cf267b 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -94,10 +94,10 @@ void examine_from(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->from = NewStrBufPlain(NULL, StrLength(HdrLine)); StrBuf_RFC822_to_Utf8(Msg->from, HdrLine, WC->DefaultCharset, FoundCharset); } -void tmplput_MAIL_SUMM_FROM(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_FROM(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->from, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->from, 0); } @@ -108,10 +108,10 @@ void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->subj = NewStrBufPlain(NULL, StrLength(HdrLine)); StrBuf_RFC822_to_Utf8(Msg->subj, HdrLine, WC->DefaultCharset, FoundCharset); } -void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) {/////TODO: Fwd: and RE: filter!! message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->subj, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->subj, 0); } @@ -121,10 +121,10 @@ void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->reply_inreplyto = NewStrBufPlain(NULL, StrLength(HdrLine)); StrBuf_RFC822_to_Utf8(Msg->reply_inreplyto, HdrLine, WC->DefaultCharset, FoundCharset); } -void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->reply_inreplyto, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->reply_inreplyto, 0); } int Conditional_MAIL_SUMM_UNREAD(WCTemplateToken *Tokens, void *Context, int ContextType) @@ -139,10 +139,10 @@ void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->reply_references = NewStrBufPlain(NULL, StrLength(HdrLine)); StrBuf_RFC822_to_Utf8(Msg->reply_references, HdrLine, WC->DefaultCharset, FoundCharset); } -void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->reply_references, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->reply_references, 0); } @@ -158,10 +158,10 @@ void examine_cccc(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) } StrBufAppendBuf(Msg->AllRcpt, Msg->cccc, 0); } -void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->cccc, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->cccc, 0); } @@ -175,10 +175,10 @@ void examine_room(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->Room = NewStrBufDup(HdrLine); } } -void tmplput_MAIL_SUMM_ORGROOM(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_ORGROOM(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->Room, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->Room, 0); } @@ -187,10 +187,10 @@ void examine_rfca(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) FreeStrBuf(&Msg->Rfca); Msg->Rfca = NewStrBufDup(HdrLine); } -void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->Rfca, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->Rfca, 0); } int Conditional_MAIL_SUMM_RFCA(WCTemplateToken *Tokens, void *Context, int ContextType) { @@ -208,10 +208,10 @@ void examine_node(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->OtherNode = NewStrBufDup(HdrLine); } } -void tmplput_MAIL_SUMM_OTHERNODE(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_OTHERNODE(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->OtherNode, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->OtherNode, 0); } int Conditional_MAIL_SUMM_OTHERNODE(WCTemplateToken *Tokens, void *Context, int ContextType) { @@ -232,15 +232,15 @@ void examine_rcpt(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) } StrBufAppendBuf(Msg->AllRcpt, Msg->to, 0); } -void tmplput_MAIL_SUMM_TO(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_TO(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->to, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->to, 0); } -void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->AllRcpt, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->AllRcpt, 0); } @@ -249,14 +249,14 @@ void examine_time(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) { Msg->date = StrTol(HdrLine); } -void tmplput_MAIL_SUMM_DATE_STR(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_DATE_STR(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { char datebuf[64]; message_summary *Msg = (message_summary*) Context; webcit_fmt_date(datebuf, Msg->date, 1); StrBufAppendBufPlain(Target, datebuf, -1, 0); } -void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; StrBufAppendPrintf(Target, "%ld", Msg->date, 0); @@ -325,7 +325,8 @@ void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundChars Buf = NewStrBuf(); Mime->Name = NewStrBuf(); - StrBufExtract_token(Mime->Name, HdrLine, 0, '|'); + StrBufExtract_token(Buf, HdrLine, 0, '|'); + StrBuf_RFC822_to_Utf8(Mime->Name, Buf, WC->DefaultCharset, FoundCharset); StrBufTrim(Mime->Name); StrBufExtract_token(Buf, HdrLine, 1, '|'); @@ -409,7 +410,7 @@ void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime) } } -void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; StrBufAppendPrintf(Target, "%ld", GetCount(Msg->Attachments)); @@ -427,10 +428,10 @@ void examine_hnod(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->hnod = NewStrBufPlain(NULL, StrLength(HdrLine)); StrBuf_RFC822_to_Utf8(Msg->hnod, HdrLine, WC->DefaultCharset, FoundCharset); } -void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->hnod, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->hnod, 0); } int Conditional_MAIL_SUMM_H_NODE(WCTemplateToken *Tokens, void *Context, int ContextType) { @@ -490,7 +491,7 @@ void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCh */ } -void tmplput_MAIL_SUMM_N(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_SUMM_N(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; StrBufAppendPrintf(Target, "%ld", Msg->msgnum); @@ -525,17 +526,17 @@ int Conditional_MAIL_MIME_ATTACH(WCTemplateToken *Tokens, void *Context, int Con /*----------------------------------------------------------------------------*/ -void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { long MsgNum; - MsgNum = LBstr(Token->Params[0]->Start, Token->Params[0]->len); + MsgNum = LBstr(Tokens->Params[0]->Start, Tokens->Params[0]->len); read_message(Target, HKEY("view_message_replyquote"), MsgNum, 0, NULL); } -void tmplput_MAIL_BODY(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MAIL_BODY(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - StrBufAppendBuf(Target, Msg->MsgBody->Data, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->MsgBody->Data, 0); } @@ -707,57 +708,58 @@ HashList *iterate_get_mime_Attachments(StrBuf *Target, int nArgs, WCTemplateToke return Msg->AllAttach; } -void tmplput_MIME_Name(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MIME_Name(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_mime_attachment *mime = (wc_mime_attachment*) Context; - StrBufAppendBuf(Target, mime->Name, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->Name, 0); } -void tmplput_MIME_FileName(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MIME_FileName(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_mime_attachment *mime = (wc_mime_attachment*) Context; - StrBufAppendBuf(Target, mime->FileName, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->FileName, 0); } -void tmplput_MIME_PartNum(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MIME_PartNum(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_mime_attachment *mime = (wc_mime_attachment*) Context; - StrBufAppendBuf(Target, mime->PartNum, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->PartNum, 0); } -void tmplput_MIME_MsgNum(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MIME_MsgNum(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_mime_attachment *mime = (wc_mime_attachment*) Context; StrBufAppendPrintf(Target, "%ld", mime->msgnum); } -void tmplput_MIME_Disposition(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MIME_Disposition(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_mime_attachment *mime = (wc_mime_attachment*) Context; - StrBufAppendBuf(Target, mime->Disposition, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->Disposition, 0); } -void tmplput_MIME_ContentType(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MIME_ContentType(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_mime_attachment *mime = (wc_mime_attachment*) Context; - StrBufAppendBuf(Target, mime->ContentType, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->ContentType, 0); } -void tmplput_MIME_Charset(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MIME_Charset(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_mime_attachment *mime = (wc_mime_attachment*) Context; - StrBufAppendBuf(Target, mime->Charset, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->Charset, 0); } -void tmplput_MIME_Data(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MIME_Data(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_mime_attachment *mime = (wc_mime_attachment*) Context; if (mime->Renderer != NULL) mime->Renderer(mime, NULL, NULL); - StrBufAppendBuf(Target, mime->Data, 0); /// TODO: check whether we need to load it now? + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->Data, 0); + /// TODO: check whether we need to load it now? } -void tmplput_MIME_Length(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_MIME_Length(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_mime_attachment *mime = (wc_mime_attachment*) Context; StrBufAppendPrintf(Target, "%ld", mime->length); @@ -768,22 +770,22 @@ HashList *iterate_get_registered_Attachments(StrBuf *Target, int nArgs, WCTempla return WC->attachments; } -void tmplput_ATT_Length(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_ATT_Length(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_attachment *att = (wc_attachment*) Context; StrBufAppendPrintf(Target, "%ld", att->length); } -void tmplput_ATT_Contenttype(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_ATT_Contenttype(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_attachment *att = (wc_attachment*) Context; - StrBufAppendBuf(Target, att->content_type, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, att->content_type, 0); } -void tmplput_ATT_FileName(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_ATT_FileName(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wc_attachment *att = (wc_attachment*) Context; - StrBufAppendBuf(Target, att->filename, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, att->filename, 0); } diff --git a/webcit/notes.c b/webcit/notes.c index 7d496f638..82b6c9262 100644 --- a/webcit/notes.c +++ b/webcit/notes.c @@ -386,61 +386,61 @@ void add_new_note(void) { } -void tmpl_vcard_put_posleft(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmpl_vcard_put_posleft(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct vnote *v = (struct vnote *) Context; StrBufAppendPrintf(Target, "%d", v->pos_left); } -void tmpl_vcard_put_postop(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmpl_vcard_put_postop(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct vnote *v = (struct vnote *) Context; StrBufAppendPrintf(Target, "%d", v->pos_top); } -void tmpl_vcard_put_poswidth(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmpl_vcard_put_poswidth(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct vnote *v = (struct vnote *) Context; StrBufAppendPrintf(Target, "%d", v->pos_width); } -void tmpl_vcard_put_posheight(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmpl_vcard_put_posheight(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct vnote *v = (struct vnote *) Context; StrBufAppendPrintf(Target, "%d", v->pos_height); } -void tmpl_vcard_put_posheight2(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmpl_vcard_put_posheight2(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct vnote *v = (struct vnote *) Context; StrBufAppendPrintf(Target, "%d", (v->pos_height / 16) - 5); } -void tmpl_vcard_put_width2(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmpl_vcard_put_width2(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct vnote *v = (struct vnote *) Context; StrBufAppendPrintf(Target, "%d", (v->pos_width / 9) - 1); } -void tmpl_vcard_put_color(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmpl_vcard_put_color(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct vnote *v = (struct vnote *) Context; StrBufAppendPrintf(Target, "%02X%02X%02X", v->color_red, v->color_green, v->color_blue); } -void tmpl_vcard_put_bgcolor(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmpl_vcard_put_bgcolor(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct vnote *v = (struct vnote *) Context; StrBufAppendPrintf(Target, "%02X%02X%02X", v->color_red/2, v->color_green/2, v->color_blue/2); } -void tmpl_vcard_put_message(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmpl_vcard_put_message(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct vnote *v = (struct vnote *) Context; StrEscAppend(Target, NULL, v->body, 0, 0); ///TODO? } -void tmpl_vcard_put_uid(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmpl_vcard_put_uid(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { struct vnote *v = (struct vnote *) Context; StrBufAppendBufPlain(Target, v->uid, -1, 0); diff --git a/webcit/preferences.c b/webcit/preferences.c index 800968875..382667f38 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -626,37 +626,37 @@ void set_preferences(void) StrBuf *buf, *encBuf; int *time_format_cache; - time_format_cache = &(WC->time_format_cache); - - if (!havebstr("change_button")) { - safestrncpy(WC->ImportantMessage, - _("Cancelled. No settings were changed."), - sizeof WC->ImportantMessage); - display_main_menu(); - return; - } - - /** - * Set the last argument to 1 only for the final setting, so - * we don't send the prefs file to the server repeatedly - */ - set_preference("roomlistview", NewStrBufPlain(bstr("roomlistview"), -1), 0); - fmt = lbstr("calhourformat"); - set_pref_long("calhourformat", fmt, 0); - if (fmt == 24) - *time_format_cache = WC_TIMEFORMAT_24; - else - *time_format_cache = WC_TIMEFORMAT_AMPM; - - set_pref_long("weekstart", lbstr("weekstart"), 0); - set_pref_yesno("use_sig", yesbstr("use_sig"), 0); - set_pref_long("daystart", lbstr("daystart"), 0); - set_pref_long("dayend", lbstr("dayend"), 0); - set_preference("default_header_charset", NewStrBufPlain(bstr("default_header_charset"), -1), 0); - set_preference("emptyfloors", NewStrBufPlain(bstr("emptyfloors"), -1), 0); - set_preference("defaultfrom", NewStrBufDup(sbstr("defaultfrom")), 0); - set_preference("defaultname", NewStrBufDup(sbstr("defaultname")), 0); - set_preference("defaulthandle", NewStrBufDup(sbstr("defaulthandle")), 0); + time_format_cache = &(WC->time_format_cache); + + if (!havebstr("change_button")) { + safestrncpy(WC->ImportantMessage, + _("Cancelled. No settings were changed."), + sizeof WC->ImportantMessage); + display_main_menu(); + return; + } + + /** + * Set the last argument to 1 only for the final setting, so + * we don't send the prefs file to the server repeatedly + */ + set_preference("roomlistview", NewStrBufPlain(bstr("roomlistview"), -1), 0); + fmt = lbstr("calhourformat"); + set_pref_long("calhourformat", fmt, 0); + if (fmt == 24) + *time_format_cache = WC_TIMEFORMAT_24; + else + *time_format_cache = WC_TIMEFORMAT_AMPM; + + set_pref_long("weekstart", lbstr("weekstart"), 0); + set_pref_yesno("use_sig", yesbstr("use_sig"), 0); + set_pref_long("daystart", lbstr("daystart"), 0); + set_pref_long("dayend", lbstr("dayend"), 0); + set_preference("default_header_charset", NewStrBufPlain(bstr("default_header_charset"), -1), 0); + set_preference("emptyfloors", NewStrBufPlain(bstr("emptyfloors"), -1), 0); + set_preference("defaultfrom", NewStrBufDup(sbstr("defaultfrom")), 0); + set_preference("defaultname", NewStrBufDup(sbstr("defaultname")), 0); + set_preference("defaulthandle", NewStrBufDup(sbstr("defaulthandle")), 0); buf = NewStrBufPlain(bstr("signature"), -1); @@ -675,20 +675,20 @@ void set_preferences(void) #define PRF_YESNO 4 -void tmplput_CFG_Value(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_CFG_Value(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { StrBuf *Setting; - if (get_PREFERENCE(Token->Params[0]->Start, - Token->Params[0]->len, + if (get_PREFERENCE(Tokens->Params[0]->Start, + Tokens->Params[0]->len, &Setting)) - StrBufAppendBuf(Target, Setting, 0); + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Setting, 1); } -void tmplput_CFG_Descr(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void tmplput_CFG_Descr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { const char *SettingStr; - SettingStr = PrefGetLocalStr(Token->Params[0]->Start, - Token->Params[0]->len); + SettingStr = PrefGetLocalStr(Tokens->Params[0]->Start, + Tokens->Params[0]->len); if (SettingStr != NULL) StrBufAppendBufPlain(Target, SettingStr, -1, 0); } @@ -701,23 +701,23 @@ void CfgZoneTempl(StrBuf *TemplBuffer, void *vContext, WCTemplateToken *Token) SVPutBuf("ZONENAME", Zone, 1); } -int ConditionalPreference(WCTemplateToken *Token, void *Context, int ContextType) +int ConditionalPreference(WCTemplateToken *Tokens, void *Context, int ContextType) { StrBuf *Pref; - if (!get_PREFERENCE(Token->Params[2]->Start, - Token->Params[2]->len, + if (!get_PREFERENCE(Tokens->Params[2]->Start, + Tokens->Params[2]->len, &Pref)) return 0; - if (Token->nParameters == 3) { + if (Tokens->nParameters == 3) { return 1; } - else if (Token->Params[3]->Type == TYPE_STR) - return ((Token->Params[3]->len == StrLength(Pref)) && - (strcmp(Token->Params[3]->Start, ChrPtr(Pref)) == 0)); + else if (Tokens->Params[3]->Type == TYPE_STR) + return ((Tokens->Params[3]->len == StrLength(Pref)) && + (strcmp(Tokens->Params[3]->Start, ChrPtr(Pref)) == 0)); else - return (StrTol(Pref) == Token->Params[3]->lvalue); + return (StrTol(Pref) == Tokens->Params[3]->lvalue); } HashList *GetGVEAHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) diff --git a/webcit/roomops.c b/webcit/roomops.c index 8d690195e..2f4b0f1df 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -276,7 +276,7 @@ void zapped_list(void) /** * \brief read this room's info file (set v to 1 for verbose mode) */ -void readinfo(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +void readinfo(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { char buf[256]; char briefinfo[128]; @@ -325,7 +325,7 @@ void readinfo(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, * keep the browser from using a cached icon from * another room. */ -void embed_room_graphic(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) { +void embed_room_graphic(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { char buf[SIZ]; serv_puts("OIMG _roompic_"); @@ -381,7 +381,7 @@ void embed_room_graphic(StrBuf *Target, int nArgs, WCTemplateToken *Token, void /** * \brief Display the current view and offer an option to change it */ -void embed_view_o_matic(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) { +void embed_view_o_matic(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { int i; wprintf("
\n"); @@ -422,7 +422,7 @@ void embed_view_o_matic(StrBuf *Target, int nArgs, WCTemplateToken *Token, void /** * \brief Display a search box */ -void embed_search_o_matic(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) { +void embed_search_o_matic(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { wprintf("\n"); wprintf("
\n", WC->nonce); wprintf("