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>
39 #include "citadel_ipc.h"
45 #define MAXWORDBUF SIZ
46 #define NO_REPLY_TO "nobody ... xxxxxx"
50 char text[MAXWORDBUF];
53 void sttybbs(int cmd);
54 int haschar(const char *st, int ch);
55 int checkpagin(int lp, int pagin, int height);
56 void getline(char *string, int lim);
57 void formout(char *name);
59 void newprompt(char *prompt, char *str, int len);
60 int file_checksum(char *filename);
61 void do_edit(char *desc, char *read_cmd, char *check_cmd, char *write_cmd);
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)
94 signal(SIGALRM, ka_sigcatch);
100 * server keep-alive version of wait() (needed for external editor)
102 pid_t ka_wait(int *kstatus)
107 signal(SIGALRM, ka_sigcatch);
111 } while (errno == EINTR);
112 signal(SIGALRM, SIG_IGN);
119 * version of system() that uses ka_wait()
121 int ka_system(char *shc)
130 perror("Cannot fork");
132 return ((pid_t) childpid);
136 execlp("/bin/sh", "sh", "-c", shc, NULL);
142 waitpid = ka_wait(&retcode);
143 } while (waitpid != childpid);
153 * add a newline to the buffer...
155 void add_newline(struct cittext *textlist)
160 while (ptr->next != NULL)
163 while (ptr->text[strlen(ptr->text) - 1] == 32)
164 ptr->text[strlen(ptr->text) - 1] = 0;
165 /* strcat(ptr->text,"\n"); */
167 ptr->next = (struct cittext *)
168 malloc(sizeof(struct cittext));
171 strcpy(ptr->text, "");
176 * add a word to the buffer...
178 void add_word(struct cittext *textlist, char *wordbuf)
183 while (ptr->next != NULL)
186 if (3 + strlen(ptr->text) + strlen(wordbuf) > screenwidth) {
187 ptr->next = (struct cittext *)
188 malloc(sizeof(struct cittext));
191 strcpy(ptr->text, "");
194 strcat(ptr->text, wordbuf);
195 strcat(ptr->text, " ");
200 * begin editing of an opened file pointed to by fp
202 void citedit(FILE * fp)
204 int a, prev, finished, b, last_space;
206 struct cittext *textlist = NULL;
208 char wordbuf[MAXWORDBUF];
210 /* first, load the text into the buffer */
212 textlist = (struct cittext *) malloc(sizeof(struct cittext));
213 textlist->next = NULL;
214 strcpy(textlist->text, "");
218 while (a = getc(fp), a >= 0) {
220 if ((a == 32) || (a == 9) || (a == 13) || (a == 10)) {
221 add_word(textlist, wordbuf);
223 if ((prev == 13) || (prev == 10)) {
224 add_word(textlist, "\n");
225 add_newline(textlist);
226 add_word(textlist, "");
229 wordbuf[strlen(wordbuf) + 1] = 0;
230 wordbuf[strlen(wordbuf)] = a;
232 if (strlen(wordbuf) + 3 > screenwidth) {
233 add_word(textlist, wordbuf);
241 prev = (appending ? 13 : (-1));
253 /******* new ***********/
254 if ((a > 32) && (a < 127) && (prev == 13)) {
255 add_word(textlist, "\n");
258 /***********************/
260 if ((a == 32) && (prev == 13)) {
261 add_word(textlist, "\n");
262 add_newline(textlist);
266 if (strlen(wordbuf) > 0) {
267 wordbuf[strlen(wordbuf) - 1] = 0;
272 } else if (a == 23) {
274 wordbuf[strlen(wordbuf) - 1] = 0;
278 } while (strlen(wordbuf) && wordbuf[strlen(wordbuf) - 1] != ' ');
279 } else if (a == 13) {
281 if (strlen(wordbuf) == 0)
284 for (b = 0; b < strlen(wordbuf); ++b)
285 if (wordbuf[b] == 32) {
293 add_word(textlist, wordbuf);
298 wordbuf[strlen(wordbuf) + 1] = 0;
299 wordbuf[strlen(wordbuf)] = a;
301 if ((strlen(wordbuf) + 3) > screenwidth) {
303 for (b = 0; b < strlen(wordbuf); ++b)
304 if (wordbuf[b] == 32)
306 if (last_space >= 0) {
307 for (b = 0; b < strlen(wordbuf); ++b)
308 if (wordbuf[b] == 32) {
316 for (b = 0; b < strlen(wordbuf); ++b) {
321 scr_printf("\n%s", wordbuf);
323 add_word(textlist, wordbuf);
329 } while (finished == 0);
332 /* write the buffer back to disk */
334 for (ptr = textlist; ptr != NULL; ptr = ptr->next) {
335 fprintf(fp, "%s", ptr->text);
339 ftruncate(fileno(fp), ftell(fp));
341 /* and deallocate the memory we used */
342 while (textlist != NULL) {
343 ptr = textlist->next;
349 /* Read a message from the server
352 long num, /* message number */
353 char pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */
354 FILE *dest) /* Destination file, NULL for screen */
361 struct ctdlipcmessage *message = NULL;
363 char reply_subject[SIZ];
364 int r; /* IPC response code */
369 r = CtdlIPCGetSingleMessage(num, (pagin == READ_HEADER ? 1 : 0), 0,
372 err_printf("*** msg #%ld: %d %s\n", num, r, buf);
375 checkpagin(lines_printed, pagin, screenheight);
380 strcpy(reply_to, NO_REPLY_TO);
381 strcpy(reply_subject, "");
384 fprintf(dest, "\n ");
388 lines_printed = checkpagin(lines_printed, pagin, screenheight);
391 if (pagin == 1 && !dest) {
395 /* View headers only */
397 sprintf(buf, "nhdr=%s\nfrom=%s\ntype=%d\nmsgn=%s\n",
398 message->nhdr ? "yes" : "no",
399 message->author, message->type,
401 /* FIXME output buf */
402 if (strlen(message->subject)) {
403 sprintf(buf, "subj=%s\n", message->subject);
404 /* FIXME: output buf */
406 if (strlen(message->email)) {
407 sprintf(buf, "rfca=%s\n", message->email);
408 /* FIXME: output buf */
410 sprintf(buf, "hnod=%s\nroom=%s\nnode=%s\ntime=%s",
411 message->hnod, message->room,
413 asctime(localtime(&message->time)));
414 if (strlen(message->recipient)) {
415 sprintf(buf, "rcpt=%s\n", message->recipient);
416 /* FIXME: output buf */
418 if (message->attachments) {
421 for (ptr = message->attachments; ptr; ptr = ptr->next) {
422 sprintf(buf, "part=%s|%s|%s|%s|%s|%ld\n",
423 ptr->name, ptr->filename, ptr->number,
424 ptr->disposition, ptr->mimetype,
426 /* FIXME: output buf */
433 if (rc_display_message_numbers) {
435 fprintf(dest, "[#%s] ", message->msgid);
440 scr_printf("#%s", message->msgid);
445 if (nhdr == 1 && !is_room_aide) {
447 fprintf(dest, " ****");
452 fmt_date(now, sizeof now, message->time, 0);
454 fprintf(dest, "%s from %s ", now, message->author);
455 if (strlen(message->email)) {
456 fprintf(dest, "<%s> ", message->email);
460 scr_printf("%s ", now);
464 scr_printf("%s ", message->author);
465 if (strlen(message->email)) {
469 scr_printf("%s", message->email);
474 if (strlen(message->node)) {
475 if ((room_flags & QR_NETWORK)
476 || ((strcasecmp(message->node, serv_info.serv_nodename)
477 && (strcasecmp(message->node, serv_info.serv_fqdn))))) {
478 if (strlen(message->email) == 0) {
480 fprintf(dest, "@%s ", message->node);
484 color(BRIGHT_YELLOW);
485 scr_printf("%s ", message->node);
490 if (strcasecmp(message->hnod, serv_info.serv_humannode)
491 && (strlen(message->hnod)) && (!strlen(message->email))) {
493 fprintf(dest, "(%s) ", message->hnod);
498 scr_printf("%s", message->hnod);
503 if (strcasecmp(message->room, room_name) && (strlen(message->email) == 0)) {
505 fprintf(dest, "in %s> ", message->room);
509 color(BRIGHT_MAGENTA);
510 scr_printf("%s> ", message->room);
513 if (strlen(message->recipient)) {
515 fprintf(dest, "to %s ", message->recipient);
520 scr_printf("%s ", message->recipient);
531 /* Set the reply-to address to an Internet e-mail address if possible
533 if (message->email != NULL) if (strlen(message->email) > 0) {
534 safestrncpy(reply_to, message->email, sizeof reply_to);
537 /* But if we can't do that, set it to a Citadel address.
539 if (!strcmp(reply_to, NO_REPLY_TO)) {
540 snprintf(reply_to, sizeof(reply_to), "%s @ %s",
541 message->author, message->node);
544 if (pagin == 1 && !dest)
548 lines_printed = checkpagin(lines_printed, pagin, screenheight);
551 if (message->subject != NULL) {
552 safestrncpy(reply_subject, message->subject,
553 sizeof reply_subject);
554 if (strlen(message->subject) > 0) {
556 fprintf(dest, "Subject: %s\n",
559 scr_printf("Subject: %s\n", message->subject);
561 lines_printed = checkpagin(lines_printed,
562 pagin, screenheight);
567 /******* end of header output, start of message text output *******/
569 if (format_type == 0) {
570 fr = fmout(screenwidth, NULL, message->text, dest,
571 ((pagin == 1) ? 1 : 0), screenheight, (-1), 1);
575 for (i = 0; i < num_tokens(message->text, '\n'); i++) {
576 if (sigcaught == 0) {
577 extract_token(buf, message->text, i, '\n');
579 fprintf(dest, "%s\n", buf);
581 scr_printf("%s\n", buf);
582 lines_printed = lines_printed + 1 +
583 (strlen(buf) / screenwidth);
585 checkpagin(lines_printed, pagin,
598 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, (sizeof(srch_str)-1) );
626 if (strlen(srch_str) == 0)
629 scr_printf("Enter text to replace it with:\n: ");
630 getline(rplc_str, (sizeof(rplc_str)-1) );
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 (!strncmp(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, sizeof 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, 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, 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 */
936 char reply_subject[SIZ];
947 * First, check to see if we have permission to enter a message in
948 * this room. The server will return an error code if we can't.
950 snprintf(cmd, sizeof cmd, "ENT0 0||0|%d", mode);
954 if ((strncmp(cmd, "570", 3)) && (strncmp(cmd, "200", 3))) {
955 scr_printf("%s\n", &cmd[4]);
959 /* Error code 570 is special. It means that we CAN enter a message
960 * in this room, but a recipient needs to be specified.
963 if (!strncmp(cmd, "570", 3))
966 /* If the user is a dumbass, tell them how to type. */
967 if ((userflags & US_EXPERT) == 0) {
971 /* Handle the selection of a recipient, if necessary. */
973 if (need_recp == 1) {
976 strcpy(buf, reply_to);
978 scr_printf("Enter recipient: ");
979 getline(buf, (SIZ-100) );
980 if (strlen(buf) == 0)
984 strcpy(buf, "sysop");
988 if (strlen(reply_subject) > 0) {
989 if (!strncasecmp(reply_subject,
991 strcpy(subject, reply_subject);
1003 if (room_flags & QR_ANONOPT) {
1004 scr_printf("Anonymous (Y/N)? ");
1009 /* If it's mail, we've got to check the validity of the recipient... */
1010 if (strlen(buf) > 0) {
1011 snprintf(cmd, sizeof cmd, "ENT0 0|%s|%d|%d|%s", buf, b, mode, subject);
1014 if (cmd[0] != '2') {
1015 scr_printf("%s\n", &cmd[4]);
1020 /* Learn the number of the newest message in in the room, so we can
1021 * tell upon saving whether someone else has posted too.
1024 serv_puts("MSGS LAST|1");
1026 if (cmd[0] != '1') {
1027 scr_printf("%s\n", &cmd[5]);
1029 while (serv_gets(cmd), strcmp(cmd, "000")) {
1031 if ((num_msgs + 1) > msg_arr_size) {
1032 msg_arr_size += 512;
1033 msg_arr = realloc(msg_arr,
1034 ((sizeof(long)) * msg_arr_size) );
1037 msg_arr[num_msgs++] = atol(cmd);
1041 /* Now compose the message... */
1042 if (client_make_message(temp, buf, b, 0, c, subject) != 0) {
1046 /* Reopen the temp file that was created, so we can send it */
1047 fp = fopen(temp, "r");
1049 /* Yes, unlink it now, so it doesn't stick around if we crash */
1053 err_printf("*** Internal error while trying to save message!\n"
1055 temp, strerror(errno));
1059 /* Transmit message to the server */
1060 snprintf(cmd, sizeof cmd, "ENT0 1|%s|%d|%d|%s|", buf, b, mode, subject);
1063 if (cmd[0] != '4') {
1064 scr_printf("%s\n", &cmd[4]);
1068 transmit_message(fp);
1073 highmsg = msg_arr[num_msgs - 1];
1075 serv_puts("MSGS NEW");
1077 if (cmd[0] != '1') {
1078 scr_printf("%s\n", &cmd[5]);
1080 while (serv_gets(cmd), strcmp(cmd, "000")) {
1081 msg_arr[num_msgs++] = atol(cmd);
1085 /* get new highest message number in room to set lrp for goto... */
1086 maxmsgnum = msg_arr[num_msgs - 1];
1088 /* now see if anyone else has posted in here */
1090 for (a = 0; a < num_msgs; ++a) {
1091 if (msg_arr[a] > highmsg) {
1096 /* In the Mail> room, this algorithm always counts one message
1097 * higher than in public rooms, so we decrement it by one.
1104 scr_printf("*** 1 additional message has been entered "
1105 "in this room by another user.\n");
1108 scr_printf("*** %d additional messages have been entered "
1109 "in this room by other users.\n", b);
1116 * Do editing on a quoted file
1118 void process_quote(void)
1120 FILE *qfile, *tfile;
1122 int line, qstart, qend;
1124 /* Unlink the second temp file as soon as it's opened, so it'll get
1125 * deleted even if the program dies
1127 qfile = fopen(temp2, "r");
1130 /* Display the quotable text with line numbers added */
1132 fgets(buf, 128, qfile);
1133 while (fgets(buf, 128, qfile) != NULL) {
1134 scr_printf("%2d %s", ++line, buf);
1136 scr_printf("Begin quoting at [ 1] : ");
1138 qstart = (buf[0] == 0) ? (1) : atoi(buf);
1139 scr_printf(" End quoting at [%d] : ", line);
1141 qend = (buf[0] == 0) ? (line) : atoi(buf);
1144 fgets(buf, 128, qfile);
1145 tfile = fopen(temp, "w");
1146 while (fgets(buf, 128, qfile) != NULL) {
1147 if ((++line >= qstart) && (line <= qend))
1148 fprintf(tfile, " >%s", buf);
1150 fprintf(tfile, " \n");
1159 * List the URL's which were embedded in the previous message
1166 if (num_urls == 0) {
1167 scr_printf("There were no URL's in the previous message.\n\n");
1171 for (i = 0; i < num_urls; ++i) {
1172 scr_printf("%3d %s\n", i + 1, urls[i]);
1175 if ((i = num_urls) != 1)
1176 i = intprompt("Display which one", 1, 1, num_urls);
1178 snprintf(cmd, sizeof cmd, rc_url_cmd, urls[i - 1]);
1184 * Read the messages in the current room
1187 int c, /* 0=Read all 1=Read new 2=Read old 3=Read last q */
1188 int rdir, /* 1=Forward (-1)=Reverse */
1189 int q /* Number of msgs to read (if c==3) */
1191 int a, b, e, f, g, start;
1197 char prtfile[PATH_MAX];
1200 char targ[ROOMNAMELEN];
1202 FILE *dest = NULL; /* Alternate destination other than screen */
1203 int r; /* IPC response code */
1210 strcpy(prtfile, tmpnam(NULL));
1213 strcpy(cmd, "MSGS ");
1225 snprintf(&cmd[5], sizeof cmd - 5, "LAST|%d", q);
1230 if (cmd[0] != '1') {
1231 scr_printf("%s\n", &cmd[5]);
1233 while (serv_gets(cmd), strcmp(cmd, "000")) {
1235 if ((num_msgs + 1) > msg_arr_size) {
1236 msg_arr_size += 512;
1237 msg_arr = realloc(msg_arr,
1238 ((sizeof(long)) * msg_arr_size) );
1241 msg_arr[num_msgs++] = atol(cmd);
1245 if (num_msgs == 0) {
1247 scr_printf("*** There are no ");
1248 if (c == 1) scr_printf("new ");
1249 if (c == 2) scr_printf("old ");
1250 scr_printf("messages in this room.\n");
1256 /* this loop cycles through each message... */
1257 start = ((rdir == 1) ? 0 : (num_msgs - 1));
1258 for (a = start; ((a < num_msgs) && (a >= 0)); a = a + rdir) {
1259 while (msg_arr[a] == 0L) {
1261 if ((a == num_msgs) || (a == (-1)))
1265 RAGAIN: pagin = ((arcflag == 0)
1267 && (userflags & US_PAGINATOR)) ? 1 : 0;
1269 /* If we're doing a quote, set the screenwidth to 72 */
1271 hold_sw = screenwidth;
1275 /* If printing or archiving, set the screenwidth to 80 */
1277 hold_sw = screenwidth;
1281 /* now read the message... */
1282 e = read_message(msg_arr[a], pagin, dest);
1284 /* ...and set the screenwidth back if we have to */
1285 if ((quotflag) || (arcflag)) {
1286 screenwidth = hold_sw;
1288 RMSGREAD: scr_flush();
1289 highest_msg_read = msg_arr[a];
1294 enable_color = hold_color;
1301 enable_color = hold_color;
1304 freopen(prtfile, "r", stdin);
1306 sttybbs(SB_RESTORE);
1307 ka_system(printcmd);
1308 sttybbs(SB_NO_INTR);
1316 } while ((g != f) && (g >= 0));
1317 scr_printf("Message printed.\n");
1319 if (rc_alt_semantics && c == 1) {
1322 r = CtdlIPCSetMessageSeen(msg_arr[a], 1, buf);
1326 if (((userflags & US_NOPROMPT) || (e == 2))
1327 && (((room_flags & QR_MAILBOX) == 0)
1328 || (rc_force_mail_prompts == 0))) {
1333 color(BRIGHT_WHITE);
1334 scr_printf("%d", num_msgs - a - 1);
1338 keyopt("<B>ack <A>gain <Q>uote <R>eply <N>ext <S>top m<Y> next ");
1339 if (rc_url_cmd[0] && num_urls)
1340 keyopt("<U>RLview ");
1341 keyopt("<?>help -> ");
1345 e = (inkey() & 127);
1347 /* return key same as <N> */ if (e == 10)
1349 /* space key same as <N> */ if (e == 32)
1351 /* del/move for aides only */
1353 && ((room_flags & QR_MAILBOX) ==
1355 if ((e == 'd') || (e == 'm'))
1358 /* print only if available */
1359 if ((e == 'p') && (strlen(printcmd) == 0))
1361 /* can't file if not allowed */
1363 && (rc_allow_attachments == 0))
1365 /* link only if browser avail*/
1367 && (strlen(rc_url_cmd) == 0))
1369 } while ((e != 'a') && (e != 'n') && (e != 's')
1370 && (e != 'd') && (e != 'm') && (e != 'p')
1371 && (e != 'q') && (e != 'b') && (e != 'h')
1372 && (e != 'r') && (e != 'f') && (e != '?')
1373 && (e != 'u') && (e != 'c') && (e != 'y'));
1379 scr_printf("Again");
1382 scr_printf("Delete");
1394 scr_printf("Print");
1397 scr_printf("Quote");
1403 scr_printf("Header");
1406 scr_printf("Reply");
1412 scr_printf("URL's");
1415 scr_printf("mY next");
1418 scr_printf("? <help>");
1421 if (userflags & US_DISAPPEAR)
1422 scr_printf("\r%79s\r", "");
1429 scr_printf("Options available here:\n"
1430 " ? Help (prints this message)\n"
1431 " S Stop reading immediately\n"
1432 " A Again (repeats last message)\n"
1433 " N Next (continue with next message)\n"
1434 " Y My Next (continue with next message you authored)\n"
1435 " B Back (go back to previous message)\n");
1437 || (room_flags & QR_MAILBOX)) {
1438 scr_printf(" D Delete this message\n"
1439 " M Move message to another room\n");
1441 scr_printf(" C Copy message to another room\n");
1442 if (strlen(printcmd) > 0)
1443 scr_printf(" P Print this message\n");
1445 " Q Quote portions of this message for your next post\n"
1446 " H Headers (display message headers only)\n");
1448 scr_printf(" R Reply to this message\n");
1449 if (rc_allow_attachments)
1451 (" F (save attachments to a file)\n");
1452 if (strlen(rc_url_cmd) > 0)
1453 scr_printf(" U (list URL's for display)\n");
1458 dest = fopen(prtfile, "w");
1460 hold_color = enable_color;
1465 dest = fopen(temp2, "w");
1467 hold_color = enable_color;
1479 newprompt("Enter target room: ",
1480 targ, ROOMNAMELEN - 1);
1481 if (strlen(targ) > 0) {
1482 r = CtdlIPCMoveMessage((e == 'c' ? 1 : 0),
1483 msg_arr[a], targ, cmd);
1484 scr_printf("%s\n", cmd);
1490 if (r / 100 != 2) /* r will be init'ed, FIXME */
1491 goto RMSGREAD; /* the logic here sucks */
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 r = CtdlIPCDeleteMessage(msg_arr[a], cmd);
1513 scr_printf("%s\n", cmd);
1521 read_message(msg_arr[a], READ_HEADER, NULL);
1524 savedpos = num_msgs;
1525 entmsg(1, (DEFAULT_ENTRY == 46 ? 2 : 0));
1526 num_msgs = savedpos;
1532 { /* hack hack hack */
1533 /* find the next message by me, stay here if we find nothing */
1536 for (finda = a; ((finda < num_msgs) && (finda >= 0)); finda += rdir)
1538 /* This is repetitively dumb, but that's what computers are for.
1539 We have to load up messages until we find one by us */
1543 snprintf(buf, sizeof buf, "MSG0 %ld|1", msg_arr[finda]); /* read the header so we can get 'from=' */
1546 while (serv_gets(buf), strcmp(buf, "000"))
1548 if ((!strncasecmp(buf, "from=", 5)) && (finda != a)) /* Skip current message. */
1550 if (strcasecmp(buf+5, fullname) == 0)
1552 a = lasta; /* meesa current */
1557 // we are now in synch with the server
1560 lasta = finda; /* keep one behind or we skip on the reentrance to the for */
1564 } /* end for loop */
1565 } /* end read routine */
1571 * View and edit a system message
1573 void edit_system_message(char *which_message)
1579 snprintf(desc, sizeof desc, "system message '%s'", which_message);
1580 snprintf(read_cmd, sizeof read_cmd, "MESG %s", which_message);
1581 snprintf(write_cmd, sizeof write_cmd, "EMSG %s", which_message);
1582 do_edit(desc, read_cmd, "NOOP", write_cmd);
1589 * Verify the message base
1591 void check_message_base(void)
1596 ("Please read the documentation before running this command.\n"
1597 "Having done so, do you still want to check the message base? ");
1603 if (buf[0] != '1') {
1604 scr_printf("%s\n", &buf[4]);
1608 while (serv_gets(buf), strcmp(buf, "000")) {
1609 scr_printf("%s\n", buf);