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 fmout(int width, FILE * fp, char pagin, int height, int starting_lp,
55 int haschar(char *st, int ch);
56 int checkpagin(int lp, int pagin, int height);
57 void getline(char *string, int lim);
58 void formout(char *name);
60 void newprompt(char *prompt, char *str, int len);
61 int file_checksum(char *filename);
62 void do_edit(char *desc, char *read_cmd, char *check_cmd, char *write_cmd);
65 long msg_arr[MAXMSGS];
67 char rc_alt_semantics;
68 extern char room_name[];
69 extern unsigned room_flags;
70 extern long highest_msg_read;
71 extern struct CtdlServInfo serv_info;
74 extern int screenwidth;
75 extern int screenheight;
76 extern long maxmsgnum;
79 extern char is_room_aide;
80 extern char fullname[];
82 extern unsigned userflags;
83 extern char sigcaught;
84 extern char editor_path[];
85 extern char printcmd[];
86 extern int rc_allow_attachments;
87 extern int rc_display_message_numbers;
88 extern int rc_force_mail_prompts;
90 extern int editor_pid;
92 void ka_sigcatch(int signum)
96 signal(SIGALRM, ka_sigcatch);
103 * server keep-alive version of wait() (needed for external editor)
105 pid_t ka_wait(int *kstatus)
110 signal(SIGALRM, ka_sigcatch);
114 } while (errno == EINTR);
115 signal(SIGALRM, SIG_IGN);
122 * version of system() that uses ka_wait()
124 int ka_system(char *shc)
133 perror("Cannot fork");
135 return ((pid_t) childpid);
139 execlp("/bin/sh", "sh", "-c", shc, NULL);
145 waitpid = ka_wait(&retcode);
146 } while (waitpid != childpid);
156 * add a newline to the buffer...
158 void add_newline(struct cittext *textlist)
163 while (ptr->next != NULL)
166 while (ptr->text[strlen(ptr->text) - 1] == 32)
167 ptr->text[strlen(ptr->text) - 1] = 0;
168 /* strcat(ptr->text,"\n"); */
170 ptr->next = (struct cittext *)
171 malloc(sizeof(struct cittext));
174 strcpy(ptr->text, "");
179 * add a word to the buffer...
181 void add_word(struct cittext *textlist, char *wordbuf)
186 while (ptr->next != NULL)
189 if (3 + strlen(ptr->text) + strlen(wordbuf) > screenwidth) {
190 ptr->next = (struct cittext *)
191 malloc(sizeof(struct cittext));
194 strcpy(ptr->text, "");
197 strcat(ptr->text, wordbuf);
198 strcat(ptr->text, " ");
203 * begin editing of an opened file pointed to by fp
205 void citedit(FILE * fp)
207 int a, prev, finished, b, last_space;
209 struct cittext *textlist = NULL;
211 char wordbuf[MAXWORDBUF];
213 /* first, load the text into the buffer */
215 textlist = (struct cittext *) malloc(sizeof(struct cittext));
216 textlist->next = NULL;
217 strcpy(textlist->text, "");
221 while (a = getc(fp), a >= 0) {
223 if ((a == 32) || (a == 9) || (a == 13) || (a == 10)) {
224 add_word(textlist, wordbuf);
226 if ((prev == 13) || (prev == 10)) {
227 add_word(textlist, "\n");
228 add_newline(textlist);
229 add_word(textlist, "");
232 wordbuf[strlen(wordbuf) + 1] = 0;
233 wordbuf[strlen(wordbuf)] = a;
235 if (strlen(wordbuf) + 3 > screenwidth) {
236 add_word(textlist, wordbuf);
244 prev = (appending ? 13 : (-1));
256 /******* new ***********/
257 if ((a > 32) && (a < 127) && (prev == 13)) {
258 add_word(textlist, "\n");
261 /***********************/
263 if ((a == 32) && (prev == 13)) {
264 add_word(textlist, "\n");
265 add_newline(textlist);
269 if (strlen(wordbuf) > 0) {
270 wordbuf[strlen(wordbuf) - 1] = 0;
275 } else if (a == 13) {
277 if (strlen(wordbuf) == 0)
280 for (b = 0; b < strlen(wordbuf); ++b)
281 if (wordbuf[b] == 32) {
289 add_word(textlist, wordbuf);
294 wordbuf[strlen(wordbuf) + 1] = 0;
295 wordbuf[strlen(wordbuf)] = a;
297 if ((strlen(wordbuf) + 3) > screenwidth) {
299 for (b = 0; b < strlen(wordbuf); ++b)
300 if (wordbuf[b] == 32)
302 if (last_space >= 0) {
303 for (b = 0; b < strlen(wordbuf); ++b)
304 if (wordbuf[b] == 32) {
312 for (b = 0; b < strlen(wordbuf); ++b) {
317 scr_printf("\n%s", wordbuf);
319 add_word(textlist, wordbuf);
325 } while (finished == 0);
328 /* write the buffer back to disk */
330 for (ptr = textlist; ptr != NULL; ptr = ptr->next) {
331 fprintf(fp, "%s", ptr->text);
335 ftruncate(fileno(fp), ftell(fp));
337 /* and deallocate the memory we used */
338 while (textlist != NULL) {
339 ptr = textlist->next;
345 /* Read a message from the server
348 long num, /* message number */
349 char pagin) /* 0 = normal read, 1 = read with pagination, 2 = header */
353 char from[SIZ], node[SIZ], rfca[SIZ];
362 sprintf(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");
382 lines_printed = checkpagin(lines_printed, pagin, screenheight);
389 while (serv_gets(buf), strcmp(buf, "000")) {
391 scr_printf("%s\n", buf);
394 checkpagin(lines_printed,
395 pagin, screenheight);
402 while (serv_gets(buf), strncasecmp(buf, "text", 4)) {
403 if (!strncasecmp(buf, "nhdr=yes", 8))
405 if (!strncasecmp(buf, "from=", 5)) {
406 strcpy(from, &buf[5]);
410 if (!strncasecmp(buf, "type=", 5))
411 format_type = atoi(&buf[5]);
412 if ((!strncasecmp(buf, "msgn=", 5))
413 && (rc_display_message_numbers)) {
417 scr_printf("#%s", &buf[5]);
421 if (!strncasecmp(buf, "from=", 5)) {
425 scr_printf("%s ", &buf[5]);
427 if (!strncasecmp(buf, "subj=", 5))
428 strcpy(m_subject, &buf[5]);
430 if (!strncasecmp(buf, "rfca=", 5)) {
431 safestrncpy(rfca, &buf[5], sizeof(rfca) - 5);
435 scr_printf("%s", &buf[5]);
439 if ((!strncasecmp(buf, "hnod=", 5))
440 && (strcasecmp(&buf[5], serv_info.serv_humannode))
441 && (strlen(rfca) == 0)) {
445 scr_printf("%s", &buf[5]);
449 if ((!strncasecmp(buf, "room=", 5))
450 && (strcasecmp(&buf[5], room_name))
451 && (strlen(rfca) == 0)) {
454 color(BRIGHT_MAGENTA);
455 scr_printf("%s> ", &buf[5]);
458 if (!strncasecmp(buf, "node=", 5)) {
459 safestrncpy(node, &buf[5], sizeof(buf) - 5);
460 if ((room_flags & QR_NETWORK)
463 (&buf[5], serv_info.serv_nodename)
465 (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
467 if (strlen(rfca) == 0) {
470 color(BRIGHT_YELLOW);
471 scr_printf("%s ", &buf[5]);
476 if (!strncasecmp(buf, "rcpt=", 5)) {
480 scr_printf("%s ", &buf[5]);
482 if (!strncasecmp(buf, "time=", 5)) {
483 fmt_date(now, atol(&buf[5]), 0);
484 scr_printf("%s ", now);
492 scr_printf(" %s", from);
497 if (strlen(rfca) > 0) {
498 strcpy(reply_to, rfca);
500 snprintf(reply_to, sizeof(reply_to), "%s @ %s", from,
507 lines_printed = checkpagin(lines_printed, pagin, screenheight);
509 if (strlen(m_subject) > 0) {
510 scr_printf("Subject: %s\n", m_subject);
513 checkpagin(lines_printed, pagin, screenheight);
516 if (format_type == 0) {
517 fr = fmout(screenwidth, NULL,
518 ((pagin == 1) ? 1 : 0), screenheight, (-1), 1);
520 while (serv_gets(buf), strcmp(buf, "000")) {
521 if (sigcaught == 0) {
522 scr_printf("%s\n", buf);
523 lines_printed = lines_printed + 1 +
524 (strlen(buf) / screenwidth);
526 checkpagin(lines_printed, pagin,
535 lines_printed = checkpagin(lines_printed, pagin, screenheight);
544 * replace string function for the built-in editor
546 void replace_string(char *filename, long int startpos)
555 int substitutions = 0;
558 scr_printf("Enter text to be replaced:\n: ");
559 getline(srch_str, 128);
560 if (strlen(srch_str) == 0)
563 scr_printf("Enter text to replace it with:\n: ");
564 getline(rplc_str, 128);
566 fp = fopen(filename, "r+");
571 fseek(fp, startpos, 0);
573 while (a = getc(fp), a > 0) {
575 buf[strlen(buf) + 1] = 0;
576 buf[strlen(buf)] = a;
577 if (strlen(buf) >= strlen(srch_str)) {
578 ptr = (&buf[strlen(buf) - strlen(srch_str)]);
579 if (!strncasecmp(ptr, srch_str, strlen(srch_str))) {
580 strcpy(ptr, rplc_str);
584 if (strlen(buf) > 384) {
587 fwrite((char *) buf, 128, 1, fp);
588 strcpy(buf, &buf[128]);
595 fwrite((char *) buf, strlen(buf), 1, fp);
598 truncate(filename, wpos);
599 scr_printf("<R>eplace made %d substitution(s).\n\n", substitutions);
603 * Function to begin composing a new message
605 int client_make_message(char *filename, /* temporary file name */
606 char *recipient, /* NULL if it's not mail */
607 int anon_type, /* see MES_ types in header file */
619 if (strlen(editor_path) == 0) {
621 ("*** No editor available, using built-in editor\n");
625 fmt_date(datestr, time(NULL), 0);
628 if (room_flags & QR_ANONONLY && !recipient) {
629 sprintf(&header[strlen(header)], " ****");
632 sprintf(&header[strlen(header)],
633 " %s from %s", datestr, fullname);
634 if (strlen(recipient) > 0) {
635 sprintf(&header[strlen(header)],
636 " to %s", recipient);
639 scr_printf("%s\n", header);
644 scr_printf("(Press ctrl-d when finished)\n");
648 fp = fopen(filename, "r");
650 fmout(screenwidth, fp, 0, screenheight, 0, 0);
654 fp = fopen(filename, "w");
656 err_printf("*** Error opening temp file!\n"
658 filename, strerror(errno));
668 fp = fopen(filename, "r+");
670 err_printf("*** Error opening temp file!\n"
672 filename, strerror(errno));
680 fp = fopen(filename, "a");
682 err_printf("*** Error opening temp file!\n"
684 filename, strerror(errno));
704 e_ex_code = 1; /* start with a failed exit code */
706 cksum = file_checksum(filename);
707 if (editor_pid == 0) {
708 chmod(filename, 0600);
711 setenv("WINDOW_TITLE", header, 1);
712 execlp(editor_path, editor_path, filename, NULL);
718 b = ka_wait(&e_ex_code);
719 } while ((b != editor_pid) && (b >= 0));
726 MECR: if (mode == 2) {
727 if (file_checksum(filename) == cksum) {
728 err_printf("*** Aborted message.\n");
736 b = keymenu("Entry command (? for options)",
737 "<A>bort|<C>ontinue|<S>ave message|<P>rint formatted|"
738 "<R>eplace string|<H>old message");
747 scr_printf(" %s from %s", datestr, fullname);
748 if (strlen(recipient) > 0)
749 scr_printf(" to %s", recipient);
751 fp = fopen(filename, "r");
753 fmout(screenwidth, fp,
754 ((userflags & US_PAGINATOR) ? 1 : 0),
762 replace_string(filename, 0L);
771 MEABT: scr_printf("Are you sure? ");
775 MEABT2: unlink(filename);
780 * Transmit message text to the server.
782 * This loop also implements a "tick" counter that displays the progress, if
783 * we're sending something that will take a long time to transmit.
785 void transmit_message(FILE *fp)
792 fseek(fp, 0L, SEEK_END);
795 lasttick = time(NULL);
797 while (ch = getc(fp), (ch >= 0)) {
799 if (!strcmp(buf, "000"))
807 if ((ch == 32) && (strlen(buf) > 200)) {
809 if (!strcmp(buf, "000"))
814 if (strlen(buf) > 250) {
815 if (!strcmp(buf, "000"))
822 if ((time(NULL) - lasttick) > 2L) {
823 scr_printf(" %3ld%% completed\r",
824 ((ftell(fp) * 100L) / msglen));
826 lasttick = time(NULL);
838 * entmsg() - edit and create a message
839 * returns 0 if message was saved
841 int entmsg(int is_reply, /* nonzero if this was a <R>eply command */
858 * First, check to see if we have permission to enter a message in
859 * this room. The server will return an error code if we can't.
861 sprintf(cmd, "ENT0 0||0|%d", mode);
865 if ((strncmp(cmd, "570", 3)) && (strncmp(cmd, "200", 3))) {
866 scr_printf("%s\n", &cmd[4]);
870 /* Error code 570 is special. It means that we CAN enter a message
871 * in this room, but a recipient needs to be specified.
874 if (!strncmp(cmd, "570", 3))
877 /* If the user is a dumbass, tell them how to type. */
878 if ((userflags & US_EXPERT) == 0) {
882 /* Handle the selection of a recipient, if necessary. */
884 if (need_recp == 1) {
887 strcpy(buf, reply_to);
889 scr_printf("Enter recipient: ");
890 getline(buf, (SIZ-100) );
891 if (strlen(buf) == 0)
895 strcpy(buf, "sysop");
899 if (room_flags & QR_ANONOPT) {
900 scr_printf("Anonymous (Y/N)? ");
905 /* If it's mail, we've got to check the validity of the recipient... */
906 if (strlen(buf) > 0) {
907 sprintf(cmd, "ENT0 0|%s|%d|%d", buf, b, mode);
911 scr_printf("%s\n", &cmd[4]);
916 /* Learn the number of the newest message in in the room, so we can
917 * tell upon saving whether someone else has posted too.
920 serv_puts("MSGS LAST|1");
923 scr_printf("%s\n", &cmd[5]);
925 while (serv_gets(cmd), strcmp(cmd, "000")) {
926 msg_arr[num_msgs++] = atol(cmd);
930 /* Now compose the message... */
931 if (client_make_message(temp, buf, b, 0, c) != 0) {
935 /* Reopen the temp file that was created, so we can send it */
936 fp = fopen(temp, "r");
938 /* Yes, unlink it now, so it doesn't stick around if we crash */
942 err_printf("*** Internal error while trying to save message!\n"
944 temp, strerror(errno));
948 /* Transmit message to the server */
949 sprintf(cmd, "ENT0 1|%s|%d|%d||", buf, b, mode);
953 scr_printf("%s\n", &cmd[4]);
957 transmit_message(fp);
962 highmsg = msg_arr[num_msgs - 1];
964 serv_puts("MSGS NEW");
967 scr_printf("%s\n", &cmd[5]);
969 while (serv_gets(cmd), strcmp(cmd, "000")) {
970 msg_arr[num_msgs++] = atol(cmd);
974 /* get new highest message number in room to set lrp for goto... */
975 maxmsgnum = msg_arr[num_msgs - 1];
977 /* now see if anyone else has posted in here */
979 for (a = 0; a < num_msgs; ++a) {
980 if (msg_arr[a] > highmsg) {
985 /* In the Mail> room, this algorithm always counts one message
986 * higher than in public rooms, so we decrement it by one.
993 scr_printf("*** 1 additional message has been entered "
994 "in this room by another user.\n");
997 scr_printf("*** %d additional messages have been entered "
998 "in this room by other users.\n", b);
1005 * Do editing on a quoted file
1007 void process_quote(void)
1009 FILE *qfile, *tfile;
1011 int line, qstart, qend;
1013 /* Unlink the second temp file as soon as it's opened, so it'll get
1014 * deleted even if the program dies
1016 qfile = fopen(temp2, "r");
1019 /* Display the quotable text with line numbers added */
1021 fgets(buf, 128, qfile);
1022 while (fgets(buf, 128, qfile) != NULL) {
1023 scr_printf("%2d %s", ++line, buf);
1025 scr_printf("Begin quoting at [ 1] : ");
1027 qstart = (buf[0] == 0) ? (1) : atoi(buf);
1028 scr_printf(" End quoting at [%d] : ", line);
1030 qend = (buf[0] == 0) ? (line) : atoi(buf);
1033 fgets(buf, 128, qfile);
1034 tfile = fopen(temp, "w");
1035 while (fgets(buf, 128, qfile) != NULL) {
1036 if ((++line >= qstart) && (line <= qend))
1037 fprintf(tfile, " >%s", buf);
1039 fprintf(tfile, " \n");
1048 * List the URL's which were embedded in the previous message
1055 if (num_urls == 0) {
1056 scr_printf("There were no URL's in the previous message.\n\n");
1060 for (i = 0; i < num_urls; ++i) {
1061 scr_printf("%3d %s\n", i + 1, urls[i]);
1064 if ((i = num_urls) != 1)
1065 i = intprompt("Display which one", 1, 1, num_urls);
1067 sprintf(cmd, rc_url_cmd, urls[i - 1]);
1073 * Read the messages in the current room
1076 int c, /* 0=Read all 1=Read new 2=Read old 3=Read last q */
1077 int rdir, /* 1=Forward (-1)=Reverse */
1078 int q /* Number of msgs to read (if c==3) */
1080 int a, b, e, f, g, start;
1086 char prtfile[PATH_MAX];
1089 char targ[ROOMNAMELEN];
1097 strcpy(prtfile, tmpnam(NULL));
1100 strcpy(cmd, "MSGS ");
1112 sprintf(&cmd[strlen(cmd)], "LAST|%d", q);
1117 if (cmd[0] != '1') {
1118 scr_printf("%s\n", &cmd[5]);
1120 while (serv_gets(cmd), strcmp(cmd, "000")) {
1121 if (num_msgs == MAXMSGS) {
1122 memcpy(&msg_arr[0], &msg_arr[1],
1123 (sizeof(long) * (MAXMSGS - 1)));
1126 msg_arr[num_msgs++] = atol(cmd);
1130 if (num_msgs == 0) {
1132 scr_printf("*** There are no ");
1133 if (c == 1) scr_printf("new ");
1134 if (c == 2) scr_printf("old ");
1135 scr_printf("messages in this room.\n");
1141 /* this loop cycles through each message... */
1142 start = ((rdir == 1) ? 0 : (num_msgs - 1));
1143 for (a = start; ((a < num_msgs) && (a >= 0)); a = a + rdir) {
1144 while (msg_arr[a] == 0L) {
1146 if ((a == MAXMSGS) || (a == (-1)))
1150 RAGAIN: pagin = ((arcflag == 0)
1152 && (userflags & US_PAGINATOR)) ? 1 : 0;
1154 /* If we're doing a quote, set the screenwidth to 72 */
1156 hold_sw = screenwidth;
1160 /* If printing or archiving, set the screenwidth to 80 */
1162 hold_sw = screenwidth;
1166 /* now read the message... */
1167 e = read_message(msg_arr[a], pagin);
1169 /* ...and set the screenwidth back if we have to */
1170 if ((quotflag) || (arcflag)) {
1171 screenwidth = hold_sw;
1173 RMSGREAD: scr_flush();
1174 highest_msg_read = msg_arr[a];
1176 freopen("/dev/tty", "r+", stdout);
1178 enable_color = hold_color;
1182 freopen("/dev/tty", "r+", stdout);
1184 enable_color = hold_color;
1187 freopen(prtfile, "r", stdin);
1189 sttybbs(SB_RESTORE);
1190 ka_system(printcmd);
1191 sttybbs(SB_NO_INTR);
1199 } while ((g != f) && (g >= 0));
1200 scr_printf("Message printed.\n");
1202 if (rc_alt_semantics && c == 1) {
1205 snprintf(buf, sizeof(buf), "SEEN %ld", msg_arr[a]);
1207 serv_gets(buf); /* Don't need to check this? */
1211 if (((userflags & US_NOPROMPT) || (e == 2))
1212 && (((room_flags & QR_MAILBOX) == 0)
1213 || (rc_force_mail_prompts == 0))) {
1218 color(BRIGHT_WHITE);
1219 scr_printf("%d", num_msgs - a - 1);
1223 keyopt("<B>ack <A>gain <Q>uote <R>eply <N>ext <S>top m<Y> next ");
1224 if (rc_url_cmd[0] && num_urls)
1225 keyopt("<U>RLview ");
1226 keyopt("<?>help -> ");
1230 e = (inkey() & 127);
1232 /* return key same as <N> */ if (e == 13)
1234 /* space key same as <N> */ if (e == 32)
1236 /* del/move for aides only */
1238 && ((room_flags & QR_MAILBOX) ==
1240 if ((e == 'd') || (e == 'm'))
1243 /* print only if available */
1244 if ((e == 'p') && (strlen(printcmd) == 0))
1246 /* can't file if not allowed */
1248 && (rc_allow_attachments == 0))
1250 /* link only if browser avail*/
1252 && (strlen(rc_url_cmd) == 0))
1254 } while ((e != 'a') && (e != 'n') && (e != 's')
1255 && (e != 'd') && (e != 'm') && (e != 'p')
1256 && (e != 'q') && (e != 'b') && (e != 'h')
1257 && (e != 'r') && (e != 'f') && (e != '?')
1258 && (e != 'u') && (e != 'c') && (e != 'y'));
1264 scr_printf("Again");
1267 scr_printf("Delete");
1279 scr_printf("Print");
1282 scr_printf("Quote");
1288 scr_printf("Header");
1291 scr_printf("Reply");
1297 scr_printf("URL's");
1300 scr_printf("mY next");
1303 scr_printf("? <help>");
1306 if (userflags & US_DISAPPEAR)
1307 scr_printf("\r%79s\r", "");
1314 scr_printf("Options available here:\n"
1315 " ? Help (prints this message)\n"
1316 " S Stop reading immediately\n"
1317 " A Again (repeats last message)\n"
1318 " N Next (continue with next message)\n"
1319 " Y My Next (continue with next message you authored)\n"
1320 " B Back (go back to previous message)\n");
1322 || (room_flags & QR_MAILBOX)) {
1323 scr_printf(" D Delete this message\n"
1324 " M Move message to another room\n");
1326 scr_printf(" C Copy message to another room\n");
1327 if (strlen(printcmd) > 0)
1328 scr_printf(" P Print this message\n");
1330 " Q Quote portions of this message for your next post\n"
1331 " H Headers (display message headers only)\n");
1333 scr_printf(" R Reply to this message\n");
1334 if (rc_allow_attachments)
1336 (" F (save attachments to a file)\n");
1337 if (strlen(rc_url_cmd) > 0)
1338 scr_printf(" U (list URL's for display)\n");
1343 freopen(prtfile, "w", stdout);
1345 hold_color = enable_color;
1350 freopen(temp2, "w", stdout);
1352 hold_color = enable_color;
1364 newprompt("Enter target room: ",
1365 targ, ROOMNAMELEN - 1);
1366 if (strlen(targ) > 0) {
1367 sprintf(cmd, "MOVE %ld|%s|%d",
1369 (e == 'c' ? 1 : 0));
1372 scr_printf("%s\n", &cmd[4]);
1382 newprompt("Which section? ", filename,
1383 ((sizeof filename) - 1));
1384 snprintf(cmd, sizeof cmd,
1385 "OPNA %ld|%s", msg_arr[a], filename);
1388 if (cmd[0] == '2') {
1389 extract(filename, &cmd[4], 2);
1390 download_to_local_disk(filename,
1391 extract_int(&cmd[4],
1394 scr_printf("%s\n", &cmd[4]);
1398 scr_printf("*** Delete this message? ");
1400 sprintf(cmd, "DELE %ld", msg_arr[a]);
1403 scr_printf("%s\n", &cmd[4]);
1411 read_message(msg_arr[a], READ_HEADER);
1414 savedpos = num_msgs;
1415 entmsg(1, (DEFAULT_ENTRY == 46 ? 2 : 0));
1416 num_msgs = savedpos;
1422 { /* hack hack hack */
1423 /* find the next message by me, stay here if we find nothing */
1426 for (finda = a; ((finda < num_msgs) && (finda >= 0)); finda += rdir)
1428 /* this is repetitivly dumb, but that's what computers are for.
1429 We have to load up messages until we find one by us */
1433 sprintf(buf, "MSG0 %ld|%d", msg_arr[finda], 1); /* read the header so we can get 'from=' */
1436 while (serv_gets(buf), strcmp(buf, "000"))
1438 if ((!strncasecmp(buf, "from=", 5)) && (finda != a)) /* Skip current message. */
1440 if (strcasecmp(buf+5, fullname) == 0)
1442 a = lasta; /* meesa current */
1447 // we are now in synch with the server
1450 lasta = finda; /* keep one behind or we skip on the reentrance to the for */
1454 } /* end for loop */
1455 } /* end read routine */
1461 * View and edit a system message
1463 void edit_system_message(char *which_message)
1469 sprintf(desc, "system message '%s'", which_message);
1470 sprintf(read_cmd, "MESG %s", which_message);
1471 sprintf(write_cmd, "EMSG %s", which_message);
1472 do_edit(desc, read_cmd, "NOOP", write_cmd);
1479 * Verify the message base
1481 void check_message_base(void)
1486 ("Please read the documentation before running this command.\n"
1487 "Having done so, do you still want to check the message base? ");
1493 if (buf[0] != '1') {
1494 scr_printf("%s\n", &buf[4]);
1498 while (serv_gets(buf), strcmp(buf, "000")) {
1499 scr_printf("%s\n", buf);