File: tcfix.c

package info (click to toggle)
bincompat 1.1.0-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 152 kB
  • ctags: 97
  • sloc: ansic: 1,291; makefile: 78; asm: 74; sh: 2
file content (59 lines) | stat: -rw-r--r-- 1,666 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <stddef.h>
#include <termios.h>

#define KERNEL_NCCS 19

struct kernel_termios
  {
    tcflag_t c_iflag;		/* input mode flags */
    tcflag_t c_oflag;		/* output mode flags */
    tcflag_t c_cflag;		/* control mode flags */
    tcflag_t c_lflag;		/* local mode flags */
    cc_t c_cc[KERNEL_NCCS];	/* control characters */
    cc_t c_line;		/* line discipline */
    speed_t c_ispeed;           /* input speed */
    speed_t c_ospeed;           /* output speed */
  };

/* Put the state of FD into *TERMIOS_P.  */
int
A0getattr (int fd, struct kernel_termios *k_termios)
{
  struct termios termios;
  size_t cnt;
  int retval;

  retval = tcgetattr (fd, &termios);
  k_termios->c_iflag = termios.c_iflag;
  k_termios->c_oflag = termios.c_oflag;
  k_termios->c_cflag = termios.c_cflag;
  k_termios->c_lflag = termios.c_lflag;
  k_termios->c_line = termios.c_line;
  k_termios->c_ispeed = termios.c_ispeed;
  k_termios->c_ospeed = termios.c_ospeed;
  for (cnt = 0; cnt < KERNEL_NCCS; ++cnt)
    k_termios->c_cc[cnt] = termios.c_cc[cnt];

  return retval;
}

/* Put the state of FD into *TERMIOS_P.  */
int
A0setattr (int fd, int optional_actions,
	   const struct kernel_termios *k_termios)
{
  struct termios termios;
  size_t cnt;

  termios.c_iflag = k_termios->c_iflag;
  termios.c_oflag = k_termios->c_oflag;
  termios.c_cflag = k_termios->c_cflag;
  termios.c_lflag = k_termios->c_lflag;
  termios.c_line = k_termios->c_line;
  termios.c_ispeed = k_termios->c_ispeed;
  termios.c_ospeed = k_termios->c_ospeed;
  for (cnt = 0; cnt < KERNEL_NCCS; ++cnt)
    termios.c_cc[cnt] = k_termios->c_cc[cnt];

  return tcsetattr(fd, optional_actions, &termios);
}