4 * Functions which deal with the fetching and displaying of messages.
10 #include "webserver.h"
13 /* Address book entry (keep it short and sweet, it's just a quickie lookup
14 * which we can use to get to the real meat and bones later)
24 /* Handle subjects with RFC2047 encoding, such as:
25 * =?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=
27 void utf8ify_rfc822_string(char *buf) {
33 iconv_t ic = (iconv_t)(-1) ;
34 char *ibuf; /* Buffer of characters to be converted */
35 char *obuf; /* Buffer for converted characters */
36 size_t ibuflen; /* Length of input buffer */
37 size_t obuflen; /* Length of output buffer */
38 char *isav; /* Saved pointer to input buffer */
39 char *osav; /* Saved pointer to output buffer */
41 while (start=strstr(buf, "=?"), end=strstr(buf, "?="),
42 ((start != NULL) && (end != NULL) && (end > start)) )
44 extract_token(charset, start, 1, '?', sizeof charset);
45 extract_token(encoding, start, 2, '?', sizeof encoding);
46 extract_token(istr, start, 3, '?', sizeof istr);
54 if (!strcasecmp(encoding, "B")) { /* base64 */
55 ibuflen = CtdlDecodeBase64(ibuf, istr, strlen(istr));
57 else if (!strcasecmp(encoding, "Q")) { /* quoted-printable */
58 ibuflen = CtdlDecodeQuotedPrintable(ibuf, istr, strlen(istr));
61 strcpy(ibuf, istr); /* huh? */
62 ibuflen = strlen(istr);
65 ic = iconv_open("UTF-8", charset);
66 if (ic != (iconv_t)(-1) ) {
69 obuf = (char *) malloc(obuflen);
71 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
72 osav[1024-obuflen] = 0;
77 remove_token(end, 0, '?');
78 remove_token(end, 0, '?');
79 remove_token(end, 0, '?');
80 remove_token(end, 0, '?');
83 snprintf(newbuf, sizeof newbuf, "%s%s%s", buf, osav, end);
89 snprintf(newbuf, sizeof newbuf, "%s(unreadable)%s", buf, end);
101 * Look for URL's embedded in a buffer and make them linkable. We use a
102 * target window in order to keep the BBS session in its own window.
118 for (pos = 0; pos < strlen(buf); ++pos) {
119 if (!strncasecmp(&buf[pos], "http://", 7))
121 if (!strncasecmp(&buf[pos], "ftp://", 6))
128 if ((start > 0) && (buf[start - 1] == '<'))
130 if ((start > 0) && (buf[start - 1] == '['))
132 if ((start > 0) && (buf[start - 1] == '('))
134 if ((start > 0) && (buf[start - 1] == '{'))
137 for (pos = strlen(buf); pos > start; --pos) {
138 if ((buf[pos] == ' ') || (buf[pos] == ench))
142 strncpy(urlbuf, &buf[start], end - start);
143 urlbuf[end - start] = 0;
145 strncpy(outbuf, buf, start);
146 sprintf(&outbuf[start], "%cA HREF=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
147 LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
148 strcat(outbuf, &buf[end]);
149 if ( strlen(outbuf) < 250 )
155 * Turn a vCard "n" (name) field into something displayable.
157 void vcard_n_prettyize(char *name)
162 original_name = strdup(name);
163 for (i=0; i<5; ++i) {
164 if (strlen(original_name) > 0) {
165 if (original_name[strlen(original_name)-1] == ' ') {
166 original_name[strlen(original_name)-1] = 0;
168 if (original_name[strlen(original_name)-1] == ';') {
169 original_name[strlen(original_name)-1] = 0;
174 for (i=0; i<strlen(original_name); ++i) {
175 if (original_name[i] == ';') {
179 name[strlen(name)+1] = 0;
180 name[strlen(name)] = original_name[i];
189 /* display_vcard() calls this after parsing the textual vCard into
190 * our 'struct vCard' data object.
191 * This gets called instead of display_parsed_vcard() if we are only looking
192 * to extract the person's name instead of displaying the card.
194 void fetchname_parsed_vcard(struct vCard *v, char *storename) {
197 strcpy(storename, "");
199 name = vcard_get_prop(v, "n", 1, 0, 0);
201 strcpy(storename, name);
202 /* vcard_n_prettyize(storename); */
209 /* display_vcard() calls this after parsing the textual vCard into
210 * our 'struct vCard' data object.
212 * Set 'full' to nonzero to display the full card, otherwise it will only
213 * show a summary line.
215 * This code is a bit ugly, so perhaps an explanation is due: we do this
216 * in two passes through the vCard fields. On the first pass, we process
217 * fields we understand, and then render them in a pretty fashion at the
218 * end. Then we make a second pass, outputting all the fields we don't
219 * understand in a simple two-column name/value format.
221 void display_parsed_vcard(struct vCard *v, int full) {
227 char *thisname, *thisvalue;
228 char firsttoken[SIZ];
231 char displayname[SIZ];
237 strcpy(displayname, "");
245 name = vcard_get_prop(v, "fn", 1, 0, 0);
249 else if (name = vcard_get_prop(v, "n", 1, 0, 0), name != NULL) {
250 strcpy(displayname, name);
251 vcard_n_prettyize(displayname);
252 escputs(displayname);
261 wprintf("<div align=center><table bgcolor=#aaaaaa width=50%%>");
262 for (pass=1; pass<=2; ++pass) {
264 if (v->numprops) for (i=0; i<(v->numprops); ++i) {
266 thisname = strdup(v->prop[i].name);
267 extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken);
269 for (j=0; j<num_tokens(thisname, ';'); ++j) {
270 extract_token(buf, thisname, j, ';', sizeof buf);
271 if (!strcasecmp(buf, "encoding=quoted-printable")) {
273 remove_token(thisname, j, ';');
275 if (!strcasecmp(buf, "encoding=base64")) {
277 remove_token(thisname, j, ';');
282 thisvalue = malloc(strlen(v->prop[i].value) + 50);
283 j = CtdlDecodeQuotedPrintable(
284 thisvalue, v->prop[i].value,
285 strlen(v->prop[i].value) );
289 thisvalue = malloc(strlen(v->prop[i].value) + 50);
291 thisvalue, v->prop[i].value,
292 strlen(v->prop[i].value) );
295 thisvalue = strdup(v->prop[i].value);
298 /*** Various fields we may encounter ***/
300 /* N is name, but only if there's no FN already there */
301 if (!strcasecmp(firsttoken, "n")) {
302 if (strlen(displayname) == 0) {
303 strcpy(displayname, thisvalue);
304 vcard_n_prettyize(displayname);
308 /* FN (full name) is a true 'display name' field */
309 else if (!strcasecmp(firsttoken, "fn")) {
310 strcpy(displayname, thisvalue);
314 else if (!strcasecmp(firsttoken, "title")) {
315 strcpy(title, thisvalue);
319 else if (!strcasecmp(firsttoken, "org")) {
320 strcpy(org, thisvalue);
323 else if (!strcasecmp(firsttoken, "email")) {
324 if (strlen(mailto) > 0) strcat(mailto, "<br />");
326 "<A HREF=\"/display_enter"
327 "?force_room=_MAIL_?recp=");
328 urlesc(&mailto[strlen(mailto)], thisvalue);
329 strcat(mailto, "\">");
330 urlesc(&mailto[strlen(mailto)], thisvalue);
331 strcat(mailto, "</A>");
333 else if (!strcasecmp(firsttoken, "tel")) {
334 if (strlen(phone) > 0) strcat(phone, "<br />");
335 strcat(phone, thisvalue);
336 for (j=0; j<num_tokens(thisname, ';'); ++j) {
337 extract_token(buf, thisname, j, ';', sizeof buf);
338 if (!strcasecmp(buf, "tel"))
340 else if (!strcasecmp(buf, "work"))
341 strcat(phone, _(" (work)"));
342 else if (!strcasecmp(buf, "home"))
343 strcat(phone, _(" (home)"));
344 else if (!strcasecmp(buf, "cell"))
345 strcat(phone, _(" (cell)"));
353 else if (!strcasecmp(firsttoken, "adr")) {
356 wprintf(_("Address:"));
357 wprintf("</TD><TD>");
358 for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
359 extract_token(buf, thisvalue, j, ';', sizeof buf);
360 if (strlen(buf) > 0) {
362 if (j<3) wprintf("<br />");
366 wprintf("</TD></TR>\n");
369 else if (!strcasecmp(firsttoken, "version")) {
372 else if (!strcasecmp(firsttoken, "rev")) {
375 else if (!strcasecmp(firsttoken, "label")) {
380 /*** Don't show extra fields. They're ugly.
384 wprintf("</TD><TD>");
386 wprintf("</TD></TR>\n");
396 wprintf("<TR BGCOLOR=\"#AAAAAA\">"
397 "<TD COLSPAN=2 BGCOLOR=\"#FFFFFF\">"
398 "<IMG ALIGN=CENTER SRC=\"/static/viewcontacts_48x.gif\">"
399 "<FONT SIZE=+1><B>");
400 escputs(displayname);
401 wprintf("</B></FONT>");
402 if (strlen(title) > 0) {
403 wprintf("<div align=right>");
407 if (strlen(org) > 0) {
408 wprintf("<div align=right>");
412 wprintf("</TD></TR>\n");
414 if (strlen(phone) > 0)
416 wprintf(_("Telephone:"));
417 wprintf("</TD><TD>%s</TD></TR>\n", phone);
418 if (strlen(mailto) > 0)
420 wprintf(_("E-mail:"));
421 wprintf("</TD><TD>%s</TD></TR>\n", mailto);
426 wprintf("</table></div>\n");
432 * Display a textual vCard
433 * (Converts to a vCard object and then calls the actual display function)
434 * Set 'full' to nonzero to display the whole card instead of a one-liner.
435 * Or, if "storename" is non-NULL, just store the person's name in that
436 * buffer instead of displaying the card at all.
438 void display_vcard(char *vcard_source, char alpha, int full, char *storename) {
444 v = vcard_load(vcard_source);
445 if (v == NULL) return;
447 name = vcard_get_prop(v, "n", 1, 0, 0);
453 if (storename != NULL) {
454 fetchname_parsed_vcard(v, storename);
456 else if ( (alpha == 0)
457 || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) )
458 || ((!isalpha(alpha)) && (!isalpha(this_alpha)))
460 display_parsed_vcard(v, full);
468 * I wanna SEE that message!
470 void read_message(long msgnum, int suppress_buttons) {
472 char mime_partnum[256];
473 char mime_filename[256];
474 char mime_content_type[256];
475 char mime_charset[256];
476 char mime_disposition[256];
489 char vcard_partnum[256];
490 char cal_partnum[256];
491 char *part_source = NULL;
493 iconv_t ic = (iconv_t)(-1) ;
494 char *ibuf; /* Buffer of characters to be converted */
495 char *obuf; /* Buffer for converted characters */
496 size_t ibuflen; /* Length of input buffer */
497 size_t obuflen; /* Length of output buffer */
498 char *osav; /* Saved pointer to output buffer */
504 strcpy(reply_to, "");
505 strcpy(vcard_partnum, "");
506 strcpy(cal_partnum, "");
507 strcpy(mime_http, "");
508 strcpy(mime_content_type, "text/plain");
509 strcpy(mime_charset, "us-ascii");
511 serv_printf("MSG4 %ld", msgnum);
512 serv_getln(buf, sizeof buf);
515 wprintf(_("ERROR:"));
516 wprintf("</STRONG> %s<br />\n", &buf[4]);
520 /* begin everythingamundo table */
521 wprintf("<div id=\"fix_scrollbar_bug\">\n");
522 wprintf("<table width=100%% border=1 cellspacing=0 "
523 "cellpadding=0><TR><TD>\n");
525 /* begin message header table */
526 wprintf("<TABLE WIDTH=100%% BORDER=0 CELLSPACING=0 "
527 "CELLPADDING=1 BGCOLOR=\"#CCCCCC\"><TR><TD>\n");
529 wprintf("<SPAN CLASS=\"message_header\">");
530 strcpy(m_subject, "");
532 while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
533 if (!strcmp(buf, "000")) {
535 wprintf(_("unexpected end of message"));
536 wprintf("</I><br /><br />\n");
537 wprintf("</SPAN>\n");
540 if (!strncasecmp(buf, "nhdr=yes", 8))
544 if (!strncasecmp(buf, "type=", 5))
545 format_type = atoi(&buf[5]);
546 if (!strncasecmp(buf, "from=", 5)) {
547 strcpy(from, &buf[5]);
549 wprintf("<A HREF=\"/showuser?who=");
551 utf8ify_rfc822_string(from);
558 if (!strncasecmp(buf, "subj=", 5)) {
559 strcpy(m_subject, &buf[5]);
561 if ((!strncasecmp(buf, "hnod=", 5))
562 && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
563 wprintf("(%s) ", &buf[5]);
565 if ((!strncasecmp(buf, "room=", 5))
566 && (strcasecmp(&buf[5], WC->wc_roomname))
567 && (strlen(&buf[5])>0) ) {
569 wprintf("%s> ", &buf[5]);
571 if (!strncasecmp(buf, "rfca=", 5)) {
572 strcpy(rfca, &buf[5]);
578 if (!strncasecmp(buf, "node=", 5)) {
579 strcpy(node, &buf[5]);
580 if ( ((WC->room_flags & QR_NETWORK)
581 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
582 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
585 wprintf("@%s ", &buf[5]);
588 if (!strncasecmp(buf, "rcpt=", 5)) {
590 wprintf("%s ", &buf[5]);
592 if (!strncasecmp(buf, "time=", 5)) {
593 fmt_date(now, atol(&buf[5]), 0);
597 if (!strncasecmp(buf, "part=", 5)) {
598 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
599 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
600 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
601 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
602 mime_length = extract_int(&buf[5], 5);
604 if (!strcasecmp(mime_disposition, "attachment")) {
605 snprintf(&mime_http[strlen(mime_http)],
606 (sizeof(mime_http) - strlen(mime_http) - 1),
607 "<A HREF=\"/output_mimepart?"
608 "msgnum=%ld?partnum=%s\" "
609 "TARGET=\"wc.%ld.%s\">"
610 "<IMG SRC=\"/static/diskette_24x.gif\" "
611 "BORDER=0 ALIGN=MIDDLE>\n"
612 "Part %s: %s (%s, %d bytes)</A><br />\n",
613 msgnum, mime_partnum,
614 msgnum, mime_partnum,
615 mime_partnum, mime_filename,
616 mime_content_type, mime_length);
619 if ((!strcasecmp(mime_disposition, "inline"))
620 && (!strncasecmp(mime_content_type, "image/", 6)) ){
621 snprintf(&mime_http[strlen(mime_http)],
622 (sizeof(mime_http) - strlen(mime_http) - 1),
623 "<IMG SRC=\"/output_mimepart?"
624 "msgnum=%ld?partnum=%s\">",
625 msgnum, mime_partnum);
628 /*** begin handler prep ***/
629 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
630 strcpy(vcard_partnum, mime_partnum);
633 if (!strcasecmp(mime_content_type, "text/calendar")) {
634 strcpy(cal_partnum, mime_partnum);
637 /*** end handler prep ***/
643 /* Generate a reply-to address */
644 if (strlen(rfca) > 0) {
645 strcpy(reply_to, rfca);
648 if ( (strlen(node) > 0)
649 && (strcasecmp(node, serv_info.serv_nodename))
650 && (strcasecmp(node, serv_info.serv_humannode)) ) {
651 snprintf(reply_to, sizeof(reply_to), "%s @ %s",
655 snprintf(reply_to, sizeof(reply_to), "%s", from);
665 utf8ify_rfc822_string(m_subject);
667 if (strlen(m_subject) > 0) {
669 "<SPAN CLASS=\"message_subject\">");
670 wprintf(_("Subject:"));
671 wprintf(" %s</SPAN>", m_subject
676 /* start msg buttons */
677 if (!suppress_buttons) {
678 wprintf("<td align=right>\n");
681 wprintf("<a href=\"/display_enter?recp=");
682 urlescputs(reply_to);
683 wprintf("?subject=");
684 if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
685 urlescputs(m_subject);
686 wprintf("\">[%s]</a> ", _("Reply"));
689 if (WC->wc_view == VIEW_MAILBOX) {
690 wprintf("<a href=\"/display_enter?pullquote=%ld?subject=", msgnum);
691 if (strncasecmp(m_subject, "Fwd:", 4)) wprintf("Fwd:%20");
692 urlescputs(m_subject);
693 wprintf("\">[%s]</a> ", _("Forward"));
696 if (WC->is_room_aide) {
698 wprintf("<a href=\"/confirm_move_msg?msgid=%ld\">[%s]</a> ",
702 wprintf("<a href=\"/delete_msg?msgid=%ld\" "
703 "onClick=\"return confirm('%s');\">"
704 "[%s]</a> ", msgnum, _("Delete this message?"), _("Delete")
708 wprintf("<a href=\"/msg?msgnum=%ld?sourceiframe=msgloader1?print_it=yes\" target=\"msgloader1\">"
709 "[%s]</a>", msgnum, _("Print"));
714 wprintf("</TR></TABLE>\n");
717 wprintf("<TABLE BORDER=0 WIDTH=100%% BGCOLOR=#FFFFFF "
718 "CELLPADDING=1 CELLSPACING=0><TR><TD>");
721 * Learn the content type
723 strcpy(mime_content_type, "text/plain");
724 while (serv_getln(buf, sizeof buf), (strlen(buf) > 0)) {
725 if (!strcmp(buf, "000")) {
727 wprintf(_("unexpected end of message"));
728 wprintf("</I><br /><br />\n");
731 if (!strncasecmp(buf, "Content-type: ", 14)) {
732 safestrncpy(mime_content_type, &buf[14],
733 sizeof(mime_content_type));
734 for (i=0; i<strlen(mime_content_type); ++i) {
735 if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
736 safestrncpy(mime_charset, &mime_content_type[i+8],
737 sizeof mime_charset);
740 for (i=0; i<strlen(mime_content_type); ++i) {
741 if (mime_content_type[i] == ';') {
742 mime_content_type[i] = 0;
748 /* Set up a character set conversion if we need to (and if we can) */
750 if ( (strcasecmp(mime_charset, "us-ascii"))
751 && (strcasecmp(mime_charset, "UTF-8")) ) {
752 ic = iconv_open("UTF-8", mime_charset);
753 if (ic == (iconv_t)(-1) ) {
754 lprintf(5, "iconv_open() failed: %s\n", strerror(errno));
759 /* Messages in legacy Citadel variformat get handled thusly... */
760 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
764 /* Boring old 80-column fixed format text gets handled this way... */
765 else if ( (!strcasecmp(mime_content_type, "text/plain"))
766 || (!strcasecmp(mime_content_type, "text")) ) {
767 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
768 if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
769 if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = 0;
772 if (ic != (iconv_t)(-1) ) {
774 ibuflen = strlen(ibuf);
776 obuf = (char *) malloc(obuflen);
778 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
779 osav[SIZ-obuflen] = 0;
780 safestrncpy(buf, osav, sizeof buf);
785 while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
786 buf[strlen(buf) - 1] = 0;
788 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
789 wprintf("<BLOCKQUOTE>");
791 } else if ((bq == 1) &&
792 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
793 wprintf("</BLOCKQUOTE>");
799 wprintf("</TT><br />\n");
801 wprintf("</I><br />");
804 else /* HTML is fun, but we've got to strip it first */
805 if (!strcasecmp(mime_content_type, "text/html")) {
806 output_html(mime_charset);
809 /* Unknown weirdness */
811 wprintf(_("I don't know how to display %s"), mime_content_type);
812 wprintf("<br />\n", mime_content_type);
813 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
816 /* Afterwards, offer links to download attachments 'n' such */
817 if (strlen(mime_http) > 0) {
818 wprintf("%s", mime_http);
821 /* Handler for vCard parts */
822 if (strlen(vcard_partnum) > 0) {
823 part_source = load_mimepart(msgnum, vcard_partnum);
824 if (part_source != NULL) {
826 /* If it's my vCard I can edit it */
827 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
828 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
829 || (WC->wc_view == VIEW_ADDRESSBOOK)
831 wprintf("<A HREF=\"/edit_vcard?"
832 "msgnum=%ld?partnum=%s\">",
833 msgnum, vcard_partnum);
834 wprintf("[%s]</A>", _("edit"));
837 /* In all cases, display the full card */
838 display_vcard(part_source, 0, 1, NULL);
842 /* Handler for calendar parts */
843 if (strlen(cal_partnum) > 0) {
844 part_source = load_mimepart(msgnum, cal_partnum);
845 if (part_source != NULL) {
846 cal_process_attachment(part_source,
847 msgnum, cal_partnum);
857 wprintf("</TD></TR></TABLE>\n");
859 /* end everythingamundo table */
860 wprintf("</TD></TR></TABLE>\n");
861 wprintf("</div><br />\n");
864 if (ic != (iconv_t)(-1) ) {
873 * Unadorned HTML output of an individual message, suitable
874 * for placing in a hidden iframe, for printing, or whatever
876 void embed_message(void) {
882 msgnum = atol(bstr("msgnum"));
883 sourceiframe = bstr("sourceiframe");
884 targetdiv = bstr("targetdiv");
885 print_it = bstr("print_it");
887 output_headers(1, 0, 0, 0, 0, 1, 0);
890 wprintf("<html><head>");
892 /* If we're loading into a hidden iframe, chances are the caller told us
893 * about a target div somewhere that we need to copy into when we're done.
895 if (strlen(targetdiv) > 0) wprintf(
897 " <script type=\"text/javascript\"> \n"
898 " function loaded_now_copy_it() { \n"
899 " parent.document.getElementById(\"%s\").innerHTML = parent.frames['%s'].document.body.innerHTML; \n"
906 if (!strcasecmp(print_it, "yes")) wprintf(
908 " <script type=\"text/javascript\"> \n"
909 " function loaded_now_print_it() { \n"
910 " parent.frames['%s'].focus(); \n"
911 " parent.frames['%s'].print(); \n"
920 if (strlen(targetdiv) > 0) {
921 wprintf(" onLoad='loaded_now_copy_it();'");
923 if (!strcasecmp(print_it, "yes")) {
924 wprintf(" onLoad='loaded_now_print_it();'");
927 read_message(msgnum, (!strcasecmp(print_it, "yes") ? 1 : 0) );
928 wprintf("</body></html>\n");
936 * Read message in simple, JavaScript-embeddable form for 'forward'
937 * or 'reply quoted' operations.
939 * NOTE: it is VITALLY IMPORTANT that we output no single-quotes or linebreaks
940 * in this function. Doing so would throw a JavaScript error in the
941 * 'supplied text' argument to the editor.
943 void pullquote_message(long msgnum, int forward_attachments) {
945 char mime_partnum[256];
946 char mime_filename[256];
947 char mime_content_type[256];
948 char mime_charset[256];
949 char mime_disposition[256];
952 char *attachments = NULL;
953 int num_attachments = 0;
954 struct wc_attachment *att, *aptr;
966 iconv_t ic = (iconv_t)(-1) ;
967 char *ibuf; /* Buffer of characters to be converted */
968 char *obuf; /* Buffer for converted characters */
969 size_t ibuflen; /* Length of input buffer */
970 size_t obuflen; /* Length of output buffer */
971 char *osav; /* Saved pointer to output buffer */
977 strcpy(reply_to, "");
978 strcpy(mime_http, "");
979 strcpy(mime_content_type, "text/plain");
980 strcpy(mime_charset, "us-ascii");
982 serv_printf("MSG4 %ld", msgnum);
983 serv_getln(buf, sizeof buf);
985 wprintf(_("ERROR:"));
986 wprintf("%s<br />", &buf[4]);
990 strcpy(m_subject, "");
992 while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
993 if (!strcmp(buf, "000")) {
994 wprintf(_("unexpected end of message"));
997 if (!strncasecmp(buf, "nhdr=yes", 8))
1001 if (!strncasecmp(buf, "type=", 5))
1002 format_type = atoi(&buf[5]);
1003 if (!strncasecmp(buf, "from=", 5)) {
1004 strcpy(from, &buf[5]);
1005 wprintf(_("from "));
1007 utf8ify_rfc822_string(from);
1011 if (!strncasecmp(buf, "subj=", 5)) {
1012 strcpy(m_subject, &buf[5]);
1014 if ((!strncasecmp(buf, "hnod=", 5))
1015 && (strcasecmp(&buf[5], serv_info.serv_humannode))) {
1016 wprintf("(%s) ", &buf[5]);
1018 if ((!strncasecmp(buf, "room=", 5))
1019 && (strcasecmp(&buf[5], WC->wc_roomname))
1020 && (strlen(&buf[5])>0) ) {
1022 wprintf("%s> ", &buf[5]);
1024 if (!strncasecmp(buf, "rfca=", 5)) {
1025 strcpy(rfca, &buf[5]);
1031 if (!strncasecmp(buf, "node=", 5)) {
1032 strcpy(node, &buf[5]);
1033 if ( ((WC->room_flags & QR_NETWORK)
1034 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
1035 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
1036 && (strlen(rfca)==0)
1038 wprintf("@%s ", &buf[5]);
1041 if (!strncasecmp(buf, "rcpt=", 5)) {
1043 wprintf("%s ", &buf[5]);
1045 if (!strncasecmp(buf, "time=", 5)) {
1046 fmt_date(now, atol(&buf[5]), 0);
1047 wprintf("%s ", now);
1051 * Save attachment info for later. We can't start downloading them
1052 * yet because we're in the middle of a server transaction.
1054 if (!strncasecmp(buf, "part=", 5)) {
1056 attachments = realloc(attachments, (num_attachments * 1024));
1057 strcat(attachments, &buf[5]);
1058 strcat(attachments, "\n");
1066 utf8ify_rfc822_string(m_subject);
1068 if (strlen(m_subject) > 0) {
1069 wprintf(_("Subject:"));
1070 wprintf(" %s<br />", m_subject);
1079 * Learn the content type
1081 strcpy(mime_content_type, "text/plain");
1082 while (serv_getln(buf, sizeof buf), (strlen(buf) > 0)) {
1083 if (!strcmp(buf, "000")) {
1084 wprintf(_("unexpected end of message"));
1087 if (!strncasecmp(buf, "Content-type: ", 14)) {
1088 safestrncpy(mime_content_type, &buf[14],
1089 sizeof(mime_content_type));
1090 for (i=0; i<strlen(mime_content_type); ++i) {
1091 if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
1092 safestrncpy(mime_charset, &mime_content_type[i+8],
1093 sizeof mime_charset);
1096 for (i=0; i<strlen(mime_content_type); ++i) {
1097 if (mime_content_type[i] == ';') {
1098 mime_content_type[i] = 0;
1104 /* Set up a character set conversion if we need to (and if we can) */
1106 if ( (strcasecmp(mime_charset, "us-ascii"))
1107 && (strcasecmp(mime_charset, "UTF-8")) ) {
1108 ic = iconv_open("UTF-8", mime_charset);
1109 if (ic == (iconv_t)(-1) ) {
1110 lprintf(5, "iconv_open() failed: %s\n", strerror(errno));
1115 /* Messages in legacy Citadel variformat get handled thusly... */
1116 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
1120 /* Boring old 80-column fixed format text gets handled this way... */
1121 else if (!strcasecmp(mime_content_type, "text/plain")) {
1122 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1123 if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
1124 if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = 0;
1127 if (ic != (iconv_t)(-1) ) {
1129 ibuflen = strlen(ibuf);
1131 obuf = (char *) malloc(obuflen);
1133 iconv(ic, &ibuf, &ibuflen, &obuf, &obuflen);
1134 osav[SIZ-obuflen] = 0;
1135 safestrncpy(buf, osav, sizeof buf);
1140 while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
1141 buf[strlen(buf) - 1] = 0;
1143 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
1144 wprintf("<BLOCKQUOTE>");
1146 } else if ((bq == 1) &&
1147 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
1148 wprintf("</BLOCKQUOTE>");
1154 wprintf("</TT><br />");
1156 wprintf("</I><br />");
1159 /* HTML just gets escaped and stuffed back into the editor */
1160 else if (!strcasecmp(mime_content_type, "text/html")) {
1161 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1166 /* Unknown weirdness ... don't know how to handle this content type */
1168 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
1172 /* end of body handler */
1175 * If there were attachments, we have to download them and insert them
1176 * into the attachment chain for the forwarded message we are composing.
1178 if (num_attachments) {
1179 for (i=0; i<num_attachments; ++i) {
1180 extract_token(buf, attachments, i, '\n', sizeof buf);
1181 extract_token(mime_filename, buf, 1, '|', sizeof mime_filename);
1182 extract_token(mime_partnum, buf, 2, '|', sizeof mime_partnum);
1183 extract_token(mime_disposition, buf, 3, '|', sizeof mime_disposition);
1184 extract_token(mime_content_type, buf, 4, '|', sizeof mime_content_type);
1185 mime_length = extract_int(buf, 5);
1188 * tracing ... uncomment if necessary
1190 lprintf(9, "fwd filename: %s\n", mime_filename);
1191 lprintf(9, "fwd partnum : %s\n", mime_partnum);
1192 lprintf(9, "fwd conttype: %s\n", mime_content_type);
1193 lprintf(9, "fwd dispose : %s\n", mime_disposition);
1194 lprintf(9, "fwd length : %d\n", mime_length);
1197 if ( (!strcasecmp(mime_disposition, "inline"))
1198 || (!strcasecmp(mime_disposition, "attachment")) ) {
1200 /* Create an attachment struct from this mime part... */
1201 att = malloc(sizeof(struct wc_attachment));
1202 memset(att, 0, sizeof(struct wc_attachment));
1203 att->length = mime_length;
1204 strcpy(att->content_type, mime_content_type);
1205 strcpy(att->filename, mime_filename);
1207 att->data = load_mimepart(msgnum, mime_partnum);
1209 /* And add it to the list. */
1210 if (WC->first_attachment == NULL) {
1211 WC->first_attachment = att;
1214 aptr = WC->first_attachment;
1215 while (aptr->next != NULL) aptr = aptr->next;
1225 if (ic != (iconv_t)(-1) ) {
1236 void display_summarized(int num) {
1240 if (WC->summ[num].is_new) wprintf("<B>");
1241 wprintf("<A HREF=\"/msg?msgnum=%ld?sourceiframe=msgloader1?targetdiv=preview_pane\" target=\"msgloader1\">",
1242 WC->summ[num].msgnum);
1243 escputs(WC->summ[num].subj);
1245 if (WC->summ[num].is_new) wprintf("</B>");
1246 wprintf("</TD><TD>");
1247 if (WC->summ[num].is_new) wprintf("<B>");
1248 escputs(WC->summ[num].from);
1249 if (WC->summ[num].is_new) wprintf("</B>");
1250 wprintf(" </TD><TD>");
1251 if (WC->summ[num].is_new) wprintf("<B>");
1252 fmt_date(datebuf, WC->summ[num].date, 1); /* brief */
1254 if (WC->summ[num].is_new) wprintf("</B>");
1257 "<INPUT TYPE=\"checkbox\" NAME=\"msg_%ld\" VALUE=\"yes\">"
1259 WC->summ[num].msgnum
1267 void display_addressbook(long msgnum, char alpha) {
1269 char mime_partnum[SIZ];
1270 char mime_filename[SIZ];
1271 char mime_content_type[SIZ];
1272 char mime_disposition[SIZ];
1274 char vcard_partnum[SIZ];
1275 char *vcard_source = NULL;
1276 struct message_summary summ;
1278 memset(&summ, 0, sizeof(summ));
1279 safestrncpy(summ.subj, _("(no subject)"), sizeof summ.subj);
1281 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
1283 serv_getln(buf, sizeof buf);
1284 if (buf[0] != '1') return;
1286 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1287 if (!strncasecmp(buf, "part=", 5)) {
1288 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
1289 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
1290 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
1291 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
1292 mime_length = extract_int(&buf[5], 5);
1294 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
1295 strcpy(vcard_partnum, mime_partnum);
1301 if (strlen(vcard_partnum) > 0) {
1302 vcard_source = load_mimepart(msgnum, vcard_partnum);
1303 if (vcard_source != NULL) {
1305 /* Display the summary line */
1306 display_vcard(vcard_source, alpha, 0, NULL);
1308 /* If it's my vCard I can edit it */
1309 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
1310 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
1311 || (WC->wc_view == VIEW_ADDRESSBOOK)
1313 wprintf("<A HREF=\"/edit_vcard?"
1314 "msgnum=%ld?partnum=%s\">",
1315 msgnum, vcard_partnum);
1316 wprintf("[%s]</A>", _("edit"));
1327 /* If it's an old "Firstname Lastname" style record, try to
1330 void lastfirst_firstlast(char *namebuf) {
1331 char firstname[SIZ];
1335 if (namebuf == NULL) return;
1336 if (strchr(namebuf, ';') != NULL) return;
1338 i = num_tokens(namebuf, ' ');
1341 extract_token(lastname, namebuf, i-1, ' ', sizeof lastname);
1342 remove_token(namebuf, i-1, ' ');
1343 strcpy(firstname, namebuf);
1344 sprintf(namebuf, "%s; %s", lastname, firstname);
1348 void fetch_ab_name(long msgnum, char *namebuf) {
1350 char mime_partnum[SIZ];
1351 char mime_filename[SIZ];
1352 char mime_content_type[SIZ];
1353 char mime_disposition[SIZ];
1355 char vcard_partnum[SIZ];
1356 char *vcard_source = NULL;
1358 struct message_summary summ;
1360 if (namebuf == NULL) return;
1361 strcpy(namebuf, "");
1363 memset(&summ, 0, sizeof(summ));
1364 safestrncpy(summ.subj, "(no subject)", sizeof summ.subj);
1366 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
1368 serv_getln(buf, sizeof buf);
1369 if (buf[0] != '1') return;
1371 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1372 if (!strncasecmp(buf, "part=", 5)) {
1373 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
1374 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
1375 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
1376 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
1377 mime_length = extract_int(&buf[5], 5);
1379 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
1380 strcpy(vcard_partnum, mime_partnum);
1386 if (strlen(vcard_partnum) > 0) {
1387 vcard_source = load_mimepart(msgnum, vcard_partnum);
1388 if (vcard_source != NULL) {
1390 /* Grab the name off the card */
1391 display_vcard(vcard_source, 0, 0, namebuf);
1397 lastfirst_firstlast(namebuf);
1399 for (i=0; i<strlen(namebuf); ++i) {
1400 if (namebuf[i] != ';') return;
1402 strcpy(namebuf, _("(no name)"));
1408 * Record compare function for sorting address book indices
1410 int abcmp(const void *ab1, const void *ab2) {
1412 (((const struct addrbookent *)ab1)->ab_name),
1413 (((const struct addrbookent *)ab2)->ab_name)
1419 * Helper function for do_addrbook_view()
1420 * Converts a name into a three-letter tab label
1422 void nametab(char *tabbuf, char *name) {
1423 stresc(tabbuf, name, 0, 0);
1424 tabbuf[0] = toupper(tabbuf[0]);
1425 tabbuf[1] = tolower(tabbuf[1]);
1426 tabbuf[2] = tolower(tabbuf[2]);
1432 * Render the address book using info we gathered during the scan
1434 void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
1438 static int NAMESPERPAGE = 60;
1442 char tabfirst_label[SIZ];
1444 char tablast_label[SIZ];
1448 wprintf(_("This address book is empty."));
1454 qsort(addrbook, num_ab, sizeof(struct addrbookent), abcmp);
1457 num_pages = num_ab / NAMESPERPAGE;
1459 page = atoi(bstr("page"));
1462 for (i=0; i<=num_pages; ++i) {
1464 wprintf("<A HREF=\"/readfwd?page=%d\">", i);
1469 tabfirst = i * NAMESPERPAGE;
1470 tablast = tabfirst + NAMESPERPAGE - 1;
1471 if (tablast > (num_ab - 1)) tablast = (num_ab - 1);
1472 nametab(tabfirst_label, addrbook[tabfirst].ab_name);
1473 nametab(tablast_label, addrbook[tablast].ab_name);
1474 wprintf("[%s - %s]",
1475 tabfirst_label, tablast_label
1484 wprintf("<br />\n");
1486 wprintf("<TABLE border=0 cellspacing=0 "
1487 "cellpadding=3 width=100%%>\n"
1490 for (i=0; i<num_ab; ++i) {
1492 if ((i / NAMESPERPAGE) == page) {
1494 if ((displayed % 4) == 0) {
1495 if (displayed > 0) {
1499 wprintf("<TR BGCOLOR=\"#%s\">",
1500 (bg ? "DDDDDD" : "FFFFFF")
1506 wprintf("<A HREF=\"/readfwd?startmsg=%ld&is_singlecard=1",
1507 addrbook[i].ab_msgnum);
1508 wprintf("?maxmsgs=1?summary=0?alpha=%s\">", bstr("alpha"));
1509 vcard_n_prettyize(addrbook[i].ab_name);
1510 escputs(addrbook[i].ab_name);
1511 wprintf("</A></TD>\n");
1516 wprintf("</TR></TABLE>\n");
1522 * load message pointers from the server
1524 int load_msg_ptrs(char *servcmd, int with_headers)
1528 char displayname[128];
1535 int num_summ_alloc = 0;
1538 if (WC->num_summ != 0) {
1543 num_summ_alloc = 100;
1545 WC->summ = malloc(num_summ_alloc * sizeof(struct message_summary));
1548 maxload = sizeof(WC->msgarr) / sizeof(long) ;
1550 serv_getln(buf, sizeof buf);
1551 if (buf[0] != '1') {
1552 wprintf("<EM>%s</EM><br />\n", &buf[4]);
1555 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1556 if (nummsgs < maxload) {
1557 WC->msgarr[nummsgs] = extract_long(buf, 0);
1558 datestamp = extract_long(buf, 1);
1559 extract_token(displayname, buf, 2, '|', sizeof displayname);
1560 extract_token(nodename, buf, 3, '|', sizeof nodename);
1561 extract_token(inetaddr, buf, 4, '|', sizeof inetaddr);
1562 extract_token(subject, buf, 5, '|', sizeof subject);
1566 if (nummsgs > num_summ_alloc) {
1567 num_summ_alloc *= 2;
1568 WC->summ = realloc(WC->summ, num_summ_alloc * sizeof(struct message_summary));
1572 memset(&WC->summ[nummsgs-1], 0, sizeof(struct message_summary));
1573 WC->summ[nummsgs-1].msgnum = WC->msgarr[nummsgs-1];
1574 safestrncpy(WC->summ[nummsgs-1].subj, _("(no subject)"), sizeof WC->summ[nummsgs-1].subj);
1575 if (strlen(displayname) > 0) {
1576 safestrncpy(WC->summ[nummsgs-1].from, displayname, sizeof WC->summ[nummsgs-1].from);
1578 if (strlen(subject) > 0) {
1579 safestrncpy(WC->summ[nummsgs-1].subj, subject,
1580 sizeof WC->summ[nummsgs-1].subj);
1583 /* Handle subjects with RFC2047 encoding */
1584 utf8ify_rfc822_string(WC->summ[nummsgs-1].subj);
1586 if (strlen(WC->summ[nummsgs-1].subj) > 75) {
1587 strcpy(&WC->summ[nummsgs-1].subj[72], "...");
1590 if (strlen(nodename) > 0) {
1591 if ( ((WC->room_flags & QR_NETWORK)
1592 || ((strcasecmp(nodename, serv_info.serv_nodename)
1593 && (strcasecmp(nodename, serv_info.serv_fqdn)))))
1595 strcat(WC->summ[nummsgs-1].from, " @ ");
1596 strcat(WC->summ[nummsgs-1].from, nodename);
1600 WC->summ[nummsgs-1].date = datestamp;
1603 /* Handle senders with RFC2047 encoding */
1604 utf8ify_rfc822_string(WC->summ[nummsgs-1].from);
1606 if (strlen(WC->summ[nummsgs-1].from) > 25) {
1607 strcpy(&WC->summ[nummsgs-1].from[22], "...");
1616 int summcmp_subj(const void *s1, const void *s2) {
1617 struct message_summary *summ1;
1618 struct message_summary *summ2;
1620 summ1 = (struct message_summary *)s1;
1621 summ2 = (struct message_summary *)s2;
1622 return strcasecmp(summ1->subj, summ2->subj);
1625 int summcmp_rsubj(const void *s1, const void *s2) {
1626 struct message_summary *summ1;
1627 struct message_summary *summ2;
1629 summ1 = (struct message_summary *)s1;
1630 summ2 = (struct message_summary *)s2;
1631 return strcasecmp(summ2->subj, summ1->subj);
1634 int summcmp_sender(const void *s1, const void *s2) {
1635 struct message_summary *summ1;
1636 struct message_summary *summ2;
1638 summ1 = (struct message_summary *)s1;
1639 summ2 = (struct message_summary *)s2;
1640 return strcasecmp(summ1->from, summ2->from);
1643 int summcmp_rsender(const void *s1, const void *s2) {
1644 struct message_summary *summ1;
1645 struct message_summary *summ2;
1647 summ1 = (struct message_summary *)s1;
1648 summ2 = (struct message_summary *)s2;
1649 return strcasecmp(summ2->from, summ1->from);
1652 int summcmp_date(const void *s1, const void *s2) {
1653 struct message_summary *summ1;
1654 struct message_summary *summ2;
1656 summ1 = (struct message_summary *)s1;
1657 summ2 = (struct message_summary *)s2;
1659 if (summ1->date < summ2->date) return -1;
1660 else if (summ1->date > summ2->date) return +1;
1664 int summcmp_rdate(const void *s1, const void *s2) {
1665 struct message_summary *summ1;
1666 struct message_summary *summ2;
1668 summ1 = (struct message_summary *)s1;
1669 summ2 = (struct message_summary *)s2;
1671 if (summ1->date < summ2->date) return +1;
1672 else if (summ1->date > summ2->date) return -1;
1677 * command loop for reading messages
1679 void readloop(char *oper)
1688 int num_displayed = 0;
1690 int is_addressbook = 0;
1691 int is_singlecard = 0;
1692 int is_calendar = 0;
1695 int remaining_messages;
1697 int lowest_displayed = (-1);
1698 int highest_displayed = 0;
1699 long pn_previous = 0L;
1700 long pn_current = 0L;
1703 struct addrbookent *addrbook = NULL;
1705 char *sortby = NULL;
1706 char sortpref_name[128];
1707 char sortpref_value[128];
1708 char *subjsort_button;
1709 char *sendsort_button;
1710 char *datesort_button;
1712 startmsg = atol(bstr("startmsg"));
1713 maxmsgs = atoi(bstr("maxmsgs"));
1714 is_summary = atoi(bstr("summary"));
1715 if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
1717 snprintf(sortpref_name, sizeof sortpref_name, "sort %s", WC->wc_roomname);
1718 get_preference(sortpref_name, sortpref_value, sizeof sortpref_value);
1720 sortby = bstr("sortby");
1721 if ( (strlen(sortby) > 0) && (strcasecmp(sortby, sortpref_value)) ) {
1722 set_preference(sortpref_name, sortby, 1);
1724 if (strlen(sortby) == 0) sortby = sortpref_value;
1725 if (strlen(sortby) == 0) sortby = "msgid";
1727 output_headers(1, 1, 1, 0, 0, 0, 0);
1729 /* When in summary mode, always show ALL messages instead of just
1730 * new or old. Otherwise, show what the user asked for.
1732 if (!strcmp(oper, "readnew")) {
1733 strcpy(cmd, "MSGS NEW");
1735 else if (!strcmp(oper, "readold")) {
1736 strcpy(cmd, "MSGS OLD");
1739 strcpy(cmd, "MSGS ALL");
1742 if ((WC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1)) {
1744 strcpy(cmd, "MSGS ALL");
1747 if ((WC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) {
1749 strcpy(cmd, "MSGS ALL");
1754 strcpy(cmd, "MSGS ALL|||1"); /* fetch header summary */
1759 /* Are we doing a summary view? If so, we need to know old messages
1760 * and new messages, so we can do that pretty boldface thing for the
1763 strcpy(old_msgs, "");
1766 serv_getln(buf, sizeof buf);
1767 if (buf[0] == '2') {
1768 strcpy(old_msgs, &buf[4]);
1772 is_singlecard = atoi(bstr("is_singlecard"));
1774 if (WC->wc_view == VIEW_CALENDAR) { /* calendar */
1776 strcpy(cmd, "MSGS ALL");
1779 if (WC->wc_view == VIEW_TASKS) { /* tasks */
1781 strcpy(cmd, "MSGS ALL");
1784 if (WC->wc_view == VIEW_NOTES) { /* notes */
1786 strcpy(cmd, "MSGS ALL");
1790 nummsgs = load_msg_ptrs(cmd, is_summary);
1793 if ((!is_tasks) && (!is_calendar) && (!is_notes)) {
1795 if (!strcmp(oper, "readnew")) {
1796 wprintf(_("No new messages."));
1797 } else if (!strcmp(oper, "readold")) {
1798 wprintf(_("No old messages."));
1800 wprintf(_("No messages here."));
1809 for (a = 0; a < nummsgs; ++a) {
1810 /* Are you a new message, or an old message? */
1812 if (is_msg_in_mset(old_msgs, WC->msgarr[a])) {
1813 WC->summ[a].is_new = 0;
1816 WC->summ[a].is_new = 1;
1822 if (startmsg == 0L) startmsg = WC->msgarr[0];
1823 remaining_messages = 0;
1825 for (a = 0; a < nummsgs; ++a) {
1826 if (WC->msgarr[a] >= startmsg) {
1827 ++remaining_messages;
1832 if (!strcasecmp(sortby, "subject")) {
1833 qsort(WC->summ, WC->num_summ,
1834 sizeof(struct message_summary), summcmp_subj);
1836 else if (!strcasecmp(sortby, "rsubject")) {
1837 qsort(WC->summ, WC->num_summ,
1838 sizeof(struct message_summary), summcmp_rsubj);
1840 else if (!strcasecmp(sortby, "sender")) {
1841 qsort(WC->summ, WC->num_summ,
1842 sizeof(struct message_summary), summcmp_sender);
1844 else if (!strcasecmp(sortby, "rsender")) {
1845 qsort(WC->summ, WC->num_summ,
1846 sizeof(struct message_summary), summcmp_rsender);
1848 else if (!strcasecmp(sortby, "date")) {
1849 qsort(WC->summ, WC->num_summ,
1850 sizeof(struct message_summary), summcmp_date);
1852 else if (!strcasecmp(sortby, "rdate")) {
1853 qsort(WC->summ, WC->num_summ,
1854 sizeof(struct message_summary), summcmp_rdate);
1858 if (!strcasecmp(sortby, "subject")) {
1859 subjsort_button = "<a href=\"/readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=rsubject\"><img border=\"0\" src=\"/static/down_pointer.gif\" /></a>" ;
1861 else if (!strcasecmp(sortby, "rsubject")) {
1862 subjsort_button = "<a href=\"/readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=subject\"><img border=\"0\" src=\"/static/up_pointer.gif\" /></a>" ;
1865 subjsort_button = "<a href=\"/readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=subject\"><img border=\"0\" src=\"/static/sort_none.gif\" /></a>" ;
1868 if (!strcasecmp(sortby, "sender")) {
1869 sendsort_button = "<a href=\"/readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=rsender\"><img border=\"0\" src=\"/static/down_pointer.gif\" /></a>" ;
1871 else if (!strcasecmp(sortby, "rsender")) {
1872 sendsort_button = "<a href=\"/readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=sender\"><img border=\"0\" src=\"/static/up_pointer.gif\" /></a>" ;
1875 sendsort_button = "<a href=\"/readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=sender\"><img border=\"0\" src=\"/static/sort_none.gif\" /></a>" ;
1878 if (!strcasecmp(sortby, "date")) {
1879 datesort_button = "<a href=\"/readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=rdate\"><img border=\"0\" src=\"/static/down_pointer.gif\" /></a>" ;
1881 else if (!strcasecmp(sortby, "rdate")) {
1882 datesort_button = "<a href=\"/readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=date\"><img border=\"0\" src=\"/static/up_pointer.gif\" /></a>" ;
1885 datesort_button = "<a href=\"/readfwd?startmsg=1?maxmsgs=9999999?summary=1?sortby=date\"><img border=\"0\" src=\"/static/sort_none.gif\" /></a>" ;
1889 wprintf("</div>"); /* end of 'content' div */
1891 wprintf("<div id=\"message_list\">"
1893 "<div id=\"fix_scrollbar_bug\">\n"
1895 "<form name=\"msgomatic\" "
1896 "method=\"POST\" action=\"/do_stuff_to_msgs\">\n"
1898 "<table border=0 cellspacing=0 "
1899 "cellpadding=0 width=100%%>\n"
1901 "<TD align=center><b><i>%s</i></b> %s</TD>"
1902 "<TD align=center><b><i>%s</i></b> %s</TD>"
1903 "<TD align=center><b><i>%s</i></b> %s</TD>"
1904 "<TD><INPUT TYPE=\"submit\" NAME=\"delete_button\" "
1905 "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
1906 " font-size: 6pt;\" "
1907 "VALUE=\"%s\"></TD>"
1910 _("Subject"), subjsort_button,
1911 _("Sender"), sendsort_button,
1912 _("Date"), datesort_button,
1917 for (a = 0; a < nummsgs; ++a) {
1918 if ((WC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
1920 /* Learn which msgs "Prev" & "Next" buttons go to */
1921 pn_current = WC->msgarr[a];
1922 if (a > 0) pn_previous = WC->msgarr[a-1];
1923 if (a < (nummsgs-1)) pn_next = WC->msgarr[a+1];
1925 /* If a tabular view, set up the line */
1928 wprintf("<TR BGCOLOR=\"#%s\">",
1929 (bg ? "DDDDDD" : "FFFFFF")
1933 /* Display the message */
1935 display_summarized(a);
1937 else if (is_addressbook) {
1938 fetch_ab_name(WC->msgarr[a], buf);
1940 addrbook = realloc(addrbook,
1941 (sizeof(struct addrbookent) * num_ab) );
1942 safestrncpy(addrbook[num_ab-1].ab_name, buf,
1943 sizeof(addrbook[num_ab-1].ab_name));
1944 addrbook[num_ab-1].ab_msgnum = WC->msgarr[a];
1946 else if (is_calendar) {
1947 display_calendar(WC->msgarr[a]);
1949 else if (is_tasks) {
1950 display_task(WC->msgarr[a]);
1952 else if (is_notes) {
1953 display_note(WC->msgarr[a]);
1956 read_message(WC->msgarr[a], 0);
1959 /* If a tabular view, finish the line */
1964 if (lowest_displayed < 0) lowest_displayed = a;
1965 highest_displayed = a;
1968 --remaining_messages;
1973 wprintf("</table></form>"
1974 "</div>\n"); /* end of 'fix_scrollbar_bug' div */
1975 wprintf("</div>"); /* end of 'message_list' div */
1977 wprintf("<div id=\"preview_pane\">"); /* The preview pane will initially be empty */
1980 /* Bump these because although we're thinking in zero base, the user
1981 * is a drooling idiot and is thinking in one base.
1984 ++highest_displayed;
1986 /* If we're only looking at one message, do a prev/next thing */
1987 if (num_displayed == 1) {
1988 if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_notes) && (!is_singlecard)) {
1990 wprintf("<div id=\"fix_scrollbar_bug\">"
1991 "<table border=0 width=100%% bgcolor=\"#dddddd\"><tr><td>");
1992 wprintf(_("Reading #%d of %d messages."), lowest_displayed, nummsgs);
1993 wprintf("</TD><TD ALIGN=RIGHT><FONT SIZE=+1>");
1995 if (pn_previous > 0L) {
1996 wprintf("<A HREF=\"/%s"
2007 wprintf("<A HREF=\"/%s"
2017 wprintf("<A HREF=\"/%s?startmsg=%ld"
2018 "?maxmsgs=%d?summary=1\">"
2027 wprintf("</td></tr></table></div>\n");
2032 * If we're not currently looking at ALL requested
2033 * messages, then display the selector bar
2035 if (num_displayed > 1) {
2036 if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
2037 && (!is_notes) && (!is_singlecard) && (!is_summary)) {
2039 wprintf("<form name=\"msgomatic\" "
2040 "method=\"POST\" action=\"/do_stuff_to_msgs\">\n");
2042 wprintf(_("Reading #"), lowest_displayed, highest_displayed);
2044 wprintf("<select name=\"whichones\" size=\"1\" "
2045 "OnChange=\"location.href=msgomatic.whichones.options"
2046 "[selectedIndex].value\">\n");
2048 for (b=0; b<nummsgs; b = b + maxmsgs) {
2051 if (hi > nummsgs) hi = nummsgs;
2052 wprintf("<option %s value="
2057 "%d-%d</option> \n",
2058 ((WC->msgarr[b] == startmsg) ? "selected" : ""),
2065 wprintf("<option value=\"/%s?startmsg=%ld"
2066 "?maxmsgs=9999999?summary=%d\">"
2070 WC->msgarr[0], is_summary);
2072 wprintf("</select> ");
2073 wprintf(_("of %d messages."), nummsgs);
2074 wprintf("</form>\n");
2080 do_tasks_view(); /* Render the task list */
2084 do_calendar_view(); /* Render the calendar */
2087 if (is_addressbook) {
2088 do_addrbook_view(addrbook, num_ab); /* Render the address book */
2091 /* Put the data transfer hidden iframe in a hidden div, to make it *really* hidden */
2093 "<div display=\"hidden\">\n"
2094 "<iframe name=\"msgloader1\" id=\"msgloader1\" width=\"1\"></iframe>\n"
2097 /* Note: wDumpContent() will output one additional </div> tag. */
2099 if (addrbook != NULL) free(addrbook);
2101 /* free the summary */
2102 if (WC->num_summ != 0) {
2107 /* If we got here via a mailbox view and are reading a single
2108 * message, mark it as "seen." We do this after rendering the web page
2109 * so it doesn't keep the user waiting.
2111 if ( (maxmsgs == 1) && (WC->wc_view == VIEW_MAILBOX) ) {
2112 serv_printf("SEEN %ld|1", startmsg);
2113 serv_getln(buf, sizeof buf);
2119 * Back end for post_message() ... this is where the actual message
2120 * gets transmitted to the server.
2122 void post_mime_to_server(void) {
2124 int is_multipart = 0;
2126 struct wc_attachment *att;
2128 size_t encoded_length;
2130 /* RFC2045 requires this, and some clients look for it... */
2131 serv_puts("MIME-Version: 1.0");
2133 /* If there are attachments, we have to do multipart/mixed */
2134 if (WC->first_attachment != NULL) {
2139 sprintf(boundary, "---Citadel-Multipart-%s-%04x%04x---",
2140 serv_info.serv_fqdn,
2145 /* Remember, serv_printf() appends an extra newline */
2146 serv_printf("Content-type: multipart/mixed; "
2147 "boundary=\"%s\"\n", boundary);
2148 serv_printf("This is a multipart message in MIME format.\n");
2149 serv_printf("--%s", boundary);
2152 serv_puts("Content-type: text/html; charset=utf-8");
2154 serv_puts("<HTML><BODY>\n");
2155 text_to_server(bstr("msgtext"), 0);
2156 serv_puts("</BODY></HTML>\n");
2161 /* Add in the attachments */
2162 for (att = WC->first_attachment; att!=NULL; att=att->next) {
2164 encoded_length = ((att->length * 150) / 100);
2165 encoded = malloc(encoded_length);
2166 if (encoded == NULL) break;
2167 CtdlEncodeBase64(encoded, att->data, att->length);
2169 serv_printf("--%s", boundary);
2170 serv_printf("Content-type: %s", att->content_type);
2171 serv_printf("Content-disposition: attachment; "
2172 "filename=\"%s\"", att->filename);
2173 serv_puts("Content-transfer-encoding: base64");
2175 serv_write(encoded, strlen(encoded));
2180 serv_printf("--%s--", boundary);
2188 * Post message (or don't post message)
2190 * Note regarding the "dont_post" variable:
2191 * A random value (actually, it's just a timestamp) is inserted as a hidden
2192 * field called "postseq" when the display_enter page is generated. This
2193 * value is checked when posting, using the static variable dont_post. If a
2194 * user attempts to post twice using the same dont_post value, the message is
2195 * discarded. This prevents the accidental double-saving of the same message
2196 * if the user happens to click the browser "back" button.
2198 void post_message(void)
2201 static long dont_post = (-1L);
2202 struct wc_attachment *att, *aptr;
2204 if (WC->upload_length > 0) {
2206 /* There's an attachment. Save it to this struct... */
2207 att = malloc(sizeof(struct wc_attachment));
2208 memset(att, 0, sizeof(struct wc_attachment));
2209 att->length = WC->upload_length;
2210 strcpy(att->content_type, WC->upload_content_type);
2211 strcpy(att->filename, WC->upload_filename);
2214 /* And add it to the list. */
2215 if (WC->first_attachment == NULL) {
2216 WC->first_attachment = att;
2219 aptr = WC->first_attachment;
2220 while (aptr->next != NULL) aptr = aptr->next;
2224 /* Mozilla sends a simple filename, which is what we want,
2225 * but Satan's Browser sends an entire pathname. Reduce
2226 * the path to just a filename if we need to.
2228 while (num_tokens(att->filename, '/') > 1) {
2229 remove_token(att->filename, 0, '/');
2231 while (num_tokens(att->filename, '\\') > 1) {
2232 remove_token(att->filename, 0, '\\');
2235 /* Transfer control of this memory from the upload struct
2236 * to the attachment struct.
2238 att->data = WC->upload;
2239 WC->upload_length = 0;
2245 if (strlen(bstr("cancel_button")) > 0) {
2246 sprintf(WC->ImportantMessage,
2247 _("Cancelled. Message was not posted."));
2248 } else if (strlen(bstr("attach_button")) > 0) {
2251 } else if (atol(bstr("postseq")) == dont_post) {
2252 sprintf(WC->ImportantMessage,
2253 _("Automatically cancelled because you have already "
2254 "saved this message."));
2256 sprintf(buf, "ENT0 1|%s|0|4|%s",
2260 serv_getln(buf, sizeof buf);
2261 if (buf[0] == '4') {
2262 post_mime_to_server();
2263 if (strlen(bstr("recp")) > 0) {
2264 sprintf(WC->ImportantMessage, _("Message has been sent.\n"));
2267 sprintf(WC->ImportantMessage, _("Message has been posted.\n"));
2269 dont_post = atol(bstr("postseq"));
2271 sprintf(WC->ImportantMessage, "%s", &buf[4]);
2277 free_attachments(WC);
2278 readloop("readnew");
2285 * display the message entry screen
2287 void display_enter(void)
2291 struct wc_attachment *att;
2292 int recipient_required = 0;
2293 int recipient_bad = 0;
2295 if (strlen(bstr("force_room")) > 0) {
2296 gotoroom(bstr("force_room"));
2299 /* Are we perhaps in an address book view? If so, then an "enter
2300 * message" command really means "add new entry."
2302 if (WC->wc_view == VIEW_ADDRESSBOOK) {
2303 do_edit_vcard(-1, "", "");
2307 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
2308 /* Are we perhaps in a calendar view? If so, then an "enter
2309 * message" command really means "add new calendar item."
2311 if (WC->wc_view == VIEW_CALENDAR) {
2312 display_edit_event();
2316 /* Are we perhaps in a tasks view? If so, then an "enter
2317 * message" command really means "add new task."
2319 if (WC->wc_view == VIEW_TASKS) {
2320 display_edit_task();
2326 * Otherwise proceed normally.
2327 ` * Do a custom room banner with no navbar...
2329 output_headers(1, 1, 2, 0, 0, 0, 0);
2330 wprintf("<div id=\"banner\">\n");
2331 embed_room_banner(NULL, navbar_none);
2332 wprintf("</div>\n");
2333 wprintf("<div id=\"content\">\n"
2334 "<div id=\"fix_scrollbar_bug\">"
2335 "<table width=100%% border=0 bgcolor=\"#ffffff\"><tr><td>");
2337 sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
2339 serv_getln(buf, sizeof buf);
2341 if (!strncmp(buf, "570", 3)) {
2342 recipient_required = 1;
2343 if (strlen(bstr("recp")) > 0) {
2347 else if (buf[0] != '2') {
2348 wprintf("<EM>%s</EM><br />\n", &buf[4]);
2353 fmt_date(buf, now, 0);
2354 strcat(&buf[strlen(buf)], _(" <I>from</I> "));
2355 stresc(&buf[strlen(buf)], WC->wc_username, 1, 1);
2356 if (strlen(bstr("recp")) > 0) {
2357 strcat(&buf[strlen(buf)], _(" <I>to</I> "));
2358 stresc(&buf[strlen(buf)], bstr("recp"), 1, 1);
2360 strcat(&buf[strlen(buf)], _(" <I>in</I> "));
2361 stresc(&buf[strlen(buf)], WC->wc_roomname, 1, 1);
2363 /* begin message entry screen */
2367 "<style> div.auto_complete { width: 350px; background: #fff; } div.auto_complete ul { border:1px solid #888; margin:0; padding:0; width:100%; list-style-type:none; } div.auto_complete ul li { margin:0; padding:3px; } div.auto_complete ul li.selected { background-color: #ffc; } div.auto_complete ul strong.highlight { color: #800; margin:0; padding:0; } </style> \n "
2370 wprintf("<form enctype=\"multipart/form-data\" "
2371 "method=\"POST\" action=\"/post\" "
2372 "name=\"enterform\""
2373 "onSubmit=\"return submitForm();\""
2375 wprintf("<input type=\"hidden\" name=\"recp\" value=\"%s\">\n",
2377 wprintf("<input type=\"hidden\" name=\"postseq\" value=\"%ld\">\n",
2380 wprintf("<img src=\"static/newmess3_24x.gif\" align=middle alt=\" \">");
2381 wprintf("%s<br>\n", buf); /* header bar */
2383 wprintf("<table border=\"0\" width=\"100%%\">\n");
2384 if (recipient_required) {
2385 wprintf("<tr><td>");
2386 wprintf("<font size=-1>");
2390 "<input autocomplete=\"off\" type=\"text\" name=\"recp\" id=\"recp_name\" value=\"");
2391 escputs(bstr("recp"));
2392 wprintf("\" size=50 maxlength=70>");
2394 wprintf("<div class=\"auto_complete\" id=\"recp_name_choices\"></div>");
2396 wprintf("<script type=\"text/javascript\"> "
2397 " new Ajax.Autocompleter('recp_name', 'recp_name_choices', "
2398 " '/recp_autocomplete', {} ); "
2402 wprintf("</td><td></td></tr>\n");
2405 wprintf("<tr><td>");
2406 wprintf("<font size=-1>");
2407 wprintf(_("Subject (optional):"));
2410 "<input type=\"text\" name=\"subject\" value=\"");
2411 escputs(bstr("subject"));
2412 wprintf("\" size=50 maxlength=70></td><td>\n");
2414 wprintf("<input type=\"submit\" name=\"send_button\" value=\"");
2415 if (recipient_required) {
2416 wprintf(_("Send message"));
2418 wprintf(_("Post message"));
2421 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">\n", _("Cancel"));
2422 wprintf("</td></tr></table>\n");
2424 wprintf("<center><script type=\"text/javascript\" "
2425 "src=\"static/richtext.js\"></script>\n"
2426 "<script type=\"text/javascript\">\n"
2427 "function submitForm() { \n"
2428 " updateRTE('msgtext'); \n"
2432 "initRTE(\"static/\", \"static/\", \"\"); \n"
2434 "<noscript>JavaScript must be enabled.</noscript> \n"
2435 "<script type=\"text/javascript\"> \n"
2436 "writeRichText('msgtext', '");
2437 msgescputs(bstr("msgtext"));
2438 if (atol(bstr("pullquote")) > 0L) {
2439 wprintf("<br><div align=center><i>");
2440 wprintf(_("--- forwarded message ---"));
2441 wprintf("</i></div><br>");
2442 pullquote_message(atol(bstr("pullquote")), 1);
2444 wprintf("', '96%%', '200', true, false); \n"
2445 "</script></center><br />\n");
2447 /* Enumerate any attachments which are already in place... */
2448 wprintf("<img src=\"/static/diskette_24x.gif\" border=0 "
2449 "align=middle height=16 width=16> Attachments: ");
2450 wprintf("<select name=\"which_attachment\" size=1>");
2451 for (att = WC->first_attachment; att != NULL; att = att->next) {
2452 wprintf("<option value=\"");
2453 urlescputs(att->filename);
2455 escputs(att->filename);
2456 /* wprintf(" (%s, %d bytes)",att->content_type,att->length); */
2457 wprintf("</option>\n");
2459 wprintf("</select>");
2461 /* Now offer the ability to attach additional files... */
2462 wprintf(" "
2463 "Attach file: <input NAME=\"attachfile\" "
2464 "SIZE=16 TYPE=\"file\">\n "
2465 "<input type=\"submit\" name=\"attach_button\" value=\"%s\">\n", _("Add"));
2467 wprintf("</form>\n");
2469 wprintf("</td></tr></table></div>\n");
2470 DONE: wDumpContent(1);
2480 void delete_msg(void)
2485 msgid = atol(bstr("msgid"));
2487 output_headers(1, 1, 1, 0, 0, 0, 0);
2489 sprintf(buf, "DELE %ld", msgid);
2491 serv_getln(buf, sizeof buf);
2492 wprintf("<EM>%s</EM><br />\n", &buf[4]);
2501 * Confirm move of a message
2503 void confirm_move_msg(void)
2509 msgid = atol(bstr("msgid"));
2511 output_headers(1, 1, 1, 0, 0, 0, 0);
2513 wprintf("<div id=\"fix_scrollbar_bug\">"
2514 "<table width=100%% border=0 bgcolor=\"#444455\"><tr><td>");
2515 wprintf("<font size=+1 color=\"#ffffff\"");
2517 wprintf(_("Confirm move of message"));
2519 wprintf("</font></td></tr></table></div>\n");
2521 wprintf("<CENTER>");
2523 wprintf(_("Move this message to:"));
2524 wprintf("<br />\n");
2526 wprintf("<form METHOD=\"POST\" ACTION=\"/move_msg\">\n");
2527 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n",
2531 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
2533 serv_getln(buf, sizeof buf);
2534 if (buf[0] == '1') {
2535 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2536 extract_token(targ, buf, 0, '|', sizeof targ);
2537 wprintf("<OPTION>");
2542 wprintf("</SELECT>\n");
2543 wprintf("<br />\n");
2545 wprintf("<INPUT TYPE=\"submit\" NAME=\"move_button\" VALUE=\"%s\">", _("Move"));
2547 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2548 wprintf("</form></CENTER>\n");
2550 wprintf("</CENTER>\n");
2561 msgid = atol(bstr("msgid"));
2563 output_headers(1, 1, 1, 0, 0, 0, 0);
2565 if (strlen(bstr("move_button")) > 0) {
2566 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
2568 serv_getln(buf, sizeof buf);
2569 wprintf("<EM>%s</EM><br />\n", &buf[4]);
2572 wprintf(_("The message was not moved."));
2573 wprintf("</EM><br />\n");
2580 * This gets called when a user selects multiple messages in a summary
2581 * list and then clicks to perform a transformation of some sort on them
2582 * (such as deleting them).
2584 void do_stuff_to_msgs(void) {
2588 struct stuff_t *next;
2592 struct stuff_t *stuff = NULL;
2593 struct stuff_t *ptr;
2594 int delete_button_pressed = 0;
2597 serv_puts("MSGS ALL");
2598 serv_getln(buf, sizeof buf);
2600 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2601 ptr = malloc(sizeof(struct stuff_t));
2602 ptr->msgnum = atol(buf);
2607 if (strlen(bstr("delete_button")) > 0) {
2608 delete_button_pressed = 1;
2611 while (stuff != NULL) {
2613 sprintf(buf, "msg_%ld", stuff->msgnum);
2614 if (!strcasecmp(bstr(buf), "yes")) {
2616 if (delete_button_pressed) {
2617 serv_printf("DELE %ld", stuff->msgnum);
2618 serv_getln(buf, sizeof buf);
2628 readloop("readfwd");