1 /* $OpenBSD: fifo_defs.h,v 1.1 1997/12/03 05:21:08 millert Exp $ */ 2 3 4 /*************************************************************************** 5 * COPYRIGHT NOTICE * 6 **************************************************************************** 7 * ncurses is copyright (C) 1992-1995 * 8 * Zeyd M. Ben-Halim * 9 * zmbenhal@netcom.com * 10 * Eric S. Raymond * 11 * esr@snark.thyrsus.com * 12 * * 13 * Permission is hereby granted to reproduce and distribute ncurses * 14 * by any means and for any fee, whether alone or as part of a * 15 * larger distribution, in source or in binary form, PROVIDED * 16 * this notice is included with any such distribution, and is not * 17 * removed from any of its header files. Mention of ncurses in any * 18 * applications linked with it is highly appreciated. * 19 * * 20 * ncurses comes AS IS with no warranty, implied or expressed. * 21 * * 22 ***************************************************************************/ 23 24 /* 25 * Common macros for lib_getch.c, lib_ungetch.c 26 * 27 * Id: fifo_defs.h,v 1.1 1997/10/19 02:31:46 tom Exp $ 28 */ 29 30 #ifndef FIFO_DEFS_H 31 #define FIFO_DEFS_H 1 32 33 #define head SP->_fifohead 34 #define tail SP->_fifotail 35 /* peek points to next uninterpreted character */ 36 #define peek SP->_fifopeek 37 38 #define h_inc() { head == FIFO_SIZE-1 ? head = 0 : head++; if (head == tail) head = -1, tail = 0;} 39 #define h_dec() { head == 0 ? head = FIFO_SIZE-1 : head--; if (head == tail) tail = -1;} 40 #define t_inc() { tail == FIFO_SIZE-1 ? tail = 0 : tail++; if (tail == head) tail = -1;} 41 #define t_dec() { tail == 0 ? tail = FIFO_SIZE-1 : tail--; if (head == tail) fifo_clear();} 42 #define p_inc() { peek == FIFO_SIZE-1 ? peek = 0 : peek++;} 43 44 #define cooked_key_in_fifo() (head!=-1 && peek!=head) 45 #define raw_key_in_fifo() (head!=-1 && peek!=tail) 46 47 #undef HIDE_EINTR 48 49 #endif /* FIFO_DEFS_H */ 50