CSOURCES=`find ../.. -name \*.c`
HSOURCES=`find ../.. -name \*.html`
+JSOURCES=`find ../.. -name \*.js`
echo Updating webcit.pot from strings in the source code ...
xgettext \
/*
* Administrative screen for site-wide configuration
*
- * Copyright (c) 1996-2014 by the citadel.org team
+ * Copyright (c) 1996-2021 by the citadel.org team
*
* This program is open source software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License, version 3.
void LoadExpirePolicy(GPEXWhichPolicy which)
{
StrBuf *Buf;
- wcsession *WCC = WC;
long State;
const char *Pos = NULL;
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, &State) == 2) {
Pos = ChrPtr(Buf) + 4;
- WCC->Policy[which].expire_mode = StrBufExtractNext_long(Buf, &Pos, '|');
- WCC->Policy[which].expire_value = StrBufExtractNext_long(Buf, &Pos, '|');
+ WC->Policy[which].expire_mode = StrBufExtractNext_long(Buf, &Pos, '|');
+ WC->Policy[which].expire_value = StrBufExtractNext_long(Buf, &Pos, '|');
}
else if (State == 550)
AppendImportantMessage(_("Higher access is required to access this function."), -1);
int ConditionalExpire(StrBuf *Target, WCTemplputParams *TP)
{
- wcsession *WCC = WC;
GPEXWhichPolicy which;
int CompareWith;
LoadExpirePolicy(which);
- return WCC->Policy[which].expire_mode == CompareWith;
+ return WC->Policy[which].expire_mode == CompareWith;
}
void tmplput_ExpireValue(StrBuf *Target, WCTemplputParams *TP)
{
GPEXWhichPolicy which;
- wcsession *WCC = WC;
which = GetTemplateTokenNumber(Target, TP, 0, 0);
LoadExpirePolicy(which);
- StrBufAppendPrintf(Target, "%d", WCC->Policy[which].expire_value);
+ StrBufAppendPrintf(Target, "%d", WC->Policy[which].expire_value);
}
void tmplput_ExpireMode(StrBuf *Target, WCTemplputParams *TP)
{
GPEXWhichPolicy which;
- wcsession *WCC = WC;
which = GetTemplateTokenNumber(Target, TP, 2, 0);
LoadExpirePolicy(which);
- StrBufAppendPrintf(Target, "%d", WCC->Policy[which].expire_mode);
+ StrBufAppendPrintf(Target, "%d", WC->Policy[which].expire_mode);
}
*/
void load_siteconfig(void)
{
- wcsession *WCC = WC;
StrBuf *Buf;
HashList *Cfg;
long len;
int i, j;
- if (WCC->ServCfg == NULL)
- WCC->ServCfg = NewHash(1, NULL);
- Cfg = WCC->ServCfg;
+ if (WC->ServCfg == NULL)
+ WC->ServCfg = NewHash(1, NULL);
+ Cfg = WC->ServCfg;
Buf = NewStrBuf();
*/
void siteconfig(void)
{
- wcsession *WCC = WC;
int i, value;
StrBuf *Line;
SaveExpirePolicyFromHTTP(sitepolicy);
SaveExpirePolicyFromHTTP(mailboxespolicy);
- FreeStrBuf(&WCC->serv_info->serv_default_cal_zone);
- WCC->serv_info->serv_default_cal_zone = NewStrBufDup(sbstr("c_default_cal_zone"));
+ FreeStrBuf(&WC->serv_info->serv_default_cal_zone);
+ WC->serv_info->serv_default_cal_zone = NewStrBufDup(sbstr("c_default_cal_zone"));
AppendImportantMessage(_("Your system configuration has been updated."), -1);
- DeleteHash(&WCC->ServCfg);
+ DeleteHash(&WC->ServCfg);
display_aide_menu();
}
+
+// if WebCit Classic wasn't obsolete we would replace this with a "CONF GETVAL" type of thing
void tmplput_servcfg(StrBuf *Target, WCTemplputParams *TP)
{
- wcsession *WCC = WC;
void *vBuf;
StrBuf *Buf;
- if (WCC->is_aide) {
- if (WCC->ServCfg == NULL)
+ if (WC->is_aide) {
+ if (WC->ServCfg == NULL)
load_siteconfig();
- GetHash(WCC->ServCfg, TKEY(0), &vBuf);
+ GetHash(WC->ServCfg, TKEY(0), &vBuf);
Buf = (StrBuf*) vBuf;
StrBufAppendTemplate(Target, TP, Buf, 1);
}
int ConditionalServCfg(StrBuf *Target, WCTemplputParams *TP)
{
- wcsession *WCC = WC;
void *vBuf;
StrBuf *Buf;
- if (WCC->is_aide) {
- if (WCC->ServCfg == NULL)
+ if (WC->is_aide) {
+ if (WC->ServCfg == NULL)
load_siteconfig();
- GetHash(WCC->ServCfg, TKEY(2), &vBuf);
+ GetHash(WC->ServCfg, TKEY(2), &vBuf);
if (vBuf == NULL) return 0;
Buf = (StrBuf*) vBuf;
if (TP->Tokens->nParameters == 3) {
int ConditionalServCfgCTXStrBuf(StrBuf *Target, WCTemplputParams *TP)
{
- wcsession *WCC = WC;
void *vBuf;
StrBuf *Buf;
StrBuf *ZoneToCheck = (StrBuf*) CTX(CTX_STRBUF);
- if ((WCC->is_aide) || (ZoneToCheck == NULL)) {
- if (WCC->ServCfg == NULL)
+ if ((WC->is_aide) || (ZoneToCheck == NULL)) {
+ if (WC->ServCfg == NULL)
load_siteconfig();
- GetHash(WCC->ServCfg, TKEY(2), &vBuf);
+ GetHash(WC->ServCfg, TKEY(2), &vBuf);
if (vBuf == NULL) return 0;
Buf = (StrBuf*) vBuf;
/*
* XML sitemap generator
*
- * Copyright (c) 2010-2012 by the citadel.org team
+ * Copyright (c) 2010-2021 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 3.
* XML sitemap generator -- go through the message list for a BBS room
*/
void sitemap_do_bbs(void) {
- wcsession *WCC = WC;
int num_msgs = 0;
int i;
SharedMessageStatus Stat;
if (num_msgs < 1) return;
for (i=0; i<num_msgs; i+=20) {
- Msg = GetMessagePtrAt(i, WCC->summ);
+ Msg = GetMessagePtrAt(i, WC->summ);
if (Msg != NULL) {
wc_printf("<url><loc>%s/readfwd", ChrPtr(site_prefix));
wc_printf("?go=");
* XML sitemap generator -- go through the message list for a wiki room
*/
void sitemap_do_wiki(void) {
- wcsession *WCC = WC;
int num_msgs = 0;
int i;
SharedMessageStatus Stat;
if (num_msgs < 1) return;
for (i=0; i<num_msgs; ++i) {
- Msg = GetMessagePtrAt(i, WCC->summ);
+ Msg = GetMessagePtrAt(i, WC->summ);
if (Msg != NULL) {
serv_printf("MSG0 %ld|3", Msg->msgnum);
void output_flat_static(void)
{
- wcsession *WCC = WC;
void *vFile;
StrBuf *File;
- if (WCC->Hdr->HR.Handler == NULL)
+ if (WC->Hdr->HR.Handler == NULL)
return;
- if (GetHash(StaticFilemappings[0], SKEY(WCC->Hdr->HR.Handler->Name), &vFile) &&
+ if (GetHash(StaticFilemappings[0], SKEY(WC->Hdr->HR.Handler->Name), &vFile) &&
(vFile != NULL))
{
File = (StrBuf*) vFile;
void output_static_safe(HashList *DirList)
{
- wcsession *WCC = WC;
void *vFile;
StrBuf *File;
const char *MimeType;
- if (GetHash(DirList, SKEY(WCC->Hdr->HR.ReqLine), &vFile) &&
+ if (GetHash(DirList, SKEY(WC->Hdr->HR.ReqLine), &vFile) &&
(vFile != NULL))
{
File = (StrBuf*) vFile;
}
else {
syslog(LOG_INFO, "output_static_safe() file %s not found. \n",
- ChrPtr(WCC->Hdr->HR.ReqLine));
- MimeType = GuessMimeByFilename(SKEY(WCC->Hdr->HR.ReqLine));
+ ChrPtr(WC->Hdr->HR.ReqLine));
+ MimeType = GuessMimeByFilename(SKEY(WC->Hdr->HR.ReqLine));
if (strstr(MimeType, "image/") != NULL)
{
output_error_pic("the file you requested isn't known to our cache", "maybe reload webcit?");
-<div class="conftitle"><?_("Global email aliases")></div>
+<div class="conftitle">
<a href="javascript:load_aliases()">↻</a>
+<?_("Global email aliases")></div>
<hr>
<div id="wc_easterbunny77">
</div>
+<textarea name="global_aliases" id="global_aliases">a
+</textarea>
+
<script type="text/javascript">
load_aliases = async() => {
populate_aliases(data);
};
+function delete_alias(rowid) {
+ var row = document.getElementById(rowid);
+ row.parentNode.removeChild(row);
+ repopulate_the_box();
+}
+
function populate_aliases(data) {
+ var a = "<table id=killo9867>";
lines = data.split("\n");
for (var i=1; i<lines.length && lines[i] != "000"; ++i) {
- document.getElementById("wc_easterbunny77").innerHTML += i + " " + lines[i] + "<br>";
+ config_line = lines[i].split("|");
+ lineid = randomString(10);
+ a += "<tr id=" + lineid + "><td>" + config_line[0] + "</td><td>" +
+ config_line[1] + "</td><td>" +
+ "<a href=\"javascript:delete_alias('" + lineid + "');\">" +
+ "<font color=#FF0000>✖</font></a></td></tr>";
}
+ a += "</table>";
+ document.getElementById("wc_easterbunny77").innerHTML = a;
+ repopulate_the_box();
+}
+
+function repopulate_the_box() {
+ newbox = "";
+ t = document.getElementById("killo9867");
+ for (row of t.rows) {
+ newbox += row.cells[0].innerHTML + " - " + row.cells[1].innerHTML + "\n";
+ }
+ document.getElementById("global_aliases").innerHTML = newbox;
}
load_aliases();
</script>
-
-<!-- This could end up being a design pattern in WebCit-NG -->
create_blog_room: {
nonce: Nonce,
er_name: roomname,
- type: 'public',
+ type: 'public',
er_view: er_view_blog,
er_floor: floorID,
template: "room_result_json",
setflags_blog_room: {
nonce: Nonce,
er_name: roomname,
- go: roomname,
- type: 'public',
+ go: roomname,
+ type: 'public',
er_floor: floorID,
directory: "yes",
ulmsg: "no",
visdir: "no",
- anon: "no",
+ anon: "no",
last_tabsel: 1,
er_view: er_view_blog,
template: "room_result_json",
create_blog_edit_room: {
nonce: Nonce,
er_name: editroomname,
- type: type_edit,
+ type: type_edit,
er_view: vselectedMarkup,
er_floor: floorID,
er_password: passvoid,
setflags_blog_edit_room: {
nonce: Nonce,
er_name: editroomname,
- go: editroomname,
- type: type_edit,
+ go: editroomname,
+ type: type_edit,
er_floor: floorID,
directory: "yes",
ulmsg: "no",
visdir: "yes",
- anon: "no",
+ anon: "no",
last_tabsel: 1,
er_view: er_view_blog,
template: "room_result_json",
blog_wiki_startmessage : {
nonce: Nonce,
force_room: editroomname,
- page: "home",
+ page: "home",
markdown: (isHtmlWiki)?0:1,
msgtext: starttext
wCLog(transport.responseText);
}
});
-}
\ No newline at end of file
+}
+
+
+
+
+// Generate a random string of the specified length
+// Useful for generating one-time-use div names
+//
+function randomString(length) {
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz'.split('');
+ var str = '';
+
+ if (!length) {
+ length = Math.floor(Math.random() * chars.length);
+ }
+ for (var i = 0; i < length; i++) {
+ str += chars[Math.floor(Math.random() * chars.length)];
+ }
+ return str;
+}
+
+
+
+
/*
* Displays the "Summary Page"
*
- * Copyright (c) 1996-2012 by the citadel.org team
+ * Copyright (c) 1996-2021 by the citadel.org team
*
* This program is open source software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License, version 3.
long HKLen;
void *vMsg;
message_summary *Msg;
- wcsession *WCC = WC;
StrBuf *Buf;
SharedMessageStatus Stat;
gotoroom(Buf);
FreeStrBuf(&Buf);
- if (WCC->CurRoom.view != VIEW_TASKS) {
+ if (WC->CurRoom.view != VIEW_TASKS) {
num_msgs = 0;
}
else {
}
if (num_msgs > 0) {
- at = GetNewHashPos(WCC->summ, 0);
- while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
+ at = GetNewHashPos(WC->summ, 0);
+ while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
Msg = (message_summary*) vMsg;
tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0);
}
long HKLen;
void *vMsg;
message_summary *Msg;
- wcsession *WCC = WC;
StrBuf *Buf;
void *v = NULL;
SharedMessageStatus Stat;
if (num_msgs > 0) {
- at = GetNewHashPos(WCC->summ, 0);
- while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
+ at = GetNewHashPos(WC->summ, 0);
+ while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
Msg = (message_summary*) vMsg;
calendar_LoadMsgFromServer(NULL, &v, Msg, 0, 0);
}
/*
* WebCit "system dependent" code.
*
- * Copyright (c) 1996-2012 by the citadel.org team
+ * Copyright (c) 1996-2021 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 3.
void CheckGZipCompressionAllowed(const char *MimeType, long MLen)
{
void *v;
- wcsession *WCC = WC;
- if (WCC->Hdr->HR.gzip_ok)
- WCC->Hdr->HR.gzip_ok = GetHash(GZMimeBlackList, MimeType, MLen, &v) == 0;
+ if (WC->Hdr->HR.gzip_ok)
+ WC->Hdr->HR.gzip_ok = GetHash(GZMimeBlackList, MimeType, MLen, &v) == 0;
}
void InitialiseSemaphores(void)
time_t due;
char buf[SIZ];
icalproperty *p;
- wcsession *WCC = WC;
wc_printf("<table class=\"calendar_view_background\"><tbody id=\"taskview\">\n<tr>\n<th>");
wc_printf(_("Completed?"));
task_completed_cmp);
}
- Pos = GetNewHashPos(WCC->disp_cal_items, 0);
- while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
+ Pos = GetNewHashPos(WC->disp_cal_items, 0);
+ while (GetNextHashPos(WC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
icalproperty_status todoStatus;
int is_date;
void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, char *from,
int unread, calview *calv)
{
- wcsession *WCC = WC;
icalcomponent *vtodo;
icalproperty *p;
struct icaltimetype IcalTime;
wc_printf("<div style=\"display: none;\">\n ");
wc_printf("<input type=\"hidden\" name=\"go\" value=\"");
- StrEscAppend(WCC->WBuf, WCC->CurRoom.name, NULL, 0, 0);
+ StrEscAppend(WC->WBuf, WC->CurRoom.name, NULL, 0, 0);
wc_printf("\">\n");
wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
{
icalproperty *ps = NULL;
struct icaltimetype dtstart, dtend;
- wcsession *WCC = WC;
disp_cal *Cal;
size_t len;
icalcomponent *cptr = NULL;
dtstart = icaltime_null_time();
dtend = icaltime_null_time();
- if (WCC->disp_cal_items == NULL) {
- WCC->disp_cal_items = NewHash(0, Flathash);
+ if (WC->disp_cal_items == NULL) {
+ WC->disp_cal_items = NewHash(0, Flathash);
}
Cal = (disp_cal*) malloc(sizeof(disp_cal));
/* Store it in the hash list. */
/* syslog(LOG_DEBUG, "INITIAL: %s", ctime(&Cal->event_start)); */
- Put(WCC->disp_cal_items,
+ Put(WC->disp_cal_items,
(char*) &Cal->event_start,
sizeof(Cal->event_start),
Cal,
/*
- * Copyright (c) 1987-2017 by the citadel.org team
+ * Copyright (c) 1987-2021 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 3.
*/
int serv_getln(char *strbuf, int bufsize)
{
- wcsession *WCC = WC;
int len;
*strbuf = '\0';
- StrBuf_ServGetln(WCC->MigrateReadLineBuf);
- len = StrLength(WCC->MigrateReadLineBuf);
+ StrBuf_ServGetln(WC->MigrateReadLineBuf);
+ len = StrLength(WC->MigrateReadLineBuf);
if (len > bufsize)
len = bufsize - 1;
- memcpy(strbuf, ChrPtr(WCC->MigrateReadLineBuf), len);
- FlushStrBuf(WCC->MigrateReadLineBuf);
+ memcpy(strbuf, ChrPtr(WC->MigrateReadLineBuf), len);
+ FlushStrBuf(WC->MigrateReadLineBuf);
strbuf[len] = '\0';
#ifdef SERV_TRACE
- syslog(LOG_DEBUG, "%3d<<<%s\n", WCC->serv_sock, strbuf);
+ syslog(LOG_DEBUG, "%3d<<<%s\n", WC->serv_sock, strbuf);
#endif
return len;
}
int StrBuf_ServGetln(StrBuf *buf)
{
- wcsession *WCC = WC;
const char *ErrStr = NULL;
int rc;
- if (!WCC->connected)
+ if (!WC->connected)
return -1;
FlushStrBuf(buf);
rc = StrBufTCP_read_buffered_line_fast(buf,
- WCC->ReadBuf,
- &WCC->ReadPos,
- &WCC->serv_sock,
+ WC->ReadBuf,
+ &WC->ReadPos,
+ &WC->serv_sock,
5, 1,
&ErrStr);
if (rc < 0)
syslog(LOG_INFO, "StrBuf_ServGetln(): Server connection broken: %s\n",
(ErrStr)?ErrStr:"");
wc_backtrace(LOG_INFO);
- if (WCC->serv_sock > 0) close(WCC->serv_sock);
- WCC->serv_sock = (-1);
- WCC->connected = 0;
- WCC->logged_in = 0;
+ if (WC->serv_sock > 0) close(WC->serv_sock);
+ WC->serv_sock = (-1);
+ WC->connected = 0;
+ WC->logged_in = 0;
}
#ifdef SERV_TRACE
else
{
long pos = 0;
- if (WCC->ReadPos != NULL)
- pos = WCC->ReadPos - ChrPtr(WCC->ReadBuf);
+ if (WC->ReadPos != NULL)
+ pos = WC->ReadPos - ChrPtr(WC->ReadBuf);
syslog(LOG_DEBUG, "%3d<<<[%ld]%s\n", WC->serv_sock, pos, ChrPtr(buf));
}
#endif
int StrBuf_ServGetBLOBBuffered(StrBuf *buf, long BlobSize)
{
- wcsession *WCC = WC;
const char *ErrStr;
int rc;
rc = StrBufReadBLOBBuffered(buf,
- WCC->ReadBuf,
- &WCC->ReadPos,
- &WCC->serv_sock,
+ WC->ReadBuf,
+ &WC->ReadPos,
+ &WC->serv_sock,
1,
BlobSize,
NNN_TERM,
syslog(LOG_INFO, "StrBuf_ServGetBLOBBuffered(): Server connection broken: %s\n",
(ErrStr)?ErrStr:"");
wc_backtrace(LOG_INFO);
- if (WCC->serv_sock > 0) close(WCC->serv_sock);
- WCC->serv_sock = (-1);
- WCC->connected = 0;
- WCC->logged_in = 0;
+ if (WC->serv_sock > 0) close(WC->serv_sock);
+ WC->serv_sock = (-1);
+ WC->connected = 0;
+ WC->logged_in = 0;
}
#ifdef SERV_TRACE
else
int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize)
{
- wcsession *WCC = WC;
const char *ErrStr;
int rc;
- WCC->ReadPos = NULL;
- rc = StrBufReadBLOB(buf, &WCC->serv_sock, 1, BlobSize, &ErrStr);
+ WC->ReadPos = NULL;
+ rc = StrBufReadBLOB(buf, &WC->serv_sock, 1, BlobSize, &ErrStr);
if (rc < 0)
{
syslog(LOG_INFO, "StrBuf_ServGetBLOB(): Server connection broken: %s\n",
(ErrStr)?ErrStr:"");
wc_backtrace(LOG_INFO);
- if (WCC->serv_sock > 0) close(WCC->serv_sock);
- WCC->serv_sock = (-1);
- WCC->connected = 0;
- WCC->logged_in = 0;
+ if (WC->serv_sock > 0) close(WC->serv_sock);
+ WC->serv_sock = (-1);
+ WC->connected = 0;
+ WC->logged_in = 0;
}
#ifdef SERV_TRACE
else
long len;
const char *pch;
const char *pche;
- wcsession *WCC = WC;
- len = StrLength(WCC->ReadBuf);
+ len = StrLength(WC->ReadBuf);
if ((len > 0) &&
- (WCC->ReadPos != NULL) &&
- (WCC->ReadPos != StrBufNOTNULL))
+ (WC->ReadPos != NULL) &&
+ (WC->ReadPos != StrBufNOTNULL))
{
- pch = ChrPtr(WCC->ReadBuf);
+ pch = ChrPtr(WC->ReadBuf);
pche = pch + len;
- if (WCC->ReadPos != pche)
+ if (WC->ReadPos != pche)
{
syslog(LOG_ERR,
"ERROR: somebody didn't eat his soup! Remaing Chars: %ld [%s]\n",
- (long)(pche - WCC->ReadPos),
+ (long)(pche - WC->ReadPos),
pche
);
syslog(LOG_ERR,
}
}
- FlushStrBuf(WCC->ReadBuf);
- WCC->ReadPos = NULL;
+ FlushStrBuf(WC->ReadBuf);
+ WC->ReadPos = NULL;
}
*/
int serv_write(const char *buf, int nbytes)
{
- wcsession *WCC = WC;
int bytes_written = 0;
int retval;
FlushReadBuf();
while (bytes_written < nbytes) {
- retval = write(WCC->serv_sock, &buf[bytes_written],
+ retval = write(WC->serv_sock, &buf[bytes_written],
nbytes - bytes_written);
if (retval < 1) {
const char *ErrStr = strerror(errno);
syslog(LOG_INFO, "serv_write(): Server connection broken: %s\n",
(ErrStr)?ErrStr:"");
- if (WCC->serv_sock > 0) close(WCC->serv_sock);
- WCC->serv_sock = (-1);
- WCC->connected = 0;
- WCC->logged_in = 0;
+ if (WC->serv_sock > 0) close(WC->serv_sock);
+ WC->serv_sock = (-1);
+ WC->connected = 0;
+ WC->logged_in = 0;
return 0;
}
bytes_written = bytes_written + retval;
*/
int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf)
{
- wcsession *WCC = WC;
size_t bytes_read = 0;
size_t this_block = 0;
int rc = 6;
while ((bytes_read < total_len) && (ServerRc == 6)) {
- if (WCC->serv_sock==-1) {
+ if (WC->serv_sock==-1) {
FlushStrBuf(Ret);
return -1;
}
if (rc < 0) {
syslog(LOG_INFO, "Server connection broken during download\n");
wc_backtrace(LOG_INFO);
- if (WCC->serv_sock > 0) close(WCC->serv_sock);
- WCC->serv_sock = (-1);
- WCC->connected = 0;
- WCC->logged_in = 0;
+ if (WC->serv_sock > 0) close(WC->serv_sock);
+ WC->serv_sock = (-1);
+ WC->connected = 0;
+ WC->logged_in = 0;
return rc;
}
bytes_read += rc;
int client_write(StrBuf *ThisBuf)
{
- wcsession *WCC = WC;
const char *ptr, *eptr;
long count;
ssize_t res = 0;
fdflags = fcntl(WC->Hdr->http_sock, F_GETFL);
- while ((ptr < eptr) && (WCC->Hdr->http_sock != -1)) {
+ while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
FD_ZERO(&wset);
- FD_SET(WCC->Hdr->http_sock, &wset);
- if (select(WCC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
+ FD_SET(WC->Hdr->http_sock, &wset);
+ if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
syslog(LOG_INFO, "client_write: Socket select failed (%s)\n", strerror(errno));
return -1;
}
}
- if ((WCC->Hdr->http_sock == -1) ||
- ((res = write(WCC->Hdr->http_sock, ptr, count)),
+ if ((WC->Hdr->http_sock == -1) ||
+ ((res = write(WC->Hdr->http_sock, ptr, count)),
(res == -1)))
{
syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
{
int rc;
int ServerRc;
- wcsession *WCC = WC;
serv_printf("READ "SIZE_T_FMT"|"SIZE_T_FMT, *bytes_read, total_len-(*bytes_read));
if ( (rc = StrBuf_ServGetln(Buf) > 0) &&
StrBufCutLeft(Buf, 4);
this_block = StrTol(Buf);
- rc = StrBuf_ServGetBLOBBuffered(WCC->WBuf, this_block);
+ rc = StrBuf_ServGetBLOBBuffered(WC->WBuf, this_block);
if (rc < 0) {
syslog(LOG_INFO, "Server connection broken during download\n");
wc_backtrace(LOG_INFO);
- if (WCC->serv_sock > 0) close(WCC->serv_sock);
- WCC->serv_sock = (-1);
- WCC->connected = 0;
- WCC->logged_in = 0;
+ if (WC->serv_sock > 0) close(WC->serv_sock);
+ WC->serv_sock = (-1);
+ WC->connected = 0;
+ WC->logged_in = 0;
return rc;
}
*bytes_read += rc;
void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static, int detect_mime)
{
int ServerRc = 6;
- wcsession *WCC = WC;
size_t bytes_read = 0;
int first = 1;
int client_con_state = 0;
Buf = NewStrBuf();
- if (WCC->Hdr->HaveRange)
+ if (WC->Hdr->HaveRange)
{
- WCC->Hdr->HaveRange++;
- WCC->Hdr->TotalBytes = total_len;
+ WC->Hdr->HaveRange++;
+ WC->Hdr->TotalBytes = total_len;
/* open range? or beyound file border? correct the numbers. */
- if ((WCC->Hdr->RangeTil == -1) || (WCC->Hdr->RangeTil>= total_len))
- WCC->Hdr->RangeTil = total_len - 1;
- bytes_read = WCC->Hdr->RangeStart;
- total_len = WCC->Hdr->RangeTil;
+ if ((WC->Hdr->RangeTil == -1) || (WC->Hdr->RangeTil>= total_len))
+ WC->Hdr->RangeTil = total_len - 1;
+ bytes_read = WC->Hdr->RangeStart;
+ total_len = WC->Hdr->RangeTil;
}
else
chunked = total_len > SIZ * 10; /* TODO: disallow for HTTP / 1.0 */
FreeStrBuf(&Buf);
return;
}
- CT = GuessMimeType(SKEY(WCC->WBuf));
- FlushStrBuf(WCC->WBuf);
+ CT = GuessMimeType(SKEY(WC->WBuf));
+ FlushStrBuf(WC->WBuf);
StrBufPlain(MimeType, CT, -1);
CheckGZipCompressionAllowed(SKEY(MimeType));
detect_mime = 0;
}
memset(&WriteBuffer, 0, sizeof(IOBuffer));
- if (chunked && !DisableGzip && WCC->Hdr->HR.gzip_ok)
+ if (chunked && !DisableGzip && WC->Hdr->HR.gzip_ok)
{
is_gzip = 1;
SC = StrBufNewStreamContext (eZLibEncode, &Err);
}
memset(&ReadBuffer, 0, sizeof(IOBuffer));
- ReadBuffer.Buf = WCC->WBuf;
+ ReadBuffer.Buf = WC->WBuf;
WriteBuffer.Buf = NewStrBufPlain(NULL, SIZ*2);;
pBuf = WriteBuffer.Buf;
}
else
{
- pBuf = WCC->WBuf;
+ pBuf = WC->WBuf;
}
if (!detect_mime)
{
http_transmit_headers(ChrPtr(MimeType), is_static, chunked, is_gzip);
- if (send_http(WCC->HBuf) < 0)
+ if (send_http(WC->HBuf) < 0)
{
FreeStrBuf(&Buf);
FreeStrBuf(&WriteBuffer.Buf);
(client_con_state == 0))
{
- if (WCC->serv_sock==-1) {
- FlushStrBuf(WCC->WBuf);
+ if (WC->serv_sock==-1) {
+ FlushStrBuf(WC->WBuf);
FreeStrBuf(&Buf);
FreeStrBuf(&WriteBuffer.Buf);
FreeStrBuf(&BufHeader);
const char *CT;
detect_mime = 0;
- CT = GuessMimeType(SKEY(WCC->WBuf));
+ CT = GuessMimeType(SKEY(WC->WBuf));
StrBufPlain(MimeType, CT, -1);
if (is_gzip) {
CheckGZipCompressionAllowed(SKEY(MimeType));
- is_gzip = WCC->Hdr->HR.gzip_ok;
+ is_gzip = WC->Hdr->HR.gzip_ok;
}
http_transmit_headers(ChrPtr(MimeType), is_static, chunked, is_gzip);
- client_con_state = send_http(WCC->HBuf);
+ client_con_state = send_http(WC->HBuf);
}
if (is_gzip)
}
} while ((rc == 1) && (StrLength(pBuf) > 0));
}
- FlushStrBuf(WCC->WBuf);
+ FlushStrBuf(WC->WBuf);
}
else {
if ((chunked) && (client_con_state == 0))
*/
long end_burst(void)
{
- wcsession *WCC = WC;
const char *ptr, *eptr;
long count;
ssize_t res = 0;
fd_set wset;
int fdflags;
- if (!DisableGzip && (WCC->Hdr->HR.gzip_ok))
+ if (!DisableGzip && (WC->Hdr->HR.gzip_ok))
{
- if (CompressBuffer(WCC->WBuf) > 0)
+ if (CompressBuffer(WC->WBuf) > 0)
hprintf("Content-encoding: gzip\r\n");
else {
syslog(LOG_ALERT, "Compression failed: %d [%s] sending uncompressed\n", errno, strerror(errno));
}
}
- if (WCC->WFBuf != NULL) {
- WildFireSerializePayload(WCC->WFBuf, WCC->HBuf, &WCC->Hdr->nWildfireHeaders, NULL);
- FreeStrBuf(&WCC->WFBuf);
+ if (WC->WFBuf != NULL) {
+ WildFireSerializePayload(WC->WFBuf, WC->HBuf, &WC->Hdr->nWildfireHeaders, NULL);
+ FreeStrBuf(&WC->WFBuf);
}
- if (WCC->Hdr->HR.prohibit_caching)
+ if (WC->Hdr->HR.prohibit_caching)
hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
- hprintf("Content-length: %d\r\n\r\n", StrLength(WCC->WBuf));
+ hprintf("Content-length: %d\r\n\r\n", StrLength(WC->WBuf));
- ptr = ChrPtr(WCC->HBuf);
- count = StrLength(WCC->HBuf);
+ ptr = ChrPtr(WC->HBuf);
+ count = StrLength(WC->HBuf);
eptr = ptr + count;
#ifdef HAVE_OPENSSL
if (is_https) {
- client_write_ssl(WCC->HBuf);
- client_write_ssl(WCC->WBuf);
+ client_write_ssl(WC->HBuf);
+ client_write_ssl(WC->WBuf);
return (count);
}
#endif
- if (WCC->Hdr->http_sock == -1) {
+ if (WC->Hdr->http_sock == -1) {
return -1;
}
fdflags = fcntl(WC->Hdr->http_sock, F_GETFL);
- while ((ptr < eptr) && (WCC->Hdr->http_sock != -1)) {
+ while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
FD_ZERO(&wset);
- FD_SET(WCC->Hdr->http_sock, &wset);
- if (select(WCC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
+ FD_SET(WC->Hdr->http_sock, &wset);
+ if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
syslog(LOG_DEBUG, "client_write: Socket select failed (%s)\n", strerror(errno));
return -1;
}
}
- if ((WCC->Hdr->http_sock == -1) ||
- (res = write(WCC->Hdr->http_sock,
+ if ((WC->Hdr->http_sock == -1) ||
+ (res = write(WC->Hdr->http_sock,
ptr,
count)) == -1) {
syslog(LOG_DEBUG, "client_write: Socket write failed (%s)\n", strerror(errno));
ptr += res;
}
- ptr = ChrPtr(WCC->WBuf);
- count = StrLength(WCC->WBuf);
+ ptr = ChrPtr(WC->WBuf);
+ count = StrLength(WC->WBuf);
eptr = ptr + count;
- while ((ptr < eptr) && (WCC->Hdr->http_sock != -1)) {
+ while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
FD_ZERO(&wset);
- FD_SET(WCC->Hdr->http_sock, &wset);
- if (select(WCC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
+ FD_SET(WC->Hdr->http_sock, &wset);
+ if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
syslog(LOG_INFO, "client_write: Socket select failed (%s)\n", strerror(errno));
return -1;
}
}
- if ((WCC->Hdr->http_sock == -1) ||
- (res = write(WCC->Hdr->http_sock,
+ if ((WC->Hdr->http_sock == -1) ||
+ (res = write(WC->Hdr->http_sock,
ptr,
count)) == -1) {
syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
ptr += res;
}
- return StrLength(WCC->WBuf);
+ return StrLength(WC->WBuf);
}
/*
- * Copyright (c) 1996-2020 by the citadel.org team
+ * Copyright (c) 1996-2021 by the citadel.org team
*
* This program is open source software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License, version 3.
*/
long locate_user_vcard_in_this_room(message_summary **VCMsg, wc_mime_attachment **VCAtt)
{
- wcsession *WCC = WC;
HashPos *at;
HashPos *att;
const char *HashKey;
Stat.highest_found = (-1);
/* Search for the user's vCard */
if (load_msg_ptrs("MSGS ALL||||1", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0) > 0) {
- at = GetNewHashPos(WCC->summ, 0);
- while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
+ at = GetNewHashPos(WC->summ, 0);
+ while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
Msg = (message_summary*) vMsg;
Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
/*
- * Copyright (c) 1996-2020 by the citadel.org team
+ * Copyright (c) 1996-2021 by the citadel.org team
*
* This program is open source software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License, version 3.
struct vCard *v;
char *photosrc;
const char *contentType;
- wcsession *WCC = WC;
- msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
+ msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
vcard = load_mimepart(msgnum,"1");
v = VCardLoad(vcard);
photosrc = vcard_get_prop(v, "PHOTO", 1,0,0);
- FlushStrBuf(WCC->WBuf);
- StrBufAppendBufPlain(WCC->WBuf, photosrc, -1, 0);
- if (StrBufDecodeBase64(WCC->WBuf) <= 0) {
- FlushStrBuf(WCC->WBuf);
+ FlushStrBuf(WC->WBuf);
+ StrBufAppendBufPlain(WC->WBuf, photosrc, -1, 0);
+ if (StrBufDecodeBase64(WC->WBuf) <= 0) {
+ FlushStrBuf(WC->WBuf);
hprintf("HTTP/1.1 500 %s\n","Unable to get photo");
output_headers(0, 0, 0, 0, 0, 0);
end_burst();
return;
}
- contentType = GuessMimeType(ChrPtr(WCC->WBuf), StrLength(WCC->WBuf));
+ contentType = GuessMimeType(ChrPtr(WC->WBuf), StrLength(WC->WBuf));
http_transmit_thing(contentType, 0);
free(v);
free(photosrc);
const char *return_to,
const char *force_room) {
WCTemplputParams SubTP;
- wcsession *WCC = WC;
message_summary *Msg = NULL;
wc_mime_attachment *VCMime = NULL;
struct vCard *v;
v = VCardLoad(VCAtt->Data);
}
- parse_vcard(WCC->WBuf, v, ab.VC, NULL);
+ parse_vcard(WC->WBuf, v, ab.VC, NULL);
vcard_free(v);
StackContext(TP, &SubTP, &ab, CTX_VCARD, 0, NULL);
- DoTemplate(HKEY("vcard_edit"), WCC->WBuf, &SubTP);
+ DoTemplate(HKEY("vcard_edit"), WC->WBuf, &SubTP);
UnStackContext(&SubTP);
}
DeleteHash(&ab.VC);
int is_new,
int i)
{
- wcsession *WCC = WC;
WCTemplputParams *TP = NULL;
WCTemplputParams SubTP;
vcardview_struct *VS;
abEntry->VC = NewHash(0, lFlathash);
abEntry->ab_msgnum = Msg->msgnum;
- parse_vcard(WCC->WBuf, v, abEntry->VC, VCMime);
+ parse_vcard(WC->WBuf, v, abEntry->VC, VCMime);
memset(&SubTP, 0, sizeof(WCTemplputParams));
StackContext(TP, &SubTP, abEntry, CTX_VCARD, 0, NULL);
// No, don't display the name, it just shits all over the screen
- // DoTemplate(HKEY("vcard_list_name"), WCC->WBuf, &SubTP);
+ // DoTemplate(HKEY("vcard_list_name"), WC->WBuf, &SubTP);
UnStackContext(&SubTP);
StrBuf **tablabels;
int num_ab = GetCount(VS->addrbook);
HashList *headlines;
- wcsession *WCC = WC;
WCTemplputParams *TP = NULL;
WCTemplputParams SubTP;
StrTabbedDialog(WC->WBuf, num_pages, tablabels);
StackContext(TP, &SubTP, VS->addrbook, CTX_VCARD_LIST, 0, NULL);
- DoTemplate(HKEY("vcard_list"), WCC->WBuf, &SubTP);
+ DoTemplate(HKEY("vcard_list"), WC->WBuf, &SubTP);
UnStackContext(&SubTP);
DeleteHash(&headlines);
free(tablabels);
- StrBufAppendBufPlain(WCC->WBuf, HKEY("</div>"), 0);/* closes: id=global */
+ StrBufAppendBufPlain(WC->WBuf, HKEY("</div>"), 0);/* closes: id=global */
}
void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
{
wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
- wcsession *WCC = WC;
if (StrLength(Mime->Data) == 0) {
MimeLoadData(Mime);
}
Buf = NewStrBuf();
/** If it's my vCard I can edit it */
- if ( (!strcasecmp(ChrPtr(WCC->CurRoom.name), USERCONFIGROOM))
- || ((StrLength(WCC->CurRoom.name) > 11) &&
- (!strcasecmp(&(ChrPtr(WCC->CurRoom.name)[11]), USERCONFIGROOM)))
- || (WCC->CurRoom.view == VIEW_ADDRESSBOOK)
+ if ( (!strcasecmp(ChrPtr(WC->CurRoom.name), USERCONFIGROOM))
+ || ((StrLength(WC->CurRoom.name) > 11) &&
+ (!strcasecmp(&(ChrPtr(WC->CurRoom.name)[11]), USERCONFIGROOM)))
+ || (WC->CurRoom.view == VIEW_ADDRESSBOOK)
) {
StrBufAppendPrintf(Buf, "<a href=\"edit_vcard?msgnum=%ld?partnum=%s\">",
Mime->msgnum, ChrPtr(Mime->PartNum));
int GetWholistSection(HashList *List, time_t now, StrBuf *Buf, const char *FilterName, long FNLen)
{
- wcsession *WCC = WC;
UserStateStruct *User, *OldUser;
void *VOldUser;
size_t BufLen;
OldUser = VOldUser;
OldUser->SessionCount++;
if (!User->Idle) {
- if (User->Session == WCC->ctdl_pid)
+ if (User->Session == WC->ctdl_pid)
OldUser->Session = User->Session;
OldUser->Idle = User->Idle;
/*
* Functions pertaining to rooms with a wiki view
*
- * Copyright (c) 2009-2018 by the citadel.org team
+ * Copyright (c) 2009-2021 by the citadel.org team
*
* This program is open source software. You can redistribute it and/or
* modify it under the terms of the GNU General Public License, version 3.
*/
void display_wiki_page_backend(StrBuf *pagename, char *rev, int do_revert)
{
- wcsession *WCC = WC;
const StrBuf *Mime;
long msgnum = (-1L);
char buf[256];
- if ((WCC->CurRoom.view != VIEW_WIKI) &&
- (WCC->CurRoom.view != VIEW_WIKIMD)) {
- wc_printf(_("'%s' is not a Wiki room."), ChrPtr(WCC->CurRoom.name) );
+ if ((WC->CurRoom.view != VIEW_WIKI) &&
+ (WC->CurRoom.view != VIEW_WIKIMD)) {
+ wc_printf(_("'%s' is not a Wiki room."), ChrPtr(WC->CurRoom.name) );
return;
}
}
if (msgnum >= 0L) {
- read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
+ read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
return;
}
putbstr("pagename", pagename);
int ConditionalHavewikiType(StrBuf *Target, WCTemplputParams *TP)
{
- wcsession *WCC = WC;
const char *pch;
long len;
GetTemplateTokenString(Target, TP, 2, &pch, &len);
- return bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), pch) != NULL;
+ return bmstrcasestr((char *)ChrPtr(WC->Hdr->HR.ReqLine), pch) != NULL;
}