Patch from Eric Norum:

With this in place, it is possible to fdopen a TCP stream socket and
  getc/fprintf/etc. on the STDIO stream!
This commit is contained in:
Joel Sherrill
1998-01-19 22:22:25 +00:00
parent 6f9c75c322
commit 4dc0fd685b
5 changed files with 27 additions and 7 deletions

View File

@@ -113,6 +113,7 @@ struct rtems_termios_tty {
int (*read)(int minor); int (*read)(int minor);
int (*write)(int minor, const char *buf, int len); int (*write)(int minor, const char *buf, int len);
}; };
static struct rtems_termios_tty *ttyHead, *ttyTail; static struct rtems_termios_tty *ttyHead, *ttyTail;
static rtems_id ttyMutex; static rtems_id ttyMutex;

View File

@@ -30,7 +30,7 @@ SRCS=$(C_FILES) $(H_FILES) $(SYS_H_FILES) $(RTEMS_H_FILES) $(PRIVATE_H_FILES)
OBJS=$(C_O_FILES) OBJS=$(C_O_FILES)
include $(RTEMS_CUSTOM) include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/lib.cfg include $(RTEMS_ROOT)/make/lib.cfg
# #
# Add local stuff here using += # Add local stuff here using +=

View File

@@ -26,6 +26,7 @@
#include <stdio.h> /* only for puts */ #include <stdio.h> /* only for puts */
#include <rtems.h> #include <rtems.h>
#include <rtems/libio.h>
#ifdef RTEMS_NEWLIB #ifdef RTEMS_NEWLIB
/* /*
@@ -35,20 +36,36 @@
int __rtems_fstat(int _fd, struct stat* _sbuf) int __rtems_fstat(int _fd, struct stat* _sbuf)
{ {
if ( _fd > 2 ) {
puts( "__rtems_fstat -- only stdio supported" );
assert( 0 );
}
_sbuf->st_mode = S_IFCHR;
#ifdef HAVE_BLKSIZE #ifdef HAVE_BLKSIZE
_sbuf->st_blksize = 0; _sbuf->st_blksize = 0;
#endif #endif
/*
* For now assume stdin/stdout/stderr are always a TTY line
*/
if (_fd <= 2) {
_sbuf->st_mode = S_IFCHR;
} else {
switch (rtems_file_descriptor_type (_fd)) {
case RTEMS_FILE_DESCRIPTOR_TYPE_SOCKET:
_sbuf->st_mode = S_IFSOCK;
break;
default:
puts( "__rtems_fstat -- unknown socket type" );
assert( 0 );
}
}
return 0; return 0;
} }
int __rtems_isatty(int _fd) int __rtems_isatty(int _fd)
{ {
return 1; struct stat st;
if (__rtems_fstat(_fd, &st) < 0)
return 0;
return S_ISCHR (st.st_mode);
} }
#if !defined(RTEMS_UNIX) #if !defined(RTEMS_UNIX)

View File

@@ -113,6 +113,7 @@ struct rtems_termios_tty {
int (*read)(int minor); int (*read)(int minor);
int (*write)(int minor, const char *buf, int len); int (*write)(int minor, const char *buf, int len);
}; };
static struct rtems_termios_tty *ttyHead, *ttyTail; static struct rtems_termios_tty *ttyHead, *ttyTail;
static rtems_id ttyMutex; static rtems_id ttyMutex;

View File

@@ -113,6 +113,7 @@ struct rtems_termios_tty {
int (*read)(int minor); int (*read)(int minor);
int (*write)(int minor, const char *buf, int len); int (*write)(int minor, const char *buf, int len);
}; };
static struct rtems_termios_tty *ttyHead, *ttyTail; static struct rtems_termios_tty *ttyHead, *ttyTail;
static rtems_id ttyMutex; static rtems_id ttyMutex;