Mail Archives: djgpp-workers/1997/09/23/15:56:57
--=====================_875062513==_
Content-Type: text/plain; charset="us-ascii"
These are the diffs of the changed source files (without the inline
documentation).
Randy Maas
randym AT acm DOT org
--=====================_875062513==_
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
--- _close.c1 Tue Sep 23 14:23:16 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>
#include <io.h>
***************
*** 6,12
#include <io.h>
#include <sys/fsext.h>
! #include <libc/dosio.h>
int
_close(int handle)
--- 5,11 -----
*/
#include <sys/fsext.h>
! #include <io.h>
int _close(int handle)
{
***************
*** 8,15
#include <libc/dosio.h>
! int
! _close(int handle)
{
__dpmi_regs r;
--- 7,13 -----
#include <io.h>
! int _close(int handle)
{
return __FSEXT_Call(__FSEXT_close, handle, &handle);
}
***************
*** 11,33
int
_close(int handle)
{
! __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;
}
--- 9,14 -----
int _close(int handle)
{
! return __FSEXT_Call(__FSEXT_close, handle, &handle);
}
***************
*** 31,33
}
return 0;
}
--- 11,14 -----
{
return __FSEXT_Call(__FSEXT_close, handle, &handle);
}
+
--=====================_875062513==_
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
--- _creat.c1 Tue Sep 23 14:23:44 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.
! 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,17 -----
#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;
--- 13,18 -----
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)
{
--- 14,19 -----
int _creat(const char* path, int attrib)
{
int rv;
if (path == 0)
{
***************
*** 15,21
int rv;
unsigned use_lfn = _USE_LFN;
! if (filename == 0)
{
errno = EINVAL;
return -1;
--- 15,21 -----
{
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);
--- 21,27 -----
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;
}
--- 24,30 -----
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;
}
--- 27,30 -----
errno = EINVAL; /* The file was not created */
return -1;
}
+
--=====================_875062513==_
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
--- _open.c1 Tue Sep 23 14:23:00 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 */
/* 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,18 -----
#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;
--- 14,19 -----
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)
{
--- 15,20 -----
int _open(const char* filename, int attrib)
{
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;
--- 16,21 -----
{
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;
}
--- 19,24 -----
if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename))
return rv;
! errno = EINVAL;
! return -1;
}
--=====================_875062513==_
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
--- _read.c1 Tue Sep 23 14:23: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>
#include <io.h>
***************
*** 8,14
#include <io.h>
#include <sys/fsext.h>
! #include <libc/dosio.h>
int
_read(int handle, void* buffer, size_t count)
--- 5,11 -----
*/
#include <sys/fsext.h>
! #include <io.h>
ssize_t _read(int handle, void* buf, size_t nbytes)
{
***************
*** 10,17
#include <libc/dosio.h>
! int
! _read(int handle, void* buffer, size_t count)
{
size_t j, k;
int ngot;
--- 7,13 -----
#include <io.h>
! ssize_t _read(int handle, void* buf, size_t nbytes)
{
return __FSEXT_Call(__FSEXT_read, handle, &handle);
}
***************
*** 13,52
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)
! {
! 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;
}
--- 9,14 -----
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;
}
--- 11,14 -----
{
return __FSEXT_Call(__FSEXT_read, handle, &handle);
}
+
--=====================_875062513==_
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
--- _write.c1 Tue Sep 23 14:23:34 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>
#include <io.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,11 -----
*/
#include <sys/fsext.h>
! #include <io.h>
ssize_t _write(int handle, const void* buf, size_t nbytes)
{
***************
*** 10,17
#include <libc/dosio.h>
! int
! _write(int handle, const void* buffer, size_t count)
{
size_t j, i;
int nput;
--- 7,13 -----
#include <io.h>
! ssize_t _write(int handle, const void* buf, size_t nbytes)
{
return __FSEXT_Call(__FSEXT_write, handle, &handle);
}
***************
*** 13,59
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)
! {
! int rv;
! if (func(__FSEXT_write, &rv, &handle))
! 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)
! {
! errno = ENOSPC;
! return -1;
! }
!
! return nput;
}
--- 9,14 -----
ssize_t _write(int handle, const void* buf, size_t nbytes)
{
! return __FSEXT_Call(__FSEXT_write, handle, &handle);
}
***************
*** 57,59
return nput;
}
--- 11,14 -----
{
return __FSEXT_Call(__FSEXT_write, handle, &handle);
}
+
--=====================_875062513==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="crt1.dif"
diff -c src\libc\crt0\crt1.c crt1.c
*** \local\src\libc\crt0\crt1.c Sun Sep 1 20:52:34 1996
--- crt1.c1 Wed Sep 17 16:57:38 1997
***************
*** 132,137
char __PROXY[] = " !proxy";
size_t __PROXY_LEN = sizeof(__PROXY)-1;
void
__crt1_startup(void)
{
--- 132,139 -----
char __PROXY[] = " !proxy";
size_t __PROXY_LEN = sizeof(__PROXY)-1;
+ #include <sys/fsext.h>
+ extern int _def_fsext(__FSEXT_Fnumber, int*, va_list, void*);
void
__crt1_startup(void)
{
***************
*** 144,149
__djgpp_exception_setup();
setup_environment();
__environ_changed++;
/* Make so rest of startup could use LFN. */
(void)_USE_LFN;
__crt0_setup_arguments();
--- 146,155 -----
__djgpp_exception_setup();
setup_environment();
__environ_changed++;
+
+ /* Add the default file extension as an open handler */
+ __FSEXT_add_open_handler(_def_fsext);
+
/* Make so rest of startup could use LFN. */
(void)_USE_LFN;
__crt0_setup_arguments();
--=====================_875062513==_
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
--- fse_open.c1 Tue Sep 23 14:20:46 1997
***************
*** 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,10 -----
/* 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
typedef struct FuncList
{
***************
*** 2,8
#include <stdlib.h>
#include <sys/fsext.h>
! typedef struct FuncList {
struct FuncList *next;
__FSEXT_Function *function;
} FuncList;
--- 6,13 -----
# include "fsext.h"
# endif
! 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)
--- 14,20 -----
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)
***************
*** 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)
--- 25,32 -----
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)
***************
*** 27,33
{
FuncList *f;
for (f=func_list; f; f=f->next)
! if (f->function(_function_number, rv, _args))
return 1;
return 0;
}
--- 30,36 -----
{
FuncList *f;
for (f=func_list; f; f=f->next)
! if (f->function(_function_number, rv, _args, NULL))
return 1;
return 0;
}
--=====================_875062513==_
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
--- fsext.c1 Tue Sep 23 14:22:22 1997
***************
*** 1,4
! /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <stdio.h>
#include <stdlib.h>
#include <go32.h>
--- 1,7 -----
! /*
! 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>
--- 4,19 -----
#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;
--- 15,22 -----
# 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;
--- 18,34 -----
# 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)
--- 30,35 -----
#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)
--- 31,37 -----
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;
--- 33,46 -----
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;
--- 49,55 -----
func_list = 0;
}
! int __FSEXT_alloc_fd(__FSEXT_Function *_function, void* state)
{
int fd;
***************
*** 26,32
__FSEXT_alloc_fd(__FSEXT_Function *_function)
{
int fd;
- __dpmi_regs r;
init();
--- 52,57 -----
int __FSEXT_alloc_fd(__FSEXT_Function *_function, void* state)
{
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 */
--- 54,60 -----
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;
}
--- 56,62 -----
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();
--- 60,66 -----
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++)
--- 71,78 -----
{
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;
--- 76,82 -----
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;
}
--- 78,85 -----
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)
--- 83,93 -----
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();
if (_fd < 0 || _fd >= num_fds) return 0;
***************
*** 73,78
__FSEXT_get_function(int _fd)
{
init();
if (_fd < 0 || _fd >= num_fds)
return 0;
return func_list[_fd];
--- 90,102 -----
__FSEXT_Function * __FSEXT_get_function(int _fd)
{
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];
}
--- 98,113 -----
{
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];
}
--- 109,123 -----
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);
+ }
+
--=====================_875062513==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="fsext-h.dif"
diff -c2 src\libc\fsext\fsext.h fsext.h
*** \local\ginsu\lib\fsext.old Mon Aug 12 23:18:10 1996
--- fsext.h Wed Sep 17 16:45:44 1997
***************
*** 23,26
__FSEXT_ready,
__FSEXT_close,
__FSEXT_fcntl,
__FSEXT_ioctl,
--- 23,28 -----
__FSEXT_ready,
__FSEXT_close,
+ __FSEXT_pread,
+ __FSEXT_pwrite,
__FSEXT_fcntl,
__FSEXT_ioctl,
***************
*** 25,28
__FSEXT_fcntl,
__FSEXT_ioctl,
} __FSEXT_Fnumber;
--- 27,34 -----
__FSEXT_fcntl,
__FSEXT_ioctl,
+ __FSEXT_lseek,
+ __FSEXT_link,
+ __FSEXT_unlink,
+ __FSEXT_copy
} __FSEXT_Fnumber;
***************
*** 36,40
caller's functionality. */
typedef int (__FSEXT_Function)(__FSEXT_Fnumber _function_number,
! int *_rv, va_list _args);
int __FSEXT_alloc_fd(__FSEXT_Function *_function);
--- 42,46 -----
caller's functionality. */
typedef int (__FSEXT_Function)(__FSEXT_Fnumber _function_number,
! int *_rv, va_list _args, void* state);
int __FSEXT_alloc_fd(__FSEXT_Function *_function, void* state);
***************
*** 38,43
int *_rv, va_list _args);
! int __FSEXT_alloc_fd(__FSEXT_Function *_function);
! int __FSEXT_set_function(int _fd, __FSEXT_Function *_function);
__FSEXT_Function *__FSEXT_get_function(int _fd);
--- 44,50 -----
int *_rv, va_list _args, void* state);
! int __FSEXT_alloc_fd(__FSEXT_Function *_function, void* state);
! int __FSEXT_set_function(int _fd, __FSEXT_Function *_function,
! void* state);
__FSEXT_Function *__FSEXT_get_function(int _fd);
int __FSEXT_get_handler(int _fd, __FSEXT_Function** func,
***************
*** 41,45
int __FSEXT_set_function(int _fd, __FSEXT_Function *_function);
__FSEXT_Function *__FSEXT_get_function(int _fd);
!
int __FSEXT_add_open_handler(__FSEXT_Function *_function);
int __FSEXT_call_open_handlers(__FSEXT_Fnumber _function_number,
--- 48,55 -----
void* state);
__FSEXT_Function *__FSEXT_get_function(int _fd);
! int __FSEXT_get_handler(int _fd, __FSEXT_Function** func,
! void** state);
! int __FSEXT_Call(__FSEXT_Fnumber, int, va_list);
! int __FSEXT_Emu (__FSEXT_Fnumber, int*, va_list, void*);
int __FSEXT_add_open_handler(__FSEXT_Function *_function);
int __FSEXT_call_open_handlers(__FSEXT_Fnumber _function_number,
--=====================_875062513==_
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
--- link.c1 Tue Sep 23 14:27:08 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,6 -----
! /*
! 1997, Modified by Randall Maas to be a wrapper to _link.
! 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 */
--- 4,9 -----
#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)
--- 8,14 -----
#include <utime.h> /* For utime() */
#include <errno.h> /* For errno */
! #include <unistd.h> /*// For read(), write(), etc. */
int link(const char *exists, const char *new)
{
***************
*** 18,95
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;
!
! /* 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);
! 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, ×);
!
! return 0;
}
--- 10,18 -----
#include <unistd.h> /*// For read(), write(), etc. */
! int link(const char *exists, const char *new)
! {
! /* _link is defined as a File System Extension call */
! return _link(exists, new);
}
***************
*** 93,95
return 0;
}
--- 15,18 -----
/* _link is defined as a File System Extension call */
return _link(exists, new);
}
+
--=====================_875062513==_
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
--- lseek.c1 Tue Sep 23 14:27:08 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
! 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
Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <libc/stubs.h>
#include <errno.h>
#include <go32.h>
#include <dpmi.h>
***************
*** 6,11
#include <dpmi.h>
#include <libc/dosio.h>
off_t
lseek(int handle, off_t offset, int whence)
--- 7,13 -----
#include <dpmi.h>
#include <libc/dosio.h>
+ #include <unistd.h>
off_t lseek(int fd, off_t offset, int whence)
{
***************
*** 7,14
#include <libc/dosio.h>
! off_t
! lseek(int handle, off_t offset, int whence)
{
__dpmi_regs r;
r.h.ah = 0x42;
--- 9,15 -----
#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;
}
--- 11,16 -----
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;
}
--- 13,16 -----
{
return _lseek(fd, offset, whence);
}
+
--=====================_875062513==_
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
--- remove.c1 Tue Sep 23 14:27:08 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
! Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <stdio.h>
int remove(const char *file_name)
***************
*** 2,28
#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;
- 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)
--- 2,7 -----
1997, Randall Maas: Made into a wrapper for _remove
Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <stdio.h>
int remove(const char *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;
}
--- 3,9 -----
Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <stdio.h>
! int remove(const char *file_name)
! {
! return _remove(file_name);
}
--=====================_875062513==_
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
--- select.c1 Tue Sep 23 14:25:46 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: 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, ®s);
! 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, ®s);
! 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);
}
int select(int nfds,
***************
*** 96,103
return regs.h.al == 0xff;
}
! int
! select(int nfds,
fd_set *readfds,
fd_set *writefds,
fd_set *exceptfds,
--- 52,58 -----
return ferror (fp);
}
! int select(int nfds,
fd_set *readfds,
fd_set *writefds,
fd_set *exceptfds,
***************
*** 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)
--- 96,103 -----
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))
{
--- 100,107 -----
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);
}
--- 110,117 -----
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);
}
--- 122,129 -----
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);
}
--=====================_875062513==_
Content-Type: text/plain; charset="us-ascii"
--=====================_875062513==_--
- Raw text -