Home | History | Annotate | Line # | Download | only in libcurses
nodelay.c revision 1.7.26.1
      1  1.7.26.1  perseant /*      $NetBSD: nodelay.c,v 1.7.26.1 2025/08/02 05:54:47 perseant Exp $  */
      2       1.1       mrg 
      3       1.1       mrg /*-
      4       1.1       mrg  * Copyright (c) 1998-1999 Brett Lymn (blymn (at) baea.com.au, brett_lymn (at) yahoo.com)
      5       1.1       mrg  * All rights reserved.
      6       1.1       mrg  *
      7       1.1       mrg  * Redistribution and use in source and binary forms, with or without
      8       1.1       mrg  * modification, are permitted provided that the following conditions
      9       1.1       mrg  * are met:
     10       1.1       mrg  * 1. Redistributions of source code must retain the above copyright
     11       1.1       mrg  *    notice, this list of conditions and the following disclaimer.
     12       1.1       mrg  * 2. The name of the author may not be used to endorse or promote products
     13       1.5       wiz  *    derived from this software without specific prior written permission
     14       1.1       mrg  *
     15       1.1       mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16       1.1       mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17       1.1       mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18       1.1       mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19       1.1       mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20       1.1       mrg  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21       1.1       mrg  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22       1.1       mrg  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23       1.1       mrg  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24       1.1       mrg  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25       1.1       mrg  *
     26       1.1       mrg  *
     27       1.1       mrg  */
     28       1.4     blymn 
     29       1.4     blymn #include <sys/cdefs.h>
     30       1.4     blymn #ifndef lint
     31  1.7.26.1  perseant __RCSID("$NetBSD: nodelay.c,v 1.7.26.1 2025/08/02 05:54:47 perseant Exp $");
     32       1.4     blymn #endif				/* not lint */
     33       1.1       mrg 
     34       1.1       mrg #include "curses.h"
     35       1.2     blymn #include "curses_private.h"
     36       1.1       mrg 
     37       1.1       mrg /*
     38       1.1       mrg  * nodelay --
     39       1.1       mrg  *	Turn on and off blocking reads in getch for a
     40       1.1       mrg  *	given window.
     41       1.1       mrg  */
     42       1.6       jdc int
     43       1.3     blymn nodelay(WINDOW *win, bool bf)
     44       1.1       mrg {
     45       1.7       roy 
     46  1.7.26.1  perseant 	if (__predict_false(win == NULL))
     47  1.7.26.1  perseant 		return ERR;
     48  1.7.26.1  perseant 
     49       1.1       mrg 	if (bf)
     50       1.1       mrg 		win->delay = 0;
     51       1.1       mrg 	else
     52       1.1       mrg 		win->delay = -1;
     53       1.7       roy 	return OK;
     54       1.1       mrg }
     55