]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/bsd/tcflow.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / bsd / tcflow.c
CommitLineData
04277e02 1/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
df4ef2ab
UD
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
df4ef2ab
UD
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12 Lesser General Public License for more details.
df4ef2ab 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
28f540f4 17
28f540f4
RM
18#include <errno.h>
19#include <stddef.h>
20#include <termios.h>
21#include <unistd.h>
22
23#include "bsdtty.h"
24
25/* Suspend or restart transmission on FD. */
26int
bd2260a2 27tcflow (int fd, int action)
28f540f4
RM
28{
29 switch (action)
30 {
31 case TCOOFF:
ce7f605b 32 return __ioctl (fd, TIOCSTOP, (void *) NULL);
28f540f4 33 case TCOON:
ce7f605b 34 return __ioctl (fd, TIOCSTART, (void *) NULL);
28f540f4
RM
35
36 case TCIOFF:
37 case TCION:
38 {
39 /* This just writes the START or STOP character with
40 `write'. Is there another way to do this? */
41 struct termios attr;
42 unsigned char c;
dba2bdbe 43 if (__tcgetattr (fd, &attr) < 0)
28f540f4
RM
44 return -1;
45 c = attr.c_cc[action == TCIOFF ? VSTOP : VSTART];
46 if (c != _POSIX_VDISABLE && write (fd, &c, 1) < 1)
47 return -1;
48 return 0;
49 }
50
51 default:
c4029823 52 __set_errno (EINVAL);
28f540f4
RM
53 return -1;
54 }
55}