about summary refs log tree commit diff
path: root/termios
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
committerRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
commit28f540f45bbacd939bfd07f213bcad2bf730b1bf (patch)
tree15f07c4c43d635959c6afee96bde71fb1b3614ee /termios
downloadglibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.gz
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.xz
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.zip
initial import
Diffstat (limited to 'termios')
-rw-r--r--termios/Makefile28
-rw-r--r--termios/cfmakeraw.c33
-rw-r--r--termios/cfsetspeed.c31
-rw-r--r--termios/sys/termios.h4
-rw-r--r--termios/sys/ttydefaults.h96
-rw-r--r--termios/termios.h98
6 files changed, 290 insertions, 0 deletions
diff --git a/termios/Makefile b/termios/Makefile
new file mode 100644
index 0000000000..bf534d7a66
--- /dev/null
+++ b/termios/Makefile
@@ -0,0 +1,28 @@
+# Copyright (C) 1991, 1992, 1993, 1995 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 Library General Public License as
+# published by the Free Software Foundation; either version 2 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
+# Library General Public License for more details.
+
+# You should have received a copy of the GNU Library General Public
+# License along with the GNU C Library; see the file COPYING.LIB.  If
+# not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+# Cambridge, MA 02139, USA.
+
+#
+#	Makefile for the terminal I/O functions.
+#
+subdir	:= termios
+
+headers	:= termios.h termbits.h sys/ttydefaults.h sys/termios.h
+routines	:= speed cfsetspeed tcsetattr tcgetattr tcgetpgrp tcsetpgrp \
+		   tcdrain tcflow tcflush tcsendbrk cfmakeraw
+
+include ../Rules
diff --git a/termios/cfmakeraw.c b/termios/cfmakeraw.c
new file mode 100644
index 0000000000..09f630b906
--- /dev/null
+++ b/termios/cfmakeraw.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1992 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <ansidecl.h>
+#include <termios.h>
+
+/* Set *T to indicate raw mode.  */
+void
+DEFUN(cfmakeraw, (termios_p), 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] = 0;
+  /* t->c_cc[VTIME] = ?; */
+}
diff --git a/termios/cfsetspeed.c b/termios/cfsetspeed.c
new file mode 100644
index 0000000000..a4a205b52f
--- /dev/null
+++ b/termios/cfsetspeed.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1992, 1993 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+#include <ansidecl.h>
+#include <termios.h>
+#include <errno.h>
+#include <stddef.h>
+
+/* Set both the input and output baud rates stored in *TERMIOS_P to SPEED.  */
+void
+DEFUN(cfsetspeed, (termios_p, speed),
+      struct termios *termios_p AND speed_t speed)
+{
+  cfsetispeed (termios_p, speed);
+  cfsetospeed (termios_p, speed);
+}
diff --git a/termios/sys/termios.h b/termios/sys/termios.h
new file mode 100644
index 0000000000..3e18805ab4
--- /dev/null
+++ b/termios/sys/termios.h
@@ -0,0 +1,4 @@
+#ifndef _SYS_TERMIOS_H
+#define _SYS_TERMIOS_H
+#include <termios.h>
+#endif
diff --git a/termios/sys/ttydefaults.h b/termios/sys/ttydefaults.h
new file mode 100644
index 0000000000..1a8aaa5bd0
--- /dev/null
+++ b/termios/sys/ttydefaults.h
@@ -0,0 +1,96 @@
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 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.
+ *
+ *	@(#)ttydefaults.h	8.4 (Berkeley) 1/21/94
+ */
+
+/*
+ * System wide defaults for terminal state.
+ */
+#ifndef _SYS_TTYDEFAULTS_H_
+#define	_SYS_TTYDEFAULTS_H_
+
+/*
+ * Defaults on "first" open.
+ */
+#define	TTYDEF_IFLAG	(BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
+#define TTYDEF_OFLAG	(OPOST | ONLCR | OXTABS)
+#define TTYDEF_LFLAG	(ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
+#define TTYDEF_CFLAG	(CREAD | CS7 | PARENB | HUPCL)
+#define TTYDEF_SPEED	(B9600)
+
+/*
+ * Control Character Defaults
+ */
+#define CTRL(x)	(x&037)
+#define	CEOF		CTRL('d')
+#define	CEOL		((unsigned char)'\377')	/* XXX avoid _POSIX_VDISABLE */
+#define	CERASE		0177
+#define	CINTR		CTRL('c')
+#define	CSTATUS		((unsigned char)'\377')	/* XXX avoid _POSIX_VDISABLE */
+#define	CKILL		CTRL('u')
+#define	CMIN		1
+#define	CQUIT		034		/* FS, ^\ */
+#define	CSUSP		CTRL('z')
+#define	CTIME		0
+#define	CDSUSP		CTRL('y')
+#define	CSTART		CTRL('q')
+#define	CSTOP		CTRL('s')
+#define	CLNEXT		CTRL('v')
+#define	CDISCARD 	CTRL('o')
+#define	CWERASE 	CTRL('w')
+#define	CREPRINT 	CTRL('r')
+#define	CEOT		CEOF
+/* compat */
+#define	CBRK		CEOL
+#define CRPRNT		CREPRINT
+#define	CFLUSH		CDISCARD
+
+/* PROTECTED INCLUSION ENDS HERE */
+#endif /* !_SYS_TTYDEFAULTS_H_ */
+
+/*
+ * #define TTYDEFCHARS to include an array of default control characters.
+ */
+#ifdef TTYDEFCHARS
+cc_t	ttydefchars[NCCS] = {
+	CEOF,	CEOL,	CEOL,	CERASE, CWERASE, CKILL, CREPRINT, 
+	_POSIX_VDISABLE, CINTR,	CQUIT,	CSUSP,	CDSUSP,	CSTART,	CSTOP,	CLNEXT,
+	CDISCARD, CMIN,	CTIME,  CSTATUS, _POSIX_VDISABLE
+};
+#undef TTYDEFCHARS
+#endif
diff --git a/termios/termios.h b/termios/termios.h
new file mode 100644
index 0000000000..f2e83a56f9
--- /dev/null
+++ b/termios/termios.h
@@ -0,0 +1,98 @@
+/* Copyright (C) 1991, 1992, 1993, 1994 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 Library General Public License as
+published by the Free Software Foundation; either version 2 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+/*
+ *	POSIX Standard: 7.1-2 General Terminal Interface	<termios.h>
+ */
+
+#ifndef	_TERMIOS_H
+
+#define	_TERMIOS_H	1
+#include <features.h>
+
+__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 <termbits.h>
+
+#ifdef __USE_BSD
+/* 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 __P ((__const struct termios *__termios_p));
+
+/* Return the input baud rate stored in *TERMIOS_P.  */
+extern speed_t cfgetispeed __P ((__const struct termios *__termios_p));
+
+/* Set the output baud rate stored in *TERMIOS_P to SPEED.  */
+extern int cfsetospeed __P ((struct termios *__termios_p, speed_t __speed));
+
+/* Set the input baud rate stored in *TERMIOS_P to SPEED.  */
+extern int cfsetispeed __P ((struct termios *__termios_p, speed_t __speed));
+
+#ifdef	__USE_BSD
+/* Set both the input and output baud rates in *TERMIOS_OP to SPEED.  */
+extern void cfsetspeed __P ((struct termios *__termios_p, speed_t __speed));
+#endif
+
+
+/* Put the state of FD into *TERMIOS_P.  */
+extern int __tcgetattr __P ((int __fd, struct termios *__termios_p));
+extern int tcgetattr __P ((int __fd, struct termios *__termios_p));
+
+#ifdef	__OPTIMIZE__
+#define	tcgetattr(fd, termios_p)	__tcgetattr((fd), (termios_p))
+#endif /* Optimizing.  */
+
+/* Set the state of FD to *TERMIOS_P.
+   Values for OPTIONAL_ACTIONS (TCSA*) are in <termbits.h>.  */
+extern int tcsetattr __P ((int __fd, int __optional_actions,
+			   __const struct termios *__termios_p));
+
+
+#ifdef	__USE_BSD
+/* Set *TERMIOS_P to indicate raw mode.  */
+extern void cfmakeraw __P ((struct termios *__termios_p));
+#endif
+
+/* Send zero bits on FD.  */
+extern int tcsendbreak __P ((int __fd, int __duration));
+
+/* Wait for pending output to be written on FD.  */
+extern int tcdrain __P ((int __fd));
+
+/* Flush pending data on FD.
+   Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in <termbits.h>.  */
+extern int tcflush __P ((int __fd, int __queue_selector));
+
+/* Suspend or restart transmission on FD.
+   Values for ACTION (TC[IO]{OFF,ON}) are in <termbits.h>.  */
+extern int tcflow __P ((int __fd, int __action));
+
+
+#ifdef __USE_BSD
+#include <sys/ttydefaults.h>
+#endif
+
+__END_DECLS
+
+#endif /* termios.h  */