4 * Functions which deal with the fetching and displaying of messages.
14 #include <sys/types.h>
16 #include <sys/socket.h>
18 #include <netinet/in.h>
28 #include "webserver.h"
31 /* Address book entry (keep it short and sweet, it's just a quickie lookup
32 * which we can use to get to the real meat and bones later)
41 * Look for URL's embedded in a buffer and make them linkable. We use a
42 * target window in order to keep the BBS session in its own window.
58 for (pos = 0; pos < strlen(buf); ++pos) {
59 if (!strncasecmp(&buf[pos], "http://", 7))
61 if (!strncasecmp(&buf[pos], "ftp://", 6))
68 if ((start > 0) && (buf[start - 1] == '<'))
70 if ((start > 0) && (buf[start - 1] == '['))
72 if ((start > 0) && (buf[start - 1] == '('))
74 if ((start > 0) && (buf[start - 1] == '{'))
77 for (pos = strlen(buf); pos > start; --pos) {
78 if ((buf[pos] == ' ') || (buf[pos] == ench))
82 strncpy(urlbuf, &buf[start], end - start);
83 urlbuf[end - start] = 0;
85 strncpy(outbuf, buf, start);
86 sprintf(&outbuf[start], "%cA HREF=%c%s%c TARGET=%c%s%c%c%s%c/A%c",
87 LB, QU, urlbuf, QU, QU, TARGET, QU, RB, urlbuf, LB, RB);
88 strcat(outbuf, &buf[end]);
89 if ( strlen(outbuf) < 250 )
95 * Turn a vCard "n" (name) field into something displayable.
97 void vcard_n_prettyize(char *name)
102 original_name = strdup(name);
103 for (i=0; i<5; ++i) {
104 if (strlen(original_name) > 0) {
105 if (original_name[strlen(original_name)-1] == ' ') {
106 original_name[strlen(original_name)-1] = 0;
108 if (original_name[strlen(original_name)-1] == ';') {
109 original_name[strlen(original_name)-1] = 0;
114 for (i=0; i<strlen(original_name); ++i) {
115 if (original_name[i] == ';') {
119 name[strlen(name)+1] = 0;
120 name[strlen(name)] = original_name[i];
129 /* display_vcard() calls this after parsing the textual vCard into
130 * our 'struct vCard' data object.
131 * This gets called instead of display_parsed_vcard() if we are only looking
132 * to extract the person's name instead of displaying the card.
134 void fetchname_parsed_vcard(struct vCard *v, char *storename) {
137 strcpy(storename, "");
139 name = vcard_get_prop(v, "n", 1, 0, 0);
141 strcpy(storename, name);
142 /* vcard_n_prettyize(storename); */
149 /* display_vcard() calls this after parsing the textual vCard into
150 * our 'struct vCard' data object.
152 * Set 'full' to nonzero to display the full card, otherwise it will only
153 * show a summary line.
155 * This code is a bit ugly, so perhaps an explanation is due: we do this
156 * in two passes through the vCard fields. On the first pass, we process
157 * fields we understand, and then render them in a pretty fashion at the
158 * end. Then we make a second pass, outputting all the fields we don't
159 * understand in a simple two-column name/value format.
161 void display_parsed_vcard(struct vCard *v, int full) {
167 char *thisname, *thisvalue;
168 char firsttoken[SIZ];
171 char displayname[SIZ];
177 strcpy(displayname, "");
185 name = vcard_get_prop(v, "fn", 1, 0, 0);
189 else if (name = vcard_get_prop(v, "n", 1, 0, 0), name != NULL) {
190 strcpy(displayname, name);
191 vcard_n_prettyize(displayname);
192 escputs(displayname);
201 wprintf("<div align=center><table bgcolor=#aaaaaa width=50%%>");
202 for (pass=1; pass<=2; ++pass) {
204 if (v->numprops) for (i=0; i<(v->numprops); ++i) {
206 thisname = strdup(v->prop[i].name);
207 extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken);
209 for (j=0; j<num_tokens(thisname, ';'); ++j) {
210 extract_token(buf, thisname, j, ';', sizeof buf);
211 if (!strcasecmp(buf, "encoding=quoted-printable")) {
213 remove_token(thisname, j, ';');
215 if (!strcasecmp(buf, "encoding=base64")) {
217 remove_token(thisname, j, ';');
222 thisvalue = malloc(strlen(v->prop[i].value) + 50);
223 j = CtdlDecodeQuotedPrintable(
224 thisvalue, v->prop[i].value,
225 strlen(v->prop[i].value) );
229 thisvalue = malloc(strlen(v->prop[i].value) + 50);
231 thisvalue, v->prop[i].value,
232 strlen(v->prop[i].value) );
235 thisvalue = strdup(v->prop[i].value);
238 /*** Various fields we may encounter ***/
240 /* N is name, but only if there's no FN already there */
241 if (!strcasecmp(firsttoken, "n")) {
242 if (strlen(displayname) == 0) {
243 strcpy(displayname, thisvalue);
244 vcard_n_prettyize(displayname);
248 /* FN (full name) is a true 'display name' field */
249 else if (!strcasecmp(firsttoken, "fn")) {
250 strcpy(displayname, thisvalue);
254 else if (!strcasecmp(firsttoken, "title")) {
255 strcpy(title, thisvalue);
259 else if (!strcasecmp(firsttoken, "org")) {
260 strcpy(org, thisvalue);
263 else if (!strcasecmp(firsttoken, "email")) {
264 if (strlen(mailto) > 0) strcat(mailto, "<br />");
266 "<A HREF=\"/display_enter"
267 "?force_room=_MAIL_&recp=");
268 urlesc(&mailto[strlen(mailto)], thisvalue);
269 strcat(mailto, "\">");
270 urlesc(&mailto[strlen(mailto)], thisvalue);
271 strcat(mailto, "</A>");
273 else if (!strcasecmp(firsttoken, "tel")) {
274 if (strlen(phone) > 0) strcat(phone, "<br />");
275 strcat(phone, thisvalue);
276 for (j=0; j<num_tokens(thisname, ';'); ++j) {
277 extract_token(buf, thisname, j, ';', sizeof buf);
278 if (!strcasecmp(buf, "tel"))
280 else if (!strcasecmp(buf, "work"))
281 strcat(phone, " (work)");
282 else if (!strcasecmp(buf, "home"))
283 strcat(phone, " (home)");
284 else if (!strcasecmp(buf, "cell"))
285 strcat(phone, " (cell)");
293 else if (!strcasecmp(firsttoken, "adr")) {
295 wprintf("<TR><TD>Address:</TD><TD>");
296 for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
297 extract_token(buf, thisvalue, j, ';', sizeof buf);
298 if (strlen(buf) > 0) {
300 if (j<3) wprintf("<br />");
304 wprintf("</TD></TR>\n");
307 else if (!strcasecmp(firsttoken, "version")) {
310 else if (!strcasecmp(firsttoken, "rev")) {
313 else if (!strcasecmp(firsttoken, "label")) {
318 /*** Don't show extra fields. They're ugly.
322 wprintf("</TD><TD>");
324 wprintf("</TD></TR>\n");
334 wprintf("<TR BGCOLOR=\"#AAAAAA\">"
335 "<TD COLSPAN=2 BGCOLOR=\"#FFFFFF\">"
336 "<IMG ALIGN=CENTER SRC=\"/static/viewcontacts_48x.gif\">"
337 "<FONT SIZE=+1><B>");
338 escputs(displayname);
339 wprintf("</B></FONT>");
340 if (strlen(title) > 0) {
341 wprintf("<div align=right>");
345 if (strlen(org) > 0) {
346 wprintf("<div align=right>");
350 wprintf("</TD></TR>\n");
352 if (strlen(phone) > 0)
353 wprintf("<TR><TD>Telephone:</TD><TD>%s</TD></TR>\n", phone);
354 if (strlen(mailto) > 0)
355 wprintf("<TR><TD>E-mail:</TD><TD>%s</TD></TR>\n", mailto);
360 wprintf("</table></div>\n");
366 * Display a textual vCard
367 * (Converts to a vCard object and then calls the actual display function)
368 * Set 'full' to nonzero to display the whole card instead of a one-liner.
369 * Or, if "storename" is non-NULL, just store the person's name in that
370 * buffer instead of displaying the card at all.
372 void display_vcard(char *vcard_source, char alpha, int full, char *storename) {
378 v = vcard_load(vcard_source);
379 if (v == NULL) return;
381 name = vcard_get_prop(v, "n", 1, 0, 0);
387 if (storename != NULL) {
388 fetchname_parsed_vcard(v, storename);
390 else if ( (alpha == 0)
391 || ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) )
392 || ((!isalpha(alpha)) && (!isalpha(this_alpha)))
394 display_parsed_vcard(v, full);
404 * I wanna SEE that message!
406 void read_message(long msgnum) {
408 char mime_partnum[256];
409 char mime_filename[256];
410 char mime_content_type[256];
411 char mime_charset[256];
412 char mime_disposition[256];
425 char vcard_partnum[256];
426 char cal_partnum[256];
427 char *part_source = NULL;
432 strcpy(reply_to, "");
433 strcpy(vcard_partnum, "");
434 strcpy(cal_partnum, "");
435 strcpy(mime_http, "");
436 strcpy(mime_content_type, "text/plain");
437 strcpy(mime_charset, "us-ascii");
439 serv_printf("MSG4 %ld", msgnum);
440 serv_getln(buf, sizeof buf);
442 wprintf("<STRONG>ERROR:</STRONG> %s<br />\n", &buf[4]);
446 /* begin everythingamundo table */
447 wprintf("<div id=\"fix_scrollbar_bug\">\n");
448 wprintf("<table width=100%% border=1 cellspacing=0 "
449 "cellpadding=0><TR><TD>\n");
451 /* begin message header table */
452 wprintf("<TABLE WIDTH=100%% BORDER=0 CELLSPACING=0 "
453 "CELLPADDING=1 BGCOLOR=\"#CCCCCC\"><TR><TD>\n");
455 wprintf("<SPAN CLASS=\"message_header\">");
456 strcpy(m_subject, "");
458 while (serv_getln(buf, sizeof buf), strcasecmp(buf, "text")) {
459 if (!strcmp(buf, "000")) {
460 wprintf("<I>unexpected end of message</I><br /><br />\n");
461 wprintf("</SPAN>\n");
464 if (!strncasecmp(buf, "nhdr=yes", 8))
468 if (!strncasecmp(buf, "type=", 5))
469 format_type = atoi(&buf[5]);
470 if (!strncasecmp(buf, "from=", 5)) {
471 strcpy(from, &buf[5]);
472 wprintf("from <A HREF=\"/showuser&who=");
478 if (!strncasecmp(buf, "subj=", 5))
479 strcpy(m_subject, &buf[5]);
480 if ((!strncasecmp(buf, "hnod=", 5))
481 && (strcasecmp(&buf[5], serv_info.serv_humannode)))
482 wprintf("(%s) ", &buf[5]);
483 if ((!strncasecmp(buf, "room=", 5))
484 && (strcasecmp(&buf[5], WC->wc_roomname))
485 && (strlen(&buf[5])>0) )
486 wprintf("in %s> ", &buf[5]);
487 if (!strncasecmp(buf, "rfca=", 5)) {
488 strcpy(rfca, &buf[5]);
494 if (!strncasecmp(buf, "node=", 5)) {
495 strcpy(node, &buf[5]);
496 if ( ((WC->room_flags & QR_NETWORK)
497 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
498 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
501 wprintf("@%s ", &buf[5]);
504 if (!strncasecmp(buf, "rcpt=", 5))
505 wprintf("to %s ", &buf[5]);
506 if (!strncasecmp(buf, "time=", 5)) {
507 fmt_date(now, atol(&buf[5]), 0);
511 if (!strncasecmp(buf, "part=", 5)) {
512 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
513 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
514 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
515 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
516 mime_length = extract_int(&buf[5], 5);
518 if (!strcasecmp(mime_disposition, "attachment")) {
519 snprintf(&mime_http[strlen(mime_http)],
520 (sizeof(mime_http) - strlen(mime_http) - 1),
521 "<A HREF=\"/output_mimepart?"
522 "msgnum=%ld&partnum=%s\" "
523 "TARGET=\"wc.%ld.%s\">"
524 "<IMG SRC=\"/static/diskette_24x.gif\" "
525 "BORDER=0 ALIGN=MIDDLE>\n"
526 "Part %s: %s (%s, %d bytes)</A><br />\n",
527 msgnum, mime_partnum,
528 msgnum, mime_partnum,
529 mime_partnum, mime_filename,
530 mime_content_type, mime_length);
533 if ((!strcasecmp(mime_disposition, "inline"))
534 && (!strncasecmp(mime_content_type, "image/", 6)) ){
535 snprintf(&mime_http[strlen(mime_http)],
536 (sizeof(mime_http) - strlen(mime_http) - 1),
537 "<IMG SRC=\"/output_mimepart?"
538 "msgnum=%ld&partnum=%s\">",
539 msgnum, mime_partnum);
542 /*** begin handler prep ***/
543 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
544 strcpy(vcard_partnum, mime_partnum);
547 if (!strcasecmp(mime_content_type, "text/calendar")) {
548 strcpy(cal_partnum, mime_partnum);
551 /*** end handler prep ***/
557 /* Generate a reply-to address */
558 if (strlen(rfca) > 0) {
559 strcpy(reply_to, rfca);
562 if ( (strlen(node) > 0)
563 && (strcasecmp(node, serv_info.serv_nodename))
564 && (strcasecmp(node, serv_info.serv_humannode)) ) {
565 snprintf(reply_to, sizeof(reply_to), "%s @ %s",
569 snprintf(reply_to, sizeof(reply_to), "%s", from);
578 if (strlen(m_subject) > 0) {
580 "<SPAN CLASS=\"message_subject\">"
587 /* start msg buttons */
588 wprintf("<TD ALIGN=RIGHT>\n");
591 wprintf("<a href=\"/display_enter?recp=");
592 urlescputs(reply_to);
593 wprintf("&subject=");
594 if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
595 urlescputs(m_subject);
596 wprintf("\">[Reply]</a> ");
598 if (WC->is_room_aide) {
601 wprintf("<a href=\"/confirm_move_msg?msgid=%ld\">[Move]</a> ",
605 wprintf("<a href=\"/delete_msg?msgid=%ld\" "
606 "onClick=\"return confirm('Delete this message?');\">"
607 "[Delete]</a>", msgnum);
611 wprintf("</TD></TR></TABLE>\n");
614 wprintf("<TABLE BORDER=0 WIDTH=100%% BGCOLOR=#FFFFFF "
615 "CELLPADDING=1 CELLSPACING=0><TR><TD>");
618 * Learn the content type
620 strcpy(mime_content_type, "text/plain");
621 while (serv_getln(buf, sizeof buf), (strlen(buf) > 0)) {
622 if (!strcmp(buf, "000")) {
623 wprintf("<I>unexpected end of message</I><br /><br />\n");
626 if (!strncasecmp(buf, "Content-type: ", 14)) {
627 safestrncpy(mime_content_type, &buf[14],
628 sizeof(mime_content_type));
629 for (i=0; i<strlen(mime_content_type); ++i) {
630 if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
631 safestrncpy(mime_charset, &mime_content_type[i+8],
632 sizeof mime_charset);
635 for (i=0; i<strlen(mime_content_type); ++i) {
636 if (mime_content_type[i] == ';') {
637 mime_content_type[i] = 0;
643 wprintf("Content-type: %s<br />\n", mime_content_type);
644 wprintf("Charset: %s<br />\n", mime_charset);
646 /* Messages in legacy Citadel variformat get handled thusly... */
647 if (!strcasecmp(mime_content_type, "text/x-citadel-variformat")) {
648 fmout(NULL, "JUSTIFY");
651 /* Boring old 80-column fixed format text gets handled this way... */
652 else if (!strcasecmp(mime_content_type, "text/plain")) {
653 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
654 if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
655 if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = 0;
656 while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
657 buf[strlen(buf) - 1] = 0;
659 ((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
660 wprintf("<BLOCKQUOTE>");
662 } else if ((bq == 1) &&
663 (strncmp(buf, ">", 1)) && (strncmp(buf, " >", 2)) && (strncmp(buf, " :-)", 4))) {
664 wprintf("</BLOCKQUOTE>");
670 wprintf("</TT><br />\n");
672 wprintf("</I><br />");
675 else /* HTML is fun, but we've got to strip it first */
676 if (!strcasecmp(mime_content_type, "text/html")) {
680 /* Unknown weirdness */
682 wprintf("I don't know how to display %s<br />\n",
684 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
687 /* Afterwards, offer links to download attachments 'n' such */
688 if (strlen(mime_http) > 0) {
689 wprintf("%s", mime_http);
692 /* Handler for vCard parts */
693 if (strlen(vcard_partnum) > 0) {
694 part_source = load_mimepart(msgnum, vcard_partnum);
695 if (part_source != NULL) {
697 /* If it's my vCard I can edit it */
698 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
699 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
700 || (WC->wc_view == VIEW_ADDRESSBOOK)
702 wprintf("<A HREF=\"/edit_vcard?"
703 "msgnum=%ld&partnum=%s\">",
704 msgnum, vcard_partnum);
705 wprintf("[edit]</A>");
708 /* In all cases, display the full card */
709 display_vcard(part_source, 0, 1, NULL);
713 /* Handler for calendar parts */
714 if (strlen(cal_partnum) > 0) {
715 part_source = load_mimepart(msgnum, cal_partnum);
716 if (part_source != NULL) {
717 cal_process_attachment(part_source,
718 msgnum, cal_partnum);
728 wprintf("</TD></TR></TABLE>\n");
730 /* end everythingamundo table */
731 wprintf("</TD></TR></TABLE>\n");
732 wprintf("</div><br />\n");
736 void summarize_message(long msgnum, int is_new) {
747 memset(&summ, 0, sizeof(summ));
748 strcpy(summ.subj, "(no subject)");
750 /* ask for headers only with no MIME */
751 sprintf(buf, "MSG0 %ld|3", msgnum);
753 serv_getln(buf, sizeof buf);
754 if (buf[0] != '1') return;
756 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
757 if (!strncasecmp(buf, "from=", 5)) {
758 strcpy(summ.from, &buf[5]);
760 if (!strncasecmp(buf, "subj=", 5)) {
761 if (strlen(&buf[5]) > 0) {
762 strcpy(summ.subj, &buf[5]);
763 if (strlen(summ.subj) > 75) {
764 strcpy(&summ.subj[72], "...");
768 /* if (!strncasecmp(buf, "rfca=", 5)) {
769 strcat(summ.from, " <");
770 strcat(summ.from, &buf[5]);
771 strcat(summ.from, ">");
774 if (!strncasecmp(buf, "node=", 5)) {
775 if ( ((WC->room_flags & QR_NETWORK)
776 || ((strcasecmp(&buf[5], serv_info.serv_nodename)
777 && (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
779 strcat(summ.from, " @ ");
780 strcat(summ.from, &buf[5]);
784 if (!strncasecmp(buf, "rcpt=", 5)) {
785 strcpy(summ.to, &buf[5]);
788 if (!strncasecmp(buf, "time=", 5)) {
789 fmt_date(summ.date, atol(&buf[5]), 1); /* brief */
793 if (strlen(summ.from) > 25) {
794 strcpy(&summ.from[22], "...");
798 if (is_new) wprintf("<B>");
799 wprintf("<A HREF=\"/readfwd?startmsg=%ld"
800 "&maxmsgs=1&summary=0\">",
804 if (is_new) wprintf("</B>");
805 wprintf("</TD><TD>");
806 if (is_new) wprintf("<B>");
808 if (is_new) wprintf("</B>");
809 wprintf(" </TD><TD>");
810 if (is_new) wprintf("<B>");
812 if (is_new) wprintf("</B>");
815 "<INPUT TYPE=\"checkbox\" NAME=\"msg_%ld\" VALUE=\"yes\">"
823 void display_addressbook(long msgnum, char alpha) {
825 char mime_partnum[SIZ];
826 char mime_filename[SIZ];
827 char mime_content_type[SIZ];
828 char mime_disposition[SIZ];
830 char vcard_partnum[SIZ];
831 char *vcard_source = NULL;
841 memset(&summ, 0, sizeof(summ));
842 strcpy(summ.subj, "(no subject)");
844 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
846 serv_getln(buf, sizeof buf);
847 if (buf[0] != '1') return;
849 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
850 if (!strncasecmp(buf, "part=", 5)) {
851 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
852 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
853 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
854 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
855 mime_length = extract_int(&buf[5], 5);
857 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
858 strcpy(vcard_partnum, mime_partnum);
864 if (strlen(vcard_partnum) > 0) {
865 vcard_source = load_mimepart(msgnum, vcard_partnum);
866 if (vcard_source != NULL) {
868 /* Display the summary line */
869 display_vcard(vcard_source, alpha, 0, NULL);
871 /* If it's my vCard I can edit it */
872 if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
873 || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
874 || (WC->wc_view == VIEW_ADDRESSBOOK)
876 wprintf("<A HREF=\"/edit_vcard?"
877 "msgnum=%ld&partnum=%s\">",
878 msgnum, vcard_partnum);
879 wprintf("[edit]</A>");
890 /* If it's an old "Firstname Lastname" style record, try to
893 void lastfirst_firstlast(char *namebuf) {
898 if (namebuf == NULL) return;
899 if (strchr(namebuf, ';') != NULL) return;
901 i = num_tokens(namebuf, ' ');
904 extract_token(lastname, namebuf, i-1, ' ', sizeof lastname);
905 remove_token(namebuf, i-1, ' ');
906 strcpy(firstname, namebuf);
907 sprintf(namebuf, "%s; %s", lastname, firstname);
911 void fetch_ab_name(long msgnum, char *namebuf) {
913 char mime_partnum[SIZ];
914 char mime_filename[SIZ];
915 char mime_content_type[SIZ];
916 char mime_disposition[SIZ];
918 char vcard_partnum[SIZ];
919 char *vcard_source = NULL;
930 if (namebuf == NULL) return;
933 memset(&summ, 0, sizeof(summ));
934 strcpy(summ.subj, "(no subject)");
936 sprintf(buf, "MSG0 %ld|1", msgnum); /* ask for headers only */
938 serv_getln(buf, sizeof buf);
939 if (buf[0] != '1') return;
941 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
942 if (!strncasecmp(buf, "part=", 5)) {
943 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
944 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
945 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
946 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
947 mime_length = extract_int(&buf[5], 5);
949 if (!strcasecmp(mime_content_type, "text/x-vcard")) {
950 strcpy(vcard_partnum, mime_partnum);
956 if (strlen(vcard_partnum) > 0) {
957 vcard_source = load_mimepart(msgnum, vcard_partnum);
958 if (vcard_source != NULL) {
960 /* Grab the name off the card */
961 display_vcard(vcard_source, 0, 0, namebuf);
967 lastfirst_firstlast(namebuf);
969 for (i=0; i<strlen(namebuf); ++i) {
970 if (namebuf[i] != ';') return;
972 strcpy(namebuf, "(no name)");
978 * Record compare function for sorting address book indices
980 int abcmp(const void *ab1, const void *ab2) {
982 (((const struct addrbookent *)ab1)->ab_name),
983 (((const struct addrbookent *)ab2)->ab_name)
989 * Helper function for do_addrbook_view()
990 * Converts a name into a three-letter tab label
992 void nametab(char *tabbuf, char *name) {
993 stresc(tabbuf, name, 0, 0);
994 tabbuf[0] = toupper(tabbuf[0]);
995 tabbuf[1] = tolower(tabbuf[1]);
996 tabbuf[2] = tolower(tabbuf[2]);
1002 * Render the address book using info we gathered during the scan
1004 void do_addrbook_view(struct addrbookent *addrbook, int num_ab) {
1008 static int NAMESPERPAGE = 60;
1012 char tabfirst_label[SIZ];
1014 char tablast_label[SIZ];
1017 wprintf("<I>This address book is empty.</I>\n");
1022 qsort(addrbook, num_ab, sizeof(struct addrbookent), abcmp);
1025 num_pages = num_ab / NAMESPERPAGE;
1027 page = atoi(bstr("page"));
1030 for (i=0; i<=num_pages; ++i) {
1032 wprintf("<A HREF=\"/readfwd?page=%d\">", i);
1037 tabfirst = i * NAMESPERPAGE;
1038 tablast = tabfirst + NAMESPERPAGE - 1;
1039 if (tablast > (num_ab - 1)) tablast = (num_ab - 1);
1040 nametab(tabfirst_label, addrbook[tabfirst].ab_name);
1041 nametab(tablast_label, addrbook[tablast].ab_name);
1042 wprintf("[%s - %s]",
1043 tabfirst_label, tablast_label
1052 wprintf("<br />\n");
1054 wprintf("<TABLE border=0 cellspacing=0 "
1055 "cellpadding=3 width=100%%>\n"
1058 for (i=0; i<num_ab; ++i) {
1060 if ((i / NAMESPERPAGE) == page) {
1062 if ((displayed % 4) == 0) {
1063 if (displayed > 0) {
1067 wprintf("<TR BGCOLOR=\"#%s\">",
1068 (bg ? "DDDDDD" : "FFFFFF")
1074 wprintf("<A HREF=\"/readfwd?startmsg=%ld&is_singlecard=1",
1075 addrbook[i].ab_msgnum);
1076 wprintf("&maxmsgs=1&summary=0&alpha=%s\">", bstr("alpha"));
1077 vcard_n_prettyize(addrbook[i].ab_name);
1078 escputs(addrbook[i].ab_name);
1079 wprintf("</A></TD>\n");
1084 wprintf("</TR></TABLE>\n");
1090 * load message pointers from the server
1092 int load_msg_ptrs(char *servcmd)
1099 maxload = sizeof(WC->msgarr) / sizeof(long) ;
1101 serv_getln(buf, sizeof buf);
1102 if (buf[0] != '1') {
1103 wprintf("<EM>%s</EM><br />\n", &buf[4]);
1106 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1107 if (nummsgs < maxload) {
1108 WC->msgarr[nummsgs] = atol(buf);
1117 * command loop for reading messages
1119 void readloop(char *oper)
1129 int num_displayed = 0;
1131 int is_addressbook = 0;
1132 int is_singlecard = 0;
1133 int is_calendar = 0;
1136 int remaining_messages;
1138 int lowest_displayed = (-1);
1139 int highest_displayed = 0;
1140 long pn_previous = 0L;
1141 long pn_current = 0L;
1144 struct addrbookent *addrbook = NULL;
1147 startmsg = atol(bstr("startmsg"));
1148 maxmsgs = atoi(bstr("maxmsgs"));
1149 is_summary = atoi(bstr("summary"));
1150 if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
1152 output_headers(1, 1, 1, 0, 0, 0, 0);
1154 /* When in summary mode, always show ALL messages instead of just
1155 * new or old. Otherwise, show what the user asked for.
1157 if (!strcmp(oper, "readnew")) {
1158 strcpy(cmd, "MSGS NEW");
1160 else if (!strcmp(oper, "readold")) {
1161 strcpy(cmd, "MSGS OLD");
1164 strcpy(cmd, "MSGS ALL");
1167 if ((WC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1)) {
1169 strcpy(cmd, "MSGS ALL");
1172 if ((WC->wc_view == VIEW_ADDRESSBOOK) && (maxmsgs > 1)) {
1174 strcpy(cmd, "MSGS ALL");
1179 strcpy(cmd, "MSGS ALL");
1182 /* Are we doing a summary view? If so, we need to know old messages
1183 * and new messages, so we can do that pretty boldface thing for the
1186 strcpy(old_msgs, "");
1189 serv_getln(buf, sizeof buf);
1190 if (buf[0] == '2') {
1191 strcpy(old_msgs, &buf[4]);
1195 is_singlecard = atoi(bstr("is_singlecard"));
1197 if (WC->wc_view == VIEW_CALENDAR) { /* calendar */
1199 strcpy(cmd, "MSGS ALL");
1202 if (WC->wc_view == VIEW_TASKS) { /* tasks */
1204 strcpy(cmd, "MSGS ALL");
1207 if (WC->wc_view == VIEW_NOTES) { /* notes */
1209 strcpy(cmd, "MSGS ALL");
1213 nummsgs = load_msg_ptrs(cmd);
1216 if ((!is_tasks) && (!is_calendar) && (!is_notes)) {
1217 if (!strcmp(oper, "readnew")) {
1218 wprintf("<EM>No new messages.</EM>\n");
1219 } else if (!strcmp(oper, "readold")) {
1220 wprintf("<EM>No old messages.</EM>\n");
1222 wprintf("<EM>No messages here.</EM>\n");
1229 if (startmsg == 0L) startmsg = WC->msgarr[0];
1230 remaining_messages = 0;
1232 for (a = 0; a < nummsgs; ++a) {
1233 if (WC->msgarr[a] >= startmsg) {
1234 ++remaining_messages;
1238 wprintf("<form name=\"msgomatic\" "
1239 "METHOD=\"POST\" ACTION=\"/do_stuff_to_msgs\">\n");
1241 wprintf("<div id=\"fix_scrollbar_bug\">"
1242 "<table border=0 cellspacing=0 "
1243 "cellpadding=0 width=100%%>\n"
1245 "<TD align=center><b><i>Subject</i></b></TD>"
1246 "<TD align=center><b><i>Sender</i></b></TD>"
1247 "<TD align=center><b><i>Date</i></b></TD>"
1253 for (a = 0; a < nummsgs; ++a) {
1254 if ((WC->msgarr[a] >= startmsg) && (num_displayed < maxmsgs)) {
1256 /* Are you a new message, or an old message? */
1259 if (is_msg_in_mset(old_msgs, WC->msgarr[a])) {
1267 /* Learn which msgs "Prev" & "Next" buttons go to */
1268 pn_current = WC->msgarr[a];
1269 if (a > 0) pn_previous = WC->msgarr[a-1];
1270 if (a < (nummsgs-1)) pn_next = WC->msgarr[a+1];
1272 /* If a tabular view, set up the line */
1275 wprintf("<TR BGCOLOR=\"#%s\">",
1276 (bg ? "DDDDDD" : "FFFFFF")
1280 /* Display the message */
1282 summarize_message(WC->msgarr[a], is_new);
1284 else if (is_addressbook) {
1285 fetch_ab_name(WC->msgarr[a], buf);
1287 addrbook = realloc(addrbook,
1288 (sizeof(struct addrbookent) * num_ab) );
1289 safestrncpy(addrbook[num_ab-1].ab_name, buf,
1290 sizeof(addrbook[num_ab-1].ab_name));
1291 addrbook[num_ab-1].ab_msgnum = WC->msgarr[a];
1293 else if (is_calendar) {
1294 display_calendar(WC->msgarr[a]);
1296 else if (is_tasks) {
1297 display_task(WC->msgarr[a]);
1299 else if (is_notes) {
1300 display_note(WC->msgarr[a]);
1303 read_message(WC->msgarr[a]);
1306 /* If a tabular view, finish the line */
1311 if (lowest_displayed < 0) lowest_displayed = a;
1312 highest_displayed = a;
1315 --remaining_messages;
1320 wprintf("</table></div>\n");
1323 /* Bump these because although we're thinking in zero base, the user
1324 * is a drooling idiot and is thinking in one base.
1327 ++highest_displayed;
1329 /* If we're only looking at one message, do a prev/next thing */
1330 if (num_displayed == 1) {
1331 if ((!is_tasks) && (!is_calendar) && (!is_addressbook) && (!is_notes) && (!is_singlecard)) {
1333 wprintf("<div id=\"fix_scrollbar_bug\">"
1334 "<table border=0 width=100%% bgcolor=\"#dddddd\"><tr><td>"
1335 "Reading #%d of %d messages.</TD>\n"
1336 "<TD ALIGN=RIGHT><FONT SIZE=+1>",
1337 lowest_displayed, nummsgs);
1340 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" "
1341 "VALUE=\"Delete selected\">\n");
1344 if (pn_previous > 0L) {
1345 wprintf("<A HREF=\"/%s"
1355 wprintf("<A HREF=\"/%s"
1364 wprintf("<A HREF=\"/%s?startmsg=%ld"
1365 "&maxmsgs=%d&summary=1\">"
1373 wprintf("</td></tr></table></div>\n");
1378 * If we're not currently looking at ALL requested
1379 * messages, then display the selector bar
1381 if (num_displayed > 1) {
1382 if ((!is_tasks) && (!is_calendar) && (!is_addressbook)
1383 && (!is_notes) && (!is_singlecard)) {
1385 wprintf("Reading #", lowest_displayed, highest_displayed);
1387 wprintf("<SELECT NAME=\"whichones\" SIZE=\"1\" "
1388 "OnChange=\"location.href=msgomatic.whichones.options"
1389 "[selectedIndex].value\">\n");
1391 for (b=0; b<nummsgs; b = b + maxmsgs) {
1394 if (hi > nummsgs) hi = nummsgs;
1395 wprintf("<OPTION %s VALUE="
1400 "%d-%d</OPTION> \n",
1401 ((WC->msgarr[b] == startmsg) ? "SELECTED" : ""),
1408 wprintf("<OPTION VALUE=\"/%s?startmsg=%ld"
1409 "&maxmsgs=9999999&summary=%d\">"
1413 WC->msgarr[0], is_summary);
1415 wprintf("</SELECT> of %d messages.", nummsgs);
1418 wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" "
1419 "VALUE=\"Delete selected\">\n");
1424 wprintf("</form>\n");
1428 do_tasks_view(); /* Render the task list */
1432 do_calendar_view(); /* Render the calendar */
1435 if (is_addressbook) {
1436 do_addrbook_view(addrbook, num_ab); /* Render the address book */
1440 if (addrbook != NULL) free(addrbook);
1442 /* If we got here via a mailbox view and are reading a single
1443 * message, mark it as "seen." We do this after rendering the web page
1444 * so it doesn't keep the user waiting.
1446 if ( (maxmsgs == 1) && (WC->wc_view == VIEW_MAILBOX) ) {
1447 serv_printf("SEEN %ld|1", startmsg);
1448 serv_getln(buf, sizeof buf);
1454 * Back end for post_message() ... this is where the actual message
1455 * gets transmitted to the server.
1457 void post_mime_to_server(void) {
1459 int is_multipart = 0;
1461 struct wc_attachment *att;
1463 size_t encoded_length;
1465 /* If there are attachments, we have to do multipart/mixed */
1466 if (WC->first_attachment != NULL) {
1471 sprintf(boundary, "---Citadel-Multipart-%s-%04x%04x---",
1472 serv_info.serv_fqdn,
1477 /* Remember, serv_printf() appends an extra newline */
1478 serv_printf("Content-type: multipart/mixed; "
1479 "boundary=\"%s\"\n", boundary);
1480 serv_printf("This is a multipart message in MIME format.\n");
1481 serv_printf("--%s", boundary);
1484 serv_puts("Content-type: text/html; charset=utf-8");
1486 serv_puts("<HTML><BODY>\n");
1487 text_to_server(bstr("msgtext"), 0);
1488 serv_puts("</BODY></HTML>\n");
1493 /* Add in the attachments */
1494 for (att = WC->first_attachment; att!=NULL; att=att->next) {
1496 encoded_length = ((att->length * 150) / 100);
1497 encoded = malloc(encoded_length);
1498 if (encoded == NULL) break;
1499 CtdlEncodeBase64(encoded, att->data, att->length);
1501 serv_printf("--%s", boundary);
1502 serv_printf("Content-type: %s", att->content_type);
1503 serv_printf("Content-disposition: attachment; "
1504 "filename=\"%s\"", att->filename);
1505 serv_puts("Content-transfer-encoding: base64");
1507 serv_write(encoded, strlen(encoded));
1512 serv_printf("--%s--", boundary);
1520 * Post message (or don't post message)
1522 * Note regarding the "dont_post" variable:
1523 * A random value (actually, it's just a timestamp) is inserted as a hidden
1524 * field called "postseq" when the display_enter page is generated. This
1525 * value is checked when posting, using the static variable dont_post. If a
1526 * user attempts to post twice using the same dont_post value, the message is
1527 * discarded. This prevents the accidental double-saving of the same message
1528 * if the user happens to click the browser "back" button.
1530 void post_message(void)
1533 static long dont_post = (-1L);
1534 struct wc_attachment *att, *aptr;
1536 if (WC->upload_length > 0) {
1538 /* There's an attachment. Save it to this struct... */
1539 att = malloc(sizeof(struct wc_attachment));
1540 memset(att, 0, sizeof(struct wc_attachment));
1541 att->length = WC->upload_length;
1542 strcpy(att->content_type, WC->upload_content_type);
1543 strcpy(att->filename, WC->upload_filename);
1546 /* And add it to the list. */
1547 if (WC->first_attachment == NULL) {
1548 WC->first_attachment = att;
1551 aptr = WC->first_attachment;
1552 while (aptr->next != NULL) aptr = aptr->next;
1556 /* Netscape sends a simple filename, which is what we want,
1557 * but Satan's browser sends an entire pathname. Reduce
1558 * the path to just a filename if we need to.
1560 while (num_tokens(att->filename, '/') > 1) {
1561 remove_token(att->filename, 0, '/');
1563 while (num_tokens(att->filename, '\\') > 1) {
1564 remove_token(att->filename, 0, '\\');
1567 /* Transfer control of this memory from the upload struct
1568 * to the attachment struct.
1570 att->data = WC->upload;
1571 WC->upload_length = 0;
1577 if (!strcasecmp(bstr("sc"), "Cancel")) {
1578 sprintf(WC->ImportantMessage,
1579 "Cancelled. Message was not posted.");
1580 } else if (!strcasecmp(bstr("attach"), "Add")) {
1583 } else if (atol(bstr("postseq")) == dont_post) {
1584 sprintf(WC->ImportantMessage,
1585 "Automatically cancelled because you have already "
1586 "saved this message.");
1588 sprintf(buf, "ENT0 1|%s|0|4|%s",
1592 serv_getln(buf, sizeof buf);
1593 if (buf[0] == '4') {
1594 post_mime_to_server();
1595 if (strlen(bstr("recp")) > 0) {
1596 sprintf(WC->ImportantMessage, "Message has been sent.\n");
1599 sprintf(WC->ImportantMessage, "Message has been posted.\n");
1601 dont_post = atol(bstr("postseq"));
1603 sprintf(WC->ImportantMessage,
1608 free_attachments(WC);
1609 readloop("readnew");
1616 * display the message entry screen
1618 void display_enter(void)
1622 struct wc_attachment *att;
1624 if (strlen(bstr("force_room")) > 0) {
1625 gotoroom(bstr("force_room"));
1628 /* Are we perhaps in an address book view? If so, then an "enter
1629 * message" command really means "add new entry."
1631 if (WC->wc_view == VIEW_ADDRESSBOOK) {
1632 do_edit_vcard(-1, "", "");
1636 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
1637 /* Are we perhaps in a calendar view? If so, then an "enter
1638 * message" command really means "add new calendar item."
1640 if (WC->wc_view == VIEW_CALENDAR) {
1641 display_edit_event();
1645 /* Are we perhaps in a tasks view? If so, then an "enter
1646 * message" command really means "add new task."
1648 if (WC->wc_view == VIEW_TASKS) {
1649 display_edit_task();
1654 /* Otherwise proceed normally. Do a custom room banner with no navbar... */
1655 output_headers(1, 1, 2, 0, 0, 0, 0);
1656 wprintf("<div id=\"banner\">\n");
1657 embed_room_banner(NULL, navbar_none);
1658 wprintf("</div>\n");
1659 wprintf("<div id=\"content\">\n"
1660 "<div id=\"fix_scrollbar_bug\">"
1661 "<table width=100%% border=0 bgcolor=\"#ffffff\"><tr><td>");
1663 sprintf(buf, "ENT0 0|%s|0|0", bstr("recp"));
1665 serv_getln(buf, sizeof buf);
1667 if (!strncmp(buf, "570", 3)) {
1668 if (strlen(bstr("recp")) > 0) {
1669 svprintf("RECPERROR", WCS_STRING,
1670 "<SPAN CLASS=\"errormsg\">%s</SPAN><br />\n",
1674 do_template("prompt_for_recipient");
1677 if (buf[0] != '2') {
1678 wprintf("<EM>%s</EM><br />\n", &buf[4]);
1683 fmt_date(buf, now, 0);
1684 strcat(&buf[strlen(buf)], " <I>from</I> ");
1685 stresc(&buf[strlen(buf)], WC->wc_username, 1, 1);
1686 if (strlen(bstr("recp")) > 0) {
1687 strcat(&buf[strlen(buf)], " <I>to</I> ");
1688 stresc(&buf[strlen(buf)], bstr("recp"), 1, 1);
1690 strcat(&buf[strlen(buf)], " <I>in</I> ");
1691 stresc(&buf[strlen(buf)], WC->wc_roomname, 1, 1);
1693 /* begin message entry screen */
1694 // wprintf("<div style=\"position:absolute; left:1%%; width:96%%; height:100%%\">\n");
1696 wprintf("<form enctype=\"multipart/form-data\" "
1697 "method=\"POST\" action=\"/post\" "
1698 "name=\"enterform\""
1699 "onSubmit=\"return submitForm();\""
1701 wprintf("<input type=\"hidden\" name=\"recp\" value=\"%s\">\n",
1703 wprintf("<input type=\"hidden\" name=\"postseq\" value=\"%ld\">\n",
1706 wprintf("%s<br>\n", buf); /* header bar */
1707 wprintf("<img src=\"static/newmess3_24x.gif\" align=middle alt=\" \">");
1708 /* "onLoad=\"document.enterform.msgtext.focus();\" " */
1709 wprintf("<font size=-1>Subject (optional):</font>"
1710 "<input type=\"text\" name=\"subject\" value=\"");
1711 escputs(bstr("subject"));
1712 wprintf("\" size=40 maxlength=70>"
1716 wprintf("<input type=\"submit\" name=\"sc\" value=\"");
1717 if (strlen(bstr("recp")) > 0) {
1718 wprintf("Send message");
1720 wprintf("Post message");
1723 "<input type=\"submit\" name=\"sc\" value=\"Cancel\">\n");
1725 wprintf("<center><script type=\"text/javascript\" "
1726 "src=\"static/richtext.js\"></script>\n"
1727 "<script type=\"text/javascript\">\n"
1728 "function submitForm() { \n"
1729 " updateRTE('msgtext'); \n"
1733 "initRTE(\"static/\", \"static/\", \"\"); \n"
1735 "<noscript>JavaScript must be enabled.</noscript> \n"
1736 "<script type=\"text/javascript\"> \n"
1737 "writeRichText('msgtext', '");
1738 msgescputs(bstr("msgtext"));
1739 wprintf("', '96%%', '200', true, false); \n"
1740 "</script></center><br />\n");
1742 /* Enumerate any attachments which are already in place... */
1743 wprintf("<img src=\"/static/diskette_24x.gif\" border=0 "
1744 "align=middle height=16 width=16> Attachments: ");
1745 wprintf("<select name=\"which_attachment\" size=1>");
1746 for (att = WC->first_attachment; att != NULL; att = att->next) {
1747 wprintf("<option value=\"");
1748 urlescputs(att->filename);
1750 escputs(att->filename);
1751 /* wprintf(" (%s, %d bytes)",att->content_type,att->length); */
1752 wprintf("</option>\n");
1754 wprintf("</select>");
1756 /* Now offer the ability to attach additional files... */
1757 wprintf(" "
1758 "Attach file: <input NAME=\"attachfile\" "
1759 "SIZE=16 TYPE=\"file\">\n "
1760 "<input type=\"submit\" name=\"attach\" value=\"Add\">\n");
1762 wprintf("</form>\n");
1764 wprintf("</td></tr></table></div>\n");
1765 DONE: wDumpContent(1);
1775 void delete_msg(void)
1780 msgid = atol(bstr("msgid"));
1782 output_headers(1, 1, 1, 0, 0, 0, 0);
1784 sprintf(buf, "DELE %ld", msgid);
1786 serv_getln(buf, sizeof buf);
1787 wprintf("<EM>%s</EM><br />\n", &buf[4]);
1796 * Confirm move of a message
1798 void confirm_move_msg(void)
1804 msgid = atol(bstr("msgid"));
1806 output_headers(1, 1, 1, 0, 0, 0, 0);
1808 wprintf("<div id=\"fix_scrollbar_bug\">"
1809 "<table width=100%% border=0 bgcolor=\"#444455\"><tr><td>");
1810 wprintf("<font size=+1 color=\"#ffffff\"");
1811 wprintf("<b>Confirm move of message</b>\n");
1812 wprintf("</font></td></tr></table></div>\n");
1814 wprintf("<CENTER>");
1816 wprintf("Move this message to:<br />\n");
1818 wprintf("<form METHOD=\"POST\" ACTION=\"/move_msg\">\n");
1819 wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n",
1823 wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
1825 serv_getln(buf, sizeof buf);
1826 if (buf[0] == '1') {
1827 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1828 extract_token(targ, buf, 0, '|', sizeof targ);
1829 wprintf("<OPTION>");
1834 wprintf("</SELECT>\n");
1835 wprintf("<br />\n");
1837 wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Move\">");
1839 wprintf("<INPUT TYPE=\"submit\" NAME=\"yesno\" VALUE=\"Cancel\">");
1840 wprintf("</form></CENTER>\n");
1842 wprintf("</CENTER>\n");
1853 msgid = atol(bstr("msgid"));
1855 output_headers(1, 1, 1, 0, 0, 0, 0);
1857 if (!strcasecmp(bstr("yesno"), "Move")) {
1858 sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
1860 serv_getln(buf, sizeof buf);
1861 wprintf("<EM>%s</EM><br />\n", &buf[4]);
1863 wprintf("<EM>Message not moved.</EM><br />\n");
1870 * This gets called when a user selects multiple messages in a summary
1871 * list and then clicks to perform a transformation of some sort on them
1872 * (such as deleting them).
1874 void do_stuff_to_msgs(void) {
1879 struct stuff_t *next;
1883 struct stuff_t *stuff = NULL;
1884 struct stuff_t *ptr;
1887 serv_puts("MSGS ALL");
1888 serv_getln(buf, sizeof buf);
1890 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1891 ptr = malloc(sizeof(struct stuff_t));
1892 ptr->msgnum = atol(buf);
1897 strcpy(sc, bstr("sc"));
1899 while (stuff != NULL) {
1901 sprintf(buf, "msg_%ld", stuff->msgnum);
1902 if (!strcasecmp(bstr(buf), "yes")) {
1904 if (!strcasecmp(sc, "Delete selected")) {
1905 serv_printf("DELE %ld", stuff->msgnum);
1906 serv_getln(buf, sizeof buf);
1916 readloop("readfwd");