4 * Citadel/UX message support routines
5 * see copyright.txt for copyright information
11 #include <sys/types.h>
22 #if TIME_WITH_SYS_TIME
23 # include <sys/time.h>
27 # include <sys/time.h>
44 #define MAXWORDBUF SIZ
49 char text[MAXWORDBUF];
52 void sttybbs(int cmd);
53 int haschar(const char *st, int ch);
54 int checkpagin(int lp, int pagin, int height);
55 void getline(char *string, int lim);
56 void formout(char *name);
58 void newprompt(char *prompt, char *str, int len);
59 int file_checksum(char *filename);
60 void do_edit(char *desc, char *read_cmd, char *check_cmd, char *write_cmd);
63 char reply_subject[SIZ];
64 long msg_arr[MAXMSGS];
66 char rc_alt_semantics;
67 extern char room_name[];
68 extern unsigned room_flags;
69 extern long highest_msg_read;
70 extern struct CtdlServInfo serv_info;
73 extern int screenwidth;
74 extern int screenheight;
75 extern long maxmsgnum;
78 extern char is_room_aide;
79 extern char fullname[];
81 extern unsigned userflags;
82 extern char sigcaught;
83 extern char editor_path[];
84 extern char printcmd[];
85 extern int rc_allow_attachments;
86 extern int rc_display_message_numbers;
87 extern int rc_force_mail_prompts;
89 extern int editor_pid;
91 void ka_sigcatch(int signum)
95 signal(SIGALRM, ka_sigcatch);
102 * server keep-alive version of wait() (needed for external editor)
104 pid_t ka_wait(int *kstatus)
109 signal(SIGALRM, ka_sigcatch);
113 } while (errno == EINTR);
114 signal(SIGALRM, SIG_IGN);
121 * version of system() that uses ka_wait()
123 int ka_system(char *shc)
132 perror("Cannot fork");
134 return ((pid_t) childpid);
138 execlp("/bin/sh", "sh", "-c", shc, NULL);
144 waitpid = ka_wait(&retcode);
145 } while (waitpid != childpid);
155 * add a newline to the buffer...
157 void add_newline(struct cittext *textlist)
162 while (ptr->next != NULL)
165 while (ptr->text[strlen(ptr->text) - 1] == 32)
166 ptr->text[strlen(ptr->text) - 1] = 0;
167 /* strcat(ptr->text,"\n"); */
169 ptr->next = (struct cittext *)
170 malloc(sizeof(struct cittext));
173 strcpy(ptr->text, "");
178 * add a word to the buffer...
180 void add_word(struct cittext *textlist, char *wordbuf)
185 while (ptr->next != NULL)
188 if (3 + strlen(ptr->text) + strlen(wordbuf) > screenwidth) {
189 ptr->next = (struct cittext *)
190 malloc(sizeof(struct cittext));
193 strcpy(ptr->text, "");
196 strcat(ptr->text, wordbuf);
197 strcat(ptr->text, " ");
202 * begin editing of an opened file pointed to by fp
204 void citedit(FILE * fp)
206 int a, prev, finished, b, last_space;
208 struct cittext *textlist = NULL;
210 char wordbuf[MAXWORDBUF];
212 /* first, load the text into the buffer */
214 textlist = (struct cittext *) malloc(sizeof(struct cittext));
215 textlist->next = NULL;
216 strcpy(textlist->text, "");
220 while (a = getc(fp), a >= 0) {
222 if ((a == 32) || (a == 9) || (a == 13) || (a == 10)) {
223 add_word(textlist, wordbuf);
225 if ((prev == 13) || (prev == 10)) {
226 add_word(textlist, "\n");
227 add_newline(textlist);
228 add_word(textlist, "");
231 wordbuf[strlen(wordbuf) + 1] = 0;
232 wordbuf[strlen(wordbuf)] = a;
234 if (strlen(wordbuf) + 3 > screenwidth) {
235 add_word(textlist, wordbuf);
243 prev = (appending ? 13 : (-1));
255 /******* new ***********/
256 if ((a > 32) && (a < 127) && (prev == 13)) {
257 add_word(textlist, "\n");
260 /***********************/
262 if ((a == 32) && (prev == 13)) {
263 add_word(textlist, "\n");
264 add_newline(textlist);
268 if (strlen(wordbuf) > 0) {
269 wordbuf[strlen(wordbuf) - 1] = 0;
274 } else if (a == 23) {
276 wordbuf[strlen(wordbuf) - 1] = 0;
280 } while (strlen(wordbuf) && wordbuf[strlen(wordbuf) - 1] != ' ');
281 } else if (a == 13) {
283 if (strlen(wordbuf) == 0)
286 for (b = 0; b < strlen(wordbuf); ++b)
287 if (wordbuf[b] == 32) {
295 add_word(textlist, wordbuf);
300 wordbuf[strlen(wordbuf) + 1] = 0;
301 wordbuf[strlen(wordbuf)] = a;
303 if ((strlen(wordbuf) + 3) > screenwidth) {
305 for (b = 0; b < strlen(wordbuf); ++b)
306 if (wordbuf[b] == 32)
308 if (last_space >= 0) {
309 for (b = 0; b < strlen(wordbuf); ++b)
310 if (wordbuf[b] == 32) {
318 for (b = 0; b < strlen(wordbuf); ++b) {
323 scr_printf("\n%s", wordbuf);
325 add_word(textlist, wordbuf);
331 } while (finished == 0);
334 /* write the buffer back to disk */
336 for (ptr = textlist; ptr != NULL; ptr = ptr->next) {
337 fprintf(fp, "%s", ptr->text);
341 ftruncate(fileno(fp), ftell(fp));
343 /* and deallocate the memory we used */
344 while (textlist != NULL) {
345 ptr = textlist->next;
351 /* Read a message from the server
354 long num, /* message number */
355 char pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */
356 FILE *dest) /* Destination file, NULL for screen */
360 char from[SIZ], node[SIZ], rfca[SIZ];
369 snprintf(buf, sizeof buf, "MSG0 %ld|%d", num, (pagin == READ_HEADER ? 1 : 0));
373 err_printf("*** msg #%ld: %s\n", num, buf);
376 checkpagin(lines_printed, pagin, screenheight);
381 strcpy(m_subject, "");
382 strcpy(reply_to, "nobody ... xxxxx");
388 fprintf(dest, "\n ");
392 lines_printed = checkpagin(lines_printed, pagin, screenheight);
395 if (pagin == 1 && !dest) {
400 while (serv_gets(buf), strcmp(buf, "000")) {
403 fprintf(dest, "%s\n", buf);
405 scr_printf("%s\n", buf);
408 checkpagin(lines_printed,
409 pagin, screenheight);
417 while (serv_gets(buf), strncasecmp(buf, "text", 4)) {
418 if (!strncasecmp(buf, "nhdr=yes", 8))
420 if (!strncasecmp(buf, "from=", 5)) {
421 strcpy(from, &buf[5]);
426 if (!strncasecmp(buf, "type=", 5))
427 format_type = atoi(&buf[5]);
428 else if ((!strncasecmp(buf, "msgn=", 5))
429 && (rc_display_message_numbers)) {
431 fprintf(dest, "[#%s] ", &buf[5]);
436 scr_printf("#%s", &buf[5]);
441 else if (!strncasecmp(buf, "from=", 5)) {
443 fprintf(dest, "from %s ", &buf[5]);
448 scr_printf("%s ", &buf[5]);
451 else if (!strncasecmp(buf, "subj=", 5)) {
452 strcpy(m_subject, &buf[5]);
454 else if (!strncasecmp(buf, "rfca=", 5)) {
455 safestrncpy(rfca, &buf[5], sizeof(rfca) - 5);
457 fprintf(dest, "<%s> ", &buf[5]);
462 scr_printf("%s", &buf[5]);
467 else if ((!strncasecmp(buf, "hnod=", 5))
468 && (strcasecmp(&buf[5], serv_info.serv_humannode))
469 && (strlen(rfca) == 0)) {
471 fprintf(dest, "(%s) ", &buf[5]);
476 scr_printf("%s", &buf[5]);
481 else if ((!strncasecmp(buf, "room=", 5))
482 && (strcasecmp(&buf[5], room_name))
483 && (strlen(rfca) == 0)) {
485 fprintf(dest, "in %s> ", &buf[5]);
489 color(BRIGHT_MAGENTA);
490 scr_printf("%s> ", &buf[5]);
493 else if (!strncasecmp(buf, "node=", 5)) {
494 safestrncpy(node, &buf[5], sizeof(buf) - 5);
495 if ((room_flags & QR_NETWORK)
498 (&buf[5], serv_info.serv_nodename)
500 (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
502 if (strlen(rfca) == 0) {
504 fprintf(dest, "@%s ", &buf[5]);
508 color(BRIGHT_YELLOW);
509 scr_printf("%s ", &buf[5]);
514 else if (!strncasecmp(buf, "rcpt=", 5)) {
516 fprintf(dest, "to %s ", &buf[5]);
521 scr_printf("%s ", &buf[5]);
524 else if (!strncasecmp(buf, "time=", 5)) {
525 fmt_date(now, sizeof now, atol(&buf[5]), 0);
527 fprintf(dest, "%s ", now);
529 scr_printf("%s ", now);
537 fprintf(dest, " ****");
543 fprintf(dest, " %s", from);
545 scr_printf(" %s", from);
555 if (strlen(rfca) > 0) {
556 strcpy(reply_to, rfca);
558 snprintf(reply_to, sizeof(reply_to), "%s @ %s", from,
562 if (pagin == 1 && !dest)
566 lines_printed = checkpagin(lines_printed, pagin, screenheight);
569 strcpy(reply_subject, m_subject);
570 if (strlen(m_subject) > 0) {
572 fprintf(dest, "Subject: %s\n", m_subject);
574 scr_printf("Subject: %s\n", m_subject);
576 lines_printed = checkpagin(lines_printed,
577 pagin, screenheight);
581 if (format_type == 0) {
582 fr = fmout(screenwidth, NULL, dest,
583 ((pagin == 1) ? 1 : 0), screenheight, (-1), 1);
585 while (serv_gets(buf), strcmp(buf, "000")) {
586 if (sigcaught == 0) {
588 fprintf(dest, "%s\n", buf);
590 scr_printf("%s\n", buf);
591 lines_printed = lines_printed + 1 +
592 (strlen(buf) / screenwidth);
594 checkpagin(lines_printed, pagin,
607 lines_printed = checkpagin(lines_printed, pagin, screenheight);
610 if (pagin == 1 && !dest)
617 * replace string function for the built-in editor
619 void replace_string(char *filename, long int startpos)
628 int substitutions = 0;
631 scr_printf("Enter text to be replaced:\n: ");
632 getline(srch_str, 128);
633 if (strlen(srch_str) == 0)
636 scr_printf("Enter text to replace it with:\n: ");
637 getline(rplc_str, 128);
639 fp = fopen(filename, "r+");
644 fseek(fp, startpos, 0);
646 while (a = getc(fp), a > 0) {
648 buf[strlen(buf) + 1] = 0;
649 buf[strlen(buf)] = a;
650 if (strlen(buf) >= strlen(srch_str)) {
651 ptr = (&buf[strlen(buf) - strlen(srch_str)]);
652 if (!strncasecmp(ptr, srch_str, strlen(srch_str))) {
653 strcpy(ptr, rplc_str);
657 if (strlen(buf) > 384) {
660 fwrite((char *) buf, 128, 1, fp);
661 strcpy(buf, &buf[128]);
668 fwrite((char *) buf, strlen(buf), 1, fp);
671 truncate(filename, wpos);
672 scr_printf("<R>eplace made %d substitution(s).\n\n", substitutions);
676 * Function to begin composing a new message
678 int client_make_message(char *filename, /* temporary file name */
679 char *recipient, /* NULL if it's not mail */
680 int anon_type, /* see MES_ types in header file */
683 char *subject) /* buffer to store subject line */
693 if (strlen(editor_path) == 0) {
695 ("*** No editor available, using built-in editor\n");
699 fmt_date(datestr, sizeof datestr, time(NULL), 0);
702 if (room_flags & QR_ANONONLY && !recipient) {
703 snprintf(header, sizeof header, " ****");
706 snprintf(header, sizeof header,
707 " %s from %s", datestr, fullname);
708 if (strlen(recipient) > 0) {
709 size_t tmp = strlen(header);
710 snprintf(&header[tmp], sizeof header - tmp,
711 " to %s", recipient);
714 scr_printf("%s\n", header);
715 if (subject != NULL) if (strlen(subject) > 0) {
716 scr_printf("Subject: %s\n", subject);
722 scr_printf("(Press ctrl-d when finished)\n");
726 fp = fopen(filename, "r");
728 fmout(screenwidth, fp, NULL, 0, screenheight, 0, 0);
732 fp = fopen(filename, "w");
734 err_printf("*** Error opening temp file!\n"
736 filename, strerror(errno));
746 fp = fopen(filename, "r+");
748 err_printf("*** Error opening temp file!\n"
750 filename, strerror(errno));
758 fp = fopen(filename, "a");
760 err_printf("*** Error opening temp file!\n"
762 filename, strerror(errno));
782 e_ex_code = 1; /* start with a failed exit code */
784 cksum = file_checksum(filename);
785 if (editor_pid == 0) {
788 chmod(filename, 0600);
791 snprintf(tmp, sizeof tmp, "WINDOW_TITLE=%s", header);
793 execlp(editor_path, editor_path, filename, NULL);
799 b = ka_wait(&e_ex_code);
800 } while ((b != editor_pid) && (b >= 0));
807 MECR: if (mode == 2) {
808 if (file_checksum(filename) == cksum) {
809 err_printf("*** Aborted message.\n");
817 b = keymenu("Entry command (? for options)",
818 "<A>bort|<C>ontinue|<S>ave message|<P>rint formatted|"
820 "<R>eplace string|<H>old message");
829 scr_printf(" %s from %s", datestr, fullname);
830 if (strlen(recipient) > 0)
831 scr_printf(" to %s", recipient);
833 if (subject != NULL) if (strlen(subject) > 0) {
834 scr_printf("Subject: %s\n", subject);
836 fp = fopen(filename, "r");
838 fmout(screenwidth, fp, NULL,
839 ((userflags & US_PAGINATOR) ? 1 : 0),
847 replace_string(filename, 0L);
854 if (subject != NULL) {
855 newprompt("Subject: ", subject, 70);
862 MEABT: scr_printf("Are you sure? ");
866 MEABT2: unlink(filename);
871 * Transmit message text to the server.
873 * This loop also implements a "tick" counter that displays the progress, if
874 * we're sending something that will take a long time to transmit.
876 void transmit_message(FILE *fp)
883 fseek(fp, 0L, SEEK_END);
886 lasttick = time(NULL);
888 while (ch = getc(fp), (ch >= 0)) {
890 if (!strcmp(buf, "000"))
898 if ((ch == 32) && (strlen(buf) > 200)) {
900 if (!strcmp(buf, "000"))
905 if (strlen(buf) > 250) {
906 if (!strcmp(buf, "000"))
913 if ((time(NULL) - lasttick) > 2L) {
914 scr_printf(" %3ld%% completed\r",
915 ((ftell(fp) * 100L) / msglen));
917 lasttick = time(NULL);
929 * entmsg() - edit and create a message
930 * returns 0 if message was saved
932 int entmsg(int is_reply, /* nonzero if this was a <R>eply command */
952 * First, check to see if we have permission to enter a message in
953 * this room. The server will return an error code if we can't.
955 snprintf(cmd, sizeof cmd, "ENT0 0||0|%d", mode);
959 if ((strncmp(cmd, "570", 3)) && (strncmp(cmd, "200", 3))) {
960 scr_printf("%s\n", &cmd[4]);
964 /* Error code 570 is special. It means that we CAN enter a message
965 * in this room, but a recipient needs to be specified.
968 if (!strncmp(cmd, "570", 3))
971 /* If the user is a dumbass, tell them how to type. */
972 if ((userflags & US_EXPERT) == 0) {
976 /* Handle the selection of a recipient, if necessary. */
978 if (need_recp == 1) {
981 strcpy(buf, reply_to);
983 scr_printf("Enter recipient: ");
984 getline(buf, (SIZ-100) );
985 if (strlen(buf) == 0)
989 strcpy(buf, "sysop");
993 if (strlen(reply_subject) > 0) {
994 if (!strncasecmp(reply_subject,
996 strcpy(subject, reply_subject);
1008 if (room_flags & QR_ANONOPT) {
1009 scr_printf("Anonymous (Y/N)? ");
1014 /* If it's mail, we've got to check the validity of the recipient... */
1015 if (strlen(buf) > 0) {
1016 snprintf(cmd, sizeof cmd, "ENT0 0|%s|%d|%d|%s", buf, b, mode, subject);
1019 if (cmd[0] != '2') {
1020 scr_printf("%s\n", &cmd[4]);
1025 /* Learn the number of the newest message in in the room, so we can
1026 * tell upon saving whether someone else has posted too.
1029 serv_puts("MSGS LAST|1");
1031 if (cmd[0] != '1') {
1032 scr_printf("%s\n", &cmd[5]);
1034 while (serv_gets(cmd), strcmp(cmd, "000")) {
1035 msg_arr[num_msgs++] = atol(cmd);
1039 /* Now compose the message... */
1040 if (client_make_message(temp, buf, b, 0, c, subject) != 0) {
1044 /* Reopen the temp file that was created, so we can send it */
1045 fp = fopen(temp, "r");
1047 /* Yes, unlink it now, so it doesn't stick around if we crash */
1051 err_printf("*** Internal error while trying to save message!\n"
1053 temp, strerror(errno));
1057 /* Transmit message to the server */
1058 snprintf(cmd, sizeof cmd, "ENT0 1|%s|%d|%d|%s|", buf, b, mode, subject);
1061 if (cmd[0] != '4') {
1062 scr_printf("%s\n", &cmd[4]);
1066 transmit_message(fp);
1071 highmsg = msg_arr[num_msgs - 1];
1073 serv_puts("MSGS NEW");
1075 if (cmd[0] != '1') {
1076 scr_printf("%s\n", &cmd[5]);
1078 while (serv_gets(cmd), strcmp(cmd, "000")) {
1079 msg_arr[num_msgs++] = atol(cmd);
1083 /* get new highest message number in room to set lrp for goto... */
1084 maxmsgnum = msg_arr[num_msgs - 1];
1086 /* now see if anyone else has posted in here */
1088 for (a = 0; a < num_msgs; ++a) {
1089 if (msg_arr[a] > highmsg) {
1094 /* In the Mail> room, this algorithm always counts one message
1095 * higher than in public rooms, so we decrement it by one.
1102 scr_printf("*** 1 additional message has been entered "
1103 "in this room by another user.\n");
1106 scr_printf("*** %d additional messages have been entered "
1107 "in this room by other users.\n", b);
1114 * Do editing on a quoted file
1116 void process_quote(void)
1118 FILE *qfile, *tfile;
1120 int line, qstart, qend;
1122 /* Unlink the second temp file as soon as it's opened, so it'll get
1123 * deleted even if the program dies
1125 qfile = fopen(temp2, "r");
1128 /* Display the quotable text with line numbers added */
1130 fgets(buf, 128, qfile);
1131 while (fgets(buf, 128, qfile) != NULL) {
1132 scr_printf("%2d %s", ++line, buf);
1134 scr_printf("Begin quoting at [ 1] : ");
1136 qstart = (buf[0] == 0) ? (1) : atoi(buf);
1137 scr_printf(" End quoting at [%d] : ", line);
1139 qend = (buf[0] == 0) ? (line) : atoi(buf);
1142 fgets(buf, 128, qfile);
1143 tfile = fopen(temp, "w");
1144 while (fgets(buf, 128, qfile) != NULL) {
1145 if ((++line >= qstart) && (line <= qend))
1146 fprintf(tfile, " >%s", buf);
1148 fprintf(tfile, " \n");
1157 * List the URL's which were embedded in the previous message
1164 if (num_urls == 0) {
1165 scr_printf("There were no URL's in the previous message.\n\n");
1169 for (i = 0; i < num_urls; ++i) {
1170 scr_printf("%3d %s\n", i + 1, urls[i]);
1173 if ((i = num_urls) != 1)
1174 i = intprompt("Display which one", 1, 1, num_urls);
1176 snprintf(cmd, sizeof cmd, rc_url_cmd, urls[i - 1]);
1182 * Read the messages in the current room
1185 int c, /* 0=Read all 1=Read new 2=Read old 3=Read last q */
1186 int rdir, /* 1=Forward (-1)=Reverse */
1187 int q /* Number of msgs to read (if c==3) */
1189 int a, b, e, f, g, start;
1195 char prtfile[PATH_MAX];
1198 char targ[ROOMNAMELEN];
1200 FILE *dest = NULL; /* Alternate destination other than screen */
1207 strcpy(prtfile, tmpnam(NULL));
1210 strcpy(cmd, "MSGS ");
1222 snprintf(&cmd[5], sizeof cmd - 5, "LAST|%d", q);
1227 if (cmd[0] != '1') {
1228 scr_printf("%s\n", &cmd[5]);
1230 while (serv_gets(cmd), strcmp(cmd, "000")) {
1231 if (num_msgs == MAXMSGS) {
1232 memcpy(&msg_arr[0], &msg_arr[1],
1233 (sizeof(long) * (MAXMSGS - 1)));
1236 msg_arr[num_msgs++] = atol(cmd);
1240 if (num_msgs == 0) {
1242 scr_printf("*** There are no ");
1243 if (c == 1) scr_printf("new ");
1244 if (c == 2) scr_printf("old ");
1245 scr_printf("messages in this room.\n");
1251 /* this loop cycles through each message... */
1252 start = ((rdir == 1) ? 0 : (num_msgs - 1));
1253 for (a = start; ((a < num_msgs) && (a >= 0)); a = a + rdir) {
1254 while (msg_arr[a] == 0L) {
1256 if ((a == MAXMSGS) || (a == (-1)))
1260 RAGAIN: pagin = ((arcflag == 0)
1262 && (userflags & US_PAGINATOR)) ? 1 : 0;
1264 /* If we're doing a quote, set the screenwidth to 72 */
1266 hold_sw = screenwidth;
1270 /* If printing or archiving, set the screenwidth to 80 */
1272 hold_sw = screenwidth;
1276 /* now read the message... */
1277 e = read_message(msg_arr[a], pagin, dest);
1279 /* ...and set the screenwidth back if we have to */
1280 if ((quotflag) || (arcflag)) {
1281 screenwidth = hold_sw;
1283 RMSGREAD: scr_flush();
1284 highest_msg_read = msg_arr[a];
1289 enable_color = hold_color;
1296 enable_color = hold_color;
1299 freopen(prtfile, "r", stdin);
1301 sttybbs(SB_RESTORE);
1302 ka_system(printcmd);
1303 sttybbs(SB_NO_INTR);
1311 } while ((g != f) && (g >= 0));
1312 scr_printf("Message printed.\n");
1314 if (rc_alt_semantics && c == 1) {
1317 snprintf(buf, sizeof(buf), "SEEN %ld", msg_arr[a]);
1319 serv_gets(buf); /* Don't need to check this? */
1323 if (((userflags & US_NOPROMPT) || (e == 2))
1324 && (((room_flags & QR_MAILBOX) == 0)
1325 || (rc_force_mail_prompts == 0))) {
1330 color(BRIGHT_WHITE);
1331 scr_printf("%d", num_msgs - a - 1);
1335 keyopt("<B>ack <A>gain <Q>uote <R>eply <N>ext <S>top m<Y> next ");
1336 if (rc_url_cmd[0] && num_urls)
1337 keyopt("<U>RLview ");
1338 keyopt("<?>help -> ");
1342 e = (inkey() & 127);
1344 /* return key same as <N> */ if (e == 10)
1346 /* space key same as <N> */ if (e == 32)
1348 /* del/move for aides only */
1350 && ((room_flags & QR_MAILBOX) ==
1352 if ((e == 'd') || (e == 'm'))
1355 /* print only if available */
1356 if ((e == 'p') && (strlen(printcmd) == 0))
1358 /* can't file if not allowed */
1360 && (rc_allow_attachments == 0))
1362 /* link only if browser avail*/
1364 && (strlen(rc_url_cmd) == 0))
1366 } while ((e != 'a') && (e != 'n') && (e != 's')
1367 && (e != 'd') && (e != 'm') && (e != 'p')
1368 && (e != 'q') && (e != 'b') && (e != 'h')
1369 && (e != 'r') && (e != 'f') && (e != '?')
1370 && (e != 'u') && (e != 'c') && (e != 'y'));
1376 scr_printf("Again");
1379 scr_printf("Delete");
1391 scr_printf("Print");
1394 scr_printf("Quote");
1400 scr_printf("Header");
1403 scr_printf("Reply");
1409 scr_printf("URL's");
1412 scr_printf("mY next");
1415 scr_printf("? <help>");
1418 if (userflags & US_DISAPPEAR)
1419 scr_printf("\r%79s\r", "");
1426 scr_printf("Options available here:\n"
1427 " ? Help (prints this message)\n"
1428 " S Stop reading immediately\n"
1429 " A Again (repeats last message)\n"
1430 " N Next (continue with next message)\n"
1431 " Y My Next (continue with next message you authored)\n"
1432 " B Back (go back to previous message)\n");
1434 || (room_flags & QR_MAILBOX)) {
1435 scr_printf(" D Delete this message\n"
1436 " M Move message to another room\n");
1438 scr_printf(" C Copy message to another room\n");
1439 if (strlen(printcmd) > 0)
1440 scr_printf(" P Print this message\n");
1442 " Q Quote portions of this message for your next post\n"
1443 " H Headers (display message headers only)\n");
1445 scr_printf(" R Reply to this message\n");
1446 if (rc_allow_attachments)
1448 (" F (save attachments to a file)\n");
1449 if (strlen(rc_url_cmd) > 0)
1450 scr_printf(" U (list URL's for display)\n");
1455 dest = fopen(prtfile, "w");
1457 hold_color = enable_color;
1462 dest = fopen(temp2, "w");
1464 hold_color = enable_color;
1476 newprompt("Enter target room: ",
1477 targ, ROOMNAMELEN - 1);
1478 if (strlen(targ) > 0) {
1479 snprintf(cmd, sizeof cmd, "MOVE %ld|%s|%d",
1481 (e == 'c' ? 1 : 0));
1484 scr_printf("%s\n", &cmd[4]);
1494 newprompt("Which section? ", filename,
1495 ((sizeof filename) - 1));
1496 snprintf(cmd, sizeof cmd,
1497 "OPNA %ld|%s", msg_arr[a], filename);
1500 if (cmd[0] == '2') {
1501 extract(filename, &cmd[4], 2);
1502 download_to_local_disk(filename,
1503 extract_int(&cmd[4],
1506 scr_printf("%s\n", &cmd[4]);
1510 scr_printf("*** Delete this message? ");
1512 snprintf(cmd, sizeof cmd, "DELE %ld", msg_arr[a]);
1515 scr_printf("%s\n", &cmd[4]);
1523 read_message(msg_arr[a], READ_HEADER, NULL);
1526 savedpos = num_msgs;
1527 entmsg(1, (DEFAULT_ENTRY == 46 ? 2 : 0));
1528 num_msgs = savedpos;
1534 { /* hack hack hack */
1535 /* find the next message by me, stay here if we find nothing */
1538 for (finda = a; ((finda < num_msgs) && (finda >= 0)); finda += rdir)
1540 /* this is repetitivly dumb, but that's what computers are for.
1541 We have to load up messages until we find one by us */
1545 snprintf(buf, sizeof buf, "MSG0 %ld|%d", msg_arr[finda], 1); /* read the header so we can get 'from=' */
1548 while (serv_gets(buf), strcmp(buf, "000"))
1550 if ((!strncasecmp(buf, "from=", 5)) && (finda != a)) /* Skip current message. */
1552 if (strcasecmp(buf+5, fullname) == 0)
1554 a = lasta; /* meesa current */
1559 // we are now in synch with the server
1562 lasta = finda; /* keep one behind or we skip on the reentrance to the for */
1566 } /* end for loop */
1567 } /* end read routine */
1573 * View and edit a system message
1575 void edit_system_message(char *which_message)
1581 snprintf(desc, sizeof desc, "system message '%s'", which_message);
1582 snprintf(read_cmd, sizeof read_cmd, "MESG %s", which_message);
1583 snprintf(write_cmd, sizeof write_cmd, "EMSG %s", which_message);
1584 do_edit(desc, read_cmd, "NOOP", write_cmd);
1591 * Verify the message base
1593 void check_message_base(void)
1598 ("Please read the documentation before running this command.\n"
1599 "Having done so, do you still want to check the message base? ");
1605 if (buf[0] != '1') {
1606 scr_printf("%s\n", &buf[4]);
1610 while (serv_gets(buf), strcmp(buf, "000")) {
1611 scr_printf("%s\n", buf);