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(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 == 13) {
276 if (strlen(wordbuf) == 0)
279 for (b = 0; b < strlen(wordbuf); ++b)
280 if (wordbuf[b] == 32) {
288 add_word(textlist, wordbuf);
293 wordbuf[strlen(wordbuf) + 1] = 0;
294 wordbuf[strlen(wordbuf)] = a;
296 if ((strlen(wordbuf) + 3) > screenwidth) {
298 for (b = 0; b < strlen(wordbuf); ++b)
299 if (wordbuf[b] == 32)
301 if (last_space >= 0) {
302 for (b = 0; b < strlen(wordbuf); ++b)
303 if (wordbuf[b] == 32) {
311 for (b = 0; b < strlen(wordbuf); ++b) {
316 scr_printf("\n%s", wordbuf);
318 add_word(textlist, wordbuf);
324 } while (finished == 0);
327 /* write the buffer back to disk */
329 for (ptr = textlist; ptr != NULL; ptr = ptr->next) {
330 fprintf(fp, "%s", ptr->text);
334 ftruncate(fileno(fp), ftell(fp));
336 /* and deallocate the memory we used */
337 while (textlist != NULL) {
338 ptr = textlist->next;
344 /* Read a message from the server
347 long num, /* message number */
348 char pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */
349 FILE *dest) /* Destination file, NULL for screen */
353 char from[SIZ], node[SIZ], rfca[SIZ];
362 snprintf(buf, sizeof buf, "MSG0 %ld|%d", num, (pagin == READ_HEADER ? 1 : 0));
366 err_printf("*** msg #%ld: %s\n", num, buf);
369 checkpagin(lines_printed, pagin, screenheight);
374 strcpy(m_subject, "");
375 strcpy(reply_to, "nobody ... xxxxx");
381 fprintf(dest, "\n ");
385 lines_printed = checkpagin(lines_printed, pagin, screenheight);
388 if (pagin == 1 && !dest) {
393 while (serv_gets(buf), strcmp(buf, "000")) {
396 fprintf(dest, "%s\n", buf);
398 scr_printf("%s\n", buf);
401 checkpagin(lines_printed,
402 pagin, screenheight);
410 while (serv_gets(buf), strncasecmp(buf, "text", 4)) {
411 if (!strncasecmp(buf, "nhdr=yes", 8))
413 if (!strncasecmp(buf, "from=", 5)) {
414 strcpy(from, &buf[5]);
419 if (!strncasecmp(buf, "type=", 5))
420 format_type = atoi(&buf[5]);
421 else if ((!strncasecmp(buf, "msgn=", 5))
422 && (rc_display_message_numbers)) {
424 fprintf(dest, "[#%s] ", &buf[5]);
429 scr_printf("#%s", &buf[5]);
434 else if (!strncasecmp(buf, "from=", 5)) {
436 fprintf(dest, "from %s ", &buf[5]);
441 scr_printf("%s ", &buf[5]);
444 else if (!strncasecmp(buf, "subj=", 5)) {
445 strcpy(m_subject, &buf[5]);
447 else if (!strncasecmp(buf, "rfca=", 5)) {
448 safestrncpy(rfca, &buf[5], sizeof(rfca) - 5);
450 fprintf(dest, "<%s> ", &buf[5]);
455 scr_printf("%s", &buf[5]);
460 else if ((!strncasecmp(buf, "hnod=", 5))
461 && (strcasecmp(&buf[5], serv_info.serv_humannode))
462 && (strlen(rfca) == 0)) {
464 fprintf(dest, "(%s) ", &buf[5]);
469 scr_printf("%s", &buf[5]);
474 else if ((!strncasecmp(buf, "room=", 5))
475 && (strcasecmp(&buf[5], room_name))
476 && (strlen(rfca) == 0)) {
478 fprintf(dest, "in %s> ", &buf[5]);
482 color(BRIGHT_MAGENTA);
483 scr_printf("%s> ", &buf[5]);
486 else if (!strncasecmp(buf, "node=", 5)) {
487 safestrncpy(node, &buf[5], sizeof(buf) - 5);
488 if ((room_flags & QR_NETWORK)
491 (&buf[5], serv_info.serv_nodename)
493 (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
495 if (strlen(rfca) == 0) {
497 fprintf(dest, "@%s ", &buf[5]);
501 color(BRIGHT_YELLOW);
502 scr_printf("%s ", &buf[5]);
507 else if (!strncasecmp(buf, "rcpt=", 5)) {
509 fprintf(dest, "to %s ", &buf[5]);
514 scr_printf("%s ", &buf[5]);
517 else if (!strncasecmp(buf, "time=", 5)) {
518 fmt_date(now, atol(&buf[5]), 0);
520 fprintf(dest, "%s ", now);
522 scr_printf("%s ", now);
530 fprintf(dest, " ****");
536 fprintf(dest, " %s", from);
538 scr_printf(" %s", from);
548 if (strlen(rfca) > 0) {
549 strcpy(reply_to, rfca);
551 snprintf(reply_to, sizeof(reply_to), "%s @ %s", from,
555 if (pagin == 1 && !dest)
559 lines_printed = checkpagin(lines_printed, pagin, screenheight);
562 strcpy(reply_subject, m_subject);
563 if (strlen(m_subject) > 0) {
565 fprintf(dest, "Subject: %s\n", m_subject);
567 scr_printf("Subject: %s\n", m_subject);
569 lines_printed = checkpagin(lines_printed,
570 pagin, screenheight);
574 if (format_type == 0) {
575 fr = fmout(screenwidth, NULL, dest,
576 ((pagin == 1) ? 1 : 0), screenheight, (-1), 1);
578 while (serv_gets(buf), strcmp(buf, "000")) {
579 if (sigcaught == 0) {
581 fprintf(dest, "%s\n", buf);
583 scr_printf("%s\n", buf);
584 lines_printed = lines_printed + 1 +
585 (strlen(buf) / screenwidth);
587 checkpagin(lines_printed, pagin,
600 lines_printed = checkpagin(lines_printed, pagin, screenheight);
603 if (pagin == 1 && !dest)
610 * replace string function for the built-in editor
612 void replace_string(char *filename, long int startpos)
621 int substitutions = 0;
624 scr_printf("Enter text to be replaced:\n: ");
625 getline(srch_str, 128);
626 if (strlen(srch_str) == 0)
629 scr_printf("Enter text to replace it with:\n: ");
630 getline(rplc_str, 128);
632 fp = fopen(filename, "r+");
637 fseek(fp, startpos, 0);
639 while (a = getc(fp), a > 0) {
641 buf[strlen(buf) + 1] = 0;
642 buf[strlen(buf)] = a;
643 if (strlen(buf) >= strlen(srch_str)) {
644 ptr = (&buf[strlen(buf) - strlen(srch_str)]);
645 if (!strncasecmp(ptr, srch_str, strlen(srch_str))) {
646 strcpy(ptr, rplc_str);
650 if (strlen(buf) > 384) {
653 fwrite((char *) buf, 128, 1, fp);
654 strcpy(buf, &buf[128]);
661 fwrite((char *) buf, strlen(buf), 1, fp);
664 truncate(filename, wpos);
665 scr_printf("<R>eplace made %d substitution(s).\n\n", substitutions);
669 * Function to begin composing a new message
671 int client_make_message(char *filename, /* temporary file name */
672 char *recipient, /* NULL if it's not mail */
673 int anon_type, /* see MES_ types in header file */
676 char *subject) /* buffer to store subject line */
686 if (strlen(editor_path) == 0) {
688 ("*** No editor available, using built-in editor\n");
692 fmt_date(datestr, time(NULL), 0);
695 if (room_flags & QR_ANONONLY && !recipient) {
696 snprintf(header, sizeof header, " ****");
699 snprintf(header, sizeof header,
700 " %s from %s", datestr, fullname);
701 if (strlen(recipient) > 0) {
702 size_t tmp = strlen(header);
703 snprintf(&header[tmp], sizeof header - tmp,
704 " to %s", recipient);
707 scr_printf("%s\n", header);
708 if (subject != NULL) if (strlen(subject) > 0) {
709 scr_printf("Subject: %s\n", subject);
715 scr_printf("(Press ctrl-d when finished)\n");
719 fp = fopen(filename, "r");
721 fmout(screenwidth, fp, NULL, 0, screenheight, 0, 0);
725 fp = fopen(filename, "w");
727 err_printf("*** Error opening temp file!\n"
729 filename, strerror(errno));
739 fp = fopen(filename, "r+");
741 err_printf("*** Error opening temp file!\n"
743 filename, strerror(errno));
751 fp = fopen(filename, "a");
753 err_printf("*** Error opening temp file!\n"
755 filename, strerror(errno));
775 e_ex_code = 1; /* start with a failed exit code */
777 cksum = file_checksum(filename);
778 if (editor_pid == 0) {
781 chmod(filename, 0600);
784 snprintf(tmp, sizeof tmp, "WINDOW_TITLE=%s", header);
786 execlp(editor_path, editor_path, filename, NULL);
792 b = ka_wait(&e_ex_code);
793 } while ((b != editor_pid) && (b >= 0));
800 MECR: if (mode == 2) {
801 if (file_checksum(filename) == cksum) {
802 err_printf("*** Aborted message.\n");
810 b = keymenu("Entry command (? for options)",
811 "<A>bort|<C>ontinue|<S>ave message|<P>rint formatted|"
813 "<R>eplace string|<H>old message");
822 scr_printf(" %s from %s", datestr, fullname);
823 if (strlen(recipient) > 0)
824 scr_printf(" to %s", recipient);
826 if (subject != NULL) if (strlen(subject) > 0) {
827 scr_printf("Subject: %s\n", subject);
829 fp = fopen(filename, "r");
831 fmout(screenwidth, fp, NULL,
832 ((userflags & US_PAGINATOR) ? 1 : 0),
840 replace_string(filename, 0L);
847 if (subject != NULL) {
848 newprompt("Subject: ", subject, 70);
855 MEABT: scr_printf("Are you sure? ");
859 MEABT2: unlink(filename);
864 * Transmit message text to the server.
866 * This loop also implements a "tick" counter that displays the progress, if
867 * we're sending something that will take a long time to transmit.
869 void transmit_message(FILE *fp)
876 fseek(fp, 0L, SEEK_END);
879 lasttick = time(NULL);
881 while (ch = getc(fp), (ch >= 0)) {
883 if (!strcmp(buf, "000"))
891 if ((ch == 32) && (strlen(buf) > 200)) {
893 if (!strcmp(buf, "000"))
898 if (strlen(buf) > 250) {
899 if (!strcmp(buf, "000"))
906 if ((time(NULL) - lasttick) > 2L) {
907 scr_printf(" %3ld%% completed\r",
908 ((ftell(fp) * 100L) / msglen));
910 lasttick = time(NULL);
922 * entmsg() - edit and create a message
923 * returns 0 if message was saved
925 int entmsg(int is_reply, /* nonzero if this was a <R>eply command */
945 * First, check to see if we have permission to enter a message in
946 * this room. The server will return an error code if we can't.
948 snprintf(cmd, sizeof cmd, "ENT0 0||0|%d", mode);
952 if ((strncmp(cmd, "570", 3)) && (strncmp(cmd, "200", 3))) {
953 scr_printf("%s\n", &cmd[4]);
957 /* Error code 570 is special. It means that we CAN enter a message
958 * in this room, but a recipient needs to be specified.
961 if (!strncmp(cmd, "570", 3))
964 /* If the user is a dumbass, tell them how to type. */
965 if ((userflags & US_EXPERT) == 0) {
969 /* Handle the selection of a recipient, if necessary. */
971 if (need_recp == 1) {
974 strcpy(buf, reply_to);
976 scr_printf("Enter recipient: ");
977 getline(buf, (SIZ-100) );
978 if (strlen(buf) == 0)
982 strcpy(buf, "sysop");
986 if (strlen(reply_subject) > 0) {
987 if (!strncasecmp(reply_subject,
989 strcpy(subject, reply_subject);
1001 if (room_flags & QR_ANONOPT) {
1002 scr_printf("Anonymous (Y/N)? ");
1007 /* If it's mail, we've got to check the validity of the recipient... */
1008 if (strlen(buf) > 0) {
1009 snprintf(cmd, sizeof cmd, "ENT0 0|%s|%d|%d|%s", buf, b, mode, subject);
1012 if (cmd[0] != '2') {
1013 scr_printf("%s\n", &cmd[4]);
1018 /* Learn the number of the newest message in in the room, so we can
1019 * tell upon saving whether someone else has posted too.
1022 serv_puts("MSGS LAST|1");
1024 if (cmd[0] != '1') {
1025 scr_printf("%s\n", &cmd[5]);
1027 while (serv_gets(cmd), strcmp(cmd, "000")) {
1028 msg_arr[num_msgs++] = atol(cmd);
1032 /* Now compose the message... */
1033 if (client_make_message(temp, buf, b, 0, c, subject) != 0) {
1037 /* Reopen the temp file that was created, so we can send it */
1038 fp = fopen(temp, "r");
1040 /* Yes, unlink it now, so it doesn't stick around if we crash */
1044 err_printf("*** Internal error while trying to save message!\n"
1046 temp, strerror(errno));
1050 /* Transmit message to the server */
1051 snprintf(cmd, sizeof cmd, "ENT0 1|%s|%d|%d|%s|", buf, b, mode, subject);
1054 if (cmd[0] != '4') {
1055 scr_printf("%s\n", &cmd[4]);
1059 transmit_message(fp);
1064 highmsg = msg_arr[num_msgs - 1];
1066 serv_puts("MSGS NEW");
1068 if (cmd[0] != '1') {
1069 scr_printf("%s\n", &cmd[5]);
1071 while (serv_gets(cmd), strcmp(cmd, "000")) {
1072 msg_arr[num_msgs++] = atol(cmd);
1076 /* get new highest message number in room to set lrp for goto... */
1077 maxmsgnum = msg_arr[num_msgs - 1];
1079 /* now see if anyone else has posted in here */
1081 for (a = 0; a < num_msgs; ++a) {
1082 if (msg_arr[a] > highmsg) {
1087 /* In the Mail> room, this algorithm always counts one message
1088 * higher than in public rooms, so we decrement it by one.
1095 scr_printf("*** 1 additional message has been entered "
1096 "in this room by another user.\n");
1099 scr_printf("*** %d additional messages have been entered "
1100 "in this room by other users.\n", b);
1107 * Do editing on a quoted file
1109 void process_quote(void)
1111 FILE *qfile, *tfile;
1113 int line, qstart, qend;
1115 /* Unlink the second temp file as soon as it's opened, so it'll get
1116 * deleted even if the program dies
1118 qfile = fopen(temp2, "r");
1121 /* Display the quotable text with line numbers added */
1123 fgets(buf, 128, qfile);
1124 while (fgets(buf, 128, qfile) != NULL) {
1125 scr_printf("%2d %s", ++line, buf);
1127 scr_printf("Begin quoting at [ 1] : ");
1129 qstart = (buf[0] == 0) ? (1) : atoi(buf);
1130 scr_printf(" End quoting at [%d] : ", line);
1132 qend = (buf[0] == 0) ? (line) : atoi(buf);
1135 fgets(buf, 128, qfile);
1136 tfile = fopen(temp, "w");
1137 while (fgets(buf, 128, qfile) != NULL) {
1138 if ((++line >= qstart) && (line <= qend))
1139 fprintf(tfile, " >%s", buf);
1141 fprintf(tfile, " \n");
1150 * List the URL's which were embedded in the previous message
1157 if (num_urls == 0) {
1158 scr_printf("There were no URL's in the previous message.\n\n");
1162 for (i = 0; i < num_urls; ++i) {
1163 scr_printf("%3d %s\n", i + 1, urls[i]);
1166 if ((i = num_urls) != 1)
1167 i = intprompt("Display which one", 1, 1, num_urls);
1169 snprintf(cmd, sizeof cmd, rc_url_cmd, urls[i - 1]);
1175 * Read the messages in the current room
1178 int c, /* 0=Read all 1=Read new 2=Read old 3=Read last q */
1179 int rdir, /* 1=Forward (-1)=Reverse */
1180 int q /* Number of msgs to read (if c==3) */
1182 int a, b, e, f, g, start;
1188 char prtfile[PATH_MAX];
1191 char targ[ROOMNAMELEN];
1193 FILE *dest = NULL; /* Alternate destination other than screen */
1200 strcpy(prtfile, tmpnam(NULL));
1203 strcpy(cmd, "MSGS ");
1215 snprintf(&cmd[5], sizeof cmd - 5, "LAST|%d", q);
1220 if (cmd[0] != '1') {
1221 scr_printf("%s\n", &cmd[5]);
1223 while (serv_gets(cmd), strcmp(cmd, "000")) {
1224 if (num_msgs == MAXMSGS) {
1225 memcpy(&msg_arr[0], &msg_arr[1],
1226 (sizeof(long) * (MAXMSGS - 1)));
1229 msg_arr[num_msgs++] = atol(cmd);
1233 if (num_msgs == 0) {
1235 scr_printf("*** There are no ");
1236 if (c == 1) scr_printf("new ");
1237 if (c == 2) scr_printf("old ");
1238 scr_printf("messages in this room.\n");
1244 /* this loop cycles through each message... */
1245 start = ((rdir == 1) ? 0 : (num_msgs - 1));
1246 for (a = start; ((a < num_msgs) && (a >= 0)); a = a + rdir) {
1247 while (msg_arr[a] == 0L) {
1249 if ((a == MAXMSGS) || (a == (-1)))
1253 RAGAIN: pagin = ((arcflag == 0)
1255 && (userflags & US_PAGINATOR)) ? 1 : 0;
1257 /* If we're doing a quote, set the screenwidth to 72 */
1259 hold_sw = screenwidth;
1263 /* If printing or archiving, set the screenwidth to 80 */
1265 hold_sw = screenwidth;
1269 /* now read the message... */
1270 e = read_message(msg_arr[a], pagin, dest);
1272 /* ...and set the screenwidth back if we have to */
1273 if ((quotflag) || (arcflag)) {
1274 screenwidth = hold_sw;
1276 RMSGREAD: scr_flush();
1277 highest_msg_read = msg_arr[a];
1282 enable_color = hold_color;
1289 enable_color = hold_color;
1292 freopen(prtfile, "r", stdin);
1294 sttybbs(SB_RESTORE);
1295 ka_system(printcmd);
1296 sttybbs(SB_NO_INTR);
1304 } while ((g != f) && (g >= 0));
1305 scr_printf("Message printed.\n");
1307 if (rc_alt_semantics && c == 1) {
1310 snprintf(buf, sizeof(buf), "SEEN %ld", msg_arr[a]);
1312 serv_gets(buf); /* Don't need to check this? */
1316 if (((userflags & US_NOPROMPT) || (e == 2))
1317 && (((room_flags & QR_MAILBOX) == 0)
1318 || (rc_force_mail_prompts == 0))) {
1323 color(BRIGHT_WHITE);
1324 scr_printf("%d", num_msgs - a - 1);
1328 keyopt("<B>ack <A>gain <Q>uote <R>eply <N>ext <S>top m<Y> next ");
1329 if (rc_url_cmd[0] && num_urls)
1330 keyopt("<U>RLview ");
1331 keyopt("<?>help -> ");
1335 e = (inkey() & 127);
1337 /* return key same as <N> */ if (e == 10)
1339 /* space key same as <N> */ if (e == 32)
1341 /* del/move for aides only */
1343 && ((room_flags & QR_MAILBOX) ==
1345 if ((e == 'd') || (e == 'm'))
1348 /* print only if available */
1349 if ((e == 'p') && (strlen(printcmd) == 0))
1351 /* can't file if not allowed */
1353 && (rc_allow_attachments == 0))
1355 /* link only if browser avail*/
1357 && (strlen(rc_url_cmd) == 0))
1359 } while ((e != 'a') && (e != 'n') && (e != 's')
1360 && (e != 'd') && (e != 'm') && (e != 'p')
1361 && (e != 'q') && (e != 'b') && (e != 'h')
1362 && (e != 'r') && (e != 'f') && (e != '?')
1363 && (e != 'u') && (e != 'c') && (e != 'y'));
1369 scr_printf("Again");
1372 scr_printf("Delete");
1384 scr_printf("Print");
1387 scr_printf("Quote");
1393 scr_printf("Header");
1396 scr_printf("Reply");
1402 scr_printf("URL's");
1405 scr_printf("mY next");
1408 scr_printf("? <help>");
1411 if (userflags & US_DISAPPEAR)
1412 scr_printf("\r%79s\r", "");
1419 scr_printf("Options available here:\n"
1420 " ? Help (prints this message)\n"
1421 " S Stop reading immediately\n"
1422 " A Again (repeats last message)\n"
1423 " N Next (continue with next message)\n"
1424 " Y My Next (continue with next message you authored)\n"
1425 " B Back (go back to previous message)\n");
1427 || (room_flags & QR_MAILBOX)) {
1428 scr_printf(" D Delete this message\n"
1429 " M Move message to another room\n");
1431 scr_printf(" C Copy message to another room\n");
1432 if (strlen(printcmd) > 0)
1433 scr_printf(" P Print this message\n");
1435 " Q Quote portions of this message for your next post\n"
1436 " H Headers (display message headers only)\n");
1438 scr_printf(" R Reply to this message\n");
1439 if (rc_allow_attachments)
1441 (" F (save attachments to a file)\n");
1442 if (strlen(rc_url_cmd) > 0)
1443 scr_printf(" U (list URL's for display)\n");
1448 dest = fopen(prtfile, "w");
1450 hold_color = enable_color;
1455 dest = fopen(temp2, "w");
1457 hold_color = enable_color;
1469 newprompt("Enter target room: ",
1470 targ, ROOMNAMELEN - 1);
1471 if (strlen(targ) > 0) {
1472 snprintf(cmd, sizeof cmd, "MOVE %ld|%s|%d",
1474 (e == 'c' ? 1 : 0));
1477 scr_printf("%s\n", &cmd[4]);
1487 newprompt("Which section? ", filename,
1488 ((sizeof filename) - 1));
1489 snprintf(cmd, sizeof cmd,
1490 "OPNA %ld|%s", msg_arr[a], filename);
1493 if (cmd[0] == '2') {
1494 extract(filename, &cmd[4], 2);
1495 download_to_local_disk(filename,
1496 extract_int(&cmd[4],
1499 scr_printf("%s\n", &cmd[4]);
1503 scr_printf("*** Delete this message? ");
1505 snprintf(cmd, sizeof cmd, "DELE %ld", msg_arr[a]);
1508 scr_printf("%s\n", &cmd[4]);
1516 read_message(msg_arr[a], READ_HEADER, NULL);
1519 savedpos = num_msgs;
1520 entmsg(1, (DEFAULT_ENTRY == 46 ? 2 : 0));
1521 num_msgs = savedpos;
1527 { /* hack hack hack */
1528 /* find the next message by me, stay here if we find nothing */
1531 for (finda = a; ((finda < num_msgs) && (finda >= 0)); finda += rdir)
1533 /* this is repetitivly dumb, but that's what computers are for.
1534 We have to load up messages until we find one by us */
1538 snprintf(buf, sizeof buf, "MSG0 %ld|%d", msg_arr[finda], 1); /* read the header so we can get 'from=' */
1541 while (serv_gets(buf), strcmp(buf, "000"))
1543 if ((!strncasecmp(buf, "from=", 5)) && (finda != a)) /* Skip current message. */
1545 if (strcasecmp(buf+5, fullname) == 0)
1547 a = lasta; /* meesa current */
1552 // we are now in synch with the server
1555 lasta = finda; /* keep one behind or we skip on the reentrance to the for */
1559 } /* end for loop */
1560 } /* end read routine */
1566 * View and edit a system message
1568 void edit_system_message(char *which_message)
1574 snprintf(desc, sizeof desc, "system message '%s'", which_message);
1575 snprintf(read_cmd, sizeof read_cmd, "MESG %s", which_message);
1576 snprintf(write_cmd, sizeof write_cmd, "EMSG %s", which_message);
1577 do_edit(desc, read_cmd, "NOOP", write_cmd);
1584 * Verify the message base
1586 void check_message_base(void)
1591 ("Please read the documentation before running this command.\n"
1592 "Having done so, do you still want to check the message base? ");
1598 if (buf[0] != '1') {
1599 scr_printf("%s\n", &buf[4]);
1603 while (serv_gets(buf), strcmp(buf, "000")) {
1604 scr_printf("%s\n", buf);