"Fossies" - the Fresh Open Source Software Archive

Member "sudo-1.9.11p3/lib/util/cfmakeraw.c" (12 Jun 2022, 1705 Bytes) of package /linux/misc/sudo-1.9.11p3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "cfmakeraw.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * SPDX-License-Identifier: ISC
    3  *
    4  * Copyright (c) 2019-2020 Todd C. Miller <Todd.Miller@sudo.ws>
    5  *
    6  * Permission to use, copy, modify, and distribute this software for any
    7  * purpose with or without fee is hereby granted, provided that the above
    8  * copyright notice and this permission notice appear in all copies.
    9  *
   10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   17  */
   18 
   19 /*
   20  * This is an open source non-commercial project. Dear PVS-Studio, please check it.
   21  * PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
   22  */
   23 
   24 #include <config.h>
   25 
   26 #include <termios.h>
   27 
   28 #include "sudo_compat.h"
   29 
   30 /* Non-standard termios input flags */
   31 #ifndef IUCLC
   32 # define IUCLC      0
   33 #endif
   34 #ifndef IMAXBEL
   35 # define IMAXBEL    0
   36 #endif
   37 
   38 /* Non-standard termios local flags */
   39 #ifndef IEXTEN
   40 # define IEXTEN     0
   41 #endif
   42 
   43 /*
   44  * Set termios to raw mode (BSD extension).
   45  */
   46 void
   47 sudo_cfmakeraw(struct termios *term)
   48 {
   49     /* Set terminal to raw mode */
   50     CLR(term->c_iflag,
   51     IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IMAXBEL|IUCLC);
   52     CLR(term->c_oflag, OPOST);
   53     CLR(term->c_lflag, ECHO|ECHONL|ICANON|ISIG|IEXTEN);
   54     CLR(term->c_cflag, CSIZE|PARENB);
   55     SET(term->c_cflag, CS8);
   56     term->c_cc[VMIN] = 1;
   57     term->c_cc[VTIME] = 0;
   58 }