1dd3cb568SWarner Losh /*- 2*796df753SPedro F. Giffuni * SPDX-License-Identifier: MIT-CMU 3*796df753SPedro F. Giffuni * 45b81b6b3SRodney W. Grimes * Mach Operating System 55b81b6b3SRodney W. Grimes * Copyright (c) 1991,1990 Carnegie Mellon University 65b81b6b3SRodney W. Grimes * All Rights Reserved. 75b81b6b3SRodney W. Grimes * 85b81b6b3SRodney W. Grimes * Permission to use, copy, modify and distribute this software and its 95b81b6b3SRodney W. Grimes * documentation is hereby granted, provided that both the copyright 105b81b6b3SRodney W. Grimes * notice and this permission notice appear in all copies of the 115b81b6b3SRodney W. Grimes * software, derivative works or modified versions, and any portions 125b81b6b3SRodney W. Grimes * thereof, and that both notices appear in supporting documentation. 135b81b6b3SRodney W. Grimes * 145b81b6b3SRodney W. Grimes * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 155b81b6b3SRodney W. Grimes * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 165b81b6b3SRodney W. Grimes * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 175b81b6b3SRodney W. Grimes * 185b81b6b3SRodney W. Grimes * Carnegie Mellon requests users of this software to return to 195b81b6b3SRodney W. Grimes * 205b81b6b3SRodney W. Grimes * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 215b81b6b3SRodney W. Grimes * School of Computer Science 225b81b6b3SRodney W. Grimes * Carnegie Mellon University 235b81b6b3SRodney W. Grimes * Pittsburgh PA 15213-3890 245b81b6b3SRodney W. Grimes * 255b81b6b3SRodney W. Grimes * any improvements or extensions that they make and grant Carnegie the 265b81b6b3SRodney W. Grimes * rights to redistribute these changes. 275b81b6b3SRodney W. Grimes */ 285b81b6b3SRodney W. Grimes /* 295b81b6b3SRodney W. Grimes * Author: David B. Golub, Carnegie Mellon University 305b81b6b3SRodney W. Grimes * Date: 7/90 315b81b6b3SRodney W. Grimes */ 325b81b6b3SRodney W. Grimes 33753960f7SDavid E. O'Brien #include <sys/cdefs.h> 34753960f7SDavid E. O'Brien __FBSDID("$FreeBSD$"); 35753960f7SDavid E. O'Brien 36f540b106SGarrett Wollman #include <sys/param.h> 37f540b106SGarrett Wollman #include <sys/systm.h> 38ce9edcf5SPoul-Henning Kamp #include <sys/cons.h> 395ccbc3ccSBruce Evans 40f540b106SGarrett Wollman #include <ddb/ddb.h> 41f540b106SGarrett Wollman #include <ddb/db_output.h> 425b81b6b3SRodney W. Grimes 435b81b6b3SRodney W. Grimes /* 445b81b6b3SRodney W. Grimes * Character input and editing. 455b81b6b3SRodney W. Grimes */ 465b81b6b3SRodney W. Grimes 475b81b6b3SRodney W. Grimes /* 485b81b6b3SRodney W. Grimes * We don't track output position while editing input, 495b81b6b3SRodney W. Grimes * since input always ends with a new-line. We just 505b81b6b3SRodney W. Grimes * reset the line position at the end. 515b81b6b3SRodney W. Grimes */ 5225eb640dSPoul-Henning Kamp static char * db_lbuf_start; /* start of input line buffer */ 5325eb640dSPoul-Henning Kamp static char * db_lbuf_end; /* end of input line buffer */ 5425eb640dSPoul-Henning Kamp static char * db_lc; /* current character */ 5525eb640dSPoul-Henning Kamp static char * db_le; /* one past last character */ 565b81b6b3SRodney W. Grimes 57b4630773SJoerg Wunsch /* 58b4630773SJoerg Wunsch * Simple input line history support. 59b4630773SJoerg Wunsch */ 6041630a01SBruce Evans static char db_lhistory[2048]; 61b4630773SJoerg Wunsch static int db_lhistlsize, db_lhistidx, db_lhistcur; 62d984ae1eSMike Smith static int db_lhist_nlines; 63b4630773SJoerg Wunsch 645b81b6b3SRodney W. Grimes #define CTRL(c) ((c) & 0x1f) 655b81b6b3SRodney W. Grimes #define BLANK ' ' 665b81b6b3SRodney W. Grimes #define BACKUP '\b' 675b81b6b3SRodney W. Grimes 68c2718b42SMark Johnston static int cnmaygetc(void); 6914e10f99SAlfred Perlstein static void db_delete(int n, int bwd); 7014e10f99SAlfred Perlstein static int db_inputchar(int c); 7114e10f99SAlfred Perlstein static void db_putnchars(int c, int count); 7214e10f99SAlfred Perlstein static void db_putstring(char *s, int count); 73058284fcSBruce Evans 7437c84183SPoul-Henning Kamp static void 755b81b6b3SRodney W. Grimes db_putstring(s, count) 765b81b6b3SRodney W. Grimes char *s; 775b81b6b3SRodney W. Grimes int count; 785b81b6b3SRodney W. Grimes { 795b81b6b3SRodney W. Grimes while (--count >= 0) 805b81b6b3SRodney W. Grimes cnputc(*s++); 815b81b6b3SRodney W. Grimes } 825b81b6b3SRodney W. Grimes 8337c84183SPoul-Henning Kamp static void 845b81b6b3SRodney W. Grimes db_putnchars(c, count) 855b81b6b3SRodney W. Grimes int c; 865b81b6b3SRodney W. Grimes int count; 875b81b6b3SRodney W. Grimes { 885b81b6b3SRodney W. Grimes while (--count >= 0) 895b81b6b3SRodney W. Grimes cnputc(c); 905b81b6b3SRodney W. Grimes } 915b81b6b3SRodney W. Grimes 925b81b6b3SRodney W. Grimes /* 935b81b6b3SRodney W. Grimes * Delete N characters, forward or backward 945b81b6b3SRodney W. Grimes */ 955b81b6b3SRodney W. Grimes #define DEL_FWD 0 965b81b6b3SRodney W. Grimes #define DEL_BWD 1 9737c84183SPoul-Henning Kamp static void 985b81b6b3SRodney W. Grimes db_delete(n, bwd) 995b81b6b3SRodney W. Grimes int n; 1005b81b6b3SRodney W. Grimes int bwd; 1015b81b6b3SRodney W. Grimes { 1020a95ab74SPedro F. Giffuni char *p; 1035b81b6b3SRodney W. Grimes 1045b81b6b3SRodney W. Grimes if (bwd) { 1055b81b6b3SRodney W. Grimes db_lc -= n; 1065b81b6b3SRodney W. Grimes db_putnchars(BACKUP, n); 1075b81b6b3SRodney W. Grimes } 1085b81b6b3SRodney W. Grimes for (p = db_lc; p < db_le-n; p++) { 1095b81b6b3SRodney W. Grimes *p = *(p+n); 1105b81b6b3SRodney W. Grimes cnputc(*p); 1115b81b6b3SRodney W. Grimes } 1125b81b6b3SRodney W. Grimes db_putnchars(BLANK, n); 1135b81b6b3SRodney W. Grimes db_putnchars(BACKUP, db_le - db_lc); 1145b81b6b3SRodney W. Grimes db_le -= n; 1155b81b6b3SRodney W. Grimes } 1165b81b6b3SRodney W. Grimes 1172b490bc7SPedro F. Giffuni /* returns true at end-of-line */ 11837c84183SPoul-Henning Kamp static int 1195b81b6b3SRodney W. Grimes db_inputchar(c) 1205b81b6b3SRodney W. Grimes int c; 1215b81b6b3SRodney W. Grimes { 122eae6ab5eSJoerg Wunsch static int escstate; 123eae6ab5eSJoerg Wunsch 124eae6ab5eSJoerg Wunsch if (escstate == 1) { 125eae6ab5eSJoerg Wunsch /* ESC seen, look for [ or O */ 126eae6ab5eSJoerg Wunsch if (c == '[' || c == 'O') 127eae6ab5eSJoerg Wunsch escstate++; 128eae6ab5eSJoerg Wunsch else 129eae6ab5eSJoerg Wunsch escstate = 0; /* re-init state machine */ 130eae6ab5eSJoerg Wunsch return (0); 131eae6ab5eSJoerg Wunsch } else if (escstate == 2) { 132eae6ab5eSJoerg Wunsch escstate = 0; 133eae6ab5eSJoerg Wunsch /* 134eae6ab5eSJoerg Wunsch * If a valid cursor key has been found, translate 135eae6ab5eSJoerg Wunsch * into an emacs-style control key, and fall through. 136eae6ab5eSJoerg Wunsch * Otherwise, drop off. 137eae6ab5eSJoerg Wunsch */ 1385b81b6b3SRodney W. Grimes switch (c) { 139eae6ab5eSJoerg Wunsch case 'A': /* up */ 140eae6ab5eSJoerg Wunsch c = CTRL('p'); 141eae6ab5eSJoerg Wunsch break; 142eae6ab5eSJoerg Wunsch case 'B': /* down */ 143eae6ab5eSJoerg Wunsch c = CTRL('n'); 144eae6ab5eSJoerg Wunsch break; 145eae6ab5eSJoerg Wunsch case 'C': /* right */ 146eae6ab5eSJoerg Wunsch c = CTRL('f'); 147eae6ab5eSJoerg Wunsch break; 148eae6ab5eSJoerg Wunsch case 'D': /* left */ 149eae6ab5eSJoerg Wunsch c = CTRL('b'); 150eae6ab5eSJoerg Wunsch break; 151eae6ab5eSJoerg Wunsch default: 152eae6ab5eSJoerg Wunsch return (0); 153eae6ab5eSJoerg Wunsch } 154eae6ab5eSJoerg Wunsch } 155eae6ab5eSJoerg Wunsch 156eae6ab5eSJoerg Wunsch switch (c) { 157eae6ab5eSJoerg Wunsch case CTRL('['): 158eae6ab5eSJoerg Wunsch escstate = 1; 159eae6ab5eSJoerg Wunsch break; 1605b81b6b3SRodney W. Grimes case CTRL('b'): 1615b81b6b3SRodney W. Grimes /* back up one character */ 1625b81b6b3SRodney W. Grimes if (db_lc > db_lbuf_start) { 1635b81b6b3SRodney W. Grimes cnputc(BACKUP); 1645b81b6b3SRodney W. Grimes db_lc--; 1655b81b6b3SRodney W. Grimes } 1665b81b6b3SRodney W. Grimes break; 1675b81b6b3SRodney W. Grimes case CTRL('f'): 1685b81b6b3SRodney W. Grimes /* forward one character */ 1695b81b6b3SRodney W. Grimes if (db_lc < db_le) { 1705b81b6b3SRodney W. Grimes cnputc(*db_lc); 1715b81b6b3SRodney W. Grimes db_lc++; 1725b81b6b3SRodney W. Grimes } 1735b81b6b3SRodney W. Grimes break; 1745b81b6b3SRodney W. Grimes case CTRL('a'): 1755b81b6b3SRodney W. Grimes /* beginning of line */ 1765b81b6b3SRodney W. Grimes while (db_lc > db_lbuf_start) { 1775b81b6b3SRodney W. Grimes cnputc(BACKUP); 1785b81b6b3SRodney W. Grimes db_lc--; 1795b81b6b3SRodney W. Grimes } 1805b81b6b3SRodney W. Grimes break; 1815b81b6b3SRodney W. Grimes case CTRL('e'): 1825b81b6b3SRodney W. Grimes /* end of line */ 1835b81b6b3SRodney W. Grimes while (db_lc < db_le) { 1845b81b6b3SRodney W. Grimes cnputc(*db_lc); 1855b81b6b3SRodney W. Grimes db_lc++; 1865b81b6b3SRodney W. Grimes } 1875b81b6b3SRodney W. Grimes break; 1885b81b6b3SRodney W. Grimes case CTRL('h'): 1895b81b6b3SRodney W. Grimes case 0177: 1905b81b6b3SRodney W. Grimes /* erase previous character */ 1915b81b6b3SRodney W. Grimes if (db_lc > db_lbuf_start) 1925b81b6b3SRodney W. Grimes db_delete(1, DEL_BWD); 1935b81b6b3SRodney W. Grimes break; 1945b81b6b3SRodney W. Grimes case CTRL('d'): 1955b81b6b3SRodney W. Grimes /* erase next character */ 1965b81b6b3SRodney W. Grimes if (db_lc < db_le) 1975b81b6b3SRodney W. Grimes db_delete(1, DEL_FWD); 1985b81b6b3SRodney W. Grimes break; 19909ffa9adSYaroslav Tykhiy case CTRL('u'): 20081e12dd1SEdward Tomasz Napierala case CTRL('c'): 20109ffa9adSYaroslav Tykhiy /* kill entire line: */ 20209ffa9adSYaroslav Tykhiy /* at first, delete to beginning of line */ 20309ffa9adSYaroslav Tykhiy if (db_lc > db_lbuf_start) 20409ffa9adSYaroslav Tykhiy db_delete(db_lc - db_lbuf_start, DEL_BWD); 20509ffa9adSYaroslav Tykhiy /* FALLTHROUGH */ 2065b81b6b3SRodney W. Grimes case CTRL('k'): 2075b81b6b3SRodney W. Grimes /* delete to end of line */ 2085b81b6b3SRodney W. Grimes if (db_lc < db_le) 2095b81b6b3SRodney W. Grimes db_delete(db_le - db_lc, DEL_FWD); 2105b81b6b3SRodney W. Grimes break; 2115b81b6b3SRodney W. Grimes case CTRL('t'): 2125b81b6b3SRodney W. Grimes /* twiddle last 2 characters */ 2135b81b6b3SRodney W. Grimes if (db_lc >= db_lbuf_start + 2) { 2145b81b6b3SRodney W. Grimes c = db_lc[-2]; 2155b81b6b3SRodney W. Grimes db_lc[-2] = db_lc[-1]; 2165b81b6b3SRodney W. Grimes db_lc[-1] = c; 2175b81b6b3SRodney W. Grimes cnputc(BACKUP); 2185b81b6b3SRodney W. Grimes cnputc(BACKUP); 2195b81b6b3SRodney W. Grimes cnputc(db_lc[-2]); 2205b81b6b3SRodney W. Grimes cnputc(db_lc[-1]); 2215b81b6b3SRodney W. Grimes } 2225b81b6b3SRodney W. Grimes break; 223eeb6101eSEdward Tomasz Napierala case CTRL('w'): 224eeb6101eSEdward Tomasz Napierala /* erase previous word */ 225eeb6101eSEdward Tomasz Napierala for (; db_lc > db_lbuf_start;) { 226eeb6101eSEdward Tomasz Napierala if (*(db_lc - 1) != ' ') 227eeb6101eSEdward Tomasz Napierala break; 228eeb6101eSEdward Tomasz Napierala db_delete(1, DEL_BWD); 229eeb6101eSEdward Tomasz Napierala } 230eeb6101eSEdward Tomasz Napierala for (; db_lc > db_lbuf_start;) { 231eeb6101eSEdward Tomasz Napierala if (*(db_lc - 1) == ' ') 232eeb6101eSEdward Tomasz Napierala break; 233eeb6101eSEdward Tomasz Napierala db_delete(1, DEL_BWD); 234eeb6101eSEdward Tomasz Napierala } 235eeb6101eSEdward Tomasz Napierala break; 2365b81b6b3SRodney W. Grimes case CTRL('r'): 2375b81b6b3SRodney W. Grimes db_putstring("^R\n", 3); 238b4630773SJoerg Wunsch redraw: 2395b81b6b3SRodney W. Grimes if (db_le > db_lbuf_start) { 2405b81b6b3SRodney W. Grimes db_putstring(db_lbuf_start, db_le - db_lbuf_start); 2415b81b6b3SRodney W. Grimes db_putnchars(BACKUP, db_le - db_lc); 2425b81b6b3SRodney W. Grimes } 2435b81b6b3SRodney W. Grimes break; 244b4630773SJoerg Wunsch case CTRL('p'): 245b4630773SJoerg Wunsch /* Make previous history line the active one. */ 246b4630773SJoerg Wunsch if (db_lhistcur >= 0) { 247b4630773SJoerg Wunsch bcopy(db_lhistory + db_lhistcur * db_lhistlsize, 248b4630773SJoerg Wunsch db_lbuf_start, db_lhistlsize); 249b4630773SJoerg Wunsch db_lhistcur--; 250b4630773SJoerg Wunsch goto hist_redraw; 251b4630773SJoerg Wunsch } 252b4630773SJoerg Wunsch break; 253b4630773SJoerg Wunsch case CTRL('n'): 254b4630773SJoerg Wunsch /* Make next history line the active one. */ 255b4630773SJoerg Wunsch if (db_lhistcur < db_lhistidx - 1) { 256b4630773SJoerg Wunsch db_lhistcur += 2; 257b4630773SJoerg Wunsch bcopy(db_lhistory + db_lhistcur * db_lhistlsize, 258b4630773SJoerg Wunsch db_lbuf_start, db_lhistlsize); 259b4630773SJoerg Wunsch } else { 260b4630773SJoerg Wunsch /* 261b4630773SJoerg Wunsch * ^N through tail of history, reset the 262b4630773SJoerg Wunsch * buffer to zero length. 263b4630773SJoerg Wunsch */ 264b4630773SJoerg Wunsch *db_lbuf_start = '\0'; 265b4630773SJoerg Wunsch db_lhistcur = db_lhistidx; 266b4630773SJoerg Wunsch } 267b4630773SJoerg Wunsch 268b4630773SJoerg Wunsch hist_redraw: 269ea1c6a39SRobert Watson db_putnchars(BACKUP, db_lc - db_lbuf_start); 270b4630773SJoerg Wunsch db_putnchars(BLANK, db_le - db_lbuf_start); 271b4630773SJoerg Wunsch db_putnchars(BACKUP, db_le - db_lbuf_start); 272dc15eac0SEd Schouten db_le = strchr(db_lbuf_start, '\0'); 273b4630773SJoerg Wunsch if (db_le[-1] == '\r' || db_le[-1] == '\n') 274b4630773SJoerg Wunsch *--db_le = '\0'; 275b4630773SJoerg Wunsch db_lc = db_le; 276b4630773SJoerg Wunsch goto redraw; 277b4630773SJoerg Wunsch 27875680b05SJulian Elischer case -1: 27975680b05SJulian Elischer /* 28075680b05SJulian Elischer * eek! the console returned eof. 28175680b05SJulian Elischer * probably that means we HAVE no console.. we should try bail 28275680b05SJulian Elischer * XXX 28375680b05SJulian Elischer */ 28475680b05SJulian Elischer c = '\r'; 2855b81b6b3SRodney W. Grimes case '\n': 2869a4b535cSPoul-Henning Kamp /* FALLTHROUGH */ 2875b81b6b3SRodney W. Grimes case '\r': 2885b81b6b3SRodney W. Grimes *db_le++ = c; 2895b81b6b3SRodney W. Grimes return (1); 2905b81b6b3SRodney W. Grimes default: 2915b81b6b3SRodney W. Grimes if (db_le == db_lbuf_end) { 2925b81b6b3SRodney W. Grimes cnputc('\007'); 2935b81b6b3SRodney W. Grimes } 2945b81b6b3SRodney W. Grimes else if (c >= ' ' && c <= '~') { 2950a95ab74SPedro F. Giffuni char *p; 2965b81b6b3SRodney W. Grimes 2975b81b6b3SRodney W. Grimes for (p = db_le; p > db_lc; p--) 2985b81b6b3SRodney W. Grimes *p = *(p-1); 2995b81b6b3SRodney W. Grimes *db_lc++ = c; 3005b81b6b3SRodney W. Grimes db_le++; 3015b81b6b3SRodney W. Grimes cnputc(c); 3025b81b6b3SRodney W. Grimes db_putstring(db_lc, db_le - db_lc); 3035b81b6b3SRodney W. Grimes db_putnchars(BACKUP, db_le - db_lc); 3045b81b6b3SRodney W. Grimes } 3055b81b6b3SRodney W. Grimes break; 3065b81b6b3SRodney W. Grimes } 3075b81b6b3SRodney W. Grimes return (0); 3085b81b6b3SRodney W. Grimes } 3095b81b6b3SRodney W. Grimes 310c2718b42SMark Johnston static int 311c2718b42SMark Johnston cnmaygetc() 312c2718b42SMark Johnston { 313c2718b42SMark Johnston return (-1); 314c2718b42SMark Johnston } 315c2718b42SMark Johnston 316f23b4c91SGarrett Wollman int 3175b81b6b3SRodney W. Grimes db_readline(lstart, lsize) 3185b81b6b3SRodney W. Grimes char * lstart; 3195b81b6b3SRodney W. Grimes int lsize; 3205b81b6b3SRodney W. Grimes { 321233f8184SRobert Watson 322233f8184SRobert Watson if (lsize < 2) 323233f8184SRobert Watson return (0); 32441630a01SBruce Evans if (lsize != db_lhistlsize) { 32541630a01SBruce Evans /* 32641630a01SBruce Evans * (Re)initialize input line history. Throw away any 32741630a01SBruce Evans * existing history. 32841630a01SBruce Evans */ 32941630a01SBruce Evans db_lhist_nlines = sizeof(db_lhistory) / lsize; 330b4630773SJoerg Wunsch db_lhistlsize = lsize; 331b4630773SJoerg Wunsch db_lhistidx = -1; 332b4630773SJoerg Wunsch } 333b4630773SJoerg Wunsch db_lhistcur = db_lhistidx; 334b4630773SJoerg Wunsch 3355b81b6b3SRodney W. Grimes db_force_whitespace(); /* synch output position */ 3365b81b6b3SRodney W. Grimes 3375b81b6b3SRodney W. Grimes db_lbuf_start = lstart; 338233f8184SRobert Watson db_lbuf_end = lstart + lsize - 2; /* Will append NL and NUL. */ 3395b81b6b3SRodney W. Grimes db_lc = lstart; 3405b81b6b3SRodney W. Grimes db_le = lstart; 3415b81b6b3SRodney W. Grimes 3425b81b6b3SRodney W. Grimes while (!db_inputchar(cngetc())) 3435b81b6b3SRodney W. Grimes continue; 3445b81b6b3SRodney W. Grimes 345086fec57SRobert Watson db_capture_write(lstart, db_le - db_lbuf_start); 3466ddbf1e2SGary Palmer db_printf("\n"); /* synch output position */ 3475b81b6b3SRodney W. Grimes *db_le = 0; 348b4630773SJoerg Wunsch 34941630a01SBruce Evans if (db_le - db_lbuf_start > 1) { 350b4630773SJoerg Wunsch /* Maintain input line history for non-empty lines. */ 351d984ae1eSMike Smith if (++db_lhistidx == db_lhist_nlines) { 352b4630773SJoerg Wunsch /* Rotate history. */ 3538543efaeSDag-Erling Smørgrav bcopy(db_lhistory + db_lhistlsize, db_lhistory, 354d984ae1eSMike Smith db_lhistlsize * (db_lhist_nlines - 1)); 355b4630773SJoerg Wunsch db_lhistidx--; 356b4630773SJoerg Wunsch } 35741630a01SBruce Evans bcopy(lstart, db_lhistory + db_lhistidx * db_lhistlsize, 358b4630773SJoerg Wunsch db_lhistlsize); 359b4630773SJoerg Wunsch } 360b4630773SJoerg Wunsch 3615b81b6b3SRodney W. Grimes return (db_le - db_lbuf_start); 3625b81b6b3SRodney W. Grimes } 3635b81b6b3SRodney W. Grimes 3645b81b6b3SRodney W. Grimes void 365a41dd031SPedro F. Giffuni db_check_interrupt(void) 3665b81b6b3SRodney W. Grimes { 3670a95ab74SPedro F. Giffuni int c; 3685b81b6b3SRodney W. Grimes 369c2718b42SMark Johnston c = cnmaygetc(); 3705b81b6b3SRodney W. Grimes switch (c) { 3715b81b6b3SRodney W. Grimes case -1: /* no character */ 3725b81b6b3SRodney W. Grimes return; 3735b81b6b3SRodney W. Grimes 3745b81b6b3SRodney W. Grimes case CTRL('c'): 3755b81b6b3SRodney W. Grimes db_error((char *)0); 3765b81b6b3SRodney W. Grimes /*NOTREACHED*/ 3775b81b6b3SRodney W. Grimes 3785b81b6b3SRodney W. Grimes case CTRL('s'): 3795b81b6b3SRodney W. Grimes do { 380c2718b42SMark Johnston c = cnmaygetc(); 3815b81b6b3SRodney W. Grimes if (c == CTRL('c')) 3825b81b6b3SRodney W. Grimes db_error((char *)0); 3835b81b6b3SRodney W. Grimes } while (c != CTRL('q')); 3845b81b6b3SRodney W. Grimes break; 3855b81b6b3SRodney W. Grimes 3865b81b6b3SRodney W. Grimes default: 3875b81b6b3SRodney W. Grimes /* drop on floor */ 3885b81b6b3SRodney W. Grimes break; 3895b81b6b3SRodney W. Grimes } 3905b81b6b3SRodney W. Grimes } 391