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 long msg_arr[MAXMSGS];
65 char rc_alt_semantics;
66 extern char room_name[];
67 extern unsigned room_flags;
68 extern long highest_msg_read;
69 extern struct CtdlServInfo serv_info;
72 extern int screenwidth;
73 extern int screenheight;
74 extern long maxmsgnum;
77 extern char is_room_aide;
78 extern char fullname[];
80 extern unsigned userflags;
81 extern char sigcaught;
82 extern char editor_path[];
83 extern char printcmd[];
84 extern int rc_allow_attachments;
85 extern int rc_display_message_numbers;
86 extern int rc_force_mail_prompts;
88 extern int editor_pid;
90 void ka_sigcatch(int signum)
94 signal(SIGALRM, ka_sigcatch);
101 * server keep-alive version of wait() (needed for external editor)
103 pid_t ka_wait(int *kstatus)
108 signal(SIGALRM, ka_sigcatch);
112 } while (errno == EINTR);
113 signal(SIGALRM, SIG_IGN);
120 * version of system() that uses ka_wait()
122 int ka_system(char *shc)
131 perror("Cannot fork");
133 return ((pid_t) childpid);
137 execlp("/bin/sh", "sh", "-c", shc, NULL);
143 waitpid = ka_wait(&retcode);
144 } while (waitpid != childpid);
154 * add a newline to the buffer...
156 void add_newline(struct cittext *textlist)
161 while (ptr->next != NULL)
164 while (ptr->text[strlen(ptr->text) - 1] == 32)
165 ptr->text[strlen(ptr->text) - 1] = 0;
166 /* strcat(ptr->text,"\n"); */
168 ptr->next = (struct cittext *)
169 malloc(sizeof(struct cittext));
172 strcpy(ptr->text, "");
177 * add a word to the buffer...
179 void add_word(struct cittext *textlist, char *wordbuf)
184 while (ptr->next != NULL)
187 if (3 + strlen(ptr->text) + strlen(wordbuf) > screenwidth) {
188 ptr->next = (struct cittext *)
189 malloc(sizeof(struct cittext));
192 strcpy(ptr->text, "");
195 strcat(ptr->text, wordbuf);
196 strcat(ptr->text, " ");
201 * begin editing of an opened file pointed to by fp
203 void citedit(FILE * fp)
205 int a, prev, finished, b, last_space;
207 struct cittext *textlist = NULL;
209 char wordbuf[MAXWORDBUF];
211 /* first, load the text into the buffer */
213 textlist = (struct cittext *) malloc(sizeof(struct cittext));
214 textlist->next = NULL;
215 strcpy(textlist->text, "");
219 while (a = getc(fp), a >= 0) {
221 if ((a == 32) || (a == 9) || (a == 13) || (a == 10)) {
222 add_word(textlist, wordbuf);
224 if ((prev == 13) || (prev == 10)) {
225 add_word(textlist, "\n");
226 add_newline(textlist);
227 add_word(textlist, "");
230 wordbuf[strlen(wordbuf) + 1] = 0;
231 wordbuf[strlen(wordbuf)] = a;
233 if (strlen(wordbuf) + 3 > screenwidth) {
234 add_word(textlist, wordbuf);
242 prev = (appending ? 13 : (-1));
254 /******* new ***********/
255 if ((a > 32) && (a < 127) && (prev == 13)) {
256 add_word(textlist, "\n");
259 /***********************/
261 if ((a == 32) && (prev == 13)) {
262 add_word(textlist, "\n");
263 add_newline(textlist);
267 if (strlen(wordbuf) > 0) {
268 wordbuf[strlen(wordbuf) - 1] = 0;
273 } else if (a == 13) {
275 if (strlen(wordbuf) == 0)
278 for (b = 0; b < strlen(wordbuf); ++b)
279 if (wordbuf[b] == 32) {
287 add_word(textlist, wordbuf);
292 wordbuf[strlen(wordbuf) + 1] = 0;
293 wordbuf[strlen(wordbuf)] = a;
295 if ((strlen(wordbuf) + 3) > screenwidth) {
297 for (b = 0; b < strlen(wordbuf); ++b)
298 if (wordbuf[b] == 32)
300 if (last_space >= 0) {
301 for (b = 0; b < strlen(wordbuf); ++b)
302 if (wordbuf[b] == 32) {
310 for (b = 0; b < strlen(wordbuf); ++b) {
315 scr_printf("\n%s", wordbuf);
317 add_word(textlist, wordbuf);
323 } while (finished == 0);
326 /* write the buffer back to disk */
328 for (ptr = textlist; ptr != NULL; ptr = ptr->next) {
329 fprintf(fp, "%s", ptr->text);
333 ftruncate(fileno(fp), ftell(fp));
335 /* and deallocate the memory we used */
336 while (textlist != NULL) {
337 ptr = textlist->next;
343 /* Read a message from the server
346 long num, /* message number */
347 char pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */
348 FILE *dest) /* Destination file, NULL for screen */
352 char from[SIZ], node[SIZ], rfca[SIZ];
361 sprintf(buf, "MSG0 %ld|%d", num, (pagin == READ_HEADER ? 1 : 0));
365 err_printf("*** msg #%ld: %s\n", num, buf);
368 checkpagin(lines_printed, pagin, screenheight);
373 strcpy(m_subject, "");
374 strcpy(reply_to, "nobody ... xxxxx");
380 fprintf(dest, "\n ");
384 lines_printed = checkpagin(lines_printed, pagin, screenheight);
387 if (pagin == 1 && !dest) {
392 while (serv_gets(buf), strcmp(buf, "000")) {
395 fprintf(dest, "%s\n", buf);
397 scr_printf("%s\n", buf);
400 checkpagin(lines_printed,
401 pagin, screenheight);
409 while (serv_gets(buf), strncasecmp(buf, "text", 4)) {
410 if (!strncasecmp(buf, "nhdr=yes", 8))
412 if (!strncasecmp(buf, "from=", 5)) {
413 strcpy(from, &buf[5]);
417 if (!strncasecmp(buf, "type=", 5))
418 format_type = atoi(&buf[5]);
419 if ((!strncasecmp(buf, "msgn=", 5))
420 && (rc_display_message_numbers)) {
422 fprintf(dest, "[#%s] ", &buf[5]);
427 scr_printf("#%s", &buf[5]);
432 if (!strncasecmp(buf, "from=", 5)) {
434 fprintf(dest, "from %s ", &buf[5]);
439 scr_printf("%s ", &buf[5]);
442 if (!strncasecmp(buf, "subj=", 5))
443 strcpy(m_subject, &buf[5]);
445 if (!strncasecmp(buf, "rfca=", 5)) {
446 safestrncpy(rfca, &buf[5], sizeof(rfca) - 5);
448 fprintf(dest, "<%s> ", &buf[5]);
453 scr_printf("%s", &buf[5]);
458 if ((!strncasecmp(buf, "hnod=", 5))
459 && (strcasecmp(&buf[5], serv_info.serv_humannode))
460 && (strlen(rfca) == 0)) {
462 fprintf(dest, "(%s) ", &buf[5]);
467 scr_printf("%s", &buf[5]);
472 if ((!strncasecmp(buf, "room=", 5))
473 && (strcasecmp(&buf[5], room_name))
474 && (strlen(rfca) == 0)) {
476 fprintf(dest, "in %s> ", &buf[5]);
480 color(BRIGHT_MAGENTA);
481 scr_printf("%s> ", &buf[5]);
485 if (!strncasecmp(buf, "node=", 5)) {
486 safestrncpy(node, &buf[5], sizeof(buf) - 5);
487 if ((room_flags & QR_NETWORK)
490 (&buf[5], serv_info.serv_nodename)
492 (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
494 if (strlen(rfca) == 0) {
496 fprintf(dest, "@%s ", &buf[5]);
500 color(BRIGHT_YELLOW);
501 scr_printf("%s ", &buf[5]);
507 if (!strncasecmp(buf, "rcpt=", 5)) {
509 fprintf(dest, "to %s ", &buf[5]);
514 scr_printf("%s ", &buf[5]);
517 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 if (strlen(m_subject) > 0) {
564 fprintf(dest, "Subject: %s\n", m_subject);
566 scr_printf("Subject: %s\n", m_subject);
568 lines_printed = checkpagin(lines_printed,
569 pagin, screenheight);
573 if (format_type == 0) {
574 fr = fmout(screenwidth, NULL, dest,
575 ((pagin == 1) ? 1 : 0), screenheight, (-1), 1);
577 while (serv_gets(buf), strcmp(buf, "000")) {
578 if (sigcaught == 0) {
580 fprintf(dest, "%s\n", buf);
582 scr_printf("%s\n", buf);
583 lines_printed = lines_printed + 1 +
584 (strlen(buf) / screenwidth);
586 checkpagin(lines_printed, pagin,
599 lines_printed = checkpagin(lines_printed, pagin, screenheight);
602 if (pagin == 1 && !dest)
609 * replace string function for the built-in editor
611 void replace_string(char *filename, long int startpos)
620 int substitutions = 0;
623 scr_printf("Enter text to be replaced:\n: ");
624 getline(srch_str, 128);
625 if (strlen(srch_str) == 0)
628 scr_printf("Enter text to replace it with:\n: ");
629 getline(rplc_str, 128);
631 fp = fopen(filename, "r+");
636 fseek(fp, startpos, 0);
638 while (a = getc(fp), a > 0) {
640 buf[strlen(buf) + 1] = 0;
641 buf[strlen(buf)] = a;
642 if (strlen(buf) >= strlen(srch_str)) {
643 ptr = (&buf[strlen(buf) - strlen(srch_str)]);
644 if (!strncasecmp(ptr, srch_str, strlen(srch_str))) {
645 strcpy(ptr, rplc_str);
649 if (strlen(buf) > 384) {
652 fwrite((char *) buf, 128, 1, fp);
653 strcpy(buf, &buf[128]);
660 fwrite((char *) buf, strlen(buf), 1, fp);
663 truncate(filename, wpos);
664 scr_printf("<R>eplace made %d substitution(s).\n\n", substitutions);
668 * Function to begin composing a new message
670 int client_make_message(char *filename, /* temporary file name */
671 char *recipient, /* NULL if it's not mail */
672 int anon_type, /* see MES_ types in header file */
684 if (strlen(editor_path) == 0) {
686 ("*** No editor available, using built-in editor\n");
690 fmt_date(datestr, time(NULL), 0);
693 if (room_flags & QR_ANONONLY && !recipient) {
694 sprintf(&header[strlen(header)], " ****");
697 sprintf(&header[strlen(header)],
698 " %s from %s", datestr, fullname);
699 if (strlen(recipient) > 0) {
700 sprintf(&header[strlen(header)],
701 " to %s", recipient);
704 scr_printf("%s\n", header);
709 scr_printf("(Press ctrl-d when finished)\n");
713 fp = fopen(filename, "r");
715 fmout(screenwidth, fp, NULL, 0, screenheight, 0, 0);
719 fp = fopen(filename, "w");
721 err_printf("*** Error opening temp file!\n"
723 filename, strerror(errno));
733 fp = fopen(filename, "r+");
735 err_printf("*** Error opening temp file!\n"
737 filename, strerror(errno));
745 fp = fopen(filename, "a");
747 err_printf("*** Error opening temp file!\n"
749 filename, strerror(errno));
769 e_ex_code = 1; /* start with a failed exit code */
771 cksum = file_checksum(filename);
772 if (editor_pid == 0) {
773 chmod(filename, 0600);
776 setenv("WINDOW_TITLE", header, 1);
777 execlp(editor_path, editor_path, filename, NULL);
783 b = ka_wait(&e_ex_code);
784 } while ((b != editor_pid) && (b >= 0));
791 MECR: if (mode == 2) {
792 if (file_checksum(filename) == cksum) {
793 err_printf("*** Aborted message.\n");
801 b = keymenu("Entry command (? for options)",
802 "<A>bort|<C>ontinue|<S>ave message|<P>rint formatted|"
803 "<R>eplace string|<H>old message");
812 scr_printf(" %s from %s", datestr, fullname);
813 if (strlen(recipient) > 0)
814 scr_printf(" to %s", recipient);
816 fp = fopen(filename, "r");
818 fmout(screenwidth, fp, NULL,
819 ((userflags & US_PAGINATOR) ? 1 : 0),
827 replace_string(filename, 0L);
836 MEABT: scr_printf("Are you sure? ");
840 MEABT2: unlink(filename);
845 * Transmit message text to the server.
847 * This loop also implements a "tick" counter that displays the progress, if
848 * we're sending something that will take a long time to transmit.
850 void transmit_message(FILE *fp)
857 fseek(fp, 0L, SEEK_END);
860 lasttick = time(NULL);
862 while (ch = getc(fp), (ch >= 0)) {
864 if (!strcmp(buf, "000"))
872 if ((ch == 32) && (strlen(buf) > 200)) {
874 if (!strcmp(buf, "000"))
879 if (strlen(buf) > 250) {
880 if (!strcmp(buf, "000"))
887 if ((time(NULL) - lasttick) > 2L) {
888 scr_printf(" %3ld%% completed\r",
889 ((ftell(fp) * 100L) / msglen));
891 lasttick = time(NULL);
903 * entmsg() - edit and create a message
904 * returns 0 if message was saved
906 int entmsg(int is_reply, /* nonzero if this was a <R>eply command */
923 * First, check to see if we have permission to enter a message in
924 * this room. The server will return an error code if we can't.
926 sprintf(cmd, "ENT0 0||0|%d", mode);
930 if ((strncmp(cmd, "570", 3)) && (strncmp(cmd, "200", 3))) {
931 scr_printf("%s\n", &cmd[4]);
935 /* Error code 570 is special. It means that we CAN enter a message
936 * in this room, but a recipient needs to be specified.
939 if (!strncmp(cmd, "570", 3))
942 /* If the user is a dumbass, tell them how to type. */
943 if ((userflags & US_EXPERT) == 0) {
947 /* Handle the selection of a recipient, if necessary. */
949 if (need_recp == 1) {
952 strcpy(buf, reply_to);
954 scr_printf("Enter recipient: ");
955 getline(buf, (SIZ-100) );
956 if (strlen(buf) == 0)
960 strcpy(buf, "sysop");
964 if (room_flags & QR_ANONOPT) {
965 scr_printf("Anonymous (Y/N)? ");
970 /* If it's mail, we've got to check the validity of the recipient... */
971 if (strlen(buf) > 0) {
972 sprintf(cmd, "ENT0 0|%s|%d|%d", buf, b, mode);
976 scr_printf("%s\n", &cmd[4]);
981 /* Learn the number of the newest message in in the room, so we can
982 * tell upon saving whether someone else has posted too.
985 serv_puts("MSGS LAST|1");
988 scr_printf("%s\n", &cmd[5]);
990 while (serv_gets(cmd), strcmp(cmd, "000")) {
991 msg_arr[num_msgs++] = atol(cmd);
995 /* Now compose the message... */
996 if (client_make_message(temp, buf, b, 0, c) != 0) {
1000 /* Reopen the temp file that was created, so we can send it */
1001 fp = fopen(temp, "r");
1003 /* Yes, unlink it now, so it doesn't stick around if we crash */
1007 err_printf("*** Internal error while trying to save message!\n"
1009 temp, strerror(errno));
1013 /* Transmit message to the server */
1014 sprintf(cmd, "ENT0 1|%s|%d|%d||", buf, b, mode);
1017 if (cmd[0] != '4') {
1018 scr_printf("%s\n", &cmd[4]);
1022 transmit_message(fp);
1027 highmsg = msg_arr[num_msgs - 1];
1029 serv_puts("MSGS NEW");
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 /* get new highest message number in room to set lrp for goto... */
1040 maxmsgnum = msg_arr[num_msgs - 1];
1042 /* now see if anyone else has posted in here */
1044 for (a = 0; a < num_msgs; ++a) {
1045 if (msg_arr[a] > highmsg) {
1050 /* In the Mail> room, this algorithm always counts one message
1051 * higher than in public rooms, so we decrement it by one.
1058 scr_printf("*** 1 additional message has been entered "
1059 "in this room by another user.\n");
1062 scr_printf("*** %d additional messages have been entered "
1063 "in this room by other users.\n", b);
1070 * Do editing on a quoted file
1072 void process_quote(void)
1074 FILE *qfile, *tfile;
1076 int line, qstart, qend;
1078 /* Unlink the second temp file as soon as it's opened, so it'll get
1079 * deleted even if the program dies
1081 qfile = fopen(temp2, "r");
1084 /* Display the quotable text with line numbers added */
1086 fgets(buf, 128, qfile);
1087 while (fgets(buf, 128, qfile) != NULL) {
1088 scr_printf("%2d %s", ++line, buf);
1090 scr_printf("Begin quoting at [ 1] : ");
1092 qstart = (buf[0] == 0) ? (1) : atoi(buf);
1093 scr_printf(" End quoting at [%d] : ", line);
1095 qend = (buf[0] == 0) ? (line) : atoi(buf);
1098 fgets(buf, 128, qfile);
1099 tfile = fopen(temp, "w");
1100 while (fgets(buf, 128, qfile) != NULL) {
1101 if ((++line >= qstart) && (line <= qend))
1102 fprintf(tfile, " >%s", buf);
1104 fprintf(tfile, " \n");
1113 * List the URL's which were embedded in the previous message
1120 if (num_urls == 0) {
1121 scr_printf("There were no URL's in the previous message.\n\n");
1125 for (i = 0; i < num_urls; ++i) {
1126 scr_printf("%3d %s\n", i + 1, urls[i]);
1129 if ((i = num_urls) != 1)
1130 i = intprompt("Display which one", 1, 1, num_urls);
1132 sprintf(cmd, rc_url_cmd, urls[i - 1]);
1138 * Read the messages in the current room
1141 int c, /* 0=Read all 1=Read new 2=Read old 3=Read last q */
1142 int rdir, /* 1=Forward (-1)=Reverse */
1143 int q /* Number of msgs to read (if c==3) */
1145 int a, b, e, f, g, start;
1151 char prtfile[PATH_MAX];
1154 char targ[ROOMNAMELEN];
1156 FILE *dest = NULL; /* Alternate destination other than screen */
1163 strcpy(prtfile, tmpnam(NULL));
1166 strcpy(cmd, "MSGS ");
1178 sprintf(&cmd[strlen(cmd)], "LAST|%d", q);
1183 if (cmd[0] != '1') {
1184 scr_printf("%s\n", &cmd[5]);
1186 while (serv_gets(cmd), strcmp(cmd, "000")) {
1187 if (num_msgs == MAXMSGS) {
1188 memcpy(&msg_arr[0], &msg_arr[1],
1189 (sizeof(long) * (MAXMSGS - 1)));
1192 msg_arr[num_msgs++] = atol(cmd);
1196 if (num_msgs == 0) {
1198 scr_printf("*** There are no ");
1199 if (c == 1) scr_printf("new ");
1200 if (c == 2) scr_printf("old ");
1201 scr_printf("messages in this room.\n");
1207 /* this loop cycles through each message... */
1208 start = ((rdir == 1) ? 0 : (num_msgs - 1));
1209 for (a = start; ((a < num_msgs) && (a >= 0)); a = a + rdir) {
1210 while (msg_arr[a] == 0L) {
1212 if ((a == MAXMSGS) || (a == (-1)))
1216 RAGAIN: pagin = ((arcflag == 0)
1218 && (userflags & US_PAGINATOR)) ? 1 : 0;
1220 /* If we're doing a quote, set the screenwidth to 72 */
1222 hold_sw = screenwidth;
1226 /* If printing or archiving, set the screenwidth to 80 */
1228 hold_sw = screenwidth;
1232 /* now read the message... */
1233 e = read_message(msg_arr[a], pagin, dest);
1235 /* ...and set the screenwidth back if we have to */
1236 if ((quotflag) || (arcflag)) {
1237 screenwidth = hold_sw;
1239 RMSGREAD: scr_flush();
1240 highest_msg_read = msg_arr[a];
1245 enable_color = hold_color;
1252 enable_color = hold_color;
1255 freopen(prtfile, "r", stdin);
1257 sttybbs(SB_RESTORE);
1258 ka_system(printcmd);
1259 sttybbs(SB_NO_INTR);
1267 } while ((g != f) && (g >= 0));
1268 scr_printf("Message printed.\n");
1270 if (rc_alt_semantics && c == 1) {
1273 snprintf(buf, sizeof(buf), "SEEN %ld", msg_arr[a]);
1275 serv_gets(buf); /* Don't need to check this? */
1279 if (((userflags & US_NOPROMPT) || (e == 2))
1280 && (((room_flags & QR_MAILBOX) == 0)
1281 || (rc_force_mail_prompts == 0))) {
1286 color(BRIGHT_WHITE);
1287 scr_printf("%d", num_msgs - a - 1);
1291 keyopt("<B>ack <A>gain <Q>uote <R>eply <N>ext <S>top m<Y> next ");
1292 if (rc_url_cmd[0] && num_urls)
1293 keyopt("<U>RLview ");
1294 keyopt("<?>help -> ");
1298 e = (inkey() & 127);
1300 /* return key same as <N> */ if (e == 13)
1302 /* space key same as <N> */ if (e == 32)
1304 /* del/move for aides only */
1306 && ((room_flags & QR_MAILBOX) ==
1308 if ((e == 'd') || (e == 'm'))
1311 /* print only if available */
1312 if ((e == 'p') && (strlen(printcmd) == 0))
1314 /* can't file if not allowed */
1316 && (rc_allow_attachments == 0))
1318 /* link only if browser avail*/
1320 && (strlen(rc_url_cmd) == 0))
1322 } while ((e != 'a') && (e != 'n') && (e != 's')
1323 && (e != 'd') && (e != 'm') && (e != 'p')
1324 && (e != 'q') && (e != 'b') && (e != 'h')
1325 && (e != 'r') && (e != 'f') && (e != '?')
1326 && (e != 'u') && (e != 'c') && (e != 'y'));
1332 scr_printf("Again");
1335 scr_printf("Delete");
1347 scr_printf("Print");
1350 scr_printf("Quote");
1356 scr_printf("Header");
1359 scr_printf("Reply");
1365 scr_printf("URL's");
1368 scr_printf("mY next");
1371 scr_printf("? <help>");
1374 if (userflags & US_DISAPPEAR)
1375 scr_printf("\r%79s\r", "");
1382 scr_printf("Options available here:\n"
1383 " ? Help (prints this message)\n"
1384 " S Stop reading immediately\n"
1385 " A Again (repeats last message)\n"
1386 " N Next (continue with next message)\n"
1387 " Y My Next (continue with next message you authored)\n"
1388 " B Back (go back to previous message)\n");
1390 || (room_flags & QR_MAILBOX)) {
1391 scr_printf(" D Delete this message\n"
1392 " M Move message to another room\n");
1394 scr_printf(" C Copy message to another room\n");
1395 if (strlen(printcmd) > 0)
1396 scr_printf(" P Print this message\n");
1398 " Q Quote portions of this message for your next post\n"
1399 " H Headers (display message headers only)\n");
1401 scr_printf(" R Reply to this message\n");
1402 if (rc_allow_attachments)
1404 (" F (save attachments to a file)\n");
1405 if (strlen(rc_url_cmd) > 0)
1406 scr_printf(" U (list URL's for display)\n");
1411 dest = fopen(prtfile, "w");
1413 hold_color = enable_color;
1418 dest = fopen(temp2, "w");
1420 hold_color = enable_color;
1432 newprompt("Enter target room: ",
1433 targ, ROOMNAMELEN - 1);
1434 if (strlen(targ) > 0) {
1435 sprintf(cmd, "MOVE %ld|%s|%d",
1437 (e == 'c' ? 1 : 0));
1440 scr_printf("%s\n", &cmd[4]);
1450 newprompt("Which section? ", filename,
1451 ((sizeof filename) - 1));
1452 snprintf(cmd, sizeof cmd,
1453 "OPNA %ld|%s", msg_arr[a], filename);
1456 if (cmd[0] == '2') {
1457 extract(filename, &cmd[4], 2);
1458 download_to_local_disk(filename,
1459 extract_int(&cmd[4],
1462 scr_printf("%s\n", &cmd[4]);
1466 scr_printf("*** Delete this message? ");
1468 sprintf(cmd, "DELE %ld", msg_arr[a]);
1471 scr_printf("%s\n", &cmd[4]);
1479 read_message(msg_arr[a], READ_HEADER, NULL);
1482 savedpos = num_msgs;
1483 entmsg(1, (DEFAULT_ENTRY == 46 ? 2 : 0));
1484 num_msgs = savedpos;
1490 { /* hack hack hack */
1491 /* find the next message by me, stay here if we find nothing */
1494 for (finda = a; ((finda < num_msgs) && (finda >= 0)); finda += rdir)
1496 /* this is repetitivly dumb, but that's what computers are for.
1497 We have to load up messages until we find one by us */
1501 sprintf(buf, "MSG0 %ld|%d", msg_arr[finda], 1); /* read the header so we can get 'from=' */
1504 while (serv_gets(buf), strcmp(buf, "000"))
1506 if ((!strncasecmp(buf, "from=", 5)) && (finda != a)) /* Skip current message. */
1508 if (strcasecmp(buf+5, fullname) == 0)
1510 a = lasta; /* meesa current */
1515 // we are now in synch with the server
1518 lasta = finda; /* keep one behind or we skip on the reentrance to the for */
1522 } /* end for loop */
1523 } /* end read routine */
1529 * View and edit a system message
1531 void edit_system_message(char *which_message)
1537 sprintf(desc, "system message '%s'", which_message);
1538 sprintf(read_cmd, "MESG %s", which_message);
1539 sprintf(write_cmd, "EMSG %s", which_message);
1540 do_edit(desc, read_cmd, "NOOP", write_cmd);
1547 * Verify the message base
1549 void check_message_base(void)
1554 ("Please read the documentation before running this command.\n"
1555 "Having done so, do you still want to check the message base? ");
1561 if (buf[0] != '1') {
1562 scr_printf("%s\n", &buf[4]);
1566 while (serv_gets(buf), strcmp(buf, "000")) {
1567 scr_printf("%s\n", buf);