Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sudo-project
GitHub Repository: sudo-project/sudo
Path: blob/main/lib/util/cfmakeraw.c
1532 views
1
/*
2
* SPDX-License-Identifier: ISC
3
*
4
* Copyright (c) 2019-2020 Todd C. Miller <[email protected]>
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
#include <config.h>
20
21
#include <termios.h>
22
23
#include <sudo_compat.h>
24
25
/* Non-standard termios input flags */
26
#ifndef IUCLC
27
# define IUCLC 0
28
#endif
29
#ifndef IMAXBEL
30
# define IMAXBEL 0
31
#endif
32
33
/* Non-standard termios local flags */
34
#ifndef IEXTEN
35
# define IEXTEN 0
36
#endif
37
38
/*
39
* Set termios to raw mode (BSD extension).
40
*/
41
void
42
sudo_cfmakeraw(struct termios *term)
43
{
44
/* Set terminal to raw mode */
45
CLR(term->c_iflag,
46
IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IMAXBEL|IUCLC);
47
CLR(term->c_oflag, OPOST);
48
CLR(term->c_lflag, ECHO|ECHONL|ICANON|ISIG|IEXTEN);
49
CLR(term->c_cflag, CSIZE|PARENB);
50
SET(term->c_cflag, CS8);
51
term->c_cc[VMIN] = 1;
52
term->c_cc[VTIME] = 0;
53
}
54
55