diff --git a/scsh/aix/stdio_dep.c b/scsh/aix/stdio_dep.c deleted file mode 100644 index 9b3d1b7..0000000 --- a/scsh/aix/stdio_dep.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (c) 1994 by Olin Shivers. -** Copyright (c) 1994-1995 by Brian D. Carlstrom. -** AIX version by Chipsy Sperber -** -** This file implements the char-ready? procedure for file descriptors -** and Scsh's fdports. It is not Posix, so it must be implemented for -** each OS to which scsh is ported. -** -** This version assumes two things: -** - the existence of select to tell if there is data -** available for the file descriptor. -** - the existence of the _cnt field in the stdio FILE struct, telling -** if there is any buffered input in the struct. -** -** Most Unixes have these things, so this file should work for them. -** However, Your Mileage May Vary. -** -** You could also replace the select() with a iotctl(FIONREAD) call, if you -** had one but not the other. -** -Olin&Brian -*/ - -#include -#include -#include -#include -#include "libcig.h" -#include -#include - -#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ - -/* These two procs return #t if data ready, #f data not ready, -** and errno if error. -*/ - -s48_value char_ready_fdes(int fd) -{ - fd_set readfds; - struct timeval timeout; - int result; - - FD_ZERO(&readfds); - FD_SET(fd,&readfds); - - timeout.tv_sec=0; - timeout.tv_usec=0; - - result=select(fd+1, &readfds, NULL, NULL, &timeout); - - if(result == -1 ) - return(s48_enter_fixnum(errno)); - if(result) - return(S48_TRUE); - return(S48_FALSE); -} - -s48_value stream_char_readyp(FILE *f) -{ - int fd = fileno(f); - return f->_cnt > 0 ? S48_TRUE : char_ready_fdes(fd); -} - -void setfileno(FILE *fs, int fd) -{ - fileno(fs) = fd; -} - -int fbufcount(FILE* fs) -{ - return(fs->_cnt); -} - -/* Returns true if there is no buffered data in stream FS -** (or there is no buffering, period.) -*/ - -int ibuf_empty(FILE *fs) {return fs->_cnt <= 0;} - - -/* Returns true if the buffer in stream FS is full -** (or there is no buffering, period). -*/ - -int obuf_full(FILE *fs) {return fs->_cnt <= 0;} diff --git a/scsh/aix/stdio_dep.h b/scsh/aix/stdio_dep.h deleted file mode 100644 index 435ebf0..0000000 --- a/scsh/aix/stdio_dep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Exports from stdio_dep.h. */ - -s48_value char_ready_fdes(int fd); - -s48_value stream_char_readyp(FILE *f); - -void setfileno(FILE *fs, int fd); - -int fbufcount(FILE* fs); - -int ibuf_empty(FILE *fs); - -int obuf_full(FILE *fs); diff --git a/scsh/bsd/stdio_dep.c b/scsh/bsd/stdio_dep.c deleted file mode 100644 index 39b1efe..0000000 --- a/scsh/bsd/stdio_dep.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (c) 1994 by Olin Shivers. -** Copyright (c) 1994-1995 by Brian D. Carlstrom. -** -** This file implements the char-ready? procedure for file descriptors -** and Scsh's fdports. It is not Posix, so it must be implemented for -** each OS to which scsh is ported. -** -** This version assumes two things: -** - the existence of select to tell if there is data -** available for the file descriptor. -** - the existence of the _cnt field in the stdio FILE struct, telling -** if there is any buffered input in the struct. -** -** Most Unixes have these things, so this file should work for them. -** However, Your Mileage May Vary. -** -** You could also replace the select() with a iotctl(FIONREAD) call, if you -** had one but not the other. -** -Olin&Brian -*/ - -#include -#include -#include -#include -#include "libcig.h" -#include - -#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ - -/* These two procs return #t if data ready, #f data not ready, -** and errno if error. -*/ - -s48_value char_ready_fdes(int fd) -{ - fd_set readfds; - struct timeval timeout; - int result; - - FD_ZERO(&readfds); - FD_SET(fd,&readfds); - - timeout.tv_sec=0; - timeout.tv_usec=0; - - result=select(fd+1, &readfds, NULL, NULL, &timeout); - - if(result == -1 ) - return(s48_enter_fixnum(errno)); - if(result) - return(S48_TRUE); - return(S48_FALSE); -} - -s48_value stream_char_readyp(FILE *f) -{ - int fd = fileno(f); - return f->_r > 0 ? S48_TRUE : char_ready_fdes(fd); -} - -void setfileno(FILE *fs, int fd) -{ - fileno(fs) = fd; -} - -int fbufcount(FILE* fs) -{ - return(fs->_r); -} - -/* Returns true if there is no buffered data in stream FS -** (or there is no buffering, period.) -*/ - -int ibuf_empty(FILE *fs) {return fs->_r <= 0;} - - -/* Returns true if the buffer in stream FS is full -** (or there is no buffering, period). -*/ - -int obuf_full(FILE *fs) {return fs->_w <= 0;} diff --git a/scsh/bsd/stdio_dep.h b/scsh/bsd/stdio_dep.h deleted file mode 100644 index 435ebf0..0000000 --- a/scsh/bsd/stdio_dep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Exports from stdio_dep.h. */ - -s48_value char_ready_fdes(int fd); - -s48_value stream_char_readyp(FILE *f); - -void setfileno(FILE *fs, int fd); - -int fbufcount(FILE* fs); - -int ibuf_empty(FILE *fs); - -int obuf_full(FILE *fs); diff --git a/scsh/cygwin32/stdio_dep.c b/scsh/cygwin32/stdio_dep.c deleted file mode 100644 index cca339f..0000000 --- a/scsh/cygwin32/stdio_dep.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright (c) 1994 by Olin Shivers. -** Copyright (c) 1994-1999 by Brian D. Carlstrom. -** -** This file implements the char-ready? procedure for file descriptors -** and Scsh's fdports. It is not Posix, so it must be implemented for -** each OS to which scsh is ported. -** -** This version assumes two things: -** - the existence of select to tell if there is data -** available for the file descriptor. -** - the existence of the _cnt field in the stdio FILE struct, telling -** if there is any buffered input in the struct. -** -** Most Unixes have these things, so this file should work for them. -** However, Your Mileage May Vary. -** -** You could also replace the select() with a iotctl(FIONREAD) call, if you -** had one but not the other. -** -Olin&Brian -*/ - -#include -#include -#include -#include -#include "libcig.h" -#include - -#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ - -/* These two procs return #t if data ready, #f data not ready, -** and errno if error. -*/ - -s48_value char_ready_fdes(int fd) -{ - fd_set readfds; - struct timeval timeout; - int result; - - FD_ZERO(&readfds); - FD_SET(fd,&readfds); - - timeout.tv_sec=0; - timeout.tv_usec=0; - - result=select(fd+1, &readfds, NULL, NULL, &timeout); - - if(result == -1 ) - return(s48_enter_fixnum(errno)); - if(result) - return(S48_TRUE); - return(S48_FALSE); -} - -s48_value stream_char_readyp(FILE *f) -{ - int fd = fileno(f); - return f->_r > 0 ? S48_TRUE : char_ready_fdes(fd); -} - -void setfileno(FILE *fs, int fd) -{ - fs->_file = fd; -} - -int fbufcount(FILE* fs) -{ - return(fs->_r); -} - -/* Returns true if there is no buffered data in stream FS -** (or there is no buffering, period.) -*/ - -int ibuf_empty(FILE *fs) {return fs->_r <= 0;} - - -/* Returns true if the buffer in stream FS is full -** (or there is no buffering, period). -*/ - -int obuf_full(FILE *fs) {return fs->_w <= 0;} - - -/* Cygwin doesn't yet implement these system calls */ -struct netent *getnetbyaddr (long x, int y) {return NULL;} -struct netent *getnetbyname (const char *x) {return NULL;} -int fchown(int x, uid_t y, gid_t z) {return 0;} -int mkfifo(char *__path, mode_t __mode) {return 0;} diff --git a/scsh/cygwin32/stdio_dep.h b/scsh/cygwin32/stdio_dep.h deleted file mode 100644 index 435ebf0..0000000 --- a/scsh/cygwin32/stdio_dep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Exports from stdio_dep.h. */ - -s48_value char_ready_fdes(int fd); - -s48_value stream_char_readyp(FILE *f); - -void setfileno(FILE *fs, int fd); - -int fbufcount(FILE* fs); - -int ibuf_empty(FILE *fs); - -int obuf_full(FILE *fs); diff --git a/scsh/hpux/stdio_dep.c b/scsh/hpux/stdio_dep.c deleted file mode 100644 index a4b6194..0000000 --- a/scsh/hpux/stdio_dep.c +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 1994 by Olin Shivers. -** Copyright (c) 1994-1995 by Brian D. Carlstrom. -** -** This file implements the char-ready? procedure for file descriptors -** and Scsh's fdports. It is not Posix, so it must be implemented for -** each OS to which scsh is ported. -** -** This version assumes two things: -** - the existence of select to tell if there is data -** available for the file descriptor. -** - the existence of the _cnt field in the stdio FILE struct, telling -** if there is any buffered input in the struct. -** -** Most Unixes have these things, so this file should work for them. -** However, Your Mileage May Vary. -** -** You could also replace the select() with a iotctl(FIONREAD) call, if you -** had one but not the other. -** -Olin&Brian -*/ - -#include -#include -#include -#include -#include "libcig.h" -#include - -#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ - -/* These two procs return #t if data ready, #f data not ready, -** and errno if error. -*/ - -s48_value char_ready_fdes(int fd) -{ - fd_set readfds; - struct timeval timeout; - int result; - - FD_ZERO(&readfds); - FD_SET(fd,&readfds); - - timeout.tv_sec=0; - timeout.tv_usec=0; - - result=select(fd+1, &readfds, NULL, NULL, &timeout); - - if(result == -1 ) - return(s48_enter_fixnum(errno)); - if(result) - return(S48_TRUE); - return(S48_FALSE); -} - -s48_value stream_char_readyp(FILE *f) -{ - int fd = fileno(f); - return f->_cnt > 0 ? S48_TRUE : char_ready_fdes(fd); -} - -void setfileno(FILE *fs, int fd) -{ - fs->__fileL = (fd & 0xFF); - fs->__fileH = ((fd>>8) & 0xFF); -} - -int fbufcount(FILE* fs) -{ - return(fs->_cnt); -} - -/* Returns true if there is no buffered data in stream FS -** (or there is no buffering, period.) -*/ - -int ibuf_empty(FILE *fs) {return fs->_cnt <= 0;} - - -/* Returns true if the buffer in stream FS is full -** (or there is no buffering, period). -*/ - -int obuf_full(FILE *fs) {return fs->_cnt <= 0;} diff --git a/scsh/hpux/stdio_dep.h b/scsh/hpux/stdio_dep.h deleted file mode 100644 index 435ebf0..0000000 --- a/scsh/hpux/stdio_dep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Exports from stdio_dep.h. */ - -s48_value char_ready_fdes(int fd); - -s48_value stream_char_readyp(FILE *f); - -void setfileno(FILE *fs, int fd); - -int fbufcount(FILE* fs); - -int ibuf_empty(FILE *fs); - -int obuf_full(FILE *fs); diff --git a/scsh/irix/stdio_dep.c b/scsh/irix/stdio_dep.c deleted file mode 100644 index c0fcfd3..0000000 --- a/scsh/irix/stdio_dep.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (c) 1994 by Olin Shivers. -** Copyright (c) 1994-1995 by Brian D. Carlstrom. -** -** This file implements the char-ready? procedure for file descriptors -** and Scsh's fdports. It is not Posix, so it must be implemented for -** each OS to which scsh is ported. -** -** This version assumes two things: -** - the existence of select to tell if there is data -** available for the file descriptor. -** - the existence of the _cnt field in the stdio FILE struct, telling -** if there is any buffered input in the struct. -** -** Most Unixes have these things, so this file should work for them. -** However, Your Mileage May Vary. -** -** You could also replace the select() with a iotctl(FIONREAD) call, if you -** had one but not the other. -** -Olin&Brian -*/ - -#include -#include -#include -#include -#include "libcig.h" -#include - -#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ - -/* These two procs return #t if data ready, #f data not ready, -** and errno if error. -*/ - -s48_value char_ready_fdes(int fd) -{ - fd_set readfds; - struct timeval timeout; - int result; - - FD_ZERO(&readfds); - FD_SET(fd,&readfds); - - timeout.tv_sec=0; - timeout.tv_usec=0; - - result=select(fd+1, &readfds, NULL, NULL, &timeout); - - if(result == -1 ) - return(s48_enter_fixnum(errno)); - if(result) - return(S48_TRUE); - return(S48_FALSE); -} - -s48_value stream_char_readyp(FILE *f) -{ - int fd = fileno(f); - return f->_cnt > 0 ? S48_TRUE : char_ready_fdes(fd); -} - -void setfileno(FILE *fs, int fd) -{ - fileno(fs) = fd; -} - -int fbufcount(FILE* fs) -{ - return(fs->_cnt); -} - -/* Returns true if there is no buffered data in stream FS -** (or there is no buffering, period.) -*/ - -int ibuf_empty(FILE *fs) {return fs->_cnt <= 0;} - - -/* Returns true if the buffer in stream FS is full -** (or there is no buffering, period). -*/ - -int obuf_full(FILE *fs) {return fs->_cnt <= 0;} diff --git a/scsh/irix/stdio_dep.h b/scsh/irix/stdio_dep.h deleted file mode 100644 index 435ebf0..0000000 --- a/scsh/irix/stdio_dep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Exports from stdio_dep.h. */ - -s48_value char_ready_fdes(int fd); - -s48_value stream_char_readyp(FILE *f); - -void setfileno(FILE *fs, int fd); - -int fbufcount(FILE* fs); - -int ibuf_empty(FILE *fs); - -int obuf_full(FILE *fs); diff --git a/scsh/linux/stdio_dep.c b/scsh/linux/stdio_dep.c deleted file mode 100644 index 5cfbd46..0000000 --- a/scsh/linux/stdio_dep.c +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (c) 1994 by Olin Shivers. -** Copyright (c) 1994-1995 by Brian D. Carlstrom. -** -** This file implements the char-ready? procedure for file descriptors -** and Scsh's fdports. It is not Posix, so it must be implemented for -** each OS to which scsh is ported. -** -** This version assumes two things: -** - the existence of select to tell if there is data -** available for the file descriptor. -** - the existence of the _cnt field in the stdio FILE struct, telling -** if there is any buffered input in the struct. -** -** Most Unixes have these things, so this file should work for them. -** However, Your Mileage May Vary. -** -** You could also replace the select() with a iotctl(FIONREAD) call, if you -** had one but not the other. -** -Olin&Brian -*/ - -#include -#include -#include -#include -#include "libcig.h" -#include - -#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ - -/* These two procs return #t if data ready, #f data not ready, -** and errno if error. -*/ - -s48_value char_ready_fdes(int fd) -{ - fd_set readfds; - struct timeval timeout; - int result; - - FD_ZERO(&readfds); - FD_SET(fd,&readfds); - - timeout.tv_sec=0; - timeout.tv_usec=0; - - result=select(fd+1, &readfds, NULL, NULL, &timeout); - - if(result == -1 ) - return(s48_enter_fixnum(errno)); - if(result) - return(S48_TRUE); - return(S48_FALSE); -} - -s48_value stream_char_readyp(FILE *f) -{ - int fd = fileno(f); - return (f->_IO_read_ptr < f->_IO_read_end) ? S48_TRUE : char_ready_fdes(fd); -} - -void setfileno(FILE *fs, int fd) -{ - fs->_fileno = fd; -} - -int fbufcount(FILE *fs) -{ - return((fs->_IO_read_end)-(fs->_IO_read_ptr)); -} - -int ibuf_empty(FILE *fs) -{ - return((fs->_IO_read_end)-(fs->_IO_read_ptr) <= 0); -} - -int obuf_full(FILE *fs) -{ - return((fs->_IO_write_end)-(fs->_IO_write_ptr) <= 0); -} diff --git a/scsh/linux/stdio_dep.h b/scsh/linux/stdio_dep.h deleted file mode 100644 index 435ebf0..0000000 --- a/scsh/linux/stdio_dep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Exports from stdio_dep.h. */ - -s48_value char_ready_fdes(int fd); - -s48_value stream_char_readyp(FILE *f); - -void setfileno(FILE *fs, int fd); - -int fbufcount(FILE* fs); - -int ibuf_empty(FILE *fs); - -int obuf_full(FILE *fs); diff --git a/scsh/next/stdio_dep.c b/scsh/next/stdio_dep.c deleted file mode 100644 index 69cd843..0000000 --- a/scsh/next/stdio_dep.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (c) 1994 by Olin Shivers. -** Copyright (c) 1994-1995 by Brian D. Carlstrom. -** -** This file implements the char-ready? procedure for file descriptors -** and Scsh's fdports. It is not Posix, so it must be implemented for -** each OS to which scsh is ported. -** -** This version assumes two things: -** - the existence of select to tell if there is data -** available for the file descriptor. -** - the existence of the _cnt field in the stdio FILE struct, telling -** if there is any buffered input in the struct. -** -** Most Unixes have these things, so this file should work for them. -** However, Your Mileage May Vary. -** -** You could also replace the select() with a iotctl(FIONREAD) call, if you -** had one but not the other. -** -Olin&Brian -*/ - -#include -#include -#include -#include -#include "libcig.h" -#include - -#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ - -/* These two procs return #t if data ready, #f data not ready, -** and errno if error. -*/ - -s48_value char_ready_fdes(int fd) -{ - fd_set readfds; - struct timeval timeout; - int result; - - FD_ZERO(&readfds); - FD_SET(fd,&readfds); - - timeout.tv_sec=0; - timeout.tv_usec=0; - - result=select(fd+1, &readfds, NULL, NULL, &timeout); - - if(result == -1 ) - return(s48_enter_fixnum(errno)); - if(result) - return(S48_TRUE); - return(S48_FALSE); -} - -s48_value stream_char_readyp(FILE *f) -{ - int fd = fileno(f); - return f->_cnt > 0 ? S48_TRUE : char_ready_fdes(fd); -} - -void setfileno(FILE *fs, int fd) -{ - fileno(fs) = fd; -} - -int fbufcount(FILE* fs) -{ - return fs->_cnt; -} - - -/* Returns true if there is no buffered data in stream FS -** (or there is no buffering, period.) -*/ - -int ibuf_empty(FILE *fs) -{ - return fs->_cnt <= 0; -} - - -/* Returns true if the buffer in stream FS is full -** (or there is no buffering, period). -*/ - -int obuf_full(FILE *fs) -{ - return (fs->_flag & _IOLBF) ? (- fs->_cnt >= fs->_bufsiz-1) - : (fs->_cnt <= 0); -} diff --git a/scsh/next/stdio_dep.h b/scsh/next/stdio_dep.h deleted file mode 100644 index 435ebf0..0000000 --- a/scsh/next/stdio_dep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Exports from stdio_dep.h. */ - -s48_value char_ready_fdes(int fd); - -s48_value stream_char_readyp(FILE *f); - -void setfileno(FILE *fs, int fd); - -int fbufcount(FILE* fs); - -int ibuf_empty(FILE *fs); - -int obuf_full(FILE *fs); diff --git a/scsh/solaris/stdio_dep.c b/scsh/solaris/stdio_dep.c deleted file mode 100644 index 3506624..0000000 --- a/scsh/solaris/stdio_dep.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (c) 1994 by Olin Shivers. -** Copyright (c) 1994-1995 by Brian D. Carlstrom. -** -** This file implements the char-ready? procedure for file descriptors -** and Scsh's fdports. It is not Posix, so it must be implemented for -** each OS to which scsh is ported. -** -** This version assumes two things: -** - the existence of select to tell if there is data -** available for the file descriptor. -** - the existence of the _cnt field in the stdio FILE struct, telling -** if there is any buffered input in the struct. -** -** Most Unixes have these things, so this file should work for them. -** However, Your Mileage May Vary. -** -** You could also replace the select() with a iotctl(FIONREAD) call, if you -** had one but not the other. -** -Olin&Brian -*/ - -#include -#include -#include -#include -#include "libcig.h" -#include - -/* somewhere around solaris 2.5 this changed to a function */ -#ifndef fileno -#define fileno(p) ((p)->_file) -#endif - -#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ - -/* These two procs return #t if data ready, #f data not ready, -** and errno if error. -*/ - -s48_value char_ready_fdes(int fd) -{ - fd_set readfds; - struct timeval timeout; - int result; - - FD_ZERO(&readfds); - FD_SET(fd,&readfds); - - timeout.tv_sec=0; - timeout.tv_usec=0; - - result=select(fd+1, &readfds, NULL, NULL, &timeout); - - if(result == -1 ) - return(s48_enter_fixnum(errno)); - if(result) - return(S48_TRUE); - return(S48_FALSE); -} - -s48_value stream_char_readyp(FILE *f) -{ - int fd = fileno(f); - return f->_cnt > 0 ? S48_TRUE : char_ready_fdes(fd); -} - -void setfileno(FILE *fs, int fd) -{ - fileno(fs) = fd; -} - -int fbufcount(FILE* fs) -{ - return(fs->_cnt); -} - -/* Returns true if there is no buffered data in stream FS -** (or there is no buffering, period.) -*/ - -int ibuf_empty(FILE *fs) {return fs->_cnt <= 0;} - - -/* Returns true if the buffer in stream FS is full -** (or there is no buffering, period). -*/ - -int obuf_full(FILE *fs) {return fs->_cnt <= 0;} diff --git a/scsh/solaris/stdio_dep.h b/scsh/solaris/stdio_dep.h deleted file mode 100644 index 435ebf0..0000000 --- a/scsh/solaris/stdio_dep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Exports from stdio_dep.h. */ - -s48_value char_ready_fdes(int fd); - -s48_value stream_char_readyp(FILE *f); - -void setfileno(FILE *fs, int fd); - -int fbufcount(FILE* fs); - -int ibuf_empty(FILE *fs); - -int obuf_full(FILE *fs); diff --git a/scsh/sunos/stdio_dep.c b/scsh/sunos/stdio_dep.c deleted file mode 100644 index c0fcfd3..0000000 --- a/scsh/sunos/stdio_dep.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (c) 1994 by Olin Shivers. -** Copyright (c) 1994-1995 by Brian D. Carlstrom. -** -** This file implements the char-ready? procedure for file descriptors -** and Scsh's fdports. It is not Posix, so it must be implemented for -** each OS to which scsh is ported. -** -** This version assumes two things: -** - the existence of select to tell if there is data -** available for the file descriptor. -** - the existence of the _cnt field in the stdio FILE struct, telling -** if there is any buffered input in the struct. -** -** Most Unixes have these things, so this file should work for them. -** However, Your Mileage May Vary. -** -** You could also replace the select() with a iotctl(FIONREAD) call, if you -** had one but not the other. -** -Olin&Brian -*/ - -#include -#include -#include -#include -#include "libcig.h" -#include - -#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ - -/* These two procs return #t if data ready, #f data not ready, -** and errno if error. -*/ - -s48_value char_ready_fdes(int fd) -{ - fd_set readfds; - struct timeval timeout; - int result; - - FD_ZERO(&readfds); - FD_SET(fd,&readfds); - - timeout.tv_sec=0; - timeout.tv_usec=0; - - result=select(fd+1, &readfds, NULL, NULL, &timeout); - - if(result == -1 ) - return(s48_enter_fixnum(errno)); - if(result) - return(S48_TRUE); - return(S48_FALSE); -} - -s48_value stream_char_readyp(FILE *f) -{ - int fd = fileno(f); - return f->_cnt > 0 ? S48_TRUE : char_ready_fdes(fd); -} - -void setfileno(FILE *fs, int fd) -{ - fileno(fs) = fd; -} - -int fbufcount(FILE* fs) -{ - return(fs->_cnt); -} - -/* Returns true if there is no buffered data in stream FS -** (or there is no buffering, period.) -*/ - -int ibuf_empty(FILE *fs) {return fs->_cnt <= 0;} - - -/* Returns true if the buffer in stream FS is full -** (or there is no buffering, period). -*/ - -int obuf_full(FILE *fs) {return fs->_cnt <= 0;} diff --git a/scsh/sunos/stdio_dep.h b/scsh/sunos/stdio_dep.h deleted file mode 100644 index 435ebf0..0000000 --- a/scsh/sunos/stdio_dep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Exports from stdio_dep.h. */ - -s48_value char_ready_fdes(int fd); - -s48_value stream_char_readyp(FILE *f); - -void setfileno(FILE *fs, int fd); - -int fbufcount(FILE* fs); - -int ibuf_empty(FILE *fs); - -int obuf_full(FILE *fs); diff --git a/scsh/syscalls.scm b/scsh/syscalls.scm index ac0faf3..6c9de8f 100644 --- a/scsh/syscalls.scm +++ b/scsh/syscalls.scm @@ -88,7 +88,7 @@ ((errno packet) ((errno/intr) (display "eintr")(loop))) (apply syscall/eintr args))))))) - + ;;; Process ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; we can't algin env here, because exec-path/env calls @@ -440,15 +440,8 @@ (let ((fd (if (integer? fd/port) fd/port (port->fdes fd/port)))) (%fd-seek fd 0 seek/delta))) -(define-foreign %char-ready-fdes?/errno - (char_ready_fdes (fixnum fd)) - desc) ; errno, #t, or #f - -(define (%char-ready-fdes? fd) - (let ((retval (%char-ready-fdes?/errno fd))) - (if (integer? retval) (errno-error retval %char-ready-fdes? fd) - retval))) - +(define-stubless-foreign %char-ready-fdes?/eintr (fd) "char_ready_fdes") +(define-retrying-syscall %char-ready-fdes? %char-ready-fdes?/eintr) (define-stubless-foreign %open/eintr (path flags mode) "scsh_open") (define-retrying-syscall %open %open/eintr) diff --git a/scsh/syscalls1.c b/scsh/syscalls1.c index 2d52e01..f2f7bf4 100644 --- a/scsh/syscalls1.c +++ b/scsh/syscalls1.c @@ -606,6 +606,26 @@ s48_value scsh_open(s48_value sch_path, s48_value sch_flags, s48_value sch_mode) return s48_enter_fixnum (retval); } +s48_value char_ready_fdes(s48_value sch_fd) +{ + fd_set readfds; + struct timeval timeout; + int result; + int fd = s48_extract_fixnum sch_fd; + FD_ZERO(&readfds); + FD_SET(fd, &readfds); + + timeout.tv_sec=0; + timeout.tv_usec=0; + + result=select(fd+1, &readfds, NULL, NULL, &timeout); + + if(result == -1 ) + s48_raise_os_error_1(errno, sch_fd); + if(result) + return(S48_TRUE); + return(S48_FALSE); +} /* Supplementary groups access diff --git a/scsh/ultrix/stdio_dep.c b/scsh/ultrix/stdio_dep.c deleted file mode 100644 index c0fcfd3..0000000 --- a/scsh/ultrix/stdio_dep.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (c) 1994 by Olin Shivers. -** Copyright (c) 1994-1995 by Brian D. Carlstrom. -** -** This file implements the char-ready? procedure for file descriptors -** and Scsh's fdports. It is not Posix, so it must be implemented for -** each OS to which scsh is ported. -** -** This version assumes two things: -** - the existence of select to tell if there is data -** available for the file descriptor. -** - the existence of the _cnt field in the stdio FILE struct, telling -** if there is any buffered input in the struct. -** -** Most Unixes have these things, so this file should work for them. -** However, Your Mileage May Vary. -** -** You could also replace the select() with a iotctl(FIONREAD) call, if you -** had one but not the other. -** -Olin&Brian -*/ - -#include -#include -#include -#include -#include "libcig.h" -#include - -#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ - -/* These two procs return #t if data ready, #f data not ready, -** and errno if error. -*/ - -s48_value char_ready_fdes(int fd) -{ - fd_set readfds; - struct timeval timeout; - int result; - - FD_ZERO(&readfds); - FD_SET(fd,&readfds); - - timeout.tv_sec=0; - timeout.tv_usec=0; - - result=select(fd+1, &readfds, NULL, NULL, &timeout); - - if(result == -1 ) - return(s48_enter_fixnum(errno)); - if(result) - return(S48_TRUE); - return(S48_FALSE); -} - -s48_value stream_char_readyp(FILE *f) -{ - int fd = fileno(f); - return f->_cnt > 0 ? S48_TRUE : char_ready_fdes(fd); -} - -void setfileno(FILE *fs, int fd) -{ - fileno(fs) = fd; -} - -int fbufcount(FILE* fs) -{ - return(fs->_cnt); -} - -/* Returns true if there is no buffered data in stream FS -** (or there is no buffering, period.) -*/ - -int ibuf_empty(FILE *fs) {return fs->_cnt <= 0;} - - -/* Returns true if the buffer in stream FS is full -** (or there is no buffering, period). -*/ - -int obuf_full(FILE *fs) {return fs->_cnt <= 0;} diff --git a/scsh/ultrix/stdio_dep.h b/scsh/ultrix/stdio_dep.h deleted file mode 100644 index 435ebf0..0000000 --- a/scsh/ultrix/stdio_dep.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Exports from stdio_dep.h. */ - -s48_value char_ready_fdes(int fd); - -s48_value stream_char_readyp(FILE *f); - -void setfileno(FILE *fs, int fd); - -int fbufcount(FILE* fs); - -int ibuf_empty(FILE *fs); - -int obuf_full(FILE *fs);