OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [sysvi386/] [tcline.c] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
#define _NO_MACROS
2
#include <sys/unistd.h>
3
#include <sys/termios.h>
4
#include <errno.h>
5
 
6
int
7
tcsendbreak (int fd, int dur) {
8
        do {
9
                if (_ioctl (fd, _TCSBRK, 0) == -1)
10
                        return -1;
11
        } while (dur--);
12
        return 0;
13
}
14
 
15
int
16
tcdrain (int fd) {
17
        return _ioctl (fd, _TCSBRK, 1);
18
}
19
 
20
int
21
tcflush(int fd, int what) {
22
        return _ioctl (fd, _TCFLSH, what);
23
}
24
 
25
/*
26
 * I'm not positive about this function.  I *think* it's right,
27
 * but I could be missing something.
28
 */
29
 
30
int
31
tcflow (int fd, int action) {
32
        struct termios t;
33
 
34
        switch (action) {
35
        case TCOOFF:
36
        case TCOON:
37
                return _ioctl (fd, _TCXONC, action);
38
/*
39
 * Here is where I'm not terribly certain.  1003.1 says:
40
 * if action is TCIOFF, the system shall transmit a STOP
41
 * character, which is intended to cause the terminal device
42
 * to stop transmitting data to the system.  (Similarly for
43
 * TCION.)
44
 * I *assume* that means I find out what VSTOP for the
45
 * terminal device is, and then write it.  1003.1 also does
46
 * not say what happens if c_cc[VSTOP] is _POSIX_VDISABLE;
47
 * I assume it should reaturn EINVAL, so that's what I do.
48
 * Anyway, here's the code.  It might or might not be right.
49
 */
50
        case TCIOFF:
51
                if (tcgetattr (fd, &t) == -1)
52
                        return -1;
53
                if (tcgetattr (fd, &t) == -1)
54
                        return -1;
55
#ifdef _POSIX_VDISABLE
56
                if (t.c_cc[VSTOP] == _POSIX_VDISABLE) {
57
                        errno = EINVAL;
58
                        return -1;
59
                }
60
#endif
61
                if (write (fd, &t.c_cc[VSTOP], 1) == 1)
62
                        return 0;
63
                else
64
                        return -1;
65
        case TCION:
66
                if (tcgetattr (fd, &t) == -1)
67
                        return -1;
68
                if (tcgetattr (fd, &t) == -1)
69
                        return -1;
70
#ifdef _POSIX_VDISABLE
71
                if (t.c_cc[VSTART] == _POSIX_VDISABLE) {
72
                        errno = EINVAL;
73
                        return -1;
74
                }
75
#endif
76
                if (write (fd, &t.c_cc[VSTART], 1) == 1)
77
                        return 0;
78
                else
79
                        return -1;
80
        default:
81
                errno = EINVAL;
82
                return -1;
83
        }
84
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.