revert between 56095 -> 55830 in arch
[AROS.git] / compiler / posixc / tcsetattr.c
blob361be4df16a971ee4fb1fed04bcfb0e362d24a19
1 /*
2 Copyright (C) 1995-2016, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/dos.h>
8 #include "__fdesc.h"
10 /*****************************************************************************
12 NAME */
14 #include <sys/ioctl.h>
15 #include <termios.h>
16 #include <errno.h>
18 int tcsetattr(
20 /* SYNOPSIS */
21 int fd,
22 int opt,
23 const struct termios *t)
25 /* FUNCTION
26 Set terminal attributes.
28 INPUTS
29 fd - file descriptor
30 opt - optional actions
31 t - struct termios containing the requested changes
33 RESULT
34 0 - success
35 -1 - error
37 NOTES
38 Will return success, if *any* of the changes were successful.
39 Currently supports only ICANON flag
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 ioctl()
48 INTERNALS
50 ******************************************************************************/
52 fdesc *fdesc = __getfdesc(fd);
54 if (!fdesc)
56 errno = EBADF;
57 return -1;
60 if (IsInteractive(fdesc->fcb->handle))
62 if (t->c_lflag & ICANON)
64 SetMode(fdesc->fcb->handle, 0);
65 fdesc->fcb->privflags &= ~_FCB_CONSOLERAW;
67 else
69 SetMode(fdesc->fcb->handle, 1);
70 fdesc->fcb->privflags |= _FCB_CONSOLERAW;
74 return 0;