From 1b302cba797e9b8d6f94304f80c52ac63845503a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Tue, 10 Feb 2009 18:50:50 +0000 Subject: [PATCH] * move serv_info into the session, here we can control its de/allocation the right way. --- webcit/addressbook_popup.c | 2 +- webcit/auth.c | 2 +- webcit/context_loop.c | 1 + webcit/groupdav_main.c | 4 +- webcit/ical_dezonify.c | 2 +- webcit/messages.c | 27 +++++++------ webcit/msg_renderers.c | 6 ++- webcit/openid.c | 7 ++-- webcit/roomops.c | 4 +- webcit/rss.c | 4 +- webcit/serv_func.c | 78 ++++++++++++++++++++++++-------------- webcit/setup_wizard.c | 2 +- webcit/sieve.c | 2 +- webcit/siteconfig.c | 4 +- webcit/smtpqueue.c | 2 +- webcit/summary.c | 11 +++--- webcit/userlist.c | 2 +- webcit/webcit.c | 25 ++++++------ webcit/webcit.h | 11 +++--- 19 files changed, 112 insertions(+), 84 deletions(-) diff --git a/webcit/addressbook_popup.c b/webcit/addressbook_popup.c index 19e06c0b4..8e687f3de 100644 --- a/webcit/addressbook_popup.c +++ b/webcit/addressbook_popup.c @@ -51,7 +51,7 @@ void display_address_book_middle_div(void) { wprintf("\n"); diff --git a/webcit/auth.c b/webcit/auth.c index c938851b1..927455214 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -91,7 +91,7 @@ void display_openid_name_request(const StrBuf *claimed_id, const StrBuf *usernam svput("EXIT_BUTTON", WCS_STRING, _("Exit")); svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by Citadel"), - ChrPtr(serv_info.serv_humannode)); + ChrPtr(WC->serv_info->serv_humannode)); do_template("openid_manual_create", NULL); wDumpContent(2); diff --git a/webcit/context_loop.c b/webcit/context_loop.c index a11b930d2..c8461d2c8 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -32,6 +32,7 @@ void DestroySession(wcsession **sessions_to_kill) if ((*sessions_to_kill)->cache_fold != NULL) { free((*sessions_to_kill)->cache_fold); } + DeleteServInfo(&((*sessions_to_kill)->serv_info)); DeleteHash(&((*sessions_to_kill)->attachments)); free_march_list((*sessions_to_kill)); DeleteHash(&((*sessions_to_kill)->hash_prefs)); diff --git a/webcit/groupdav_main.c b/webcit/groupdav_main.c index a2c3f169d..6a7f8beac 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, ChrPtr(serv_info.serv_software) + PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software) ); } @@ -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", - ChrPtr(serv_info.serv_humannode)); + ChrPtr(WCC->serv_info->serv_humannode)); hprintf("Content-Length: 0\r\n"); end_burst(); return; diff --git a/webcit/ical_dezonify.c b/webcit/ical_dezonify.c index 044825592..ea4b53ece 100644 --- a/webcit/ical_dezonify.c +++ b/webcit/ical_dezonify.c @@ -21,7 +21,7 @@ icaltimezone *get_default_icaltimezone(void) { icaltimezone *zone = NULL; - const char *default_zone_name = ChrPtr(serv_info.serv_default_cal_zone); + const char *default_zone_name = ChrPtr(WC->serv_info->serv_default_cal_zone); if (!zone) { zone = icaltimezone_get_builtin_timezone(default_zone_name); diff --git a/webcit/messages.c b/webcit/messages.c index 171b73e02..a30263a2f 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -43,7 +43,9 @@ typedef struct _MsgPartEvaluatorStruct { * printable_view Nonzero to display a printable view * section Optional for encapsulated message/rfc822 submessage */ -int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *PartNum) { +int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *PartNum) +{ + wcsession *WCC = WC; StrBuf *Buf; StrBuf *HdrToken; StrBuf *FoundCharset; @@ -208,8 +210,8 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in else { if ((StrLength(Msg->OtherNode)>0) && - (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(serv_info.serv_nodename))) && - (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(serv_info.serv_humannode)) )) + (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_nodename))) && + (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_humannode)) )) { if (Msg->reply_to == NULL) Msg->reply_to = NewStrBuf(); @@ -256,13 +258,14 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in */ void embed_message(void) { long msgnum = 0L; + wcsession *WCC = WC; const StrBuf *Tmpl = sbstr("template"); - msgnum = StrTol(WC->UrlFragment2); + msgnum = StrTol(WCC->UrlFragment2); if (StrLength(Tmpl) > 0) - read_message(WC->WBuf, SKEY(Tmpl), msgnum, 0, NULL); + read_message(WCC->WBuf, SKEY(Tmpl), msgnum, 0, NULL); else - read_message(WC->WBuf, HKEY("view_message"), msgnum, 0, NULL); + read_message(WCC->WBuf, HKEY("view_message"), msgnum, 0, NULL); } @@ -440,8 +443,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), ChrPtr(serv_info.serv_nodename)) - && (strcasecmp(ChrPtr(Buf2), ChrPtr(serv_info.serv_fqdn)))))))) + || ((strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_nodename)) + && (strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_fqdn)))))))) { StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0); StrBufAppendBuf(Msg->from, Buf2, 0); @@ -963,12 +966,12 @@ void post_mime_to_server(void) { char *txtmail = NULL; sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x", - ChrPtr(serv_info.serv_fqdn), + ChrPtr(WCC->serv_info->serv_fqdn), getpid(), ++seq ); sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x", - ChrPtr(serv_info.serv_fqdn), + ChrPtr(WCC->serv_info->serv_fqdn), getpid(), ++seq ); @@ -1647,7 +1650,7 @@ void jsonMessageListHdr(void) /* TODO: make a generic function */ hprintf("HTTP/1.1 200 OK\r\n"); hprintf("Content-type: application/json; charset=utf-8\r\n"); - hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(serv_info.serv_software)); + hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)); hprintf("Connection: close\r\n"); hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n"); begin_burst(); @@ -1662,8 +1665,8 @@ void new_summary_view(void) { /** Output message list in JSON-format */ void jsonMessageList(void) { const StrBuf *room = sbstr("room"); - WC->is_ajax = 1; long oper = (havebstr("query")) ? do_search : readnew; + WC->is_ajax = 1; gotoroom(room); readloop(oper); WC->is_ajax = 0; diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index 8ca86433e..6554be70d 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -366,10 +366,12 @@ int Conditional_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP) void examine_node(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) { + wcsession *WCC = WC; + if ( (StrLength(HdrLine) > 0) && ((WC->room_flags & QR_NETWORK) - || ((strcasecmp(ChrPtr(HdrLine), ChrPtr(serv_info.serv_nodename)) - && (strcasecmp(ChrPtr(HdrLine), ChrPtr(serv_info.serv_fqdn))))))) { + || ((strcasecmp(ChrPtr(HdrLine), ChrPtr(WCC->serv_info->serv_nodename)) + && (strcasecmp(ChrPtr(HdrLine), ChrPtr(WCC->serv_info->serv_fqdn))))))) { FreeStrBuf(&Msg->OtherNode); Msg->OtherNode = NewStrBufDup(HdrLine); } diff --git a/webcit/openid.c b/webcit/openid.c index a4af9d257..4c234b178 100644 --- a/webcit/openid.c +++ b/webcit/openid.c @@ -10,6 +10,7 @@ */ void display_openids(void) { + wcsession *WCC = WC; char buf[1024]; int bg = 0; @@ -20,7 +21,7 @@ void display_openids(void) svput("BOXTITLE", WCS_STRING, _("Manage Account/OpenID Associations")); do_template("beginboxx", NULL); - if (serv_info.serv_supports_openid) { + if (WCC->serv_info->serv_supports_openid) { wprintf(""); @@ -43,7 +44,7 @@ void display_openids(void) wprintf("

\n"); wprintf("
\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WCC->nonce); wprintf(_("Add an OpenID: ")); wprintf("\n"); wprintf("" @@ -51,7 +52,7 @@ void display_openids(void) } else { - wprintf(_("%s does not permit authentication via OpenID."), ChrPtr(serv_info.serv_humannode)); + wprintf(_("%s does not permit authentication via OpenID."), ChrPtr(WCC->serv_info->serv_humannode)); } do_template("endbox", NULL); diff --git a/webcit/roomops.c b/webcit/roomops.c index 40c8a3aab..b1fce7f15 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -451,7 +451,7 @@ void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP) wprintf("serv_info->serv_fulltext_enabled ? "" : "disabled "); wprintf("type=\"text\" name=\"query\" id=\"srchquery\" size=\"15\" maxlength=\"128\" class=\"inputbox\">\n" ); wprintf("
\n"); @@ -3820,7 +3820,7 @@ void jsonRoomFlr(void) { /* Send as our own (application/json) content type */ hprintf("HTTP/1.1 200 OK\r\n"); hprintf("Content-type: application/json; charset=utf-8\r\n"); - hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(serv_info.serv_software)); + hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)); hprintf("Connection: close\r\n"); hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n"); begin_burst(); diff --git a/webcit/rss.c b/webcit/rss.c index 60f097844..ab01a2aef 100644 --- a/webcit/rss.c +++ b/webcit/rss.c @@ -163,7 +163,7 @@ void display_rss(const StrBuf *roomname, StrBuf *request_method) svput("XML_HEAD", WCS_STRING, ""); svput("XML_STYLE", WCS_STRING, ""); SVPutBuf("ROOM", WCC->wc_roomname, 1); - SVPutBuf("NODE", serv_info.serv_humannode, 1); + SVPutBuf("NODE", WCC->serv_info->serv_humannode, 1); /* TODO: Fix me */ svprintf(HKEY("ROOM_LINK"), WCS_STRING, "%s://%s/", (is_https ? "https" : "http"), ChrPtr(WCC->http_host)); @@ -233,7 +233,7 @@ void display_rss(const StrBuf *roomname, StrBuf *request_method) svput("SUBJ", WCS_STRING, _("From")); } svprintf(HKEY("IN_ROOM"), WCS_STRING, _("%s in %s"), from, room); - if (strcmp(hnod, ChrPtr(serv_info.serv_humannode)) && !IsEmptyStr(hnod)) { + if (strcmp(hnod, ChrPtr(WCC->serv_info->serv_humannode)) && !IsEmptyStr(hnod)) { svprintf(HKEY("NODE"), WCS_STRING, _(" on %s"), hnod); } if (now) { diff --git a/webcit/serv_func.c b/webcit/serv_func.c index cbd53634e..6b36860f4 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -5,15 +5,31 @@ #include "webcit.h" #include "webserver.h" -struct serv_info serv_info; /**< our connection data to the server */ + +void DeleteServInfo(ServInfo **FreeMe) +{ + FreeStrBuf(&(*FreeMe)->serv_nodename); + FreeStrBuf(&(*FreeMe)->serv_humannode); + FreeStrBuf(&(*FreeMe)->serv_fqdn); + FreeStrBuf(&(*FreeMe)->serv_software); + FreeStrBuf(&(*FreeMe)->serv_bbs_city); + FreeStrBuf(&(*FreeMe)->serv_sysadm); + FreeStrBuf(&(*FreeMe)->serv_moreprompt); + FreeStrBuf(&(*FreeMe)->serv_default_cal_zone); + FreeStrBuf(&(*FreeMe)->serv_svn_revision); + free(*FreeMe); + *FreeMe = NULL; +} + /* * get info about the server we've connected to * * browser_host the citadell we want to connect to * user_agent which browser uses our client? */ -void get_serv_info(StrBuf *browser_host, char *user_agent) +ServInfo *get_serv_info(StrBuf *browser_host, char *user_agent) { + ServInfo *info; StrBuf *Buf; char buf[SIZ]; int a; @@ -44,65 +60,69 @@ void get_serv_info(StrBuf *browser_host, char *user_agent) serv_puts("INFO"); serv_getln(buf, sizeof buf); if (buf[0] != '1') - return; + return NULL; + info = (ServInfo*)malloc(sizeof(ServInfo)); + memset(info, 0, sizeof(ServInfo)); a = 0; Buf = NewStrBuf(); while (StrBuf_ServGetln(Buf), (strcmp(ChrPtr(Buf), "000")!= 0)) { /* lprintf (1, "a: %d [%s]", a, ChrPtr(Buf));*/ switch (a) { case 0: - serv_info.serv_pid = StrToi(Buf); - WC->ctdl_pid = serv_info.serv_pid; + info->serv_pid = StrToi(Buf); + WC->ctdl_pid = info->serv_pid; break; case 1: - serv_info.serv_nodename = NewStrBufDup(Buf); + info->serv_nodename = NewStrBufDup(Buf); break; case 2: - serv_info.serv_humannode = NewStrBufDup(Buf); + info->serv_humannode = NewStrBufDup(Buf); break; case 3: - serv_info.serv_fqdn = NewStrBufDup(Buf); + info->serv_fqdn = NewStrBufDup(Buf); break; case 4: - serv_info.serv_software = NewStrBufDup(Buf); + info->serv_software = NewStrBufDup(Buf); break; case 5: - serv_info.serv_rev_level = StrToi(Buf); + info->serv_rev_level = StrToi(Buf); break; case 6: - serv_info.serv_bbs_city = NewStrBufDup(Buf); + info->serv_bbs_city = NewStrBufDup(Buf); break; case 7: - serv_info.serv_sysadm = NewStrBufDup(Buf); + info->serv_sysadm = NewStrBufDup(Buf); break; case 9: - serv_info.serv_moreprompt = NewStrBufDup(Buf); + info->serv_moreprompt = NewStrBufDup(Buf); break; case 14: - serv_info.serv_supports_ldap = StrToi(Buf); + info->serv_supports_ldap = StrToi(Buf); break; case 15: - serv_info.serv_newuser_disabled = StrToi(Buf); + info->serv_newuser_disabled = StrToi(Buf); break; case 16: - serv_info.serv_default_cal_zone = NewStrBufDup(Buf); + info->serv_default_cal_zone = NewStrBufDup(Buf); break; case 20: - serv_info.serv_supports_sieve = StrToi(Buf); + info->serv_supports_sieve = StrToi(Buf); break; case 21: - serv_info.serv_fulltext_enabled = StrToi(Buf); + info->serv_fulltext_enabled = StrToi(Buf); break; case 22: - serv_info.serv_svn_revision = NewStrBufDup(Buf); + info->serv_svn_revision = NewStrBufDup(Buf); break; case 23: - serv_info.serv_supports_openid = StrToi(Buf); + info->serv_supports_openid = StrToi(Buf); break; } ++a; } + FreeStrBuf(&Buf); + return info; } @@ -512,42 +532,42 @@ void tmplput_serv_ip(StrBuf *Target, WCTemplputParams *TP) void tmplput_serv_nodename(StrBuf *Target, WCTemplputParams *TP) { - StrBufAppendTemplate(Target, TP, serv_info.serv_nodename, 0); + StrBufAppendTemplate(Target, TP, WC->serv_info->serv_nodename, 0); } void tmplput_serv_humannode(StrBuf *Target, WCTemplputParams *TP) { - StrBufAppendTemplate(Target, TP, serv_info.serv_humannode, 0); + StrBufAppendTemplate(Target, TP, WC->serv_info->serv_humannode, 0); } void tmplput_serv_fqdn(StrBuf *Target, WCTemplputParams *TP) { - StrBufAppendTemplate(Target, TP, serv_info.serv_fqdn, 0); + StrBufAppendTemplate(Target, TP, WC->serv_info->serv_fqdn, 0); } void tmplput_serv_software(StrBuf *Target, WCTemplputParams *TP) { - StrBufAppendTemplate(Target, TP, serv_info.serv_software, 0); + StrBufAppendTemplate(Target, TP, WC->serv_info->serv_software, 0); } void tmplput_serv_rev_level(StrBuf *Target, WCTemplputParams *TP) { StrBufAppendPrintf(Target, "%d.%02d", - serv_info.serv_rev_level / 100, - serv_info.serv_rev_level % 100); + WC->serv_info->serv_rev_level / 100, + WC->serv_info->serv_rev_level % 100); } int conditional_serv_newuser_disabled(StrBuf *Target, WCTemplputParams *TP) { - return serv_info.serv_newuser_disabled != 0; + return WC->serv_info->serv_newuser_disabled != 0; } int conditional_serv_supports_openid(StrBuf *Target, WCTemplputParams *TP) { - return serv_info.serv_supports_openid != 0; + return WC->serv_info->serv_supports_openid != 0; } void tmplput_serv_bbs_city(StrBuf *Target, WCTemplputParams *TP) { - StrBufAppendTemplate(Target, TP, serv_info.serv_bbs_city, 0); + StrBufAppendTemplate(Target, TP, WC->serv_info->serv_bbs_city, 0); } diff --git a/webcit/setup_wizard.c b/webcit/setup_wizard.c index 8b52e0616..a22b8fc03 100644 --- a/webcit/setup_wizard.c +++ b/webcit/setup_wizard.c @@ -19,7 +19,7 @@ void do_setup_wizard(void) if (!strcasecmp(step, "Finish")) { fp = fopen(wizard_filename, "w"); if (fp != NULL) { - fprintf(fp, "%d\n", serv_info.serv_rev_level); + fprintf(fp, "%d\n", WC->serv_info->serv_rev_level); fclose(fp); } do_welcome(); diff --git a/webcit/sieve.c b/webcit/sieve.c index 14a04a7ad..ee9449883 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -49,7 +49,7 @@ void display_sieve(void) int i; int rules_script_is_active = 0; - if (!serv_info.serv_supports_sieve) { + if (!WC->serv_info->serv_supports_sieve) { display_no_sieve(); return; } diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c index 01824a592..785a54d36 100644 --- a/webcit/siteconfig.c +++ b/webcit/siteconfig.c @@ -237,8 +237,8 @@ void siteconfig(void) serv_getln(buf, sizeof buf); serv_printf("SPEX mailboxes|%d|%d", ibstr("mboxpolicy"), ibstr("mboxvalue")); serv_getln(buf, sizeof buf); - FreeStrBuf(&serv_info.serv_default_cal_zone); - serv_info.serv_default_cal_zone = NewStrBufDup(sbstr("c_default_cal_zone")); + FreeStrBuf(&WCC->serv_info->serv_default_cal_zone); + WCC->serv_info->serv_default_cal_zone = NewStrBufDup(sbstr("c_default_cal_zone")); safestrncpy(WCC->ImportantMessage, _("Your system configuration has been updated."), sizeof WCC->ImportantMessage); diff --git a/webcit/smtpqueue.c b/webcit/smtpqueue.c index 1f86b3f27..43f5cd90a 100644 --- a/webcit/smtpqueue.c +++ b/webcit/smtpqueue.c @@ -90,7 +90,7 @@ void display_queue_msg(long msgnum) atsign = strchr(sender, '@'); if (atsign != NULL) { ++atsign; - if (!strcasecmp(atsign, ChrPtr(serv_info.serv_nodename))) { + if (!strcasecmp(atsign, ChrPtr(WC->serv_info->serv_nodename))) { --atsign; *atsign = 0; } diff --git a/webcit/summary.c b/webcit/summary.c index 19caa74fa..43c8e590d 100644 --- a/webcit/summary.c +++ b/webcit/summary.c @@ -156,15 +156,16 @@ void calendar_section(void) { */ void server_info_section(void) { char message[512]; + wcsession *WCC = WC; snprintf(message, sizeof message, _("You are connected to %s, running %s with %s, server build %s and located in %s. Your system administrator is %s."), - ChrPtr(serv_info.serv_humannode), - ChrPtr(serv_info.serv_software), + ChrPtr(WCC->serv_info->serv_humannode), + ChrPtr(WCC->serv_info->serv_software), PACKAGE_STRING, - ChrPtr(serv_info.serv_svn_revision), - ChrPtr(serv_info.serv_bbs_city), - ChrPtr(serv_info.serv_sysadm)); + ChrPtr(WCC->serv_info->serv_svn_revision), + ChrPtr(WCC->serv_info->serv_bbs_city), + ChrPtr(WCC->serv_info->serv_sysadm)); escputs(message); } diff --git a/webcit/userlist.c b/webcit/userlist.c index f0b8325ac..83d82e3cf 100644 --- a/webcit/userlist.c +++ b/webcit/userlist.c @@ -39,7 +39,7 @@ void userlist(void) output_headers(1, 1, 2, 0, 0, 0); wprintf("
\n"); wprintf("

"); - snprintf(title, sizeof title, _("User list for %s"), ChrPtr(serv_info.serv_humannode)); + snprintf(title, sizeof title, _("User list for %s"), ChrPtr(WC->serv_info->serv_humannode)); escputs(title); wprintf("

"); wprintf("
"); diff --git a/webcit/webcit.c b/webcit/webcit.c index e8a295814..edc19a0c6 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -108,6 +108,7 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers int suppress_check, /* 1 = suppress check for instant messages */ int cache /* 1 = allow browser to cache this page */ ) { + wcsession *WCC = WC; char cookie[1024]; char httpnow[128]; @@ -119,7 +120,7 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers "Server: %s / %s\n" "Connection: close\r\n", PACKAGE_STRING, - ChrPtr(serv_info.serv_software) + ChrPtr(WCC->serv_info->serv_software) ); } @@ -145,8 +146,8 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers } stuff_to_cookie(cookie, 1024, - WC->wc_session, WC->wc_username, - WC->wc_password, WC->wc_roomname); + WCC->wc_session, WCC->wc_username, + WCC->wc_password, WCC->wc_roomname); if (unset_cookies) { hprintf("Set-cookie: webcit=%s; path=/\r\n", unset); @@ -169,13 +170,13 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers wprintf("
\n" "\n" ); - StrBufAppendPrintf(WC->trailing_javascript, + StrBufAppendPrintf(WCC->trailing_javascript, "setTimeout('hide_imsg_popup()', 5000); \n" ); - WC->ImportantMessage[0] = 0; + WCC->ImportantMessage[0] = 0; } - if ( (WC->logged_in) && (!unset_cookies) ) { + if ( (WCC->logged_in) && (!unset_cookies) ) { //DoTemplate(HKEY("iconbar"), NULL, &NoCtx); page_popup(); } @@ -195,7 +196,7 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers void output_custom_content_header(const char *ctype) { hprintf("HTTP/1.1 200 OK\r\n"); hprintf("Content-type: %s; charset=utf-8\r\n",ctype); - hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(serv_info.serv_software)); + hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)); hprintf("Connection: close\r\n"); } @@ -395,7 +396,7 @@ void display_success(char *successmessage) void authorization_required(const char *message) { hprintf("HTTP/1.1 401 Authorization Required\r\n"); - hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n", ChrPtr(serv_info.serv_humannode)); + hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n", ChrPtr(WC->serv_info->serv_humannode)); hprintf("Content-Type: text/html\r\n"); wprintf("

"); wprintf(_("Authorization Required")); @@ -827,16 +828,16 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method locate_host(browser_host, WCC->http_sock); } - get_serv_info(browser_host, user_agent); - if (serv_info.serv_rev_level < MINIMUM_CIT_VERSION) { + WCC->serv_info = get_serv_info(browser_host, user_agent); + if (WCC->serv_info->serv_rev_level < MINIMUM_CIT_VERSION) { begin_burst(); wprintf(_("You are connected to a Citadel " "server running Citadel %d.%02d. \n" "In order to run this version of WebCit " "you must also have Citadel %d.%02d or" " newer.\n\n\n"), - serv_info.serv_rev_level / 100, - serv_info.serv_rev_level % 100, + WCC->serv_info->serv_rev_level / 100, + WCC->serv_info->serv_rev_level % 100, MINIMUM_CIT_VERSION / 100, MINIMUM_CIT_VERSION % 100 ); diff --git a/webcit/webcit.h b/webcit/webcit.h index 5b2aa23ce..604205bc0 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -214,7 +214,7 @@ struct urlcontent { /* * \brief information about us ??? */ -struct serv_info { +typedef struct _serv_info { int serv_pid; /* Process ID of the Citadel server */ StrBuf *serv_nodename; /* Node name of the Citadel server */ StrBuf *serv_humannode; /* human readable node name of the Citadel server */ @@ -232,7 +232,7 @@ struct serv_info { int serv_fulltext_enabled; /* Does the server have the full text index enabled? */ StrBuf *serv_svn_revision; /* SVN revision of the server */ int serv_supports_openid; /* Does the server support authentication via OpenID? */ -}; +} ServInfo; @@ -343,6 +343,7 @@ struct wcsession { int chat_sock; /**< Client socket to Citadel server - for chat */ time_t lastreq; /**< Timestamp of most recent HTTP */ time_t last_pager_check; /**< last time we polled for instant msgs */ + ServInfo *serv_info; /**< Iformation about the citserver we're connected to */ /* Request local Members */ StrBuf *CLineBuf; /**< linebuffering client stuff */ StrBuf *UrlFragment1; /**< first urlfragment, if NEED_URL is specified by the handler*/ @@ -488,7 +489,6 @@ extern char file_crpt_file_csr[PATH_MAX]; extern char file_crpt_file_cer[PATH_MAX]; #endif -struct serv_info serv_info; extern char floorlist[128][SIZ]; extern char *axdefs[]; extern char *ctdlhost, *ctdlport; @@ -526,7 +526,8 @@ void display_main_menu(void); void display_aide_menu(void); void display_advanced_menu(void); void slrp_highest(void); -void get_serv_info(StrBuf *, char *); +ServInfo *get_serv_info(StrBuf *, char *); +void DeleteServInfo(ServInfo **FreeMe); int uds_connectsock(char *); int tcp_connectsock(char *, char *); int serv_getln(char *strbuf, int bufsize); @@ -602,10 +603,8 @@ void confirm_delete_room(void); void validate(void); void display_graphics_upload(char *, char *, char *); void do_graphics_upload(char *upl_cmd); -void serv_read(char *buf, int bytes); void serv_gets(char *strbuf); void serv_write(const char *buf, int nbytes); -void serv_puts(const char *string); void serv_putbuf(const StrBuf *string); void serv_printf(const char *format,...)__attribute__((__format__(__printf__,1,2))); void load_floorlist(void); -- 2.30.2