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 if (FD_ISSET(0, &rfds)) {
103 the_character = inkey();
108 return(the_character);
116 * Check to see if we need to pause at the end of a screen.
117 * If we do, we have to disable server keepalives during the pause because
118 * we are probably in the middle of a server operation and the NOOP command
119 * would confuse everything.
121 int checkpagin(int lp, int pagin, int height)
125 if (sigcaught) return(lp);
126 thekey = was_a_key_pressed();
127 if ( (thekey == NEXT_KEY) || (thekey == STOP_KEY)) sigcaught = thekey;
128 if (sigcaught) return(lp);
130 if (!pagin) return(0);
131 if (lp>=(height-1)) {
132 set_keepalives(KA_NO);
134 set_keepalives(KA_YES);
144 * pprintf() ... paginated version of printf()
146 void pprintf(const char *format, ...) {
148 static char buf[4096]; /* static for performance, change if needed */
151 /* If sigcaught is nonzero, a keypress has interrupted this and we
152 * should just drain output.
154 if (sigcaught) return;
156 /* Otherwise, start spewing... */
157 va_start(arg_ptr, format);
158 vsprintf(buf, format, arg_ptr);
161 for (i=0; i<strlen(buf); ++i) {
162 putc(buf[i], stdout);
165 lines_printed = checkpagin(lines_printed,
166 (userflags & US_PAGINATOR),
175 * print_express() - print express messages if there are any
177 void print_express(void)
182 if (express_msgs == 0)
190 if (strlen(rc_exp_cmd) > 0) {
191 outpipe = popen(rc_exp_cmd, "w");
192 if (outpipe != NULL) {
193 while (serv_gets(buf), strcmp(buf, "000")) {
194 fprintf(outpipe, "%s\n", buf);
200 /* fall back to built-in express message display */
206 while (serv_gets(buf), strcmp(buf, "000")) {
214 void set_keepalives(int s)
216 keepalives_enabled = (char) s;
220 * This loop handles the "keepalive" messages sent to the server when idling.
223 static time_t idlet = 0;
224 static void really_do_keepalive(void) {
228 if (keepalives_enabled == KA_YES) {
233 if (ok_to_interrupt == 1) {
234 printf("\r%64s\r", "");
236 printf("%s%c ", room_name,
237 room_prompt(room_flags));
244 /* threaded nonblocking keepalive stuff starts here. I'm going for a simple
245 encapsulated interface; in theory there should be no need to touch these
246 globals outside of the async_ka_* functions. */
248 #ifdef THREADED_CLIENT
249 static pthread_t ka_thr_handle;
250 static int ka_thr_active = 0;
251 static int async_ka_enabled = 0;
253 static void *ka_thread(void *arg)
255 really_do_keepalive();
256 pthread_detach(ka_thr_handle);
261 /* start up a thread to handle a keepalive in the background */
262 static void async_ka_exec(void)
264 if (!ka_thr_active) {
266 if (pthread_create(&ka_thr_handle, NULL, ka_thread, NULL)) {
267 perror("pthread_create");
272 #endif /* THREADED_CLIENT */
274 static void do_keepalive(void)
279 if ((now - idlet) < ((long) S_KEEPALIVE))
282 /* Do a space-backspace to keep telnet sessions from idling out */
286 #ifdef THREADED_CLIENT
287 if (async_ka_enabled)
291 really_do_keepalive();
295 /* Now the actual async-keepalve API that we expose to higher levels:
296 async_ka_start() and async_ka_end(). These do nothing when we don't have
297 threading enabled, so we avoid sprinkling ifdef's throughout the code. */
299 /* wait for a background keepalive to complete. this must be done before
300 attempting any further server requests! */
301 void async_ka_end(void)
303 #ifdef THREADED_CLIENT
305 pthread_join(ka_thr_handle, NULL);
311 /* tell do_keepalive() that keepalives are asynchronous. */
312 void async_ka_start(void)
314 #ifdef THREADED_CLIENT
321 { /* get a character from the keyboard, with */
322 int a; /* the watchdog timer in effect if necessary */
325 time_t start_time, now;
334 /* This loop waits for keyboard input. If the keepalive
335 * timer expires, it sends a keepalive to the server if
336 * necessary and then waits again.
343 tv.tv_sec = S_KEEPALIVE;
347 if (((now - start_time) > SLEEPING)
348 && (SLEEPING != 0) && (getppid() == 1)) {
349 printf("Sleeping? Call again.\n");
352 select(1, &rfds, NULL, NULL, &tv);
353 } while (!FD_ISSET(0, &rfds));
358 /* At this point, there's input, so fetch it.
359 * (There's a hole in the bucket...)
369 if (((a != 4) && (a != 13) && (a != 8) && (a != NEXT_KEY) && (a != STOP_KEY))
370 && ((a < 32) || (a > 126)))
378 { /* Returns 1 for yes, 0 for no */
394 /* Returns 1 for yes, 0 for no, arg is default value */
417 /* Gets a line from the terminal */
418 /* string == Pointer to string buffer */
419 /* lim == Maximum length - if negative, no-show */
420 void getline(char *string, int lim)
434 if ((a == 8) && (strlen(string) == 0))
436 if ((a != 13) && (a != 8) && (strlen(string) == lim))
438 if ((a == 8) && (string[0] != 0)) {
439 string[strlen(string) - 1] = 0;
445 if ((a == 13) || (a == 10)) {
465 * strprompt() - prompt for a string, print the existing value and
466 * allow the user to press return to keep it...
468 void strprompt(char *prompt, char *str, int len)
473 printf("%s ", prompt);
476 color(BRIGHT_MAGENTA);
490 * boolprompt() - prompt for a yes/no, print the existing value and
491 * allow the user to press return to keep it...
493 int boolprompt(char *prompt, int prev_val)
498 printf("%s ", prompt);
501 color(BRIGHT_MAGENTA);
502 printf("%s", (prev_val ? "Yes" : "No"));
506 r = (yesno_d(prev_val));
512 * intprompt() - like strprompt(), except for an integer
513 * (note that it RETURNS the new value!)
515 int intprompt(char *prompt, int ival, int imin, int imax)
523 snprintf(buf, sizeof buf, "%d", i);
524 strprompt(prompt, buf, 15);
526 for (p=0; p<strlen(buf); ++p) {
527 if ( (!isdigit(buf[p]))
528 && ( (buf[p]!='-') || (p!=0) ) )
532 printf("*** Must be no less than %d.\n", imin);
534 printf("*** Must be no more than %d.\n", imax);
535 } while ((i < imin) || (i > imax));
540 * newprompt() - prompt for a string with no existing value
541 * (clears out string buffer first)
543 void newprompt(char *prompt, char *str, int len)
545 color(BRIGHT_MAGENTA);
546 printf("%s", prompt);
554 { /* returns a lower case value */
563 * parse the citadel.rc file
565 void load_command_set(void)
570 struct citcmd *lastcmd = NULL;
575 /* first, set up some defaults for non-required variables */
577 strcpy(editor_path, "");
578 strcpy(printcmd, "");
579 strcpy(rc_username, "");
580 strcpy(rc_password, "");
583 rc_allow_attachments = 0;
584 rc_remember_passwords = 0;
585 strcpy(rc_exp_cmd, "");
586 rc_display_message_numbers = 0;
587 rc_force_mail_prompts = 0;
589 strcpy(rc_url_cmd, "");
591 /* now try to open the citadel.rc file */
594 if (getenv("HOME") != NULL) {
595 snprintf(buf, sizeof buf, "%s/.citadelrc", getenv("HOME"));
596 ccfile = fopen(buf, "r");
598 if (ccfile == NULL) {
599 ccfile = fopen("/usr/local/lib/citadel.rc", "r");
601 if (ccfile == NULL) {
602 snprintf(buf, sizeof buf, "%s/citadel.rc", BBSDIR);
603 ccfile = fopen(buf, "r");
605 if (ccfile == NULL) {
606 ccfile = fopen("./citadel.rc", "r");
608 if (ccfile == NULL) {
609 perror("commands: cannot open citadel.rc");
612 while (fgets(buf, 256, ccfile) != NULL) {
613 while ((strlen(buf) > 0) ? (isspace(buf[strlen(buf) - 1])) : 0)
614 buf[strlen(buf) - 1] = 0;
616 if (!strncasecmp(buf, "editor=", 7))
617 strcpy(editor_path, &buf[7]);
619 if (!strncasecmp(buf, "printcmd=", 9))
620 strcpy(printcmd, &buf[9]);
622 if (!strncasecmp(buf, "expcmd=", 7))
623 strcpy(rc_exp_cmd, &buf[7]);
625 if (!strncasecmp(buf, "local_screen_dimensions=", 24))
626 have_xterm = (char) atoi(&buf[24]);
628 if (!strncasecmp(buf, "use_floors=", 11)) {
629 if (!strcasecmp(&buf[11], "yes"))
630 rc_floor_mode = RC_YES;
631 if (!strcasecmp(&buf[11], "no"))
632 rc_floor_mode = RC_NO;
633 if (!strcasecmp(&buf[11], "default"))
634 rc_floor_mode = RC_DEFAULT;
636 if (!strncasecmp(buf, "beep=", 5)) {
637 rc_exp_beep = atoi(&buf[5]);
639 if (!strncasecmp(buf, "allow_attachments=", 18)) {
640 rc_allow_attachments = atoi(&buf[18]);
642 if (!strncasecmp(buf, "remember_passwords=", 19)) {
643 rc_remember_passwords = atoi(&buf[19]);
645 if (!strncasecmp(buf, "display_message_numbers=", 24)) {
646 rc_display_message_numbers = atoi(&buf[24]);
648 if (!strncasecmp(buf, "force_mail_prompts=", 19)) {
649 rc_force_mail_prompts = atoi(&buf[19]);
651 if (!strncasecmp(buf, "ansi_color=", 11)) {
652 if (!strncasecmp(&buf[11], "on", 2))
654 if (!strncasecmp(&buf[11], "auto", 4))
655 rc_ansi_color = 2; /* autodetect */
656 if (!strncasecmp(&buf[11], "user", 4))
657 rc_ansi_color = 3; /* user config */
659 if (!strncasecmp(buf, "username=", 9))
660 strcpy(rc_username, &buf[9]);
662 if (!strncasecmp(buf, "password=", 9))
663 strcpy(rc_password, &buf[9]);
665 if (!strncasecmp(buf, "urlcmd=", 7))
666 strcpy(rc_url_cmd, &buf[7]);
668 if (!strncasecmp(buf, "cmd=", 4)) {
669 strcpy(buf, &buf[4]);
671 cptr = (struct citcmd *) malloc(sizeof(struct citcmd));
673 cptr->c_cmdnum = atoi(buf);
674 for (d = strlen(buf); d >= 0; --d)
677 strcpy(buf, &buf[b + 1]);
679 cptr->c_axlevel = atoi(buf);
680 for (d = strlen(buf); d >= 0; --d)
683 strcpy(buf, &buf[b + 1]);
685 for (a = 0; a < 5; ++a)
686 cptr->c_keys[a][0] = 0;
690 buf[strlen(buf) + 1] = 0;
691 while (strlen(buf) > 0) {
693 for (d = strlen(buf); d >= 0; --d)
696 strncpy(cptr->c_keys[a], buf, b);
697 cptr->c_keys[a][b] = 0;
699 strcpy(buf, &buf[b + 1]);
709 lastcmd->next = cptr;
719 * return the key associated with a command
721 char keycmd(char *cmdstr)
725 for (a = 0; a < strlen(cmdstr); ++a)
726 if (cmdstr[a] == '&')
727 return (tolower(cmdstr[a + 1]));
733 * Output the string from a key command without the ampersand
734 * "mode" should be set to 0 for normal or 1 for <C>ommand key highlighting
736 char *cmd_expand(char *strbuf, int mode)
744 for (a = 0; a < strlen(exp); ++a) {
745 if (strbuf[a] == '&') {
748 strcpy(&exp[a], &exp[a + 1]);
752 strcpy(buf, &exp[a + 2]);
758 if (!strncmp(&exp[a], "^r", 2)) {
760 strcpy(&exp[a], room_name);
761 strcat(exp, &buf[a + 2]);
763 if (!strncmp(&exp[a], "^c", 2)) {
765 strcpy(&exp[a + 1], &exp[a + 2]);
775 * Comparison function to determine if entered commands match a
776 * command loaded from the config file.
778 int cmdmatch(char *cmdbuf, struct citcmd *cptr, int ncomp)
789 for (a = 0; a < ncomp; ++a) {
790 if ((tolower(cmdbuf[a]) != keycmd(cptr->c_keys[a]))
791 || (cptr->c_axlevel > cmdax))
799 * This function returns 1 if a given command requires a string input
801 int requires_string(struct citcmd *cptr, int ncomp)
806 strcpy(buf, cptr->c_keys[ncomp - 1]);
807 for (a = 0; a < strlen(buf); ++a) {
816 * Input a command at the main prompt.
817 * This function returns an integer command number. If the command prompts
818 * for a string then it is placed in the supplied buffer.
820 int getcmd(char *argbuf)
832 * Starting a new command now, so set sigcaught to 0. This variable
833 * is set to nonzero (usually NEXT_KEY or STOP_KEY) if a command has
834 * been interrupted by a keypress.
838 /* Switch color support on or off if we're in user mode */
839 if (rc_ansi_color == 3) {
840 if (userflags & US_COLOR)
845 /* if we're running in idiot mode, display a cute little menu */
846 IFNEXPERT formout("mainmenu");
848 print_express(); /* print express messages if there are any */
851 for (a = 0; a < 5; ++a)
853 /* now the room prompt... */
856 printf("\n%s", room_name);
858 printf("%c ", room_prompt(room_flags));
865 /* Handle the backspace key, but only if there's something
866 * to backspace over...
868 if ((ch == 8) && (cmdpos > 0)) {
869 back(cmdspaces[cmdpos - 1] + 1);
873 /* Spacebar invokes "lazy traversal" commands */
874 if ((ch == 32) && (cmdpos == 0)) {
875 this_lazy_cmd = next_lazy_cmd;
876 if (this_lazy_cmd == 13)
878 if (this_lazy_cmd == 5)
880 for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
881 if (cptr->c_cmdnum == this_lazy_cmd) {
882 for (a = 0; a < 5; ++a)
883 if (cptr->c_keys[a][0] != 0)
884 printf("%s ", cmd_expand(
885 cptr->c_keys[a], 0));
887 return (this_lazy_cmd);
891 return (this_lazy_cmd);
893 /* Otherwise, process the command */
894 cmdbuf[cmdpos] = tolower(ch);
896 for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
897 if (cmdmatch(cmdbuf, cptr, cmdpos + 1)) {
899 printf("%s", cmd_expand(cptr->c_keys[cmdpos], 0));
900 cmdspaces[cmdpos] = strlen(
901 cmd_expand(cptr->c_keys[cmdpos], 0));
903 if ((cptr->c_keys[cmdpos + 1]) != 0)
909 for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
910 if (cmdmatch(cmdbuf, cptr, 5)) {
911 /* We've found our command. */
912 if (requires_string(cptr, cmdpos)) {
918 /* If this command is one that changes rooms,
919 * then the next lazy-command (space bar)
920 * should be "read new" instead of "goto"
922 if ((cptr->c_cmdnum == 5)
923 || (cptr->c_cmdnum == 6)
924 || (cptr->c_cmdnum == 47)
925 || (cptr->c_cmdnum == 52)
926 || (cptr->c_cmdnum == 16)
927 || (cptr->c_cmdnum == 20))
930 return (cptr->c_cmdnum);
936 printf("\rOne of ... \n");
937 for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
938 if (cmdmatch(cmdbuf, cptr, cmdpos)) {
939 for (a = 0; a < 5; ++a) {
940 printf("%s ", cmd_expand(cptr->c_keys[a], 1));
946 printf("\n%s%c ", room_name, room_prompt(room_flags));
948 for (cptr = cmdlist; cptr != NULL; cptr = cptr->next) {
949 if ((got == 0) && (cmdmatch(cmdbuf, cptr, cmdpos))) {
950 for (a = 0; a < cmdpos; ++a) {
952 cmd_expand(cptr->c_keys[a], 0));
967 * set tty modes. commands are:
969 * 01- set to bbs mode
970 * 2 - save current settings for later restoral
971 * 3 - restore saved settings
973 #ifdef HAVE_TERMIOS_H
974 void sttybbs(int cmd)
975 { /* SysV version of sttybbs() */
977 static struct termios saved_settings;
978 static int last_cmd = 0;
985 if ((cmd == 0) || (cmd == 1)) {
987 live.c_iflag = ISTRIP | IXON | IXANY;
988 live.c_oflag = OPOST | ONLCR;
989 live.c_lflag = ISIG | NOFLSH;
991 live.c_cc[VINTR] = (-1);
992 live.c_cc[VQUIT] = (-1);
994 /* do we even need this stuff anymore? */
996 live.c_cc[VERASE] = 8;
997 live.c_cc[VKILL] = 24;
999 live.c_cc[VEOL] = 255;
1000 live.c_cc[VEOL2] = 0;
1001 live.c_cc[VSTART] = 0;
1002 tcsetattr(0, TCSADRAIN, &live);
1005 tcgetattr(0, &saved_settings);
1008 tcsetattr(0, TCSADRAIN, &saved_settings);
1012 void sttybbs(int cmd)
1013 { /* BSD version of sttybbs() */
1015 static struct sgttyb saved_settings;
1017 if ((cmd == 0) || (cmd == 1)) {
1019 live.sg_flags |= CBREAK;
1020 live.sg_flags |= CRMOD;
1021 live.sg_flags |= NL1;
1022 live.sg_flags &= ~ECHO;
1024 live.sg_flags |= NOFLSH;
1028 gtty(0, &saved_settings);
1031 stty(0, &saved_settings);
1038 * display_help() - help file viewer
1040 void display_help(char *name)
1047 * fmout() - Citadel text formatter and paginator
1050 int width, /* screen width to use */
1051 FILE *fp, /* file to read from, or NULL to read from server */
1052 char pagin, /* nonzero if we should use the paginator */
1053 int height, /* screen height to use */
1054 int starting_lp,/* starting value for lines_printed, -1 for global */
1055 char subst) /* nonzero if we should use hypertext mode */
1057 int a, b, c, d, old;
1063 num_urls = 0; /* Start with a clean slate of embedded URL's */
1065 if (starting_lp >= 0) {
1066 lines_printed = starting_lp;
1071 c = 1; /* c is the current pos */
1073 FMTA: while ((eof_flag == 0) && (strlen(buffer) < 126)) {
1074 if (fp != NULL) { /* read from file */
1077 if (eof_flag == 0) {
1079 buffer[strlen(buffer) + 1] = 0;
1080 buffer[strlen(buffer)] = a;
1082 } else { /* read from server */
1084 serv_gets(&buffer[d]);
1085 while ((!isspace(buffer[d])) && (isspace(buffer[strlen(buffer) - 1])))
1086 buffer[strlen(buffer) - 1] = 0;
1087 if (!strcmp(&buffer[d], "000")) {
1090 while (isspace(buffer[strlen(buffer) - 1]))
1091 buffer[strlen(buffer) - 1] = 0;
1099 if ( (!strncasecmp(buffer, "http://", 7))
1100 || (!strncasecmp(buffer, "ftp://", 6)) ) {
1101 safestrncpy(urls[num_urls], buffer, 255);
1102 for (a=0; a<strlen(urls[num_urls]); ++a) {
1103 b = urls[num_urls][a];
1104 if ( (b==' ') || (b==')') || (b=='>') || (b==10)
1105 || (b==13) || (b==9) || (b=='\"') )
1106 urls[num_urls][a] = 0;
1111 buffer[strlen(buffer) + 1] = 0;
1113 strcpy(buffer, &buffer[1]);
1120 if (((a == 13) || (a == 10)) && (old != 13) && (old != 10))
1122 if (((old == 13) || (old == 10)) && (isspace(real))) {
1125 lines_printed = checkpagin(lines_printed, pagin, height);
1132 if (((strlen(aaa) + c) > (width - 5)) && (strlen(aaa) > (width - 5))) {
1133 printf("\n%s", aaa);
1137 lines_printed = checkpagin(lines_printed, pagin, height);
1144 if ((strlen(aaa) + c) > (width - 5)) {
1148 lines_printed = checkpagin(lines_printed, pagin, height);
1152 c = c + strlen(aaa);
1156 if ((a == 13) || (a == 10)) {
1157 printf("%s\n", aaa);
1160 lines_printed = checkpagin(lines_printed, pagin, height);
1161 if (sigcaught) goto OOPS;
1167 /* keypress caught; drain the server */
1170 } while (strcmp(aaa, "000"));
1172 FMTEND: printf("\n");
1174 lines_printed = checkpagin(lines_printed, pagin, height);
1180 * support ANSI color if defined
1182 void color(int colornum)
1184 static int is_bold = 0;
1185 static int hold_color, current_color;
1187 if (colornum == COLOR_PUSH) {
1188 hold_color = current_color;
1192 if (colornum == COLOR_POP) {
1197 current_color = colornum;
1199 /* When switching to dim white, actually output an 'original
1200 * pair' sequence -- this looks better on black-on-white
1203 if (colornum == DIM_WHITE)
1204 printf("\033[39;49m");
1206 printf("\033[3%d;40m", (colornum & 7));
1208 if ((colornum >= 8) && (is_bold == 0)) {
1211 } else if ((colornum < 8) && (is_bold == 1)) {
1219 void cls(int colornum)
1222 printf("\033[4%dm\033[2J\033[H\033[0m", colornum);
1229 * Detect whether ANSI color is available (answerback)
1231 void send_ansi_detect(void)
1233 if (rc_ansi_color == 2) {
1240 void look_for_ansi(void)
1248 if (rc_ansi_color == 0) {
1250 } else if (rc_ansi_color == 1) {
1252 } else if (rc_ansi_color == 2) {
1254 /* otherwise, do the auto-detect */
1259 if ((now - AnsiDetect) < 2)
1268 select(1, &rfds, NULL, NULL, &tv);
1269 if (FD_ISSET(0, &rfds)) {
1270 abuf[strlen(abuf) + 1] = 0;
1271 read(0, &abuf[strlen(abuf)], 1);
1273 } while (FD_ISSET(0, &rfds));
1275 for (a = 0; a < strlen(abuf); ++a) {
1276 if ((abuf[a] == 27) && (abuf[a + 1] == '[')
1277 && (abuf[a + 2] == '?')) {
1286 * Display key options (highlight hotkeys inside angle brackets)
1288 void keyopt(char *buf) {
1292 for (i=0; i<strlen(buf); ++i) {
1294 putc(buf[i], stdout);
1295 color(BRIGHT_MAGENTA);
1300 putc(buf[i], stdout);
1309 * Present a key-menu line choice type of thing
1311 char keymenu(char *menuprompt, char *menustring) {
1317 int display_prompt = 1;
1319 choices = num_tokens(menustring, '|');
1321 if (menuprompt != NULL) do_prompt = 1;
1322 if (menuprompt != NULL) if (strlen(menuprompt)==0) do_prompt = 0;
1325 if (display_prompt) {
1327 printf("%s ", menuprompt);
1330 for (i=0; i<choices; ++i) {
1331 extract(buf, menustring, i);
1341 if ( (do_prompt) && (ch=='?') ) {
1342 printf("\rOne of... ");
1344 for (i=0; i<choices; ++i) {
1345 extract(buf, menustring, i);
1354 for (i=0; i<choices; ++i) {
1355 extract(buf, menustring, i);
1356 for (c=1; c<strlen(buf); ++c) {
1357 if ( (ch == tolower(buf[c]))
1359 && (buf[c+1]=='>') ) {
1360 for (a=0; a<strlen(buf); ++a) {
1361 if ( (a!=(c-1)) && (a!=(c+1))) {
1362 putc(buf[a], stdout);