* move the default template params to a standard structure, so adding further controll structures here gets more easy
* move some cases to GetServerStatus() to evaluate the server status feedback to queries.
wprintf("<option value=\"__LOCAL_USERS__\" %s>",
(strcmp(ChrPtr(DefAddrBook), "__LOCAL_USERS__") == 0)?
"selected=\"selected\" ":"");
- escputs(serv_info.serv_humannode);
+ escputs(ChrPtr(serv_info.serv_humannode));
wprintf("</option>\n");
HashList *List;
HashPos *it;
int i;
- char saved_roomname[128];
+ StrBuf *saved_roomname;
begin_ajax_response();
else {
set_room_pref("defaddrbook",NewStrBufDup(sbstr("which_addr_book")), 0);
- safestrncpy(saved_roomname, WC->wc_roomname, sizeof saved_roomname);
- gotoroom(bstr("which_addr_book"));
+ saved_roomname = NewStrBufDup(WC->wc_roomname);
+ gotoroom(sbstr("which_addr_book"));
serv_puts("DVCA");
serv_getln(buf, sizeof buf);
if (buf[0] == '1') while(len = serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
DeleteHashPos(&it);
DeleteHash(&List);
gotoroom(saved_roomname);
+ FreeStrBuf(&saved_roomname);
}
wprintf("</select>\n");
}
-void display_openid_name_request(char *claimed_id, char *username) {
- char buf[SIZ];
+void display_openid_name_request(const StrBuf *claimed_id, const StrBuf *username)
+{
+ StrBuf *Buf = NULL;
output_headers(1, 1, 2, 0, 0, 0);
wprintf("<div id=\"login_screen\">\n");
- stresc(buf, sizeof buf, claimed_id, 0, 0);
+ Buf = NewStrBufPlain(NULL, StrLength(claimed_id));
+ StrEscAppend(Buf, claimed_id, NULL, 0, 0);
svprintf(HKEY("VERIFIED"), WCS_STRING, _("Your OpenID <tt>%s</tt> was successfully verified."),
- claimed_id);
- svput("CLAIMED_ID", WCS_STRING, claimed_id);
+ ChrPtr(Buf));
+ SVPutBuf("CLAIMED_ID", Buf, 0);
- if (!IsEmptyStr(username)) {
- stresc(buf, sizeof buf, username, 0, 0);
- svprintf(HKEY("REASON"), WCS_STRING,
- _("However, the user name '%s' conflicts with an existing user."), username);
+ if (StrLength(username) > 0) {
+ Buf = NewStrBufPlain(NULL, StrLength(username));
+ StrEscAppend(Buf, claimed_id, NULL, 0, 0);
+ svprintf(HKEY("REASON"), WCS_STRING,
+ _("However, the user name '%s' conflicts with an existing user."),
+ ChrPtr(Buf));
+ FreeStrBuf(&Buf);
}
else {
svput("REASON", WCS_STRING, "");
svput("EXIT_BUTTON", WCS_STRING, _("Exit"));
svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by <a href=\"http://www.citadel.org\">Citadel</a>"),
- serv_info.serv_humannode);
+ ChrPtr(serv_info.serv_humannode));
do_template("openid_manual_create", NULL);
wDumpContent(2);
* pass his password
* serv_response The parameters returned from a Citadel USER or NEWU command
*/
-void become_logged_in(char *user, char *pass, char *serv_response)
+void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_response)
{
+ wcsession *WCC = WC;
char buf[SIZ];
StrBuf *FloorDiv;
WC->logged_in = 1;
- extract_token(WC->wc_fullname, &serv_response[4], 0, '|', sizeof WC->wc_fullname);
- safestrncpy(WC->wc_username, user, sizeof WC->wc_username);
- safestrncpy(WC->wc_password, pass, sizeof WC->wc_password);
- WC->axlevel = extract_int(&serv_response[4], 1);
- if (WC->axlevel >= 6) {
- WC->is_aide = 1;
+
+ if (WCC->wc_fullname == NULL)
+ WCC->wc_fullname = NewStrBufPlain(NULL, StrLength(serv_response));
+ StrBufExtract_token(WCC->wc_fullname, serv_response, 0, '|');
+ StrBufCutLeft(WCC->wc_fullname, 4 );
+
+ if (WCC->wc_username == NULL)
+ WCC->wc_username = NewStrBufDup(user);
+ else {
+ FlushStrBuf(WCC->wc_username);
+ StrBufAppendBuf(WCC->wc_username, user, 0);
+ }
+
+ if (WCC->wc_password == NULL)
+ WCC->wc_password = NewStrBufDup(pass);
+ else {
+ FlushStrBuf(WCC->wc_password);
+ StrBufAppendBuf(WCC->wc_password, pass, 0);
+ }
+
+ WCC->axlevel = StrBufExtract_int(serv_response, 1, '|');
+ if (WCC->axlevel >= 6) { /* TODO: make this a define, else it might trick us later */
+ WCC->is_aide = 1;
}
load_preferences();
void do_login(void)
{
wcsession *WCC = WC;
- char buf[SIZ];
+ StrBuf *Buf;
if (havebstr("language")) {
set_selected_language(bstr("language"));
do_logout();
return;
}
+ Buf = NewStrBuf();
if (havebstr("login_action")) {
serv_printf("USER %s", bstr("name"));
- serv_getln(buf, sizeof buf);
- if (buf[0] == '3') {
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 3) {
serv_printf("PASS %s", bstr("pass"));
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
- become_logged_in(bstr("name"), bstr("pass"), buf);
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ become_logged_in(sbstr("name"), sbstr("pass"), Buf);
} else {
snprintf(WCC->ImportantMessage,
sizeof (WCC->ImportantMessage),
"%s",
- &buf[4]);
+ &(ChrPtr(Buf))[4]);
display_login();
+ FreeStrBuf(&Buf);
return;
}
} else {
snprintf(WCC->ImportantMessage,
sizeof (WCC->ImportantMessage),
"%s",
- &buf[4]);
+ &(ChrPtr(Buf))[4]);
display_login();
+ FreeStrBuf(&Buf);
return;
}
}
"%s",
_("Blank passwords are not allowed."));
display_login();
+ FreeStrBuf(&Buf);
return;
}
serv_printf("NEWU %s", bstr("name"));
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
- become_logged_in(bstr("name"), bstr("pass"), buf);
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ become_logged_in(sbstr("name"), sbstr("pass"), Buf);
serv_printf("SETP %s", bstr("pass"));
- serv_getln(buf, sizeof buf);
+ StrBuf_ServGetln(Buf); /* Don't care? */
} else {
snprintf(WCC->ImportantMessage,
sizeof (WCC->ImportantMessage),
"%s",
- &buf[4]);
+ &(ChrPtr(Buf))[4]);
display_login();
+ FreeStrBuf(&Buf);
return;
}
}
_("Your password was not accepted."));
display_login();
}
-
+ FreeStrBuf(&Buf);
}
/*
*/
void openid_manual_create(void)
{
- char buf[1024];
+ StrBuf *Buf;
if (havebstr("exit_action")) {
do_logout();
}
if (havebstr("newuser_action")) {
+ Buf = NewStrBuf();
serv_printf("OIDC %s", bstr("name"));
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
- char gpass[1024] = "";
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ StrBuf *gpass;
+
+ gpass = NewStrBuf();
serv_puts("SETP GENERATE_RANDOM_PASSWORD");
- serv_getln(gpass, sizeof gpass);
- become_logged_in(bstr("name"), &gpass[4], buf);
+ StrBuf_ServGetln(gpass);
+ StrBufCutLeft(gpass, 4);
+ become_logged_in(sbstr("name"), gpass, Buf);
+ FreeStrBuf(&gpass);
}
+ FreeStrBuf(&Buf);
}
if (WC->logged_in) {
do_welcome();
}
} else {
- display_openid_name_request(bstr("openid_url"), bstr("name"));
+ display_openid_name_request(sbstr("openid_url"), sbstr("name"));
}
}
*/
void finalize_openid_login(void)
{
- char buf[1024];
+ StrBuf *Buf;
wcsession *WCC = WC;
int already_logged_in = (WCC->logged_in) ;
int linecount = 0;
- char result[128] = "";
- char username[128] = "";
- char password[128] = "";
- char logged_in_response[1024] = "";
- char claimed_id[1024] = "";
+ StrBuf *result = NULL;
+ StrBuf *username = NULL;
+ StrBuf *password = NULL;
+ StrBuf *logged_in_response = NULL;
+ StrBuf *claimed_id = NULL;
if (havebstr("openid.mode")) {
if (!strcasecmp(bstr("openid.mode"), "id_res")) {
-
+ Buf = NewStrBuf();
serv_puts("OIDF");
- serv_getln(buf, sizeof buf);
-
- if (buf[0] == '8') {
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 8) {
urlcontent *u;
void *U;
long HKLen;
serv_puts("000");
linecount = 0;
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- if (linecount == 0) safestrncpy(result, buf, sizeof result);
- if (!strcasecmp(result, "authenticate")) {
+ while (StrBuf_ServGetln(Buf),
+ (StrLength(Buf)==3) &&
+ !strcmp(ChrPtr(Buf), "000"))
+ {
+ if (linecount == 0) result = NewStrBufDup(Buf);
+ if (!strcasecmp(ChrPtr(result), "authenticate")) {
if (linecount == 1) {
- safestrncpy(username, buf, sizeof username);
+ username = NewStrBufDup(Buf);
}
else if (linecount == 2) {
- safestrncpy(password, buf, sizeof password);
+ password = NewStrBufDup(Buf);
}
else if (linecount == 3) {
- safestrncpy(logged_in_response, buf,
- sizeof logged_in_response);
+ logged_in_response = NewStrBufDup(Buf);
}
}
- else if (!strcasecmp(result, "verify_only")) {
+ else if (!strcasecmp(ChrPtr(result), "verify_only")) {
if (linecount == 1) {
- safestrncpy(claimed_id, buf, sizeof claimed_id);
+ claimed_id = NewStrBufDup(Buf);
}
if (linecount == 2) {
- safestrncpy(username, buf, sizeof username);
+ username = NewStrBufDup(Buf);
}
}
++linecount;
}
}
+ FreeStrBuf(&Buf);
}
}
/* If we were already logged in, this was an attempt to associate an OpenID account */
if (already_logged_in) {
display_openids();
+ FreeStrBuf(&result);
+ FreeStrBuf(&username);
+ FreeStrBuf(&password);
+ FreeStrBuf(&claimed_id);
+ FreeStrBuf(&logged_in_response);
return;
}
/* If this operation logged us in, either by connecting with an existing account or by
* auto-creating one using Simple Registration Extension, we're already on our way.
*/
- if (!strcasecmp(result, "authenticate")) {
+ if (!strcasecmp(ChrPtr(result), "authenticate")) {
become_logged_in(username, password, logged_in_response);
}
* or conflicts with an existing user. Either way the user will need to specify a new name.
*/
- else if (!strcasecmp(result, "verify_only")) {
+ else if (!strcasecmp(ChrPtr(result), "verify_only")) {
display_openid_name_request(claimed_id, username);
}
display_openid_login(_("Your password was not accepted."));
}
+ FreeStrBuf(&result);
+ FreeStrBuf(&username);
+ FreeStrBuf(&password);
+ FreeStrBuf(&claimed_id);
+ FreeStrBuf(&logged_in_response);
}
{
char buf[SIZ];
- safestrncpy(WC->wc_username, "", sizeof WC->wc_username);
- safestrncpy(WC->wc_password, "", sizeof WC->wc_password);
- safestrncpy(WC->wc_roomname, "", sizeof WC->wc_roomname);
- safestrncpy(WC->wc_fullname, "", sizeof WC->wc_fullname);
+ FlushStrBuf(WC->wc_username);
+ FlushStrBuf(WC->wc_password);
+ FlushStrBuf(WC->wc_roomname);
+ FlushStrBuf(WC->wc_fullname);
/** Calling output_headers() this way causes the cookies to be un-set */
output_headers(1, 1, 0, 1, 0, 0);
*/
void display_changepw(void)
{
+ WCTemplputParams SubTP;
char buf[SIZ];
StrBuf *Buf;
output_headers(1, 1, 1, 0, 0, 0);
Buf = NewStrBufPlain(_("Change your password"), -1);
- DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_STRBUF;
+ SubTP.Context = Buf;
+ DoTemplate(HKEY("beginbox"), NULL, &SubTP);
FreeStrBuf(&Buf);
serv_getln(buf, sizeof buf);
sprintf(WC->ImportantMessage, "%s", &buf[4]);
if (buf[0] == '2') {
- safestrncpy(WC->wc_password, buf, sizeof WC->wc_password);
+ if (WC->wc_password == NULL)
+ WC->wc_password = NewStrBufPlain(buf, -1);
+ else {
+ FlushStrBuf(WC->wc_password);
+ StrBufAppendBufPlain(WC->wc_password, buf, -1, 0);
+ }
display_main_menu();
}
else {
}
}
-int ConditionalAide(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalAide(StrBuf *Target, WCTemplputParams *TP)
{
return (WC->is_aide == 0);
}
-int ConditionalRoomAide(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
{
return (WC->is_room_aide == 0);
}
-int ConditionalRoomAcessDelete(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
return ( (WCC->is_room_aide) || (WCC->is_mailbox) || (WCC->room_flags2 & QR2_COLLABDEL) );
/* Force change the room if we have to */
if (havebstr("taskrm")) {
- gotoroom((char *)bstr("taskrm"));
+ gotoroom(sbstr("taskrm"));
}
msgnum = lbstr("msgnum");
"?gotofirst=",
Cal->cal_msgnum
);
- escputs(WCC->wc_roomname);
+ escputs(ChrPtr(WCC->wc_roomname));
wprintf("\">");
}
else {
today_tm.tm_mon + 1,
today_tm.tm_mday
);
- escputs(WCC->wc_roomname);
+ escputs(ChrPtr(WCC->wc_roomname));
wprintf("\">");
}
escputs((char *) icalproperty_get_comment(p));
p = icalcomponent_get_first_property(Cal->cal,
ICAL_SUMMARY_PROPERTY);
wprintf("<a href=\"display_edit_task?msgnum=%ld?taskrm=", Cal->cal_msgnum);
- urlescputs(WC->wc_roomname);
+ urlescputs(ChrPtr(WC->wc_roomname));
wprintf("\">");
/* wprintf("<img align=middle "
"src=\"static/taskmanag_16x.gif\" border=0> "); */
FreeStrBuf(&((*sessions_to_kill)->WBuf));
FreeStrBuf(&((*sessions_to_kill)->HBuf));
FreeStrBuf(&((*sessions_to_kill)->CLineBuf));
+ FreeStrBuf(&((*sessions_to_kill)->wc_username));
+ FreeStrBuf(&((*sessions_to_kill)->wc_fullname));
+ FreeStrBuf(&((*sessions_to_kill)->wc_password));
+ FreeStrBuf(&((*sessions_to_kill)->wc_roomname));
+ FreeStrBuf(&((*sessions_to_kill)->httpauth_user));
+ FreeStrBuf(&((*sessions_to_kill)->httpauth_pass));
free((*sessions_to_kill));
(*sessions_to_kill) = NULL;
}
if (GetHash(HTTPHeaders, HKEY("COOKIE"), &vLine) &&
(vLine != NULL)) {
cookie_to_stuff(vLine, &desired_session,
- NULL, 0, NULL, 0, NULL, 0);
+ NULL, NULL, NULL);
got_cookie = 1;
}
/** If HTTP-AUTH, look for a session with matching credentials */
if ( (!IsEmptyStr(httpauth_user))
- &&(!strcasecmp(sptr->httpauth_user, httpauth_user))
- &&(!strcasecmp(sptr->httpauth_pass, httpauth_pass)) ) {
+ &&(!strcasecmp(ChrPtr(sptr->httpauth_user), httpauth_user))
+ &&(!strcasecmp(ChrPtr(sptr->httpauth_pass), httpauth_pass)) ) {
TheSession = sptr;
}
TheSession->wc_session = desired_session;
}
- strcpy(TheSession->httpauth_user, httpauth_user);
- strcpy(TheSession->httpauth_pass, httpauth_pass);
+ if (TheSession->httpauth_user != NULL){
+ FlushStrBuf(TheSession->httpauth_user);
+ StrBufAppendBufPlain(TheSession->httpauth_user, httpauth_user, -1, 0);
+ }
+ else TheSession->httpauth_user = NewStrBufPlain(httpauth_user, -1);
+ if (TheSession->httpauth_user != NULL){
+ FlushStrBuf(TheSession->httpauth_pass);
+ StrBufAppendBufPlain(TheSession->httpauth_pass, httpauth_user, -1, 0);
+ }
+ else TheSession->httpauth_pass = NewStrBufPlain(httpauth_user, -1);
+
TheSession->hash_prefs = NewHash(1,NULL); /* Get a hash table for the user preferences */
pthread_mutex_init(&TheSession->SessionMutex, NULL);
pthread_mutex_lock(&SessionListMutex);
}
-void tmpl_nonce(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_nonce(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
StrBufAppendPrintf(Target, "%ld",
(WCC != NULL)? WCC->nonce:0);
}
+void tmplput_current_user(StrBuf *Target, WCTemplputParams *TP)
+{
+ StrBufAppendTemplate(Target, TP, WC->wc_fullname, 0);
+}
+
+void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
+{
+ StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
+}
+
+
+
void
InitModule_CONTEXT
(void)
{
- RegisterNamespace("NONCE", 0, 0, tmpl_nonce, 0);
+ RegisterNamespace("CURRENT_USER", 0, 1, tmplput_current_user, CTX_NONE);
+ RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, CTX_NONE);
+ RegisterNamespace("NONCE", 0, 0, tmplput_nonce, 0);
}
* \param room the room he wants to enter
*/
void stuff_to_cookie(char *cookie, size_t clen, int session,
- char *user, char *pass, char *room)
+ StrBuf *user, StrBuf *pass, StrBuf *room)
{
char buf[SIZ];
int i;
int len;
- len = snprintf(buf, SIZ, "%d|%s|%s|%s|", session, user, pass, room);
+ len = snprintf(buf, SIZ, "%d|%s|%s|%s|",
+ session,
+ ChrPtr(user),
+ ChrPtr(pass),
+ ChrPtr(room));
+
strcpy(cookie, "");
for (i=0; (i < len) && (i * 2 < clen); ++i) {
snprintf(&cookie[i*2], clen - i * 2, "%02X", buf[i]);
* \param room_len the length of the room string
*/
void cookie_to_stuff(StrBuf *cookie, int *session,
- char *user, size_t user_len,
- char *pass, size_t pass_len,
- char *room, size_t room_len)
+ StrBuf *user,
+ StrBuf *pass,
+ StrBuf *room)
{
const char *pch;
char buf[SIZ];
+ StrBuf *Buf;
int i, len;
pch = strstr(ChrPtr(cookie), "webcit=");
buf[i] = xtoi(&pch[i*2], 2);
buf[i+1] = 0;
}
+ Buf = NewStrBufPlain(buf, i);
/* debug
char t[256];
debug */
if (session != NULL)
- *session = extract_int(buf, 0);
+ *session = StrBufExtract_int(Buf, 0, '|');
if (user != NULL)
- extract_token(user, buf, 1, '|', user_len);
+ StrBufExtract_token(user, Buf, 1, '|');
if (pass != NULL)
- extract_token(pass, buf, 2, '|', pass_len);
+ StrBufExtract_token(pass, Buf, 2, '|');
if (room != NULL)
- extract_token(room, buf, 3, '|', room_len);
+ StrBufExtract_token(room, Buf, 3, '|');
+ FreeStrBuf(&Buf);
}
/*@}*/
}
/* -------------------------------------------------------------------------------- */
-void tmplput_FILE_NAME(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_FILE_NAME(StrBuf *Target, WCTemplputParams *TP)
{
- FileListStruct *F = (FileListStruct*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, F->Filename, 0);
+ FileListStruct *F = (FileListStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, F->Filename, 0);
}
-void tmplput_FILE_SIZE(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_FILE_SIZE(StrBuf *Target, WCTemplputParams *TP)
{
- FileListStruct *F = (FileListStruct*) Context;
+ FileListStruct *F = (FileListStruct*) CTX;
StrBufAppendPrintf(Target, "%ld", F->FileSize);
}
-void tmplput_FILEMIMETYPE(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_FILEMIMETYPE(StrBuf *Target, WCTemplputParams *TP)
{
- FileListStruct *F = (FileListStruct*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, F->MimeType, 0);
+ FileListStruct *F = (FileListStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, F->MimeType, 0);
}
-void tmplput_FILE_COMMENT(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_FILE_COMMENT(StrBuf *Target, WCTemplputParams *TP)
{
- FileListStruct *F = (FileListStruct*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, F->Comment, 0);
+ FileListStruct *F = (FileListStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, F->Comment, 0);
}
/* -------------------------------------------------------------------------------- */
-int Conditional_FILE_ISPIC(WCTemplateToken *Tokens, void *Context, int ContextType)
+int Conditional_FILE_ISPIC(StrBuf *Target, WCTemplputParams *TP)
{
- FileListStruct *F = (FileListStruct*) Context;
+ FileListStruct *F = (FileListStruct*) CTX;
return F->IsPic;
}
}
/* -------------------------------------------------------------------------------- */
-HashList* LoadFileList(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList* LoadFileList(StrBuf *Target, WCTemplputParams *TP)
{
FileListStruct *Entry;
StrBuf *Buf;
char buf[1024];
CompareFunc SortIt;
int HavePic;
+ WCTemplputParams SubTP;
+ memset(&TP, 0, sizeof(WCTemplputParams));
serv_puts("RDIR");
serv_getln(buf, sizeof buf);
if (buf[0] != '1') return NULL;
}
Put(Files, SKEY(Entry->Filename), Entry, FreeFiles);
}
- SortIt = RetrieveSort(CTX_FILELIST, NULL, HKEY("fileunsorted"), 0);
+ SubTP.ContextType = CTX_FILELIST;
+ SortIt = RetrieveSort(&SubTP, NULL, HKEY("fileunsorted"), 0);
if (SortIt != NULL)
SortByPayload(Files, SortIt);
else
StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
- if (ChrPtr(Buf)[0] == '2') {
+ if (GetServerStatus(Buf, NULL) == 2) {
StrBufPlain(Buf, _("Floor has been deleted."),-1);
}
else {
serv_printf("CFLR %s|1", bstr("floorname"));
StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
- if (ChrPtr(Buf)[0] == '2') {
+ if (GetServerStatus(Buf, NULL) == 2) {
StrBufPlain(Buf, _("New floor has been created."),-1);
}
else {
* depending on the browser locale change the sequence of the
* language chooser.
*/
-void tmplput_offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) {
+void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
+{
int i;
#ifndef HAVE_USELOCALE
char *Lang = getenv("LANG");
#else /* ENABLE_NLS */
/** \brief dummy for non NLS enabled systems */
-void tmplput_offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) {
+void tmplput_offer_languages(StrBuf *Target, WCTemplputParams *TP)
+{
wprintf("English (US)");
}
#endif /* ENABLE_NLS */
-void TmplGettext(StrBuf *Target, int nTokens, WCTemplateToken *Tokens)
+void TmplGettext(StrBuf *Target, WCTemplputParams *TP)
{
- StrBufAppendBufPlain(Target, _(Tokens->Params[0]->Start), -1, 0);
+ StrBufAppendBufPlain(Target, _(TP->Tokens->Params[0]->Start), -1, 0);
}
void display_graphics_upload(char *description, char *filename, char *uplurl)
{
+ WCTemplputParams SubTP;
StrBuf *Buf;
char buf[SIZ];
output_headers(1, 1, 1, 0, 0, 0);
Buf = NewStrBufPlain(_("Image upload"), -1);
- DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_STRBUF;
+ SubTP.Context = Buf;
+ DoTemplate(HKEY("beginbox"), NULL, &SubTP);
FreeStrBuf(&Buf);
int dav_content_length,
StrBuf *dav_content,
int Offset);
-void groupdav_get(const char *dav_pathname);
-void groupdav_put(const char *dav_pathname, char *dav_ifmatch,
+void groupdav_get(StrBuf *dav_pathname);
+void groupdav_put(StrBuf *dav_pathname, char *dav_ifmatch,
const char *dav_content_type, StrBuf *dav_content,
int offset);
void groupdav_delete(StrBuf *dav_pathname, char *dav_ifmatch);
-void groupdav_propfind(const char *dav_pathname, int dav_depth, StrBuf *dav_content_type, StrBuf *dav_content, int offset);
-void groupdav_options(const char *dav_pathname);
-long locate_message_by_uid(char *);
+void groupdav_propfind(StrBuf *dav_pathname, int dav_depth, StrBuf *dav_content_type, StrBuf *dav_content, int offset);
+void groupdav_options(StrBuf *dav_pathname);
+long locate_message_by_uid(const char *);
void groupdav_folder_list(void);
-void euid_escapize(char *, char *);
-void euid_unescapize(char *, char *);
+void euid_escapize(char *, const char *);
+void euid_unescapize(char *, const char *);
void groupdav_identify_host(void);
* The pathname is always going to be /groupdav/room_name/euid
*/
void groupdav_delete(StrBuf *dav_pathname, char *dav_ifmatch) {
- char dav_roomname[SIZ];
char dav_uid[SIZ];
long dav_msgnum = (-1);
char buf[SIZ];
if ((len > 0) && (ChrPtr(dav_pathname)[len-1] == '/')) {
StrBufCutRight(dav_pathname, 1);
}
- strcpy(dav_roomname, ChrPtr(dav_pathname));
/* Go to the correct room. */
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
- gotoroom(dav_roomname);
+ if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_pathname))) {
+ gotoroom(dav_pathname);
}
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+ if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_pathname))) {
hprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
hprintf("Content-Length: 0\r\n\r\n");
* /groupdav/room_name/euid (GroupDAV)
* /groupdav/room_name (webcal)
*/
-void groupdav_get(const char *dav_pathname) {
- char dav_roomname[1024];
- char dav_uid[1024];
+void groupdav_get(StrBuf *dav_pathname) {
+ StrBuf *dav_roomname;
+ StrBuf *dav_uid;
long dav_msgnum = (-1);
char buf[1024];
int in_body = 0;
char date[128];
struct epdata epdata;
- if (num_tokens(dav_pathname, '/') < 3) {
+ if (StrBufNum_tokens(dav_pathname, '/') < 3) {
hprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
hprintf("Content-Type: text/plain\r\n");
return;
}
- extract_token(dav_roomname, dav_pathname, 2, '/', sizeof dav_roomname);
- extract_token(dav_uid, dav_pathname, 3, '/', sizeof dav_uid);
- if ((!strcasecmp(dav_uid, "ics")) || (!strcasecmp(dav_uid, "calendar.ics"))) {
- strcpy(dav_uid, "");
+ dav_roomname = NewStrBuf();;
+ dav_uid = NewStrBuf();;
+ StrBufExtract_token(dav_roomname, dav_pathname, 2, '/');
+ StrBufExtract_token(dav_uid, dav_pathname, 3, '/');
+ if ((!strcasecmp(ChrPtr(dav_uid), "ics")) ||
+ (!strcasecmp(ChrPtr(dav_uid), "calendar.ics"))) {
+ FlushStrBuf(dav_uid);
}
/* Go to the correct room. */
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+ if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
gotoroom(dav_roomname);
}
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+ if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
hprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
hprintf("Content-Type: text/plain\r\n");
wprintf("There is no folder called \"%s\" on this server.\r\n",
- dav_roomname);
+ ChrPtr(dav_roomname));
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
/** GET on the collection itself returns an ICS of the entire collection.
*/
- if (!strcasecmp(dav_uid, "")) {
+ if (StrLength(dav_uid) > 0) {
groupdav_get_big_ics();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
- dav_msgnum = locate_message_by_uid(dav_uid);
+ dav_msgnum = locate_message_by_uid(ChrPtr(dav_uid));
serv_printf("MSG2 %ld", dav_msgnum);
serv_getln(buf, sizeof buf);
if (buf[0] != '1') {
groupdav_common_headers();
hprintf("Content-Type: text/plain\r\n");
wprintf("Object \"%s\" was not found in the \"%s\" folder.\r\n",
- dav_uid,
- dav_roomname);
+ ChrPtr(dav_uid),
+ ChrPtr(dav_roomname));
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
/* We got it; a message is now arriving from the server. Read it in. */
hprintf(
"Server: %s / %s\r\n"
"Connection: close\r\n",
- PACKAGE_STRING, serv_info.serv_software
+ PACKAGE_STRING, ChrPtr(serv_info.serv_software)
);
}
/*
* string conversion function
*/
-void euid_escapize(char *target, char *source) {
+void euid_escapize(char *target, const char *source) {
int i, len;
int target_length = 0;
/*
* string conversion function
*/
-void euid_unescapize(char *target, char *source) {
+void euid_unescapize(char *target, const char *source) {
int a, b, len;
char hex[3];
int target_length = 0;
hprintf("HTTP/1.1 401 Unauthorized\r\n");
groupdav_common_headers();
hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n",
- serv_info.serv_humannode);
+ ChrPtr(serv_info.serv_humannode));
hprintf("Content-Length: 0\r\n");
end_burst();
return;
* other variants of DAV in the future.
*/
if (!strcasecmp(ChrPtr(DavMethod), "OPTIONS")) {
- groupdav_options(ChrPtr(DavPathname));
+ groupdav_options(DavPathname);
return;
}
* room, or to list all relevant rooms on the server.
*/
if (!strcasecmp(ChrPtr(DavMethod), "PROPFIND")) {
- groupdav_propfind(ChrPtr(DavPathname), dav_depth,
+ groupdav_propfind(DavPathname, dav_depth,
dav_content_type, dav_content,
Offset);
return;
* The GET method is used for fetching individual items.
*/
if (!strcasecmp(ChrPtr(DavMethod), "GET")) {
- groupdav_get(ChrPtr(DavPathname));
+ groupdav_get(DavPathname);
return;
}
* The PUT method is used to add or modify items.
*/
if (!strcasecmp(ChrPtr(DavMethod), "PUT")) {
- groupdav_put(ChrPtr(DavPathname), dav_ifmatch,
+ groupdav_put(DavPathname, dav_ifmatch,
ChrPtr(dav_content_type), dav_content,
Offset);
return;
/*
* The pathname is always going to be /groupdav/room_name/msg_num
*/
-void groupdav_options(const char *dav_pathname) {
- char dav_roomname[256];
- char dav_uid[256];
+void groupdav_options(StrBuf *dav_pathname) {
+ StrBuf *dav_roomname;
+ StrBuf *dav_uid;
long dav_msgnum = (-1);
char datestring[256];
time_t now;
now = time(NULL);
http_datestring(datestring, sizeof datestring, now);
- extract_token(dav_roomname, dav_pathname, 2, '/', sizeof dav_roomname);
- extract_token(dav_uid, dav_pathname, 3, '/', sizeof dav_uid);
+ dav_roomname = NewStrBuf();
+ dav_uid = NewStrBuf();
+ StrBufExtract_token(dav_roomname, dav_pathname, 2, '/');
+ StrBufExtract_token(dav_uid, dav_pathname, 3, '/');
/*
* If the room name is blank, the client is doing a top-level OPTIONS.
*/
- if (IsEmptyStr(dav_roomname)) {
+ if (StrLength(dav_roomname) == 0) {
hprintf("HTTP/1.1 200 OK\r\n");
groupdav_common_headers();
hprintf("Date: %s\r\n", datestring);
hprintf("\r\n");
begin_burst();
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
/* Go to the correct room. */
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+ if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
gotoroom(dav_roomname);
}
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+ if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
hprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
hprintf("Date: %s\r\n", datestring);
"Content-Type: text/plain\r\n"
"\r\n"
"There is no folder called \"%s\" on this server.\r\n",
- dav_roomname
+ ChrPtr(dav_roomname)
);
begin_burst();
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
/* If dav_uid is non-empty, client is requesting an OPTIONS on
* a specific item in the room.
*/
- if (!IsEmptyStr(dav_uid)) {
+ if (StrLength(dav_uid) != 0) {
- dav_msgnum = locate_message_by_uid(dav_uid);
+ dav_msgnum = locate_message_by_uid(ChrPtr(dav_uid));
if (dav_msgnum < 0) {
hprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
"Content-Type: text/plain\r\n"
"\r\n"
"Object \"%s\" was not found in the \"%s\" folder.\r\n",
- dav_uid,
- dav_roomname
+ ChrPtr(dav_uid),
+ ChrPtr(dav_roomname)
);
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
begin_burst();end_burst();return;
}
hprintf("\r\n");
begin_burst();
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
+
/*
* We got to this point, which means that the client is requesting
* an OPTIONS on the room itself.
* if not found.
*
*/
-long locate_message_by_uid(char *uid) {
+long locate_message_by_uid(const char *uid) {
char buf[256];
char decoded_uid[1024];
long retval = (-1L);
/*
* The pathname is always going to be /groupdav/room_name/msg_num
*/
-void groupdav_propfind(const char *dav_pathname, int dav_depth, StrBuf *dav_content_type, StrBuf *dav_content, int offset) {
- char dav_roomname[256];
- char dav_uid[256];
+void groupdav_propfind(StrBuf *dav_pathname, int dav_depth, StrBuf *dav_content_type, StrBuf *dav_content, int offset) {
+ StrBuf *dav_roomname;
+ StrBuf *dav_uid;
char msgnum[256];
long dav_msgnum = (-1);
char buf[256];
now = time(NULL);
http_datestring(datestring, sizeof datestring, now);
- extract_token(dav_roomname, dav_pathname, 2, '/', sizeof dav_roomname);
- extract_token(dav_uid, dav_pathname, 3, '/', sizeof dav_uid);
+ dav_roomname = NewStrBuf();
+ dav_uid = NewStrBuf();
+ StrBufExtract_token(dav_roomname, dav_pathname, 2, '/');
+ StrBufExtract_token(dav_uid, dav_pathname, 3, '/');
/*
* If the room name is blank, the client is requesting a
* folder list.
*/
- if (IsEmptyStr(dav_roomname)) {
- groupdav_collection_list(dav_pathname, dav_depth);
+ if (StrLength(dav_roomname) == 0) {
+ groupdav_collection_list(ChrPtr(dav_pathname), dav_depth);
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
/* Go to the correct room. */
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+ if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
gotoroom(dav_roomname);
}
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+ if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
hprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
hprintf("Date: %s\r\n", datestring);
hprintf("Content-Type: text/plain\r\n");
wprintf("There is no folder called \"%s\" on this server.\r\n",
- dav_roomname
+ ChrPtr(dav_roomname)
);
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
* a specific item in the room. This is not valid GroupDAV, but
* it is valid WebDAV.
*/
- if (!IsEmptyStr(dav_uid)) {
+ if (StrLength(dav_uid) != 0) {
- dav_msgnum = locate_message_by_uid(dav_uid);
+ dav_msgnum = locate_message_by_uid(ChrPtr(dav_uid));
if (dav_msgnum < 0) {
hprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
hprintf("Content-Type: text/plain\r\n");
wprintf("Object \"%s\" was not found in the \"%s\" folder.\r\n",
- dav_uid,
- dav_roomname
+ ChrPtr(dav_uid),
+ ChrPtr(dav_roomname)
);
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
wprintf("<href>");
groupdav_identify_host();
wprintf("/groupdav/");
- urlescputs(WC->wc_roomname);
- euid_escapize(encoded_uid, dav_uid);
+ urlescputs(ChrPtr(WC->wc_roomname));
+ euid_escapize(encoded_uid, ChrPtr(dav_uid));
wprintf("/%s", encoded_uid);
wprintf("</href>");
wprintf("<propstat>");
wprintf("</response>\n");
wprintf("</multistatus>\n");
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
/*
wprintf("<href>");
groupdav_identify_host();
wprintf("/groupdav/");
- urlescputs(WC->wc_roomname);
+ urlescputs(ChrPtr(WC->wc_roomname));
wprintf("</href>");
wprintf("<propstat>");
wprintf("<status>HTTP/1.1 200 OK</status>");
wprintf("<prop>");
wprintf("<displayname>");
- escputs(WC->wc_roomname);
+ escputs(ChrPtr(WC->wc_roomname));
wprintf("</displayname>");
wprintf("<resourcetype><collection/>");
wprintf("<href>");
groupdav_identify_host();
wprintf("/groupdav/");
- urlescputs(WC->wc_roomname);
+ urlescputs(ChrPtr(WC->wc_roomname));
euid_escapize(encoded_uid, uid);
wprintf("/%s", encoded_uid);
wprintf("</href>");
* /groupdav/room_name/euid (GroupDAV)
* /groupdav/room_name (webcal)
*/
-void groupdav_put(const char *dav_pathname, char *dav_ifmatch,
+void groupdav_put(StrBuf *dav_pathname, char *dav_ifmatch,
const char *dav_content_type, StrBuf *dav_content,
int offset)
{
- char dav_roomname[1024];
- char dav_uid[1024];
+ StrBuf *dav_roomname;
+ StrBuf *dav_uid;
long new_msgnum = (-2L);
long old_msgnum = (-1L);
char buf[SIZ];
int n = 0;
- if (num_tokens(dav_pathname, '/') < 3) {
+ if (StrBufNum_tokens(dav_pathname, '/') < 3) {
hprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
hprintf("Content-Type: text/plain\r\n");
return;
}
- extract_token(dav_roomname, dav_pathname, 2, '/', sizeof dav_roomname);
- extract_token(dav_uid, dav_pathname, 3, '/', sizeof dav_uid);
- if ((!strcasecmp(dav_uid, "ics")) || (!strcasecmp(dav_uid, "calendar.ics"))) {
- strcpy(dav_uid, "");
+ dav_roomname = NewStrBuf();;
+ dav_uid = NewStrBuf();;
+ StrBufExtract_token(dav_roomname, dav_pathname, 2, '/');
+ StrBufExtract_token(dav_uid, dav_pathname, 3, '/');
+ if ((!strcasecmp(ChrPtr(dav_uid), "ics")) ||
+ (!strcasecmp(ChrPtr(dav_uid), "calendar.ics"))) {
+ FlushStrBuf(dav_uid);
}
/* Go to the correct room. */
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+ if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
gotoroom(dav_roomname);
}
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+ if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
hprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
hprintf("Content-Type: text/plain\r\n");
wprintf("There is no folder called \"%s\" on this server.\r\n",
- dav_roomname);
+ ChrPtr(dav_roomname));
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
*/
if (!IsEmptyStr(dav_ifmatch)) {
lprintf(9, "dav_ifmatch: %s\n", dav_ifmatch);
- old_msgnum = locate_message_by_uid(dav_uid);
+ old_msgnum = locate_message_by_uid(ChrPtr(dav_uid));
lprintf(9, "old_msgnum: %ld\n", old_msgnum);
if (atol(dav_ifmatch) != old_msgnum) {
hprintf("HTTP/1.1 412 Precondition Failed\r\n");
groupdav_common_headers();
hprintf("Content-Length: 0\r\n");
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
}
/** PUT on the collection itself uploads an ICS of the entire collection.
*/
- if (!strcasecmp(dav_uid, "")) {
+ if (StrLength(dav_uid) > 0) {
groupdav_put_bigics(dav_content, offset);
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
/* Fetch the reply from the Citadel server */
n = 0;
- strcpy(dav_uid, "");
+ FlushStrBuf(dav_uid);
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
switch(n++) {
- case 0: new_msgnum = atol(buf);
- break;
- case 1: lprintf(9, "new_msgnum=%ld (%s)\n", new_msgnum, buf);
- break;
- case 2: strcpy(dav_uid, buf);
- break;
- default:
- break;
+ case 0:
+ new_msgnum = atol(buf);
+ break;
+ case 1:
+ lprintf(9, "new_msgnum=%ld (%s)\n", new_msgnum, buf);
+ break;
+ case 2:
+ StrBufAppendBufPlain(dav_uid, buf, -1, 0);
+ break;
+ default:
+ break;
}
}
wprintf("new_msgnum is %ld\r\n"
"\r\n", new_msgnum);
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
hprintf("Location: ");
groupdav_identify_host();
hprintf("/groupdav/");/* TODO */
- hurlescputs(dav_roomname);
- euid_escapize(escaped_uid, dav_uid);
+ hurlescputs(ChrPtr(dav_roomname));
+ euid_escapize(escaped_uid, ChrPtr(dav_uid));
hprintf("/%s\r\n", escaped_uid);
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
serv_printf("DELE %ld", old_msgnum);
serv_getln(buf, sizeof buf);
end_burst();
+ FreeStrBuf(&dav_roomname);
+ FreeStrBuf(&dav_uid);
return;
}
}
-void tmplput_nowstr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_nowstr(StrBuf *Target, WCTemplputParams *TP)
{
time_t now;
now = time(NULL);
StrEscAppend(Target, NULL, asctime(localtime(&now)), 0, 0);
}
-void tmplput_nowno(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_nowno(StrBuf *Target, WCTemplputParams *TP)
{
time_t now;
now = time(NULL);
icaltimezone *get_default_icaltimezone(void) {
icaltimezone *zone = NULL;
- char *default_zone_name = serv_info.serv_default_cal_zone;
+ const char *default_zone_name = ChrPtr(serv_info.serv_default_cal_zone);
if (!zone) {
zone = icaltimezone_get_builtin_timezone(default_zone_name);
}
-void tmplput_iconbar(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_iconbar(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
url_do_template();
}
-void InetCfgSubst(StrBuf *TemplBuffer, void *vContext, WCTemplateToken *Tokens)
+void InetCfgSubst(StrBuf *TemplBuffer, WCTemplputParams *TP)
{
- SVPutBuf("SERVCFG:INET:HOSTNAME", vContext, 1);
+ SVPutBuf("SERVCFG:INET:HOSTNAME", CTX, 1);
}
-void DeleteInetConfHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void DeleteInetConfHash(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
}
-HashList *GetInetConfHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *GetInetConfHash(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
void *vHash;
if (WCC->InetCfg == NULL)
load_inetconf();
GetHash(WCC->InetCfg, TKEY(2), &vHash);
- svprintf(HKEY("SERVCFG:INET:TYPE"), WCS_STRING, Tokens->Params[2]->Start);
+ svprintf(HKEY("SERVCFG:INET:TYPE"), WCS_STRING, TP->Tokens->Params[2]->Start);
return vHash;
}
int self;
char sroom[SIZ];
- strcpy(WC->wc_fullname, "");
- strcpy(WC->wc_username, "");
- strcpy(WC->wc_password, "");
- strcpy(WC->wc_roomname, "");
+ FlushStrBuf(WC->wc_fullname);
+ FlushStrBuf(WC->wc_username);
+ FlushStrBuf(WC->wc_password);
+ FlushStrBuf(WC->wc_roomname);
output_headers(1, 0, 0, 1, 1, 0);
begin_burst();
{
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(HKEY("display_main_menu"), NULL, NULL, 0);
+ DoTemplate(HKEY("display_main_menu"), NULL, &NoCtx);
end_burst();
/*
{
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(HKEY("display_aide_menu"), NULL, NULL, 0);
+ DoTemplate(HKEY("display_aide_menu"), NULL, &NoCtx);
end_burst();
/*
output_headers(1, 1, 2, 0, 0, 0);
}
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(HKEY("display_serverrestart"), NULL, NULL, 0);
+ DoTemplate(HKEY("display_serverrestart"), NULL, &NoCtx);
end_burst();
lingering_close(WC->http_sock);
sleeeeeeeeeep(10);
{
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(HKEY("display_serverrestartpage"), NULL, NULL, 0);
+ DoTemplate(HKEY("display_serverrestartpage"), NULL, &NoCtx);
end_burst();
}
else
serv_getln(buf, sizeof buf); /* TODO: should we care? */
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(HKEY("display_serverrestartpagedo"), NULL, NULL, 0);
+ DoTemplate(HKEY("display_serverrestartpagedo"), NULL, &NoCtx);
end_burst();
}
}
}
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(HKEY("display_aide_menu"), NULL, NULL, 0);
+ DoTemplate(HKEY("display_aide_menu"), NULL, &NoCtx);
end_burst();
}
}
int state=0;
long len;
const char *Key;
+ WCTemplputParams SubTP;
Buf = NewStrBuf();
lprintf(1, "----------%s---------MSG4 %ld|%s--------------\n", tmpl, msgnum, ChrPtr(PartNum));
else
{
if ((StrLength(Msg->OtherNode)>0) &&
- (strcasecmp(ChrPtr(Msg->OtherNode), serv_info.serv_nodename)) &&
- (strcasecmp(ChrPtr(Msg->OtherNode), serv_info.serv_humannode)) )
+ (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(serv_info.serv_nodename))) &&
+ (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(serv_info.serv_humannode)) ))
{
if (Msg->reply_to == NULL)
Msg->reply_to = NewStrBuf();
evaluate_mime_part(Msg, Mime);
}
DeleteHashPos(&it);
-
- DoTemplate(tmpl, tmpllen, Target, Msg, CTX_MAILSUM);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_MAILSUM;
+ SubTP.Context = Msg;
+ DoTemplate(tmpl, tmpllen, Target, &SubTP);
DestroyMessageSummary(Msg);
FreeStrBuf(&FoundCharset);
StrBufExtract_token(Buf2, Buf, 3, '|');
if ((StrLength(Buf2) !=0 ) &&
( ((WCC->room_flags & QR_NETWORK)
- || ((strcasecmp(ChrPtr(Buf2), serv_info.serv_nodename)
- && (strcasecmp(ChrPtr(Buf2), serv_info.serv_fqdn)))))))
+ || ((strcasecmp(ChrPtr(Buf2), ChrPtr(serv_info.serv_nodename))
+ && (strcasecmp(ChrPtr(Buf2), ChrPtr(serv_info.serv_fqdn))))))))
{
StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
StrBufAppendBuf(Msg->from, Buf2, 0);
int nItems;
HashPos *At;
long vector[16];
+ WCTemplputParams SubTP;
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_LONGVECTOR;
+ SubTP.Context = &vector;
TmpBuf = NewStrBuf();
At = GetNewHashPos(WCC->summ, nMessages);
nItems = GetCount(WCC->summ);
vector[6] = lo;
FlushStrBuf(TmpBuf);
dbg_print_longvector(vector);
- DoTemplate(HKEY("select_messageindex"), TmpBuf, &vector, CTX_LONGVECTOR);
+ DoTemplate(HKEY("select_messageindex"), TmpBuf, &SubTP);
StrBufAppendBuf(Selector, TmpBuf, 0);
}
vector[6] = 0;
vector[1] = lbstr("maxmsgs") == 9999999;
vector[2] = 0;
dbg_print_longvector(vector);
- DoTemplate(HKEY("select_messageindex_all"), TmpBuf, &vector, CTX_LONGVECTOR);
+ DoTemplate(HKEY("select_messageindex_all"), TmpBuf, &SubTP);
StrBufAppendBuf(Selector, TmpBuf, 0);
FreeStrBuf(&TmpBuf);
DeleteHashPos(&At);
OldMsg = NewStrBuf();
serv_puts("GTSN");
StrBuf_ServGetln(OldMsg);
- if (ChrPtr(OldMsg)[0] == '2') {
+ if (GetServerStatus(OldMsg, NULL) == 2) {
StrBufCutLeft(OldMsg, 4);
}
else {
int load_seen = 0;
int sortit = 0;
int defaultsortorder = 0;
+ WCTemplputParams SubTP;
if (havebstr("is_summary") && (1 == (ibstr("is_summary"))))
WCC->wc_view = VIEW_MAILBOX;
switch (WCC->wc_view) {
case VIEW_WIKI:
- sprintf(buf, "wiki?room=%s&page=home", WCC->wc_roomname);
+ sprintf(buf, "wiki?room=%s&page=home", ChrPtr(WCC->wc_roomname));
http_redirect(buf);
return;
case VIEW_CALBRIEF:
if (sortit) {
CompareFunc SortIt;
- SortIt = RetrieveSort(CTX_MAILSUM, NULL,
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_NONE;
+ SubTP.Context = NULL;
+ SortIt = RetrieveSort(&SubTP, NULL,
HKEY("date"), defaultsortorder);
if (SortIt != NULL)
SortByPayload(WCC->summ, SortIt);
maxmsgs = abs(maxmsgs);
}
- DoTemplate(HKEY("msg_listselector_top"), BBViewToolBar, MessageDropdown, CTX_STRBUF);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_STRBUF;
+ SubTP.Context = MessageDropdown;
+ DoTemplate(HKEY("msg_listselector_top"), BBViewToolBar, &SubTP);
StrBufAppendBuf(WCC->WBuf, BBViewToolBar, 0);
FlushStrBuf(BBViewToolBar);
break;
addrbook[num_ab-1].ab_msgnum = Msg->msgnum;
break;
case VIEW_MAILBOX: /* here we just need the abstract, so render it now. */
- DoTemplate(HKEY("section_mailsummary"), NULL, Msg, CTX_MAILSUM);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_MAILSUM;
+ SubTP.Context = Msg;
+ DoTemplate(HKEY("section_mailsummary"), NULL, &SubTP);
num_displayed++;
break;
free(displayed_msgs);
displayed_msgs = NULL;
}
- DoTemplate(HKEY("msg_listselector_bottom"), BBViewToolBar, MessageDropdown, CTX_STRBUF);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_STRBUF;
+ SubTP.Context = MessageDropdown;
+ DoTemplate(HKEY("msg_listselector_bottom"), BBViewToolBar, &SubTP);
StrBufAppendBuf(WCC->WBuf, BBViewToolBar, 0);
FreeStrBuf(&BBViewToolBar);
char *txtmail = NULL;
sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
- serv_info.serv_fqdn,
+ ChrPtr(serv_info.serv_fqdn),
getpid(),
++seq
);
sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
- serv_info.serv_fqdn,
+ ChrPtr(serv_info.serv_fqdn),
getpid(),
++seq
);
wcsession *WCC = WC;
if (havebstr("force_room")) {
- gotoroom(bstr("force_room"));
+ gotoroom(sbstr("force_room"));
}
if (havebstr("display_name")) {
now = time(NULL);
if (havebstr("force_room")) {
- gotoroom(bstr("force_room"));
+ gotoroom(sbstr("force_room"));
}
display_name = sbstr("display_name");
* message" command really means "add new entry."
*/
if (WCC->wc_default_view == VIEW_ADDRESSBOOK) {
- do_edit_vcard(-1, "", "", WCC->wc_roomname);
+ do_edit_vcard(-1, "", "", ChrPtr(WCC->wc_roomname));
return;
}
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(HKEY("edit_message"), NULL, NULL, CTX_NONE);
+ DoTemplate(HKEY("edit_message"), NULL, &NoCtx);
end_burst();
return;
if (!strncasecmp(ChrPtr(HdrLine), "yes", 8))
Msg->nhdr = 1;
}
-int Conditional_ANONYMOUS_MESSAGE(WCTemplateToken *Tokens, void *Context, int ContextType)
+int Conditional_ANONYMOUS_MESSAGE(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return Msg->nhdr != 0;
}
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 *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_FROM(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->from, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->from, 0);
}
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 *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
{/*////TODO: Fwd: and RE: filter!!*/
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->subj, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->subj, 0);
}
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 *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->reply_inreplyto, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->reply_inreplyto, 0);
}
-int Conditional_MAIL_SUMM_UNREAD(WCTemplateToken *Tokens, void *Context, int ContextType)
+int Conditional_MAIL_SUMM_UNREAD(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return Msg->is_new != 0;
}
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 *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->reply_references, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->reply_references, 0);
}
}
StrBufAppendBuf(Msg->AllRcpt, Msg->cccc, 0);
}
-void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->cccc, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->cccc, 0);
}
void examine_room(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
if ((StrLength(HdrLine) > 0) &&
- (strcasecmp(ChrPtr(HdrLine), WC->wc_roomname))) {
+ (strcasecmp(ChrPtr(HdrLine), ChrPtr(WC->wc_roomname)))) {
FreeStrBuf(&Msg->Room);
Msg->Room = NewStrBufDup(HdrLine);
}
}
-void tmplput_MAIL_SUMM_ORGROOM(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_ORGROOM(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->Room, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->Room, 0);
}
FreeStrBuf(&Msg->Rfca);
Msg->Rfca = NewStrBufDup(HdrLine);
}
-void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->Rfca, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->Rfca, 0);
}
-int Conditional_MAIL_SUMM_RFCA(WCTemplateToken *Tokens, void *Context, int ContextType)
+int Conditional_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return StrLength(Msg->Rfca) > 0;
}
{
if ( (StrLength(HdrLine) > 0) &&
((WC->room_flags & QR_NETWORK)
- || ((strcasecmp(ChrPtr(HdrLine), serv_info.serv_nodename)
- && (strcasecmp(ChrPtr(HdrLine), serv_info.serv_fqdn)))))) {
+ || ((strcasecmp(ChrPtr(HdrLine), ChrPtr(serv_info.serv_nodename))
+ && (strcasecmp(ChrPtr(HdrLine), ChrPtr(serv_info.serv_fqdn))))))) {
FreeStrBuf(&Msg->OtherNode);
Msg->OtherNode = NewStrBufDup(HdrLine);
}
}
-void tmplput_MAIL_SUMM_OTHERNODE(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_OTHERNODE(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->OtherNode, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->OtherNode, 0);
}
-int Conditional_MAIL_SUMM_OTHERNODE(WCTemplateToken *Tokens, void *Context, int ContextType)
+int Conditional_MAIL_SUMM_OTHERNODE(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return StrLength(Msg->OtherNode) > 0;
}
}
StrBufAppendBuf(Msg->AllRcpt, Msg->to, 0);
}
-void tmplput_MAIL_SUMM_TO(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_TO(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->to, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->to, 0);
}
-void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->AllRcpt, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->AllRcpt, 0);
}
-HashList *iterate_get_mailsumm_All(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *iterate_get_mailsumm_All(StrBuf *Target, WCTemplputParams *TP)
{
return WC->summ;
}
{
Msg->date = StrTol(HdrLine);
}
-void tmplput_MAIL_SUMM_DATE_BRIEF(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+
+void tmplput_MAIL_SUMM_DATE_BRIEF(StrBuf *Target, WCTemplputParams *TP)
{
char datebuf[64];
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
webcit_fmt_date(datebuf, Msg->date, 1);
StrBufAppendBufPlain(Target, datebuf, -1, 0);
}
-void tmplput_MAIL_SUMM_DATE_FULL(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+
+void tmplput_MAIL_SUMM_DATE_FULL(StrBuf *Target, WCTemplputParams *TP)
{
char datebuf[64];
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
webcit_fmt_date(datebuf, Msg->date, 0);
StrBufAppendBufPlain(Target, datebuf, -1, 0);
}
-void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
StrBufAppendPrintf(Target, "%ld", Msg->date, 0);
}
void render_MIME_VCard(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
{
+ wcsession *WCC = WC;
MimeLoadData(Mime);
if (StrLength(Mime->Data) > 0) {
StrBuf *Buf;
Buf = NewStrBuf();
/** If it's my vCard I can edit it */
- if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
- || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
+ if ( (!strcasecmp(ChrPtr(WCC->wc_roomname), USERCONFIGROOM))
+ || (!strcasecmp(&(ChrPtr(WCC->wc_roomname)[11]), USERCONFIGROOM))
|| (WC->wc_view == VIEW_ADDRESSBOOK)
) {
StrBufAppendPrintf(Buf, "<a href=\"edit_vcard?msgnum=%ld&partnum=%s\">",
}
}
-void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
StrBufAppendPrintf(Target, "%ld", GetCount(Msg->Attachments));
}
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 *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->hnod, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->hnod, 0);
}
-int Conditional_MAIL_SUMM_H_NODE(WCTemplateToken *Tokens, void *Context, int ContextType)
+int Conditional_MAIL_SUMM_H_NODE(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return StrLength(Msg->hnod) > 0;
}
}
}
-void tmplput_MAIL_SUMM_N(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
StrBufAppendPrintf(Target, "%ld", Msg->msgnum);
}
-int Conditional_MAIL_MIME_ALL(WCTemplateToken *Tokens, void *Context, int ContextType)
+int Conditional_MAIL_MIME_ALL(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return GetCount(Msg->Attachments) > 0;
}
-int Conditional_MAIL_MIME_SUBMESSAGES(WCTemplateToken *Tokens, void *Context, int ContextType)
+int Conditional_MAIL_MIME_SUBMESSAGES(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return GetCount(Msg->Submessages) > 0;
}
-int Conditional_MAIL_MIME_ATTACHLINKS(WCTemplateToken *Tokens, void *Context, int ContextType)
+int Conditional_MAIL_MIME_ATTACHLINKS(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return GetCount(Msg->AttachLinks) > 0;
}
-int Conditional_MAIL_MIME_ATTACH(WCTemplateToken *Tokens, void *Context, int ContextType)
+int Conditional_MAIL_MIME_ATTACH(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return GetCount(Msg->AllAttach) > 0;
}
/*----------------------------------------------------------------------------*/
-void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
{
long MsgNum;
StrBuf *Buf;
MsgNum = LBstr(TKEY(0));
Buf = NewStrBuf();
read_message(Buf, HKEY("view_message_replyquote"), MsgNum, 0, NULL);
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Buf, 1);
+ StrBufAppendTemplate(Target, TP, Buf, 1);
FreeStrBuf(&Buf);
}
-void tmplput_MAIL_BODY(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->MsgBody->Data, 0);
+ message_summary *Msg = (message_summary*) CTX;
+ StrBufAppendTemplate(Target, TP, Msg->MsgBody->Data, 0);
}
-HashList *iterate_get_mime_All(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *iterate_get_mime_All(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return Msg->Attachments;
}
-HashList *iterate_get_mime_Submessages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *iterate_get_mime_Submessages(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return Msg->Submessages;
}
-HashList *iterate_get_mime_AttachLinks(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *iterate_get_mime_AttachLinks(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return Msg->AttachLinks;
}
-HashList *iterate_get_mime_Attachments(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *iterate_get_mime_Attachments(StrBuf *Target, WCTemplputParams *TP)
{
- message_summary *Msg = (message_summary*) Context;
+ message_summary *Msg = (message_summary*) CTX;
return Msg->AllAttach;
}
-void tmplput_MIME_Name(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MIME_Name(StrBuf *Target, WCTemplputParams *TP)
{
- wc_mime_attachment *mime = (wc_mime_attachment*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->Name, 0);
+ wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
+ StrBufAppendTemplate(Target, TP, mime->Name, 0);
}
-void tmplput_MIME_FileName(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MIME_FileName(StrBuf *Target, WCTemplputParams *TP)
{
- wc_mime_attachment *mime = (wc_mime_attachment*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->FileName, 0);
+ wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
+ StrBufAppendTemplate(Target, TP, mime->FileName, 0);
}
-void tmplput_MIME_PartNum(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MIME_PartNum(StrBuf *Target, WCTemplputParams *TP)
{
- wc_mime_attachment *mime = (wc_mime_attachment*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->PartNum, 0);
+ wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
+ StrBufAppendTemplate(Target, TP, mime->PartNum, 0);
}
-void tmplput_MIME_MsgNum(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MIME_MsgNum(StrBuf *Target, WCTemplputParams *TP)
{
- wc_mime_attachment *mime = (wc_mime_attachment*) Context;
+ wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
StrBufAppendPrintf(Target, "%ld", mime->msgnum);
}
-void tmplput_MIME_Disposition(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MIME_Disposition(StrBuf *Target, WCTemplputParams *TP)
{
- wc_mime_attachment *mime = (wc_mime_attachment*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->Disposition, 0);
+ wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
+ StrBufAppendTemplate(Target, TP, mime->Disposition, 0);
}
-void tmplput_MIME_ContentType(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MIME_ContentType(StrBuf *Target, WCTemplputParams *TP)
{
- wc_mime_attachment *mime = (wc_mime_attachment*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->ContentType, 0);
+ wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
+ StrBufAppendTemplate(Target, TP, mime->ContentType, 0);
}
void examine_charset(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
Msg->MsgBody->Charset = NewStrBufDup(HdrLine);
}
-void tmplput_MIME_Charset(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MIME_Charset(StrBuf *Target, WCTemplputParams *TP)
{
- wc_mime_attachment *mime = (wc_mime_attachment*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->Charset, 0);
+ wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
+ StrBufAppendTemplate(Target, TP, mime->Charset, 0);
}
-void tmplput_MIME_Data(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MIME_Data(StrBuf *Target, WCTemplputParams *TP)
{
- wc_mime_attachment *mime = (wc_mime_attachment*) Context;
+ wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
if (mime->Renderer != NULL)
mime->Renderer->f(mime, NULL, NULL);
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->Data, 0);
+ StrBufAppendTemplate(Target, TP, mime->Data, 0);
/* TODO: check whether we need to load it now? */
}
-void tmplput_MIME_LoadData(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MIME_LoadData(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
- wc_mime_attachment *mime = (wc_mime_attachment*) Context;
+ wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
wc_mime_attachment *att;
if ( (!strcasecmp(ChrPtr(mime->Disposition), "inline"))||
}
}
-void tmplput_MIME_Length(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_MIME_Length(StrBuf *Target, WCTemplputParams *TP)
{
- wc_mime_attachment *mime = (wc_mime_attachment*) Context;
+ wc_mime_attachment *mime = (wc_mime_attachment*) CTX;
StrBufAppendPrintf(Target, "%ld", mime->length);
}
-HashList *iterate_get_registered_Attachments(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *iterate_get_registered_Attachments(StrBuf *Target, WCTemplputParams *TP)
{
return WC->attachments;
}
}
-HashList *load_netconf(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP)
{
StrBuf *Buf;
HashList *Hash;
}
-void NodeCfgSubst(StrBuf *TemplBuffer, void *vContext, WCTemplateToken *Token)
-{
- NodeConf *Node= (NodeConf*)vContext;
-
- SVPutBuf("CFG:IGNET:NODE", Node->NodeName, 1);
- SVPutBuf("CFG:IGNET:SECRET", Node->Secret, 1);
- SVPutBuf("CFG:IGNET:HOST", Node->Host, 1);
- SVPutBuf("CFG:IGNET:PORT", Node->Port, 1);
-}
-
void save_net_conf(HashList *Nodelist)
{
return;
}
- NodeConfig = load_netconf(NULL, 0, NULL, NULL, CTX_NONE);
+ NodeConfig = load_netconf(NULL, &NoCtx);
Put(NodeConfig, ChrPtr(Index), StrLength(Index), NewNode, DeleteNodeConf);
save_net_conf(NodeConfig);
DeleteHash(&NodeConfig);
*/
void display_edit_node(void)
{
+ WCTemplputParams SubTP;
HashList *NodeConfig;
const StrBuf *Index;
void *vNode;
+ const StrBuf *Tmpl;
Index = sbstr("index");
if (Index == NULL) {
return;
}
- NodeConfig = load_netconf(NULL, 0, NULL, NULL, CTX_NONE);
+ NodeConfig = load_netconf(NULL, &NoCtx);
if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) ||
(vNode == NULL)) {
sprintf(WC->ImportantMessage, _("Invalid Parameter"));
return;
}
- NodeCfgSubst(NULL, vNode, NULL);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
SVPutBuf("ITERATE:KEY", Index, 1);
- url_do_template();
-
+ SubTP.ContextType = CTX_NODECONF;
+ SubTP.Context = vNode;
+ begin_burst();
+ Tmpl = sbstr("template");
+ output_headers(1, 0, 0, 0, 1, 0);
+ DoTemplate(SKEY(Tmpl), NULL, &SubTP);
+ end_burst();
DeleteHash(&NodeConfig);
}
return;
}
- NodeConfig = load_netconf(NULL, 0, NULL, NULL, CTX_NONE);
+ NodeConfig = load_netconf(NULL, &NoCtx);
if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) ||
(vNode == NULL)) {
sprintf(WC->ImportantMessage, _("Invalid Parameter"));
}
+
+void tmplput_NodeName(StrBuf *Target, WCTemplputParams *TP)
+{
+ NodeConf *Node = (NodeConf*) CTX;
+ StrBufAppendTemplate(Target, TP, Node->NodeName, 0);
+}
+
+void tmplput_Secret(StrBuf *Target, WCTemplputParams *TP)
+{
+ NodeConf *Node = (NodeConf*) CTX;
+ StrBufAppendTemplate(Target, TP, Node->Secret, 0);
+}
+
+void tmplput_Host(StrBuf *Target, WCTemplputParams *TP)
+{
+ NodeConf *Node= (NodeConf*) CTX;
+ StrBufAppendTemplate(Target, TP, Node->Host, 0);
+}
+
+void tmplput_Port(StrBuf *Target, WCTemplputParams *TP)
+{
+ NodeConf *Node= (NodeConf*) CTX;
+ StrBufAppendTemplate(Target, TP, Node->Port, 0);
+}
+
void
InitModule_NETCONF
(void)
WebcitAddUrlHandler(HKEY("display_netconf"), display_netconf, 0);
WebcitAddUrlHandler(HKEY("display_confirm_delete_node"), display_confirm_delete_node, 0);
WebcitAddUrlHandler(HKEY("delete_node"), delete_node, 0);
- RegisterIterator("NODECONFIG", 0, NULL, load_netconf, NodeCfgSubst, DeleteHash, CTX_NODECONF, CTX_NONE, IT_NOFLAG);
+
+
+ RegisterNamespace("CFG:IGNET:NODE", 0, 1, tmplput_NodeName, CTX_NODECONF);
+ RegisterNamespace("CFG:IGNET:SECRET", 0, 1, tmplput_Secret, CTX_NODECONF);
+ RegisterNamespace("CFG:IGNET:HOST", 0, 1, tmplput_Host, CTX_NODECONF);
+ RegisterNamespace("CFG:IGNET:PORT", 0, 1, tmplput_Port, CTX_NODECONF);
+
+ RegisterIterator("NODECONFIG", 0, NULL, load_netconf, NULL, DeleteHash, CTX_NODECONF, CTX_NONE, IT_NOFLAG);
}
/*@}*/
int i;
- wprintf("<div id=\"note-%s\" ", v->uid); // begin outer div
+ wprintf("<div id=\"note-%s\" ", v->uid); /* begin outer div */
wprintf("class=\"stickynote_outer\" ");
wprintf("style=\"");
wprintf("left: %dpx; ", v->pos_left);
- wprintf("<div id=\"titlebar-%s\" ", v->uid); // begin title bar div
+ wprintf("<div id=\"titlebar-%s\" ", v->uid); /* begin title bar div */
wprintf("class=\"stickynote_titlebar\" ");
wprintf("onMouseDown=\"NotesDragMouseDown(event,'%s')\" ", v->uid);
wprintf("style=\"");
*/
void display_note(message_summary *Msg, int unread) {
struct vnote *v;
+ WCTemplputParams TP;
+ memset(&TP, 0, sizeof(WCTemplputParams));
+ TP.ContextType = CTX_VNOTE;
v = vnote_new_from_msg(Msg->msgnum);
if (v) {
// display_vnote_div(v);
+ TP.Context = v;
DoTemplate(HKEY("vnoteitem"),
- WC->WBuf, v, CTX_VNOTE);
+ WC->WBuf, &TP);
/* uncomment these lines to see ugly debugging info
}
-void tmpl_vcard_put_posleft(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_vcard_put_posleft(StrBuf *Target, WCTemplputParams *TP)
{
- struct vnote *v = (struct vnote *) Context;
+ struct vnote *v = (struct vnote *) CTX;
StrBufAppendPrintf(Target, "%d", v->pos_left);
}
-void tmpl_vcard_put_postop(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_vcard_put_postop(StrBuf *Target, WCTemplputParams *TP)
{
- struct vnote *v = (struct vnote *) Context;
+ struct vnote *v = (struct vnote *) CTX;
StrBufAppendPrintf(Target, "%d", v->pos_top);
}
-void tmpl_vcard_put_poswidth(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_vcard_put_poswidth(StrBuf *Target, WCTemplputParams *TP)
{
- struct vnote *v = (struct vnote *) Context;
+ struct vnote *v = (struct vnote *) CTX;
StrBufAppendPrintf(Target, "%d", v->pos_width);
}
-void tmpl_vcard_put_posheight(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_vcard_put_posheight(StrBuf *Target, WCTemplputParams *TP)
{
- struct vnote *v = (struct vnote *) Context;
+ struct vnote *v = (struct vnote *) CTX;
StrBufAppendPrintf(Target, "%d", v->pos_height);
}
-void tmpl_vcard_put_posheight2(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_vcard_put_posheight2(StrBuf *Target, WCTemplputParams *TP)
{
- struct vnote *v = (struct vnote *) Context;
+ struct vnote *v = (struct vnote *) CTX;
StrBufAppendPrintf(Target, "%d", (v->pos_height / 16) - 5);
}
-void tmpl_vcard_put_width2(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_vcard_put_width2(StrBuf *Target, WCTemplputParams *TP)
{
- struct vnote *v = (struct vnote *) Context;
+ struct vnote *v = (struct vnote *) CTX;
StrBufAppendPrintf(Target, "%d", (v->pos_width / 9) - 1);
}
-void tmpl_vcard_put_color(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_vcard_put_color(StrBuf *Target, WCTemplputParams *TP)
{
- struct vnote *v = (struct vnote *) Context;
+ struct vnote *v = (struct vnote *) CTX;
StrBufAppendPrintf(Target, "%02X%02X%02X", v->color_red, v->color_green, v->color_blue);
}
-void tmpl_vcard_put_bgcolor(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_vcard_put_bgcolor(StrBuf *Target, WCTemplputParams *TP)
{
- struct vnote *v = (struct vnote *) Context;
+ struct vnote *v = (struct vnote *) CTX;
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 *Tokens, void *Context, int ContextType)
+void tmpl_vcard_put_message(StrBuf *Target, WCTemplputParams *TP)
{
- struct vnote *v = (struct vnote *) Context;
+ struct vnote *v = (struct vnote *) CTX;
StrEscAppend(Target, NULL, v->body, 0, 0); ///TODO?
}
-void tmpl_vcard_put_uid(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_vcard_put_uid(StrBuf *Target, WCTemplputParams *TP)
{
- struct vnote *v = (struct vnote *) Context;
+ struct vnote *v = (struct vnote *) CTX;
StrBufAppendBufPlain(Target, v->uid, -1, 0);
}
}
else {
- wprintf(_("%s does not permit authentication via OpenID."), serv_info.serv_humannode);
+ wprintf(_("%s does not permit authentication via OpenID."), ChrPtr(serv_info.serv_humannode));
}
do_template("endbox", NULL);
char buf[SIZ];
/** First, check to make sure we're still allowed in this room. */
- serv_printf("GOTO %s", WC->wc_roomname);
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
if (buf[0] != '2') {
- smart_goto("_BASEROOM_");
+ StrBuf *Buf;
+ Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
+ smart_goto(Buf);
+ FreeStrBuf(&Buf);
return;
}
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- serv_printf("USER %s", WC->wc_username);
+ serv_printf("USER %s", ChrPtr(WC->wc_username));
serv_getln(buf, sizeof buf);
if (buf[0] == '3') {
- serv_printf("PASS %s", WC->wc_password);
+ serv_printf("PASS %s", ChrPtr(WC->wc_password));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- serv_printf("GOTO %s", WC->wc_roomname);
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
serv_puts("CHAT");
if (strcasecmp(cl_user, WC->last_chat_user)) {
wprintf("<B>");
- if (!strcasecmp(cl_user, WC->wc_fullname)) {
+ if (!strcasecmp(cl_user, ChrPtr(WC->wc_fullname))) {
wprintf("<FONT COLOR="#FF0000">");
}
else {
-int ConditionalBstr(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalBstr(StrBuf *Target, WCTemplputParams *TP)
{
- if(Tokens->nParameters == 3)
+ if(TP->Tokens->nParameters == 3)
return HaveBstr(TKEY(2));
else {
- if (Tokens->Params[3]->Type == TYPE_LONG)
- return LBstr(TKEY(2)) == Tokens->Params[3]->lvalue;
+ if (TP->Tokens->Params[3]->Type == TYPE_LONG)
+ return LBstr(TKEY(2)) == TP->Tokens->Params[3]->lvalue;
else
return strcmp(Bstr(TKEY(2)),
- Tokens->Params[3]->Start) == 0;
+ TP->Tokens->Params[3]->Start) == 0;
}
}
-void tmplput_bstr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_bstr(StrBuf *Target, WCTemplputParams *TP)
{
const StrBuf *Buf = SBstr(TKEY(0));
if (Buf != NULL)
- StrBufAppendTemplate(Target, nArgs, Tokens,
- Context, ContextType,
- Buf, 1);
+ StrBufAppendTemplate(Target, TP, Buf, 1);
}
void diagnostics(void)
}
-void tmplput_url_part(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_url_part(StrBuf *Target, WCTemplputParams *TP)
{
StrBuf *UrlBuf;
wcsession *WCC = WC;
if (WCC != NULL) {
- if (Tokens->Params[0]->lvalue == 0)
+ if (TP->Tokens->Params[0]->lvalue == 0)
UrlBuf = WCC->UrlFragment1;
- else if (Tokens->Params[0]->lvalue == 1)
+ else if (TP->Tokens->Params[0]->lvalue == 1)
UrlBuf = WCC->UrlFragment2;
else
UrlBuf = WCC->UrlFragment3;
if (UrlBuf == NULL) {
- lprintf(1, "urlbuf [%s] not set. (in '%s' line %ld);[%s]\n",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\nurlbuf [%s] not set (in '%s' line %ld)\n[%s]\n</pre>\n",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
-
-
-
+ LogTemplateError(Target, "urlbuf", ERR_PARM1, TP, "not set.");
}
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType,
- UrlBuf, 2);
+ StrBufAppendTemplate(Target, TP, UrlBuf, 2);
}
}
}
/* Go back to the room we're supposed to be in */
- serv_printf("GOTO %s", WC->wc_roomname);
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
}
}
/** Go back to the room we're supposed to be in */
- serv_printf("GOTO %s", WC->wc_roomname);
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
}
StrBuf *pref_name, *pref_value;
pref_name = NewStrBuf ();
- StrBufPrintf(pref_name, "%s %s", key, WC->wc_roomname);
+ StrBufPrintf(pref_name, "%s %s", key, ChrPtr(WC->wc_roomname));
get_pref(pref_name, &pref_value);
FreeStrBuf(&pref_name);
return pref_value;
StrBuf *pref_name;
pref_name = NewStrBuf ();
- StrBufPrintf(pref_name, "%s %s", key, WC->wc_roomname);
+ StrBufPrintf(pref_name, "%s %s", key, ChrPtr(WC->wc_roomname));
set_PREFERENCE(ChrPtr(pref_name), StrLength(pref_name), value, save_to_server);
FreeStrBuf(&pref_name);
}
/*
* Offer to make any page the user's "start page."
*/
-void offer_start_page(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) {
+void offer_start_page(StrBuf *Target, WCTemplputParams *TP)
+{
wprintf("<a href=\"change_start_page?startpage=");
urlescputs(WC->this_page);
wprintf("\">");
wprintf("</a>");
#ifdef TECH_PREVIEW
wprintf("<br/><a href=\"rss?room=");
- urlescputs(WC->wc_roomname);
+ urlescputs(ChrPtr(WC->wc_roomname));
wprintf("\" title=\"RSS 2.0 feed for ");
- escputs(WC->wc_roomname);
+ escputs(ChrPtr(WC->wc_roomname));
wprintf("\"><img alt=\"RSS\" border=\"0\" src=\"static/xml_button.gif\"/></a>\n");
#endif
}
#define PRF_YESNO 4
-void tmplput_CFG_Value(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_CFG_Value(StrBuf *Target, WCTemplputParams *TP)
{
StrBuf *Setting;
if (get_PREFERENCE(TKEY(0), &Setting))
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Setting, 1);
+ StrBufAppendTemplate(Target, TP, Setting, 1);
}
-void tmplput_CFG_Descr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_CFG_Descr(StrBuf *Target, WCTemplputParams *TP)
{
const char *SettingStr;
SettingStr = PrefGetLocalStr(TKEY(0));
}
-void CfgZoneTempl(StrBuf *TemplBuffer, void *vContext, WCTemplateToken *Token)
+void CfgZoneTempl(StrBuf *TemplBuffer, WCTemplputParams *TP)
{
- StrBuf *Zone = (StrBuf*) vContext;
+ StrBuf *Zone = (StrBuf*) CTX;
SVPutBuf("ZONENAME", Zone, 1);
}
-int ConditionalPreference(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalPreference(StrBuf *Target, WCTemplputParams *TP)
{
StrBuf *Pref;
if (!get_PREFERENCE(TKEY(2), &Pref))
return 0;
- if (Tokens->nParameters == 3) {
+ if (TP->Tokens->nParameters == 3) {
return 1;
}
- else if (Tokens->Params[3]->Type == TYPE_STR)
- return ((Tokens->Params[3]->len == StrLength(Pref)) &&
- (strcmp(Tokens->Params[3]->Start, ChrPtr(Pref)) == 0));
+ else if (TP->Tokens->Params[3]->Type == TYPE_STR)
+ return ((TP->Tokens->Params[3]->len == StrLength(Pref)) &&
+ (strcmp(TP->Tokens->Params[3]->Start, ChrPtr(Pref)) == 0));
else
- return (StrTol(Pref) == Tokens->Params[3]->lvalue);
+ return (StrTol(Pref) == TP->Tokens->Params[3]->lvalue);
}
-int ConditionalHazePreference(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalHazePreference(StrBuf *Target, WCTemplputParams *TP)
{
StrBuf *Pref;
return 1;
}
-HashList *GetGVEAHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *GetGVEAHash(StrBuf *Target, WCTemplputParams *TP)
{
StrBuf *Rcp;
HashList *List = NULL;
Rcp = NewStrBuf();
serv_puts("GVEA");
StrBuf_ServGetln(Rcp);
- if (ChrPtr(Rcp)[0] == '1') {
+ if (GetServerStatus(Rcp, NULL) == 1) {
FlushStrBuf(Rcp);
List = NewHash(1, NULL);
while (!Done && (StrBuf_ServGetln(Rcp)>=0)) {
DeleteHash(KillMe);
}
-HashList *GetGVSNHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *GetGVSNHash(StrBuf *Target, WCTemplputParams *TP)
{
StrBuf *Rcp;
HashList *List = NULL;
Rcp = NewStrBuf();
serv_puts("GVSN");
StrBuf_ServGetln(Rcp);
- if (ChrPtr(Rcp)[0] == '1') {
+ if (GetServerStatus(Rcp, NULL) == 1) {
FlushStrBuf(Rcp);
List = NewHash(1, NULL);
while (!Done && (StrBuf_ServGetln(Rcp)>=0)) {
RegisterPreference("defaultfrom", _("Preferred email address"), PRF_STRING);
RegisterPreference("defaultname", _("Preferred display name for email messages"), PRF_STRING);
RegisterPreference("defaulthandle", _("Preferred display name for bulletin board posts"), PRF_STRING);
-
+ RegisterNamespace("OFFERSTARTPAGE", 0, 0, offer_start_page, CTX_NONE);
RegisterNamespace("PREF:VALUE", 1, 2, tmplput_CFG_Value, CTX_NONE);
RegisterNamespace("PREF:DESCR", 1, 1, tmplput_CFG_Descr, CTX_NONE);
RegisterIterator("PREF:ZONE", 0, ZoneHash, NULL, CfgZoneTempl, NULL, CTX_PREF, CTX_NONE, IT_NOFLAG);
} else if (is_funambol) {
svput("PUSH_FNBL", WCS_STRING, "checked=\"checked\"");
}
- serv_printf("GOTO %s", WC->wc_roomname);
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
}
output_headers(1, 1, 2, 0, 0, 0);
}
/** Go back to the room we're supposed to be in */
- serv_printf("GOTO %s", WC->wc_roomname);
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
http_redirect("display_pushemail");
}
/*
* remove a room from the march list
*/
-void remove_march(char *aaa)
+void remove_march(const StrBuf *aaa)
{
struct march *mptr, *mptr2;
if (WC->march == NULL)
return;
- if (!strcasecmp(WC->march->march_name, aaa)) {
+ if (!strcasecmp(WC->march->march_name, ChrPtr(aaa))) {
mptr = WC->march->next;
free(WC->march);
WC->march = mptr;
}
mptr2 = WC->march;
for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
- if (!strcasecmp(mptr->march_name, aaa)) {
+ if (!strcasecmp(mptr->march_name, ChrPtr(aaa))) {
mptr2->next = mptr->next;
free(mptr);
mptr = mptr2;
*/
void zapped_list(void)
{
+ WCTemplputParams SubTP;
StrBuf *Buf;
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
- DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF);
+ SubTP.ContextType = CTX_STRBUF;
+ SubTP.Context = Buf;
+ DoTemplate(HKEY("beginbox"), NULL, &SubTP);
FreeStrBuf(&Buf);
/**
* \brief read this room's info file (set v to 1 for verbose mode)
*/
-void readinfo(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void readinfo(StrBuf *Target, WCTemplputParams *TP)
{
char buf[256];
char briefinfo[128];
* keep the browser from using a cached icon from
* another room.
*/
-void embed_room_graphic(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) {
+void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
+{
char buf[SIZ];
serv_puts("OIMG _roompic_");
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
wprintf("<img height=\"64px\" src=\"image&name=_roompic_&room=");
- urlescputs(WC->wc_roomname);
+ urlescputs(ChrPtr(WC->wc_roomname));
wprintf("\">");
serv_puts("CLOS");
serv_getln(buf, sizeof buf);
/**
* \brief Display the current view and offer an option to change it
*/
-void embed_view_o_matic(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) {
+void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
+{
int i;
wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
/**
* \brief Display a search box
*/
-void embed_search_o_matic(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) {
+void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP)
+{
wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
wprintf("<label for=\"search_name\">");
* If it isn't supplied, we fake it by issuing our own GOTO.
*/
if (got == NULL) {
- memset(buf, 20, '0');
+ memset(buf, '0', 20);
buf[20] = '\0';
- serv_printf("GOTO %s", WC->wc_roomname);
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
got = buf;
}
* a "skip" or "gotonext" or something like that.
*/
snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
- WC->wc_roomname);
+ ChrPtr(WC->wc_roomname));
/** Check for new mail. */
WC->new_mail = extract_int(&got[4], 9);
/*
* back end routine to take the session to a new room
*/
-int gotoroom(char *gname)
+long gotoroom(const StrBuf *gname)
{
+ StrBuf *Buf;
char buf[SIZ];
static long ls = (-1L);
- int err = 0;
+ long err = 0;
/* store ungoto information */
- strcpy(WC->ugname, WC->wc_roomname);
+ strcpy(WC->ugname, ChrPtr(WC->wc_roomname));
WC->uglsn = ls;
-
+ Buf = NewStrBuf();
/** move to the new room */
- serv_printf("GOTO %s", gname);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- buf[3] = 0;
- err = atoi(buf);
- serv_puts("GOTO _BASEROOM_");
- serv_getln(buf, sizeof buf);
- }
- if (buf[0] != '2') {
- buf[3] = 0;
- err = atoi(buf);
+ serv_printf("GOTO %s", ChrPtr(gname));
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, &err) != 2) {
+ FreeStrBuf(&Buf);
return err;
}
- extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
- WC->room_flags = extract_int(&buf[4], 4);
+
+ serv_puts("GOTO _BASEROOM_");
+ serv_getln(buf, sizeof buf);
+
+ if (WC->wc_roomname == NULL)
+ WC->wc_roomname = NewStrBuf();
+ else
+ FlushStrBuf(WC->wc_roomname);
+
+ StrBufExtract_token(WC->wc_roomname, Buf, 0, '|');
+ StrBufCutLeft(WC->wc_roomname, 4);
+ WC->room_flags = StrBufExtract_int(Buf, 4, '|');
/* highest_msg_read = extract_int(&buf[4],6);
maxmsgnum = extract_int(&buf[4],5);
*/
- WC->is_mailbox = extract_int(&buf[4],7);
- ls = extract_long(&buf[4], 6);
- WC->wc_floor = extract_int(&buf[4], 10);
- WC->wc_view = extract_int(&buf[4], 11);
- WC->wc_default_view = extract_int(&buf[4], 12);
- WC->wc_is_trash = extract_int(&buf[4], 13);
- WC->room_flags2 = extract_int(&buf[4], 14);
+ WC->is_mailbox = StrBufExtract_int(Buf, 7, '|');
+ ls = StrBufExtract_long(Buf, 6, '|');
+ WC->wc_floor = StrBufExtract_int(Buf, 10, '|');
+ WC->wc_view = StrBufExtract_int(Buf, 11, '|');
+ WC->wc_default_view = StrBufExtract_int(Buf, 12, '|');
+ WC->wc_is_trash = StrBufExtract_int(Buf, 13, '|');
+ WC->room_flags2 = StrBufExtract_int(Buf, 14, '|');
if (WC->is_aide)
WC->is_room_aide = WC->is_aide;
else
- WC->is_room_aide = (char) extract_int(&buf[4], 8);
+ WC->is_room_aide = (char) StrBufExtract_int(Buf, 8, '|');
remove_march(WC->wc_roomname);
- if (!strcasecmp(gname, "_BASEROOM_"))
+ if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
remove_march(gname);
+ FreeStrBuf(&Buf);
return err;
}
struct march *mptr = NULL;
struct march *mptr2 = NULL;
char room_name[128];
- char next_room[128];
+ StrBuf *next_room;
int ELoop = 0;
/*
continue;
}
extract_token(room_name, buf, 0, '|', sizeof room_name);
- if (strcasecmp(room_name, WC->wc_roomname)) {
+ if (strcasecmp(room_name, ChrPtr(WC->wc_roomname))) {
mptr = (struct march *) malloc(sizeof(struct march));
mptr->next = NULL;
safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
remove_march(WC->wc_roomname);
}
if (WC->march != NULL) {
- strcpy(next_room, pop_march(-1));
+ next_room = NewStrBufPlain(pop_march(-1), -1);/*TODO: migrate march to strbuf */
} else {
- strcpy(next_room, "_BASEROOM_");
+ next_room = NewStrBufPlain(HKEY("_BASEROOM_"));
}
smart_goto(next_room);
+ FreeStrBuf(&next_room);
}
/*
* goto next room
*/
-void smart_goto(char *next_room) {
+void smart_goto(const StrBuf *next_room) {
gotoroom(next_room);
readloop(readnew);
}
*/
void ungoto(void)
{
- char buf[SIZ];
+ StrBuf *Buf;
if (!strcmp(WC->ugname, "")) {
smart_goto(WC->wc_roomname);
return;
}
serv_printf("GOTO %s", WC->ugname);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
+ Buf = NewStrBuf();
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) != 2) {
smart_goto(WC->wc_roomname);
+ FreeStrBuf(&Buf);
return;
}
if (WC->uglsn >= 0L) {
serv_printf("SLRP %ld", WC->uglsn);
- serv_getln(buf, sizeof buf);
+ StrBuf_ServGetln(Buf);
}
- strcpy(buf, WC->ugname);
+ FlushStrBuf(Buf);
+ StrBufAppendBufPlain(Buf, WC->ugname, -1, 0);
strcpy(WC->ugname, "");
- smart_goto(buf);
+ smart_goto(Buf);
+ FreeStrBuf(&Buf);
}
typedef struct __room_states {
wprintf("<tr><td>");
wprintf(_("Message expire policy for this room"));
wprintf("<br />(");
- escputs(WC->wc_roomname);
+ escputs(ChrPtr(WC->wc_roomname));
wprintf(")</td><td>");
wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
((roompolicy == 0) ? "CHECKED" : "") );
*/
void editroom(void)
{
- char buf[SIZ];
- char er_name[128];
- char er_password[10];
- char er_dirname[15];
- char er_roomaide[26];
+ const StrBuf *Ptr;
+ StrBuf *Buf;
+ StrBuf *er_name;
+ StrBuf *er_password;
+ StrBuf *er_dirname;
+ StrBuf *er_roomaide;
int er_floor;
unsigned er_flags;
int er_listingorder;
return;
}
serv_puts("GETR");
- serv_getln(buf, sizeof buf);
-
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
+ Buf = NewStrBuf();
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) != 2) {
+ StrBufCutLeft(Buf, 4);
+ strcpy(WC->ImportantMessage, ChrPtr(Buf));
display_editroom();
+ FreeStrBuf(&Buf);
return;
}
- extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
- extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
- extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
- er_flags = extract_int(&buf[4], 3);
- er_listingorder = extract_int(&buf[4], 5);
- er_defaultview = extract_int(&buf[4], 6);
- er_flags2 = extract_int(&buf[4], 7);
-
- strcpy(er_roomaide, bstr("er_roomaide"));
- if (IsEmptyStr(er_roomaide)) {
+ StrBufCutLeft(Buf, 4);
+ StrBufExtract_token(er_name, Buf, 0, '|');
+ StrBufExtract_token(er_password, Buf, 1, '|');
+ StrBufExtract_token(er_dirname, Buf, 2, '|');
+ er_flags = StrBufExtract_int(Buf, 3, '|');
+ er_listingorder = StrBufExtract_int(Buf, 5, '|');
+ er_defaultview = StrBufExtract_int(Buf, 6, '|');
+ er_flags2 = StrBufExtract_int(Buf, 7, '|');
+
+ er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
+ if (StrLength(er_roomaide) == 0) {
serv_puts("GETA");
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- strcpy(er_roomaide, "");
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) != 2) {
+ FlushStrBuf(er_roomaide);
} else {
- extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
+ StrBufCutLeft(Buf, 4);
+ StrBufExtract_token(er_roomaide, Buf, 0, '|');
}
}
- strcpy(buf, bstr("er_name"));
- buf[128] = 0;
- if (!IsEmptyStr(buf)) {
- strcpy(er_name, buf);
+ Ptr = sbstr("er_name");
+ if (StrLength(Ptr) > 0) {
+ FlushStrBuf(er_name);
+ StrBufAppendBuf(er_name, Ptr, 0);
+ }
+
+ Ptr = sbstr("er_password");
+ if (StrLength(Ptr) > 0) {
+ FlushStrBuf(er_password);
+ StrBufAppendBuf(er_password, Ptr, 0);
}
+
- strcpy(buf, bstr("er_password"));
- buf[10] = 0;
- if (!IsEmptyStr(buf))
- strcpy(er_password, buf);
+ Ptr = sbstr("er_dirname");
+ if (StrLength(Ptr) > 0) { /* todo: cut 15 */
+ FlushStrBuf(er_dirname);
+ StrBufAppendBuf(er_dirname, Ptr, 0);
+ }
- strcpy(buf, bstr("er_dirname"));
- buf[15] = 0;
- if (!IsEmptyStr(buf))
- strcpy(er_dirname, buf);
- strcpy(buf, bstr("type"));
+ Ptr = sbstr("type");
er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
- if (!strcmp(buf, "invonly")) {
+ if (!strcmp(ChrPtr(Ptr), "invonly")) {
er_flags |= (QR_PRIVATE);
}
- if (!strcmp(buf, "hidden")) {
+ if (!strcmp(ChrPtr(Ptr), "hidden")) {
er_flags |= (QR_PRIVATE | QR_GUESSNAME);
}
- if (!strcmp(buf, "passworded")) {
+ if (!strcmp(ChrPtr(Ptr), "passworded")) {
er_flags |= (QR_PRIVATE | QR_PASSWORDED);
}
- if (!strcmp(buf, "personal")) {
+ if (!strcmp(ChrPtr(Ptr), "personal")) {
er_flags |= QR_MAILBOX;
} else {
er_flags &= ~QR_MAILBOX;
er_flags &= ~QR_VISDIR;
}
- strcpy(buf, bstr("anon"));
+ Ptr = sbstr("anon");
er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
- if (!strcmp(buf, "anononly"))
+ if (!strcmp(ChrPtr(Ptr), "anononly"))
er_flags |= QR_ANONONLY;
- if (!strcmp(buf, "anon2"))
+ if (!strcmp(ChrPtr(Ptr), "anon2"))
er_flags |= QR_ANONOPT;
- bump = 0;
- if (!strcmp(bstr("bump"), "yes"))
- bump = 1;
+ bump = yesbstr("bump");
er_floor = ibstr("er_floor");
- sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
- er_name, er_password, er_dirname, er_flags, bump, er_floor,
- er_listingorder, er_defaultview, er_flags2);
- serv_puts(buf);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
+ StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
+ ChrPtr(er_name),
+ ChrPtr(er_password),
+ ChrPtr(er_dirname),
+ er_flags,
+ bump,
+ er_floor,
+ er_listingorder,
+ er_defaultview,
+ er_flags2);
+ serv_putbuf(Buf);
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) != 2) {
+ strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
display_editroom();
+ FreeStrBuf(&Buf);
+ FreeStrBuf(&er_name);
+ FreeStrBuf(&er_password);
+ FreeStrBuf(&er_dirname);
+ FreeStrBuf(&er_roomaide);
return;
}
gotoroom(er_name);
- if (!IsEmptyStr(er_roomaide)) {
- sprintf(buf, "SETA %s", er_roomaide);
- serv_puts(buf);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
+ if (StrLength(er_roomaide) > 0) {
+ serv_printf("SETA %s", ChrPtr(er_roomaide));
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) != 2) {
+ strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
display_main_menu();
+ FreeStrBuf(&Buf);
+ FreeStrBuf(&er_name);
+ FreeStrBuf(&er_password);
+ FreeStrBuf(&er_dirname);
+ FreeStrBuf(&er_roomaide);
return;
}
}
gotoroom(er_name);
strcpy(WC->ImportantMessage, _("Your changes have been saved."));
display_editroom();
+ FreeStrBuf(&Buf);
+ FreeStrBuf(&er_name);
+ FreeStrBuf(&er_password);
+ FreeStrBuf(&er_dirname);
+ FreeStrBuf(&er_roomaide);
return;
}
void entroom(void)
{
char buf[SIZ];
- char er_name[SIZ];
- char er_type[SIZ];
- char er_password[SIZ];
+ const StrBuf *er_name;
+ const StrBuf *er_type;
+ const StrBuf *er_password;
int er_floor;
int er_num_type;
int er_view;
display_main_menu();
return;
}
- strcpy(er_name, bstr("er_name"));
- strcpy(er_type, bstr("type"));
- strcpy(er_password, bstr("er_password"));
+ er_name = sbstr("er_name");
+ er_type = sbstr("type");
+ er_password = sbstr("er_password");
er_floor = ibstr("er_floor");
er_view = ibstr("er_view");
er_num_type = 0;
- if (!strcmp(er_type, "hidden"))
+ if (!strcmp(ChrPtr(er_type), "hidden"))
er_num_type = 1;
- if (!strcmp(er_type, "passworded"))
+ else if (!strcmp(ChrPtr(er_type), "passworded"))
er_num_type = 2;
- if (!strcmp(er_type, "invonly"))
+ else if (!strcmp(ChrPtr(er_type), "invonly"))
er_num_type = 3;
- if (!strcmp(er_type, "personal"))
+ else if (!strcmp(ChrPtr(er_type), "personal"))
er_num_type = 4;
- sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
- er_name, er_num_type, er_password, er_floor, 0, er_view);
- serv_puts(buf);
+ serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
+ ChrPtr(er_name),
+ er_num_type,
+ ChrPtr(er_password),
+ er_floor,
+ 0,
+ er_view);
+
serv_getln(buf, sizeof buf);
if (buf[0] != '2') {
strcpy(WC->ImportantMessage, &buf[4]);
*/
void display_private(char *rname, int req_pass)
{
+ WCTemplputParams SubTP;
StrBuf *Buf;
output_headers(1, 1, 1, 0, 0, 0);
Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
- DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_STRBUF;
+ SubTP.Context = Buf;
+ DoTemplate(HKEY("beginbox"), NULL, &SubTP);
FreeStrBuf(&Buf);
display_main_menu();
return;
}
- strcpy(hold_rm, WC->wc_roomname);
- strcpy(buf, "GOTO ");
- strcat(buf, bstr("gr_name"));
- strcat(buf, "|");
- strcat(buf, bstr("gr_pass"));
- serv_puts(buf);
+ strcpy(hold_rm, ChrPtr(WC->wc_roomname));
+ serv_printf("GOTO %s|%s",
+ bstr("gr_name"),
+ bstr("gr_pass"));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- smart_goto(bstr("gr_name"));
+ smart_goto(sbstr("gr_name"));
return;
}
if (!strncmp(buf, "540", 3)) {
wprintf("<div id=\"content\" class=\"service\">\n");
wprintf(_("If you select this option, <em>%s</em> will "
- "disappear from your room list. Is this what you wish "
- "to do?<br />\n"), WC->wc_roomname);
+ "disappear from your room list. Is this what you wish "
+ "to do?<br />\n"), ChrPtr(WC->wc_roomname));
wprintf("<form method=\"POST\" action=\"zap\">\n");
wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
void zap(void)
{
char buf[SIZ];
- char final_destination[SIZ];
+ StrBuf *final_destination;
/**
* If the forget-room routine fails for any reason, we fall back
* to the current room; otherwise, we go to the Lobby
*/
- strcpy(final_destination, WC->wc_roomname);
+ final_destination = NewStrBufDup(WC->wc_roomname);
if (havebstr("ok_button")) {
- serv_printf("GOTO %s", WC->wc_roomname);
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
serv_puts("FORG");
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- strcpy(final_destination, "_BASEROOM_");
+ FlushStrBuf(final_destination);
+ StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
}
}
}
smart_goto(final_destination);
+ FreeStrBuf(&final_destination);
}
display_main_menu();
return;
} else {
- smart_goto("_BASEROOM_");
+ StrBuf *Buf;
+
+ Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
+ smart_goto(Buf);
+ FreeStrBuf(&Buf);
}
}
if (levels == 1) {
StrBuf *Buf;
-
+ WCTemplputParams SubTP;
+
Buf = NewStrBufPlain(floor_name, -1);
- DoTemplate(HKEY("beginbox"), NULL, Buf, CTX_STRBUF);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_STRBUF;
+ SubTP.Context = Buf;
+ DoTemplate(HKEY("beginbox"), NULL, &SubTP);
FreeStrBuf(&Buf);
}
/** offer the ability to switch views */
wprintf("<ul class=\"room_actions\">\n");
wprintf("<li class=\"start_page\">");
- offer_start_page(NULL, 0, NULL, NULL, CTX_NONE);
+ offer_start_page(NULL, &NoCtx);
wprintf("</li>");
wprintf("<li><form name=\"roomlistomatic\">\n"
"<select name=\"newview\" size=\"1\" "
}
-void tmplput_RoomName(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
{
- StrBuf *tmp;
- tmp = NewStrBufPlain(WC->wc_roomname, -1);;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, tmp, 0);
- FreeStrBuf(&tmp);
+ StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
}
void _gotonext(void) { slrp_highest(); gotonext(); }
-void dotskip(void) {smart_goto(bstr("room"));}
+void dotskip(void) {smart_goto(sbstr("room"));}
void _display_private(void) { display_private("", 0); }
void dotgoto(void) {
if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
slrp_highest();
}
- smart_goto(bstr("room"));
+ smart_goto(sbstr("room"));
}
-void tmplput_roombanner(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
{
wprintf("<div id=\"banner\">\n");
embed_room_banner(NULL, navbar_default);
}
-void tmplput_ungoto(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
}
-int ConditionalHaveUngoto(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
return ((WCC!=NULL) &&
(!IsEmptyStr(WCC->ugname)) &&
- (strcasecmp(WCC->ugname, WCC->wc_roomname) == 0));
+ (strcasecmp(WCC->ugname, ChrPtr(WCC->wc_roomname)) == 0));
}
-
-
-
-int ConditionalRoomHas_QR_PERMANENT(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_PERMANENT(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_PERMANENT) != 0));
}
-int ConditionalRoomHas_QR_INUSE(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_INUSE(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_INUSE) != 0));
}
-int ConditionalRoomHas_QR_PRIVATE(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_PRIVATE(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_PRIVATE) != 0));
}
-int ConditionalRoomHas_QR_PASSWORDED(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_PASSWORDED(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_PASSWORDED) != 0));
}
-int ConditionalRoomHas_QR_GUESSNAME(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_GUESSNAME(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_GUESSNAME) != 0));
}
-int ConditionalRoomHas_QR_DIRECTORY(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_DIRECTORY(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_DIRECTORY) != 0));
}
-int ConditionalRoomHas_QR_UPLOAD(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_UPLOAD(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_UPLOAD) != 0));
}
-int ConditionalRoomHas_QR_DOWNLOAD(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_DOWNLOAD(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_DOWNLOAD) != 0));
}
-int ConditionalRoomHas_QR_VISDIR(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_VISDIR(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_VISDIR) != 0));
}
-int ConditionalRoomHas_QR_ANONONLY(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_ANONONLY(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_ANONONLY) != 0));
}
-int ConditionalRoomHas_QR_ANONOPT(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_ANONOPT(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_ANONOPT) != 0));
}
-int ConditionalRoomHas_QR_NETWORK(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_NETWORK(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_NETWORK) != 0));
}
-int ConditionalRoomHas_QR_PREFONLY(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_PREFONLY(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_PREFONLY) != 0));
}
-int ConditionalRoomHas_QR_READONLY(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_READONLY(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
((WCC->room_flags & QR_READONLY) != 0));
}
-int ConditionalRoomHas_QR_MAILBOX(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalRoomHas_QR_MAILBOX(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
}
-
-
-
-
-int ConditionalHaveRoomeditRights(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
* roomname the room we sould print out as rss
* request_method the way the rss is requested????
*/
-void display_rss(char *roomname, StrBuf *request_method)
+void display_rss(const StrBuf *roomname, StrBuf *request_method)
{
message_summary *Msg;
wcsession *WCC = WC;
if (!WCC->logged_in) {
#ifdef ALLOW_ANON_RSS
+ StrBuf *User;
+ StrBuf *Pass;
+ StrBuf *Buf;
serv_printf("USER %s", ANON_RSS_USER);
serv_getln(buf, sizeof buf);
serv_printf("PASS %s", ANON_RSS_PASS);
- serv_getln(buf, sizeof buf);
- become_logged_in(ANON_RSS_USER, ANON_RSS_PASS, buf);
+
+ StrBuf_ServGetln(Buf);
+ User = NewStrBufPlain(HKEY(ANON_RSS_USER));
+ Pass = NewStrBufPlain(HKEY(ANON_RSS_PASS));
+ become_logged_in(User, Pass, Buf);
WCC->killthis = 1;
+ FreeStrBuf(&User);
+ FreeStrBuf(&Pass);
+ FreeStrBuf(&Buf);
#else
authorization_required(_("Not logged in"));
return;
#endif
}
- if (gotoroom((char *)roomname)) {
+ if (gotoroom(roomname)) {
lprintf(3, "RSS: Can't goto requested room\n");
hprintf("HTTP/1.1 404 Not Found\r\n");
hprintf("Content-Type: text/html\r\n");
/* <?xml.. etc confuses our subst parser, so do it here */
svput("XML_HEAD", WCS_STRING, "<?xml version=\"1.0\" ?>");
svput("XML_STYLE", WCS_STRING, "<?xml-stylesheet type=\"text/css\" href=\"/static/rss_browser.css\" ?>");
- svput("ROOM", WCS_STRING, WCC->wc_roomname);
- svput("NODE", WCS_STRING, serv_info.serv_humannode);
+ SVPutBuf("ROOM", WCC->wc_roomname, 1);
+ SVPutBuf("NODE", serv_info.serv_humannode, 1);
/* TODO: Fix me */
svprintf(HKEY("ROOM_LINK"), WCS_STRING, "%s://%s/", (is_https ? "https" : "http"), WCC->http_host);
svput("SUBJ", WCS_STRING, _("From"));
}
svprintf(HKEY("IN_ROOM"), WCS_STRING, _("%s in %s"), from, room);
- if (strcmp(hnod, serv_info.serv_humannode) && !IsEmptyStr(hnod)) {
+ if (strcmp(hnod, ChrPtr(serv_info.serv_humannode)) && !IsEmptyStr(hnod)) {
svprintf(HKEY("NODE"), WCS_STRING, _(" on %s"), hnod);
}
if (now) {
*/
void get_serv_info(char *browser_host, char *user_agent)
{
+ StrBuf *Buf;
char buf[SIZ];
int a;
return;
a = 0;
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ Buf = NewStrBuf();
+ while (StrBuf_ServGetln(Buf), (strcmp(ChrPtr(Buf), "000")!= 0)) {
+/* lprintf (1, "a: %d [%s]", a, ChrPtr(Buf));*/
switch (a) {
case 0:
- serv_info.serv_pid = atoi(buf);
+ serv_info.serv_pid = StrToi(Buf);
WC->ctdl_pid = serv_info.serv_pid;
break;
case 1:
- safestrncpy(serv_info.serv_nodename, buf, sizeof serv_info.serv_nodename);
+ serv_info.serv_nodename = NewStrBufDup(Buf);
break;
case 2:
- safestrncpy(serv_info.serv_humannode, buf, sizeof serv_info.serv_humannode);
+ serv_info.serv_humannode = NewStrBufDup(Buf);
break;
case 3:
- safestrncpy(serv_info.serv_fqdn, buf, sizeof serv_info.serv_fqdn);
+ serv_info.serv_fqdn = NewStrBufDup(Buf);
break;
case 4:
- safestrncpy(serv_info.serv_software, buf, sizeof serv_info.serv_software);
+ serv_info.serv_software = NewStrBufDup(Buf);
break;
case 5:
- serv_info.serv_rev_level = atoi(buf);
+ serv_info.serv_rev_level = StrToi(Buf);
break;
case 6:
- safestrncpy(serv_info.serv_bbs_city, buf, sizeof serv_info.serv_bbs_city);
+ serv_info.serv_bbs_city = NewStrBufDup(Buf);
break;
case 7:
- safestrncpy(serv_info.serv_sysadm, buf, sizeof serv_info.serv_sysadm);
+ serv_info.serv_sysadm = NewStrBufDup(Buf);
break;
case 9:
- safestrncpy(serv_info.serv_moreprompt, buf, sizeof serv_info.serv_moreprompt);
+ serv_info.serv_moreprompt = NewStrBufDup(Buf);
break;
case 14:
- serv_info.serv_supports_ldap = atoi(buf);
+ serv_info.serv_supports_ldap = StrToi(Buf);
break;
case 15:
- serv_info.serv_newuser_disabled = atoi(buf);
+ serv_info.serv_newuser_disabled = StrToi(Buf);
break;
case 16:
- safestrncpy(serv_info.serv_default_cal_zone, buf, sizeof serv_info.serv_default_cal_zone);
+ serv_info.serv_default_cal_zone = NewStrBufDup(Buf);
break;
case 20:
- serv_info.serv_supports_sieve = atoi(buf);
+ serv_info.serv_supports_sieve = StrToi(Buf);
break;
case 21:
- serv_info.serv_fulltext_enabled = atoi(buf);
+ serv_info.serv_fulltext_enabled = StrToi(Buf);
break;
case 22:
- safestrncpy(serv_info.serv_svn_revision, buf, sizeof serv_info.serv_svn_revision);
+ serv_info.serv_svn_revision = NewStrBufDup(Buf);
break;
case 23:
- serv_info.serv_supports_openid = atoi(buf);
+ serv_info.serv_supports_openid = StrToi(Buf);
break;
}
++a;
serv_printf("READ %d|%d", (int)bytes, (int)thisblock);
if (StrBuf_ServGetln(Buf) > 0)
{
- if (ChrPtr(Buf)[0] == '6')
- {
+ if (GetServerStatus(Buf, NULL) == 6)
+ {
StrBufCutLeft(Buf, 4); /*/ TODO : thisblock = (size_t)atoi(&buf[4]); */
thisblock = StrTol(Buf);
if (!WC->connected) {
}
-void tmplput_serv_ip(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_serv_ip(StrBuf *Target, WCTemplputParams *TP)
{
StrBufAppendPrintf(Target, "%d", WC->ctdl_pid);
}
-void tmplput_serv_nodename(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_serv_nodename(StrBuf *Target, WCTemplputParams *TP)
{
- StrEscAppend(Target, NULL, serv_info.serv_nodename, 0, 0);
+ StrBufAppendTemplate(Target, TP, serv_info.serv_nodename, 0);
}
-void tmplput_serv_humannode(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_serv_humannode(StrBuf *Target, WCTemplputParams *TP)
{
- StrEscAppend(Target, NULL, serv_info.serv_humannode, 0, 0);
+ StrBufAppendTemplate(Target, TP, serv_info.serv_humannode, 0);
}
-void tmplput_serv_fqdn(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_serv_fqdn(StrBuf *Target, WCTemplputParams *TP)
{
- StrEscAppend(Target, NULL, serv_info.serv_fqdn, 0, 0);
+ StrBufAppendTemplate(Target, TP, serv_info.serv_fqdn, 0);
}
-void tmplput_serv_software(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_serv_software(StrBuf *Target, WCTemplputParams *TP)
{
- StrEscAppend(Target, NULL, serv_info.serv_software, 0, 0);
+ StrBufAppendTemplate(Target, TP, serv_info.serv_software, 0);
}
-void tmplput_serv_rev_level(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_serv_rev_level(StrBuf *Target, WCTemplputParams *TP)
{
StrBufAppendPrintf(Target, "%d.%02d",
serv_info.serv_rev_level / 100,
serv_info.serv_rev_level % 100);
}
-int conditional_serv_newuser_disabled(WCTemplateToken *Tokens, void *Context, int ContextType)
+int conditional_serv_newuser_disabled(StrBuf *Target, WCTemplputParams *TP)
{
return serv_info.serv_newuser_disabled != 0;
}
-int conditional_serv_supports_openid(WCTemplateToken *Tokens, void *Context, int ContextType)
+int conditional_serv_supports_openid(StrBuf *Target, WCTemplputParams *TP)
{
return serv_info.serv_supports_openid != 0;
}
-void tmplput_serv_bbs_city(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
-{
- StrEscAppend(Target, NULL, serv_info.serv_bbs_city, 0, 0);
-}
-
-void tmplput_current_user(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
-{
- StrEscAppend(Target, NULL, WC->wc_fullname, 0, 0);
-}
-
-void tmplput_current_room(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_serv_bbs_city(StrBuf *Target, WCTemplputParams *TP)
{
- StrEscAppend(Target, NULL, WC->wc_roomname, 0, 0);
+ StrBufAppendTemplate(Target, TP, serv_info.serv_bbs_city, 0);
}
-void tmplput_mesg(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_mesg(StrBuf *Target, WCTemplputParams *TP)
{
int n = 0;
int Done = 0;
Buf = NewStrBuf();
Line = NewStrBuf();
- serv_printf("MESG %s", Tokens->Params[0]->Start);
+ serv_printf("MESG %s", TP->Tokens->Params[0]->Start);
StrBuf_ServGetln(Line);
while (!Done && (StrBuf_ServGetln(Line)>=0)) {
if ( (StrLength(Line)==3) &&
}
FlushStrBuf(Line);
FmOut(Line, "center", Buf);
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Line, 1);
+ StrBufAppendTemplate(Target, TP, Line, 1);
FreeStrBuf(&Buf);
FreeStrBuf(&Line);
}
RegisterConditional(HKEY("COND:SERV:OPENID"), 2, conditional_serv_supports_openid, CTX_NONE);
RegisterConditional(HKEY("COND:SERV:NEWU"), 2, conditional_serv_newuser_disabled, CTX_NONE);
- RegisterNamespace("CURRENT_USER", 0, 0, tmplput_current_user, CTX_NONE);
- RegisterNamespace("CURRENT_ROOM", 0, 0, tmplput_current_room, CTX_NONE);
RegisterNamespace("SERV:PID", 0, 0, tmplput_serv_ip, CTX_NONE);
- RegisterNamespace("SERV:NODENAME", 0, 0, tmplput_serv_nodename, CTX_NONE);
- RegisterNamespace("SERV:HUMANNODE", 0, 0, tmplput_serv_humannode, CTX_NONE);
- RegisterNamespace("SERV:FQDN", 0, 0, tmplput_serv_fqdn, CTX_NONE);
- RegisterNamespace("SERV:SOFTWARE", 0, 0, tmplput_serv_software, CTX_NONE);
+ RegisterNamespace("SERV:NODENAME", 0, 1, tmplput_serv_nodename, CTX_NONE);
+ RegisterNamespace("SERV:HUMANNODE", 0, 1, tmplput_serv_humannode, CTX_NONE);
+ RegisterNamespace("SERV:FQDN", 0, 1, tmplput_serv_fqdn, CTX_NONE);
+ RegisterNamespace("SERV:SOFTWARE", 0, 1, tmplput_serv_software, CTX_NONE);
RegisterNamespace("SERV:REV_LEVEL", 0, 0, tmplput_serv_rev_level, CTX_NONE);
- RegisterNamespace("SERV:BBS_CITY", 0, 0, tmplput_serv_bbs_city, CTX_NONE);
+ RegisterNamespace("SERV:BBS_CITY", 0, 1, tmplput_serv_bbs_city, CTX_NONE);
RegisterNamespace("SERV:MESG", 1, 2, tmplput_mesg, CTX_NONE);
/*TODO // RegisterNamespace("SERV:LDAP_SUPP", 0, 0, tmplput_serv_ldap_enabled, 0); */
}
Buf = NewStrBuf();
CfgToken = NULL;
StrBuf_ServGetln(Buf);
- if (ChrPtr(Buf)[0] == '2') {
+ if (GetServerStatus(Buf, NULL) == 2) {
StrBufCutLeft(Buf, 4);
CfgToken = NewStrBuf();
serv_getln(buf, sizeof buf);
serv_printf("SPEX mailboxes|%d|%d", ibstr("mboxpolicy"), ibstr("mboxvalue"));
serv_getln(buf, sizeof buf);
-
- strcpy(serv_info.serv_default_cal_zone, bstr("c_default_cal_zone"));
+ FreeStrBuf(&serv_info.serv_default_cal_zone);
+ serv_info.serv_default_cal_zone = NewStrBufDup(sbstr("c_default_cal_zone"));
safestrncpy(WCC->ImportantMessage, _("Your system configuration has been updated."),
sizeof WCC->ImportantMessage);
display_aide_menu();
}
-void tmplput_servcfg(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_servcfg(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
void *vBuf;
load_siteconfig();
GetHash(WCC->ServCfg, TKEY(0), &vBuf);
Buf = (StrBuf*) vBuf;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Buf, 1);
+ StrBufAppendTemplate(Target, TP, Buf, 1);
}
}
-int ConditionalServCfg(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalServCfg(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
void *vBuf;
GetHash(WCC->ServCfg, TKEY(2), &vBuf);
if (vBuf == NULL) return 0;
Buf = (StrBuf*) vBuf;
- if (Tokens->nParameters == 3) {
+ if (TP->Tokens->nParameters == 3) {
return 1;
}
- else if (Tokens->Params[3]->Type == TYPE_STR)
- return (strcmp(Tokens->Params[3]->Start, ChrPtr(Buf)) == 0);
- else return (StrTol(Buf) == Tokens->Params[3]->lvalue);
+ else if (TP->Tokens->Params[3]->Type == TYPE_STR)
+ return (strcmp(TP->Tokens->Params[3]->Start, ChrPtr(Buf)) == 0);
+ else return (StrTol(Buf) == TP->Tokens->Params[3]->lvalue);
}
else return 0;
}
-int ConditionalServCfgSubst(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalServCfgSubst(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
void *vBuf;
if (vBuf == NULL) return 0;
Buf = (StrBuf*) vBuf;
- return CompareSubstToStrBuf(Buf, Tokens->Params[3]);
+ return CompareSubstToStrBuf(Buf, TP->Tokens->Params[3]);
}
else return 0;
}
atsign = strchr(sender, '@');
if (atsign != NULL) {
++atsign;
- if (!strcasecmp(atsign, serv_info.serv_nodename)) {
+ if (!strcasecmp(atsign, ChrPtr(serv_info.serv_nodename))) {
--atsign;
*atsign = 0;
}
wcsession *WCC = WC;
int i;
int num_msgs;
+ StrBuf *Buf;
/* Check to see if we can go to the __CitadelSMTPspoolout__ room.
* If not, we don't have access to the queue.
*/
- gotoroom("__CitadelSMTPspoolout__");
- if (!strcasecmp(WCC->wc_roomname, "__CitadelSMTPspoolout__")) {
+ Buf = NewStrBufPlain(HKEY("__CitadelSMTPspoolout__"));
+ gotoroom(Buf);
+ FreeStrBuf(&Buf);
+ if (!strcasecmp(ChrPtr(WCC->wc_roomname), "__CitadelSMTPspoolout__")) {
num_msgs = load_msg_ptrs("MSGS ALL", 0);
if (num_msgs > 0) {
font:lighter 11px/1.3 sans-serif;\r
text-decoration:none;\r
text-align:left;\r
- overflow:hidden;\r
}\r
\r
.tooltip span.top {\r
padding: 30px 8px 0;\r
- background: url(bt.gif) no-repeat top left;\r
+ background: url(bt.gif) no-repeat top\r
}\r
\r
.tooltip b.bottom {\r
// Send the text to the server
parms = 'r=' + Math.random()
- + '&g_cmd=SEXP ' + recipient + '|-&g_input=' + encodeURIComponent(thetext);
+ + '&g_cmd=SEXP ' + recipient + '|-\n' + escape(thetext);
new Ajax.Request('../ajax_servcmd',
{
method: 'post',
-/* Prototype JavaScript framework, version 1.6.0.2
+/* Prototype JavaScript framework, version 1.6.0.3
* (c) 2005-2008 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
*--------------------------------------------------------------------------*/
var Prototype = {
- Version: '1.6.0.2',
+ Version: '1.6.0.3',
Browser: {
- IE: !!(window.attachEvent && !window.opera),
- Opera: !!window.opera,
+ IE: !!(window.attachEvent &&
+ navigator.userAgent.indexOf('Opera') === -1),
+ Opera: navigator.userAgent.indexOf('Opera') > -1,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
- Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
+ Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
+ navigator.userAgent.indexOf('KHTML') === -1,
MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
},
BrowserFeatures: {
XPath: !!document.evaluate,
+ SelectorsAPI: !!document.querySelector,
ElementExtensions: !!window.HTMLElement,
SpecificElementExtensions:
- document.createElement('div').__proto__ &&
- document.createElement('div').__proto__ !==
- document.createElement('form').__proto__
+ document.createElement('div')['__proto__'] &&
+ document.createElement('div')['__proto__'] !==
+ document.createElement('form')['__proto__']
},
ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
var property = properties[i], value = source[property];
if (ancestor && Object.isFunction(value) &&
value.argumentNames().first() == "$super") {
- var method = value, value = Object.extend((function(m) {
+ var method = value;
+ value = (function(m) {
return function() { return ancestor[m].apply(this, arguments) };
- })(property).wrap(method), {
- valueOf: function() { return method },
- toString: function() { return method.toString() }
- });
+ })(property).wrap(method);
+
+ value.valueOf = method.valueOf.bind(method);
+ value.toString = method.toString.bind(method);
}
this.prototype[property] = value;
}
},
isElement: function(object) {
- return object && object.nodeType == 1;
+ return !!(object && object.nodeType == 1);
},
isArray: function(object) {
Object.extend(Function.prototype, {
argumentNames: function() {
- var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip");
+ var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]
+ .replace(/\s+/g, '').split(',');
return names.length == 1 && !names[0] ? [] : names;
},
}, timeout);
},
+ defer: function() {
+ var args = [0.01].concat($A(arguments));
+ return this.delay.apply(this, args);
+ },
+
wrap: function(wrapper) {
var __method = this;
return function() {
}
});
-Function.prototype.defer = Function.prototype.delay.curry(0.01);
-
Date.prototype.toJSON = function() {
return '"' + this.getUTCFullYear() + '-' +
(this.getUTCMonth() + 1).toPaddedString(2) + '-' +
return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
},
unescapeHTML: function() {
- return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
+ return this.stripTags().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
}
});
text: document.createTextNode('')
});
-with (String.prototype.escapeHTML) div.appendChild(text);
+String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);
var Template = Class.create({
initialize: function(template, pattern) {
var Enumerable = {
each: function(iterator, context) {
var index = 0;
- iterator = iterator.bind(context);
try {
this._each(function(value) {
- iterator(value, index++);
+ iterator.call(context, value, index++);
});
} catch (e) {
if (e != $break) throw e;
},
eachSlice: function(number, iterator, context) {
- iterator = iterator ? iterator.bind(context) : Prototype.K;
var index = -number, slices = [], array = this.toArray();
+ if (number < 1) return array;
while ((index += number) < array.length)
slices.push(array.slice(index, index+number));
return slices.collect(iterator, context);
},
all: function(iterator, context) {
- iterator = iterator ? iterator.bind(context) : Prototype.K;
+ iterator = iterator || Prototype.K;
var result = true;
this.each(function(value, index) {
- result = result && !!iterator(value, index);
+ result = result && !!iterator.call(context, value, index);
if (!result) throw $break;
});
return result;
},
any: function(iterator, context) {
- iterator = iterator ? iterator.bind(context) : Prototype.K;
+ iterator = iterator || Prototype.K;
var result = false;
this.each(function(value, index) {
- if (result = !!iterator(value, index))
+ if (result = !!iterator.call(context, value, index))
throw $break;
});
return result;
},
collect: function(iterator, context) {
- iterator = iterator ? iterator.bind(context) : Prototype.K;
+ iterator = iterator || Prototype.K;
var results = [];
this.each(function(value, index) {
- results.push(iterator(value, index));
+ results.push(iterator.call(context, value, index));
});
return results;
},
detect: function(iterator, context) {
- iterator = iterator.bind(context);
var result;
this.each(function(value, index) {
- if (iterator(value, index)) {
+ if (iterator.call(context, value, index)) {
result = value;
throw $break;
}
},
findAll: function(iterator, context) {
- iterator = iterator.bind(context);
var results = [];
this.each(function(value, index) {
- if (iterator(value, index))
+ if (iterator.call(context, value, index))
results.push(value);
});
return results;
},
grep: function(filter, iterator, context) {
- iterator = iterator ? iterator.bind(context) : Prototype.K;
+ iterator = iterator || Prototype.K;
var results = [];
if (Object.isString(filter))
this.each(function(value, index) {
if (filter.match(value))
- results.push(iterator(value, index));
+ results.push(iterator.call(context, value, index));
});
return results;
},
},
inject: function(memo, iterator, context) {
- iterator = iterator.bind(context);
this.each(function(value, index) {
- memo = iterator(memo, value, index);
+ memo = iterator.call(context, memo, value, index);
});
return memo;
},
},
max: function(iterator, context) {
- iterator = iterator ? iterator.bind(context) : Prototype.K;
+ iterator = iterator || Prototype.K;
var result;
this.each(function(value, index) {
- value = iterator(value, index);
+ value = iterator.call(context, value, index);
if (result == null || value >= result)
result = value;
});
},
min: function(iterator, context) {
- iterator = iterator ? iterator.bind(context) : Prototype.K;
+ iterator = iterator || Prototype.K;
var result;
this.each(function(value, index) {
- value = iterator(value, index);
+ value = iterator.call(context, value, index);
if (result == null || value < result)
result = value;
});
},
partition: function(iterator, context) {
- iterator = iterator ? iterator.bind(context) : Prototype.K;
+ iterator = iterator || Prototype.K;
var trues = [], falses = [];
this.each(function(value, index) {
- (iterator(value, index) ?
+ (iterator.call(context, value, index) ?
trues : falses).push(value);
});
return [trues, falses];
},
reject: function(iterator, context) {
- iterator = iterator.bind(context);
var results = [];
this.each(function(value, index) {
- if (!iterator(value, index))
+ if (!iterator.call(context, value, index))
results.push(value);
});
return results;
},
sortBy: function(iterator, context) {
- iterator = iterator.bind(context);
return this.map(function(value, index) {
- return {value: value, criteria: iterator(value, index)};
+ return {
+ value: value,
+ criteria: iterator.call(context, value, index)
+ };
}).sort(function(left, right) {
var a = left.criteria, b = right.criteria;
return a < b ? -1 : a > b ? 1 : 0;
if (Prototype.Browser.WebKit) {
$A = function(iterable) {
if (!iterable) return [];
- if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') &&
- iterable.toArray) return iterable.toArray();
+ // In Safari, only use the `toArray` method if it's not a NodeList.
+ // A NodeList is a function, has an function `item` property, and a numeric
+ // `length` property. Adapted from Google Doctype.
+ if (!(typeof iterable === 'function' && typeof iterable.length ===
+ 'number' && typeof iterable.item === 'function') && iterable.toArray)
+ return iterable.toArray();
var length = iterable.length || 0, results = new Array(length);
while (length--) results[length] = iterable[length];
return results;
return this + 1;
},
- times: function(iterator) {
- $R(0, this, true).each(iterator);
+ times: function(iterator, context) {
+ $R(0, this, true).each(iterator, context);
return this;
},
},
get: function(key) {
- return this._object[key];
+ // simulating poorly supported hasOwnProperty
+ if (this._object[key] !== Object.prototype[key])
+ return this._object[key];
},
unset: function(key) {
},
toQueryString: function() {
- return this.map(function(pair) {
+ return this.inject([], function(results, pair) {
var key = encodeURIComponent(pair.key), values = pair.value;
if (values && typeof values == 'object') {
if (Object.isArray(values))
- return values.map(toQueryPair.curry(key)).join('&');
- }
- return toQueryPair(key, values);
+ return results.concat(values.map(toQueryPair.curry(key)));
+ } else results.push(toQueryPair(key, values));
+ return results;
}).join('&');
},
return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
};
Object.extend(this.Element, element || { });
+ if (element) this.Element.prototype = element.prototype;
}).call(window);
Element.cache = { };
},
hide: function(element) {
- $(element).style.display = 'none';
+ element = $(element);
+ element.style.display = 'none';
return element;
},
show: function(element) {
- $(element).style.display = '';
+ element = $(element);
+ element.style.display = '';
return element;
},
element = $(element);
if (arguments.length == 1) return element.firstDescendant();
return Object.isNumber(expression) ? element.descendants()[expression] :
- element.select(expression)[index || 0];
+ Element.select(element, expression)[index || 0];
},
previous: function(element, expression, index) {
descendantOf: function(element, ancestor) {
element = $(element), ancestor = $(ancestor);
- var originalAncestor = ancestor;
if (element.compareDocumentPosition)
return (element.compareDocumentPosition(ancestor) & 8) === 8;
- if (element.sourceIndex && !Prototype.Browser.Opera) {
- var e = element.sourceIndex, a = ancestor.sourceIndex,
- nextAncestor = ancestor.nextSibling;
- if (!nextAncestor) {
- do { ancestor = ancestor.parentNode; }
- while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode);
- }
- if (nextAncestor && nextAncestor.sourceIndex)
- return (e > a && e < nextAncestor.sourceIndex);
- }
+ if (ancestor.contains)
+ return ancestor.contains(element) && ancestor !== element;
while (element = element.parentNode)
- if (element == originalAncestor) return true;
+ if (element == ancestor) return true;
+
return false;
},
element = $(element);
style = style == 'float' ? 'cssFloat' : style.camelize();
var value = element.style[style];
- if (!value) {
+ if (!value || value == 'auto') {
var css = document.defaultView.getComputedStyle(element, null);
value = css ? css[style] : null;
}
getDimensions: function(element) {
element = $(element);
- var display = $(element).getStyle('display');
+ var display = element.getStyle('display');
if (display != 'none' && display != null) // Safari bug
return {width: element.offsetWidth, height: element.offsetHeight};
element.style.position = 'relative';
// Opera returns the offset relative to the positioning context, when an
// element is position relative but top and left have not been defined
- if (window.opera) {
+ if (Prototype.Browser.Opera) {
element.style.top = 0;
element.style.left = 0;
}
valueL += element.offsetLeft || 0;
element = element.offsetParent;
if (element) {
- if (element.tagName == 'BODY') break;
+ if (element.tagName.toUpperCase() == 'BODY') break;
var p = Element.getStyle(element, 'position');
if (p !== 'static') break;
}
absolutize: function(element) {
element = $(element);
- if (element.getStyle('position') == 'absolute') return;
+ if (element.getStyle('position') == 'absolute') return element;
// Position.prepare(); // To be done manually by Scripty when it needs it.
var offsets = element.positionedOffset();
relativize: function(element) {
element = $(element);
- if (element.getStyle('position') == 'relative') return;
+ if (element.getStyle('position') == 'relative') return element;
// Position.prepare(); // To be done manually by Scripty when it needs it.
element.style.position = 'relative';
element = forElement;
do {
- if (!Prototype.Browser.Opera || element.tagName == 'BODY') {
+ if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) {
valueT -= element.scrollTop || 0;
valueL -= element.scrollLeft || 0;
}
Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap(
function(proceed, element) {
element = $(element);
+ // IE throws an error if element is not in document
+ try { element.offsetParent }
+ catch(e) { return $(document.body) }
var position = element.getStyle('position');
if (position !== 'static') return proceed(element);
element.setStyle({ position: 'relative' });
Element.Methods[method] = Element.Methods[method].wrap(
function(proceed, element) {
element = $(element);
+ try { element.offsetParent }
+ catch(e) { return Element._returnOffset(0,0) }
var position = element.getStyle('position');
if (position !== 'static') return proceed(element);
// Trigger hasLayout on the offset parent so that IE6 reports
);
});
+ Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap(
+ function(proceed, element) {
+ try { element.offsetParent }
+ catch(e) { return Element._returnOffset(0,0) }
+ return proceed(element);
+ }
+ );
+
Element.Methods.getStyle = function(element, style) {
element = $(element);
style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
Element._attributeTranslations.has = {};
$w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
- 'encType maxLength readOnly longDesc').each(function(attr) {
+ 'encType maxLength readOnly longDesc frameBorder').each(function(attr) {
Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
Element._attributeTranslations.has[attr.toLowerCase()] = attr;
});
(value < 0.00001) ? 0 : value;
if (value == 1)
- if(element.tagName == 'IMG' && element.width) {
+ if(element.tagName.toUpperCase() == 'IMG' && element.width) {
element.width++; element.width--;
} else try {
var n = document.createTextNode(' ');
hasAttribute: function(element, attribute) {
attribute = Element._attributeTranslations.has[attribute] || attribute;
var node = $(element).getAttributeNode(attribute);
- return node && node.specified;
+ return !!(node && node.specified);
}
};
Object.extend(Element, Element.Methods);
if (!Prototype.BrowserFeatures.ElementExtensions &&
- document.createElement('div').__proto__) {
+ document.createElement('div')['__proto__']) {
window.HTMLElement = { };
- window.HTMLElement.prototype = document.createElement('div').__proto__;
+ window.HTMLElement.prototype = document.createElement('div')['__proto__'];
Prototype.BrowserFeatures.ElementExtensions = true;
}
element.nodeType != 1 || element == window) return element;
var methods = Object.clone(Methods),
- tagName = element.tagName, property, value;
+ tagName = element.tagName.toUpperCase(), property, value;
// extend methods for specific tags
if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
if (window[klass]) return window[klass];
window[klass] = { };
- window[klass].prototype = document.createElement(tagName).__proto__;
+ window[klass].prototype = document.createElement(tagName)['__proto__'];
return window[klass];
}
document.viewport = {
getDimensions: function() {
- var dimensions = { };
- var B = Prototype.Browser;
+ var dimensions = { }, B = Prototype.Browser;
$w('width height').each(function(d) {
var D = d.capitalize();
- dimensions[d] = (B.WebKit && !document.evaluate) ? self['inner' + D] :
- (B.Opera) ? document.body['client' + D] : document.documentElement['client' + D];
+ if (B.WebKit && !document.evaluate) {
+ // Safari <3.0 needs self.innerWidth/Height
+ dimensions[d] = self['inner' + D];
+ } else if (B.Opera && parseFloat(window.opera.version()) < 9.5) {
+ // Opera <9.5 needs document.body.clientWidth/Height
+ dimensions[d] = document.body['client' + D]
+ } else {
+ dimensions[d] = document.documentElement['client' + D];
+ }
});
return dimensions;
},
window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
}
};
-/* Portions of the Selector class are derived from Jack Slocum’s DomQuery,
+/* Portions of the Selector class are derived from Jack Slocum's DomQuery,
* part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
* license. Please see http://www.yui-ext.com/ for more information. */
var Selector = Class.create({
initialize: function(expression) {
this.expression = expression.strip();
- this.compileMatcher();
+
+ if (this.shouldUseSelectorsAPI()) {
+ this.mode = 'selectorsAPI';
+ } else if (this.shouldUseXPath()) {
+ this.mode = 'xpath';
+ this.compileXPathMatcher();
+ } else {
+ this.mode = "normal";
+ this.compileMatcher();
+ }
+
},
shouldUseXPath: function() {
// XPath can't do namespaced attributes, nor can it read
// the "checked" property from DOM nodes
- if ((/(\[[\w-]*?:|:checked)/).test(this.expression))
+ if ((/(\[[\w-]*?:|:checked)/).test(e))
return false;
return true;
},
- compileMatcher: function() {
- if (this.shouldUseXPath())
- return this.compileXPathMatcher();
+ shouldUseSelectorsAPI: function() {
+ if (!Prototype.BrowserFeatures.SelectorsAPI) return false;
+
+ if (!Selector._div) Selector._div = new Element('div');
+
+ // Make sure the browser treats the selector as valid. Test on an
+ // isolated element to minimize cost of this check.
+ try {
+ Selector._div.querySelector(this.expression);
+ } catch(e) {
+ return false;
+ }
+
+ return true;
+ },
+ compileMatcher: function() {
var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
c = Selector.criteria, le, p, m;
p = ps[i];
if (m = e.match(p)) {
this.matcher.push(Object.isFunction(c[i]) ? c[i](m) :
- new Template(c[i]).evaluate(m));
+ new Template(c[i]).evaluate(m));
e = e.replace(m[0], '');
break;
}
findElements: function(root) {
root = root || document;
- if (this.xpath) return document._getElementsByXPath(this.xpath, root);
- return this.matcher(root);
+ var e = this.expression, results;
+
+ switch (this.mode) {
+ case 'selectorsAPI':
+ // querySelectorAll queries document-wide, then filters to descendants
+ // of the context element. That's not what we want.
+ // Add an explicit context to the selector if necessary.
+ if (root !== document) {
+ var oldId = root.id, id = $(root).identify();
+ e = "#" + id + " " + e;
+ }
+
+ results = $A(root.querySelectorAll(e)).map(Element.extend);
+ root.id = oldId;
+
+ return results;
+ case 'xpath':
+ return document._getElementsByXPath(this.xpath, root);
+ default:
+ return this.matcher(root);
+ }
},
match: function(element) {
'first-child': '[not(preceding-sibling::*)]',
'last-child': '[not(following-sibling::*)]',
'only-child': '[not(preceding-sibling::* or following-sibling::*)]',
- 'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",
+ 'empty': "[count(*) = 0 and (count(text()) = 0)]",
'checked': "[@checked]",
- 'disabled': "[@disabled]",
- 'enabled': "[not(@disabled)]",
+ 'disabled': "[(@disabled) and (@type!='hidden')]",
+ 'enabled': "[not(@disabled) and (@type!='hidden')]",
'not': function(m) {
var e = m[6], p = Selector.patterns,
x = Selector.xpath, le, v;
className: /^\.([\w\-\*]+)(\b|$)/,
pseudo:
/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,
- attrPresence: /^\[([\w]+)\]/,
+ attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/,
attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
},
nextElementSibling: function(node) {
while (node = node.nextSibling)
- if (node.nodeType == 1) return node;
+ if (node.nodeType == 1) return node;
return null;
},
'empty': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++) {
// IE treats comments as element nodes
- if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue;
+ if (node.tagName == '!' || node.firstChild) continue;
results.push(node);
}
return results;
'enabled': function(nodes, value, root) {
for (var i = 0, results = [], node; node = nodes[i]; i++)
- if (!node.disabled) results.push(node);
+ if (!node.disabled && (!node.type || node.type !== 'hidden'))
+ results.push(node);
return results;
},
operators: {
'=': function(nv, v) { return nv == v; },
'!=': function(nv, v) { return nv != v; },
- '^=': function(nv, v) { return nv.startsWith(v); },
+ '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); },
+ '$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); },
+ '*=': function(nv, v) { return nv == v || nv && nv.include(v); },
'$=': function(nv, v) { return nv.endsWith(v); },
'*=': function(nv, v) { return nv.include(v); },
'~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
- '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); }
+ '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() +
+ '-').include('-' + (v || "").toUpperCase() + '-'); }
},
split: function(expression) {
var data = elements.inject({ }, function(result, element) {
if (!element.disabled && element.name) {
key = element.name; value = $(element).getValue();
- if (value != null && (element.type != 'submit' || (!submitted &&
+ if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
submit !== false && (!submit || key == submit) && (submitted = true)))) {
if (key in result) {
// a key is already present; construct an array of values
disable: function(element) {
element = $(element);
- element.blur();
element.disabled = true;
return element;
},
else element.value = value;
},
- select: function(element, index) {
- if (Object.isUndefined(index))
+ select: function(element, value) {
+ if (Object.isUndefined(value))
return this[element.type == 'select-one' ?
'selectOne' : 'selectMany'](element);
else {
- var opt, value, single = !Object.isArray(index);
+ var opt, currentValue, single = !Object.isArray(value);
for (var i = 0, length = element.length; i < length; i++) {
opt = element.options[i];
- value = this.optionValue(opt);
+ currentValue = this.optionValue(opt);
if (single) {
- if (value == index) {
+ if (currentValue == value) {
opt.selected = true;
return;
}
}
- else opt.selected = index.include(value);
+ else opt.selected = value.include(currentValue);
}
}
},
isRightClick: function(event) { return isButton(event, 2) },
element: function(event) {
- var node = Event.extend(event).target;
- return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node);
+ event = Event.extend(event);
+
+ var node = event.target,
+ type = event.type,
+ currentTarget = event.currentTarget;
+
+ if (currentTarget && currentTarget.tagName) {
+ // Firefox screws up the "click" event when moving between radio buttons
+ // via arrow keys. It also screws up the "load" and "error" events on images,
+ // reporting the document as the target instead of the original image.
+ if (type === 'load' || type === 'error' ||
+ (type === 'click' && currentTarget.tagName.toLowerCase() === 'input'
+ && currentTarget.type === 'radio'))
+ node = currentTarget;
+ }
+ if (node.nodeType == Node.TEXT_NODE) node = node.parentNode;
+ return Element.extend(node);
},
findElement: function(event, expression) {
},
pointer: function(event) {
+ var docElement = document.documentElement,
+ body = document.body || { scrollLeft: 0, scrollTop: 0 };
return {
x: event.pageX || (event.clientX +
- (document.documentElement.scrollLeft || document.body.scrollLeft)),
+ (docElement.scrollLeft || body.scrollLeft) -
+ (docElement.clientLeft || 0)),
y: event.pageY || (event.clientY +
- (document.documentElement.scrollTop || document.body.scrollTop))
+ (docElement.scrollTop || body.scrollTop) -
+ (docElement.clientTop || 0))
};
},
};
} else {
- Event.prototype = Event.prototype || document.createEvent("HTMLEvents").__proto__;
+ Event.prototype = Event.prototype || document.createEvent("HTMLEvents")['__proto__'];
Object.extend(Event.prototype, methods);
return Prototype.K;
}
cache[id][eventName] = null;
}
+
+ // Internet Explorer needs to remove event handlers on page unload
+ // in order to avoid memory leaks.
if (window.attachEvent) {
window.attachEvent("onunload", destroyCache);
}
+ // Safari has a dummy event handler on page unload so that it won't
+ // use its bfcache. Safari <= 3.1 has an issue with restoring the "document"
+ // object when page is returned to via the back button using its bfcache.
+ if (Prototype.Browser.WebKit) {
+ window.addEventListener('unload', Prototype.emptyFunction, false);
+ }
+
return {
observe: function(element, eventName, handler) {
element = $(element);
var table = $('taskview');
}
-function attachDatePicker(relative, wclang) {
+function attachDatePicker(relative) {
var dpck = new DatePicker({
relative: relative,
- language: wclang.substr(0,2),
- disableFutureDate: false,
- dateFormat: [ ["yyyy", "mm", "dd"], "-"],
- showDuration: 0.2,
- closeEffectDuration: 0.2
+ language: 'en', // fix please
+ disableFutureDate: false
});
document.getElementById(relative).dpck = dpck; // attach a ref to it
}
-
function eventEditAllDay() {
- var allDayCheck = $('alldayevent');
- var dtend = $('dtendcell');
-
- if (allDayCheck.checked) {
+ var allDayCheck = document.getElementById("alldayevent");
+ var dtend= document.getElementById("dtendcell");
+ if(allDayCheck.checked) {
//dtend.disabled = true;
dtend.style.textDecoration = "line-through";
} else {
dtend.style.textDecoration = "";
}
}
-
-
-
-
-// Functions which handle show/hide of various elements in the recurrence editor
-
-function RecurrenceShowHide() {
-
- if ($('is_recur').checked) {
- $('rrule_div').style.display = 'block';
- }
- else {
- $('rrule_div').style.display = 'none';
- }
-
- if ($('freq_selector').selectedIndex == 4) {
- $('weekday_selector').style.display = 'block';
- }
- else {
- $('weekday_selector').style.display = 'none';
- }
-
- if ($('freq_selector').selectedIndex == 5) {
- $('monthday_selector').style.display = 'block';
- }
- else {
- $('monthday_selector').style.display = 'none';
- }
-
- if ($('rrend_count').checked) {
- $('rrcount').disabled = false;
- }
- else {
- $('rrcount').disabled = true;
- }
-
- if ($('rrend_until').checked) {
- $('rruntil').disabled = false;
- }
- else {
- $('rruntil').disabled = true;
- }
-
- if ($('rrmonthtype_mday').checked) {
- $('rrmday').disabled = false;
- }
- else {
- $('rrmday').disabled = true;
- }
-
- if ($('rrmonthtype_wday').checked) {
- $('rrmweek').disabled = false;
- $('rrmweekday').disabled = false;
- }
- else {
- $('rrmweek').disabled = true;
- $('rrmweekday').disabled = true;
- }
-
- if ($('freq_selector').selectedIndex == 6) {
- $('yearday_selector').style.display = 'block';
- }
- else {
- $('yearday_selector').style.display = 'none';
- }
-
- $('ymday').innerHTML = 'XXXX-' + $('dtstart').value.substr(5);
- $('rrmday').innerHTML = $('dtstart').value.substr(8);
-
- if ($('rryeartype_ywday').checked) {
- $('rrymweek').disabled = false;
- $('rrymweekday').disabled = false;
- $('rrymonth').disabled = false;
- }
- else {
- $('rrymweek').disabled = true;
- $('rrymweekday').disabled = true;
- $('rrymonth').disabled = true;
- }
-
-}
#room_infos, #address_book_popup, .mimepart, .room_actions form select {
border: 1px solid #333;
- overflow: hidden;
}
.tabcontent_submit {
margin: 0 auto 0 auto;
- width: 96%;
+ width: 50%;
padding: 10px;
text-align: center;
}
HashList *SortHash;
int LoadTemplates = 0;
+WCTemplputParams NoCtx;
#define SV_GETTEXT 1
#define SV_CONDITIONAL 2
}HashHandler;
void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere);
-int EvaluateConditional(StrBuf *Target, WCTemplateToken *Tokens, WCTemplate *pTmpl, void *Context, int Neg, int state, int ContextType);
+int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams *TP);
typedef struct _SortStruct {
StrBuf *Name;
free (Sort);
}
+void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplputParams *TP, const char *Format, ...)
+{
+ StrBuf *Error;
+ StrBuf *Info;
+ va_list arg_ptr;
+ const char *Err = NULL;
+
+ Info = NewStrBuf();
+ Error = NewStrBuf();
+
+ va_start(arg_ptr, Format);
+ StrBufVAppendPrintf(Error, Format, arg_ptr);
+ va_end(arg_ptr);
+
+ switch (ErrorPos) {
+ default:
+ case ERR_NAME: /* the main token name... */
+ Err = TP->Tokens->pName;
+ break;
+ case ERR_PARM1:
+ Err = TP->Tokens->Params[0]->Start;
+ break;
+ case ERR_PARM2:
+ Err = TP->Tokens->Params[1]->Start;
+ break;
+ }
+ lprintf(1, "%s [%s] (in '%s' line %ld); %s; [%s]\n",
+ Type,
+ Err,
+ ChrPtr(TP->Tokens->FileName),
+ TP->Tokens->Line,
+ ChrPtr(Error),
+ ChrPtr(TP->Tokens->FlatToken));
+ if (Target != NULL) {
+ StrBufAppendPrintf(
+ Target,
+ "<pre>\n%s [%s] (in '%s' line %ld); %s\n[%s]\n</pre>\n",
+ Type,
+ Err,
+ ChrPtr(TP->Tokens->FileName),
+ TP->Tokens->Line,
+ ChrPtr(Error),
+ ChrPtr(TP->Tokens->FlatToken));
+ }
+}
+
void RegisterNS(const char *NSName,
long len,
}
}
-void GetTemplateTokenString(WCTemplateToken *Tokens,
- int N,
+void GetTemplateTokenString(WCTemplputParams *TP,
+ int N,
const char **Value,
long *len)
{
StrBuf *Buf;
- if (Tokens->nParameters < N) {
+ if (TP->Tokens->nParameters < N) {
+ lprintf(1, "invalid token. this shouldn't have come till here.\n");
+ wc_backtrace();
*Value = "";
*len = 0;
return;
}
- switch (Tokens->Params[N]->Type) {
+ switch (TP->Tokens->Params[N]->Type) {
case TYPE_STR:
- *Value = Tokens->Params[N]->Start;
- *len = Tokens->Params[N]->len;
+ *Value = TP->Tokens->Params[N]->Start;
+ *len = TP->Tokens->Params[N]->len;
break;
case TYPE_BSTR:
Buf = (StrBuf*) SBstr(TKEY(N));
case TYPE_PREFINT:
break; /* todo: string to text? */
case TYPE_GETTEXT:
- *Value = _(Tokens->Params[N]->Start);
+ *Value = _(TP->Tokens->Params[N]->Start);
*len = strlen(*Value);
break;
default:
* \brief Print the value of a variable
* \param keyname get a key to print
*/
-void print_value_of(StrBuf *Target, WCTemplateToken *Tokens, void *Context, int ContextType) {
+void print_value_of(StrBuf *Target, WCTemplputParams *TP)
+
+{
wcsession *WCC = WC;
wcsubst *ptr;
void *vVar;
/*if (WCC->vars != NULL) PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
/* TODO: depricated! */
- if (Tokens->pName[0] == '=') {
- DoTemplate(Tokens->pName+1, Tokens->NameEnd - 1, NULL, NULL, 0);
+ if (TP->Tokens->pName[0] == '=') {
+ DoTemplate(TP->Tokens->pName+1, TP->Tokens->NameEnd - 1, NULL, &NoCtx);
}
-
/*/////TODO: if param[1] == "U" -> urlescape
/// X -> escputs */
/** Page-local variables */
- if ((WCC->vars!= NULL) && GetHash(WCC->vars, Tokens->pName, Tokens->NameEnd, &vVar)) {
+ if ((WCC->vars!= NULL) && GetHash(WCC->vars, TP->Tokens->pName, TP->Tokens->NameEnd, &vVar)) {
ptr = (wcsubst*) vVar;
switch(ptr->wcs_type) {
case WCS_STRING:
pvo_do_cmd(Target, ptr->wcs_value);
break;
case WCS_FUNCTION:
- (*ptr->wcs_function) (Target, Tokens->nParameters, Tokens, Context, ContextType);
+ (*ptr->wcs_function) (Target, TP);
break;
case WCS_STRBUF:
case WCS_STRBUF_REF:
StrBufAppendPrintf(Target, "%ld", ptr->lvalue);
break;
default:
- lprintf(1,"WARNING: invalid value in SV-Hash at %s!\n", Tokens->pName);
- StrBufAppendPrintf(Target, "<pre>WARNING: \ninvalid value in SV-Hash at %s!\n</pre>", Tokens->pName);
+ LogTemplateError(
+ Target, "Subst", ERR_NAME, TP,
+ "WARNING: invalid value in SV-Hash at %s!", TP->Tokens->pName);
}
}
else {
- lprintf(1, "didn't find Handler [%s] (in '%s' line %ld); "
- " [%s]\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
+ LogTemplateError(
+ Target, "Token", ERR_NAME, TP,
+ "didn't find Handler");
wc_backtrace();
}
}
* \param FormatTypeIndex where should we look for escape types if?
*/
void StrBufAppendTemplate(StrBuf *Target,
- int nArgs,
- WCTemplateToken *Tokens,
- void *Context, int ContextType,
+ WCTemplputParams *TP,
const StrBuf *Source, int FormatTypeIndex)
{
wcsession *WCC;
StrBuf *Buf;
char EscapeAs = ' ';
- if ((FormatTypeIndex < Tokens->nParameters) &&
- (Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) &&
- (Tokens->Params[FormatTypeIndex]->len == 1)) {
- EscapeAs = *Tokens->Params[FormatTypeIndex]->Start;
+ if ((FormatTypeIndex < TP->Tokens->nParameters) &&
+ (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) &&
+ (TP->Tokens->Params[FormatTypeIndex]->len == 1)) {
+ EscapeAs = *TP->Tokens->Params[FormatTypeIndex]->Start;
}
switch(EscapeAs)
}
else {
Parm->lvalue = 0;
+/* TODO whUT?
lprintf(1, "Error (in '%s' line %ld); "
"evaluating long template param [%s] in Token [%s]\n",
ChrPtr(pTmpl->FileName),
Tokens->Line,
ChrPtr(Tokens->FlatToken),
*pCh);
+ */
free(Parm);
return NULL;
}
const char *pch;
TemplateParam *Param;
WCTemplateToken *NewToken = (WCTemplateToken*)malloc(sizeof(WCTemplateToken));
+ WCTemplputParams TP;
+ TP.Tokens = NewToken;
NewToken->FileName = pTmpl->FileName; /* to print meaningfull log messages... */
NewToken->Flags = 0;
NewToken->Line = Line + 1;
NewToken->NameEnd = pch - NewToken->pName;
pch ++;
if (*(pTmplEnd - 1) != ')') {
- lprintf(1, "Warning, Non welformed Token; missing right parenthesis (in '%s' line %ld); "
- "[%s]\n",
- ChrPtr(pTmpl->FileName),
- NewToken->Line,
- ChrPtr(NewToken->FlatToken));
+ LogTemplateError(
+ NULL, "Parseerror", ERR_NAME, &TP,
+ "Warning, Non welformed Token; missing right parenthesis");
}
while (pch < pTmplEnd - 1) {
Param = GetNextParameter(Buf, &pch, pTmplEnd - 1, NewToken, pTmpl);
if (Param != NULL) {
NewToken->HaveParameters = 1;
if (NewToken->nParameters > 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));
+ LogTemplateError(
+ NULL, "Parseerror", ERR_NAME, &TP,
+ "only [%ld] Params allowed in Tokens",
+ MAXPARAM);
+
free(Param);
FreeToken(&NewToken);
return NULL;
Handler = (HashHandler*) vVar;
if ((NewToken->nParameters < Handler->nMinArgs) ||
(NewToken->nParameters > Handler->nMaxArgs)) {
- lprintf(1, "Handler [%s] (in '%s' line %ld); "
- "doesn't work with %ld params [%s]\n",
- NewToken->pName,
- ChrPtr(pTmpl->FileName),
- NewToken->Line,
- NewToken->nParameters,
- ChrPtr(NewToken->FlatToken));
+ LogTemplateError(
+ NULL, "Token", ERR_NAME, &TP,
+ "doesn't work with %ld params",
+ NewToken->nParameters);
+
}
else {
NewToken->PreEval = Handler;
break;
case SV_GETTEXT:
if (NewToken->nParameters !=1) {
- lprintf(1, "Gettext (in '%s' line %ld); "
- "requires exactly 1 parameter, you gave %ld params [%s]\n",
- ChrPtr(pTmpl->FileName),
- NewToken->Line,
- NewToken->nParameters,
- ChrPtr(NewToken->FlatToken));
+ LogTemplateError(
+ NULL, "Gettext", ERR_NAME, &TP,
+ "requires exactly 1 parameter, you gave %ld params",
+ NewToken->nParameters);
NewToken->Flags = 0;
break;
}
break;
case SV_SUBTEMPL:
if (NewToken->nParameters != 1) {
- lprintf(1, "Subtemplates (in '%s' line %ld); "
- "require exactly 1 parameter, you gave %ld params [%s]\n",
- ChrPtr(pTmpl->FileName),
- NewToken->Line,
- NewToken->nParameters,
- ChrPtr(NewToken->FlatToken));
+ LogTemplateError(
+ NULL, "Subtemplates", ERR_NAME, &TP,
+ "require exactly 1 parameter, you gave %ld params",
+ NewToken->nParameters);
break;
}
break;
case SV_CONDITIONAL:
case SV_NEG_CONDITIONAL:
if (NewToken->nParameters <2) {
- lprintf(1, "Conditional (in '%s' line %ld); "
- "require at least 2 parameters, you gave %ld params [%s]\n",
- ChrPtr(pTmpl->FileName),
- NewToken->Line,
- NewToken->nParameters,
- ChrPtr(NewToken->FlatToken));
+ LogTemplateError(
+ NULL, "Conditional", ERR_NAME, &TP,
+ "require at least 2 parameters, you gave %ld params",
+ NewToken->nParameters);
NewToken->Flags = 0;
break;
}
if (NewToken->Params[1]->lvalue == 0) {
- lprintf(1, "Conditional (in '%s' line %ld); "
- "Conditional ID mustn't be 0! [%s]\n",
- ChrPtr(pTmpl->FileName),
- NewToken->Line,
- ChrPtr(NewToken->FlatToken));
+ LogTemplateError(
+ NULL, "Conditional", ERR_NAME, &TP,
+ "Conditional ID (Parameter 1) mustn't be 0!");
NewToken->Flags = 0;
break;
}
if ((NewToken->Params[0]->len == 1) &&
(NewToken->Params[0]->Start[0] == 'X'))
break;
- lprintf(1, "Conditional [%s] (in '%s' line %ld); Not found![%s]\n",
- NewToken->Params[0]->Start,
- ChrPtr(pTmpl->FileName),
- NewToken->Line,
- ChrPtr(NewToken->FlatToken));
+ LogTemplateError(
+ NULL, "Conditional", ERR_NAME, &TP,
+ "Not found!");
/*
NewToken->Error = NewStrBuf();
StrBufAppendPrintf(
* \param state are we in conditional state?
* \param ContextType what type of information does context giv us?
*/
-int EvaluateToken(StrBuf *Target, WCTemplateToken *Tokens, WCTemplate *pTmpl, void *Context, int state, int ContextType)
+int EvaluateToken(StrBuf *Target, int state, WCTemplputParams *TP)
{
const char *AppendMe;
long AppendMeLen;
lprintf(1,"Doing token: %s\n",Token->pName);
*/
- switch (Tokens->Flags) {
+ switch (TP->Tokens->Flags) {
case SV_GETTEXT:
- TmplGettext(Target, Tokens->nParameters, Tokens);
+ TmplGettext(Target, TP);
break;
case SV_CONDITIONAL: /** Forward conditional evaluation */
- return EvaluateConditional(Target, Tokens, pTmpl, Context, 1, state, ContextType);
+ return EvaluateConditional(Target, 1, state, TP);
break;
case SV_NEG_CONDITIONAL: /** Reverse conditional evaluation */
- return EvaluateConditional(Target, Tokens, pTmpl, Context, 0, state, ContextType);
+ return EvaluateConditional(Target, 0, state, TP);
break;
case SV_CUST_STR_CONDITIONAL: /** Conditional put custom strings from params */
- if (Tokens->nParameters >= 6) {
- if (EvaluateConditional(Target, Tokens, pTmpl, Context, 0, state, ContextType)) {
- GetTemplateTokenString(Tokens, 5, &AppendMe, &AppendMeLen);
+ if (TP->Tokens->nParameters >= 6) {
+ if (EvaluateConditional(Target, 0, state, TP)) {
+ GetTemplateTokenString(TP, 5, &AppendMe, &AppendMeLen);
StrBufAppendBufPlain(Target,
AppendMe,
AppendMeLen,
0);
}
else{
- GetTemplateTokenString(Tokens, 4, &AppendMe, &AppendMeLen);
+ GetTemplateTokenString(TP, 4, &AppendMe, &AppendMeLen);
StrBufAppendBufPlain(Target,
AppendMe,
AppendMeLen,
}
}
else {
- lprintf(1, "Conditional [%s] (in '%s' line %ld); needs at least 6 Params![%s]\n",
- Tokens->Params[0]->Start,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\nConditional [%s] (in '%s' line %ld); needs 6 Params!\n[%s]\n</pre>\n",
- Tokens->Params[0]->Start,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
+ LogTemplateError(
+ Target, "Conditional", ERR_NAME, TP,
+ "needs at least 6 Params!");
}
break;
case SV_SUBTEMPL:
- if (Tokens->nParameters == 1)
- DoTemplate(TKEY(0), NULL, NULL, ContextType);
+ if (TP->Tokens->nParameters == 1)
+ DoTemplate(TKEY(0), NULL, TP);
break;
case SV_PREEVALUATED:
- Handler = (HashHandler*) Tokens->PreEval;
+ Handler = (HashHandler*) TP->Tokens->PreEval;
if ((Handler->ContextRequired != CTX_NONE) &&
- (Handler->ContextRequired != ContextType)) {
- lprintf(1, "Handler [%s] (in '%s' line %ld); "
- "requires context of type %ld, have %ld [%s]\n",
- Tokens->pName,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
- Handler->ContextRequired,
- ContextType,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\nHandler [%s] (in '%s' line %ld);"
- " requires context of type %ld, have %ld!\n[%s]\n</pre>\n",
- Tokens->pName,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
+ (Handler->ContextRequired != TP->ContextType)) {
+ LogTemplateError(
+ Target, "Token", ERR_NAME, TP,
+ "requires context of type %ld, have %ld",
Handler->ContextRequired,
- ContextType,
- ChrPtr(Tokens->FlatToken));
+ TP->ContextType);
return -1;
}
- Handler->HandlerFunc(Target,
- Tokens->nParameters,
- Tokens,
- Context,
- ContextType);
+ Handler->HandlerFunc(Target, TP);
break;
default:
- if (GetHash(GlobalNS, Tokens->pName, Tokens->NameEnd, &vVar)) {
+ if (GetHash(GlobalNS, TP->Tokens->pName, TP->Tokens->NameEnd, &vVar)) {
Handler = (HashHandler*) vVar;
if ((Handler->ContextRequired != CTX_NONE) &&
- (Handler->ContextRequired != ContextType)) {
- lprintf(1, "Handler [%s] (in '%s' line %ld); "
- "requires context of type %ld, have %ld [%s]\n",
- Tokens->pName,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
- Handler->ContextRequired,
- ContextType,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\nHandler [%s] (in '%s' line %ld);"
- " requires context of type %ld, have %ld!\n[%s]\n</pre>\n",
- Tokens->pName,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
+ (Handler->ContextRequired != TP->ContextType)) {
+ LogTemplateError(
+ Target, "Token", ERR_NAME, TP,
+ "requires context of type %ld, have %ld",
Handler->ContextRequired,
- ContextType,
- ChrPtr(Tokens->FlatToken));
+ TP->ContextType);
return -1;
}
- else if ((Tokens->nParameters < Handler->nMinArgs) ||
- (Tokens->nParameters > Handler->nMaxArgs)) {
- lprintf(1, "Handler [%s] (in '%s' line %ld); "
- "doesn't work with %ld params [%s]\n",
- Tokens->pName,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
- Tokens->nParameters,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\nHandler [%s] (in '%s' line %ld);"
- " doesn't work with %ld params!\n[%s]\n</pre>\n",
- Tokens->pName,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
- Tokens->nParameters,
- ChrPtr(Tokens->FlatToken));
+ else if ((TP->Tokens->nParameters < Handler->nMinArgs) ||
+ (TP->Tokens->nParameters > Handler->nMaxArgs)) {
+ LogTemplateError(
+ Target, "Token", ERR_NAME, TP,
+ "doesn't work with %ld params need > %ld < %ld",
+ TP->Tokens->nParameters,
+ Handler->nMaxArgs,
+ Handler->nMinArgs);
}
else {
- Handler->HandlerFunc(Target,
- Tokens->nParameters,
- Tokens,
- Context,
- ContextType); /*TODO: subset of that */
-
+ Handler->HandlerFunc(Target, TP);
}
}
else {
- print_value_of(Target, Tokens, Context, ContextType);
+ print_value_of(Target, TP);
}
}
return 0;
int i, state;
const char *pData, *pS;
long len;
+ WCTemplputParams TP;
+
+ TP.Context = Context;
+ TP.ContextType = ContextType;
if (LoadTemplates != 0) {
if (LoadTemplates > 1)
StrBufAppendBufPlain(
Target, pData,
pTmpl->Tokens[i]->pTokenStart - pData, 0);
- state = EvaluateToken(Target, pTmpl->Tokens[i], pTmpl, Context, state, ContextType);
+ TP.Tokens = pTmpl->Tokens[i];
+ TP.nArgs = pTmpl->Tokens[i]->nParameters;
+ state = EvaluateToken(Target, state, &TP);
+
while ((state != 0) && (i+1 < pTmpl->nTokensUsed)) {
/* condition told us to skip till its end condition */
i++;
+ TP.Tokens = pTmpl->Tokens[i];
+ TP.nArgs = pTmpl->Tokens[i]->nParameters;
if ((pTmpl->Tokens[i]->Flags == SV_CONDITIONAL) ||
(pTmpl->Tokens[i]->Flags == SV_NEG_CONDITIONAL)) {
if (state == EvaluateConditional(
- Target,
- pTmpl->Tokens[i],
- pTmpl,
- Context,
- pTmpl->Tokens[i]->Flags,
+ Target,
+ pTmpl->Tokens[i]->Flags,
state,
- ContextType))
+ &TP))
state = 0;
}
}
* \brief Display a variable-substituted template
* \param templatename template file to load
*/
-void DoTemplate(const char *templatename, long len, StrBuf *Target, void *Context, int ContextType)
+void DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP)
{
HashList *Static;
HashList *StaticLocal;
}
if (vTmpl == NULL)
return;
- ProcessTemplate(vTmpl, Target, Context, ContextType);
+ ProcessTemplate(vTmpl, Target, TP->Context, TP->ContextType);
}
/*-----------------------------------------------------------------------------
Put(Iterators, Name, len, It, NULL);
}
-void tmpl_iterate_subtmpl(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
{
void *vIt;
HashIterator *It;
HashList *List;
HashPos *it;
- SortStruct *SortBy;
+ SortStruct *SortBy = NULL;
void *vSortBy;
int DetectGroupChange = 0;
int nMembersUsed;
long len;
const char *Key;
void *vContext;
- void *vLastContext;
+ void *vLastContext = NULL;
StrBuf *SubBuf;
int oddeven = 0;
+ WCTemplputParams SubTP;
+
+ memcpy (&SubTP, &TP, sizeof(WCTemplputParams));
if (!GetHash(Iterators, TKEY(0), &vIt)) {
- lprintf(1, "unknown Iterator [%s] (in '%s' line %ld); "
- " [%s]\n",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\nunknown Iterator [%s] (in '%s' line %ld); \n"
- " [%s]\n</pre>",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
+ LogTemplateError(
+ Target, "Iterator", ERR_PARM1, TP, "Unknown!");
return;
}
It = (HashIterator*) vIt;
- if (Tokens->nParameters < It->AdditionalParams + 2) {
- lprintf(1, "Iterator [%s] (in '%s' line %ld); "
- "doesn't work with %ld params [%s]\n",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->nParameters,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>Iterator [%s] \n(in '%s' line %ld);\n"
- "doesn't work with %ld params \n[%s]\n</pre>",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->nParameters,
- ChrPtr(Tokens->FlatToken));
+ if (TP->Tokens->nParameters < It->AdditionalParams + 2) {
+ LogTemplateError(
+ Target, "Iterator", ERR_PARM1, TP,
+ "doesn't work with %ld params",
+ TP->Tokens->nParameters);
return;
}
if ((It->XPectContextType != CTX_NONE) &&
- (It->XPectContextType != ContextType)) {
- lprintf(1, "Iterator [%s] (in '%s' line %ld); "
- "requires context of type %ld, have %ld [%s]\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- It->XPectContextType,
- ContextType,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\nIterator [%s] (in '%s' line %ld);"
- " requires context of type %ld, have %ld!\n[%s]\n</pre>\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
+ (It->XPectContextType != TP->ContextType)) {
+ LogTemplateError(
+ Target, "Iterator", ERR_PARM1, TP,
+ "requires context of type %ld, have %ld",
It->XPectContextType,
- ContextType,
- ChrPtr(Tokens->FlatToken));
+ TP->ContextType);
return ;
}
if (It->StaticList == NULL)
- List = It->GetHash(Target, nArgs, Tokens, Context, ContextType);
+ List = It->GetHash(Target, TP);
else
List = It->StaticList;
}
nMembersUsed = GetCount(List);
SubBuf = NewStrBuf();
+ SubTP.ContextType = It->ContextType;
it = GetNewHashPos(List, 0);
while (GetNextHashPos(List, it, &len, &Key, &vContext)) {
if (DetectGroupChange && nMembersCounted > 0) {
svprintf(HKEY("ITERATE:KEY"), WCS_STRING, "%s", Key);
svputlong("ITERATE:N", nMembersCounted);
svputlong("ITERATE:LASTN", ++nMembersCounted == nMembersUsed);
-
+ SubTP.Context = vContext;
if (It->DoSubTemplate != NULL)
- It->DoSubTemplate(SubBuf, vContext, Tokens);
- DoTemplate(TKEY(1), SubBuf, vContext, It->ContextType);
+ It->DoSubTemplate(SubBuf, &SubTP);
+ DoTemplate(TKEY(1), SubBuf, &SubTP);
StrBufAppendBuf(Target, SubBuf, 0);
FlushStrBuf(SubBuf);
/*-----------------------------------------------------------------------------
* Conditionals
*/
-int EvaluateConditional(StrBuf *Target, WCTemplateToken *Tokens, WCTemplate *pTmpl, void *Context, int Neg, int state, int ContextType)
+int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams *TP)
{
ConditionalStruct *Cond;
- if ((Tokens->Params[0]->len == 1) &&
- (Tokens->Params[0]->Start[0] == 'X'))
- return (state != 0)?Tokens->Params[1]->lvalue:0;
+ if ((TP->Tokens->Params[0]->len == 1) &&
+ (TP->Tokens->Params[0]->Start[0] == 'X'))
+ return (state != 0)?TP->Tokens->Params[1]->lvalue:0;
- Cond = (ConditionalStruct *) Tokens->PreEval;
+ Cond = (ConditionalStruct *) TP->Tokens->PreEval;
if (Cond == NULL) {
- lprintf(1, "Conditional [%s] (in '%s' line %ld); unknown![%s]\n",
- Tokens->Params[0]->Start,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
+ LogTemplateError(
+ Target, "Conditional", ERR_PARM1, TP,
+ "unknown!");
return 1;
}
- if (Tokens->nParameters < Cond->nParams) {
- lprintf(1, "Conditional [%s] (in '%s' line %ld); needs %ld Params![%s]\n",
- Tokens->Params[0]->Start,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
- Cond->nParams,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\nConditional [%s] (in '%s' line %ld); needs %ld Params!\n[%s]\n</pre>\n",
- Tokens->Params[0]->Start,
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
+ if (TP->Tokens->nParameters < Cond->nParams) {
+ LogTemplateError(
+ Target, "Conditional", ERR_PARM1, TP,
+ "needs %ld Params, have %ld!",
Cond->nParams,
- ChrPtr(Tokens->FlatToken));
+ TP->Tokens->nParameters);
return 0;
}
- if (Cond->CondF(Tokens, Context, ContextType) == Neg)
- return Tokens->Params[1]->lvalue;
+ if (Cond->CondF(Target, TP) == Neg)
+ return TP->Tokens->Params[1]->lvalue;
return 0;
}
-int ConditionalVar(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalVar(StrBuf *Target, WCTemplputParams *TP)
{
void *vsubst;
wcsubst *subst;
return 0;
subst = (wcsubst*) vsubst;
if ((subst->ContextRequired != CTX_NONE) &&
- (subst->ContextRequired != ContextType)) {
- lprintf(1," WARNING: Conditional requires Context: [%ld]!\n", Tokens->Params[2]->Start);
+ (subst->ContextRequired != TP->ContextType)) {
+ LogTemplateError(
+ Target, "ConditionalVar", ERR_PARM1, TP,
+ " WARNING: Conditional requires Context: [%ld], have [%ld]!",
+ subst->ContextRequired, CTX);
return -1;
}
case WCS_STRING:
case WCS_STRBUF:
case WCS_STRBUF_REF:
- if (Tokens->nParameters < 4)
+ if (TP->Tokens->nParameters < 4)
return 1;
- return (strcmp(Tokens->Params[3]->Start, ChrPtr(subst->wcs_value)) == 0);
+ return (strcmp(TP->Tokens->Params[3]->Start, ChrPtr(subst->wcs_value)) == 0);
case WCS_LONG:
- if (Tokens->nParameters < 4)
+ if (TP->Tokens->nParameters < 4)
return (subst->lvalue != 0);
- return (subst->lvalue == Tokens->Params[3]->lvalue);
+ return (subst->lvalue == TP->Tokens->Params[3]->lvalue);
default:
lprintf(1," WARNING: invalid type: [%ld]!\n", subst->wcs_type);
return -1;
/*-----------------------------------------------------------------------------
* Context Strings
*/
-void tmplput_ContextString(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_ContextString(StrBuf *Target, WCTemplputParams *TP)
{
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, (StrBuf*)Context, 0);
+ StrBufAppendTemplate(Target, TP, (StrBuf*)CTX, 0);
}
-int ConditionalContextStr(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalContextStr(StrBuf *Target, WCTemplputParams *TP)
{
- StrBuf *TokenText = (StrBuf*) Context;
+ StrBuf *TokenText = (StrBuf*) CTX;
const char *CompareToken;
long len;
- GetTemplateTokenString(Tokens, 2, &CompareToken, &len);
+ GetTemplateTokenString(TP, 2, &CompareToken, &len);
return strcmp(ChrPtr(TokenText), CompareToken) == 0;
}
* Boxed-API
*/
-void tmpl_do_boxed(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_do_boxed(StrBuf *Target, WCTemplputParams *TP)
{
+ WCTemplputParams SubTP;
+
StrBuf *Headline;
- if (nArgs == 2) {
- if (Tokens->Params[1]->Type == TYPE_STR) {
+ if (TP->Tokens->nParameters == 2) {
+ if (TP->Tokens->Params[1]->Type == TYPE_STR) {
Headline = NewStrBuf();
- DoTemplate(TKEY(1), Headline, Context, ContextType);
+ DoTemplate(TKEY(1), Headline, TP);
}
else {
const char *Ch;
long len;
- GetTemplateTokenString(Tokens,
+ GetTemplateTokenString(TP,
1,
&Ch,
&len);
Headline = NewStrBufPlain(Ch, len);
}
}
-
- DoTemplate(HKEY("beginbox"), Target, Headline, CTX_STRBUF);
- DoTemplate(TKEY(0), Target, Context, ContextType);
- DoTemplate(HKEY("endbox"), Target, Context, ContextType);
+ memcpy (&SubTP, TP, sizeof(WCTemplputParams));
+ SubTP.Context = Headline;
+ SubTP.ContextType = CTX_STRBUF;
+ DoTemplate(HKEY("beginbox"), Target, &SubTP);
+ DoTemplate(TKEY(0), Target, TP);
+ DoTemplate(HKEY("endbox"), Target, TP);
FreeStrBuf(&Headline);
}
* Tabbed-API
*/
-void tmpl_do_tabbed(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmpl_do_tabbed(StrBuf *Target, WCTemplputParams *TP)
{
StrBuf **TabNames;
int i, ntabs, nTabs;
- nTabs = ntabs = Tokens->nParameters / 2;
+ nTabs = ntabs = TP->Tokens->nParameters / 2;
TabNames = (StrBuf **) malloc(ntabs * sizeof(StrBuf*));
for (i = 0; i < ntabs; i++) {
- if ((Tokens->Params[i * 2]->Type == TYPE_STR) &&
- (Tokens->Params[i * 2]->len > 0)) {
+ if ((TP->Tokens->Params[i * 2]->Type == TYPE_STR) &&
+ (TP->Tokens->Params[i * 2]->len > 0)) {
TabNames[i] = NewStrBuf();
- DoTemplate(TKEY(i * 2), TabNames[i], Context, ContextType);
+ DoTemplate(TKEY(i * 2), TabNames[i], TP);
}
- else if (Tokens->Params[i * 2]->Type == TYPE_GETTEXT) {
+ else if (TP->Tokens->Params[i * 2]->Type == TYPE_GETTEXT) {
const char *Ch;
long len;
- GetTemplateTokenString(Tokens,
+ GetTemplateTokenString(TP,
i * 2,
&Ch,
&len);
StrTabbedDialog(Target, nTabs, TabNames);
for (i = 0; i < ntabs; i++) {
StrBeginTab(Target, i, nTabs);
- DoTemplate(TKEY(i * 2 + 1), Target, Context, ContextType);
+ DoTemplate(TKEY(i * 2 + 1), Target, TP);
StrEndTab(Target, i, nTabs);
}
}
Put(SortHash, name, len, NewSort, DestroySortStruct);
}
-CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix,
+CompareFunc RetrieveSort(WCTemplputParams *TP, const char *OtherPrefix,
const char *Default, long ldefault, long DefaultDirection)
{
int isdefault = 0;
- const StrBuf *BSort;
+ const StrBuf *BSort = NULL;
SortStruct *SortBy;
void *vSortBy;
long SortOrder = -1;
isdefault = 1;
if (!GetHash(SortHash, Default, ldefault, &vSortBy) ||
(vSortBy == NULL)) {
- lprintf(1, "Illegal default sort: [%s]\n", Default);
+ LogTemplateError(
+ NULL, "Sorting", ERR_PARM1, TP,
+ "Illegal default sort: [%s]", Default);
wc_backtrace();
}
}
SortOrder = LBSTR("SortOrder");
}
else { /** Try to fallback to our remembered values... */
- StrBuf *Buf;
+ StrBuf *Buf = NULL;
if (SortBy->PrefPrepend == NULL) {
Buf = get_room_pref("SortOrder");
SortOrder = StrTol(Buf);
};
-int GetSortMetric(WCTemplateToken *Tokens, SortStruct **Next, SortStruct **Param, long *SortOrder)
+int GetSortMetric(WCTemplputParams *TP, SortStruct **Next, SortStruct **Param, long *SortOrder)
{
int bSortError = eNOT_SPECIFIED;
const StrBuf *BSort;
BSort = get_room_pref("sort");
}
else {
- /* TODO: nail prefprepend to sort, and lookup this! */
+ BSort = NULL;/* TODO: nail prefprepend to sort, and lookup this! */
}
}
*SortOrder = StrTol(get_room_pref("SortOrder"));
}
else {
- /* TODO: nail prefprepend to sort, and lookup this! */
+ *SortOrder = 0;/* TODO: nail prefprepend to sort, and lookup this! */
}
}
if (*SortOrder > 2)
}
-void tmplput_SORT_ICON(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_SORT_ICON(StrBuf *Target, WCTemplputParams *TP)
{
long SortOrder;
SortStruct *Next;
SortStruct *Param;
const ConstStr *SortIcon;
- switch (GetSortMetric(Tokens, &Next, &Param, &SortOrder)){
+ switch (GetSortMetric(TP, &Next, &Param, &SortOrder)){
case eNO_SUCH_SORT:
- lprintf(1, "[%s] (in '%s' line %ld); "
- " Sorter [%s] unknown! [%s]\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\n [%s] (in '%s' line %ld);"
- " Sorter [%s] unknown!\n[%s]\n</pre>\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FlatToken));
+ LogTemplateError(
+ Target, "Sorter", ERR_PARM1, TP,
+ " Sorter [%s] unknown!",
+ TP->Tokens->Params[0]->Start);
break;
case eINVALID_PARAM:
- lprintf(1, "[%s] (in '%s' line %ld); "
- " Sorter specified by BSTR 'SortBy' [%s] unknown! [%s]\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- bstr("SortBy"),
- ChrPtr(Tokens->FlatToken));
+ LogTemplateError(NULL, "Sorter", ERR_PARM1, TP,
+ " Sorter specified by BSTR 'SortBy' [%s] unknown!",
+ bstr("SortBy"));
case eNOT_SPECIFIED:
case eFOUND:
if (Next == Param) {
}
}
-void tmplput_SORT_NEXT(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_SORT_NEXT(StrBuf *Target, WCTemplputParams *TP)
{
long SortOrder;
SortStruct *Next;
SortStruct *Param;
- switch (GetSortMetric(Tokens, &Next, &Param, &SortOrder)){
+ switch (GetSortMetric(TP, &Next, &Param, &SortOrder)){
case eNO_SUCH_SORT:
- lprintf(1, "[%s] (in '%s' line %ld); "
- " Sorter [%s] unknown! [%s]\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\n [%s] (in '%s' line %ld);"
- " Sorter [%s] unknown!\n[%s]\n</pre>\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FlatToken));
+ LogTemplateError(
+ Target, "Sorter", ERR_PARM1, TP,
+ " Sorter [%s] unknown!",
+ TP->Tokens->Params[0]->Start);
break;
case eINVALID_PARAM:
- lprintf(1, "[%s] (in '%s' line %ld); "
- " Sorter specified by BSTR 'SortBy' [%s] unknown! [%s]\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- bstr("SortBy"),
- ChrPtr(Tokens->FlatToken));
-
+ LogTemplateError(
+ NULL, "Sorter", ERR_PARM1, TP,
+ " Sorter specified by BSTR 'SortBy' [%s] unknown!",
+ bstr("SortBy"));
case eNOT_SPECIFIED:
case eFOUND:
StrBufAppendBuf(Target, Param->Name, 0);
}
}
-void tmplput_SORT_ORDER(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_SORT_ORDER(StrBuf *Target, WCTemplputParams *TP)
{
long SortOrder;
const ConstStr *SortOrderStr;
SortStruct *Next;
SortStruct *Param;
- switch (GetSortMetric(Tokens, &Next, &Param, &SortOrder)){
+ switch (GetSortMetric(TP, &Next, &Param, &SortOrder)){
case eNO_SUCH_SORT:
- lprintf(1, "[%s] (in '%s' line %ld); "
- " Sorter [%s] unknown! [%s]\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\n [%s] (in '%s' line %ld);"
- " Sorter [%s] unknown!\n[%s]\n</pre>\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FlatToken));
+ LogTemplateError(
+ Target, "Sorter", ERR_PARM1, TP,
+ " Sorter [%s] unknown!",
+ TP->Tokens->Params[0]->Start);
break;
case eINVALID_PARAM:
- lprintf(1, "[%s] (in '%s' line %ld); "
- " Sorter specified by BSTR 'SortBy' [%s] unknown! [%s]\n",
- Tokens->pName,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- bstr("SortBy"),
- ChrPtr(Tokens->FlatToken));
-
+ LogTemplateError(
+ NULL, "Sorter", ERR_PARM1, TP,
+ " Sorter specified by BSTR 'SortBy' [%s] unknown!",
+ bstr("SortBy"));
case eNOT_SPECIFIED:
case eFOUND:
if (Next == Param) {
}
-void tmplput_long_vector(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_long_vector(StrBuf *Target, WCTemplputParams *TP)
{
- long *LongVector = (long*) Context;
+ long *LongVector = (long*) CTX;
- if ((Tokens->Params[0]->Type == TYPE_LONG) &&
- (Tokens->Params[0]->lvalue <= LongVector[0]))
+ if ((TP->Tokens->Params[0]->Type == TYPE_LONG) &&
+ (TP->Tokens->Params[0]->lvalue <= LongVector[0]))
{
- StrBufAppendPrintf(Target, "%ld", LongVector[Tokens->Params[0]->lvalue]);
+ StrBufAppendPrintf(Target, "%ld", LongVector[TP->Tokens->Params[0]->lvalue]);
}
else
{
- if (Tokens->Params[0]->Type == TYPE_LONG) {
- lprintf(1, "longvector [%s] (in '%s' line %ld); needs a long Parameter![%s]\n",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\nlongvector [%s] (in '%s' line %ld); needs a numerical Parameter!\n[%s]\n</pre>\n",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
+ if (TP->Tokens->Params[0]->Type != TYPE_LONG) {
+ LogTemplateError(
+ Target, "Longvector", ERR_NAME, TP,
+ "needs a numerical Parameter!");
}
else {
- lprintf(1, "longvector [%s] (in '%s' line %ld); doesn't have %ld Parameters,"
- " its just the size of %ld![%s]\n",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->Params[0]->lvalue,
- LongVector[0],
- ChrPtr(Tokens->FlatToken));
- StrBufAppendPrintf(
- Target,
- "<pre>\nlongvector [%s] (in '%s' line %ld); doesn't have %ld Parameters,"
- " its just the size of %ld!\n[%s]\n</pre>\n",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->Params[0]->lvalue,
- LongVector[0],
- ChrPtr(Tokens->FlatToken));
+ LogTemplateError(
+ Target, "LongVector", ERR_PARM1, TP,
+ "doesn't have %ld Parameters, its just the size of %ld!",
+ TP->Tokens->Params[0]->lvalue,
+ LongVector[0]);
}
}
}
FreeStrBuf(&Buf);
}
-int ConditionalLongVector(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalLongVector(StrBuf *Target, WCTemplputParams *TP)
{
- long *LongVector = (long*) Context;
+ long *LongVector = (long*) CTX;
- if ((Tokens->Params[2]->Type == TYPE_LONG) &&
- (Tokens->Params[2]->lvalue <= LongVector[0])&&
- (Tokens->Params[3]->Type == TYPE_LONG) &&
- (Tokens->Params[3]->lvalue <= LongVector[0]))
+ if ((TP->Tokens->Params[2]->Type == TYPE_LONG) &&
+ (TP->Tokens->Params[2]->lvalue <= LongVector[0])&&
+ (TP->Tokens->Params[3]->Type == TYPE_LONG) &&
+ (TP->Tokens->Params[3]->lvalue <= LongVector[0]))
{
- return LongVector[Tokens->Params[2]->lvalue] == LongVector[Tokens->Params[3]->lvalue];
+ return LongVector[TP->Tokens->Params[2]->lvalue] ==
+ LongVector[TP->Tokens->Params[3]->lvalue];
}
else
{
- if ((Tokens->Params[2]->Type == TYPE_LONG) ||
- (Tokens->Params[2]->Type == TYPE_LONG)) {
- lprintf(1, "ConditionalLongVector [%s] (in '%s' line %ld); needs two long Parameter![%s]\n",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken));
+ if ((TP->Tokens->Params[2]->Type == TYPE_LONG) ||
+ (TP->Tokens->Params[2]->Type == TYPE_LONG)) {
+ LogTemplateError(
+ Target, "ConditionalLongvector", ERR_PARM1, TP,
+ "needs two long Parameter!");
}
else {
- lprintf(1, "longvector [%s] (in '%s' line %ld); doesn't have %ld / %ld Parameters,"
- " its just the size of %ld![%s]\n",
- Tokens->Params[0]->Start,
- ChrPtr(Tokens->FileName),
- Tokens->Line,
- Tokens->Params[2]->lvalue,
- Tokens->Params[3]->lvalue,
- LongVector[0],
- ChrPtr(Tokens->FlatToken));
+ LogTemplateError(
+ Target, "Longvector", ERR_PARM1, TP,
+ "doesn't have %ld / %ld Parameters, its just the size of %ld!",
+ TP->Tokens->Params[2]->lvalue,
+ TP->Tokens->Params[3]->lvalue,
+ LongVector[0]);
}
}
return 0;
InitModule_SUBST
(void)
{
+ memset(&NoCtx, 0, sizeof(WCTemplputParams));
RegisterNamespace("SORT:ICON", 1, 1, tmplput_SORT_ICON, CTX_NONE);
RegisterNamespace("SORT:ORDER", 1, 1, tmplput_SORT_ORDER, CTX_NONE);
RegisterNamespace("SORT:NEXT", 1, 1, tmplput_SORT_NEXT, CTX_NONE);
WCS_LONG /* its an integer */
};
-
+typedef struct WCTemplateToken WCTemplateToken;
+typedef struct WCTemplputParams WCTemplputParams;
+typedef void (*WCHandlerFunc)(StrBuf *Target, WCTemplputParams *TP);
typedef struct _TemplateParam {
const char *Start;
} TemplateParam;
/* make a template token a lookup key: */
-#define TKEY(a) Tokens->Params[a]->Start, Tokens->Params[a]->len
-typedef struct _TemplateToken {
+#define TKEY(a) TP->Tokens->Params[a]->Start, TP->Tokens->Params[a]->len
+struct WCTemplateToken {
const StrBuf *FileName; /* Reference to print error messages; not to be freed */
StrBuf *FlatToken;
long Line;
int HaveParameters;
int nParameters;
TemplateParam *Params[MAXPARAM];
-} WCTemplateToken;
-
-typedef void (*WCHandlerFunc)();
+};
/*
WCHandlerFunc wcs_function; /* funcion hook ???*/
} wcsubst;
+struct WCTemplputParams {
+ int nArgs;
+ WCTemplateToken *Tokens;
+ void *Context;
+ int ContextType;
+};
+
+
+extern WCTemplputParams NoCtx;
+
+#define CTX TP->Context
+
+
+
#define CTX_NONE 0
#define CTX_SITECFG 1
#define CTX_SESSION 2
int ContextRequired);
#define RegisterNamespace(a, b, c, d, e) RegisterNS(a, sizeof(a)-1, b, c, d, e)
-typedef int (*WCConditionalFunc)(WCTemplateToken *Token, void *Context, int ContextType);
+typedef int (*WCConditionalFunc)(StrBuf *Target, WCTemplputParams *TP);
typedef struct _ConditionalStruct {
const char *PlainName;
int nParams;
-typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context, WCTemplateToken *Token);
-typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType);
+typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, WCTemplputParams *TP);
+typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, WCTemplputParams *TP);
typedef void (*HashDestructorFunc) (HashList **KillMe);
void RegisterITERATOR(const char *Name, long len, /* Our identifier */
int AdditionalParams, /* doe we use more parameters? */
#define RegisterIterator(a, b, c, d, e, f, g, h, i) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h, i)
-void GetTemplateTokenString(WCTemplateToken *Tokens,
- int N,
+void GetTemplateTokenString(WCTemplputParams *TP,
+ int N,
const char **Value,
long *len);
void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref);
#define SVPutBuf(a, b, c); SVPUTBuf(a, sizeof(a) - 1, b, c)
-void DoTemplate(const char *templatename, long len, StrBuf *Target, void *Context, int ContextType);
-#define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, b, 0);
+void DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP);
+#define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, &NoCtx);
void url_do_template(void);
int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
void StrBufAppendTemplate(StrBuf *Target,
- int nArgs,
- WCTemplateToken *Tokens,
- void *Context, int ContextType,
- const StrBuf *Source, int FormatTypeIndex);
-CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix,
+ WCTemplputParams *TP,
+ const StrBuf *Source,
+ int FormatTypeIndex);
+CompareFunc RetrieveSort(WCTemplputParams *TP, const char *OtherPrefix,
const char *Default, long ldefault, long DefaultDirection);
void RegisterSortFunc(const char *name, long len,
const char *prepend, long preplen,
long ContextType);
void dbg_print_longvector(long *LongVector);
+
+
+#define ERR_NAME 0
+#define ERR_PARM1 1
+#define ERR_PARM2 2
+void LogTemplateError (StrBuf *Target,
+ const char *Type,
+ int ErrorPos,
+ WCTemplputParams *TP,
+ const char *Format, ...);
void *vMsg;
message_summary *Msg;
wcsession *WCC = WC;
+ StrBuf *Buf;
- gotoroom("_TASKS_");
+ Buf = NewStrBufPlain(HKEY("_TASKS_"));
+ gotoroom(Buf);
+ FreeStrBuf(&Buf);
if (WCC->wc_view != VIEW_TASKS) {
num_msgs = 0;
}
message_summary *Msg;
wcsession *WCC = WC;
struct calview c;
+ StrBuf *Buf;
- gotoroom("_CALENDAR_");
+ Buf = NewStrBufPlain(HKEY("_CALENDAR_"));
+ gotoroom(Buf);
+ FreeStrBuf(&Buf);
if ( (WC->wc_view != VIEW_CALENDAR) && (WC->wc_view != VIEW_CALBRIEF) ) {
num_msgs = 0;
}
snprintf(message, sizeof message,
_("You are connected to %s, running %s with %s, server build %s and located in %s. Your system administrator is %s."),
- serv_info.serv_humannode,
- serv_info.serv_software,
- PACKAGE_STRING,
- serv_info.serv_svn_revision,
- serv_info.serv_bbs_city,
- serv_info.serv_sysadm);
+ ChrPtr(serv_info.serv_humannode),
+ ChrPtr(serv_info.serv_software),
+ PACKAGE_STRING,
+ ChrPtr(serv_info.serv_svn_revision),
+ ChrPtr(serv_info.serv_bbs_city),
+ ChrPtr(serv_info.serv_sysadm));
escputs(message);
}
wprintf("<div class=\"room_banner\">");
wprintf("<img src=\"static/summscreen_48x.gif\">");
wprintf("<h1>");
- snprintf(title, sizeof title, _("Summary page for %s"), WC->wc_fullname);
+ snprintf(title, sizeof title, _("Summary page for %s"), ChrPtr(WC->wc_fullname));
escputs(title);
wprintf("</h1><h2>");
output_date();
wprintf("</h2></div>");
wprintf("<ul class=\"room_actions\">\n");
wprintf("<li class=\"start_page\">");
- offer_start_page(NULL, 0, NULL, NULL, CTX_NONE);
+ offer_start_page(NULL, &NoCtx);
wprintf("</li></ul>");
wprintf("</div>");
void display_editbio(void) {
char buf[SIZ];
- snprintf(buf, SIZ, "RBIO %s", WC->wc_fullname);
+ snprintf(buf, SIZ, "RBIO %s", ChrPtr(WC->wc_fullname));
display_edit(_("Your bio"), "NOOP", buf, "editbio", 3);
}
void editbio(void) { save_edit(_("Your bio"), "EBIO", 0); }
}
-HashList *iterate_load_userlist(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
{
HashList *Hash;
char buf[SIZ];
}
-void tmplput_USERLIST_UserName(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_USERLIST_UserName(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
- StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, ul->UserName, 0);
+ UserListEntry *ul = (UserListEntry*) CTX;
+ StrBufAppendTemplate(Target, TP, ul->UserName, 0);
}
-void tmplput_USERLIST_AccessLevelNo(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_USERLIST_AccessLevelNo(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
StrBufAppendPrintf(Target, "%d", ul->AccessLevel, 0);
}
-void tmplput_USERLIST_AccessLevelStr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_USERLIST_AccessLevelStr(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
StrBufAppendBufPlain(Target, _(axdefs[ul->AccessLevel]), -1, 0);
}
-void tmplput_USERLIST_UID(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_USERLIST_UID(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
StrBufAppendPrintf(Target, "%d", ul->UID, 0);
}
-void tmplput_USERLIST_LastLogonNo(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_USERLIST_LastLogonNo(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
StrBufAppendPrintf(Target,"%ld", ul->LastLogonT, 0);
}
-void tmplput_USERLIST_LastLogonStr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_USERLIST_LastLogonStr(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
StrEscAppend(Target, NULL, asctime(localtime(&ul->LastLogonT)), 0, 0);
}
-void tmplput_USERLIST_nLogons(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_USERLIST_nLogons(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
StrBufAppendPrintf(Target, "%d", ul->nLogons, 0);
}
-void tmplput_USERLIST_nPosts(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_USERLIST_nPosts(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
StrBufAppendPrintf(Target, "%d", ul->nPosts, 0);
}
-void tmplput_USERLIST_Flags(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_USERLIST_Flags(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
StrBufAppendPrintf(Target, "%d", ul->Flags, 0);
}
-void tmplput_USERLIST_DaysTillPurge(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_USERLIST_DaysTillPurge(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
StrBufAppendPrintf(Target, "%d", ul->DaysTillPurge, 0);
}
-int ConditionalUser(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalUser(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
if (havebstr("usernum")) {
return ibstr("usernum") == ul->UID;
}
return 0;
}
-int ConditionalFlagINetEmail(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalFlagINetEmail(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
return (ul->Flags & US_INTERNET) != 0;
}
-int ConditionalUserAccess(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalUserAccess(StrBuf *Target, WCTemplputParams *TP)
{
- UserListEntry *ul = (UserListEntry*) Context;
+ UserListEntry *ul = (UserListEntry*) CTX;
- if (Tokens->Params[3]->Type == TYPE_LONG)
- return (Tokens->Params[3]->lvalue == ul->AccessLevel);
+ if (TP->Tokens->Params[3]->Type == TYPE_LONG)
+ return (TP->Tokens->Params[3]->lvalue == ul->AccessLevel);
else
return 0;
}
delete_user(username);
}
else {
+ WCTemplputParams SubTP;
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_USERLIST;
+ SubTP.Context = UL;
output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(HKEY("userlist_detailview"), NULL, (void*) UL, CTX_USERLIST);
+ DoTemplate(HKEY("userlist_detailview"), NULL, &SubTP);
end_burst();
}
DeleteUserListEntry(UL);
output_headers(1, 1, 2, 0, 0, 0);
wprintf("<div id=\"banner\">\n");
wprintf("<h1>");
- snprintf(title, sizeof title, _("User list for %s"), serv_info.serv_humannode);
+ snprintf(title, sizeof title, _("User list for %s"), ChrPtr(serv_info.serv_humannode));
escputs(title);
wprintf("</h1>");
wprintf("</div>");
}
-void escputs1(char *strbuf, int nbsp, int nolinebreaks)
+void escputs1(const char *strbuf, int nbsp, int nolinebreaks)
{
StrEscAppend(WC->WBuf, NULL, strbuf, nbsp, nolinebreaks);
}
/*
* static wrapper for ecsputs1
*/
-void escputs(char *strbuf)
+void escputs(const char *strbuf)
{
escputs1(strbuf, 0, 0);
}
display_vcard(WC->WBuf, vcard_source, alpha, 0, NULL,msgnum);
/** If it's my vCard I can edit it */
- if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
- || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
+ if ( (!strcasecmp(ChrPtr(WC->wc_roomname), USERCONFIGROOM))
+ || (!strcasecmp(&(ChrPtr(WC->wc_roomname)[11]), USERCONFIGROOM))
|| (WC->wc_view == VIEW_ADDRESSBOOK)
) {
wprintf("<a href=\"edit_vcard?"
* and MIME part number to fetch. Or, specify -1 for the message number
* to start with a blank card.
*/
-void do_edit_vcard(long msgnum, char *partnum, char *return_to, char *force_room) {
+void do_edit_vcard(long msgnum, char *partnum, char *return_to, const char *force_room) {
char buf[SIZ];
char *serialized_vcard = NULL;
size_t total_len = 0;
}
if (havebstr("force_room")) {
- gotoroom(bstr("force_room"));
+ gotoroom(sbstr("force_room"));
}
sprintf(buf, "ENT0 1|||4||");
void initialize_locales(void);
void ShutdownLocale(void);
#endif
-void TmplGettext(StrBuf *Target, int nTokens, WCTemplateToken *Token);
+void TmplGettext(StrBuf *Target, WCTemplputParams *TP);
void offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
void set_selected_language(const char *);
void go_selected_language(void);
hprintf("Content-type: text/html; charset=utf-8\r\n"
"Server: %s / %s\n"
"Connection: close\r\n",
- PACKAGE_STRING, serv_info.serv_software
+ PACKAGE_STRING,
+ ChrPtr(serv_info.serv_software)
);
}
);
}
- stuff_to_cookie(cookie, 1024, WC->wc_session, WC->wc_username,
+ stuff_to_cookie(cookie, 1024,
+ WC->wc_session, WC->wc_username,
WC->wc_password, WC->wc_roomname);
if (unset_cookies) {
const StrBuf *Tmpl = sbstr("template");
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
- DoTemplate(ChrPtr(Tmpl), StrLength(Tmpl), NULL, NULL, 0);
+ DoTemplate(SKEY(Tmpl), NULL, &NoCtx);
end_burst();
}
void authorization_required(const char *message)
{
hprintf("HTTP/1.1 401 Authorization Required\r\n");
- hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n", serv_info.serv_humannode);
+ hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n", ChrPtr(serv_info.serv_humannode));
hprintf("Content-Type: text/html\r\n");
wprintf("<h1>");
wprintf(_("Authorization Required"));
wprintf("NO\n");
}
else {
- memset(buf, 5, 0);
+ memset(buf, 0, 5);
serv_puts("NOOP");
serv_getln(buf, sizeof buf);
if (buf[3] == '*') {
*/
void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method, StrBuf *ReadBuf)
{
+ StrBuf *Buf;
const char *pch, *pchs, *pche;
void *vLine;
char action[1024];
* We stuff these with the values coming from the client cookies,
* so we can use them to reconnect a timed out session if we have to.
*/
- char c_username[SIZ];
- char c_password[SIZ];
- char c_roomname[SIZ];
+ StrBuf *c_username;
+ StrBuf *c_password;
+ StrBuf *c_roomname;
char c_httpauth_string[SIZ];
- char c_httpauth_user[SIZ];
- char c_httpauth_pass[SIZ];
+ StrBuf *c_httpauth_user;
+ StrBuf *c_httpauth_pass;
wcsession *WCC;
- safestrncpy(c_username, "", sizeof c_username);
- safestrncpy(c_password, "", sizeof c_password);
- safestrncpy(c_roomname, "", sizeof c_roomname);
+ Buf = NewStrBuf();
+ c_username = NewStrBuf();
+ c_password = NewStrBuf();
+ c_roomname = NewStrBuf();
safestrncpy(c_httpauth_string, "", sizeof c_httpauth_string);
- safestrncpy(c_httpauth_user, DEFAULT_HTTPAUTH_USER, sizeof c_httpauth_user);
- safestrncpy(c_httpauth_pass, DEFAULT_HTTPAUTH_PASS, sizeof c_httpauth_pass);
+ c_httpauth_user = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
+ c_httpauth_pass = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
strcpy(browser_host, "");
WCC= WC;
if (GetHash(HTTPHeaders, HKEY("COOKIE"), &vLine) &&
(vLine != NULL)){
cookie_to_stuff((StrBuf *)vLine, NULL,
- c_username, sizeof c_username,
- c_password, sizeof c_password,
- c_roomname, sizeof c_roomname);
+ c_username,
+ c_password,
+ c_roomname);
}
if (GetHash(HTTPHeaders, HKEY("AUTHORIZATION"), &vLine) &&
(vLine!=NULL)) {
+/* TODO: wrap base64 in strbuf */
CtdlDecodeBase64(c_httpauth_string, ChrPtr((StrBuf*)vLine), StrLength((StrBuf*)vLine));
- extract_token(c_httpauth_user, c_httpauth_string, 0, ':', sizeof c_httpauth_user);
- extract_token(c_httpauth_pass, c_httpauth_string, 1, ':', sizeof c_httpauth_pass);
+ FlushStrBuf(Buf);
+ StrBufAppendBufPlain(Buf, c_httpauth_string, -1, 0);
+ StrBufExtract_token(c_httpauth_user, Buf, 0, ':');
+ StrBufExtract_token(c_httpauth_pass, Buf, 1, ':');
}
if (GetHash(HTTPHeaders, HKEY("CONTENT-LENGTH"), &vLine) &&
(vLine!=NULL)) {
* try logging in to Citadel using that.
*/
if ((!WCC->logged_in)
- && (strlen(c_httpauth_user) > 0)
- && (strlen(c_httpauth_pass) > 0)) {
- serv_printf("USER %s", c_httpauth_user);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '3') {
- serv_printf("PASS %s", c_httpauth_pass);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
+ && (StrLength(c_httpauth_user) > 0)
+ && (StrLength(c_httpauth_pass) > 0))
+ {
+ FlushStrBuf(Buf);
+ serv_printf("USER %s", ChrPtr(c_httpauth_user));
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 3) {
+ serv_printf("PASS %s", ChrPtr(c_httpauth_pass));
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
become_logged_in(c_httpauth_user,
- c_httpauth_pass, buf);
- safestrncpy(WCC->httpauth_user, c_httpauth_user, sizeof WCC->httpauth_user);
- safestrncpy(WCC->httpauth_pass, c_httpauth_pass, sizeof WCC->httpauth_pass);
+ c_httpauth_pass, Buf);
+ if (WCC->httpauth_user == NULL)
+ WCC->httpauth_user = NewStrBufDup(c_httpauth_user);
+ else {
+ FlushStrBuf(WCC->httpauth_user);
+ StrBufAppendBuf(WCC->httpauth_user, c_httpauth_user, 0);
+ }
+ if (WCC->httpauth_pass == NULL)
+ WCC->httpauth_pass = NewStrBufDup(c_httpauth_pass);
+ else {
+ FlushStrBuf(WCC->httpauth_pass);
+ StrBufAppendBuf(WCC->httpauth_pass, c_httpauth_pass, 0);
+ }
} else {
/* Should only display when password is wrong */
authorization_required(&buf[4]);
+ FreeStrBuf(&Buf);
goto SKIP_ALL_THIS_CRAP;
}
}
/* This needs to run early */
#ifdef TECH_PREVIEW
if (!strcasecmp(action, "rss")) {
- display_rss(bstr("room"), request_method);
+ display_rss(sbstr("room"), request_method);
goto SKIP_ALL_THIS_CRAP;
}
#endif
* supplied by the browser, try using them to log in.
*/
if ((!WCC->logged_in)
- && (!IsEmptyStr(c_username))
- && (!IsEmptyStr(c_password))) {
- serv_printf("USER %s", c_username);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '3') {
- serv_printf("PASS %s", c_password);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
+ && (StrLength(c_username)>0)
+ && (StrLength(c_password)>0)) {
+ serv_printf("USER %s", ChrPtr(c_username));
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 3) {
+ serv_printf("PASS %s", ChrPtr(c_password));
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
StrBuf *Lang;
- become_logged_in(c_username, c_password, buf);
+ become_logged_in(c_username, c_password, Buf);
if (get_preference("language", &Lang)) {
set_selected_language(ChrPtr(Lang));
go_selected_language(); /* set locale */
* prior to doing anything else.
*/
if (havebstr("gotofirst")) {
- gotoroom(bstr("gotofirst")); /* do this quietly to avoid session output! */
+ gotoroom(sbstr("gotofirst")); /* do this quietly to avoid session output! */
}
/*
* If we don't have a current room, but a cookie specifying the
* current room is supplied, make an effort to go there.
*/
- if ((IsEmptyStr(WCC->wc_roomname)) && (!IsEmptyStr(c_roomname))) {
- serv_printf("GOTO %s", c_roomname);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
- safestrncpy(WCC->wc_roomname, c_roomname, sizeof WCC->wc_roomname);
+ if ((StrLength(WCC->wc_roomname) == 0) && (StrLength(c_roomname) > 0)) {
+ serv_printf("GOTO %s", ChrPtr(c_roomname));
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ if (WCC->wc_roomname == NULL) {
+ WCC->wc_roomname = NewStrBufDup(c_roomname);
+ }
+ else {
+ FlushStrBuf(WCC->wc_roomname);
+ StrBufAppendBuf(WCC->wc_roomname, c_roomname, 0);
+ }
}
}
}
SKIP_ALL_THIS_CRAP:
+ FreeStrBuf(&Buf);
+ FreeStrBuf(&c_username);
+ FreeStrBuf(&c_password);
+ FreeStrBuf(&c_roomname);
+ FreeStrBuf(&c_httpauth_user);
+ FreeStrBuf(&c_httpauth_pass);
fflush(stdout);
if (content != NULL) {
FreeStrBuf(&content);
}
-int ConditionalImportantMesage(WCTemplateToken *Tokens, void *Context, int ContextType)
+int ConditionalImportantMesage(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
if (WCC != NULL)
return 0;
}
-void tmplput_importantmessage(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_importantmessage(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
}
}
-void tmplput_trailing_javascript(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+void tmplput_trailing_javascript(StrBuf *Target, WCTemplputParams *TP)
{
wcsession *WCC = WC;
if (WCC != NULL)
- StrBufAppendTemplate(Target, nArgs, Tokens, vContext, ContextType,
- WCC->trailing_javascript, 0);
+ StrBufAppendTemplate(Target, TP, WCC->trailing_javascript, 0);
}
-void tmplput_csslocal(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+void tmplput_csslocal(StrBuf *Target, WCTemplputParams *TP)
{
extern StrBuf *csslocal;
StrBufAppendBuf(Target,
RegisterConditional(HKEY("COND:IMPMSG"), 0, ConditionalImportantMesage, CTX_NONE);
RegisterNamespace("CSSLOCAL", 0, 0, tmplput_csslocal, CTX_NONE);
RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, CTX_NONE);
- RegisterNamespace("OFFERSTARTPAGE", 0, 0, offer_start_page, CTX_NONE);
RegisterNamespace("TRAILING_JAVASCRIPT", 0, 0, tmplput_trailing_javascript, CTX_NONE);
}
*/
struct serv_info {
int serv_pid; /* Process ID of the Citadel server */
- char serv_nodename[32]; /* Node name of the Citadel server */
- char serv_humannode[64]; /* human readable node name of the Citadel server */
- char serv_fqdn[64]; /* fully quallified Domain Name (such as uncensored.citadel.org) */
- char serv_software[64]; /* What version does our connected citadel server use */
+ StrBuf *serv_nodename; /* Node name of the Citadel server */
+ StrBuf *serv_humannode; /* human readable node name of the Citadel server */
+ StrBuf *serv_fqdn; /* fully quallified Domain Name (such as uncensored.citadel.org) */
+ StrBuf *serv_software; /* What version does our connected citadel server use */
int serv_rev_level; /* Whats the citadel server revision */
- char serv_bbs_city[64]; /* Geographic location of the Citadel server */
- char serv_sysadm[64]; /* Name of system administrator */
- char serv_moreprompt[256]; /* Whats the commandline textprompt */
+ StrBuf *serv_bbs_city; /* Geographic location of the Citadel server */
+ StrBuf *serv_sysadm; /* Name of system administrator */
+ StrBuf *serv_moreprompt; /* Whats the commandline textprompt */
int serv_ok_floors; /* nonzero == server supports floors */
int serv_supports_ldap; /* is the server linked against an ldap tree for adresses? */
int serv_newuser_disabled; /* Has the server disabled self-service new user creation? */
- char serv_default_cal_zone[128];/* Default timezone for unspecified calendar items */
+ StrBuf *serv_default_cal_zone; /* Default timezone for unspecified calendar items */
int serv_supports_sieve; /* Does the server support Sieve mail filtering? */
int serv_fulltext_enabled; /* Does the server have the full text index enabled? */
- char serv_svn_revision[256]; /* SVN revision of the server */
+ StrBuf *serv_svn_revision; /* SVN revision of the server */
int serv_supports_openid; /* Does the server support authentication via OpenID? */
};
struct wcsession {
wcsession *next; /**< Linked list */
int wc_session; /**< WebCit session ID */
- char wc_username[128]; /**< login name of current user */
- char wc_fullname[128]; /**< Screen name of current user */
- char wc_password[128]; /**< Password of current user */
- char wc_roomname[256]; /**< Room we are currently in */
+ StrBuf *wc_username; /**< login name of current user */
+ StrBuf *wc_fullname; /**< Screen name of current user */
+ StrBuf *wc_password; /**< Password of current user */
+ StrBuf *wc_roomname; /**< Room we are currently in */
int connected; /**< nonzero == we are connected to Citadel */
int logged_in; /**< nonzero == we are logged in */
int axlevel; /**< this user's access level */
char last_chat_user[256]; /**< ??? todo */
char ImportantMessage[SIZ]; /**< ??? todo */
int ctdl_pid; /**< Session ID on the Citadel server */
- char httpauth_user[256]; /**< only for GroupDAV sessions */
- char httpauth_pass[256]; /**< only for GroupDAV sessions */
+ StrBuf *httpauth_user; /**< only for GroupDAV sessions */
+ StrBuf *httpauth_pass; /**< only for GroupDAV sessions */
int gzip_ok; /**< Nonzero if Accept-encoding: gzip */
int is_mailbox; /**< the current room is a private mailbox */
struct folder *cache_fold; /**< cache the iconbar room list */
void stuff_to_cookie(char *cookie, size_t clen, int session,
- char *user, char *pass, char *room);
+ StrBuf *user, StrBuf *pass, StrBuf *room);
void cookie_to_stuff(StrBuf *cookie, int *session,
- char *user, size_t user_len,
- char *pass, size_t pass_len,
- char *room, size_t room_len);
+ StrBuf *user,
+ StrBuf *pass,
+ StrBuf *room);
void locate_host(char *, int);
-void become_logged_in(char *, char *, char *);
+void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_response);
void openid_manual_create(void);
void display_login();
void display_openids(void);
void print_menu_box(char* Title, char *Class, int nLines, ...);
long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks);
-void escputs(char *strbuf);
+void escputs(const char *strbuf);
void url(char *buf, size_t bufsize);
void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf);
-void escputs1(char *strbuf, int nbsp, int nolinebreaks);
+void escputs1(const char *strbuf, int nbsp, int nolinebreaks);
void msgesc(char *target, size_t tlen, char *strbuf);
void msgescputs(char *strbuf);
void msgescputs1(char *strbuf);
void save_edit(char *description, char *enter_cmd, int regoto);
void display_edit(char *description, char *check_cmd,
char *read_cmd, char *save_cmd, int with_room_banner);
-int gotoroom(char *gname);
+long gotoroom(const StrBuf *gname);
void confirm_delete_room(void);
void validate(void);
void display_graphics_upload(char *, char *, char *);
void load_floorlist(void);
void shutdown_sessions(void);
void do_housekeeping(void);
-void smart_goto(char *);
+void smart_goto(const StrBuf *);
void worker_entry(void);
void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *ReqType, StrBuf *ReadBuf);
size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm);
char *load_mimepart(long msgnum, char *partnum);
void MimeLoadData(wc_mime_attachment *Mime);
int pattern2(char *search, char *patn);
-void do_edit_vcard(long, char *, char *, char *);
+void do_edit_vcard(long, char *, char *, const char *);
void striplt(char *);
void stripltlen(char *, int *);
void select_user_to_edit(char *message, char *preselect);
void display_addressbook(long msgnum, char alpha);
-void offer_start_page(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
+void offer_start_page(StrBuf *Target, WCTemplputParams *TP);
void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext);
void output_html(const char *, int, int, StrBuf *, StrBuf *);
void do_listsub(void);
long unescape_input(char *buf);
void do_selected_iconbar(void);
void spawn_another_worker_thread(void);
-void display_rss(char *roomname, StrBuf *request_method);
+void display_rss(const StrBuf *roomname, StrBuf *request_method);
void StrEndTab(StrBuf *Target, int tabnum, int num_tabs);
void StrBeginTab(StrBuf *Target, int tabnum, int num_tabs);
void StrTabbedDialog(StrBuf *Target, int num_tabs, StrBuf *tabnames[]);
terminate_session();
}
-HashList *GetWholistHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+HashList *GetWholistHash(StrBuf *Target, WCTemplputParams *TP)
+
{
HashList *List;
char buf[SIZ];
DeleteHash(KillMe);
}
-void tmplput_who_username(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+void tmplput_who_username(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
- StrBufAppendTemplate(Target, nArgs, Tokens, vContext, ContextType, User->UserName, 0);
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, User->UserName, 0);
}
-void tmplput_who_room(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+void tmplput_who_room(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
- StrBufAppendTemplate(Target, nArgs, Tokens, vContext, ContextType, User->Room, 0);
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, User->Room, 0);
}
-void tmplput_who_host(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+void tmplput_who_host(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
- StrBufAppendTemplate(Target, nArgs, Tokens, vContext, ContextType, User->Host, 0);
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, User->Host, 0);
}
-void tmplput_who_realroom(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+void tmplput_who_realroom(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
- StrBufAppendTemplate(Target, nArgs, Tokens, vContext, ContextType, User->RealRoom, 0);
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, User->RealRoom, 0);
}
-int conditional_who_realroom(WCTemplateToken *Tokens, void *vContext, int ContextType)
+int conditional_who_realroom(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
+ UserStateStruct *User = (UserStateStruct*) CTX;
return StrLength(User->RealRoom) > 0;
}
-void tmplput_who_realhost(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+void tmplput_who_realhost(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
- StrBufAppendTemplate(Target, nArgs, Tokens, vContext, ContextType, User->RealHost, 0);
+ UserStateStruct *User = (UserStateStruct*) CTX;
+ StrBufAppendTemplate(Target, TP, User->RealHost, 0);
}
-void tmplput_who_lastactive(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+void tmplput_who_lastactive(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
+ UserStateStruct *User = (UserStateStruct*) CTX;
StrBufAppendPrintf(Target, "%d", User->LastActive);
}
-void tmplput_who_idlesince(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+void tmplput_who_idlesince(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
+ UserStateStruct *User = (UserStateStruct*) CTX;
StrBufAppendPrintf(Target, "%d", User->IdleSince);
}
-void tmplput_who_session(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+void tmplput_who_session(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
+ UserStateStruct *User = (UserStateStruct*) CTX;
StrBufAppendPrintf(Target, "%d", User->Session);
}
-int conditional_who_idle(WCTemplateToken *Tokens, void *vContext, int ContextType)
+int conditional_who_idle(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
+ UserStateStruct *User = (UserStateStruct*) CTX;
return User->Idle;
}
-int conditional_who_nsessions(WCTemplateToken *Tokens, void *vContext, int ContextType)
+int conditional_who_nsessions(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
+ UserStateStruct *User = (UserStateStruct*) CTX;
return User->SessionCount;
}
-void tmplput_who_nsessions(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *vContext, int ContextType)
+void tmplput_who_nsessions(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
+ UserStateStruct *User = (UserStateStruct*) CTX;
StrBufAppendPrintf(Target, "%d", User->SessionCount);
}
-int conditional_who_isme(WCTemplateToken *Tokens, void *vContext, int ContextType)
+int conditional_who_isme(StrBuf *Target, WCTemplputParams *TP)
{
- UserStateStruct *User = (UserStateStruct*) vContext;
+ UserStateStruct *User = (UserStateStruct*) CTX;
return (User->Session == WC->ctdl_pid);
}
*/
void display_wiki_page(void)
{
- char roomname[128];
+ const StrBuf *roomname;
char pagename[128];
char errmsg[256];
long msgnum = (-1L);
- safestrncpy(roomname, bstr("room"), sizeof roomname);
+ roomname = sbstr("room");
safestrncpy(pagename, bstr("page"), sizeof pagename);
str_wiki_index(pagename);
- if (!IsEmptyStr(roomname)) {
+ if (StrLength(roomname) > 0) {
/* If we're not in the correct room, try going there. */
- if (strcasecmp(roomname, WC->wc_roomname)) {
+ if (strcasecmp(ChrPtr(roomname), ChrPtr(WC->wc_roomname))) {
gotoroom(roomname);
}
/* If we're still not in the correct room, it doesn't exist. */
- if (strcasecmp(roomname, WC->wc_roomname)) {
+ if (strcasecmp(ChrPtr(roomname), ChrPtr(WC->wc_roomname))) {
snprintf(errmsg, sizeof errmsg,
- _("There is no room called '%s'."),
- roomname);
+ _("There is no room called '%s'."),
+ ChrPtr(roomname));
convenience_page("FF0000", _("Error"), errmsg);
return;
}
if (WC->wc_view != VIEW_WIKI) {
snprintf(errmsg, sizeof errmsg,
_("'%s' is not a Wiki room."),
- roomname);
+ ChrPtr(roomname));
convenience_page("FF0000", _("Error"), errmsg);
return;
}