1 /** 2 * @defgroup termios Termios 3 * @ingroup libc 4 */ 5 6 #ifndef _TERMIOS_H 7 #define _TERMIOS_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 #include <features.h> 14 15 #define __NEED_pid_t 16 17 #include <bits/alltypes.h> 18 19 typedef unsigned char cc_t; 20 typedef unsigned int speed_t; 21 typedef unsigned int tcflag_t; 22 23 #define NCCS 32 24 25 #include <bits/termios.h> 26 27 /** 28 *@ingroup termios 29 * 30 *@par Description: 31 *The cfgetospeed() function shall extract the output baud rate from the 32 *termios structure to which the s argument points. This function 33 *shall return exactly the value in the termios data structure, without interpretation. 34 * 35 *@attention 36 * <ul> 37 * <li>None.</li> 38 * </ul> 39 * 40 *@retval #speed_t Upon successful completion, cfgetospeed() shall return a value 41 *of type speed_t representing the output baud rate. 42 * 43 *@par Dependency: 44 *<ul><li>termios.h</li></ul> 45 *@see cfgetispeed | cfsetispeed | cfsetospeed | tcgetattr 46 */ 47 speed_t cfgetospeed (const struct termios *); 48 49 /** 50 *@ingroup termios 51 * 52 *@par Description: 53 *The cfgetispeed() function shall extract the input baud rate from the termios 54 *structure to which the s argument points. This function shall return 55 *exactly the value in the termios data structure, without interpretation. 56 * 57 *@attention 58 * <ul> 59 * <li>None.</li> 60 * </ul> 61 * 62 *@retval #speed_t Upon successful completion, cfgetispeed() shall return a value of 63 *type speed_t representing the input baud rate. 64 * 65 *@par Dependency: 66 *<ul><li>termios.h</li></ul> 67 *@see cfgetospeed | cfsetispeed | cfsetospeed | tcgetattr 68 */ 69 speed_t cfgetispeed (const struct termios *); 70 71 /** 72 *@ingroup termios 73 * 74 *@par Description: 75 *The cfsetospeed() function shall set the output baud rate stored in 76 *the structure pointed to by s to speed. 77 * 78 *@attention 79 * <ul> 80 * <li>None.</li> 81 * </ul> 82 * 83 *@retval #0 cfsetospeed() shall return 0. 84 * 85 *@par Dependency: 86 *<ul><li>termios.h</li></ul> 87 *@see cfgetispeed | cfgetospeed | cfsetispeed | tcsetattr 88 */ 89 int cfsetospeed (struct termios *, speed_t); 90 91 /** 92 *@ingroup termios 93 * 94 *@par Description: 95 *The cfsetispeed() function shall set the input baud rate stored in 96 *the structure pointed to by s to speed. 97 * 98 *@attention 99 * <ul> 100 * <li>None.</li> 101 * </ul> 102 * 103 *@retval #0 cfsetispeed() shall return 0. 104 * 105 *@par Dependency: 106 *<ul><li>termios.h</li></ul> 107 *@see cfgetispeed | cfgetospeed | cfsetospeed | tcsetattr 108 */ 109 int cfsetispeed (struct termios *, speed_t); 110 111 /** 112 *@ingroup termios 113 * 114 *@par Description: 115 *The tcgetattr() function shall get the parameters associated with the terminal referred 116 *to by fd and store them in the termios structure referenced by s. 117 *The fd argument is an open file descriptor associated with a terminal. 118 * 119 *@attention 120 * <ul> 121 * <li>The API is not supported.</li> 122 * </ul> 123 * 124 *@retval #0 Upon successful completion, 0 shall be returned. 125 *@retval #-1 If it fails, -1 shall be returned and errno set to indicate the error. 126 * 127 *@par Errors 128 *<ul> 129 *<li><b>EBADF</b>:The fd argument is not a valid open file descriptor.</li> 130 *<li><b>EINVAL</b>:The request or arg argument is not valid for this device.</li> 131 *<li><b>ENOMEM</b>:If any resource allocation fails, ENOMEM is set as errno.</li> 132 *<li><b>EAFNOSUPPORT</b>:If socket created with PF_PACKET, SOCK_RAW is called with SIOCADDRT.</li> 133 *</ul> 134 * 135 *@par Dependency: 136 *<ul><li>termios.h</li></ul> 137 *@see tcsetattr 138 */ 139 int tcgetattr (int, struct termios *); 140 141 /** 142 *@ingroup termios 143 * 144 *@par Description: 145 *The tcsetattr() function shall set the parameters associated with the terminal 146 *referred to by the open file descriptor fd (an open file descriptor associated with a terminal) 147 *from the termios structure referenced by s. 148 * 149 *@attention 150 * <ul> 151 * <li>The API is not supported.</li> 152 * </ul> 153 * 154 *@retval #0 Upon successful completion, 0 shall be returned. 155 *@retval #-1 If it fails, -1 shall be returned and errno set to indicate the error. 156 * 157 *@par Errors 158 *<ul> 159 *<li><b>EBADF</b>:The fd argument is not a valid open file descriptor.</li> 160 *<li><b>EINVAL</b>:The request or arg argument is not valid for this device.</li> 161 *<li><b>ENOMEM</b>:If any resource allocation fails, ENOMEM is set as errno.</li> 162 *<li><b>EAFNOSUPPORT</b>:If socket created with PF_PACKET, SOCK_RAW is called with SIOCADDRT.</li> 163 *</ul> 164 * 165 *@par Dependency: 166 *<ul><li>termios.h</li></ul> 167 *@see cfgetispeed | tcgetattr 168 */ 169 int tcsetattr (int, int, const struct termios *); 170 171 /** 172 *@ingroup termios 173 * 174 *@par Description: 175 *The tcsendbreak() function sends a break for a specific duration. 176 * 177 *@attention 178 * <ul> 179 * <li>None.</li> 180 * </ul> 181 * 182 *@retval #0 Upon successful completion, 0 shall be returned. 183 *@retval #-1 If it fails, -1 shall be returned and errno set to indicate the error. 184 * 185 *@par Errors 186 *<ul> 187 *<li><b>EBADF</b>:The fd argument is not a valid open file descriptor.</li> 188 *<li><b>EINVAL</b>:The request or arg argument is not valid for this device.</li> 189 *<li><b>ENOMEM</b>:If any resource allocation fails, ENOMEM is set as errno.</li> 190 *<li><b>EAFNOSUPPORT</b>:If socket created with PF_PACKET, SOCK_RAW is called with SIOCADDRT.</li> 191 *</ul> 192 * 193 *@par Dependency: 194 *<ul><li>termios.h</li></ul> 195 *@see None 196 */ 197 int tcsendbreak (int, int); 198 int tcdrain (int); 199 200 /** 201 *@ingroup termios 202 * 203 *@par Description: 204 *Upon successful completion, tcflush() shall discard data written to the object 205 *referred to by fd (an open file descriptor associated with a terminal) but not transmitted, 206 *or data received but not read, depending on the value of __queue. 207 * 208 *@attention 209 * <ul> 210 * <li>None.</li> 211 * </ul> 212 * 213 *@retval #0 Upon successful completion, 0 shall be returned. 214 *@retval #-1 If it fails, -1 shall be returned and errno set to indicate the error. 215 * 216 *@par Errors 217 *<ul> 218 *<li><b>EBADF</b>:The fd argument is not a valid open file descriptor.</li> 219 *<li><b>EINVAL</b>:The request or arg argument is not valid for this device.</li> 220 *<li><b>ENOMEM</b>:If any resource allocation fails, ENOMEM is set as errno.</li> 221 *<li><b>EAFNOSUPPORT</b>:If socket created with PF_PACKET, SOCK_RAW is called with SIOCADDRT.</li> 222 *</ul> 223 * 224 *@par Dependency: 225 *<ul><li>termios.h</li></ul> 226 *@see None 227 */ 228 int tcflush (int, int); 229 230 /** 231 *@ingroup termios 232 * 233 *@par Description: 234 *The tcflow() function shall suspend or restart transmission or reception of 235 *data on the object referred to by fd, depending on the value of action. 236 * 237 *@attention 238 * <ul> 239 * <li>None.</li> 240 * </ul> 241 * 242 *@retval #0 Upon successful completion, 0 shall be returned. 243 *@retval #-1 If it fails, -1 shall be returned and errno set to indicate the error. 244 * 245 *@par Errors 246 *<ul> 247 *<li><b>EBADF</b>:The fd argument is not a valid open file descriptor.</li> 248 *<li><b>EINVAL</b>:The request or arg argument is not valid for this device.</li> 249 *<li><b>ENOMEM</b>:If any resource allocation fails, ENOMEM is set as errno.</li> 250 *<li><b>EAFNOSUPPORT</b>:If socket created with PF_PACKET, SOCK_RAW is called with SIOCADDRT.</li> 251 *</ul> 252 * 253 *@par Dependency: 254 *<ul><li>termios.h</li></ul> 255 *@see tcsendbreak 256 */ 257 int tcflow (int, int); 258 259 /** 260 *@ingroup termios 261 * 262 *@par Description: 263 *The tcgetsid() function shall obtain the process group ID of the session for which the terminal 264 *specified by fildes is the controlling terminal. 265 * 266 *@attention 267 * <ul> 268 * <li>None.</li> 269 * </ul> 270 * 271 *@retval #pid_t Upon successful completion, tcgetsid() shall return the process group ID of 272 *the session associated with the terminal. Otherwise, a value of -1 shall be returned 273 *and errno set to indicate the error. 274 * 275 *@par Errors 276 *<ul> 277 *<li><b>EBADF</b>:The fd argument is not a valid open file descriptor.</li> 278 *<li><b>EINVAL</b>:The request or arg argument is not valid for this device.</li> 279 *<li><b>ENOMEM</b>:If any resource allocation fails, ENOMEM is set as errno.</li> 280 *<li><b>EAFNOSUPPORT</b>:If socket created with PF_PACKET, SOCK_RAW is called with SIOCADDRT.</li> 281 *</ul> 282 * 283 *@par Dependency: 284 *<ul><li>termios.h</li></ul> 285 *@see None 286 */ 287 pid_t tcgetsid (int); 288 289 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 290 291 /** 292 *@ingroup termios 293 * 294 *@par Description: 295 *The cfmakeraw() sets the terminal to something like the "raw" mode of terminal driver: 296 *input is available character by character, echoing is disabled, and all special processing 297 *of terminal input and output characters is disabled. 298 * 299 *@attention 300 *<ul> 301 *<li> 302 *The cfmakeraw() function is not a standard C Library Function. 303 *</li> 304 *</ul> 305 * 306 *@retval #void None. 307 * 308 *@par Dependency: 309 *<ul><li>termios.h</li></ul> 310 * 311 *@see cfgetispeed | cfsetispeed | cfsetospeed | tcgetattr 312 * 313 */ 314 void cfmakeraw(struct termios *); 315 int cfsetspeed(struct termios *, speed_t); 316 #endif 317 318 #ifdef __cplusplus 319 } 320 #endif 321 322 #endif 323