delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/10/15/17:58:50

Message-Id: <3.0.1.32.19971015165621.0069d4d4@yacker.xiotech.com>
Date: Wed, 15 Oct 1997 16:56:21 -0500
To: djgpp-workers AT delorie DOT com
From: Randy Maas <randym AT acm DOT org>
Subject: 971009: FileSysExt's Rev D. p5
Mime-Version: 1.0

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"

The .c file diffs
There are a lot of them.

Randy Maas
randym AT acm DOT org
--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="_close.dif"

diff -c src\libc\dos\io\_close.c _close.c 
*** \local\src\libc\dos\io\_close.c	Sat Nov 25 18:47:06 1995
--- \local\ginsu\diffs\_close.c	Wed Oct 15 16:19:24 1997
***************
*** 1,9
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
! #include <unistd.h>
! #include <errno.h>
! #include <go32.h>
! #include <dpmi.h>
! #include <io.h>
  #include <sys/fsext.h>
  
  #include <libc/dosio.h>

--- 1,8 -----
! /*
!   emulates _close
! 
!   1997, Randall Maas rewrote this calls to use __FSEXT_Call
!   */
  #include <sys/fsext.h>
  
  
***************
*** 6,12
  #include <io.h>
  #include <sys/fsext.h>
  
- #include <libc/dosio.h>
  
  int
  _close(int handle)

--- 5,10 -----
    */
  #include <sys/fsext.h>
  
  
  #include <io.h>
  
***************
*** 8,15
  
  #include <libc/dosio.h>
  
! int
! _close(int handle)
  {
    __dpmi_regs r;
  

--- 6,14 -----
  #include <sys/fsext.h>
  
  
! #include <io.h>
! 
! int _close(int handle)
  {
  
     return __FSEXT_Call(__FSEXT_close, handle, &handle);
***************
*** 11,17
  int
  _close(int handle)
  {
-   __dpmi_regs r;
  
    __FSEXT_Function *func = __FSEXT_get_function(handle);
    if (func)

--- 10,15 -----
  
  int _close(int handle)
  {
  
     return __FSEXT_Call(__FSEXT_close, handle, &handle);
  }
***************
*** 13,33
  {
    __dpmi_regs r;
  
!   __FSEXT_Function *func = __FSEXT_get_function(handle);
!   if (func)
!   {
!     int rv;
!     if (func(__FSEXT_close, &rv, &handle))
!       return rv;
!   }
! 
!   r.h.ah = 0x3e;
!   r.x.bx = handle;
!   __dpmi_int(0x21, &r);
!   if (r.x.flags & 1)
!   {
!     errno = EBADF;
!     return -1;
!   }
!   return 0;
  }

--- 11,16 -----
  int _close(int handle)
  {
  
!    return __FSEXT_Call(__FSEXT_close, handle, &handle);
  }
  
***************
*** 31,33
    }
    return 0;
  }

--- 13,16 -----
  
     return __FSEXT_Call(__FSEXT_close, handle, &handle);
  }
+ 

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="_creat.dif"

diff -c src\libc\dos\io\_creat.c _creat.c 
*** \local\src\libc\dos\io\_creat.c	Sat Aug 31 21:09:32 1996
--- \local\ginsu\diffs\_creat.c	Wed Oct 15 16:19:22 1997
***************
*** 1,4
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
  #include <fcntl.h>
  #include <errno.h>

--- 1,6 -----
! /*
!    1997, Randall Maas.  Remove MSDOS specific code. Inlined documentation.
!    Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
  #include <fcntl.h>
  #include <errno.h>
***************
*** 4,10
  #include <errno.h>
  #include <go32.h>
  #include <dpmi.h>
- #include <io.h>
  #include <libc/dosio.h>
  #include <sys/fsext.h>
  

--- 6,11 -----
  #include <errno.h>
  #include <go32.h>
  #include <dpmi.h>
  #include <libc/dosio.h>
  #include <sys/fsext.h>
  
***************
*** 8,15
  #include <libc/dosio.h>
  #include <sys/fsext.h>
  
! int
! _creat(const char* filename, int attrib)
  {
    __dpmi_regs r;
    int rv;

--- 9,18 -----
  #include <libc/dosio.h>
  #include <sys/fsext.h>
  
! 
! #include <io.h>
! 
! int _creat(const char* path, int attrib)
  {
  
    int rv;
***************
*** 11,17
  int
  _creat(const char* filename, int attrib)
  {
!   __dpmi_regs r;
    int rv;
    unsigned use_lfn = _USE_LFN;
  

--- 14,20 -----
  
  int _creat(const char* path, int attrib)
  {
! 
    int rv;
  
    if (path == 0)
***************
*** 13,19
  {
    __dpmi_regs r;
    int rv;
-   unsigned use_lfn = _USE_LFN;
  
    if (filename == 0)
    {

--- 16,21 -----
  {
  
    int rv;
  
    if (path == 0)
    {
***************
*** 15,21
    int rv;
    unsigned use_lfn = _USE_LFN;
  
!   if (filename == 0)
    {
      errno = EINVAL;
      return -1;

--- 17,23 -----
  
    int rv;
  
!   if (path == 0)
    {
      errno = EINVAL;
      return -1;
***************
*** 21,27
      return -1;
    }
  
!   if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename))
      return rv;
  
    _put_path(filename);

--- 23,29 -----
      return -1;
    }
  
!   if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &path))
      return rv;
  
    errno = EINVAL; /* The file was not created */
***************
*** 24,47
    if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &filename))
      return rv;
  
!   _put_path(filename);
!   if(use_lfn) {
!     r.x.ax = 0x716c;
!     r.x.bx = 0x0002;		/* open r/w */
!     r.x.dx = 0x0012;		/* Create, truncate if exists */
!     r.x.si = __tb_offset;
!   } else {
!     r.h.ah = 0x3c;
!     r.x.dx = __tb_offset;
!   }
!   r.x.cx = attrib;
!   r.x.ds = __tb_segment;
!   __dpmi_int(0x21, &r);
!   if(r.x.flags & 1)
!   {
!     errno = __doserr_to_errno(r.x.ax);
!     return -1;
!   }
!   __file_handle_set(r.x.ax, O_BINARY);
!   return r.x.ax;
  }

--- 26,32 -----
    if (__FSEXT_call_open_handlers(__FSEXT_creat, &rv, &path))
      return rv;
  
!   errno = EINVAL; /* The file was not created */
!   return -1;
  }
  
***************
*** 45,47
    __file_handle_set(r.x.ax, O_BINARY);
    return r.x.ax;
  }

--- 29,32 -----
    errno = EINVAL; /* The file was not created */
    return -1;
  }
+ 

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="_open.dif"

diff -c src\libc\dos\io\_open.c _open.c 
*** \local\src\libc\dos\io\_open.c	Sat Aug 31 21:09:32 1996
--- \local\ginsu\diffs\_open.c	Wed Oct 15 16:19:22 1997
***************
*** 1,3
  /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>

--- 1,4 -----
+ /* 1997, Randall Maas remove DOS specific code and inlined documentation. */
  /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
***************
*** 6,12
  #include <errno.h>
  #include <go32.h>
  #include <dpmi.h>
- #include <io.h>
  #include <libc/dosio.h>
  #include <sys/fsext.h>
  

--- 7,12 -----
  #include <errno.h>
  #include <go32.h>
  #include <dpmi.h>
  #include <libc/dosio.h>
  #include <sys/fsext.h>
  
***************
*** 10,17
  #include <libc/dosio.h>
  #include <sys/fsext.h>
  
! int
! _open(const char* filename, int oflag)
  {
    __dpmi_regs r;
    int rv;

--- 10,19 -----
  #include <libc/dosio.h>
  #include <sys/fsext.h>
  
! 
! #include <io.h>
! 
! int _open(const char* filename, int attrib)
  {
  
    int rv;
***************
*** 13,19
  int
  _open(const char* filename, int oflag)
  {
!   __dpmi_regs r;
    int rv;
    int use_lfn = _USE_LFN;
  

--- 15,21 -----
  
  int _open(const char* filename, int attrib)
  {
! 
    int rv;
  
    if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename))
***************
*** 15,21
  {
    __dpmi_regs r;
    int rv;
-   int use_lfn = _USE_LFN;
  
    if (filename == 0)
    {

--- 17,22 -----
  {
  
    int rv;
  
    if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename))
      return rv;
***************
*** 17,28
    int rv;
    int use_lfn = _USE_LFN;
  
-   if (filename == 0)
-   {
-     errno = EINVAL;
-     return -1;
-   }
- 
    if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename))
      return rv;
  

--- 18,23 -----
  
    int rv;
  
    if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename))
      return rv;
  
***************
*** 26,50
    if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename))
      return rv;
  
!   _put_path(filename);
!   if(use_lfn) {
!     r.x.ax = 0x716c;
!     r.x.bx = oflag & 0xff;
!     r.x.dx = 1;			/* Open existing file */
!     r.x.si = __tb_offset;
!   } else {
!     r.h.ah = 0x3d;
!     r.h.al = oflag;
!     r.x.dx = __tb_offset;
!   }
!   r.x.cx = 0;
!   r.x.ds = __tb_segment;
!   __dpmi_int(0x21, &r);
!   if(r.x.flags & 1)
!   {
!     errno = __doserr_to_errno(r.x.ax);
!     return -1;
!   }
!   __file_handle_set(r.x.ax, O_BINARY);
!   return r.x.ax;
  }

--- 21,26 -----
    if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename))
      return rv;
  
!   errno = EINVAL;
!   return -1;
  }

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="_read.dif"

diff -c src\libc\dos\io\_read.c _read.c 
*** \local\src\libc\dos\io\_read.c	Sat Nov 25 16:48:30 1995
--- \local\ginsu\diffs\_read.c	Wed Oct 15 16:19:24 1997
***************
*** 1,11
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
! #include <libc/stubs.h>
! #include <unistd.h>
! #include <string.h>
! #include <errno.h>
! #include <go32.h>
! #include <dpmi.h>
! #include <io.h>
  #include <sys/fsext.h>
  
  #include <libc/dosio.h>

--- 1,8 -----
! /*
!   emulates _read
! 
!   1997, Randall Maas rewrote this calls to use __FSEXT_Call
!   */
  #include <sys/fsext.h>
  
  
***************
*** 8,14
  #include <io.h>
  #include <sys/fsext.h>
  
- #include <libc/dosio.h>
  
  int
  _read(int handle, void* buffer, size_t count)

--- 5,10 -----
    */
  #include <sys/fsext.h>
  
  
  #include <io.h>
  
***************
*** 10,17
  
  #include <libc/dosio.h>
  
! int
! _read(int handle, void* buffer, size_t count)
  {
    size_t j, k;
    int ngot;

--- 6,14 -----
  #include <sys/fsext.h>
  
  
! #include <io.h>
! 
! ssize_t _read(int handle, void* buf, size_t nbytes)
  {
  
     return __FSEXT_Call(__FSEXT_read, handle, &handle);
***************
*** 13,22
  int
  _read(int handle, void* buffer, size_t count)
  {
-   size_t j, k;
-   int ngot;
-   unsigned long tbsize;
-   __dpmi_regs r;
  
    __FSEXT_Function *func = __FSEXT_get_function(handle);
    if (func)

--- 10,15 -----
  
  ssize_t _read(int handle, void* buf, size_t nbytes)
  {
  
     return __FSEXT_Call(__FSEXT_read, handle, &handle);
  }
***************
*** 18,52
    unsigned long tbsize;
    __dpmi_regs r;
  
!   __FSEXT_Function *func = __FSEXT_get_function(handle);
!   if (func)
!   {
!     int rv;
!     if (func(__FSEXT_read, &rv, &handle))
!       return rv;
!   }
! 
!   tbsize = _go32_info_block.size_of_transfer_buffer;
!   ngot = 0;
!   do {
!     j = (count <= tbsize) ? count : tbsize;
!     r.x.ax = 0x3f00;
!     r.x.bx = handle;
!     r.x.cx = j;
!     r.x.dx = __tb & 15;
!     r.x.ds = __tb / 16;
!     __dpmi_int(0x21, &r);
!     if(r.x.flags & 1)
!     {
!       errno = __doserr_to_errno(r.x.ax);
!       return -1;
!     }
!     count -= j;
!     k = r.x.ax;
!     ngot += k;
!     if (k)
!       dosmemget(__tb, k, buffer);
!     buffer = (void *)((int)buffer + k);
!   } while(count && j == k);	/* if not == on DOS then no more */
!   return ngot;
  }

--- 11,16 -----
  ssize_t _read(int handle, void* buf, size_t nbytes)
  {
  
!    return __FSEXT_Call(__FSEXT_read, handle, &handle);
  }
  
***************
*** 50,52
    } while(count && j == k);	/* if not == on DOS then no more */
    return ngot;
  }

--- 13,16 -----
  
     return __FSEXT_Call(__FSEXT_read, handle, &handle);
  }
+ 

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="_write.dif"

diff -c src\libc\dos\io\_write.c _write.c 
*** \local\src\libc\dos\io\_write.c	Thu Oct 24 22:26:26 1996
--- \local\ginsu\diffs\_write.c	Wed Oct 15 16:19:24 1997
***************
*** 1,11
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
! #include <libc/stubs.h>
! #include <unistd.h>
! #include <string.h>
! #include <errno.h>
! #include <go32.h>
! #include <dpmi.h>
! #include <io.h>
  #include <sys/fsext.h>
  
  #include <libc/dosio.h>

--- 1,8 -----
! /*
!   emulate _write
! 
!   1997, Randall Maas rewrote this calls to use __FSEXT_Call
!   */
  #include <sys/fsext.h>
  
  
***************
*** 8,14
  #include <io.h>
  #include <sys/fsext.h>
  
- #include <libc/dosio.h>
  
  int
  _write(int handle, const void* buffer, size_t count)

--- 5,10 -----
    */
  #include <sys/fsext.h>
  
  
  
  #include <io.h>
***************
*** 10,22
  
  #include <libc/dosio.h>
  
- int
- _write(int handle, const void* buffer, size_t count)
- {
-   size_t j, i;
-   int nput;
-   unsigned long tbsize;
-   __dpmi_regs r;
  
    __FSEXT_Function *func = __FSEXT_get_function(handle);
    if (func)

--- 6,11 -----
  #include <sys/fsext.h>
  
  
  
  #include <io.h>
  
***************
*** 18,30
    unsigned long tbsize;
    __dpmi_regs r;
  
!   __FSEXT_Function *func = __FSEXT_get_function(handle);
!   if (func)
!   {
!     int rv;
!     if (func(__FSEXT_write, &rv, &handle))
!       return rv;
!   }
  
    tbsize = _go32_info_block.size_of_transfer_buffer;
    nput = 0;

--- 7,13 -----
  
  
  
! #include <io.h>
  
  ssize_t _write(int handle, const void* buf, size_t nbytes)
  {
***************
*** 26,53
        return rv;
    }
  
!   tbsize = _go32_info_block.size_of_transfer_buffer;
!   nput = 0;
!   do {
!     j = (count <= tbsize) ? count : tbsize;
!     if (j)
!       dosmemput(buffer, j, __tb);
!     r.x.ax = 0x4000;
!     r.x.bx = handle;
!     r.x.cx = j;
!     r.x.dx = __tb & 15;
!     r.x.ds = __tb / 16;
!     __dpmi_int(0x21, &r);
!     if (r.x.flags & 1)
!     {
!       errno = __doserr_to_errno(r.x.ax);
!       return -1;
!     }
!     i = r.x.ax;
!     count -= i;
!     buffer = (void *)((int)buffer + i);
!     nput += i;
!   } while(count && (i == j));
  
    if (count && nput == 0)
    {

--- 9,16 -----
  
  #include <io.h>
  
! ssize_t _write(int handle, const void* buf, size_t nbytes)
! {
  
     return __FSEXT_Call(__FSEXT_write, handle, &handle);
  }
***************
*** 49,59
      nput += i;
    } while(count && (i == j));
  
!   if (count && nput == 0)
!   {
!     errno = ENOSPC;
!     return -1;
!   }
! 
!   return nput;
  }

--- 12,17 -----
  ssize_t _write(int handle, const void* buf, size_t nbytes)
  {
  
!    return __FSEXT_Call(__FSEXT_write, handle, &handle);
  }
  
***************
*** 57,59
  
    return nput;
  }

--- 14,17 -----
  
     return __FSEXT_Call(__FSEXT_write, handle, &handle);
  }
+ 

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="dup2.dif"

diff -c src\libc\posix\unistd\dup2.c dup2.c 
*** \local\src\libc\posix\unistd\dup2.c	Sun Sep 29 09:20:56 1996
--- \local\ginsu\diffs\dup2.c	Wed Oct 15 16:19:24 1997
***************
*** 1,6
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
! #include <libc/stubs.h>
! #include <unistd.h>
  #include <fcntl.h>
  #include <dpmi.h>
  #include <errno.h>

--- 1,6 -----
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
!    1997, Randall Maas: carved it to pieces.
!   */
  #include <fcntl.h>
  #include <io.h>
  
***************
*** 2,9
  #include <libc/stubs.h>
  #include <unistd.h>
  #include <fcntl.h>
- #include <dpmi.h>
- #include <errno.h>
  #include <io.h>
  #include <libc/dosio.h>
  

--- 2,7 -----
     1997, Randall Maas: carved it to pieces.
    */
  #include <fcntl.h>
  #include <io.h>
  
  
***************
*** 5,11
  #include <dpmi.h>
  #include <errno.h>
  #include <io.h>
- #include <libc/dosio.h>
  
  int
  dup2(int fd, int newfd)

--- 3,8 -----
    */
  #include <fcntl.h>
  #include <io.h>
  
  
  #include <unistd.h>
***************
*** 7,14
  #include <io.h>
  #include <libc/dosio.h>
  
! int
! dup2(int fd, int newfd)
  {
    __dpmi_regs r;
    if (fd == newfd)

--- 4,12 -----
  #include <fcntl.h>
  #include <io.h>
  
! 
! #include <unistd.h>
! int dup2(int existing_handle, int new_handle)
  {
  
    if (existing_handle == new_handle)
***************
*** 10,28
  int
  dup2(int fd, int newfd)
  {
!   __dpmi_regs r;
!   if (fd == newfd)
!     return newfd;
!   __file_handle_set(newfd, __file_handle_modes[fd] ^ (O_BINARY|O_TEXT));
!   r.h.ah = 0x46;
!   r.x.bx = fd;
!   r.x.cx = newfd;
!   __dpmi_int(0x21, &r);
!   if (r.x.flags & 1)
!   {
!     errno = __doserr_to_errno(r.x.ax);
!     return -1;
!   }
!   setmode(newfd, __file_handle_modes[fd]);
!   return newfd;
  }

--- 8,15 -----
  #include <unistd.h>
  int dup2(int existing_handle, int new_handle)
  {
! 
!   if (existing_handle == new_handle)
!     return new_handle;
!   return _dup2(existing_handle, new_handle);
  }

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="fse_open.dif"

diff -c src\libc\fsext\fse_open.c fse_open.c 
*** \local\src\libc\fsext\fse_open.c	Sat Nov 25 18:49:58 1995
--- \local\ginsu\diffs\fse_open.c	Wed Oct 15 16:19:22 1997
***************
*** 1,4
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <stdlib.h>
  #include <sys/fsext.h>
  

--- 1,5 -----
! /*  1997, some modifications by Randall Maas
!     Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <stdlib.h>
  # if defined(__DJGPP__)
  #  include <sys/fsext.h>
***************
*** 1,6
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <stdlib.h>
! #include <sys/fsext.h>
  
  typedef struct FuncList {
    struct FuncList *next;

--- 1,12 -----
  /*  1997, some modifications by Randall Maas
      Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <stdlib.h>
! # if defined(__DJGPP__)
! #  include <sys/fsext.h>
! # else
! #  include "fsext.h"
! # endif
! # include <errno.h>
  
  typedef struct FuncList
  {
***************
*** 2,8
  #include <stdlib.h>
  #include <sys/fsext.h>
  
! typedef struct FuncList {
    struct FuncList *next;
    __FSEXT_Function *function;
  } FuncList;

--- 8,15 -----
  # endif
  # include <errno.h>
  
! typedef struct FuncList
! {
    struct FuncList *next;
    __FSEXT_Function *function;
  } FuncList;
***************
*** 9,16
  
  static FuncList *func_list = 0;
  
! int
! __FSEXT_add_open_handler(__FSEXT_Function *_function)
  {
    FuncList *new_func_list = (FuncList *)malloc(sizeof(FuncList));
    if (new_func_list == 0)

--- 16,23 -----
  
  static FuncList *func_list = 0;
  
! 
! int __FSEXT_add_open_handler(__FSEXT_Function *_function)
  {
  
    FuncList *new_func_list = (FuncList *)malloc(sizeof(FuncList));
***************
*** 12,17
  int
  __FSEXT_add_open_handler(__FSEXT_Function *_function)
  {
    FuncList *new_func_list = (FuncList *)malloc(sizeof(FuncList));
    if (new_func_list == 0)
      return 1;

--- 19,25 -----
  
  int __FSEXT_add_open_handler(__FSEXT_Function *_function)
  {
+ 
    FuncList *new_func_list = (FuncList *)malloc(sizeof(FuncList));
    if (new_func_list == 0)
      return 1;
***************
*** 21,29
    return 0;
  }
  
! int
! __FSEXT_call_open_handlers(__FSEXT_Fnumber _function_number,
! 			   int *rv, va_list _args)
  {
    FuncList *f;
    for (f=func_list; f; f=f->next)

--- 29,37 -----
    return 0;
  }
  
! 
! int __FSEXT_call_open_handlers(__FSEXT_Fnumber _function_number,
!                              int *rv, va_list _args)
  {
  
    FuncList *f;
***************
*** 25,30
  __FSEXT_call_open_handlers(__FSEXT_Fnumber _function_number,
  			   int *rv, va_list _args)
  {
    FuncList *f;
    for (f=func_list; f; f=f->next)
      if (f->function(_function_number, rv, _args))

--- 33,39 -----
  int __FSEXT_call_open_handlers(__FSEXT_Fnumber _function_number,
                               int *rv, va_list _args)
  {
+ 
    FuncList *f;
    for (f=func_list; f; f=f->next)
      if (f->function(_function_number, rv, _args, NULL))
***************
*** 27,33
  {
    FuncList *f;
    for (f=func_list; f; f=f->next)
!     if (f->function(_function_number, rv, _args))
        return 1;
    return 0;
  }

--- 36,42 -----
  
    FuncList *f;
    for (f=func_list; f; f=f->next)
!     if (f->function(_function_number, rv, _args, NULL))
        return 1;
  
    /* If the open handlers did not emulate it, call our default extension */
***************
*** 29,33
    for (f=func_list; f; f=f->next)
      if (f->function(_function_number, rv, _args))
        return 1;
    return 0;
  }

--- 38,50 -----
    for (f=func_list; f; f=f->next)
      if (f->function(_function_number, rv, _args, NULL))
        return 1;
+ 
+   /* If the open handlers did not emulate it, call our default extension */
+   if (_def_fsext(_function_number, rv, _args, NULL)) return 1;
+ 
+   /* If the default extension did not do the job, try the emulator set */
+  if (__FSEXT_Emu(_function_number, rv, _args, NULL)) return 1;
+ 
+   errno = EINVAL; /* The file was not opened/created/copied*/
    return 0;
  }

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="fsext.dif"

diff -c src\libc\fsext\fsext.c fsext.c 
*** \local\src\libc\fsext\fsext.c	Sat Nov 25 17:48:12 1995
--- \local\ginsu\diffs\fsext.c	Wed Oct 15 16:19:22 1997
***************
*** 1,4
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <stdio.h>
  #include <stdlib.h>
  #include <go32.h>

--- 1,10 -----
! /*
!     1997, Randall Maas.  Inlined documentation. 
!     Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
!     
!    
! */
! 
  #include <stdio.h>
  #include <stdlib.h>
  # if defined(__DJGPP__)
***************
*** 1,8
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <stdio.h>
  #include <stdlib.h>
! #include <go32.h>
! #include <dpmi.h>
  #include <errno.h>
  #include <sys/fsext.h>
  #include <libc/bss.h>

--- 7,22 -----
  
  #include <stdio.h>
  #include <stdlib.h>
! # if defined(__DJGPP__)
! #  include <go32.h>
! #  include <dpmi.h>
! #  include <sys/fsext.h>
! #  include <libc/bss.h>
! #  include <libc/dosio.h>
! # else
! #  include "fsext.h"
! # endif
! # include <fcntl.h>
  #include <errno.h>
  # include <io.h>
  # include <string.h>
***************
*** 4,12
  #include <go32.h>
  #include <dpmi.h>
  #include <errno.h>
! #include <sys/fsext.h>
! #include <libc/bss.h>
! #include <libc/dosio.h>
  
  static int num_fds;
  static __FSEXT_Function **func_list;

--- 18,25 -----
  # endif
  # include <fcntl.h>
  #include <errno.h>
! # include <io.h>
! # include <string.h>
  
  #if defined(__DJGPP__)
  extern int _DOS_alloc_fd(void);
***************
*** 8,13
  #include <libc/bss.h>
  #include <libc/dosio.h>
  
  static int num_fds;
  static __FSEXT_Function **func_list;
  

--- 21,37 -----
  # include <io.h>
  # include <string.h>
  
+ #if defined(__DJGPP__)
+ extern int _DOS_alloc_fd(void);
+ # else
+  /* This is for non-DJGPP environments */
+ int _DOS_alloc_fd() {return open("/dev/null", O_RDWR|O_CREAT);}
+ 
+ # if defined(WIN32)
+ #  define bzero(a,b) memset(a, 0, b)
+ # endif
+ #endif
+ 
  static int num_fds;
  
  typedef struct
***************
*** 9,15
  #include <libc/dosio.h>
  
  static int num_fds;
- static __FSEXT_Function **func_list;
  
  static void
  init(void)

--- 33,38 -----
  #endif
  
  static int num_fds;
  
  typedef struct
  {
***************
*** 11,18
  static int num_fds;
  static __FSEXT_Function **func_list;
  
! static void
! init(void)
  {
    static int init_count = -1;
    if (init_count == __bss_count)

--- 34,40 -----
  
  static int num_fds;
  
! typedef struct
  {
     __FSEXT_Function* func; /* The handler for the descriptor */
     void* state_ptr; /* The handlers instance data */
***************
*** 14,19
  static void
  init(void)
  {
    static int init_count = -1;
    if (init_count == __bss_count)
      return;

--- 36,49 -----
  
  typedef struct
  {
+    __FSEXT_Function* func; /* The handler for the descriptor */
+    void* state_ptr; /* The handlers instance data */
+ } __FSEXT_func_rec;
+ 
+ static __FSEXT_func_rec *func_list;
+ 
+ static void init(void)
+ {
    static int init_count = -1;
    if (init_count == __bss_count)
      return;
***************
*** 22,29
    func_list = 0;
  }
  
! int
! __FSEXT_alloc_fd(__FSEXT_Function *_function)
  {
    int fd;
    __dpmi_regs r;

--- 52,59 -----
    func_list = 0;
  }
  
! 
! int __FSEXT_alloc_fd(__FSEXT_Function *_function, void* state)
  {
  
    int fd;
***************
*** 25,30
  int
  __FSEXT_alloc_fd(__FSEXT_Function *_function)
  {
    int fd;
    __dpmi_regs r;
  

--- 55,61 -----
  
  int __FSEXT_alloc_fd(__FSEXT_Function *_function, void* state)
  {
+ 
    int fd;
  
    init();
***************
*** 26,32
  __FSEXT_alloc_fd(__FSEXT_Function *_function)
  {
    int fd;
-   __dpmi_regs r;
  
    init();
  

--- 57,62 -----
  {
  
    int fd;
  
    init();
    fd = _DOS_alloc_fd();
***************
*** 29,34
    __dpmi_regs r;
  
    init();
  
    _put_path("nul");
    r.x.ax = 0x3d82;	/* open, no inherit, read/write */

--- 59,65 -----
    int fd;
  
    init();
+   fd = _DOS_alloc_fd();
  
    __FSEXT_set_function(fd, _function, state);
    return fd;
***************
*** 30,49
  
    init();
  
!   _put_path("nul");
!   r.x.ax = 0x3d82;	/* open, no inherit, read/write */
!   r.x.dx = __tb_offset;
!   r.x.ds = __tb_segment;
!   __dpmi_int(0x21, &r);
! 
!   if (r.x.flags & 1)
!   {
!     errno = __doserr_to_errno(r.x.ax);
!     return -1;
!   }
! 
!   fd = r.x.ax;
!   __FSEXT_set_function(fd, _function);
    return fd;
  }
  

--- 61,67 -----
    init();
    fd = _DOS_alloc_fd();
  
!   __FSEXT_set_function(fd, _function, state);
    return fd;
  }
  
***************
*** 47,54
    return fd;
  }
  
! int
! __FSEXT_set_function(int _fd, __FSEXT_Function *_function)
  {
    init();
  

--- 65,73 -----
    return fd;
  }
  
! /*
!    */
! int __FSEXT_set_function(int _fd, __FSEXT_Function *_function, void* state)
  {
    init();
  
***************
*** 59,65
    {
      int old_fds = num_fds, i;
      num_fds = (_fd+256) & ~255;
!     func_list = (__FSEXT_Function **)realloc(func_list, num_fds * sizeof(__FSEXT_Function *));
      if (func_list == 0)
        return 1;
      for (i=old_fds; i<num_fds; i++)

--- 78,85 -----
    {
      int old_fds = num_fds, i;
      num_fds = (_fd+256) & ~255;
!     func_list = (__FSEXT_func_rec*)realloc(func_list,
!                                           num_fds * sizeof(__FSEXT_func_rec));
      if (func_list == 0)
        return 1;
      for (i=old_fds; i<num_fds; i++)
***************
*** 63,69
      if (func_list == 0)
        return 1;
      for (i=old_fds; i<num_fds; i++)
!       func_list[i] = 0;
    }
    func_list[_fd] = _function;
    return 0;

--- 83,89 -----
      if (func_list == 0)
        return 1;
      for (i=old_fds; i<num_fds; i++)
!       bzero(&func_list[i], sizeof(func_list[i]));
    }
    func_list[_fd].func = _function;
    func_list[_fd].state_ptr = state;
***************
*** 65,71
      for (i=old_fds; i<num_fds; i++)
        func_list[i] = 0;
    }
!   func_list[_fd] = _function;
    return 0;
  }
  

--- 85,92 -----
      for (i=old_fds; i<num_fds; i++)
        bzero(&func_list[i], sizeof(func_list[i]));
    }
!   func_list[_fd].func = _function;
!   func_list[_fd].state_ptr = state;
    return 0;
  }
  
***************
*** 69,76
    return 0;
  }
  
! __FSEXT_Function *
! __FSEXT_get_function(int _fd)
  {
    init();
    if (_fd < 0 || _fd >= num_fds)

--- 90,101 -----
    return 0;
  }
  
! /* Note: __FSEXT_get_function has same parameters and semantics as version
!           2.01.  __FSEXT_get_handler will provide both the function pointer
!           and the state pointer.
!  */
! 
! __FSEXT_Function * __FSEXT_get_function(int _fd)
  {
  
    init();
***************
*** 72,77
  __FSEXT_Function *
  __FSEXT_get_function(int _fd)
  {
    init();
    if (_fd < 0 || _fd >= num_fds)
      return 0;

--- 97,103 -----
  
  __FSEXT_Function * __FSEXT_get_function(int _fd)
  {
+ 
    init();
    if (_fd < 0 || _fd >= num_fds) return 0;
    return func_list[_fd].func;
***************
*** 73,78
  __FSEXT_get_function(int _fd)
  {
    init();
    if (_fd < 0 || _fd >= num_fds)
      return 0;
    return func_list[_fd];

--- 99,113 -----
  {
  
    init();
+   if (_fd < 0 || _fd >= num_fds) return 0;
+   return func_list[_fd].func;
+ }
+ 
+ 
+ int __FSEXT_get_handler(int _fd, __FSEXT_Function** func, void** state)
+ {
+ 
+   init();
    if (_fd < 0 || _fd >= num_fds)
      {
         /* Clear out func just in case */
***************
*** 74,79
  {
    init();
    if (_fd < 0 || _fd >= num_fds)
!     return 0;
!   return func_list[_fd];
  }

--- 109,124 -----
  
    init();
    if (_fd < 0 || _fd >= num_fds)
!     {
!        /* Clear out func just in case */
!        if (func) *func = NULL;
!        return 0;
!     }
! 
!   /* Return the parameters */
!   if (func) *func = func_list[_fd].func;
!   if (state) *state = func_list[_fd].state_ptr;
!   return 1;
  }
  
  
***************
*** 77,79
      return 0;
    return func_list[_fd];
  }

--- 120,136 -----
    if (state) *state = func_list[_fd].state_ptr;
    return 1;
  }
+ 
+ 
+ 
+ void __FSEXT_close_all (void)
+ {
+ 
+    int I;
+ 
+    if (!func_list) return;
+    for (I = 0; I < num_fds; I++)
+     if (func_list[I].func)
+       _close(I);
+ }
+ 

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="link.dif"

diff -c src\libc\posix\unistd\link.c link.c 
*** \local\src\libc\posix\unistd\link.c	Wed May 10 02:13:46 1995
--- \local\ginsu\diffs\link.c	Wed Oct 15 16:19:26 1997
***************
*** 1,4
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
  #include <sys/stat.h>		/* For stat() */
  #include <fcntl.h>		/* For O_RDONLY, etc. */

--- 1,7 -----
! /*
!     1997, Modified by Randall Maas to be a wrapper to _link.  Inlined the
!           documentation
!     Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
  #include <sys/stat.h>		/* For stat() */
  #include <fcntl.h>		/* For O_RDONLY, etc. */
***************
*** 2,8
  #include <libc/stubs.h>
  #include <sys/stat.h>		/* For stat() */
  #include <fcntl.h>		/* For O_RDONLY, etc. */
- #include <unistd.h>		/* For read(), write(), etc. */
  #include <limits.h>		/* For PATH_MAX */
  #include <utime.h>		/* For utime() */
  #include <errno.h>		/* For errno */

--- 5,10 -----
  #include <libc/stubs.h>
  #include <sys/stat.h>		/* For stat() */
  #include <fcntl.h>		/* For O_RDONLY, etc. */
  #include <limits.h>		/* For PATH_MAX */
  #include <utime.h>		/* For utime() */
  #include <errno.h>		/* For errno */
***************
*** 7,22
  #include <utime.h>		/* For utime() */
  #include <errno.h>		/* For errno */
  
- /* Of course, DOS can't really do a link.  We just do a copy instead,
-    which is as close as DOS gets.  Alternatively, we could always fail
-    and return -1.  I think this is slightly better. */
- int
- link(const char *path1, const char *path2)
- {
-   struct stat statbuf1, statbuf2;
-   struct utimbuf times;
-   char buf[16384];
-   int fd1, fd2, nbyte, status1, status2;
  
    /* Fail if either path is null */
    if (path1 == NULL || path2 == NULL)

--- 9,14 -----
  #include <utime.h>		/* For utime() */
  #include <errno.h>		/* For errno */
  
  
  #include <unistd.h>             
  
***************
*** 18,34
    char buf[16384];
    int fd1, fd2, nbyte, status1, status2;
  
!   /* Fail if either path is null */
!   if (path1 == NULL || path2 == NULL)
!   {
!     errno = EFAULT;
!     return -1;
!   }
!   if (*path1 == '\0' || *path2 == '\0')
!   {
!     errno = ENOENT;
!     return -1;
!   }
  
    /* Fail if path1 does not exist - stat() will set errno */
    if (stat(path1, &statbuf1) < 0) return -1;

--- 10,16 -----
  #include <errno.h>		/* For errno */
  
  
! #include <unistd.h>             
  
  int link(const char *exists, const char *new)
  
***************
*** 30,37
      return -1;
    }
  
!   /* Fail if path1 does not exist - stat() will set errno */
!   if (stat(path1, &statbuf1) < 0) return -1;
  
    /* Fail if path1 is not a regular file */
    if (!S_ISREG(statbuf1.st_mode))

--- 12,18 -----
  
  #include <unistd.h>             
  
! int link(const char *exists, const char *new)
  
  {
  
***************
*** 33,44
    /* Fail if path1 does not exist - stat() will set errno */
    if (stat(path1, &statbuf1) < 0) return -1;
  
!   /* Fail if path1 is not a regular file */
!   if (!S_ISREG(statbuf1.st_mode))
!   {
!     errno = EPERM;
!     return -1;
!   }
  
    /* Fail if unable to open path1 - open() will set errno */
    fd1 = open(path1, O_RDONLY | O_BINARY);

--- 14,20 -----
  
  int link(const char *exists, const char *new)
  
! {
  
      /* _link is defined as a File System Extension call */
     return _link(exists, new);
***************
*** 40,95
      return -1;
    }
  
!   /* Fail if unable to open path1 - open() will set errno */
!   fd1 = open(path1, O_RDONLY | O_BINARY);
!   if (fd1 < 0) return -1;
! 
!   /* Fail if unable to create path2 - open() will set errno */
!   fd2 = open(path2, O_WRONLY | O_BINARY | O_CREAT | O_EXCL, 0600);
!   if (fd2 < 0)
!   {
!     (void) close(fd1);
!     return -1;
!   }
! 
!   /* Fail if path1 and path2 are on different devices */
!   if (fstat(fd2, &statbuf2) < 0) return -1;
!   if (statbuf1.st_dev != statbuf2.st_dev)
!   {
!     (void)close(fd1);
!     (void)close(fd2);
!     (void)unlink(path2);
!     errno = EXDEV;
!     return -1;
!   }
! 
!   /* Copy path1 to path2 */
!   do
!   {
!     nbyte = read(fd1, buf, sizeof buf);
!     if (nbyte <= 0) break;
!     if (write(fd2, buf, nbyte) != nbyte) nbyte = -1;
!   }
!   while (nbyte > 0);
! 
!   /* Fail if the copy failed or we can't clean up */
!   status1 = close(fd1);
!   status2 = close(fd2);
!   if (nbyte < 0 || status1 < 0 || status2 < 0)
!   {
!     (void) unlink(path2);
!     return -1;
!   }
! 
!   /* Success! */
! 
!   /* Set the mode to match the original, ignoring errors */
!   (void) chmod(path2, statbuf1.st_mode);
! 
!   /* Set the file time to match the original, ignoring errors */
!   times.actime = statbuf1.st_atime;
!   times.modtime = statbuf1.st_mtime;
!   (void) utime(path2, &times);
! 
!   return 0;
  }

--- 16,22 -----
  
  {
  
!     /* _link is defined as a File System Extension call */
!    return _link(exists, new);
  }
  
***************
*** 93,95
  
    return 0;
  }

--- 19,22 -----
      /* _link is defined as a File System Extension call */
     return _link(exists, new);
  }
+ 

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="lseek.dif"

diff -c src\libc\posix\unistd\lseek.c lseek.c 
*** \local\src\libc\posix\unistd\lseek.c	Sun Feb 26 19:43:10 1995
--- \local\ginsu\diffs\lseek.c	Wed Oct 15 16:19:26 1997
***************
*** 1,4
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
  #include <unistd.h>
  #include <errno.h>

--- 1,6 -----
! /*
!    1997, Randall Maas. Converted to a wrapper to _lseek and inlined the documentation
!    Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
  #include <errno.h>
  #include <go32.h>
***************
*** 1,6
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
- #include <unistd.h>
  #include <errno.h>
  #include <go32.h>
  #include <dpmi.h>

--- 2,7 -----
     1997, Randall Maas. Converted to a wrapper to _lseek and inlined the documentation
     Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <libc/stubs.h>
  #include <errno.h>
  #include <go32.h>
  #include <dpmi.h>
***************
*** 7,14
  
  #include <libc/dosio.h>
  
! off_t
! lseek(int handle, off_t offset, int whence)
  {
    __dpmi_regs r;
    r.h.ah = 0x42;

--- 8,17 -----
  
  #include <libc/dosio.h>
  
! 
! #include <unistd.h>
! 
! off_t lseek(int fd, off_t offset, int whence)
  {
  
     return _lseek(fd, offset, whence);
***************
*** 10,26
  off_t
  lseek(int handle, off_t offset, int whence)
  {
!   __dpmi_regs r;
!   r.h.ah = 0x42;
!   r.h.al = whence;
!   r.x.bx = handle;
!   r.x.cx = offset >> 16;
!   r.x.dx = offset & 0xffff;
!   __dpmi_int(0x21, &r);
!   if (r.x.flags & 1)
!   {
!     errno = __doserr_to_errno(r.x.ax);
!     return -1;
!   }
!   return (r.x.dx << 16) + r.x.ax;
  }

--- 13,19 -----
  
  off_t lseek(int fd, off_t offset, int whence)
  {
! 
!    return _lseek(fd, offset, whence);
  }
  
***************
*** 24,26
    }
    return (r.x.dx << 16) + r.x.ax;
  }

--- 16,19 -----
  
     return _lseek(fd, offset, whence);
  }
+ 

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="pipe.dif"

diff -c src\libc\posix\unistd\pipe.c pipe.c 
*** \local\src\libc\posix\unistd\pipe.c	Sat Apr  1 18:49:02 1995
--- \local\ginsu\diffs\pipe.c	Wed Oct 15 16:19:24 1997
***************
*** 1,6
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
! #include <unistd.h>
! #include <errno.h>
  
  int
  pipe(int _fildes[2])

--- 1,7 -----
! /*
!    pipe redirector to _pipe
!    1997, Randall Maas
!  */
  
  
  int pipe(int filedes[2])
***************
*** 2,9
  #include <unistd.h>
  #include <errno.h>
  
! int
! pipe(int _fildes[2])
  {
    errno = EACCES;
    return -1;

--- 3,10 -----
     1997, Randall Maas
   */
  
! 
! int pipe(int filedes[2])
  {
  
    _pipe(filedes);
***************
*** 5,10
  int
  pipe(int _fildes[2])
  {
!   errno = EACCES;
!   return -1;
  }

--- 6,12 -----
  
  int pipe(int filedes[2])
  {
! 
!   _pipe(filedes);
!   return 0;
  }

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="remove.dif"

diff -c src\libc\ansi\stdio\remove.c remove.c 
*** \local\src\libc\ansi\stdio\remove.c	Sat Aug 31 21:09:32 1996
--- \local\ginsu\diffs\remove.c	Wed Oct 15 16:19:26 1997
***************
*** 1,6
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
! #include <libc/stubs.h>
! #include <io.h>
  #include <stdio.h>
  #include <fcntl.h>
  #include <errno.h>

--- 1,6 -----
! /*
!    1997, Randall Maas: Made into a wrapper for _remove, and inlined documentation
!    Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <stdio.h>
  
  
***************
*** 2,15
  #include <libc/stubs.h>
  #include <io.h>
  #include <stdio.h>
! #include <fcntl.h>
! #include <errno.h>
! #include <dpmi.h>
! #include <go32.h>
! #include <libc/dosio.h>
!  
! int
! remove(const char *fn)
  {
    __dpmi_regs r;
    unsigned attr;

--- 2,10 -----
     1997, Randall Maas: Made into a wrapper for _remove, and inlined documentation
     Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <stdio.h>
! 
! 
! int remove(const char *file_name)
  {
  
     return _unlink(file_name);
***************
*** 11,28
  int
  remove(const char *fn)
  {
-   __dpmi_regs r;
-   unsigned attr;
-   int directory_p;
-   int use_lfn = _USE_LFN;
-  
-   /* Get the file attribute byte.  */
-   attr = _chmod(fn, 0);
-   directory_p = attr & 0x10;
-  
-   /* Now, make the file writable.  We must reset Vol, Dir, Sys and Hidden bits 
-      in addition to the Read-Only bit, or else 214301 will fail.  */
-   _chmod(fn, 1, attr & 0xffe0);
  
    /* Now delete it.  Note, _chmod leaves dir name in tranfer buffer. */
    if (directory_p)

--- 6,11 -----
  
  int remove(const char *file_name)
  {
  
     return _unlink(file_name);
  }
***************
*** 24,50
       in addition to the Read-Only bit, or else 214301 will fail.  */
    _chmod(fn, 1, attr & 0xffe0);
  
!   /* Now delete it.  Note, _chmod leaves dir name in tranfer buffer. */
!   if (directory_p)
!     r.h.ah = 0x3a;		/* DOS Remove Directory function */
!   else
!     r.h.ah = 0x41;		/* DOS Remove File function */
!   if(use_lfn) {
!     r.h.al = r.h.ah;
!     r.h.ah = 0x71;
!     r.x.si = 0;			/* No Wildcards */
!   }
!   r.x.dx = __tb_offset;
!   r.x.ds = __tb_segment;
!   __dpmi_int(0x21, &r);
!   if(r.x.flags & 1)
!   {
!     /* We failed.  Leave the things as we've found them.  */
!     int e = __doserr_to_errno(r.x.ax);
!  
!     _chmod(fn, 1, attr & 0xffe7);
!     errno = e;
!     return -1;
!   }
!   return 0;
  }

--- 7,11 -----
  int remove(const char *file_name)
  {
  
!    return _unlink(file_name);
  }

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="select.dif"

diff -c src\libc\compat\time\select.c select.c 
*** \local\src\libc\compat\time\select.c	Tue Jul 23 22:41:26 1996
--- \local\ginsu\diffs\select.c	Wed Oct 15 16:19:22 1997
***************
*** 1,3
  /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  /* An implementation of select()

--- 1,4 -----
+ /* 1997, Randall Maas: inlined documentation and removed MSDOS specific code */
  /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  /* An implementation of select()
***************
*** 23,30
  #include <libc/dosio.h>
  #include <sys/fsext.h>
  
! inline static int
! fp_output_ready(FILE *fp)
  {
    return !ferror(fp);
  }

--- 24,30 -----
  #include <libc/dosio.h>
  #include <sys/fsext.h>
  
! inline static int fp_input_ready (FILE *fp)
  {
    /* I think if there is something in the buffer, we should return
       ``ready'', even if some error was encountered.  Let him consume
***************
*** 26,46
  inline static int
  fp_output_ready(FILE *fp)
  {
-   return !ferror(fp);
- }
- 
- /* This is as close as we get, I think.  For a file connected to a printer
-    we could of course go ask the BIOS, but this should be enough.  */
- 
- inline static int
- fp_except_ready(FILE *fp)
- {
-   return ferror (fp);
- }
- 
- inline static int
- fp_input_ready (FILE *fp)
- {
    /* I think if there is something in the buffer, we should return
       ``ready'', even if some error was encountered.  Let him consume
       the buffered characters, *then* return ``not ready''.  */

--- 26,31 -----
  
  inline static int fp_input_ready (FILE *fp)
  {
    /* I think if there is something in the buffer, we should return
       ``ready'', even if some error was encountered.  Let him consume
       the buffered characters, *then* return ``not ready''.  */
***************
*** 44,51
    /* I think if there is something in the buffer, we should return
       ``ready'', even if some error was encountered.  Let him consume
       the buffered characters, *then* return ``not ready''.  */
!   if (fp->_cnt)
!     return 1;
  
    /* The `feof' part is only correct in a single-tasked environment.  */
    if (ferror (fp) || feof (fp))

--- 29,35 -----
    /* I think if there is something in the buffer, we should return
       ``ready'', even if some error was encountered.  Let him consume
       the buffered characters, *then* return ``not ready''.  */
!   if (fp->_cnt) return 1;
  
    /* The `feof' part is only correct in a single-tasked environment.  */
    if (ferror (fp) || feof (fp))
***************
*** 57,67
    return 1;
  }
  
! /* The Dos call 4407 always returns TRUE for disk files.  So the
!    following really is meaningful for character devices only...  */
! 
! inline static int
! fd_output_ready(int fd)
  {
  
    __dpmi_regs regs;

--- 41,47 -----
    return 1;
  }
  
! inline static int fp_output_ready(FILE *fp)
  {
    return !ferror(fp);
  }
***************
*** 63,81
  inline static int
  fd_output_ready(int fd)
  {
! 
!   __dpmi_regs regs;
! 
!   regs.x.ax = 0x4407;
!   regs.x.bx = fd;
!   __dpmi_int (0x21, &regs);
!   if (regs.x.flags & 1)
!   {
!     errno = __doserr_to_errno (regs.x.ax);
!     return -1;
!   }
!   else
!     return regs.h.al == 0xff;
  }
  
  inline static int

--- 43,49 -----
  
  inline static int fp_output_ready(FILE *fp)
  {
!   return !ferror(fp);
  }
  
  inline static int
***************
*** 79,85
  }
  
  inline static int
! fd_input_ready(int fd)
  {
  
    __dpmi_regs regs;

--- 47,53 -----
  }
  
  inline static int
! fp_except_ready(FILE *fp)
  {
    return ferror (fp);
  }
***************
*** 81,99
  inline static int
  fd_input_ready(int fd)
  {
! 
!   __dpmi_regs regs;
! 
!   regs.x.ax = 0x4406;
!   regs.x.bx = fd;
!   __dpmi_int (0x21, &regs);
!   if (regs.x.flags & 1)
!   {
!     errno = __doserr_to_errno (regs.x.ax);
!     return -1;
!   }
!   else
!     return regs.h.al == 0xff;
  }
  
  int

--- 49,55 -----
  inline static int
  fp_except_ready(FILE *fp)
  {
!   return ferror (fp);
  }
  
  
***************
*** 96,103
      return regs.h.al == 0xff;
  }
  
! int
! select(int nfds,
  	fd_set *readfds,
  	fd_set *writefds,
  	fd_set *exceptfds,

--- 52,59 -----
    return ferror (fp);
  }
  
! 
! int select(int nfds,
  	fd_set *readfds,
  	fd_set *writefds,
  	fd_set *exceptfds,
***************
*** 103,108
  	fd_set *exceptfds,
  	struct timeval *timeout)
  {
    int ready;
    fd_set oread, owrite, oexcept;
    struct timeval now, then;

--- 59,65 -----
  	fd_set *exceptfds,
  	struct timeval *timeout)
  {
+ 
    int ready;
    fd_set oread, owrite, oexcept;
    struct timeval now, then;
***************
*** 141,147
      for (i = 0; i < nfds; i++)
      {
        register int ioctl_result;
!       __FSEXT_Function *func = __FSEXT_get_function(i);
        int fsext_ready = -1;
  
        if (func)

--- 98,105 -----
      for (i = 0; i < nfds; i++)
      {
        register int ioctl_result;
!       __FSEXT_Function *func;
!       void* state;
        int fsext_ready = -1;
  
        if (__FSEXT_get_handler(i, &func, &state) && func)
***************
*** 144,151
        __FSEXT_Function *func = __FSEXT_get_function(i);
        int fsext_ready = -1;
  
!       if (func)
! 	func(__FSEXT_ready, &fsext_ready, &i);
  
        if (readfds && FD_ISSET (i, readfds))
        {

--- 102,109 -----
        void* state;
        int fsext_ready = -1;
  
!       if (__FSEXT_get_handler(i, &func, &state) && func)
!         func(__FSEXT_ready, &fsext_ready, &i, state);
  
        if (readfds && FD_ISSET (i, readfds))
        {
***************
*** 154,161
  	  if (fsext_ready & __FSEXT_ready_read)
  	    ready++, FD_SET(i, &oread);
  	}
!         else if ((ioctl_result = fd_input_ready (i)) == -1)
!           return -1;
          else if (ioctl_result)
            ready++, FD_SET (i, &oread);
        }

--- 112,119 -----
  	  if (fsext_ready & __FSEXT_ready_read)
  	    ready++, FD_SET(i, &oread);
  	}
! /*        else if ((ioctl_result = fd_input_ready (i)) == -1)
!           return -1; */
          else if (ioctl_result)
            ready++, FD_SET (i, &oread);
        }
***************
*** 166,173
  	  if (fsext_ready & __FSEXT_ready_write)
  	    ready++, FD_SET(i, &owrite);
  	}
!         else if ((ioctl_result = fd_output_ready (i)) == -1)
!           return -1;
          else if (ioctl_result)
            ready++, FD_SET (i, &owrite);
        }

--- 124,131 -----
  	  if (fsext_ready & __FSEXT_ready_write)
  	    ready++, FD_SET(i, &owrite);
  	}
! /*        else if ((ioctl_result = fd_output_ready (i)) == -1)
!           return -1;*/
          else if (ioctl_result)
            ready++, FD_SET (i, &owrite);
        }

--=====================_876970581==_
Content-Type: text/plain; charset="us-ascii"



--=====================_876970581==_--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019