X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftrace%2Flib_tracebits.c;fp=ncurses%2Flib_raw.c;h=a92e00a8624e4341e752616d12777f01aed3a24f;hp=e2573c729d6fa4c2e6ce501b8dcc46269279553d;hb=refs%2Ftags%2Fv5.0;hpb=661078ddbde3ce0f3b06e95642fbb9b5fef7dca1 diff --git a/ncurses/lib_raw.c b/ncurses/trace/lib_tracebits.c similarity index 64% rename from ncurses/lib_raw.c rename to ncurses/trace/lib_tracebits.c index e2573c72..a92e00a8 100644 --- a/ncurses/lib_raw.c +++ b/ncurses/trace/lib_tracebits.c @@ -31,25 +31,10 @@ * and: Eric S. Raymond * ****************************************************************************/ - -/* - * raw.c - * - * Routines: - * raw() - * cbreak() - * noraw() - * nocbreak() - * qiflush() - * noqiflush() - * intrflush() - * - */ - #include #include /* cur_term */ -MODULE_ID("$Id: lib_raw.c,v 1.25 1998/02/11 12:13:59 tom Exp $") +MODULE_ID("$Id: lib_tracebits.c,v 1.3 1999/08/21 21:43:48 tom Exp $") #if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE) #define _POSIX_SOURCE @@ -72,8 +57,6 @@ MODULE_ID("$Id: lib_raw.c,v 1.25 1998/02/11 12:13:59 tom Exp $") #define IEXTEN 0 #endif -#define COOKED_INPUT (IXON|BRKINT|PARMRK) - #ifdef TRACE typedef struct {unsigned int val; const char *name;} BITNAMES; @@ -96,7 +79,7 @@ static void lookup_bits(char *buf, const BITNAMES *table, const char *label, uns (void) strcat(buf,"} "); } -char *_tracebits(void) +char *_nc_tracebits(void) /* describe the state of the terminal control bits exactly */ { char *buf; @@ -173,10 +156,18 @@ lflags[] = #if defined(CS5) && defined(CS8) switch (cur_term->Nttyb.c_cflag & CSIZE) { +#if defined(CS5) && (CS5 != 0) case CS5: strcat(buf, "CS5 "); break; +#endif +#if defined(CS6) && (CS6 != 0) case CS6: strcat(buf, "CS6 "); break; +#endif +#if defined(CS7) && (CS7 != 0) case CS7: strcat(buf, "CS7 "); break; +#endif +#if defined(CS8) && (CS8 != 0) case CS8: strcat(buf, "CS8 "); break; +#endif default: strcat(buf, "CSIZE? "); break; } #endif @@ -229,170 +220,6 @@ cflags[] = #endif return(buf); } - -#define BEFORE(N) if (_nc_tracing&TRACE_BITS) _tracef("%s before bits: %s", N, _tracebits()) -#define AFTER(N) if (_nc_tracing&TRACE_BITS) _tracef("%s after bits: %s", N, _tracebits()) #else -#define BEFORE(s) -#define AFTER(s) +char *_nc_tracebits(void) { static char tmp[] = ""; return tmp; } #endif /* TRACE */ - -int raw(void) -{ - T((T_CALLED("raw()"))); - if (SP != 0 && cur_term != 0) { - - SP->_raw = TRUE; - SP->_cbreak = TRUE; - -#ifdef __EMX__ - setmode(SP->_ifd, O_BINARY); -#endif - -#ifdef TERMIOS - BEFORE("raw"); - cur_term->Nttyb.c_lflag &= ~(ICANON|ISIG); - cur_term->Nttyb.c_iflag &= ~(COOKED_INPUT); - cur_term->Nttyb.c_cc[VMIN] = 1; - cur_term->Nttyb.c_cc[VTIME] = 0; - AFTER("raw"); -#else - cur_term->Nttyb.sg_flags |= RAW; -#endif - returnCode(_nc_set_curterm(&cur_term->Nttyb)); - } - returnCode(ERR); -} - -int cbreak(void) -{ - T((T_CALLED("cbreak()"))); - - SP->_cbreak = TRUE; - -#ifdef __EMX__ - setmode(SP->_ifd, O_BINARY); -#endif - -#ifdef TERMIOS - BEFORE("cbreak"); - cur_term->Nttyb.c_lflag &= ~ICANON; - cur_term->Nttyb.c_iflag &= ~ICRNL; - cur_term->Nttyb.c_lflag |= ISIG; - cur_term->Nttyb.c_cc[VMIN] = 1; - cur_term->Nttyb.c_cc[VTIME] = 0; - AFTER("cbreak"); -#else - cur_term->Nttyb.sg_flags |= CBREAK; -#endif - returnCode(_nc_set_curterm( &cur_term->Nttyb)); -} - -int qiflush(void) -{ - T((T_CALLED("qiflush()"))); - - /* - * Note: this implementation may be wrong. See the comment under - * intrflush(). - */ - -#ifdef TERMIOS - BEFORE("qiflush"); - cur_term->Nttyb.c_lflag &= ~(NOFLSH); - AFTER("qiflush"); - returnCode(_nc_set_curterm( &cur_term->Nttyb)); -#else - returnCode(ERR); -#endif -} - - -int noraw(void) -{ - T((T_CALLED("noraw()"))); - - SP->_raw = FALSE; - SP->_cbreak = FALSE; - -#ifdef __EMX__ - setmode(SP->_ifd, O_TEXT); -#endif - -#ifdef TERMIOS - BEFORE("noraw"); - cur_term->Nttyb.c_lflag |= ISIG|ICANON; - cur_term->Nttyb.c_iflag |= COOKED_INPUT; - AFTER("noraw"); -#else - cur_term->Nttyb.sg_flags &= ~(RAW|CBREAK); -#endif - returnCode(_nc_set_curterm( &cur_term->Nttyb)); -} - - -int nocbreak(void) -{ - T((T_CALLED("nocbreak()"))); - - SP->_cbreak = FALSE; - -#ifdef __EMX__ - setmode(SP->_ifd, O_TEXT); -#endif - -#ifdef TERMIOS - BEFORE("nocbreak"); - cur_term->Nttyb.c_lflag |= ICANON; - cur_term->Nttyb.c_iflag |= ICRNL; - AFTER("nocbreak"); -#else - cur_term->Nttyb.sg_flags &= ~CBREAK; -#endif - returnCode(_nc_set_curterm( &cur_term->Nttyb)); -} - -int noqiflush(void) -{ - T((T_CALLED("noqiflush()"))); - - /* - * Note: this implementation may be wrong. See the comment under - * intrflush(). - */ - -#ifdef TERMIOS - BEFORE("noqiflush"); - cur_term->Nttyb.c_lflag |= NOFLSH; - AFTER("noqiflush"); - returnCode(_nc_set_curterm( &cur_term->Nttyb)); -#else - returnCode(ERR); -#endif -} - -int intrflush(WINDOW *win GCC_UNUSED, bool flag) -{ - T((T_CALLED("intrflush(%d)"), flag)); - - /* - * This call does the same thing as the qiflush()/noqiflush() - * pair. We know for certain that SVr3 intrflush() tweaks the - * NOFLSH bit; on the other hand, the match (in the SVr4 man - * pages) between the language describing NOFLSH in termio(7) - * and the language describing qiflush()/noqiflush() in - * curs_inopts(3x) is too exact to be coincidence. - */ - -#ifdef TERMIOS - BEFORE("intrflush"); - if (flag) - cur_term->Nttyb.c_lflag &= ~(NOFLSH); - else - cur_term->Nttyb.c_lflag |= (NOFLSH); - AFTER("intrflush"); - returnCode(_nc_set_curterm( &cur_term->Nttyb)); -#else - returnCode(ERR); -#endif -}