|
| 1 | +/* |
| 2 | +# _____ ___ ____ ___ ____ |
| 3 | +# ____| | ____| | | |____| |
| 4 | +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. |
| 5 | +#----------------------------------------------------------------------- |
| 6 | +# Copyright ps2dev - http://www.ps2dev.org |
| 7 | +# Licenced under Academic Free License version 2.0 |
| 8 | +# Review ps2sdk README & LICENSE files for further details. |
| 9 | +*/ |
| 10 | + |
| 11 | +/** |
| 12 | + * @file |
| 13 | + * termios functions. |
| 14 | + */ |
| 15 | + |
| 16 | +#ifndef __SYS_TERMIOS_H__ |
| 17 | +#define __SYS_TERMIOS_H__ |
| 18 | + |
| 19 | +#ifdef _EE |
| 20 | +// For pid_t |
| 21 | +#include <sys/types.h> |
| 22 | +#endif |
| 23 | + |
| 24 | +typedef unsigned char cc_t; |
| 25 | +typedef unsigned int speed_t; |
| 26 | +typedef unsigned int tcflag_t; |
| 27 | + |
| 28 | +#define NCCS 32 |
| 29 | + |
| 30 | +struct termios { |
| 31 | + tcflag_t c_iflag; |
| 32 | + tcflag_t c_oflag; |
| 33 | + tcflag_t c_cflag; |
| 34 | + tcflag_t c_lflag; |
| 35 | + cc_t c_line; |
| 36 | + cc_t c_cc[NCCS]; |
| 37 | + speed_t __c_ispeed; |
| 38 | + speed_t __c_ospeed; |
| 39 | +}; |
| 40 | + |
| 41 | +struct winsize { |
| 42 | + unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; |
| 43 | +}; |
| 44 | + |
| 45 | +#define VINTR 0 |
| 46 | +#define VQUIT 1 |
| 47 | +#define VERASE 2 |
| 48 | +#define VKILL 3 |
| 49 | +#define VEOF 4 |
| 50 | +#define VTIME 5 |
| 51 | +#define VMIN 6 |
| 52 | +#define VSWTC 7 |
| 53 | +#define VSTART 8 |
| 54 | +#define VSTOP 9 |
| 55 | +#define VSUSP 10 |
| 56 | +#define VEOL 11 |
| 57 | +#define VREPRINT 12 |
| 58 | +#define VDISCARD 13 |
| 59 | +#define VWERASE 14 |
| 60 | +#define VLNEXT 15 |
| 61 | +#define VEOL2 16 |
| 62 | + |
| 63 | +#define IGNBRK 0000001 |
| 64 | +#define BRKINT 0000002 |
| 65 | +#define IGNPAR 0000004 |
| 66 | +#define PARMRK 0000010 |
| 67 | +#define INPCK 0000020 |
| 68 | +#define ISTRIP 0000040 |
| 69 | +#define INLCR 0000100 |
| 70 | +#define IGNCR 0000200 |
| 71 | +#define ICRNL 0000400 |
| 72 | +#define IUCLC 0001000 |
| 73 | +#define IXON 0002000 |
| 74 | +#define IXANY 0004000 |
| 75 | +#define IXOFF 0010000 |
| 76 | +#define IMAXBEL 0020000 |
| 77 | +#define IUTF8 0040000 |
| 78 | + |
| 79 | +#define OPOST 0000001 |
| 80 | +#define OLCUC 0000002 |
| 81 | +#define ONLCR 0000004 |
| 82 | +#define OCRNL 0000010 |
| 83 | +#define ONOCR 0000020 |
| 84 | +#define ONLRET 0000040 |
| 85 | +#define OFILL 0000100 |
| 86 | +#define OFDEL 0000200 |
| 87 | +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE) |
| 88 | +#define NLDLY 0000400 |
| 89 | +#define NL0 0000000 |
| 90 | +#define NL1 0000400 |
| 91 | +#define CRDLY 0003000 |
| 92 | +#define CR0 0000000 |
| 93 | +#define CR1 0001000 |
| 94 | +#define CR2 0002000 |
| 95 | +#define CR3 0003000 |
| 96 | +#define TABDLY 0014000 |
| 97 | +#define TAB0 0000000 |
| 98 | +#define TAB1 0004000 |
| 99 | +#define TAB2 0010000 |
| 100 | +#define TAB3 0014000 |
| 101 | +#define BSDLY 0020000 |
| 102 | +#define BS0 0000000 |
| 103 | +#define BS1 0020000 |
| 104 | +#define FFDLY 0100000 |
| 105 | +#define FF0 0000000 |
| 106 | +#define FF1 0100000 |
| 107 | +#endif |
| 108 | + |
| 109 | +#define VTDLY 0040000 |
| 110 | +#define VT0 0000000 |
| 111 | +#define VT1 0040000 |
| 112 | + |
| 113 | +#define B0 0000000 |
| 114 | +#define B50 0000001 |
| 115 | +#define B75 0000002 |
| 116 | +#define B110 0000003 |
| 117 | +#define B134 0000004 |
| 118 | +#define B150 0000005 |
| 119 | +#define B200 0000006 |
| 120 | +#define B300 0000007 |
| 121 | +#define B600 0000010 |
| 122 | +#define B1200 0000011 |
| 123 | +#define B1800 0000012 |
| 124 | +#define B2400 0000013 |
| 125 | +#define B4800 0000014 |
| 126 | +#define B9600 0000015 |
| 127 | +#define B19200 0000016 |
| 128 | +#define B38400 0000017 |
| 129 | + |
| 130 | +#define B57600 0010001 |
| 131 | +#define B115200 0010002 |
| 132 | +#define B230400 0010003 |
| 133 | +#define B460800 0010004 |
| 134 | +#define B500000 0010005 |
| 135 | +#define B576000 0010006 |
| 136 | +#define B921600 0010007 |
| 137 | +#define B1000000 0010010 |
| 138 | +#define B1152000 0010011 |
| 139 | +#define B1500000 0010012 |
| 140 | +#define B2000000 0010013 |
| 141 | +#define B2500000 0010014 |
| 142 | +#define B3000000 0010015 |
| 143 | +#define B3500000 0010016 |
| 144 | +#define B4000000 0010017 |
| 145 | + |
| 146 | +#define CSIZE 0000060 |
| 147 | +#define CS5 0000000 |
| 148 | +#define CS6 0000020 |
| 149 | +#define CS7 0000040 |
| 150 | +#define CS8 0000060 |
| 151 | +#define CSTOPB 0000100 |
| 152 | +#define CREAD 0000200 |
| 153 | +#define PARENB 0000400 |
| 154 | +#define PARODD 0001000 |
| 155 | +#define HUPCL 0002000 |
| 156 | +#define CLOCAL 0004000 |
| 157 | + |
| 158 | +#define ISIG 0000001 |
| 159 | +#define ICANON 0000002 |
| 160 | +#define ECHO 0000010 |
| 161 | +#define ECHOE 0000020 |
| 162 | +#define ECHOK 0000040 |
| 163 | +#define ECHONL 0000100 |
| 164 | +#define NOFLSH 0000200 |
| 165 | +#define TOSTOP 0000400 |
| 166 | +#define IEXTEN 0100000 |
| 167 | + |
| 168 | +#define TCOOFF 0 |
| 169 | +#define TCOON 1 |
| 170 | +#define TCIOFF 2 |
| 171 | +#define TCION 3 |
| 172 | + |
| 173 | +#define TCIFLUSH 0 |
| 174 | +#define TCOFLUSH 1 |
| 175 | +#define TCIOFLUSH 2 |
| 176 | + |
| 177 | +#define TCSANOW 0 |
| 178 | +#define TCSADRAIN 1 |
| 179 | +#define TCSAFLUSH 2 |
| 180 | + |
| 181 | +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 182 | +#define EXTA 0000016 |
| 183 | +#define EXTB 0000017 |
| 184 | +#define CBAUD 0010017 |
| 185 | +#define CBAUDEX 0010000 |
| 186 | +#define CIBAUD 002003600000 |
| 187 | +#define CMSPAR 010000000000 |
| 188 | +#define CRTSCTS 020000000000 |
| 189 | + |
| 190 | +#define XCASE 0000004 |
| 191 | +#define ECHOCTL 0001000 |
| 192 | +#define ECHOPRT 0002000 |
| 193 | +#define ECHOKE 0004000 |
| 194 | +#define FLUSHO 0010000 |
| 195 | +#define PENDIN 0040000 |
| 196 | +#define EXTPROC 0200000 |
| 197 | + |
| 198 | +#define XTABS 0014000 |
| 199 | +#endif |
| 200 | + |
| 201 | +__BEGIN_DECLS |
| 202 | + |
| 203 | +extern speed_t cfgetospeed (const struct termios *termios_p); |
| 204 | +extern speed_t cfgetispeed (const struct termios *termios_p); |
| 205 | +extern int cfsetospeed (struct termios *termios_p, speed_t speed); |
| 206 | +extern int cfsetispeed (struct termios *termios_p, speed_t speed); |
| 207 | + |
| 208 | +extern int tcgetattr (int fildes, struct termios *termios_p); |
| 209 | +extern int tcsetattr (int fildes, int optional_actions, const struct termios *termios_p); |
| 210 | + |
| 211 | +extern int tcgetwinsize (int fildes, struct winsize *gws); |
| 212 | +extern int tcsetwinsize (int fildes, const struct winsize *gws); |
| 213 | + |
| 214 | +extern int tcsendbreak (int fildes, int len); |
| 215 | +extern int tcdrain (int fildes); |
| 216 | +extern int tcflush (int fildes, int action); |
| 217 | +extern int tcflow (int fildes, int action); |
| 218 | + |
| 219 | +#ifdef _EE |
| 220 | +extern pid_t tcgetsid (int fildes); |
| 221 | +#endif |
| 222 | + |
| 223 | +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 224 | +extern void cfmakeraw(struct termios *termios_p); |
| 225 | +extern int cfsetspeed(struct termios *termios_p, speed_t speed); |
| 226 | +#endif |
| 227 | + |
| 228 | +__END_DECLS |
| 229 | + |
| 230 | +#endif |
0 commit comments