aclocal.m4
*.d
-
+gmon.out
+modules_init.c
*/
#include "webcit.h"
+#include "webserver.h"
/*
* display the inet config dialog
}
+
/*
* save changes to the inet config
*/
serv_puts(newconfig);
if (!strcasecmp(bstr("oper"), "add")) {
serv_printf("%s|%s", bstr("ename"), bstr("etype") );
- sprintf(WC->ImportantMessage, "%s added.", bstr("ename"));
+ sprintf(WC->ImportantMessage, _("%s added."), bstr("ename"));
}
serv_puts("000");
}
free(newconfig);
}
+typedef enum _e_cfg {
+ ic_localhost,
+ ic_directory,
+ ic_smarthost,
+ ic_rbl,
+ ic_spamass,
+ ic_masq,
+ ic_max
+} ECfg;
+
+typedef struct _ConstStrBuf {
+ const char *name;
+ size_t len;
+} ConstStrBuf;
+
+
+ /* These are server config keywords; do not localize! */
+ConstStrBuf CfgNames[] = {
+ { HKEY("localhost") },
+ { HKEY("directory") },
+ { HKEY("smarthost") },
+ { HKEY("rbl") },
+ { HKEY("spamassassin") },
+ { HKEY("masqdomain") }
+};
+
+
+
+
+/*
+ * display the inet config dialog
+ */
+void load_inetconf(void)
+{
+ struct wcsession *WCC = WC;
+ StrBuf *Buf, *Token, *Value;
+ void *vHash;
+ HashList *Hash;
+ char nnn[64];
+ char buf[SIZ];
+ int i, len, nUsed;
+
+ WCC->InetCfg = NewHash(1, NULL);
+
+ for (i = 0; i < (sizeof(CfgNames) / sizeof(ConstStrBuf)); i++) {
+ Hash = NewHash(1, NULL);
+ Put(WCC->InetCfg, CfgNames[i].name, CfgNames[i].len, Hash, HDeleteHash);
+ }
+
+ serv_printf("CONF GETSYS|application/x-citadel-internet-config");
+ serv_getln(buf, sizeof buf);
+
+ if (buf[0] == '1') {
+ Buf = NewStrBuf();
+ Token = NewStrBuf();
+ while ((len = StrBuf_ServGetln(Buf),
+ strcmp(ChrPtr(Buf), "000"))) {
+ Value = NewStrBuf();
+
+ StrBufExtract_token(Token, Buf, 1, '|');
+ StrBufExtract_token(Value, Buf, 0, '|');
+ GetHash(WCC->InetCfg, ChrPtr(Token), StrLength(Token), &vHash);
+ Hash = (HashList*) vHash;
+ if (Hash == NULL) {
+ lprintf(1, "ERROR Loading inet config line: [%s]\n",
+ ChrPtr(Buf));
+ FreeStrBuf(&Value);
+ continue;
+ }
+ nUsed = GetCount(Hash);
+ nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1);
+ Put(Hash, nnn, nUsed, Value, HFreeStrBuf);
+ }
+ FreeStrBuf(&Buf);
+ FreeStrBuf(&Token);
+ }
+}
+
+
+/*
+ * save changes to the inet config
+ */
+void new_save_inetconf(void) {
+ struct wcsession *WCC = WC;
+ HashList *Hash;
+ StrBuf *Str;
+ const StrBuf *eType, *eNum, *eName;
+ char nnn[64];
+ void *vHash, *vStr;
+ char buf[SIZ];
+ int i, nUsed;
+
+ load_inetconf();
+ eType = sbstr("etype");
+
+ GetHash(WCC->InetCfg, ChrPtr(eType), StrLength(eType), &vHash);
+ Hash = (HashList*) vHash;
+ if (Hash == NULL) {
+ sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+ url_do_template();
+ return;
+ }
+
+ if (strcasecmp(bstr("oper"), "delete") == 0) {
+ eNum = sbstr("ename");
+ if (!GetHash(Hash, ChrPtr(eNum), StrLength(eNum), &vStr) ||
+ (vStr == NULL)) {
+ sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+ url_do_template();
+ return;
+ }
+
+ Str = (StrBuf*)vStr;
+ sprintf(WC->ImportantMessage, _("%s has been deleted."), ChrPtr(Str));
+ FlushStrBuf(Str);
+ }
+ else if (!strcasecmp(bstr("oper"), "add")) {
+ eName = sbstr("ename");
+ if (eName == NULL) {
+ sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+ url_do_template();
+ return;
+ }
+
+ nUsed = GetCount(Hash);
+ nUsed = snprintf(nnn, sizeof(nnn), "%d", nUsed+1);
+
+ Put(Hash, nnn, nUsed, NewStrBufDup(eName), HFreeStrBuf);
+ sprintf(WC->ImportantMessage, "%s added.", ChrPtr(eName));
+ }
+
+ serv_printf("CONF PUTSYS|application/x-citadel-internet-config");
+ serv_getln(buf, SIZ);
+ if (buf[0] == '4') {
+ for (i = 0; i < (sizeof(CfgNames) / sizeof(ConstStrBuf)); i++) {
+ HashPos *where;
+ const char *Key;
+ long KeyLen;
+
+ GetHash(WCC->InetCfg, CfgNames[i].name, CfgNames[i].len, &vHash);
+ Hash = (HashList*) vHash;
+ if (Hash == NULL) {
+ sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+ url_do_template();
+ return;
+ }
+ if (GetCount(Hash) > 0) {
+ where = GetNewHashPos();
+ while (GetNextHashPos(Hash, where, &KeyLen, &Key, &vStr)) {
+ Str = (StrBuf*) vStr;
+ if ((Str!= NULL) && (StrLength(Str) > 0))
+ serv_printf("%s|%s",
+ ChrPtr(Str),
+ CfgNames[i].name);
+ }
+ DeleteHashPos(&where);
+ }
+ }
+ serv_puts("000");
+ DeleteHash(&WCC->InetCfg);
+ }
+
+ url_do_template();
+}
+
+void InetCfgSubst(StrBuf *TemplBuffer, void *vContext, WCTemplateToken *Token)
+{
+ SVPutBuf("SERVCFG:INET:HOSTNAME", vContext, 1);
+}
+
+void DeleteInectConfHash(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context)
+{
+ struct wcsession *WCC = WC;
+ if (WCC->InetCfg == NULL)
+ load_inetconf();
+ DeleteHash(&WCC->InetCfg);
+
+}
+
+
+HashList *GetInetConfHash(WCTemplateToken *Token)
+{
+ struct wcsession *WCC = WC;
+ void *vHash;
+
+ if (WCC->InetCfg == NULL)
+ load_inetconf();
+ GetHash(WCC->InetCfg,
+ Token->Params[2]->Start,
+ Token->Params[2]->len,
+ &vHash);
+ svprintf(HKEY("SERVCFG:INET:TYPE"), WCS_STRING, Token->Params[2]->Start);
+ return vHash;
+}
+
void
InitModule_INETCONF
(void)
{
WebcitAddUrlHandler(HKEY("display_inetconf"), display_inetconf, 0);
- WebcitAddUrlHandler(HKEY("save_inetconf"), save_inetconf, AJAX);
+ WebcitAddUrlHandler(HKEY("save_inetconf"), new_save_inetconf, AJAX);
+ RegisterIterator("SERVCFG:INET", 1, NULL, GetInetConfHash, InetCfgSubst, NULL);
+ RegisterNamespace("SERVCFG:FLUSHINETCFG",0, 0, DeleteInectConfHash);
}
}
-void CfgZoneTempl(StrBuf *TemplBuffer, void *vContext)
+void CfgZoneTempl(StrBuf *TemplBuffer, void *vContext, WCTemplateToken *Token)
{
StrBuf *Zone = (StrBuf*) vContext;
RegisterNamespace("PREF:VALUE", 1, 1, tmplput_CFG_Value);
RegisterNamespace("PREF:DESCR", 1, 1, tmplput_CFG_Descr);
- RegisterIterator("PREF:ZONE", ZoneHash, NULL, CfgZoneTempl, NULL);
+ RegisterIterator("PREF:ZONE", 0, ZoneHash, NULL, CfgZoneTempl, NULL);
RegisterConditional(HKEY("COND:PREF"), 4, ConditionalPreference);
}
serv_printf("CONF get");
serv_getln(buf, sizeof buf);
i = 0;
- while (len = serv_getln(buf, sizeof buf),
- strcmp(buf, "000") &&
- (i < sizeof(ServerConfig)))
+ Buf = NewStrBuf();
+ while ((sizeof(ServerConfig) / sizeof(CfgMapping)) &&
+ (len = StrBuf_ServGetln(Buf),
+ strcmp(ChrPtr(Buf), "000")) &&
+ (i <= sizeof(ServerConfig)))
{
Put(Cfg,
ServerConfig[i].Key,
ServerConfig[i].len,
- NewStrBufPlain(buf, len),
+ Buf,
HFreeStrBuf);
i++;
+ if (i <= sizeof(ServerConfig) / sizeof(CfgMapping))
+ Buf = NewStrBuf();
+ else
+ Buf = NULL;
}
+ FreeStrBuf(&Buf);
serv_puts("GPEX site");
Buf = NewStrBuf();
<ul class="adminitems">
<li><a href="do_template?template=display_sitewide_config"><?_("Edit site-wide configuration")></a></li>
-<li><a href="display_inetconf"><?_("Domain names and Internet mail configuration")></a></li>
+<li><a href="do_template?template=aide_inetconf"><?_("Domain names and Internet mail configuration")></a></li>
<li><a href="display_netconf"><?_("Configure replication with other Citadel servers")></a></li>
<li><a href="display_smtpqueue"><?_("View the outbound SMTP queue")></a></li>
</ul>
--- /dev/null
+<span class="menudesc">
+<?_("(domains for which this host receives mail)")>
+</span><br />
+<table border=0 cellspacing="2px" cellpadding="2px" width=94%% class="altern" >
+<?ITERATE("SERVCFG:INET", "section_aide_inetconf_entry", "localhost")>
+<form method="post" action="save_inetconf">
+<input type="hidden" name="nonce" value='<?NONCE>'>
+<tr><td>
+<input type="text" name="ename" maxlength="64">
+<input type="hidden" name="etype" VALUE="localhost">
+</td><td align=left>
+<input type="submit" name="oper" value="Add">
+<input type="hidden" name="template" value="aide_inetconf">
+</td></tr></table></form>
--- /dev/null
+<span class="menudesc">
+<?_("(domains mapped with the Global Address Book)")>
+</span><br />
+<table border=0 cellspacing="2px" cellpadding="2px" width=94%% class="altern" >
+<?ITERATE("SERVCFG:INET", "section_aide_inetconf_entry", "directory")>
+<form method="post" action="save_inetconf">
+<input type="hidden" name="nonce" value='<?NONCE>'>
+<tr><td>
+<input type="text" name="ename" maxlength="64">
+<input type="hidden" name="etype" VALUE="directory">
+</td><td align=left>
+<input type="submit" name="oper" value="Add">
+<input type="hidden" name="template" value="aide_inetconf">
+</td></tr></table></form>
--- /dev/null
+<span class="menudesc">
+<?_("(Domains as which users are allowed to masquerade)")>
+</span><br />
+<table border=0 cellspacing="2px" cellpadding="2px" width=94%% class="altern" >
+<?ITERATE("SERVCFG:INET", "section_aide_inetconf_entry", "masqdomain")>
+<form method="post" action="save_inetconf">
+<input type="hidden" name="nonce" value='<?NONCE>'>
+<tr><td>
+<input type="text" name="ename" maxlength="64">
+<input type="hidden" name="etype" VALUE="directory">
+</td><td align=left>
+<input type="submit" name="oper" value="Add">
+<input type="hidden" name="template" value="aide_inetconf">
+</td></tr></table></form>
--- /dev/null
+<span class="menudesc">
+<?_("(hosts running a Realtime Blackhole List)")>
+</span><br />
+<table border=0 cellspacing="2px" cellpadding="2px" width=94%% class="altern" >
+<?ITERATE("SERVCFG:INET", "section_aide_inetconf_entry", "rbl")>
+<form method="post" action="save_inetconf">
+<input type="hidden" name="nonce" value='<?NONCE>'>
+<tr><td>
+<input type="text" name="ename" maxlength="64">
+<input type="hidden" name="etype" VALUE="rbl">
+</td><td align=left>
+<input type="submit" name="oper" value="Add">
+<input type="hidden" name="template" value="aide_inetconf">
+</td></tr></table></form>
--- /dev/null
+<span class="menudesc">
+<?_("(if present, forward all outbound mail to one of these hosts)")>
+</span><br />
+<table border=0 cellspacing="2px" cellpadding="2px" width=94%% class="altern" >
+<?ITERATE("SERVCFG:INET", "section_aide_inetconf_entry", "smarthost")>
+<form method="post" action="save_inetconf">
+<input type="hidden" name="nonce" value='<?NONCE>'>
+<tr><td>
+<input type="text" name="ename" maxlength="64">
+<input type="hidden" name="etype" VALUE="rbl">
+</td><td align=left>
+<input type="submit" name="oper" value="Add">
+<input type="hidden" name="template" value="aide_inetconf">
+</td></tr></table></form>
--- /dev/null
+<span class="menudesc">
+<?_("(hosts running the SpamAssassin service)")>
+</span><br />
+<table border=0 cellspacing="2px" cellpadding="2px" width=94%% class="altern" >
+<?ITERATE("SERVCFG:INET", "section_aide_inetconf_entry", "spamassassin")>
+<form method="post" action="save_inetconf">
+<input type="hidden" name="nonce" value='<?NONCE>'>
+<tr><td>
+<input type="text" name="ename" maxlength="64">
+<input type="hidden" name="etype" VALUE="spamassassin">
+</td><td align=left>
+<input type="submit" name="oper" value="Add">
+<input type="hidden" name="template" value="aide_inetconf">
+</td></tr></table></form>
--- /dev/null
+<?=("head")>
+<?=("important_msg")>
+<?ICONBAR>
+<div id="banner">
+<h1>
+<??("COND:AIDE", 1)><?_("System Administration Menu")><??("X", 1)>
+<?!("COND:AIDE", 2)><?_("Room Aide Menu")><?!("X", 2)>
+</h1>
+</div>
+<div id="content" class="service">
+<div class="fix_scrollbar_bug">
+<table border=0 width=100% cellspacing="10px" cellpadding="10px"> <tr><td valign=top width=50%>
+
+
+<?DOBOXED("aide_inet_aliases", "subject_inet_aliases")><br />
+<?DOBOXED("aide_inet_dirnames", "subject_inet_dirnames")><br />
+<?DOBOXED("aide_inet_smarthosts", "subject_inet_smarthosts")>
+
+</td><td valign=top>
+
+
+<?DOBOXED("aide_inet_rbldns", "subject_inet_rbldns")><br />
+<?DOBOXED("aide_inet_spamass", "subject_inet_spamass")><br />
+<?DOBOXED("aide_inet_masqdomains", "subject_inet_masqdomains")>
+
+
+</td></tr></table>
+<?SERVCFG:FLUSHINETCFG>
+<?=("trailing")>
--- /dev/null
+<tr class='<?ITERATE:ODDEVEN>'>
+<td align=left>
+<?SERVCFG:INET:HOSTNAME>
+</td><td align=left>
+<span class="button_link">
+<a href='save_inetconf?template=aide_inetconf&oper=delete&ename=<?ITERATE:KEY>&etype=<?SERVCFG:INET:TYPE>' onClick='return confirm(\'<?_("Delete this entry?")>\')' >
+<?_("Delete")> </a></span></td></tr>
--- /dev/null
+<OPTION <?%("COND:SERVCFG:SUBST", 1, "c_default_cal_zone", "ZONENAME", 'selected="selected"', "")> VALUE='<?ZONENAME>'><?ZONENAME></OPTION>
--- /dev/null
+<?_("Local host aliases")>
--- /dev/null
+<?_("Directory domains")>
--- /dev/null
+<?_("Masqueradable domains")>
--- /dev/null
+<?_("RBL hosts")>
--- /dev/null
+<?_("Smart hosts")>
--- /dev/null
+<?_("SpamAssassin hosts")>
--- /dev/null
+<input type="submit" NAME="ok_button" VALUE='<?_("Save changes")>'>
+
+<input type="submit" NAME="cancel_button" VALUE='<?_("Cancel")>'>
StrBufAppendPrintf(Target, "%ld", ptr->lvalue);
break;
default:
- lprintf(1,"WARNING: invalid value in SV-Hash at %s!", keyname);
+ lprintf(1,"WARNING: invalid value in SV-Hash at %s!\n", keyname);
+ StrBufAppendPrintf(Target, "<pre>WARNING: \ninvalid value in SV-Hash at %s!</pre>", keyname);
}
}
}
return ParamToCompare->lvalue == ptr->lvalue;
break;
default:
- lprintf(1,"WARNING: invalid value in SV-Hash at %s!",
+ lprintf(1,"WARNING: invalid value in SV-Hash at %s!\n",
ParamToLookup->Start);
}
}
case WCS_LONG:
return StrTol(Compare) == ptr->lvalue;
default:
- lprintf(1,"WARNING: invalid value in SV-Hash at %s!",
+ lprintf(1,"WARNING: invalid value in SV-Hash at %s!\n",
ParamToLookup->Start);
}
}
NewToken->TokenEnd = (pTmplEnd - pStart) - NewToken->TokenStart;
NewToken->pTokenEnd = pTmplEnd;
NewToken->NameEnd = NewToken->TokenEnd - 2;
- NewToken->FlatToken = NewStrBufPlain(pTmplStart, pTmplEnd - pTmplStart);
+ NewToken->FlatToken = NewStrBufPlain(pTmplStart + 2, pTmplEnd - pTmplStart - 2);
StrBufPeek(Buf, pTmplStart, + 1, '\0');
StrBufPeek(Buf, pTmplEnd, -1, '\0');
if (Param != NULL) {
NewToken->HaveParameters = 1;
if (NewToken->nParameters > MAXPARAM) {
- lprintf(1, "Only %ld Tokens supported!\n", MAXPARAM);
+ lprintf(1, "Error (in '%s' line %ld); "
+ "only [%ld] Params allowed in Tokens [%s]\n",
+ ChrPtr(pTmpl->FileName),
+ NewToken->Line,
+ MAXPARAM,
+ ChrPtr(NewToken->FlatToken));
free(Param);
return NULL;
}
}
-int EvaluateConditional(WCTemplateToken *Token, WCTemplate *pTmpl, void *Context, int Neg, int state)
+int EvaluateConditional(StrBuf *Target, WCTemplateToken *Token, WCTemplate *pTmpl, void *Context, int Neg, int state)
{
- void *vConditional;
+ void *vConditional = NULL;
ConditionalStruct *Cond;
if ((Token->Params[0]->len == 1) &&
if (!GetHash(Contitionals,
Token->Params[0]->Start,
Token->Params[0]->len,
- &vConditional)) {
+ &vConditional) ||
+ (vConditional == NULL)) {
lprintf(1, "Conditional [%s] (in '%s' line %ld); Not found![%s]\n",
Token->Params[0]->Start,
ChrPtr(pTmpl->FileName),
Token->Line,
ChrPtr(Token->FlatToken));
+ StrBufAppendPrintf(
+ Target,
+ "<pre>\nConditional [%s] (in '%s' line %ld); Not found!\n[%s]\n</pre>\n",
+ Token->Params[0]->Start,
+ ChrPtr(pTmpl->FileName),
+ Token->Line,
+ ChrPtr(Token->FlatToken));
}
Cond = (ConditionalStruct *) vConditional;
- if (Cond == NULL) {
- lprintf(1, "Conditional [%s] (in '%s' line %ld); Not found![%s]\n",
+ if (Token->nParameters < Cond->nParams) {
+ lprintf(1, "Conditional [%s] (in '%s' line %ld); needs %ld Params![%s]\n",
Token->Params[0]->Start,
ChrPtr(pTmpl->FileName),
Token->Line,
+ Cond->nParams,
ChrPtr(Token->FlatToken));
- return 0;
- }
- if (Token->nParameters < Cond->nParams) {
- lprintf(1, "Conditional [%s] (in '%s' line %ld); needs %ld Params![%s]\n",
+ StrBufAppendPrintf(
+ Target,
+ "<pre>\nConditional [%s] (in '%s' line %ld); needs %ld Params!\n[%s]\n</pre>\n",
Token->Params[0]->Start,
ChrPtr(pTmpl->FileName),
Token->Line,
TmplGettext(Target, Token->nParameters, Token);
break;
case SV_CONDITIONAL: /** Forward conditional evaluation */
- return EvaluateConditional(Token, pTmpl, Context, 1, state);
+ return EvaluateConditional(Target, Token, pTmpl, Context, 1, state);
break;
case SV_NEG_CONDITIONAL: /** Reverse conditional evaluation */
- return EvaluateConditional(Token, pTmpl, Context, 0, state);
+ return EvaluateConditional(Target, Token, pTmpl, Context, 0, state);
break;
case SV_CUST_STR_CONDITIONAL: /** Conditional put custom strings from params */
if (Token->nParameters >= 6) {
- if (EvaluateConditional(Token, pTmpl, Context, 0, state))
+ if (EvaluateConditional(Target, Token, pTmpl, Context, 0, state))
StrBufAppendBufPlain(Target,
Token->Params[5]->Start,
Token->Params[5]->len,
if ((Token->nParameters < Handler->nMinArgs) ||
(Token->nParameters > Handler->nMaxArgs)) {
lprintf(1, "Handler [%s] (in '%s' line %ld); "
- "doesn't work with %ld params [%s]",
+ "doesn't work with %ld params [%s]\n",
Token->pName,
ChrPtr(pTmpl->FileName),
Token->Line,
Token->nParameters,
ChrPtr(Token->FlatToken));
+ StrBufAppendPrintf(
+ Target,
+ "<pre>\nHandler [%s] (in '%s' line %ld);"
+ " doesn't work with %ld params!\n[%s]\n</pre>\n",
+ Token->pName,
+ ChrPtr(pTmpl->FileName),
+ Token->Line,
+ Token->nParameters,
+ ChrPtr(Token->FlatToken));
}
else {
Handler->HandlerFunc(Target,
Token,
Context); /*TODO: subset of that */
-
}
}
else {
lprintf(1, "DBG: ----- loading: [%s] ------ \n",
ChrPtr(Tmpl->FileName));
pTmpl = load_template(Tmpl->FileName, NULL, NULL);
+ if(pTmpl == NULL) {
+ StrBufAppendPrintf(
+ Target,
+ "<pre>\nError loading Template [%s]\n See Logfile for details\n</pre>\n",
+ ChrPtr(Tmpl->FileName));
+ return;
+
+
+ }
+
}
pS = pData = ChrPtr(pTmpl->Data);
i++;
if ((pTmpl->Tokens[i]->Flags == SV_CONDITIONAL) ||
(pTmpl->Tokens[i]->Flags == SV_NEG_CONDITIONAL)) {
- if (state == EvaluateConditional(pTmpl->Tokens[i],
- pTmpl,
- Context,
- pTmpl->Tokens[i]->Flags,
- state))
+ if (state == EvaluateConditional(
+ Target,
+ pTmpl->Tokens[i],
+ pTmpl,
+ Context,
+ pTmpl->Tokens[i]->Flags,
+ state))
state = 0;
}
}
StaticLocal = LocalTemplateCache;
}
+ if (len == 0)
+ {
+ lprintf (1, "Can't to load a template with empty name!\n");
+ StrBufAppendPrintf(Target, "<pre>\nCan't to load a template with empty name!\n</pre>");
+ return;
+ }
+
if (!GetHash(StaticLocal, templatename, len, &vTmpl) &&
!GetHash(Static, templatename, len, &vTmpl)) {
- printf ("didn't find %s %ld %ld\n", templatename, len , (long)strlen(templatename));
+ lprintf (1, "didn't find Template [%s] %ld %ld\n", templatename, len , (long)strlen(templatename));
+ 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);
return;
d_without_ext --;
if ((d_without_ext == 0) || (d_namelen < 3))
continue;
+ if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~')
+ continue; /* Ignore backup files... */
IsMobile = (strstr(filedir_entry->d_name, ".m.html")!= NULL);
PStart = filedir_entry->d_name;
StrBufPlain(Tag, filedir_entry->d_name, MinorPtr - filedir_entry->d_name);
- printf("%s %d %s\n",ChrPtr(FileName), IsMobile, ChrPtr(Tag));
+ lprintf(1, "%s %d %s\n",ChrPtr(FileName), IsMobile, ChrPtr(Tag));
if (LoadTemplates == 0)
load_template(FileName, Tag, (IsMobile)?wireless:big);
else
typedef struct _HashIterator {
HashList *StaticList;
+ int AdditionalParams;
RetrieveHashlistFunc GetHash;
HashDestructorFunc Destructor;
SubTemplFunc DoSubTemplate;
Tokens->Params[0]->len,
&vIt))
return;
+
It = (HashIterator*) vIt;
+
+ if (Tokens->nParameters < It->AdditionalParams + 2) {
+ lprintf(1, "Iterator [%s] (in line %ld); "
+ "doesn't work with %ld params [%s]\n",
+ Tokens->Params[0]->Start,
+ Tokens->Line,
+ Tokens->nParameters,
+ ChrPtr(Tokens->FlatToken));
+ StrBufAppendPrintf(
+ Target,
+ "<pre>Iterator [%s] \n(in line %ld);\n"
+ "doesn't work with %ld params \n[%s]\n</pre>",
+ Tokens->Params[0]->Start,
+ Tokens->Line,
+ Tokens->nParameters,
+ ChrPtr(Tokens->FlatToken));
+ return;
+ }
+
if (It->StaticList == NULL)
- List = It->GetHash();
+ List = It->GetHash(Tokens);
else
List = It->StaticList;
it = GetNewHashPos();
while (GetNextHashPos(List, it, &len, &Key, &vContext)) {
svprintf(HKEY("ITERATE:ODDEVEN"), WCS_STRING, "%s", (oddeven)?"odd":"even");
- It->DoSubTemplate(SubBuf, vContext);
+ svprintf(HKEY("ITERATE:KEY"), WCS_STRING, "%s",Key);
+ It->DoSubTemplate(SubBuf, vContext, Tokens);
DoTemplate(Tokens->Params[1]->Start,
Tokens->Params[1]->len,
vContext, SubBuf);
}
void RegisterITERATOR(const char *Name, long len,
+ int AdditionalParams,
HashList *StaticList,
RetrieveHashlistFunc GetHash,
SubTemplFunc DoSubTempl,
{
HashIterator *It = (HashIterator*)malloc(sizeof(HashIterator));
It->StaticList = StaticList;
+ It->AdditionalParams = AdditionalParams;
It->GetHash = GetHash;
It->DoSubTemplate = DoSubTempl;
It->Destructor = Destructor;
/// RegisterNamespace("SERV:LDAP_SUPP", 0, 0, tmmplput_serv_ldap_enabled);
RegisterNamespace("CURRENT_USER", 0, 0, tmplput_current_user);
RegisterNamespace("CURRENT_ROOM", 0, 0, tmplput_current_room);
- RegisterNamespace("ITERATE", 2, 4, tmpl_iterate_subtmpl);
+ RegisterNamespace("ITERATE", 2, 100, tmpl_iterate_subtmpl);
RegisterNamespace("DOBOXED", 1, 2, tmpl_do_boxed);
RegisterNamespace("DOTABBED", 2, 100, tmpl_do_tabbed);
RegisterConditional(HKEY("COND:SUBST"), 3, ConditionalVar);
-typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context);
-typedef HashList *(*RetrieveHashlistFunc)(void);
+typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context, WCTemplateToken *Token);
+typedef HashList *(*RetrieveHashlistFunc)(WCTemplateToken *Token);
typedef void (*HashDestructorFunc) (HashList *KillMe);
-void RegisterITERATOR(const char *Name, long len,
+void RegisterITERATOR(const char *Name, long len,
+ int AdditionalParams,
HashList *StaticList,
RetrieveHashlistFunc GetHash,
SubTemplFunc DoSubTempl,
HashDestructorFunc Destructor);
-#define RegisterIterator(a, b, c, d, e) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e)
-
+#define RegisterIterator(a, b, c, d, e, f) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f)
/**
* \brief Values for wcs_type
StrBuf *HBuf; /**< Our HeaderBuffer */
HashList *ServCfg; /**< cache our server config for editing */
+ HashList *InetCfg; /**< Our inet server config for editing */
};
/** values for WC->current_iconbar */
terminate_session();
}
-HashList *GetWholistHash(void)
+HashList *GetWholistHash(WCTemplateToken *Token)
{
HashList *List;
char buf[SIZ];
return List;
}
-void WholistSubst(StrBuf *TemplBuffer, void *vContext)
+void WholistSubst(StrBuf *TemplBuffer, void *vContext, WCTemplateToken *Token)
{
UserStateStruct *User = (UserStateStruct*) vContext;
WebcitAddUrlHandler(HKEY("terminate_session"), _terminate_session, 0);
WebcitAddUrlHandler(HKEY("edit_me"), edit_me, 0);
- RegisterIterator("WHOLIST", NULL, GetWholistHash, WholistSubst, DeleteWholistHash);
+ RegisterIterator("WHOLIST", 0, NULL, GetWholistHash, WholistSubst, DeleteWholistHash);
}