From 808f3be91dd6b6677e380695e2f16e6473141a7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Thu, 8 Jan 2009 23:11:56 +0000 Subject: [PATCH] * move some more vars from the session context to strbuf (the use of StrBufAppendTemplate demands this) * 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. --- webcit/addressbook_popup.c | 9 +- webcit/auth.c | 193 ++++--- webcit/calendar.c | 2 +- webcit/calendar_view.c | 6 +- webcit/context_loop.c | 43 +- webcit/cookie_conversion.c | 26 +- webcit/downloads.c | 33 +- webcit/floors.c | 4 +- webcit/gettext.c | 10 +- webcit/graphics.c | 6 +- webcit/groupdav.h | 14 +- webcit/groupdav_delete.c | 8 +- webcit/groupdav_get.c | 41 +- webcit/groupdav_main.c | 16 +- webcit/groupdav_options.c | 39 +- webcit/groupdav_propfind.c | 52 +- webcit/groupdav_put.c | 66 ++- webcit/http_datestring.c | 4 +- webcit/ical_dezonify.c | 2 +- webcit/iconbar.c | 2 +- webcit/inetconf.c | 10 +- webcit/listsub.c | 8 +- webcit/mainmenu.c | 12 +- webcit/messages.c | 60 ++- webcit/msg_renderers.c | 219 ++++---- webcit/netconf.c | 65 ++- webcit/notes.c | 50 +- webcit/openid.c | 2 +- webcit/paging.c | 15 +- webcit/paramhandling.c | 41 +- webcit/preferences.c | 49 +- webcit/pushemail.c | 4 +- webcit/roomops.c | 402 ++++++++------- webcit/rss.c | 23 +- webcit/serv_func.c | 97 ++-- webcit/siteconfig.c | 24 +- webcit/smtpqueue.c | 9 +- webcit/static/bt.css | 3 +- webcit/static/instant_messenger.html | 2 +- webcit/static/prototype.js | 337 +++++++----- webcit/static/wclib.js | 98 +--- webcit/static/webcit.css | 3 +- webcit/subst.c | 737 +++++++++++---------------- webcit/subst.h | 59 ++- webcit/summary.c | 26 +- webcit/sysmsgs.c | 2 +- webcit/useredit.c | 66 +-- webcit/userlist.c | 2 +- webcit/utils.c | 4 +- webcit/vcard_edit.c | 8 +- webcit/wc_gettext.h | 2 +- webcit/webcit.c | 138 +++-- webcit/webcit.h | 54 +- webcit/who.c | 65 +-- webcit/wiki.c | 16 +- 55 files changed, 1747 insertions(+), 1541 deletions(-) diff --git a/webcit/addressbook_popup.c b/webcit/addressbook_popup.c index 3cb23ebdd..711a73c90 100644 --- a/webcit/addressbook_popup.c +++ b/webcit/addressbook_popup.c @@ -51,7 +51,7 @@ void display_address_book_middle_div(void) { wprintf("\n"); @@ -113,7 +113,7 @@ void display_address_book_inner_div() { HashList *List; HashPos *it; int i; - char saved_roomname[128]; + StrBuf *saved_roomname; begin_ajax_response(); @@ -149,8 +149,8 @@ void display_address_book_inner_div() { 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")) { @@ -171,6 +171,7 @@ void display_address_book_inner_div() { DeleteHashPos(&it); DeleteHash(&List); gotoroom(saved_roomname); + FreeStrBuf(&saved_roomname); } wprintf("\n"); diff --git a/webcit/auth.c b/webcit/auth.c index 93480d86b..77dc5c475 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -91,22 +91,27 @@ void display_openid_login(char *mesg) } -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("
\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 %s 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, ""); @@ -119,7 +124,7 @@ void display_openid_name_request(char *claimed_id, char *username) { svput("EXIT_BUTTON", WCS_STRING, _("Exit")); svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by Citadel"), - serv_info.serv_humannode); + ChrPtr(serv_info.serv_humannode)); do_template("openid_manual_create", NULL); wDumpContent(2); @@ -139,18 +144,36 @@ void display_openid_name_request(char *claimed_id, char *username) { * 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(); @@ -177,7 +200,7 @@ void become_logged_in(char *user, char *pass, char *serv_response) void do_login(void) { wcsession *WCC = WC; - char buf[SIZ]; + StrBuf *Buf; if (havebstr("language")) { set_selected_language(bstr("language")); @@ -188,28 +211,31 @@ void do_login(void) 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; } } @@ -220,20 +246,22 @@ void do_login(void) "%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; } } @@ -253,7 +281,7 @@ void do_login(void) _("Your password was not accepted.")); display_login(); } - + FreeStrBuf(&Buf); } /* @@ -261,7 +289,7 @@ void do_login(void) */ void openid_manual_create(void) { - char buf[1024]; + StrBuf *Buf; if (havebstr("exit_action")) { do_logout(); @@ -269,14 +297,20 @@ void openid_manual_create(void) } 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) { @@ -288,7 +322,7 @@ void openid_manual_create(void) do_welcome(); } } else { - display_openid_name_request(bstr("openid_url"), bstr("name")); + display_openid_name_request(sbstr("openid_url"), sbstr("name")); } } @@ -342,23 +376,22 @@ void do_openid_login(void) */ 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; @@ -376,44 +409,52 @@ void finalize_openid_login(void) 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); } @@ -421,7 +462,7 @@ void finalize_openid_login(void) * 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); } @@ -436,6 +477,11 @@ void finalize_openid_login(void) display_openid_login(_("Your password was not accepted.")); } + FreeStrBuf(&result); + FreeStrBuf(&username); + FreeStrBuf(&password); + FreeStrBuf(&claimed_id); + FreeStrBuf(&logged_in_response); } @@ -524,10 +570,10 @@ void do_logout(void) { 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); @@ -746,12 +792,16 @@ void display_reg(int during_login) */ 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); @@ -831,7 +881,12 @@ void changepw(void) 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 { @@ -839,17 +894,17 @@ void changepw(void) } } -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) ); diff --git a/webcit/calendar.c b/webcit/calendar.c index 9012e8966..a059acb8f 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -1058,7 +1058,7 @@ void display_edit_task(void) { /* Force change the room if we have to */ if (havebstr("taskrm")) { - gotoroom((char *)bstr("taskrm")); + gotoroom(sbstr("taskrm")); } msgnum = lbstr("msgnum"); diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index f9863836b..0af1842ec 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -1304,7 +1304,7 @@ void calendar_summary_view(void) { "?gotofirst=", Cal->cal_msgnum ); - escputs(WCC->wc_roomname); + escputs(ChrPtr(WCC->wc_roomname)); wprintf("\">"); } else { @@ -1320,7 +1320,7 @@ void calendar_summary_view(void) { 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)); @@ -1552,7 +1552,7 @@ void do_tasks_view(void) { p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY); wprintf("cal_msgnum); - urlescputs(WC->wc_roomname); + urlescputs(ChrPtr(WC->wc_roomname)); wprintf("\">"); /* wprintf(" "); */ diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 0248c384f..e0a816e1d 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -43,6 +43,12 @@ void DestroySession(wcsession **sessions_to_kill) 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; } @@ -353,7 +359,7 @@ authentication 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; } @@ -471,8 +477,8 @@ authentication /** 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; } @@ -509,8 +515,17 @@ authentication 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); @@ -574,16 +589,30 @@ authentication } -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); } diff --git a/webcit/cookie_conversion.c b/webcit/cookie_conversion.c index 844798ea0..172536fc4 100644 --- a/webcit/cookie_conversion.c +++ b/webcit/cookie_conversion.c @@ -27,13 +27,18 @@ typedef unsigned char byte; /**< Byte type */ * \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]); @@ -78,12 +83,13 @@ int xtoi(const char *in, size_t len) * \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="); @@ -98,6 +104,7 @@ void cookie_to_stuff(StrBuf *cookie, int *session, buf[i] = xtoi(&pch[i*2], 2); buf[i+1] = 0; } + Buf = NewStrBufPlain(buf, i); /* debug char t[256]; @@ -112,12 +119,13 @@ void cookie_to_stuff(StrBuf *cookie, int *session, 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); } /*@}*/ diff --git a/webcit/downloads.c b/webcit/downloads.c index ed78c74c6..ea6ad4d9b 100644 --- a/webcit/downloads.c +++ b/webcit/downloads.c @@ -25,32 +25,32 @@ void FreeFiles(void *vFile) } /* -------------------------------------------------------------------------------- */ -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; } @@ -163,7 +163,7 @@ int GroupchangeFilelistBySequence(const void *vFile1, const void *vFile2) } /* -------------------------------------------------------------------------------- */ -HashList* LoadFileList(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) +HashList* LoadFileList(StrBuf *Target, WCTemplputParams *TP) { FileListStruct *Entry; StrBuf *Buf; @@ -173,7 +173,9 @@ HashList* LoadFileList(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void 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; @@ -208,7 +210,8 @@ HashList* LoadFileList(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void } 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 diff --git a/webcit/floors.c b/webcit/floors.c index 1b52c9aec..78227221b 100644 --- a/webcit/floors.c +++ b/webcit/floors.c @@ -145,7 +145,7 @@ void delete_floor(void) { 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 { @@ -167,7 +167,7 @@ void create_floor(void) { 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 { diff --git a/webcit/gettext.c b/webcit/gettext.c index 241fb9eed..930d9df38 100644 --- a/webcit/gettext.c +++ b/webcit/gettext.c @@ -167,7 +167,8 @@ void httplang_to_locale(StrBuf *LocaleString) * 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"); @@ -306,7 +307,8 @@ void ShutdownLocale(void) #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)"); } @@ -328,9 +330,9 @@ void preset_locale(void) #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); } diff --git a/webcit/graphics.c b/webcit/graphics.c index 378cdfbc5..ba879dc35 100644 --- a/webcit/graphics.c +++ b/webcit/graphics.c @@ -9,6 +9,7 @@ void display_graphics_upload(char *description, char *filename, char *uplurl) { + WCTemplputParams SubTP; StrBuf *Buf; char buf[SIZ]; @@ -26,7 +27,10 @@ void display_graphics_upload(char *description, char *filename, char *uplurl) 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); diff --git a/webcit/groupdav.h b/webcit/groupdav.h index 42709a5b7..ee7ffff80 100644 --- a/webcit/groupdav.h +++ b/webcit/groupdav.h @@ -21,15 +21,15 @@ void groupdav_main(HashList *HTTPHeaders, 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); diff --git a/webcit/groupdav_delete.c b/webcit/groupdav_delete.c index 2a76687b1..20915900f 100644 --- a/webcit/groupdav_delete.c +++ b/webcit/groupdav_delete.c @@ -14,7 +14,6 @@ * 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]; @@ -35,13 +34,12 @@ void groupdav_delete(StrBuf *dav_pathname, char *dav_ifmatch) { 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"); diff --git a/webcit/groupdav_get.c b/webcit/groupdav_get.c index 85f643b83..39008e53a 100644 --- a/webcit/groupdav_get.c +++ b/webcit/groupdav_get.c @@ -86,9 +86,9 @@ void extract_preferred(char *name, char *filename, char *partnum, char *disp, * /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; @@ -104,7 +104,7 @@ void groupdav_get(const char *dav_pathname) { 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"); @@ -113,34 +113,41 @@ void groupdav_get(const char *dav_pathname) { 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') { @@ -148,11 +155,15 @@ void groupdav_get(const char *dav_pathname) { 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. */ diff --git a/webcit/groupdav_main.c b/webcit/groupdav_main.c index b761875ef..19b060c13 100644 --- a/webcit/groupdav_main.c +++ b/webcit/groupdav_main.c @@ -22,7 +22,7 @@ void groupdav_common_headers(void) { hprintf( "Server: %s / %s\r\n" "Connection: close\r\n", - PACKAGE_STRING, serv_info.serv_software + PACKAGE_STRING, ChrPtr(serv_info.serv_software) ); } @@ -31,7 +31,7 @@ void groupdav_common_headers(void) { /* * 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; @@ -52,7 +52,7 @@ void euid_escapize(char *target, char *source) { /* * 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; @@ -129,7 +129,7 @@ void groupdav_main(HashList *HTTPHeaders, 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; @@ -186,7 +186,7 @@ void groupdav_main(HashList *HTTPHeaders, * other variants of DAV in the future. */ if (!strcasecmp(ChrPtr(DavMethod), "OPTIONS")) { - groupdav_options(ChrPtr(DavPathname)); + groupdav_options(DavPathname); return; } @@ -195,7 +195,7 @@ void groupdav_main(HashList *HTTPHeaders, * 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; @@ -205,7 +205,7 @@ void groupdav_main(HashList *HTTPHeaders, * The GET method is used for fetching individual items. */ if (!strcasecmp(ChrPtr(DavMethod), "GET")) { - groupdav_get(ChrPtr(DavPathname)); + groupdav_get(DavPathname); return; } @@ -213,7 +213,7 @@ void groupdav_main(HashList *HTTPHeaders, * 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; diff --git a/webcit/groupdav_options.c b/webcit/groupdav_options.c index 366f5ffe3..5f678c1e6 100644 --- a/webcit/groupdav_options.c +++ b/webcit/groupdav_options.c @@ -12,9 +12,9 @@ /* * 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; @@ -22,13 +22,15 @@ void groupdav_options(const char *dav_pathname) { 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); @@ -37,15 +39,17 @@ void groupdav_options(const char *dav_pathname) { 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); @@ -53,19 +57,21 @@ void groupdav_options(const char *dav_pathname) { "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(); @@ -73,9 +79,11 @@ void groupdav_options(const char *dav_pathname) { "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; } @@ -87,9 +95,14 @@ void groupdav_options(const char *dav_pathname) { 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. diff --git a/webcit/groupdav_propfind.c b/webcit/groupdav_propfind.c index 017dc91a9..c0f702f4a 100644 --- a/webcit/groupdav_propfind.c +++ b/webcit/groupdav_propfind.c @@ -25,7 +25,7 @@ * 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); @@ -227,9 +227,9 @@ void groupdav_collection_list(const char *dav_pathname, int dav_depth) /* * 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]; @@ -244,31 +244,37 @@ void groupdav_propfind(const char *dav_pathname, int dav_depth, StrBuf *dav_cont 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; } @@ -276,18 +282,20 @@ void groupdav_propfind(const char *dav_pathname, int dav_depth, StrBuf *dav_cont * 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; } @@ -312,8 +320,8 @@ void groupdav_propfind(const char *dav_pathname, int dav_depth, StrBuf *dav_cont wprintf(""); 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(""); wprintf(""); @@ -329,8 +337,12 @@ void groupdav_propfind(const char *dav_pathname, int dav_depth, StrBuf *dav_cont wprintf("\n"); wprintf("\n"); end_burst(); + FreeStrBuf(&dav_roomname); + FreeStrBuf(&dav_uid); return; } + FreeStrBuf(&dav_roomname); + FreeStrBuf(&dav_uid); /* @@ -360,14 +372,14 @@ void groupdav_propfind(const char *dav_pathname, int dav_depth, StrBuf *dav_cont wprintf(""); groupdav_identify_host(); wprintf("/groupdav/"); - urlescputs(WC->wc_roomname); + urlescputs(ChrPtr(WC->wc_roomname)); wprintf(""); wprintf(""); wprintf("HTTP/1.1 200 OK"); wprintf(""); wprintf(""); - escputs(WC->wc_roomname); + escputs(ChrPtr(WC->wc_roomname)); wprintf(""); wprintf(""); @@ -422,7 +434,7 @@ void groupdav_propfind(const char *dav_pathname, int dav_depth, StrBuf *dav_cont wprintf(""); groupdav_identify_host(); wprintf("/groupdav/"); - urlescputs(WC->wc_roomname); + urlescputs(ChrPtr(WC->wc_roomname)); euid_escapize(encoded_uid, uid); wprintf("/%s", encoded_uid); wprintf(""); diff --git a/webcit/groupdav_put.c b/webcit/groupdav_put.c index 63d3a8dae..512cea098 100644 --- a/webcit/groupdav_put.c +++ b/webcit/groupdav_put.c @@ -54,18 +54,18 @@ void groupdav_put_bigics(StrBuf *dav_content, int offset) * /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"); @@ -74,23 +74,28 @@ void groupdav_put(const char *dav_pathname, char *dav_ifmatch, 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; } @@ -103,7 +108,7 @@ void groupdav_put(const char *dav_pathname, char *dav_ifmatch, */ 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"); @@ -112,14 +117,18 @@ void groupdav_put(const char *dav_pathname, char *dav_ifmatch, 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; } @@ -147,17 +156,20 @@ void groupdav_put(const char *dav_pathname, char *dav_ifmatch, /* 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; } } @@ -171,6 +183,8 @@ void groupdav_put(const char *dav_pathname, char *dav_ifmatch, wprintf("new_msgnum is %ld\r\n" "\r\n", new_msgnum); end_burst(); + FreeStrBuf(&dav_roomname); + FreeStrBuf(&dav_uid); return; } @@ -184,10 +198,12 @@ void groupdav_put(const char *dav_pathname, char *dav_ifmatch, 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; } @@ -204,5 +220,7 @@ void groupdav_put(const char *dav_pathname, char *dav_ifmatch, serv_printf("DELE %ld", old_msgnum); serv_getln(buf, sizeof buf); end_burst(); + FreeStrBuf(&dav_roomname); + FreeStrBuf(&dav_uid); return; } diff --git a/webcit/http_datestring.c b/webcit/http_datestring.c index 908e65424..f3db04ce9 100644 --- a/webcit/http_datestring.c +++ b/webcit/http_datestring.c @@ -64,13 +64,13 @@ void http_datestring(char *buf, size_t n, time_t xtime) { } -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); diff --git a/webcit/ical_dezonify.c b/webcit/ical_dezonify.c index 116095908..044825592 100644 --- a/webcit/ical_dezonify.c +++ b/webcit/ical_dezonify.c @@ -21,7 +21,7 @@ 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); diff --git a/webcit/iconbar.c b/webcit/iconbar.c index a55e72c71..ee216df1d 100644 --- a/webcit/iconbar.c +++ b/webcit/iconbar.c @@ -804,7 +804,7 @@ void commit_iconbar(void) { } -void tmplput_iconbar(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) +void tmplput_iconbar(StrBuf *Target, WCTemplputParams *TP) { wcsession *WCC = WC; diff --git a/webcit/inetconf.c b/webcit/inetconf.c index 97820b7ab..5e0bd5b11 100644 --- a/webcit/inetconf.c +++ b/webcit/inetconf.c @@ -175,12 +175,12 @@ void new_save_inetconf(void) { 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; @@ -190,7 +190,7 @@ void DeleteInetConfHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void } -HashList *GetInetConfHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) +HashList *GetInetConfHash(StrBuf *Target, WCTemplputParams *TP) { wcsession *WCC = WC; void *vHash; @@ -198,7 +198,7 @@ HashList *GetInetConfHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, vo 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; } diff --git a/webcit/listsub.c b/webcit/listsub.c index 0f2fd8e86..a694cd227 100644 --- a/webcit/listsub.c +++ b/webcit/listsub.c @@ -23,10 +23,10 @@ void do_listsub(void) 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(); diff --git a/webcit/mainmenu.c b/webcit/mainmenu.c index 60de06cb5..82c28918b 100644 --- a/webcit/mainmenu.c +++ b/webcit/mainmenu.c @@ -11,7 +11,7 @@ void display_main_menu(void) { 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(); /* @@ -161,7 +161,7 @@ void display_aide_menu(void) { 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); @@ -369,7 +369,7 @@ void display_shutdown(void) } 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); @@ -384,7 +384,7 @@ void display_shutdown(void) { 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 @@ -393,7 +393,7 @@ void display_shutdown(void) 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(); } } @@ -409,7 +409,7 @@ void display_shutdown(void) } 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(); } } diff --git a/webcit/messages.c b/webcit/messages.c index 141a63a74..2aca9e37c 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -64,6 +64,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in int state=0; long len; const char *Key; + WCTemplputParams SubTP; Buf = NewStrBuf(); lprintf(1, "----------%s---------MSG4 %ld|%s--------------\n", tmpl, msgnum, ChrPtr(PartNum)); @@ -213,8 +214,8 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in 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(); @@ -239,8 +240,10 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in 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); @@ -444,8 +447,8 @@ int load_msg_ptrs(char *servcmd, int with_headers) 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); @@ -512,7 +515,11 @@ long DrawMessageDropdown(StrBuf *Selector, long maxmsgs, long startmsg, int nMes 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); @@ -563,7 +570,7 @@ long DrawMessageDropdown(StrBuf *Selector, long maxmsgs, long startmsg, int nMes 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; @@ -571,7 +578,7 @@ long DrawMessageDropdown(StrBuf *Selector, long maxmsgs, long startmsg, int nMes 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); @@ -591,7 +598,7 @@ void load_seen_flags(void) OldMsg = NewStrBuf(); serv_puts("GTSN"); StrBuf_ServGetln(OldMsg); - if (ChrPtr(OldMsg)[0] == '2') { + if (GetServerStatus(OldMsg, NULL) == 2) { StrBufCutLeft(OldMsg, 4); } else { @@ -651,13 +658,14 @@ void readloop(long oper) 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: @@ -745,7 +753,10 @@ void readloop(long oper) 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); @@ -784,7 +795,10 @@ void readloop(long oper) 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; @@ -821,7 +835,10 @@ void readloop(long oper) 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; @@ -865,7 +882,10 @@ void readloop(long oper) 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); @@ -924,12 +944,12 @@ void post_mime_to_server(void) { 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 ); @@ -1029,7 +1049,7 @@ void post_message(void) wcsession *WCC = WC; if (havebstr("force_room")) { - gotoroom(bstr("force_room")); + gotoroom(sbstr("force_room")); } if (havebstr("display_name")) { @@ -1222,7 +1242,7 @@ void display_enter(void) now = time(NULL); if (havebstr("force_room")) { - gotoroom(bstr("force_room")); + gotoroom(sbstr("force_room")); } display_name = sbstr("display_name"); @@ -1254,7 +1274,7 @@ void display_enter(void) * 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; } @@ -1331,7 +1351,7 @@ void display_enter(void) 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; diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index a12407056..450e66889 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -233,9 +233,9 @@ void examine_nhdr(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) 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; } @@ -252,10 +252,10 @@ void examine_from(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->from = NewStrBufPlain(NULL, StrLength(HdrLine)); StrBuf_RFC822_to_Utf8(Msg->from, HdrLine, WC->DefaultCharset, FoundCharset); } -void tmplput_MAIL_SUMM_FROM(StrBuf *Target, int nArgs, WCTemplateToken *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); } @@ -266,11 +266,11 @@ void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->subj = NewStrBufPlain(NULL, StrLength(HdrLine)); StrBuf_RFC822_to_Utf8(Msg->subj, HdrLine, WC->DefaultCharset, FoundCharset); } -void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, int nArgs, WCTemplateToken *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); } @@ -280,15 +280,15 @@ void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->reply_inreplyto = NewStrBufPlain(NULL, StrLength(HdrLine)); StrBuf_RFC822_to_Utf8(Msg->reply_inreplyto, HdrLine, WC->DefaultCharset, FoundCharset); } -void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, int nArgs, WCTemplateToken *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; } @@ -298,10 +298,10 @@ void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->reply_references = NewStrBufPlain(NULL, StrLength(HdrLine)); StrBuf_RFC822_to_Utf8(Msg->reply_references, HdrLine, WC->DefaultCharset, FoundCharset); } -void tmplput_MAIL_SUMM_REFIDS(StrBuf *Target, int nArgs, WCTemplateToken *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); } @@ -317,25 +317,25 @@ void examine_cccc(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) } StrBufAppendBuf(Msg->AllRcpt, Msg->cccc, 0); } -void tmplput_MAIL_SUMM_CCCC(StrBuf *Target, int nArgs, WCTemplateToken *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); } @@ -344,14 +344,14 @@ void examine_rfca(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) FreeStrBuf(&Msg->Rfca); Msg->Rfca = NewStrBufDup(HdrLine); } -void tmplput_MAIL_SUMM_RFCA(StrBuf *Target, int nArgs, WCTemplateToken *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; } @@ -359,20 +359,20 @@ void examine_node(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) { 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; } @@ -389,19 +389,19 @@ void examine_rcpt(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) } StrBufAppendBuf(Msg->AllRcpt, Msg->to, 0); } -void tmplput_MAIL_SUMM_TO(StrBuf *Target, int nArgs, WCTemplateToken *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; } @@ -410,23 +410,25 @@ void examine_time(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) { 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); } @@ -451,13 +453,14 @@ void render_MAIL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset 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, "", @@ -579,9 +582,9 @@ void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime) } } -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)); } @@ -592,14 +595,14 @@ void examine_hnod(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) Msg->hnod = NewStrBufPlain(NULL, StrLength(HdrLine)); StrBuf_RFC822_to_Utf8(Msg->hnod, HdrLine, WC->DefaultCharset, FoundCharset); } -void tmplput_MAIL_SUMM_H_NODE(StrBuf *Target, int nArgs, WCTemplateToken *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; } @@ -674,42 +677,42 @@ void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCh } } -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; @@ -717,14 +720,14 @@ void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, int nArgs, WCTemplateToken *Tokens 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); } @@ -880,61 +883,61 @@ void render_MAIL_UNKNOWN(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun -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) @@ -942,25 +945,25 @@ 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"))|| @@ -985,13 +988,13 @@ void tmplput_MIME_LoadData(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, v } } -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; } diff --git a/webcit/netconf.c b/webcit/netconf.c index 456b7f6c7..5f9087228 100644 --- a/webcit/netconf.c +++ b/webcit/netconf.c @@ -81,7 +81,7 @@ void SerializeNode(NodeConf *Node, StrBuf *Buf) } -HashList *load_netconf(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) +HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP) { StrBuf *Buf; HashList *Hash; @@ -113,16 +113,6 @@ HashList *load_netconf(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void } -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) { @@ -178,7 +168,7 @@ void edit_node(void) { 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); @@ -192,9 +182,11 @@ void edit_node(void) { */ void display_edit_node(void) { + WCTemplputParams SubTP; HashList *NodeConfig; const StrBuf *Index; void *vNode; + const StrBuf *Tmpl; Index = sbstr("index"); if (Index == NULL) { @@ -203,7 +195,7 @@ void display_edit_node(void) 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")); @@ -212,10 +204,15 @@ void display_edit_node(void) 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); } @@ -255,7 +252,7 @@ void delete_node(void) 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")); @@ -272,6 +269,31 @@ void delete_node(void) } + +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) @@ -282,6 +304,13 @@ InitModule_NETCONF 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); } /*@}*/ diff --git a/webcit/notes.c b/webcit/notes.c index 48582a9fb..d55fd2f81 100644 --- a/webcit/notes.c +++ b/webcit/notes.c @@ -27,7 +27,7 @@ void display_vnote_div(struct vnote *v) { int i; - wprintf("
uid); // begin outer div + wprintf("
uid); /* begin outer div */ wprintf("class=\"stickynote_outer\" "); wprintf("style=\""); wprintf("left: %dpx; ", v->pos_left); @@ -41,7 +41,7 @@ void display_vnote_div(struct vnote *v) { - wprintf("
uid); // begin title bar div + wprintf("
uid); /* begin title bar div */ wprintf("class=\"stickynote_titlebar\" "); wprintf("onMouseDown=\"NotesDragMouseDown(event,'%s')\" ", v->uid); wprintf("style=\""); @@ -339,12 +339,16 @@ void ajax_update_note(void) { */ 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 @@ -386,63 +390,63 @@ void add_new_note(void) { } -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); } diff --git a/webcit/openid.c b/webcit/openid.c index 464f3c912..dc6d09838 100644 --- a/webcit/openid.c +++ b/webcit/openid.c @@ -51,7 +51,7 @@ void display_openids(void) } 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); diff --git a/webcit/paging.c b/webcit/paging.c index acfcdd97c..d3319f127 100644 --- a/webcit/paging.c +++ b/webcit/paging.c @@ -107,10 +107,13 @@ void do_chat(void) 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; } @@ -229,13 +232,13 @@ int setup_chat_socket(void) { 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"); @@ -382,7 +385,7 @@ void chat_recv(void) { if (strcasecmp(cl_user, WC->last_chat_user)) { wprintf(""); - if (!strcasecmp(cl_user, WC->wc_fullname)) { + if (!strcasecmp(cl_user, ChrPtr(WC->wc_fullname))) { wprintf(""); } else { diff --git a/webcit/paramhandling.c b/webcit/paramhandling.c index 2ebc35305..c514c44a8 100644 --- a/webcit/paramhandling.c +++ b/webcit/paramhandling.c @@ -352,26 +352,24 @@ void PutBstr(const char *key, long keylen, StrBuf *Value) -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) @@ -392,37 +390,22 @@ 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, - "
\nurlbuf [%s] not set (in '%s' line %ld)\n[%s]\n
\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); } } diff --git a/webcit/preferences.c b/webcit/preferences.c index 8118e6eb8..46e439f7f 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -122,7 +122,7 @@ void load_preferences(void) } /* 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); } @@ -234,7 +234,7 @@ void save_preferences(void) { } /** 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); } @@ -341,7 +341,7 @@ StrBuf *get_ROOM_PREFS(const char *key, size_t keylen) 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; @@ -352,7 +352,7 @@ void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_s 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); } @@ -360,7 +360,8 @@ void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_s /* * 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("
this_page); wprintf("\">"); @@ -368,9 +369,9 @@ void offer_start_page(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *C wprintf(""); #ifdef TECH_PREVIEW wprintf("
wc_roomname); + urlescputs(ChrPtr(WC->wc_roomname)); wprintf("\" title=\"RSS 2.0 feed for "); - escputs(WC->wc_roomname); + escputs(ChrPtr(WC->wc_roomname)); wprintf("\">\"RSS\"\n"); #endif } @@ -456,14 +457,14 @@ void set_preferences(void) #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)); @@ -472,31 +473,31 @@ void tmplput_CFG_Descr(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void } -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; @@ -507,7 +508,7 @@ int ConditionalHazePreference(WCTemplateToken *Tokens, void *Context, int Contex 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; @@ -518,7 +519,7 @@ HashList *GetGVEAHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void * 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)) { @@ -544,7 +545,7 @@ void DeleteGVEAHash(HashList **KillMe) 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; @@ -555,7 +556,7 @@ HashList *GetGVSNHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void * 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)) { @@ -602,7 +603,7 @@ InitModule_PREFERENCES 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); diff --git a/webcit/pushemail.c b/webcit/pushemail.c index 3346d83ba..2f8c6a130 100644 --- a/webcit/pushemail.c +++ b/webcit/pushemail.c @@ -59,7 +59,7 @@ void display_pushemail(void) { } 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); @@ -107,7 +107,7 @@ void save_pushemail(void) { } /** 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"); } diff --git a/webcit/roomops.c b/webcit/roomops.c index 1e20e12a1..5efd7109a 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -96,14 +96,14 @@ void free_march_list(wcsession *wcf) /* * 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; @@ -111,7 +111,7 @@ void remove_march(char *aaa) } 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; @@ -256,11 +256,15 @@ void listrms(char *variety) */ 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); @@ -276,7 +280,7 @@ void zapped_list(void) /** * \brief read this room's info file (set v to 1 for verbose mode) */ -void readinfo(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) +void readinfo(StrBuf *Target, WCTemplputParams *TP) { char buf[256]; char briefinfo[128]; @@ -325,14 +329,15 @@ void readinfo(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, * 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("wc_roomname); + urlescputs(ChrPtr(WC->wc_roomname)); wprintf("\">"); serv_puts("CLOS"); serv_getln(buf, sizeof buf); @@ -381,7 +386,8 @@ void embed_room_graphic(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void /** * \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("
\n"); @@ -422,7 +428,8 @@ void embed_view_o_matic(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void /** * \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("\n"); wprintf("
\n", WC->nonce); wprintf("