4 * This file contains functions which implement parts of the
5 * text-mode user interface.
16 #include <sys/types.h>
25 #ifdef HAVE_SYS_SELECT_H
26 #include <sys/select.h>
29 #ifdef THREADED_CLIENT
39 #include "citadel_decls.h"
41 #include "routines2.h"
55 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
60 int rc_allow_attachments;
61 int rc_display_message_numbers;
62 int rc_force_mail_prompts;
63 int rc_remember_passwords;
66 char urls[MAXURLS][256];
70 int next_lazy_cmd = 5;
72 int lines_printed = 0; /* line count for paginator */
73 extern int screenwidth, screenheight;
75 struct citcmd *cmdlist = NULL;
78 /* these variables are local to this module */
79 char keepalives_enabled = KA_YES; /* send NOOPs to server when idle */
80 int ok_to_interrupt = 0; /* print express msgs asynchronously */
81 time_t AnsiDetect; /* when did we send the detect code? */
82 int enable_color = 0; /* nonzero for ANSI color */
88 * If an interesting key has been pressed, return its value, otherwise 0
90 char was_a_key_pressed(void) {
100 retval = select(1, &rfds, NULL, NULL, &tv);
102 /* Careful! Disable keepalives during keyboard polling; we're probably
103 * in the middle of a data transfer from the server, in which case
104 * sending a NOOP would throw the client protocol out of sync.
106 if (FD_ISSET(0, &rfds)) {
107 set_keepalives(KA_NO);
108 the_character = inkey();
109 set_keepalives(KA_YES);
114 return(the_character);
122 * Check to see if we need to pause at the end of a screen.
123 * If we do, we have to disable server keepalives during the pause because
124 * we are probably in the middle of a server operation and the NOOP command
125 * would confuse everything.
127 int checkpagin(int lp, int pagin, int height)
131 if (sigcaught) return(lp);
132 thekey = was_a_key_pressed();
133 if ( (thekey == NEXT_KEY) || (thekey == STOP_KEY)) sigcaught = thekey;
134 if (sigcaught) return(lp);
136 if (!pagin) return(0);
137 if (lp>=(height-1)) {
138 set_keepalives(KA_NO);
140 set_keepalives(KA_YES);
150 * pprintf() ... paginated version of printf()
152 void pprintf(const char *format, ...) {
154 static char buf[4096]; /* static for performance, change if needed */
157 /* If sigcaught is nonzero, a keypress has interrupted this and we
158 * should just drain output.
160 if (sigcaught) return;
162 /* Otherwise, start spewing... */
163 va_start(arg_ptr, format);
164 vsprintf(buf, format, arg_ptr);
167 for (i=0; i<strlen(buf); ++i) {
168 putc(buf[i], stdout);
171 lines_printed = checkpagin(lines_printed,
172 (userflags & US_PAGINATOR),
181 * print_express() - print express messages if there are any
183 void print_express(void)
188 if (express_msgs == 0)
196 if (strlen(rc_exp_cmd) > 0) {
197 outpipe = popen(rc_exp_cmd, "w");
198 if (outpipe != NULL) {
199 while (serv_gets(buf), strcmp(buf, "000")) {
200 fprintf(outpipe, "%s\n", buf);
206 /* fall back to built-in express message display */
212 while (serv_gets(buf), strcmp(buf, "000")) {
220 void set_keepalives(int s)
222 keepalives_enabled = (char) s;
226 * This loop handles the "keepalive" messages sent to the server when idling.
229 static time_t idlet = 0;
230 static void really_do_keepalive(void) {
234 if (keepalives_enabled == KA_YES) {
239 if (ok_to_interrupt == 1) {
240 printf("\r%64s\r", "");
242 printf("%s%c ", room_name,
243 room_prompt(room_flags));
250 /* threaded nonblocking keepalive stuff starts here. I'm going for a simple
251 encapsulated interface; in theory there should be no need to touch these
252 globals outside of the async_ka_* functions. */
254 #ifdef THREADED_CLIENT
255 static pthread_t ka_thr_handle;
256 static int ka_thr_active = 0;
257 static int async_ka_enabled = 0;
259 static void *ka_thread(void *arg)
261 really_do_keepalive();
262 pthread_detach(ka_thr_handle);
267 /* start up a thread to handle a keepalive in the background */
268 static void async_ka_exec(void)
270 if (!ka_thr_active) {
272 if (pthread_create(&ka_thr_handle, NULL, ka_thread, NULL)) {
273 perror("pthread_create");
278 #endif /* THREADED_CLIENT */
280 static void do_keepalive(void)
285 if ((now - idlet) < ((long) S_KEEPALIVE))
288 /* Do a space-backspace to keep telnet sessions from idling out */
292 #ifdef THREADED_CLIENT
293 if (async_ka_enabled)
297 really_do_keepalive();
301 /* Now the actual async-keepalve API that we expose to higher levels:
302 async_ka_start() and async_ka_end(). These do nothing when we don't have
303 threading enabled, so we avoid sprinkling ifdef's throughout the code. */
305 /* wait for a background keepalive to complete. this must be done before
306 attempting any further server requests! */
307 void async_ka_end(void)
309 #ifdef THREADED_CLIENT
311 pthread_join(ka_thr_handle, NULL);
317 /* tell do_keepalive() that keepalives are asynchronous. */
318 void async_ka_start(void)
320 #ifdef THREADED_CLIENT
327 { /* get a character from the keyboard, with */
328 int a; /* the watchdog timer in effect if necessary */
331 time_t start_time, now;
340 /* This loop waits for keyboard input. If the keepalive
341 * timer expires, it sends a keepalive to the server if
342 * necessary and then waits again.
349 tv.tv_sec = S_KEEPALIVE;
353 if (((now - start_time) > SLEEPING)
354 && (SLEEPING != 0) && (getppid() == 1)) {
355 printf("Sleeping? Call again.\n");
358 select(1, &rfds, NULL, NULL, &tv);
359 } while (!FD_ISSET(0, &rfds));
364 /* At this point, there's input, so fetch it.
365 * (There's a hole in the bucket...)
375 if (((a != 4) && (a != 13) && (a != 8) && (a != NEXT_KEY) && (a != STOP_KEY))
376 && ((a < 32) || (a > 126)))
384 { /* Returns 1 for yes, 0 for no */
400 /* Returns 1 for yes, 0 for no, arg is default value */
423 /* Gets a line from the terminal */
424 /* string == Pointer to string buffer */
425 /* lim == Maximum length - if negative, no-show */
426 void getline(char *string, int lim)
440 if ((a == 8) && (strlen(string) == 0))
442 if ((a != 13) && (a != 8) && (strlen(string) == lim))
444 if ((a == 8) && (string[0] != 0)) {
445 string[strlen(string) - 1] = 0;
451 if ((a == 13) || (a == 10)) {
471 * strprompt() - prompt for a string, print the existing value and
472 * allow the user to press return to keep it...
474 void strprompt(char *prompt, char *str, int len)
479 printf("%s ", prompt);
482 color(BRIGHT_MAGENTA);
496 * boolprompt() - prompt for a yes/no, print the existing value and
497 * allow the user to press return to keep it...
499 int boolprompt(char *prompt, int prev_val)
504 printf("%s ", prompt);
507 color(BRIGHT_MAGENTA);
508 printf("%s", (prev_val ? "Yes" : "No"));
512 r = (yesno_d(prev_val));
518 * intprompt() - like strprompt(), except for an integer
519 * (note that it RETURNS the new value!)
521 int intprompt(char *prompt, int ival, int imin, int imax)
529 snprintf(buf, sizeof buf, "%d", i);
530 strprompt(prompt, buf, 15);
532 for (p=0; p<strlen(buf); ++p) {
533 if ( (!isdigit(buf[p]))
534 && ( (buf[p]!='-') || (p!=0) ) )
538 printf("*** Must be no less than %d.\n", imin);
540 printf("*** Must be no more than %d.\n", imax);
541 } while ((i < imin) || (i > imax));
546 * newprompt() - prompt for a string with no existing value
547 * (clears out string buffer first)
549 void newprompt(char *prompt, char *str, int len)
551 color(BRIGHT_MAGENTA);
552 printf("%s", prompt);
560 { /* returns a lower case value */
569 * parse the citadel.rc file
571 void load_command_set(void)
576 struct citcmd *lastcmd = NULL;
581 /* first, set up some defaults for non-required variables */
583 strcpy(editor_path, "");
584 strcpy(printcmd, "");
585 strcpy(rc_username, "");
586 strcpy(rc_password, "");
589 rc_allow_attachments = 0;
590 rc_remember_passwords = 0;
591 strcpy(rc_exp_cmd, "");
592 rc_display_message_numbers = 0;
593 rc_force_mail_prompts = 0;
595 strcpy(rc_url_cmd, "");
597 /* now try to open the citadel.rc file */
600 if (getenv("HOME") != NULL) {
601 snprintf(buf, sizeof buf, "%s/.citadelrc", getenv("HOME"));
602 ccfile = fopen(buf, "r");
604 if (ccfile == NULL) {
605 ccfile = fopen("/usr/local/lib/citadel.rc", "r");
607 if (ccfile == NULL) {
608 snprintf(buf, sizeof buf, "%s/citadel.rc", BBSDIR);
609 ccfile = fopen(buf, "r");
611 if (ccfile == NULL) {
612 ccfile = fopen("./citadel.rc", "r");
614 if (ccfile == NULL) {
615 perror("commands: cannot open citadel.rc");
618 while (fgets(buf, 256, ccfile) != NULL) {
619 while ((strlen(buf) > 0) ? (isspace(buf[strlen(buf) - 1])) : 0)
620 buf[strlen(buf) - 1] = 0;
622 if (!strncasecmp(buf, "editor=", 7))
623 strcpy(editor_path, &buf[7]);
625 if (!strncasecmp(buf, "printcmd=", 9))
626 strcpy(printcmd, &buf[9]);
628 if (!strncasecmp(buf, "expcmd=", 7))
629 strcpy(rc_exp_cmd, &buf[7]);
631 if (!strncasecmp(buf, "local_screen_dimensions=", 24))
632 have_xterm = (char) atoi(&buf[24]);
634 if (!strncasecmp(buf, "use_floors=", 11)) {
635 if (!strcasecmp(&buf[11], "yes"))
636 rc_floor_mode = RC_YES;
637 if (!strcasecmp(&buf[11], "no"))
638 rc_floor_mode = RC_NO;
639 if (!strcasecmp(&buf[11], "default"))
640 rc_floor_mode = RC_DEFAULT;
642 if (!strncasecmp(buf, "beep=", 5)) {
643 rc_exp_beep = atoi(&buf[5]);
645 if (!strncasecmp(buf, "allow_attachments=", 18)) {
646 rc_allow_attachments = atoi(&buf[18]);
648 if (!strncasecmp(buf, "remember_passwords=", 19)) {
649 rc_remember_passwords = atoi(&buf[19]);
651 if (!strncasecmp(buf, "display_message_numbers=", 24)) {
652 rc_display_message_numbers = atoi(&buf[24]);
654 if (!strncasecmp(buf, "force_mail_prompts=", 19)) {
655 rc_force_mail_prompts = atoi(&buf[19]);
657 if (!strncasecmp(buf, "ansi_color=", 11)) {
658 if (!strncasecmp(&buf[11], "on", 2))
660 if (!strncasecmp(&buf[11], "auto", 4))
661 rc_ansi_color = 2; /* autodetect */
662 if (!strncasecmp(&buf[11], "user", 4))
663 rc_ansi_color = 3; /* user config */
665 if (!strncasecmp(buf, "username=", 9))
666 strcpy(rc_username, &buf[9]);
668 if (!strncasecmp(buf, "password=", 9))
669 strcpy(rc_password, &buf[9]);
671 if (!strncasecmp(buf, "urlcmd=", 7))
672 strcpy(rc_url_cmd, &buf[7]);
674 if (!strncasecmp(buf, "cmd=", 4)) {
675 strcpy(buf, &buf[4]);
677 cptr = (struct citcmd *) malloc(sizeof(struct citcmd));
679 cptr->c_cmdnum = atoi(buf);
680 for (d = strlen(buf); d >= 0; --d)
683 strcpy(buf, &buf[b + 1]);
685 cptr->c_axlevel = atoi(buf);
686 for (d = strlen(buf); d >= 0; --d)
689 strcpy(buf, &buf[b + 1]);
691 for (a = 0; a < 5; ++a)
692 cptr->c_keys[a][0] = 0;
696 buf[strlen(buf) + 1] = 0;
697 while (strlen(buf) > 0) {
699 for (d = strlen(buf); d >= 0; --d)
702 strncpy(cptr->c_keys[a], buf, b);
703 cptr->c_keys[a][b] = 0;
705 strcpy(buf, &buf[b + 1]);
715 lastcmd->next = cptr;
725 * return the key associated with a command
727 char keycmd(char *cmdstr)
731 for (a = 0; a < strlen(cmdstr); ++a)
732 if (cmdstr[a] == '&')
733 return (tolower(cmdstr[a + 1]));
739 * Output the string from a key command without the ampersand
740 * "mode" should be set to 0 for normal or 1 for <C>ommand key highlighting
742 char *cmd_expand(char *strbuf, int mode)
750 for (a = 0; a < strlen(exp); ++a) {
751 if (strbuf[a] == '&') {
754 strcpy(&exp[a], &exp[a + 1]);
758 strcpy(buf, &exp[a + 2]);
764 if (!strncmp(&exp[a], "^r", 2)) {
766 strcpy(&exp[a], room_name);
767 strcat(exp, &buf[a + 2]);
769 if (!strncmp(&exp[a], "^c", 2)) {
771 strcpy(&exp[a + 1], &exp[a + 2]);
781 * Comparison function to determine if entered commands match a
782 * command loaded from the config file.
784 int cmdmatch(char *cmdbuf, struct citcmd *cptr, int ncomp)
795 for (a = 0; a < ncomp; ++a) {
796 if ((tolower(cmdbuf[a]) != keycmd(cptr->c_keys[a]))
797 || (cptr->c_axlevel > cmdax))
805 * This function returns 1 if a given command requires a string input
807 int requires_string(struct citcmd *cptr, int ncomp)
812 strcpy(buf, cptr->c_keys[ncomp - 1]);
813 for (a = 0; a < strlen(buf); ++a) {
822 * Input a command at the main prompt.
823 * This function returns an integer command number. If the command prompts
824 * for a string then it is placed in the supplied buffer.
826 int getcmd(char *argbuf)
838 * Starting a new command now, so set sigcaught to 0. This variable
839 * is set to nonzero (usually NEXT_KEY or STOP_KEY) if a command has
840 * been interrupted by a keypress.
844 /* Switch color support on or off if we're in user mode */
845 if (rc_ansi_color == 3) {
846 if (userflags & US_COLOR)
851 /* if we're running in idiot mode, display a cute little menu */
852 IFNEXPERT formout("mainmenu");
854 print_express(); /* print express messages if there are any */
857 for (a = 0; a < 5; ++a)
859 /* now the room prompt... */
862 printf("\n%s", room_name);
864 printf("%c ", room_prompt(room_flags));
871 /* Handle the backspace key, but only if there's something
872 * to backspace over...
874 if ((ch == 8) && (cmdpos > 0)) {
875 back(cmdspaces[cmdpos - 1] + 1);
879 /* Spacebar invokes "lazy traversal" commands */
880 if ((ch == 32) && (cmdpos == 0)) {
881 this_lazy_cmd = next_lazy_cmd;
882 if (this_lazy_cmd == 13)
884 if (this_lazy_cmd == 5)
886 for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
887 if (cptr->c_cmdnum == this_lazy_cmd) {
888 for (a = 0; a < 5; ++a)
889 if (cptr->c_keys[a][0] != 0)
890 printf("%s ", cmd_expand(
891 cptr->c_keys[a], 0));
893 return (this_lazy_cmd);
897 return (this_lazy_cmd);
899 /* Otherwise, process the command */
900 cmdbuf[cmdpos] = tolower(ch);
902 for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
903 if (cmdmatch(cmdbuf, cptr, cmdpos + 1)) {
905 printf("%s", cmd_expand(cptr->c_keys[cmdpos], 0));
906 cmdspaces[cmdpos] = strlen(
907 cmd_expand(cptr->c_keys[cmdpos], 0));
909 if ((cptr->c_keys[cmdpos + 1]) != 0)
915 for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
916 if (cmdmatch(cmdbuf, cptr, 5)) {
917 /* We've found our command. */
918 if (requires_string(cptr, cmdpos)) {
924 /* If this command is one that changes rooms,
925 * then the next lazy-command (space bar)
926 * should be "read new" instead of "goto"
928 if ((cptr->c_cmdnum == 5)
929 || (cptr->c_cmdnum == 6)
930 || (cptr->c_cmdnum == 47)
931 || (cptr->c_cmdnum == 52)
932 || (cptr->c_cmdnum == 16)
933 || (cptr->c_cmdnum == 20))
936 return (cptr->c_cmdnum);
942 printf("\rOne of ... \n");
943 for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
944 if (cmdmatch(cmdbuf, cptr, cmdpos)) {
945 for (a = 0; a < 5; ++a) {
946 printf("%s ", cmd_expand(cptr->c_keys[a], 1));
952 printf("\n%s%c ", room_name, room_prompt(room_flags));
954 for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
955 if ((got == 0) && (cmdmatch(cmdbuf, cptr, cmdpos))) {
956 for (a = 0; a < cmdpos; ++a) {
958 cmd_expand(cptr->c_keys[a], 0));
973 * set tty modes. commands are:
975 * 01- set to bbs mode
976 * 2 - save current settings for later restoral
977 * 3 - restore saved settings
979 #ifdef HAVE_TERMIOS_H
980 void sttybbs(int cmd)
981 { /* SysV version of sttybbs() */
983 static struct termios saved_settings;
984 static int last_cmd = 0;
991 if ((cmd == 0) || (cmd == 1)) {
993 live.c_iflag = ISTRIP | IXON | IXANY;
994 live.c_oflag = OPOST | ONLCR;
995 live.c_lflag = ISIG | NOFLSH;
997 live.c_cc[VINTR] = (-1);
998 live.c_cc[VQUIT] = (-1);
1000 /* do we even need this stuff anymore? */
1001 /* live.c_line=0; */
1002 live.c_cc[VERASE] = 8;
1003 live.c_cc[VKILL] = 24;
1004 live.c_cc[VEOF] = 1;
1005 live.c_cc[VEOL] = 255;
1006 live.c_cc[VEOL2] = 0;
1007 live.c_cc[VSTART] = 0;
1008 tcsetattr(0, TCSADRAIN, &live);
1011 tcgetattr(0, &saved_settings);
1014 tcsetattr(0, TCSADRAIN, &saved_settings);
1018 void sttybbs(int cmd)
1019 { /* BSD version of sttybbs() */
1021 static struct sgttyb saved_settings;
1023 if ((cmd == 0) || (cmd == 1)) {
1025 live.sg_flags |= CBREAK;
1026 live.sg_flags |= CRMOD;
1027 live.sg_flags |= NL1;
1028 live.sg_flags &= ~ECHO;
1030 live.sg_flags |= NOFLSH;
1034 gtty(0, &saved_settings);
1037 stty(0, &saved_settings);
1044 * display_help() - help file viewer
1046 void display_help(char *name)
1053 * fmout() - Citadel text formatter and paginator
1056 int width, /* screen width to use */
1057 FILE *fp, /* file to read from, or NULL to read from server */
1058 char pagin, /* nonzero if we should use the paginator */
1059 int height, /* screen height to use */
1060 int starting_lp,/* starting value for lines_printed, -1 for global */
1061 char subst) /* nonzero if we should use hypertext mode */
1063 int a, b, c, d, old;
1069 num_urls = 0; /* Start with a clean slate of embedded URL's */
1071 if (starting_lp >= 0) {
1072 lines_printed = starting_lp;
1077 c = 1; /* c is the current pos */
1079 FMTA: while ((eof_flag == 0) && (strlen(buffer) < 126)) {
1080 if (fp != NULL) { /* read from file */
1083 if (eof_flag == 0) {
1085 buffer[strlen(buffer) + 1] = 0;
1086 buffer[strlen(buffer)] = a;
1088 } else { /* read from server */
1090 serv_gets(&buffer[d]);
1091 while ((!isspace(buffer[d])) && (isspace(buffer[strlen(buffer) - 1])))
1092 buffer[strlen(buffer) - 1] = 0;
1093 if (!strcmp(&buffer[d], "000")) {
1096 while (isspace(buffer[strlen(buffer) - 1]))
1097 buffer[strlen(buffer) - 1] = 0;
1105 if ( (!strncasecmp(buffer, "http://", 7))
1106 || (!strncasecmp(buffer, "ftp://", 6)) ) {
1107 safestrncpy(urls[num_urls], buffer, 255);
1108 for (a=0; a<strlen(urls[num_urls]); ++a) {
1109 b = urls[num_urls][a];
1110 if ( (b==' ') || (b==')') || (b=='>') || (b==10)
1111 || (b==13) || (b==9) || (b=='\"') )
1112 urls[num_urls][a] = 0;
1117 buffer[strlen(buffer) + 1] = 0;
1119 strcpy(buffer, &buffer[1]);
1126 if (((a == 13) || (a == 10)) && (old != 13) && (old != 10))
1128 if (((old == 13) || (old == 10)) && (isspace(real))) {
1131 lines_printed = checkpagin(lines_printed, pagin, height);
1138 if (((strlen(aaa) + c) > (width - 5)) && (strlen(aaa) > (width - 5))) {
1139 printf("\n%s", aaa);
1143 lines_printed = checkpagin(lines_printed, pagin, height);
1150 if ((strlen(aaa) + c) > (width - 5)) {
1154 lines_printed = checkpagin(lines_printed, pagin, height);
1158 c = c + strlen(aaa);
1162 if ((a == 13) || (a == 10)) {
1163 printf("%s\n", aaa);
1166 lines_printed = checkpagin(lines_printed, pagin, height);
1167 if (sigcaught) goto OOPS;
1173 /* keypress caught; drain the server */
1176 } while (strcmp(aaa, "000"));
1178 FMTEND: printf("\n");
1180 lines_printed = checkpagin(lines_printed, pagin, height);
1186 * support ANSI color if defined
1188 void color(int colornum)
1190 static int is_bold = 0;
1191 static int hold_color, current_color;
1193 if (colornum == COLOR_PUSH) {
1194 hold_color = current_color;
1198 if (colornum == COLOR_POP) {
1203 current_color = colornum;
1205 /* When switching to dim white, actually output an 'original
1206 * pair' sequence -- this looks better on black-on-white
1209 if (colornum == DIM_WHITE)
1210 printf("\033[39;49m");
1212 printf("\033[3%d;40m", (colornum & 7));
1214 if ((colornum >= 8) && (is_bold == 0)) {
1217 } else if ((colornum < 8) && (is_bold == 1)) {
1225 void cls(int colornum)
1228 printf("\033[4%dm\033[2J\033[H\033[0m", colornum);
1235 * Detect whether ANSI color is available (answerback)
1237 void send_ansi_detect(void)
1239 if (rc_ansi_color == 2) {
1246 void look_for_ansi(void)
1254 if (rc_ansi_color == 0) {
1256 } else if (rc_ansi_color == 1) {
1258 } else if (rc_ansi_color == 2) {
1260 /* otherwise, do the auto-detect */
1265 if ((now - AnsiDetect) < 2)
1274 select(1, &rfds, NULL, NULL, &tv);
1275 if (FD_ISSET(0, &rfds)) {
1276 abuf[strlen(abuf) + 1] = 0;
1277 read(0, &abuf[strlen(abuf)], 1);
1279 } while (FD_ISSET(0, &rfds));
1281 for (a = 0; a < strlen(abuf); ++a) {
1282 if ((abuf[a] == 27) && (abuf[a + 1] == '[')
1283 && (abuf[a + 2] == '?')) {
1292 * Display key options (highlight hotkeys inside angle brackets)
1294 void keyopt(char *buf) {
1298 for (i=0; i<strlen(buf); ++i) {
1300 putc(buf[i], stdout);
1301 color(BRIGHT_MAGENTA);
1306 putc(buf[i], stdout);
1315 * Present a key-menu line choice type of thing
1317 char keymenu(char *menuprompt, char *menustring) {
1323 int display_prompt = 1;
1325 choices = num_tokens(menustring, '|');
1327 if (menuprompt != NULL) do_prompt = 1;
1328 if (menuprompt != NULL) if (strlen(menuprompt)==0) do_prompt = 0;
1331 if (display_prompt) {
1333 printf("%s ", menuprompt);
1336 for (i=0; i<choices; ++i) {
1337 extract(buf, menustring, i);
1347 if ( (do_prompt) && (ch=='?') ) {
1348 printf("\rOne of... ");
1350 for (i=0; i<choices; ++i) {
1351 extract(buf, menustring, i);
1360 for (i=0; i<choices; ++i) {
1361 extract(buf, menustring, i);
1362 for (c=1; c<strlen(buf); ++c) {
1363 if ( (ch == tolower(buf[c]))
1365 && (buf[c+1]=='>') ) {
1366 for (a=0; a<strlen(buf); ++a) {
1367 if ( (a!=(c-1)) && (a!=(c+1))) {
1368 putc(buf[a], stdout);