svput("OFFER_OPENID_LOGIN", WCS_STRING, "");
}
- do_template("login");
+ do_template("login", NULL);
wDumpContent(2);
}
"Log in using a user name and password"
);
- do_template("openid_login");
+ do_template("openid_login", NULL);
wDumpContent(2);
}
svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by <a href=\"http://www.citadel.org\">Citadel</a>"),
serv_info.serv_humannode);
- do_template("openid_manual_create");
+ do_template("openid_manual_create", NULL);
wDumpContent(2);
}
output_headers(1, 1, 1, 0, 0, 0);
svput("BOXTITLE", WCS_STRING, _("Change your password"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
if (!IsEmptyStr(WC->ImportantMessage)) {
wprintf("<span class=\"errormsg\">"
wprintf("</div>\n");
wprintf("</form>\n");
- do_template("endbox");
+ do_template("endbox", NULL);
wDumpContent(1);
}
output_headers(1, 1, 1, 0, 0, 0);
svput("BOXTITLE", WCS_STRING, _("Image upload"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf("<form enctype=\"multipart/form-data\" action=\"%s\" "
"method=\"post\" name=\"graphicsupload\">\n", uplurl);
wprintf("</div>\n");
wprintf("</form>\n");
- do_template("endbox");
+ do_template("endbox", NULL);
wDumpContent(1);
}
wprintf("</td><td valign=top>");
}
svput("BOXTITLE", WCS_STRING, ic_boxtitle[which]);
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf("<span class=\"menudesc\">");
escputs(ic_desc[which]);
wprintf("</span><br />");
wprintf("</td><td align=left>"
"<input type=\"submit\" name=\"oper\" value=\"Add\">"
"</td></tr></table></form>\n");
- do_template("endbox");
+ do_template("endbox", NULL);
wprintf("<br />");
}
wprintf("</td></tr></table></div>\n");
wprintf("<table border=0 width=75%%><tr><td>");
svput("BOXTITLE", WCS_STRING, _("List subscribe/unsubscribe"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf("<div align=center><br>");
/*
}
wprintf("</div>");
- do_template("endbox");
+ do_template("endbox", NULL);
wprintf("</td></tr></table></div>");
wprintf("</BODY></HTML>\n");
"<tr><td colspan=\"2\" class=\"advanced\">\n");
svput("BOXTITLE", WCS_STRING, _("Basic commands"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
/* start of first column */
wprintf("<ul class=\"adminitems col1\">");
wprintf(" ");
- do_template("endbox");
+ do_template("endbox", NULL);
wprintf("</td></tr>"
"<tr valign=top><td width=50%%>");
serv_getln(buf, sizeof buf);
svput("BOXTITLE", WCS_STRING, _("Server command results"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf("<table border=0><tr><td>Command:</td><td><tt>");
escputs(bstr("g_cmd"));
wprintf("<hr />");
wprintf("<a href=\"display_generic\">Enter another command</a><br />\n");
wprintf("<a href=\"display_advanced\">Return to menu</a>\n");
- do_template("endbox");
+ do_template("endbox", NULL);
wDumpContent(1);
}
"body { text-decoration: none; }\n"
"</style>\n"
"</head>\n");
- do_template("background");
+ do_template("background", NULL);
}
- do_template("menubar");
+ do_template("menubar", NULL);
if (as_single_page) {
wDumpContent(2);
{
output_headers(1, 1, 1, 0, 0, 0);
svput("BOXTITLE", WCS_STRING, _("Message to your Users:"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf("<form action=\"server_shutdown\">\n"
"<input type=\"hidden\" name=\"when\" value=\"page\">\n"
"<input type=\"text\" name=\"message\" value=\"%s\">\n"
"</form>\n",
_("The citadel server has to be restarted. It 'll be back in a minute.")
);
- do_template("endbox");
+ do_template("endbox", NULL);
wDumpContent(1);
msgnum = StrTol(WC->UrlFragment1);
output_headers(1, 0, 0, 0, 0, 1);
begin_burst();
- do_template("msgcontrols");
+ do_template("msgcontrols", NULL);
read_message(msgnum,1, "");
wDumpContent(0);
}
* The following template embeds the TinyMCE richedit control, and automatically
* transforms the textarea into a richedit textarea.
*/
- do_template("richedit");
+ do_template("richedit", NULL);
/** Enumerate any attachments which are already in place... */
wprintf("<div class=\"attachment buttons\"><img src=\"static/diskette_24x.gif\" class=\"imgedit\" > ");
wprintf("<div class=\"fix_scrollbar_bug\">");
svput("BOXTITLE", WCS_STRING, _("Manage Account/OpenID Associations"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
if (serv_info.serv_supports_openid) {
wprintf(_("%s does not permit authentication via OpenID."), serv_info.serv_humannode);
}
- do_template("endbox");
+ do_template("endbox", NULL);
wprintf("</div>");
wDumpContent(2);
}
* output by begin_ajax_response() happen to be the ones we need.)
*/
begin_ajax_response();
- do_template("chatframeset");
+ do_template("chatframeset", NULL);
end_ajax_response();
return;
}
#define PRF_QP_STRING 3
#define PRF_YESNO 4
+
+void tmplput_CFG_Value(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context)
+{
+ StrBuf *Setting;
+ if (get_PREFERENCE(Token->Params[0]->Start,
+ Token->Params[0]->len,
+ &Setting))
+ StrBufAppendBuf(Target, Setting, 0);
+}
+
+void tmplput_CFG_Descr(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context)
+{
+ const char *SettingStr;
+ SettingStr = PrefGetLocalStr(Token->Params[0]->Start,
+ Token->Params[0]->len);
+ if (SettingStr != NULL)
+ StrBufAppendBufPlain(Target, SettingStr, -1, 0);
+}
+
+
+
void
InitModule_PREFERENCES
(void)
RegisterPreference("signature",_("Use this signature:"),PRF_QP_STRING);
RegisterPreference("default_header_charset", _("Default character set for email headers:") ,PRF_STRING);
RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO);
+
+ RegisterNS(HKEY("PREF:VALUE"), 1, 1, tmplput_CFG_Value);
+ RegisterNS(HKEY("PREF:DESCR"), 1, 1, tmplput_CFG_Descr);
}
/*@}*/
serv_printf("GOTO %s", WC->wc_roomname);
serv_getln(buf, sizeof buf);
}
-output_headers(1, 1, 2, 0, 0, 0);
-do_template("pushemail");
+ output_headers(1, 1, 2, 0, 0, 0);
+ do_template("pushemail", NULL);
//do_template("endbox");
-wDumpContent(1);
+ wDumpContent(1);
}
void save_pushemail(void) {
output_headers(1, 1, 1, 0, 0, 0);
svput("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
listrms("LZRM -1");
wprintf("<br /><br />\n");
wprintf(_("Click on any room to un-zap it and goto that room.\n"));
- do_template("endbox");
+ do_template("endbox", NULL);
wDumpContent(1);
}
svcallback("SEARCHOMATIC", embed_search_o_matic);
svcallback("START", offer_start_page);
- do_template("roombanner");
+ do_template("roombanner", NULL);
// roombanner contains this for mobile
if (navbar_style != navbar_none && !WC->is_mobile) {
output_headers(1, 1, 1, 0, 0, 0);
svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
fmout("LEFT");
}
- do_template("endbox");
+ do_template("endbox", NULL);
wDumpContent(1);
}
output_headers(1, 1, 1, 0, 0, 0);
svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Go to a hidden room"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf("<p>");
wprintf(_("If you know the name of a hidden (guess-name) or "
);
wprintf("</div></form>\n");
- do_template("endbox");
+ do_template("endbox", NULL);
wDumpContent(1);
}
if ( (strcasecmp(floor_name, old_floor_name))
&& (!IsEmptyStr(old_floor_name)) ) {
/* End inner box */
- do_template("endbox");
+ do_template("endbox", NULL);
wprintf("<br>");
++num_boxes;
/** Begin inner box */
stresc(boxtitle, 256, floor_name, 1, 0);
svprintf(HKEY("BOXTITLE"), WCS_STRING, boxtitle);
- do_template("beginbox");
+ do_template("beginbox", NULL);
}
oldlevels = levels;
}
}
/** End the final inner box */
- do_template("endbox");
+ do_template("endbox", NULL);
wprintf("</td></tr></table>\n");
}
svput("822_PUB_DATE", WCS_STRING, date);
}
svput("GENERATOR", WCS_STRING, PACKAGE_STRING);
- do_template("rss_head");
+ do_template("rss_head", NULL);
/** Read all messages and output as RSS items */
for (a = 0; a < nummsgs; ++a) {
svprintf(HKEY("822_PUB_DATE"),WCS_STRING, _("%s"), date);
}
svprintf(HKEY("GUID"), WCS_STRING,"%s", msgn);
- do_template("rss_item");
+ do_template("rss_item", NULL);
/** Now the hard part, the message itself */
strcpy(content_type, "text/plain");
while (serv_getln(buf, sizeof buf), !IsEmptyStr(buf)) {
ENDBODY:
//wprintf(" </item>\n");
- do_template("rss_item_end");
+ do_template("rss_item_end", NULL);
ENDITEM:
now = 0L;
}
wprintf("<table border=0 cellspacing=10><tr valign=top><td>\n");
svput("BOXTITLE", WCS_STRING, _("Add a new script"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf(_("To create a new script, enter the desired "
"script name in the box below and click 'Create'."));
"<input type=\"submit\" name=\"create_button\" value=\"%s\">"
"</form></center>\n", _("Create"));
- do_template("endbox");
+ do_template("endbox", NULL);
svput("BOXTITLE", WCS_STRING, _("Edit scripts"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf("<br /><div align=center><a href=\"display_sieve\">%s</a><br /><br />\n",
_("Return to the script editing screen")
);
- do_template("endbox");
+ do_template("endbox", NULL);
wprintf("</td><td>");
svput("BOXTITLE", WCS_STRING, _("Delete scripts"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf(_("To delete an existing script, select the script "
"name from the list and click 'Delete'."));
wprintf("<input type=\"submit\" name=\"delete_button\" value=\"%s\" "
"onClick=\"return confirm('%s');\">", _("Delete script"), _("Delete this script?"));
wprintf("</form></center>\n");
- do_template("endbox");
+ do_template("endbox", NULL);
wprintf("</td></tr></table>\n");
/*if (WCC->vars != NULL) PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
if (keyname[0] == '=') {
- DoTemplate(keyname+1, keylen - 1);
+ DoTemplate(keyname+1, keylen - 1, NULL);
}
/** Page-local variables */
if ((WCC->vars!= NULL) && GetHash(WCC->vars, keyname, keylen, &vVar)) {
free(FreeMe);
}
-void EvaluateToken(StrBuf *Target, WCTemplateToken *Token)
+void EvaluateToken(StrBuf *Target, WCTemplateToken *Token, void *Context)
{
void *vVar;
// much output, since pName is not terminated...
else {
Handler->HandlerFunc(Target,
Token->nParameters,
- &Token); /*TODO: subset of that */
+ Token,
+ Context); /*TODO: subset of that */
}
}
}
-void ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target)
+void ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, void *Context)
{
int done = 0;
int i;
StrBufAppendBufPlain(
Target, pData,
Tmpl->Tokens[i]->pTokenStart - pData, 0);
- EvaluateToken(Target, Tmpl->Tokens[i]);
+ EvaluateToken(Target, Tmpl->Tokens[i], Context);
pData = Tmpl->Tokens[i++]->pTokenEnd + 1;
}
}
* \brief Display a variable-substituted template
* \param templatename template file to load
*/
-void DoTemplate(const char *templatename, long len)
+void DoTemplate(const char *templatename, long len, void *Context)
{
HashList *Static;
HashList *StaticLocal;
}
if (vTmpl == NULL)
return;
- ProcessTemplate(vTmpl, WC->WBuf);
+ ProcessTemplate(vTmpl, WC->WBuf, Context);
}
int LoadTemplateDir(const char *DirName, HashList *wireless, HashList *big)
LocalTemplateCache);
}
-void tmplput_serv_ip(StrBuf *Target, int nArgs, WCTemplateToken **Tokens)
+void tmplput_serv_ip(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
{
StrBufAppendPrintf(Target, "%d", WC->ctdl_pid);
}
-void tmplput_serv_nodename(StrBuf *Target, int nArgs, WCTemplateToken **Tokens)
+void tmplput_serv_nodename(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
{
escputs(serv_info.serv_nodename); ////TODO: respcect Target
}
-void tmplput_serv_humannode(StrBuf *Target, int nArgs, WCTemplateToken **Tokens)
+void tmplput_serv_humannode(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
{
escputs(serv_info.serv_humannode);////TODO: respcect Target
}
-void tmplput_serv_fqdn(StrBuf *Target, int nArgs, WCTemplateToken **Tokens)
+void tmplput_serv_fqdn(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
{
escputs(serv_info.serv_fqdn);////TODO: respcect Target
}
-void tmmplput_serv_software(StrBuf *Target, int nArgs, WCTemplateToken **Tokens)
+void tmmplput_serv_software(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
{
escputs(serv_info.serv_software);////TODO: respcect Target
}
-void tmplput_serv_rev_level(StrBuf *Target, int nArgs, WCTemplateToken **Tokens)
+void tmplput_serv_rev_level(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
{
StrBufAppendPrintf(Target, "%d.%02d",
serv_info.serv_rev_level / 100,
serv_info.serv_rev_level % 100);
}
-void tmmplput_serv_bbs_city(StrBuf *Target, int nArgs, WCTemplateToken **Tokens)
+void tmmplput_serv_bbs_city(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
{
escputs(serv_info.serv_bbs_city);////TODO: respcect Target
}
-void tmplput_current_user(StrBuf *Target, int nArgs, WCTemplateToken **Tokens)
+void tmplput_current_user(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
{
escputs(WC->wc_fullname);////TODO: respcect Target
}
-void tmplput_current_room(StrBuf *Target, int nArgs, WCTemplateToken **Tokens)
+void tmplput_current_room(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context)
{
escputs(WC->wc_roomname);////TODO: respcect Target
}
*/
void dummy_section(void) {
svput("BOXTITLE", WCS_STRING, "(dummy section)");
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf(_("(nothing)"));
- do_template("endbox");
+ do_template("endbox", NULL);
}
}
svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Edit %s"), description);
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf(_("Enter %s below. Text is formatted to the reader's browser."
" A newline is forced by preceding the next line by a blank."), description);
wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br />\n", _("Cancel"));
wprintf("</div></form>\n");
- do_template("endbox");
+ do_template("endbox", NULL);
wDumpContent(1);
}
wprintf("<table border=0 cellspacing=10><tr valign=top><td>\n");
svput("BOXTITLE", WCS_STRING, _("Add users"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf(_("To create a new user account, enter the desired "
"user name in the box below and click 'Create'."));
"<input type=\"submit\" name=\"create_button\" value=\"%s\">"
"</form></center>\n", _("Create"));
- do_template("endbox");
+ do_template("endbox", NULL);
wprintf("</td><td>");
svput("BOXTITLE", WCS_STRING, _("Edit or Delete users"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf(_("To edit an existing user account, select the user "
"name from the list and click 'Edit'."));
wprintf("<input type=\"submit\" name=\"delete_button\" value=\"%s\" "
"onClick=\"return confirm('%s');\">", _("Delete user"), _("Delete this user?"));
wprintf("</form></center>\n");
- do_template("endbox");
+ do_template("endbox", NULL);
wprintf("</td></tr></table>\n");
output_headers(1, 1, 1, 0, 0, 0);
svput("BOXTITLE", WCS_STRING, _("Edit contact information"));
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf("<form method=\"POST\" action=\"submit_vcard\">\n");
wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
);
wprintf("</td></tr></table>\n");
- do_template("endbox");
+ do_template("endbox", NULL);
wDumpContent(1);
}
{
if (print_standard_html_footer) {
wprintf("</div>\n"); /* end of "text" div */
- do_template("trailing");
+ do_template("trailing", NULL);
}
/* If we've been saving it all up for one big output burst,
"<link href=\"static.local/webcit.css\" rel=\"stylesheet\" type=\"text/css\">"
);
}
- do_template("head");
+ do_template("head", NULL);
}
/* ICONBAR */
long i;
svput("BOXTITLE", WCS_STRING, Title);
- do_template("beginbox");
+ do_template("beginbox", NULL);
wprintf("<ul class=\"%s\">", Class);
wprintf("</ul>");
- do_template("endbox");
+ do_template("endbox", NULL);
}
* A template has been requested
*/
void url_do_template(void) {
- do_template(bstr("template"));
+ do_template(bstr("template"), NULL);
}
set_preference("startpage", NewStrBufPlain(bstr("startpage"), -1), 1);
output_headers(1, 1, 0, 0, 0, 0);
- do_template("newstartpage");
+ do_template("newstartpage", NULL);
wDumpContent(1);
}
TemplateParam *Params[MAXPARAM];
} WCTemplateToken;
-typedef void (*WCHandlerFunc)(StrBuf *Target, int nArgs, WCTemplateToken **Tokens);
+typedef void (*WCHandlerFunc)(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context);
+
+void RegisterNS(const char *NSName, long len, int nMinArgs, int nMaxArgs, WCHandlerFunc HandlerFunc);
/**
* \brief Values for wcs_type
void SVCallback(char *keyname, size_t keylen, var_callback_fptr fcn_ptr);
#define svcallback(a, b) SVCallback(a, sizeof(a) - 1, b)
-void DoTemplate(const char *templatename, long len);
-#define do_template(a) DoTemplate(a, sizeof(a) -1);
+void DoTemplate(const char *templatename, long len, void *Context);
+#define do_template(a, b) DoTemplate(a, sizeof(a) -1, b);
int lingering_close(int fd);