summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-16 15:27:52 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-11-16 15:27:52 +0000
commitc7016198fa34f63e0dd2c8f68443ce2a4170fd79 (patch)
treed38ac3d9c3fa72845b7056ffdec90a9d97312809 /c
parentb88691c30f077c08da83d925a8070b489c1bd2f0 (diff)
downloadrtems-c7016198fa34f63e0dd2c8f68443ce2a4170fd79.tar.bz2
Added.
Diffstat (limited to 'c')
-rw-r--r--c/src/exec/libcsupport/src/ctermid.c33
-rw-r--r--c/src/exec/libcsupport/src/tcgetprgrp.c33
-rw-r--r--c/src/exec/libcsupport/src/tcsendbreak.c33
-rw-r--r--c/src/exec/libcsupport/src/tcsetpgrp.c33
-rw-r--r--c/src/exec/libcsupport/src/ttyname.c73
-rw-r--r--c/src/lib/libc/Makefile.in7
-rw-r--r--c/src/lib/libc/ctermid.c33
-rw-r--r--c/src/lib/libc/tcgetprgrp.c33
-rw-r--r--c/src/lib/libc/tcsendbreak.c33
-rw-r--r--c/src/lib/libc/tcsetpgrp.c33
-rw-r--r--c/src/lib/libc/ttyname.c73
11 files changed, 414 insertions, 3 deletions
diff --git a/c/src/exec/libcsupport/src/ctermid.c b/c/src/exec/libcsupport/src/ctermid.c
new file mode 100644
index 0000000000..23308dc4a6
--- /dev/null
+++ b/c/src/exec/libcsupport/src/ctermid.c
@@ -0,0 +1,33 @@
+/*
+ * ctermid() - POSIX 1003.1b 4.7.1 - Generate Terminal Pathname
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <stdio.h>
+
+static ctermid_name = "/dev/console";
+
+char *ctermid(
+ char *s
+)
+{
+ if ( !s )
+ return ctermid_name;
+
+ strcpy( s, ctermid_name );
+ return s;
+}
+
+#endif
diff --git a/c/src/exec/libcsupport/src/tcgetprgrp.c b/c/src/exec/libcsupport/src/tcgetprgrp.c
new file mode 100644
index 0000000000..563a1842ed
--- /dev/null
+++ b/c/src/exec/libcsupport/src/tcgetprgrp.c
@@ -0,0 +1,33 @@
+/*
+ * tcgetprgrp() - POSIX 1003.1b 7.2.3 - Get Foreground Process Group ID
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <termios.h>
+/* #include <sys/ioctl.h> */
+
+int ioctl();
+
+#include <rtems/libio.h>
+
+pid_t tcgetprgrp(int fd)
+{
+ return getpid();
+}
+
+#endif
diff --git a/c/src/exec/libcsupport/src/tcsendbreak.c b/c/src/exec/libcsupport/src/tcsendbreak.c
new file mode 100644
index 0000000000..e7da9cf165
--- /dev/null
+++ b/c/src/exec/libcsupport/src/tcsendbreak.c
@@ -0,0 +1,33 @@
+/*
+ * tcsendbreak() - POSIX 1003.1b 7.2.2 - Line Control Functions
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <termios.h>
+/* #include <sys/ioctl.h> */
+
+int ioctl();
+
+#include <rtems/libio.h>
+
+int tcsendbreak ( int fd, int duration )
+{
+ return 0;
+}
+
+#endif
diff --git a/c/src/exec/libcsupport/src/tcsetpgrp.c b/c/src/exec/libcsupport/src/tcsetpgrp.c
new file mode 100644
index 0000000000..3e6c32c9c4
--- /dev/null
+++ b/c/src/exec/libcsupport/src/tcsetpgrp.c
@@ -0,0 +1,33 @@
+/*
+ * tcsetprgrp() - POSIX 1003.1b 7.2.4 - Set Foreground Process Group ID
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <termios.h>
+/* #include <sys/ioctl.h> */
+
+int ioctl();
+
+#include <rtems/libio.h>
+
+int tcsetprgrp(int fd, pid_t pid)
+{
+ return 0;
+}
+
+#endif
diff --git a/c/src/exec/libcsupport/src/ttyname.c b/c/src/exec/libcsupport/src/ttyname.c
new file mode 100644
index 0000000000..51b3a5f6aa
--- /dev/null
+++ b/c/src/exec/libcsupport/src/ttyname.c
@@ -0,0 +1,73 @@
+/*
+ * ttyname_r() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name
+ *
+ * $Id$
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <termios.h>
+#include <unistd.h>
+#include <paths.h>
+#include <_syslist.h>
+#include <errno.h>
+
+#include <rtems/posix/seterr.h>
+
+int ttyname_r(
+ int fd,
+ char *name,
+ int namesize
+)
+{
+ struct stat sb;
+ struct termios tty;
+ struct dirent *dirp;
+ DIR *dp;
+ struct stat dsb;
+ char *rval;
+
+ /* Must be a terminal. */
+ if (tcgetattr (fd, &tty) < 0)
+ set_errno_and_return_minus_one(EBADF);
+
+ /* Must be a character device. */
+ if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode))
+ set_errno_and_return_minus_one(EBADF);
+
+ if ((dp = opendir (_PATH_DEV)) == NULL)
+ set_errno_and_return_minus_one(EBADF);
+
+ for (rval = NULL; (dirp = readdir (dp)) != NULL ;)
+ {
+ if (dirp->d_ino != sb.st_ino)
+ continue;
+ strcpy (name + sizeof (_PATH_DEV) - 1, dirp->d_name);
+ if (stat (name, &dsb) || sb.st_dev != dsb.st_dev ||
+ sb.st_ino != dsb.st_ino)
+ continue;
+ (void) closedir (dp);
+ rval = name;
+ break;
+ }
+ (void) closedir (dp);
+ return 0;
+}
+
+static char buf[sizeof (_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
+
+/*
+ * ttyname() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name
+ */
+
+char *ttyname(
+ int fd
+)
+{
+ if ( !ttyname_r( fd, buf, sizeof(buf) ) )
+ return buf;
+ return NULL;
+}
+
diff --git a/c/src/lib/libc/Makefile.in b/c/src/lib/libc/Makefile.in
index ceba4f7bef..7b3c80ba64 100644
--- a/c/src/lib/libc/Makefile.in
+++ b/c/src/lib/libc/Makefile.in
@@ -32,13 +32,13 @@ IMFS_C_PIECES = imfs_chown imfs_creat imfs_directory imfs_eval imfs_free \
imfs_fcntl miniimfs_init
TERMIOS_C_PIECES = cfgetispeed cfgetospeed cfsetispeed cfsetospeed tcgetattr \
- tcsetattr tcdrain tcflow tcflush termios \
- termiosinitialize termiosreserveresources
+ tcsetattr tcdrain tcflow tcflush tcgetprgrp tcsendbreak tcsetpgrp \
+ termios termiosinitialize termiosreserveresources
SYSTEM_CALL_C_PIECES = open close read write lseek ioctl mkdir mknod mkfifo \
rmdir chdir chmod fchmod chown link unlink umask ftruncate utime fstat \
fcntl fpathconf getdents fsync fdatasync pipe dup dup2 symlink readlink \
- creat isatty
+ creat
DIRECTORY_SCAN_C_PIECES = opendir closedir readdir rewinddir scandir seekdir \
telldir getcwd
@@ -47,6 +47,7 @@ MALLOC_C_PIECES = malloc __brk __sbrk
PASSWORD_GROUP_C_PIECES = getpwent getgrent
+TERMINAL_IDENTIFICATION = ctermid isatty ttyname ttyname_r
LIBC_GLUE_C_PIECES = __getpid __gettod __times truncate access stat \
lstat pathconf newlibc no_posix no_libc
diff --git a/c/src/lib/libc/ctermid.c b/c/src/lib/libc/ctermid.c
new file mode 100644
index 0000000000..23308dc4a6
--- /dev/null
+++ b/c/src/lib/libc/ctermid.c
@@ -0,0 +1,33 @@
+/*
+ * ctermid() - POSIX 1003.1b 4.7.1 - Generate Terminal Pathname
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <stdio.h>
+
+static ctermid_name = "/dev/console";
+
+char *ctermid(
+ char *s
+)
+{
+ if ( !s )
+ return ctermid_name;
+
+ strcpy( s, ctermid_name );
+ return s;
+}
+
+#endif
diff --git a/c/src/lib/libc/tcgetprgrp.c b/c/src/lib/libc/tcgetprgrp.c
new file mode 100644
index 0000000000..563a1842ed
--- /dev/null
+++ b/c/src/lib/libc/tcgetprgrp.c
@@ -0,0 +1,33 @@
+/*
+ * tcgetprgrp() - POSIX 1003.1b 7.2.3 - Get Foreground Process Group ID
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <termios.h>
+/* #include <sys/ioctl.h> */
+
+int ioctl();
+
+#include <rtems/libio.h>
+
+pid_t tcgetprgrp(int fd)
+{
+ return getpid();
+}
+
+#endif
diff --git a/c/src/lib/libc/tcsendbreak.c b/c/src/lib/libc/tcsendbreak.c
new file mode 100644
index 0000000000..e7da9cf165
--- /dev/null
+++ b/c/src/lib/libc/tcsendbreak.c
@@ -0,0 +1,33 @@
+/*
+ * tcsendbreak() - POSIX 1003.1b 7.2.2 - Line Control Functions
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <termios.h>
+/* #include <sys/ioctl.h> */
+
+int ioctl();
+
+#include <rtems/libio.h>
+
+int tcsendbreak ( int fd, int duration )
+{
+ return 0;
+}
+
+#endif
diff --git a/c/src/lib/libc/tcsetpgrp.c b/c/src/lib/libc/tcsetpgrp.c
new file mode 100644
index 0000000000..3e6c32c9c4
--- /dev/null
+++ b/c/src/lib/libc/tcsetpgrp.c
@@ -0,0 +1,33 @@
+/*
+ * tcsetprgrp() - POSIX 1003.1b 7.2.4 - Set Foreground Process Group ID
+ *
+ * COPYRIGHT (c) 1989-1998.
+ * On-Line Applications Research Corporation (OAR).
+ * Copyright assigned to U.S. Government, 1994.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#if defined(RTEMS_NEWLIB)
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <termios.h>
+/* #include <sys/ioctl.h> */
+
+int ioctl();
+
+#include <rtems/libio.h>
+
+int tcsetprgrp(int fd, pid_t pid)
+{
+ return 0;
+}
+
+#endif
diff --git a/c/src/lib/libc/ttyname.c b/c/src/lib/libc/ttyname.c
new file mode 100644
index 0000000000..51b3a5f6aa
--- /dev/null
+++ b/c/src/lib/libc/ttyname.c
@@ -0,0 +1,73 @@
+/*
+ * ttyname_r() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name
+ *
+ * $Id$
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <termios.h>
+#include <unistd.h>
+#include <paths.h>
+#include <_syslist.h>
+#include <errno.h>
+
+#include <rtems/posix/seterr.h>
+
+int ttyname_r(
+ int fd,
+ char *name,
+ int namesize
+)
+{
+ struct stat sb;
+ struct termios tty;
+ struct dirent *dirp;
+ DIR *dp;
+ struct stat dsb;
+ char *rval;
+
+ /* Must be a terminal. */
+ if (tcgetattr (fd, &tty) < 0)
+ set_errno_and_return_minus_one(EBADF);
+
+ /* Must be a character device. */
+ if (_fstat (fd, &sb) || !S_ISCHR (sb.st_mode))
+ set_errno_and_return_minus_one(EBADF);
+
+ if ((dp = opendir (_PATH_DEV)) == NULL)
+ set_errno_and_return_minus_one(EBADF);
+
+ for (rval = NULL; (dirp = readdir (dp)) != NULL ;)
+ {
+ if (dirp->d_ino != sb.st_ino)
+ continue;
+ strcpy (name + sizeof (_PATH_DEV) - 1, dirp->d_name);
+ if (stat (name, &dsb) || sb.st_dev != dsb.st_dev ||
+ sb.st_ino != dsb.st_ino)
+ continue;
+ (void) closedir (dp);
+ rval = name;
+ break;
+ }
+ (void) closedir (dp);
+ return 0;
+}
+
+static char buf[sizeof (_PATH_DEV) + MAXNAMLEN] = _PATH_DEV;
+
+/*
+ * ttyname() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name
+ */
+
+char *ttyname(
+ int fd
+)
+{
+ if ( !ttyname_r( fd, buf, sizeof(buf) ) )
+ return buf;
+ return NULL;
+}
+