wprintf("<option value=\"__LOCAL_USERS__\" %s>",
(strcmp(ChrPtr(DefAddrBook), "__LOCAL_USERS__") == 0)?
"selected=\"selected\" ":"");
- escputs(ChrPtr(serv_info.serv_humannode));
+ escputs(ChrPtr(WC->serv_info->serv_humannode));
wprintf("</option>\n");
svput("EXIT_BUTTON", WCS_STRING, _("Exit"));
svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by <a href=\"http://www.citadel.org\">Citadel</a>"),
- ChrPtr(serv_info.serv_humannode));
+ ChrPtr(WC->serv_info->serv_humannode));
do_template("openid_manual_create", NULL);
wDumpContent(2);
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));
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)
);
}
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;
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);
* 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;
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();
*/
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);
}
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);
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
);
/* 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();
/** 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;
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);
}
*/
void display_openids(void)
{
+ wcsession *WCC = WC;
char buf[1024];
int bg = 0;
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("<table class=\"altern\">");
wprintf("</table><br />\n");
wprintf("<form method=\"POST\" action=\"openid_attach\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
+ wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WCC->nonce);
wprintf(_("Add an OpenID: "));
wprintf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
wprintf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">"
}
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);
wprintf("<label for=\"srchquery\">");
wprintf(_("Search: "));
wprintf("</label><input ");
- wprintf("%s", serv_info.serv_fulltext_enabled ? "" : "disabled ");
+ wprintf("%s", WC->serv_info->serv_fulltext_enabled ? "" : "disabled ");
wprintf("type=\"text\" name=\"query\" id=\"srchquery\" size=\"15\" maxlength=\"128\" class=\"inputbox\">\n"
);
wprintf("</div></form>\n");
/* 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();
svput("XML_HEAD", WCS_STRING, "<?xml version=\"1.0\" ?>");
svput("XML_STYLE", WCS_STRING, "<?xml-stylesheet type=\"text/css\" href=\"/static/rss_browser.css\" ?>");
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));
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) {
#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;
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;
}
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);
}
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();
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;
}
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);
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;
}
*/
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);
}
output_headers(1, 1, 2, 0, 0, 0);
wprintf("<div id=\"banner\">\n");
wprintf("<h1>");
- 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("</h1>");
wprintf("</div>");
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];
"Server: %s / %s\n"
"Connection: close\r\n",
PACKAGE_STRING,
- ChrPtr(serv_info.serv_software)
+ ChrPtr(WCC->serv_info->serv_software)
);
}
}
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);
wprintf("</span><br />\n"
"</div>\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();
}
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");
}
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("<h1>");
wprintf(_("Authorization Required"));
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
);
/*
* \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 */
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;
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*/
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;
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);
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);