diff options
Diffstat (limited to 'REORG.TODO/termios')
-rw-r--r-- | REORG.TODO/termios/Makefile | 33 | ||||
-rw-r--r-- | REORG.TODO/termios/Versions | 14 | ||||
-rw-r--r-- | REORG.TODO/termios/cfmakeraw.c | 31 | ||||
-rw-r--r-- | REORG.TODO/termios/cfsetspeed.c | 161 | ||||
-rw-r--r-- | REORG.TODO/termios/speed.c | 65 | ||||
-rw-r--r-- | REORG.TODO/termios/sys/termios.h | 4 | ||||
-rw-r--r-- | REORG.TODO/termios/sys/ttychars.h | 61 | ||||
-rw-r--r-- | REORG.TODO/termios/tcdrain.c | 37 | ||||
-rw-r--r-- | REORG.TODO/termios/tcflow.c | 49 | ||||
-rw-r--r-- | REORG.TODO/termios/tcflush.c | 42 | ||||
-rw-r--r-- | REORG.TODO/termios/tcgetattr.c | 42 | ||||
-rw-r--r-- | REORG.TODO/termios/tcgetpgrp.c | 36 | ||||
-rw-r--r-- | REORG.TODO/termios/tcgetsid.c | 62 | ||||
-rw-r--r-- | REORG.TODO/termios/tcsendbrk.c | 36 | ||||
-rw-r--r-- | REORG.TODO/termios/tcsetattr.c | 106 | ||||
-rw-r--r-- | REORG.TODO/termios/tcsetpgrp.c | 37 | ||||
-rw-r--r-- | REORG.TODO/termios/termios.h | 109 |
17 files changed, 925 insertions, 0 deletions
diff --git a/REORG.TODO/termios/Makefile b/REORG.TODO/termios/Makefile new file mode 100644 index 0000000000..ac14a854df --- /dev/null +++ b/REORG.TODO/termios/Makefile @@ -0,0 +1,33 @@ +# Copyright (C) 1991-2017 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# <http://www.gnu.org/licenses/>. + +# +# Makefile for the terminal I/O functions. +# +subdir := termios + +include ../Makeconfig + +headers := termios.h bits/termios.h sys/ttydefaults.h sys/termios.h \ + sys/ttychars.h + +routines := speed cfsetspeed tcsetattr tcgetattr tcgetpgrp tcsetpgrp \ + tcdrain tcflow tcflush tcsendbrk cfmakeraw tcgetsid + +include ../Rules + +CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables diff --git a/REORG.TODO/termios/Versions b/REORG.TODO/termios/Versions new file mode 100644 index 0000000000..711ed0334b --- /dev/null +++ b/REORG.TODO/termios/Versions @@ -0,0 +1,14 @@ +libc { + GLIBC_2.0 { + # c* + cfgetispeed; cfgetospeed; cfmakeraw; cfsetispeed; cfsetospeed; cfsetspeed; + + # t* + tcdrain; tcflow; tcflush; tcgetattr; tcgetpgrp; tcsendbreak; tcsetattr; + tcsetpgrp; + } + GLIBC_2.1 { + # t* + tcgetsid; + } +} diff --git a/REORG.TODO/termios/cfmakeraw.c b/REORG.TODO/termios/cfmakeraw.c new file mode 100644 index 0000000000..0f97ce66d2 --- /dev/null +++ b/REORG.TODO/termios/cfmakeraw.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1992-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <termios.h> + +/* Set *T to indicate raw mode. */ +void +cfmakeraw (struct termios *t) +{ + t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); + t->c_oflag &= ~OPOST; + t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + t->c_cflag &= ~(CSIZE|PARENB); + t->c_cflag |= CS8; + t->c_cc[VMIN] = 1; /* read returns when one char is available. */ + t->c_cc[VTIME] = 0; +} diff --git a/REORG.TODO/termios/cfsetspeed.c b/REORG.TODO/termios/cfsetspeed.c new file mode 100644 index 0000000000..c836e8d3cd --- /dev/null +++ b/REORG.TODO/termios/cfsetspeed.c @@ -0,0 +1,161 @@ +/* Copyright (C) 1992-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <termios.h> +#include <errno.h> +#include <stddef.h> + +struct speed_struct +{ + speed_t value; + speed_t internal; +}; + +static const struct speed_struct speeds[] = + { +#ifdef B0 + { 0, B0 }, +#endif +#ifdef B50 + { 50, B50 }, +#endif +#ifdef B75 + { 75, B75 }, +#endif +#ifdef B110 + { 110, B110 }, +#endif +#ifdef B134 + { 134, B134 }, +#endif +#ifdef B150 + { 150, B150 }, +#endif +#ifdef B200 + { 200, B200 }, +#endif +#ifdef B300 + { 300, B300 }, +#endif +#ifdef B600 + { 600, B600 }, +#endif +#ifdef B1200 + { 1200, B1200 }, +#endif +#ifdef B1200 + { 1200, B1200 }, +#endif +#ifdef B1800 + { 1800, B1800 }, +#endif +#ifdef B2400 + { 2400, B2400 }, +#endif +#ifdef B4800 + { 4800, B4800 }, +#endif +#ifdef B9600 + { 9600, B9600 }, +#endif +#ifdef B19200 + { 19200, B19200 }, +#endif +#ifdef B38400 + { 38400, B38400 }, +#endif +#ifdef B57600 + { 57600, B57600 }, +#endif +#ifdef B76800 + { 76800, B76800 }, +#endif +#ifdef B115200 + { 115200, B115200 }, +#endif +#ifdef B153600 + { 153600, B153600 }, +#endif +#ifdef B230400 + { 230400, B230400 }, +#endif +#ifdef B307200 + { 307200, B307200 }, +#endif +#ifdef B460800 + { 460800, B460800 }, +#endif +#ifdef B500000 + { 500000, B500000 }, +#endif +#ifdef B576000 + { 576000, B576000 }, +#endif +#ifdef B921600 + { 921600, B921600 }, +#endif +#ifdef B1000000 + { 1000000, B1000000 }, +#endif +#ifdef B1152000 + { 1152000, B1152000 }, +#endif +#ifdef B1500000 + { 1500000, B1500000 }, +#endif +#ifdef B2000000 + { 2000000, B2000000 }, +#endif +#ifdef B2500000 + { 2500000, B2500000 }, +#endif +#ifdef B3000000 + { 3000000, B3000000 }, +#endif +#ifdef B3500000 + { 3500000, B3500000 }, +#endif +#ifdef B4000000 + { 4000000, B4000000 }, +#endif + }; + + +/* Set both the input and output baud rates stored in *TERMIOS_P to SPEED. */ +int +cfsetspeed (struct termios *termios_p, speed_t speed) +{ + size_t cnt; + + for (cnt = 0; cnt < sizeof (speeds) / sizeof (speeds[0]); ++cnt) + if (speed == speeds[cnt].internal) + { + cfsetispeed (termios_p, speed); + cfsetospeed (termios_p, speed); + return 0; + } + else if (speed == speeds[cnt].value) + { + cfsetispeed (termios_p, speeds[cnt].internal); + cfsetospeed (termios_p, speeds[cnt].internal); + return 0; + } + + __set_errno (EINVAL); + + return -1; +} diff --git a/REORG.TODO/termios/speed.c b/REORG.TODO/termios/speed.c new file mode 100644 index 0000000000..e5e4acaa87 --- /dev/null +++ b/REORG.TODO/termios/speed.c @@ -0,0 +1,65 @@ +/* `struct termios' speed frobnication functions. 4.4 BSD/generic GNU version. + Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <stddef.h> +#include <errno.h> +#include <termios.h> + +/* Return the output baud rate stored in *TERMIOS_P. */ +speed_t +cfgetospeed (const struct termios *termios_p) +{ + return termios_p->__ospeed; +} + +/* Return the input baud rate stored in *TERMIOS_P. */ +speed_t +cfgetispeed (const struct termios *termios_p) +{ + return termios_p->__ispeed; +} + +/* Set the output baud rate stored in *TERMIOS_P to SPEED. */ +int +cfsetospeed (struct termios *termios_p, speed_t speed) +{ + if (termios_p == NULL) + { + __set_errno (EINVAL); + return -1; + } + + termios_p->__ospeed = speed; + return 0; +} +libc_hidden_def (cfsetospeed) + +/* Set the input baud rate stored in *TERMIOS_P to SPEED. */ +int +cfsetispeed (struct termios *termios_p, speed_t speed) +{ + if (termios_p == NULL) + { + __set_errno (EINVAL); + return -1; + } + + termios_p->__ispeed = speed; + return 0; +} +libc_hidden_def (cfsetispeed) diff --git a/REORG.TODO/termios/sys/termios.h b/REORG.TODO/termios/sys/termios.h new file mode 100644 index 0000000000..3e18805ab4 --- /dev/null +++ b/REORG.TODO/termios/sys/termios.h @@ -0,0 +1,4 @@ +#ifndef _SYS_TERMIOS_H +#define _SYS_TERMIOS_H +#include <termios.h> +#endif diff --git a/REORG.TODO/termios/sys/ttychars.h b/REORG.TODO/termios/sys/ttychars.h new file mode 100644 index 0000000000..7043f60f81 --- /dev/null +++ b/REORG.TODO/termios/sys/ttychars.h @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ttychars.h 8.2 (Berkeley) 1/4/94 + */ + +/* + * 4.3 COMPATIBILITY FILE + * + * User visible structures and constants related to terminal handling. + */ +#ifndef _SYS_TTYCHARS_H +#define _SYS_TTYCHARS_H 1 + +struct ttychars { + char tc_erase; /* erase last character */ + char tc_kill; /* erase entire line */ + char tc_intrc; /* interrupt */ + char tc_quitc; /* quit */ + char tc_startc; /* start output */ + char tc_stopc; /* stop output */ + char tc_eofc; /* end-of-file */ + char tc_brkc; /* input delimiter (like nl) */ + char tc_suspc; /* stop process signal */ + char tc_dsuspc; /* delayed stop process signal */ + char tc_rprntc; /* reprint line */ + char tc_flushc; /* flush output (toggles) */ + char tc_werasc; /* word erase */ + char tc_lnextc; /* literal next character */ +}; + +#ifdef __USE_OLD_TTY +#include <sys/ttydefaults.h> /* to pick up character defaults */ +#endif + +#endif /* sys/ttychars.h */ diff --git a/REORG.TODO/termios/tcdrain.c b/REORG.TODO/termios/tcdrain.c new file mode 100644 index 0000000000..edd892decb --- /dev/null +++ b/REORG.TODO/termios/tcdrain.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <termios.h> + +/* Wait for pending output to be written on FD. */ +int +__libc_tcdrain (int fd) +{ + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +weak_alias (__libc_tcdrain, tcdrain) + + +stub_warning (tcdrain) diff --git a/REORG.TODO/termios/tcflow.c b/REORG.TODO/termios/tcflow.c new file mode 100644 index 0000000000..728112d8e2 --- /dev/null +++ b/REORG.TODO/termios/tcflow.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <termios.h> + +/* Suspend or restart transmission on FD. */ +int +tcflow (int fd, int action) +{ + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + + switch (action) + { + case TCOOFF: + case TCOON: + case TCIOFF: + case TCION: + break; + + default: + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (tcflow) diff --git a/REORG.TODO/termios/tcflush.c b/REORG.TODO/termios/tcflush.c new file mode 100644 index 0000000000..9d0c1fb912 --- /dev/null +++ b/REORG.TODO/termios/tcflush.c @@ -0,0 +1,42 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <termios.h> + +/* Flush pending data on FD. */ +int +tcflush (int fd, int queue_selector) +{ + switch (queue_selector) + { + case TCIFLUSH: + case TCOFLUSH: + case TCIOFLUSH: + break; + + default: + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + + +stub_warning(tcflush); diff --git a/REORG.TODO/termios/tcgetattr.c b/REORG.TODO/termios/tcgetattr.c new file mode 100644 index 0000000000..a5c076b1b0 --- /dev/null +++ b/REORG.TODO/termios/tcgetattr.c @@ -0,0 +1,42 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <stddef.h> +#include <termios.h> + +/* Put the state of FD into *TERMIOS_P. */ +int +__tcgetattr (int fd, struct termios *termios_p) +{ + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + if (termios_p == NULL) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +stub_warning (tcgetattr) + +weak_alias (__tcgetattr, tcgetattr) diff --git a/REORG.TODO/termios/tcgetpgrp.c b/REORG.TODO/termios/tcgetpgrp.c new file mode 100644 index 0000000000..94a1c751ec --- /dev/null +++ b/REORG.TODO/termios/tcgetpgrp.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <unistd.h> +#include <sys/types.h> + +/* Return the foreground process group ID of FD. */ +pid_t +tcgetpgrp (int fd) +{ + if (fd < 0) + { + __set_errno (EBADF); + return (pid_t) -1; + } + + __set_errno (ENOSYS); + return (pid_t) -1; +} +libc_hidden_def (tcgetpgrp) +stub_warning (tcgetpgrp) diff --git a/REORG.TODO/termios/tcgetsid.c b/REORG.TODO/termios/tcgetsid.c new file mode 100644 index 0000000000..e49e6b12dd --- /dev/null +++ b/REORG.TODO/termios/tcgetsid.c @@ -0,0 +1,62 @@ +/* Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <termios.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <unistd.h> + +/* Return the session ID of FD. */ +pid_t +tcgetsid (int fd) +{ + pid_t pgrp; + pid_t sid; +#ifdef TIOCGSID + static int tiocgsid_does_not_work; + + if (! tiocgsid_does_not_work) + { + int serrno = errno; + int sid; + + if (__ioctl (fd, TIOCGSID, &sid) < 0) + { + if (errno == EINVAL) + { + tiocgsid_does_not_work = 1; + __set_errno (serrno); + } + else + return (pid_t) -1; + } + else + return (pid_t) sid; + } +#endif + + pgrp = tcgetpgrp (fd); + if (pgrp == -1) + return (pid_t) -1; + + sid = getsid (pgrp); + if (sid == -1 && errno == ESRCH) + __set_errno (ENOTTY); + + return sid; +} diff --git a/REORG.TODO/termios/tcsendbrk.c b/REORG.TODO/termios/tcsendbrk.c new file mode 100644 index 0000000000..4e8fb3fed4 --- /dev/null +++ b/REORG.TODO/termios/tcsendbrk.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <termios.h> + +/* Send zero bits on FD. */ +int +tcsendbreak (int fd, int duration) +{ + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (tcsendbreak) diff --git a/REORG.TODO/termios/tcsetattr.c b/REORG.TODO/termios/tcsetattr.c new file mode 100644 index 0000000000..7dd709046b --- /dev/null +++ b/REORG.TODO/termios/tcsetattr.c @@ -0,0 +1,106 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <stddef.h> +#include <termios.h> + +static int bad_speed (speed_t speed); + +/* Set the state of FD to *TERMIOS_P. */ +int +tcsetattr (int fd, int optional_actions, const struct termios *termios_p) +{ + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + if (termios_p == NULL) + { + __set_errno (EINVAL); + return -1; + } + switch (optional_actions) + { + case TCSANOW: + case TCSADRAIN: + case TCSAFLUSH: + break; + default: + __set_errno (EINVAL); + return -1; + } + + if (bad_speed(termios_p->__ospeed) || + bad_speed(termios_p->__ispeed == 0 ? + termios_p->__ospeed : termios_p->__ispeed)) + { + __set_errno (EINVAL); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} +libc_hidden_def (tcsetattr) + +/* Strychnine checking. */ +static int +bad_speed (speed_t speed) +{ + switch (speed) + { + case B0: + case B50: + case B75: + case B110: + case B134: + case B150: + case B200: + case B300: + case B600: + case B1200: + case B1800: + case B2400: + case B4800: + case B9600: + case B19200: + case B38400: + case B57600: + case B115200: + case B230400: + case B460800: + case B500000: + case B576000: + case B921600: + case B1000000: + case B1152000: + case B1500000: + case B2000000: + case B2500000: + case B3000000: + case B3500000: + case B4000000: + return 0; + default: + return 1; + } +} + + +stub_warning (tcsetattr) diff --git a/REORG.TODO/termios/tcsetpgrp.c b/REORG.TODO/termios/tcsetpgrp.c new file mode 100644 index 0000000000..44e61b2a8a --- /dev/null +++ b/REORG.TODO/termios/tcsetpgrp.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <unistd.h> +#include <sys/types.h> + +/* Set the foreground process group ID of FD set PGRP_ID. */ +int +tcsetpgrp (int fd, pid_t pgrp_id) +{ + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } + + __set_errno (ENOSYS); + return -1; +} + + +stub_warning (tcsetpgrp) diff --git a/REORG.TODO/termios/termios.h b/REORG.TODO/termios/termios.h new file mode 100644 index 0000000000..c0f7780cff --- /dev/null +++ b/REORG.TODO/termios/termios.h @@ -0,0 +1,109 @@ +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +/* + * POSIX Standard: 7.1-2 General Terminal Interface <termios.h> + */ + +#ifndef _TERMIOS_H +#define _TERMIOS_H 1 + +#include <features.h> +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +/* We need `pid_t'. */ +# include <bits/types.h> +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +# endif +#endif + +__BEGIN_DECLS + +/* Get the system-dependent definitions of `struct termios', `tcflag_t', + `cc_t', `speed_t', and all the macros specifying the flag bits. */ +#include <bits/termios.h> + +#ifdef __USE_MISC +/* Compare a character C to a value VAL from the `c_cc' array in a + `struct termios'. If VAL is _POSIX_VDISABLE, no character can match it. */ +# define CCEQ(val, c) ((c) == (val) && (val) != _POSIX_VDISABLE) +#endif + +/* Return the output baud rate stored in *TERMIOS_P. */ +extern speed_t cfgetospeed (const struct termios *__termios_p) __THROW; + +/* Return the input baud rate stored in *TERMIOS_P. */ +extern speed_t cfgetispeed (const struct termios *__termios_p) __THROW; + +/* Set the output baud rate stored in *TERMIOS_P to SPEED. */ +extern int cfsetospeed (struct termios *__termios_p, speed_t __speed) __THROW; + +/* Set the input baud rate stored in *TERMIOS_P to SPEED. */ +extern int cfsetispeed (struct termios *__termios_p, speed_t __speed) __THROW; + +#ifdef __USE_MISC +/* Set both the input and output baud rates in *TERMIOS_OP to SPEED. */ +extern int cfsetspeed (struct termios *__termios_p, speed_t __speed) __THROW; +#endif + + +/* Put the state of FD into *TERMIOS_P. */ +extern int tcgetattr (int __fd, struct termios *__termios_p) __THROW; + +/* Set the state of FD to *TERMIOS_P. + Values for OPTIONAL_ACTIONS (TCSA*) are in <bits/termios.h>. */ +extern int tcsetattr (int __fd, int __optional_actions, + const struct termios *__termios_p) __THROW; + + +#ifdef __USE_MISC +/* Set *TERMIOS_P to indicate raw mode. */ +extern void cfmakeraw (struct termios *__termios_p) __THROW; +#endif + +/* Send zero bits on FD. */ +extern int tcsendbreak (int __fd, int __duration) __THROW; + +/* Wait for pending output to be written on FD. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int tcdrain (int __fd); + +/* Flush pending data on FD. + Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in <bits/termios.h>. */ +extern int tcflush (int __fd, int __queue_selector) __THROW; + +/* Suspend or restart transmission on FD. + Values for ACTION (TC[IO]{OFF,ON}) are in <bits/termios.h>. */ +extern int tcflow (int __fd, int __action) __THROW; + + +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 +/* Get process group ID for session leader for controlling terminal FD. */ +extern __pid_t tcgetsid (int __fd) __THROW; +#endif + + +#ifdef __USE_MISC +# include <sys/ttydefaults.h> +#endif + +__END_DECLS + +#endif /* termios.h */ |