*/
void display_changepw(void)
{
+ wcsession *WCC = WC;
WCTemplputParams SubTP;
char buf[SIZ];
StrBuf *Buf;
FreeStrBuf(&Buf);
- if (!IsEmptyStr(WC->ImportantMessage)) {
+ if (StrLength(WCC->ImportantMsg) > 0) {
wc_printf("<span class=\"errormsg\">"
- "%s</span><br>\n", WC->ImportantMessage);
- safestrncpy(WC->ImportantMessage, "", sizeof WC->ImportantMessage);
+ "%s</span><br>\n", ChrPtr(WCC->ImportantMsg));
+ FlushStrBuf(WCC->ImportantMsg);
}
serv_puts("MESG changepw");
*/
void changepw(void)
{
- char buf[SIZ];
+ StrBuf *Line;
char newpass1[32], newpass2[32];
if (!havebstr("change_action")) {
- safestrncpy(WC->ImportantMessage,
- _("Cancelled. Password was not changed."),
- sizeof WC->ImportantMessage);
+ AppendImportantMessage(_("Cancelled. Password was not changed."), -1);
display_main_menu();
return;
}
safestrncpy(newpass2, bstr("newpass2"), sizeof newpass2);
if (strcasecmp(newpass1, newpass2)) {
- safestrncpy(WC->ImportantMessage,
- _("They don't match. Password was not changed."),
- sizeof WC->ImportantMessage);
+ AppendImportantMessage(_("They don't match. Password was not changed."), -1);
display_changepw();
return;
}
if (IsEmptyStr(newpass1)) {
- safestrncpy(WC->ImportantMessage,
- _("Blank passwords are not allowed."),
- sizeof WC->ImportantMessage);
+ AppendImportantMessage(_("Blank passwords are not allowed."), -1);
display_changepw();
return;
}
+ Line = NewStrBuf();
serv_printf("SETP %s", newpass1);
- serv_getln(buf, sizeof buf);
- sprintf(WC->ImportantMessage, "%s", &buf[4]);
- if (buf[0] == '2') {
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 1, 0) == 2) {
if (WC->wc_password == NULL)
- WC->wc_password = NewStrBufPlain(buf, -1);
+ WC->wc_password = NewStrBufPlain(
+ ChrPtr(Line) + 4,
+ StrLength(Line) - 4);
else {
FlushStrBuf(WC->wc_password);
- StrBufAppendBufPlain(WC->wc_password, buf, -1, 0);
+ StrBufAppendBufPlain(WC->wc_password,
+ ChrPtr(Line) + 4,
+ StrLength(Line) - 4, 0);
}
display_main_menu();
}
else {
display_changepw();
}
+ FreeStrBuf(&Line);
}
void delete_file(void)
{
const StrBuf *MimeType;
- StrBuf *Buf;
+ StrBuf *Line;
char buf[256];
safestrncpy(buf, bstr("file"), sizeof buf);
unescape_input(buf);
serv_printf("DELF %s", buf);
- Buf = NewStrBuf();
- StrBuf_ServGetln(Buf);
- GetServerStatus(Buf, NULL);
- StrBufCutLeft(Buf, 4);
- strcpy(WC->ImportantMessage, ChrPtr(Buf));
+
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 0);
+
MimeType = DoTemplate(HKEY("files"), NULL, &NoCtx);
http_transmit_thing(ChrPtr(MimeType), 0);
- FreeStrBuf(&Buf);
+ FreeStrBuf(&Line);
}
{
const StrBuf *RetMimeType;
const char *MimeType;
- char buf[1024];
+ StrBuf *Line;
long bytes_transmitted = 0;
long blocksize;
const StrBuf *Desc;
ChrPtr(WCC->upload_filename),
MimeType,
ChrPtr(Desc));
-
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2')
- {
- strcpy(WCC->ImportantMessage, &buf[4]);
+ Line = NewStrBuf();
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
RetMimeType = DoTemplate(HKEY("files"), NULL, &NoCtx);
http_transmit_thing(ChrPtr(RetMimeType), 0);
+ FreeStrBuf(&Line);
return;
}
blocksize = (WCC->upload_length - bytes_transmitted);
}
serv_printf("WRIT %ld", blocksize);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '7')
- {
- blocksize = atoi(&buf[4]);
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 0, 0) == 7) {
+ blocksize = atoi(ChrPtr(Line) + 4);
serv_write(&ChrPtr(WCC->upload)[bytes_transmitted], blocksize);
bytes_transmitted += blocksize;
}
+ else
+ break;
}
serv_puts("UCLS 1");
- serv_getln(buf, sizeof buf);
- strcpy(WCC->ImportantMessage, &buf[4]);
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 0);
RetMimeType = DoTemplate(HKEY("files"), NULL, &NoCtx);
http_transmit_thing(ChrPtr(RetMimeType), 0);
+ FreeStrBuf(&Line);
}
}
}
if (buf[0] == '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
+ StrBufAppendBufPlain(WC->ImportantMsg, buf, -1, 4);
}
icalmemory_free_ring ();
icalcomponent_free(encaps);
void display_graphics_upload(char *filename)
{
- char buf[SIZ];
+ StrBuf *Line;
- snprintf(buf, SIZ, "UIMG 0||%s", filename);
- serv_puts(buf);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
+ Line = NewStrBuf();
+ serv_printf("UIMG 0||%s", filename);
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
display_main_menu();
return;
}
- output_headers(1, 0, 0, 0, 1, 0);
- do_template("files_graphicsupload");
- end_burst();
+ else
+ {
+ output_headers(1, 0, 0, 0, 1, 0);
+ do_template("files_graphicsupload");
+ end_burst();
+ }
+ FreeStrBuf(&Line);
}
void do_graphics_upload(char *filename)
{
+ StrBuf *Line;
const char *MimeType;
wcsession *WCC = WC;
char buf[SIZ];
bytes_remaining = WCC->upload_length;
if (havebstr("cancel_button")) {
- strcpy(WC->ImportantMessage,
- _("Graphics upload has been cancelled."));
+ AppendImportantMessage(_("Graphics upload has been cancelled."), -1);
display_main_menu();
return;
}
if (WCC->upload_length == 0) {
- strcpy(WC->ImportantMessage,
- _("You didn't upload a file."));
+ AppendImportantMessage(_("You didn't upload a file."), -1);
display_main_menu();
return;
}
MimeType = GuessMimeType(ChrPtr(WCC->upload), bytes_remaining);
- snprintf(buf, SIZ, "UIMG 1|%s|%s", MimeType, filename);
- serv_puts(buf);
+ serv_printf("UIMG 1|%s|%s", MimeType, filename);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- strcpy(WCC->ImportantMessage, &buf[4]);
+ Line = NewStrBuf();
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
display_main_menu();
+ FreeStrBuf(&Line);
return;
}
while (bytes_remaining) {
thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
serv_printf("WRIT %d", thisblock);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '7') {
- strcpy(WCC->ImportantMessage, &buf[4]);
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 1, 7) != 7) {
serv_puts("UCLS 0");
- serv_getln(buf, sizeof buf);
+ StrBuf_ServGetln(Line);
display_main_menu();
+ FreeStrBuf(&Line);
return;
}
thisblock = extract_int(&buf[4], 0);
}
serv_puts("UCLS 1");
- serv_getln(buf, sizeof buf);
- if (buf[0] != 'x') {
- display_success(&buf[4]);
- return;
+ StrBuf_ServGetln(Line);
+ if (*ChrPtr(Line) != 'x') {
+ display_success(ChrPtr(Line) + 4);
+
}
+ FreeStrBuf(&Line);
+
}
GetHash(WCC->InetCfg, CKEY(CfgNames[i]), &vHash);
Hash = (HashList*) vHash;
if (Hash == NULL) {
- sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+ AppendImportantMessage(_("Invalid Parameter"), -1);
url_do_template();
return;
}
*/
void display_shutdown(void)
{
- char buf[SIZ];
+ StrBuf *Line;
char *when;
+ Line = NewStrBuf();
when=bstr("when");
if (strcmp(when, "now") == 0){
serv_printf("DOWN 1");
- serv_getln(buf, sizeof buf);
- if (atol(buf) == 500)
- { /* upsie. maybe the server is not running as daemon? */
-
- safestrncpy(WC->ImportantMessage,
- &buf[4],
- sizeof WC->ImportantMessage);
- }
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 5);
+
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
DoTemplate(HKEY("aide_display_serverrestart"), NULL, &NoCtx);
else
{
serv_printf("SEXP broadcast|%s", message);
- serv_getln(buf, sizeof buf); /* TODO: should we care? */
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 0);
+
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
}
else if (!strcmp(when, "idle")) {
serv_printf("SCDN 3");
- serv_getln(buf, sizeof buf);
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 2);
- if (atol(buf) == 500)
- { /* upsie. maybe the server is not running as daemon? */
- safestrncpy(WC->ImportantMessage,
- &buf[4],
- sizeof WC->ImportantMessage);
- }
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
DoTemplate(HKEY("aide_display_menu"), NULL, &NoCtx);
end_burst();
}
+ FreeStrBuf(&Line);
}
void
}
if (!strcasecmp(bstr("submit_action"), "cancel")) {
- sprintf(WCC->ImportantMessage,
- _("Cancelled. Message was not posted."));
+ AppendImportantMessage(_("Cancelled. Message was not posted."), -1);
} else if (lbstr("postseq") == dont_post) {
- sprintf(WCC->ImportantMessage,
+ AppendImportantMessage(
_("Automatically cancelled because you have already "
- "saved this message."));
+ "saved this message."), -1);
} else {
const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
StrBuf *Recp = NULL;
}
+long FourHash(const char *key, long length)
+{
+ int i;
+ long ret = 0;
+ const unsigned char *ptr = (const unsigned char*)key;
+
+ for (i = 0; i < 4; i++, ptr ++)
+ ret = (ret << 8) |
+ ( ((*ptr >= 'a') &&
+ (*ptr <= 'z'))?
+ *ptr - 'a' + 'A':
+ *ptr);
+
+ return ret;
+}
+
+long l_subj;
+long l_wefw;
+long l_msgn;
+long l_from;
+long l_rcpt;
+long l_cccc;
+long l_node;
+long l_rfca;
+
/*
* display the message entry screen
*/
void display_enter(void)
{
- char buf[SIZ];
+ StrBuf *Line;
+ long Result;
+ int rc;
const StrBuf *display_name = NULL;
int recipient_required = 0;
int subject_required = 0;
}
/* First test to see whether this is a room that requires recipients to be entered */
+ Line = NewStrBuf();
serv_puts("ENT0 0");
- serv_getln(buf, sizeof buf);
+ StrBuf_ServGetln(Line);
+ rc = GetServerStatusMsg(Line, &Result, 0, 2);
- if (!strncmp(buf, "570", 3)) { /* 570 means that we need a recipient here */
+ if (Result == 570) { /* 570 means that we need a recipient here */
recipient_required = 1;
}
- else if (buf[0] != '2') { /* Any other error means that we cannot continue */
- sprintf(WCC->ImportantMessage, "%s", &buf[4]);
+ else if (rc != 2) { /* Any other error means that we cannot continue */
+ rc = GetServerStatusMsg(Line, &Result, 0, 2);
readloop(readnew, eUseDefault);
+ FreeStrBuf(&Line);
return;
}
/* Is the server strongly recommending that the user enter a message subject? */
- if ((buf[3] != '\0') && (buf[4] != '\0')) {
- subject_required = extract_int(&buf[4], 1);
+ if (StrLength(Line) > 4) {
+ subject_required = extract_int(ChrPtr(Line) + 4, 1);
}
/*
*/
if (WCC->CurRoom.defview == VIEW_ADDRESSBOOK) {
do_edit_vcard(-1, "", NULL, NULL, "", ChrPtr(WCC->CurRoom.name));
+ FreeStrBuf(&Line);
return;
}
*/
if (WCC->CurRoom.defview == VIEW_CALENDAR) {
display_edit_event();
+ FreeStrBuf(&Line);
return;
}
*/
if (WCC->CurRoom.defview == VIEW_TASKS) {
display_edit_task();
+ FreeStrBuf(&Line);
return;
}
*/
replying_to = lbstr("replying_to");
if (replying_to > 0) {
- char wefw[1024] = "";
- char msgn[256] = "";
- char from[256] = "";
- char node[256] = "";
- char rfca[256] = "";
- char rcpt[SIZ] = "";
- char cccc[SIZ] = "";
+ long len;
+ StrBuf *wefw = NULL;
+ StrBuf *msgn = NULL;
+ StrBuf *from = NULL;
+ StrBuf *node = NULL;
+ StrBuf *rfca = NULL;
+ StrBuf *rcpt = NULL;
+ StrBuf *cccc = NULL;
serv_printf("MSG0 %ld|1", replying_to);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-
- if ( (!strncasecmp(buf, "subj=", 5)) && (strlen(buf) > 5) ) {
- StrBuf *subj = NewStrBuf();
- if (!strcasecmp(bstr("replying_mode"), "forward")) {
- if (strncasecmp(&buf[5], "Fw:", 3)) {
- StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
+
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 0, 0) == 1)
+ while (len = StrBuf_ServGetln(Line),
+ (len >= 0) &&
+ ((len != 3) ||
+ strcmp(ChrPtr(Line), "000")))
+ {
+ long which = 0;
+ if ((StrLength(Line) > 4) &&
+ (ChrPtr(Line)[5] == '='))
+ which = FourHash(ChrPtr(Line), 4);
+
+ if (which == l_subj)
+ {
+ StrBuf *subj = NewStrBuf();
+ if (!strcasecmp(bstr("replying_mode"), "forward")) {
+ if (strncasecmp(ChrPtr(Line) + 5, "Fw:", 3)) {
+ StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
+ }
}
- }
- else {
- if (strncasecmp(&buf[5], "Re:", 3)) {
- StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+ else {
+ if (strncasecmp(ChrPtr(Line) + 5, "Re:", 3)) {
+ StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+ }
}
+ StrBufAppendBufPlain(subj,
+ ChrPtr(Line) + 5,
+ StrLength(Line) - 5, 0);
+ PutBstr(HKEY("subject"), subj);
}
- StrBufAppendBufPlain(subj, &buf[5], -1, 0);
- PutBstr(HKEY("subject"), subj);
- }
- else if (!strncasecmp(buf, "wefw=", 5)) {
- int rrtok;
- int rrlen;
- safestrncpy(wefw, &buf[5], sizeof wefw);
-
- /* Trim down excessively long lists of thread references. We eliminate the
- * second one in the list so that the thread root remains intact.
- */
- rrtok = num_tokens(wefw, '|');
- rrlen = strlen(wefw);
- if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
- remove_token(wefw, 1, '|');
+ else if (which == l_wefw)
+ {
+ int rrtok;
+ int rrlen;
+
+ wefw = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+
+ /* Trim down excessively long lists of thread references. We eliminate the
+ * second one in the list so that the thread root remains intact.
+ */
+ rrtok = num_tokens(ChrPtr(wefw), '|');
+ rrlen = StrLength(wefw);
+ if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
+ StrBufRemove_token(wefw, 1, '|');
+ }
}
- }
- else if (!strncasecmp(buf, "msgn=", 5)) {
- safestrncpy(msgn, &buf[5], sizeof msgn);
- }
-
- else if (!strncasecmp(buf, "from=", 5)) {
- safestrncpy(from, &buf[5], sizeof from);
- for (i=0; i<strlen(from); ++i) {
- if (from[i] == ',') from[i] = ' ';
+ else if (which == l_msgn) {
+ msgn = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
}
- }
-
- else if (!strncasecmp(buf, "rcpt=", 5)) {
- safestrncpy(rcpt, &buf[5], sizeof rcpt);
- }
-
- else if (!strncasecmp(buf, "cccc=", 5)) {
- safestrncpy(cccc, &buf[5], sizeof cccc);
- }
- else if (!strncasecmp(buf, "node=", 5)) {
- safestrncpy(node, &buf[5], sizeof node);
- }
-
- else if (!strncasecmp(buf, "rfca=", 5)) {
- safestrncpy(rfca, &buf[5], sizeof rfca);
+ else if (which == l_from) {
+ from = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ for (i=0; i<StrLength(from); ++i) {
+ if (ChrPtr(from)[i] == ',')
+ StrBufPeek(from, NULL, i, ' ');
+ }
+ }
+
+ else if (which == l_rcpt) {
+ rcpt = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ }
+
+ else if (which == l_cccc) {
+ cccc = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ }
+
+ else if (which == l_node) {
+ node = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ }
+
+ else if (which == l_rfca) {
+ rfca = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ }
}
- }
- if (strlen(wefw) + strlen(msgn) > 0) {
+ if (StrLength(wefw) + StrLength(msgn) > 0) {
StrBuf *refs = NewStrBuf();
- if (!IsEmptyStr(wefw)) {
- StrBufAppendBufPlain(refs, wefw, -1, 0);
+ if (StrLength(wefw) > 0) {
+ StrBufAppendBuf(refs, wefw, 0);
}
- if ( (!IsEmptyStr(wefw)) && (!IsEmptyStr(msgn)) ) {
+ if ( (StrLength(wefw) > 0) &&
+ (StrLength(msgn) > 0) )
+ {
StrBufAppendBufPlain(refs, HKEY("|"), 0);
}
- if (!IsEmptyStr(msgn)) {
- StrBufAppendBufPlain(refs, msgn, -1, 0);
+ if (StrLength(msgn) > 0) {
+ StrBufAppendBuf(refs, msgn, 0);
}
PutBstr(HKEY("references"), refs);
}
if ( (!strcasecmp(bstr("replying_mode"), "reply"))
|| (!strcasecmp(bstr("replying_mode"), "replyall"))
) {
- StrBuf *to_rcpt = NewStrBuf();
- if (!IsEmptyStr(rfca)) {
- StrBufAppendPrintf(to_rcpt, "%s <%s>", from, rfca);
+ StrBuf *to_rcpt;
+ if (StrLength(rfca) > 0) {
+ to_rcpt = NewStrBuf();
+ StrBufAppendBuf(to_rcpt, from, 0);
+ StrBufAppendBufPlain(to_rcpt, HKEY(" <"), 0);
+ StrBufAppendBuf(to_rcpt, rfca, 0);
+ StrBufAppendBufPlain(to_rcpt, HKEY(">"), 0);
}
else {
- StrBufAppendPrintf(to_rcpt, "%s", from);
- if ( (!IsEmptyStr(node))
- && (strcasecmp(node, ChrPtr(WC->serv_info->serv_nodename)))
+ to_rcpt = from;
+ from = NULL;
+ if ( (StrLength(node) > 0)
+ && (strcasecmp(ChrPtr(node), ChrPtr(WC->serv_info->serv_nodename)))
) {
- StrBufAppendPrintf(to_rcpt, " @ %s", node);
+ StrBufAppendBufPlain(to_rcpt, HKEY(" @ "), 0);
+ StrBufAppendBuf(to_rcpt, node, 0);
}
}
PutBstr(HKEY("recp"), to_rcpt);
*/
if ( (!strcasecmp(bstr("replying_mode"), "replyall"))
) {
- StrBuf *cc_rcpt = NewStrBuf();
- if (!IsEmptyStr(rcpt)) {
- StrBufAppendPrintf(cc_rcpt, "%s", rcpt);
- }
- if ( (!IsEmptyStr(rcpt)) && (!IsEmptyStr(cccc)) ) {
- StrBufAppendPrintf(cc_rcpt, ", ");
- }
- if (!IsEmptyStr(cccc)) {
- StrBufAppendPrintf(cc_rcpt, "%s", cccc);
+ StrBuf *cc_rcpt = rcpt;
+ rcpt = NULL;
+ if (StrLength(cccc) > 0) {
+ if (cc_rcpt != NULL) {
+ StrBufAppendPrintf(cc_rcpt, ", ");
+ StrBufAppendBuf(cc_rcpt, cccc, 0);
+ } else {
+ cc_rcpt = cccc;
+ cccc = NULL;
+ }
}
- PutBstr(HKEY("cc"), cc_rcpt);
+ if (cc_rcpt != NULL)
+ PutBstr(HKEY("cc"), cc_rcpt);
}
-
- }
-
+ FreeStrBuf(&wefw);
+ FreeStrBuf(&msgn);
+ FreeStrBuf(&from);
+ FreeStrBuf(&node);
+ FreeStrBuf(&rfca);
+ FreeStrBuf(&rcpt);
+ FreeStrBuf(&cccc);
+ }
+ FreeStrBuf(&Line);
/*
* Otherwise proceed normally.
* Do a custom room banner with no navbar...
ChrPtr(Bcc),
ChrPtr(Wikipage));
serv_puts(ChrPtr(CmdBuf));
- serv_getln(buf, sizeof buf);
- FreeStrBuf(&CmdBuf);
+ StrBuf_ServGetln(CmdBuf);
+
+ rc = GetServerStatusMsg(CmdBuf, &Result, 0, 0);
- if (!strncmp(buf, "570", 3)) { /* 570 means we have an invalid recipient listed */
+ if (Result == 570) { /* 570 means we have an invalid recipient listed */
if (havebstr("recp") &&
havebstr("cc" ) &&
havebstr("bcc" )) {
recipient_bad = 1; /* TODO: and now????? */
}
}
- else if (buf[0] != '2') { /* Any other error means that we cannot continue */
- wc_printf("<em>%s</em><br>\n", &buf[4]); /* TODO -> important message */
+ else if (rc != 2) { /* Any other error means that we cannot continue */
+ wc_printf("<em>%s</em><br>\n", ChrPtr(CmdBuf) +4); /* TODO -> important message */
+ FreeStrBuf(&CmdBuf);
return;
}
+ FreeStrBuf(&CmdBuf);
}
if (recipient_required)
PutBstr(HKEY("__RCPTREQUIRED"), NewStrBufPlain(HKEY("1")));
void delete_msg(void)
{
long msgid;
- char buf[SIZ];
-
+ StrBuf *Line;
+
msgid = lbstr("msgid");
-
+ Line = NewStrBuf();
if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
serv_printf("DELE %ld", msgid);
}
serv_printf("MOVE %ld|_TRASH_|0", msgid);
}
- serv_getln(buf, sizeof buf);
- sprintf(WC->ImportantMessage, "%s", &buf[4]);
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 0);
+
readloop(readnew, eUseDefault);
}
void move_msg(void)
{
long msgid;
- char buf[SIZ];
msgid = lbstr("msgid");
if (havebstr("move_button")) {
- sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
- serv_puts(buf);
- serv_getln(buf, sizeof buf);
- sprintf(WC->ImportantMessage, "%s", &buf[4]);
+ StrBuf *Line;
+ serv_printf("MOVE %ld|%s", msgid, bstr("target_room"));
+ Line = NewStrBuf();
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 0);
+ FreeStrBuf(&Line);
} else {
- sprintf(WC->ImportantMessage, (_("The message was not moved.")));
+ AppendImportantMessage(_("The message was not moved."), -1);
}
readloop(readnew, eUseDefault);
/* json */
WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
+
+ l_subj = FourHash("subj", 4);
+ l_wefw = FourHash("wefw", 4);
+ l_msgn = FourHash("msgn", 4);
+ l_from = FourHash("from", 4);
+ l_rcpt = FourHash("rcpt", 4);
+ l_cccc = FourHash("cccc", 4);
+ l_node = FourHash("node", 4);
+ l_rfca = FourHash("rfca", 4);
+
return ;
}
Index = sbstr("index");
NewNode = HttpGetNewNode();
if ((NewNode == NULL) || (Index == NULL)) {
- sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+ AppendImportantMessage(_("Invalid Parameter"), -1);
url_do_template();
return;
}
Index = sbstr("index");
if (Index == NULL) {
- sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+ AppendImportantMessage(_("Invalid Parameter"), -1);
url_do_template();
return;
}
NodeConfig = load_netconf(NULL, &NoCtx);
if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) ||
(vNode == NULL)) {
- sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+ AppendImportantMessage(_("Invalid Parameter"), -1);
url_do_template();
DeleteHash(&NodeConfig);
return;
Index = sbstr("index");
if (Index == NULL) {
- sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+ AppendImportantMessage(_("Invalid Parameter"), -1);
url_do_template();
return;
}
NodeConfig = load_netconf(NULL, &NoCtx);
if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) ||
(vNode == NULL)) {
- sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+ AppendImportantMessage(_("Invalid Parameter"), -1);
url_do_template();
DeleteHash(&NodeConfig);
return;
* Detach an OpenID from the currently logged-in account
*/
void openid_detach(void) {
- char buf[1024];
+ StrBuf *Line;
if (havebstr("id_to_detach")) {
serv_printf("OIDD %s", bstr("id_to_detach"));
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
- }
+ Line = NewStrBuf();
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 2);
+ FreeStrBuf(&Line);
}
display_openids();
void page_user(void)
{
char recp[256];
- char buf[256];
+ StrBuf *Line;
safestrncpy(recp, bstr("recp"), sizeof recp);
if (!havebstr("send_button")) {
- safestrncpy(WC->ImportantMessage,
- _("Message was not sent."),
- sizeof WC->ImportantMessage
- );
+ AppendImportantMessage(_("Message was not sent."), -1);
} else {
+ Line = NewStrBuf();
serv_printf("SEXP %s|-", recp);
- serv_getln(buf, sizeof buf);
-
- if (buf[0] == '4') {
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 0, 0) == 4) {
+ char buf[256];
text_to_server(bstr("msgtext"));
serv_puts("000");
stresc(buf, 256, recp, 0, 0);
- snprintf(WC->ImportantMessage,
- sizeof WC->ImportantMessage,
- "%s%s.",
- _("Message has been sent to "),
- buf
- );
- }
- else {
- safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
+ AppendImportantMessage(buf, -1);
+ AppendImportantMessage(_("Message has been sent to "), -1);
}
}
void set_preferences(void)
{
if (!havebstr("change_button")) {
- safestrncpy(WC->ImportantMessage,
- _("Cancelled. No settings were changed."),
- sizeof WC->ImportantMessage);
+ AppendImportantMessage(_("Cancelled. No settings were changed."), -1);
display_main_menu();
return;
}
*/
void delete_room(void)
{
- char buf[SIZ];
-
+ StrBuf *Line;
serv_puts("KILL 1");
- serv_getln(buf, sizeof buf);
-
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
display_main_menu();
- return;
} else {
StrBuf *Buf;
smart_goto(Buf);
FreeStrBuf(&Buf);
}
+ FreeStrBuf(&Line);
}
/*
int succ1, succ2;
if (!havebstr("ok_button")) {
- strcpy(WC->ImportantMessage,
- _("Cancelled. Changes were not saved."));
+ AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
return;
}
*/
void entroom(void)
{
- char buf[SIZ];
+ StrBuf *Line;
const StrBuf *er_name;
const StrBuf *er_type;
const StrBuf *er_password;
wcsession *WCC = WC;
if (!havebstr("ok_button")) {
- strcpy(WC->ImportantMessage,
- _("Cancelled. No new room was created."));
+ AppendImportantMessage(_("Cancelled. No new room was created."), -1);
display_main_menu();
return;
}
0,
er_view);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- strcpy(WCC->ImportantMessage, &buf[4]);
+ Line = NewStrBuf();
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
+ FreeStrBuf(&Line);
display_main_menu();
return;
}
gotoroom(er_name);
serv_printf("VIEW %d", er_view);
- serv_getln(buf, sizeof buf);
+ StrBuf_ServGetln(Line);
+ FreeStrBuf(&Line); /* TODO: should we care about errors? */
WCC->CurRoom.view = er_view;
if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
} else {
smart_goto(WCC->CurRoom.name);
}
-
+ FreeStrBuf(&Line);
}
* Set the message expire policy for this room and/or floor
*/
void set_room_policy(void) {
- char buf[SIZ];
+ StrBuf *Line;
if (!havebstr("ok_button")) {
- strcpy(WC->ImportantMessage,
- _("Cancelled. Changes were not saved."));
+ AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
return;
}
+ Line = NewStrBuf();
serv_printf("SPEX roompolicy|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
- serv_getln(buf, sizeof buf);
- strcpy(WC->ImportantMessage, &buf[4]);
-
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 0);
if (WC->axlevel >= 6) {
- strcat(WC->ImportantMessage, "<br>\n");
serv_printf("SPEX floorpolicy|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
- serv_getln(buf, sizeof buf);
- strcat(WC->ImportantMessage, &buf[4]);
+ StrBuf_ServGetln(Line);
+ GetServerStatusMsg(Line, NULL, 1, 0);
}
+ FreeStrBuf(&Line);
ReloadCurrentRoom();
http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
}
char buf[256];
if (!havebstr("save_button")) {
- strcpy(WC->ImportantMessage,
- _("Cancelled. Changes were not saved."));
+ AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
display_main_menu();
return;
}
}
}
- strcpy(WC->ImportantMessage, _("Your changes have been saved."));
+ AppendImportantMessage(_("Your changes have been saved."), -1);
display_main_menu();
return;
}
{
wcsession *WCC = WC;
int i;
- char buf[256];
+ StrBuf *Line;
if (strlen(bstr("ok_button")) == 0) {
display_aide_menu();
return;
}
+ Line = NewStrBuf();
serv_printf("CONF set");
- serv_getln(buf, sizeof buf);
- if (buf[0] != '4') {
- safestrncpy(WCC->ImportantMessage, &buf[4], sizeof WCC->ImportantMessage);
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 1, 4) != 4) {
display_aide_menu();
+ FreeStrBuf(&Line);
return;
}
+ FreeStrBuf(&Line);
+
for (i=0; i < (sizeof(ServerConfig) / sizeof(CfgMapping)); i ++)
{
switch (ServerConfig[i].type) {
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);
+ AppendImportantMessage(_("Your system configuration has been updated."), -1);
DeleteHash(&WCC->ServCfg);
display_aide_menu();
}
void display_edit(char *description, char *check_cmd,
char *read_cmd, char *save_cmd, int with_room_banner)
{
- char buf[SIZ];
+ StrBuf *Line;
serv_puts(check_cmd);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
+ FreeStrBuf(&Line);
display_main_menu();
return;
}
wc_printf("<textarea name=\"msgtext\" wrap=soft "
"rows=10 cols=80 width=80>\n");
serv_puts(read_cmd);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1')
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 0, 0) == 1)
server_to_text();
wc_printf("</textarea><div class=\"buttons\" >\n");
wc_printf("<input type=\"submit\" name=\"save_button\" value=\"%s\">", _("Save changes"));
do_template("box_end");
wDumpContent(1);
+ FreeStrBuf(&Line);
}
*/
void save_edit(char *description, char *enter_cmd, int regoto)
{
- char buf[SIZ];
+ StrBuf *Line;
if (!havebstr("save_button")) {
- sprintf(WC->ImportantMessage,
- _("Cancelled. %s was not saved."),
- description);
+ AppendImportantMessage(_("Cancelled. %s was not saved."), -1);
display_main_menu();
return;
}
+ Line = NewStrBuf();
serv_puts(enter_cmd);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '4') {
- safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
+ StrBuf_ServGetln(Line);
+ if (GetServerStatusMsg(Line, NULL, 1, 0) != 4) {
+ FreeStrBuf(&Line);
display_main_menu();
return;
}
+ FreeStrBuf(&Line);
text_to_server(bstr("msgtext"));
serv_puts("000");
if (regoto) {
smart_goto(WC->CurRoom.name);
} else {
- sprintf(WC->ImportantMessage,
- _("%s has been saved."),
- description);
+ AppendImportantMessage(description, -1);
+ AppendImportantMessage(_(" has been saved."), -1);
display_main_menu();
return;
}
serv_printf("CREU %s", username);
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, &FullState) == 2) {
- sprintf(WC->ImportantMessage, _("A new user has been created."));
+ AppendImportantMessage(_("A new user has been created."), -1);
display_edituser(username, 1);
}
else if (FullState == 570) {
v = VCardLoad(Buf); /* Start with the extra fields */
FreeStrBuf(&Buf);
if (v == NULL) {
- safestrncpy(WCC->ImportantMessage,
- _("An error has occurred."),
- sizeof WCC->ImportantMessage
- );
+ AppendImportantMessage(_("An error has occurred."), -1);
edit_vcard();
return;
}
serialized_vcard = vcard_serialize(v);
vcard_free(v);
if (serialized_vcard == NULL) {
- safestrncpy(WCC->ImportantMessage,
- _("An error has occurred."),
- sizeof WCC->ImportantMessage
- );
+ AppendImportantMessage(_("An error has occurred."), -1);
edit_vcard();
return;
}
do_template("head");
/* check for ImportantMessages (these display in a div overlaying the main screen) */
- if (!IsEmptyStr(WCC->ImportantMessage)) {
- wc_printf("<div id=\"important_message\">\n"
- "<span class=\"imsg\">");
- StrEscAppend(WCC->WBuf, NULL, WCC->ImportantMessage, 0, 0);
- wc_printf("</span><br>\n"
- "</div>\n"
- );
- StrBufAppendBufPlain(WCC->trailing_javascript,
- HKEY("setTimeout('hide_imsg_popup()', 5000); \n"),
- 0
- );
- WCC->ImportantMessage[0] = 0;
- }
- else if (StrLength(WCC->ImportantMsg) > 0) {
+ if (StrLength(WCC->ImportantMsg) > 0) {
wc_printf("<div id=\"important_message\">\n"
"<span class=\"imsg\">");
StrEscAppend(WCC->WBuf, WCC->ImportantMsg, NULL, 0, 0);
/*
* convenience function to indicate success
*/
-void display_success(char *successmessage)
+void display_success(const char *successmessage)
{
convenience_page("007700", "OK", successmessage);
}
if (WCC->ImportantMsg != NULL)
message = ChrPtr(WCC->ImportantMsg);
- else if (WCC->ImportantMessage != NULL)
- message = WCC->ImportantMessage;
wc_printf(_("The resource you requested requires a valid username and password. "
"You could not be logged in: %s\n"), message);
{
wcsession *WCC = WC;
if (WCC != NULL)
- return ((!IsEmptyStr(WCC->ImportantMessage)) ||
- (StrLength(WCC->ImportantMsg) > 0));
+ return (StrLength(WCC->ImportantMsg) > 0);
else
return 0;
}
wcsession *WCC = WC;
if (WCC != NULL) {
- if (!IsEmptyStr(WCC->ImportantMessage)) {
- StrEscAppend(Target, NULL, WCC->ImportantMessage, 0, 0);
- WCC->ImportantMessage[0] = '\0';
- }
- else if (StrLength(WCC->ImportantMsg) > 0) {
+ if (StrLength(WCC->ImportantMsg) > 0) {
StrEscAppend(Target, WCC->ImportantMsg, NULL, 0, 0);
FlushStrBuf(WCC->ImportantMsg);
}
StrBuf *WFBuf; /* Wildfire error logging buffer */
StrBuf *trailing_javascript; /* extra javascript to be appended to page */
- char ImportantMessage[SIZ];
+/* char ImportantMessage[SIZ];*/
StrBuf *ImportantMsg;
HashList *Directory; /* Parts of the directory URL in snippets */
const Floor *CurrentFloor; /* when Parsing REST, which floor are we on? */
void display_vcard(StrBuf *Target, wc_mime_attachment *Mime, char alpha, int full, char **storename, long msgnum);
-void display_success(char *);
+void display_success(const char *successmessage);
void shutdown_sessions(void);