delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/12/29/06:58:48

Message-Id: <5.0.2.1.0.20001229065701.00a82590@pop5.banet.net>
X-Sender: usbanet DOT farley3 AT pop5 DOT banet DOT net
X-Mailer: QUALCOMM Windows Eudora Version 5.0.2
Date: Fri, 29 Dec 2000 06:59:56 -0500
To: djgpp-workers AT delorie DOT com
From: "Peter J. Farley III" <pjfarley AT banet DOT net>
Subject: fcntl locking changes #3: new function dostrerr
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

--=====================_12542069==_
Content-Type: text/plain; charset="us-ascii"; format=flowed

Here is the new function dostrerr used for reporting errors in all of 
the new fcntl and flock test programs.  This patch is *required* to run 
any of the new fcntl or flock tests.

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

diff -ruN djgpp-cvs/include/dos.h djgpp/include/dos.h
--- djgpp-cvs/include/dos.h	Thu Jun 22 14:20:36 2000
+++ djgpp/include/dos.h	Mon Dec 11 21:56:46 2000
@@ -1,3 +1,4 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
@@ -235,6 +236,18 @@
 };
 #define DOSERROR _DOSERROR
 
+struct _DOSERROR_STR {
+  char *exterror_str;
+  #ifdef __cplusplus
+  char *errclass_str;
+  #else
+  char *class_str;
+  #endif
+  char *action_str;
+  char *locus_str;
+};
+#define DOSERROR_STR _DOSERROR_STR
+
 unsigned int   _dos_creat(const char *_filename, unsigned int _attr, int *_handle);
 unsigned int   _dos_creatnew(const char *_filename, unsigned int _attr, int *_handle);
 unsigned int   _dos_open(const char *_filename, unsigned int _mode, int *_handle);
@@ -262,6 +275,8 @@
 
 int            _dosexterr(struct _DOSERROR *_p_error);
 #define dosexterr(_ep) _dosexterr(_ep)
+int            _dostrerr(struct _DOSERROR *_p_error, struct _DOSERROR_STR *_p_str);
+#define dostrerr(_ep,_sp) _dostrerr(_ep,_sp)
 
 #define int386(_i, _ir, _or)         int86(_i, _ir, _or)
 #define int386x(_i, _ir, _or, _sr)   int86x(_i, _ir, _or, _sr)
diff -ruN djgpp-cvs/src/libc/dos/compat/d_exterr.txh djgpp/src/libc/dos/compat/d_exterr.txh
--- djgpp-cvs/src/libc/dos/compat/d_exterr.txh	Sun Sep 27 11:21:20 1998
+++ djgpp/src/libc/dos/compat/d_exterr.txh	Sat Dec 16 01:21:14 2000
@@ -13,7 +13,7 @@
 @var{p_error} structure.
 
 @example
-struct _DOSERROR @{
+struct DOSERROR @{
   int  exterror;
   char class;
   char action;
@@ -21,134 +21,271 @@
 @};
 @end example
 
-Values for extended error code (@var{exterror} field):
+Values for DOS extended error code (@var{exterr} field):
 @example
-00h (0)   no error
-01h (1)   function number invalid
-02h (2)   file not found
-03h (3)   path not found
-04h (4)   too many open files (no handles available)
-05h (5)   access denied
-06h (6)   invalid handle
-07h (7)   memory control block destroyed
-08h (8)   insufficient memory
-09h (9)   memory block address invalid
-0Ah (10)  environment invalid (usually >32K in length)
-0Bh (11)  format invalid
-0Ch (12)  access code invalid
-0Dh (13)  data invalid
-0Eh (14)  reserved
-0Fh (15)  invalid drive
-10h (16)  attempted to remove current directory
-11h (17)  not same device
-12h (18)  no more files
-13h (19)  disk write-protected
-14h (20)  unknown unit
-15h (21)  drive not ready
-16h (22)  unknown command
-17h (23)  data error (CRC)
-18h (24)  bad request structure length
-19h (25)  seek error
-1Ah (26)  unknown media type (non-DOS disk)
-1Bh (27)  sector not found
-1Ch (28)  printer out of paper
-1Dh (29)  write fault
-1Eh (30)  read fault
-1Fh (31)  general failure
-20h (32)  sharing violation
-21h (33)  lock violation
-22h (34)  disk change invalid (ES:DI -> media ID structure)(see below)
-23h (35)  FCB unavailable
-24h (36)  sharing buffer overflow
-25h (37)  (DOS 4+) code page mismatch
-26h (38)  (DOS 4+) cannot complete file operation (out of input)
-27h (39)  (DOS 4+) insufficient disk space
-28h-31h   reserved
-32h (50)  network request not supported
-33h (51)  remote computer not listening
-34h (52)  duplicate name on network
-35h (53)  network name not found
-36h (54)  network busy
-37h (55)  network device no longer exists
-38h (56)  network BIOS command limit exceeded
-39h (57)  network adapter hardware error
-3Ah (58)  incorrect response from network
-3Bh (59)  unexpected network error
-3Ch (60)  incompatible remote adapter
-3Dh (61)  print queue full
-3Eh (62)  queue not full
-3Fh (63)  not enough space to print file
-40h (64)  network name was deleted
-41h (65)  network: Access denied
-42h (66)  network device type incorrect
-43h (67)  network name not found
-44h (68)  network name limit exceeded
-45h (69)  network BIOS session limit exceeded
-46h (70)  temporarily paused
-47h (71)  network request not accepted
-48h (72)  network print/disk redirection paused
-49h (73)  network software not installed
-          (LANtastic) invalid network version
-4Ah (74)  unexpected adapter close
-          (LANtastic) account expired
-4Bh (75)  (LANtastic) password expired
-4Ch (76)  (LANtastic) login attempt invalid at this time
-4Dh (77)  (LANtastic v3+) disk limit exceeded on network node
-4Eh (78)  (LANtastic v3+) not logged in to network node
-4Fh (79)  reserved
-50h (80)  file exists
-51h (81)  reserved
-52h (82)  cannot make directory
-53h (83)  fail on INT 24h
-54h (84)  (DOS 3.3+) too many redirections
-55h (85)  (DOS 3.3+) duplicate redirection
-56h (86)  (DOS 3.3+) invalid password
-57h (87)  (DOS 3.3+) invalid parameter
-58h (88)  (DOS 3.3+) network write fault
-59h (89)  (DOS 4+) function not supported on network
-5Ah (90)  (DOS 4+) required system component not installed
-64h (100) (MSCDEX) unknown error
-65h (101) (MSCDEX) not ready
-66h (102) (MSCDEX) EMS memory no longer valid
-67h (103) (MSCDEX) not High Sierra or ISO-9660 format
-68h (104) (MSCDEX) door open
+---DOS 2.0+ ---
+ 00h (0)   no error
+ 01h (1)   function number invalid
+ 02h (2)   file not found
+ 03h (3)   path not found
+ 04h (4)   too many open files (no handles available)
+ 05h (5)   access denied
+ 06h (6)   invalid handle
+ 07h (7)   memory control block destroyed
+ 08h (8)   insufficient memory
+ 09h (9)   memory block address invalid
+ 0Ah (10)  environment invalid (usually >32K in length)
+ 0Bh (11)  format invalid
+ 0Ch (12)  access code invalid
+ 0Dh (13)  data invalid
+ 0Eh (14)  reserved
+ 0Eh (14)  (PTS-DOS 6.51+, S/DOS 1.0+) fixup overflow
+ 0Fh (15)  invalid drive
+ 10h (16)  attempted to remove current directory
+ 11h (17)  not same device
+ 12h (18)  no more files
+---DOS 3.0+ (INT 24 errors)---
+ 13h (19)  disk write-protected
+ 14h (20)  unknown unit
+ 15h (21)  drive not ready
+ 16h (22)  unknown command
+ 17h (23)  data error (CRC)
+ 18h (24)  bad request structure length
+ 19h (25)  seek error
+ 1Ah (26)  unknown media type (non-DOS disk)
+ 1Bh (27)  sector not found
+ 1Ch (28)  printer out of paper
+ 1Dh (29)  write fault
+ 1Eh (30)  read fault
+ 1Fh (31)  general failure
+ 20h (32)  sharing violation
+ 21h (33)  lock violation
+ 22h (34)  disk change invalid (ES:DI -> media ID structure)(see #01681)
+ 23h (35)  FCB unavailable
+ 23h (35)  (PTS-DOS 6.51+, S/DOS 1.0+) bad FAT
+ 24h (36)  sharing buffer overflow
+ 25h (37)  (DOS 4.0+) code page mismatch
+ 26h (38)  (DOS 4.0+) cannot complete file operation (EOF / out of input)
+ 27h (39)  (DOS 4.0+) insufficient disk space
+ 28h-31h   reserved
+---OEM network errors (INT 24)---
+ 32h (50)  network request not supported
+ 33h (51)  remote computer not listening
+ 34h (52)  duplicate name on network
+ 35h (53)  network name not found
+ 36h (54)  network busy
+ 37h (55)  network device no longer exists
+ 38h (56)  network BIOS command limit exceeded
+ 39h (57)  network adapter hardware error
+ 3Ah (58)  incorrect response from network
+ 3Bh (59)  unexpected network error
+ 3Ch (60)  incompatible remote adapter
+ 3Dh (61)  print queue full
+ 3Eh (62)  queue not full
+ 3Fh (63)  not enough space to print file
+ 40h (64)  network name was deleted
+ 41h (65)  network: Access denied
+	  (DOS 3.0+ [maybe 3.3+???]) codepage switching not possible
+	    (see also INT 21/AX=6602h,INT 2F/AX=AD42h)
+ 42h (66)  network device type incorrect
+ 43h (67)  network name not found
+ 44h (68)  network name limit exceeded
+ 45h (69)  network BIOS session limit exceeded
+ 46h (70)  temporarily paused
+ 47h (71)  network request not accepted
+ 48h (72)  network print/disk redirection paused
+ 49h (73)  network software not installed
+	    (LANtastic) invalid network version
+ 4Ah (74)  unexpected adapter close
+	    (LANtastic) account expired
+ 4Bh (75)  (LANtastic) password expired
+ 4Ch (76)  (LANtastic) login attempt invalid at this time
+ 4Dh (77)  (LANtastic v3+) disk limit exceeded on network node
+ 4Eh (78)  (LANtastic v3+) not logged in to network node
+ 4Fh (79)  reserved
+---end of errors reportable via INT 24---
+ 50h (80)  file exists
+ 51h (81)  (undoc) duplicated FCB
+ 52h (82)  cannot make directory
+ 53h (83)  fail on INT 24h
+---network-related errors (non-INT 24)---
+ 54h (84)  (DOS 3.3+) too many redirections / out of structures
+ 55h (85)  (DOS 3.3+) duplicate redirection / already assigned
+ 56h (86)  (DOS 3.3+) invalid password
+ 57h (87)  (DOS 3.3+) invalid parameter
+ 58h (88)  (DOS 3.3+) network write fault
+ 59h (89)  (DOS 4.0+) function not supported on network / no process slots
+	      available
+ 5Ah (90)  (DOS 4.0+) required system component not installed / not frozen
+ 5Bh (91)  (DOS 4.0+,NetWare4) timer server table overflowed
+ 5Ch (92)  (DOS 4.0+,NetWare4) duplicate in timer service table
+ 5Dh (93)  (DOS 4.0+,NetWare4) no items to work on
+ 5Fh (95)  (DOS 4.0+,NetWare4) interrupted / invalid system call
+ 64h (100) (MSCDEX) unknown error
+ 64h (100) (DOS 4.0+,NetWare4) open semaphore limit exceeded
+ 65h (101) (MSCDEX) not ready
+ 65h (101) (DOS 4.0+,NetWare4) exclusive semaphore is already owned
+ 66h (102) (MSCDEX) EMS memory no longer valid
+ 66h (102) (DOS 4.0+,NetWare4) semaphore was set when close attempted
+ 67h (103) (MSCDEX) not High Sierra or ISO-9660 format
+ 67h (103) (DOS 4.0+,NetWare4) too many exclusive semaphore requests
+ 68h (104) (MSCDEX) door open
+ 68h (104) (DOS 4.0+,NetWare4) operation invalid from interrupt handler
+ 69h (105) (DOS 4.0+,NetWare4) semaphore owner died
+ 6Ah (106) (DOS 4.0+,NetWare4) semaphore limit exceeded
+ 6Bh (107) (DOS 4.0+,NetWare4) insert drive B: disk into A: / disk changed
+ 6Ch (108) (DOS 4.0+,NetWare4) drive locked by another process
+ 6Dh (109) (DOS 4.0+,NetWare4) broken pipe
+ 6Eh (110) (DOS 5.0+,NetWare4) pipe open/create failed
+ 6Fh (111) (DOS 5.0+,NetWare4) pipe buffer overflowed
+ 70h (112) (DOS 5.0+,NetWare4) disk full
+ 71h (113) (DOS 5.0+,NetWare4) no more search handles
+ 72h (114) (DOS 5.0+,NetWare4) invalid target handle for dup2
+ 73h (115) (DOS 5.0+,NetWare4) bad user virtual address / protection violation
+ 74h (116) (DOS 5.0+) VIOKBD request
+ 74h (116) (NetWare4) error on console I/O
+ 75h (117) (DOS 5.0+,NetWare4) unknown category code for IOCTL
+ 76h (118) (DOS 5.0+,NetWare4) invalid value for verify flag
+ 77h (119) (DOS 5.0+,NetWare4) level four driver not found by DOS IOCTL
+ 78h (120) (DOS 5.0+,NetWare4) invalid / unimplemented function number
+ 79h (121) (DOS 5.0+,NetWare4) semaphore timeout
+ 7Ah (122) (DOS 5.0+,NetWare4) buffer too small to hold return data
+ 7Bh (123) (DOS 5.0+,NetWare4) invalid character or bad file-system name
+ 7Ch (124) (DOS 5.0+,NetWare4) unimplemented information level
+ 7Dh (125) (DOS 5.0+,NetWare4) no volume label found
+ 7Eh (126) (DOS 5.0+,NetWare4) module handle not found
+ 7Fh (127) (DOS 5.0+,NetWare4) procedure address not found
+ 80h (128) (DOS 5.0+,NetWare4) CWait found no children
+ 81h (129) (DOS 5.0+,NetWare4) CWait children still running
+ 82h (130) (DOS 5.0+,NetWare4) invalid operation for direct disk-access handle
+ 83h (131) (DOS 5.0+,NetWare4) attempted seek to negative offset
+ 84h (132) (DOS 5.0+,NetWare4) attempted to seek on device or pipe
+---JOIN/SUBST errors---
+ 85h (133) (DOS 5.0+,NetWare4) drive already has JOINed drives
+ 86h (134) (DOS 5.0+,NetWare4) drive is already JOINed
+ 87h (135) (DOS 5.0+,NetWare4) drive is already SUBSTed
+ 88h (136) (DOS 5.0+,NetWare4) can not delete drive which is not JOINed
+ 89h (137) (DOS 5.0+,NetWare4) can not delete drive which is not SUBSTed
+ 8Ah (138) (DOS 5.0+,NetWare4) can not JOIN to a JOINed drive
+ 8Bh (139) (DOS 5.0+,NetWare4) can not SUBST to a SUBSTed drive
+ 8Ch (140) (DOS 5.0+,NetWare4) can not JOIN to a SUBSTed drive
+ 8Dh (141) (DOS 5.0+,NetWare4) can not SUBST to a JOINed drive
+ 8Eh (142) (DOS 5.0+,NetWare4) drive is busy
+ 8Fh (143) (DOS 5.0+,NetWare4) can not JOIN/SUBST to same drive
+ 90h (144) (DOS 5.0+,NetWare4) directory must not be root directory
+ 91h (145) (DOS 5.0+,NetWare4) can only JOIN to empty directory
+ 92h (146) (DOS 5.0+,NetWare4) path is already in use for SUBST
+ 93h (147) (DOS 5.0+,NetWare4) path is already in use for JOIN
+ 94h (148) (DOS 5.0+,NetWare4) path is in use by another process
+ 95h (149) (DOS 5.0+,NetWare4) directory previously SUBSTituted
+ 96h (150) (DOS 5.0+,NetWare4) system trace error
+ 97h (151) (DOS 5.0+,NetWare4) invalid event count for DosMuxSemWait
+ 98h (152) (DOS 5.0+,NetWare4) too many waiting on mutex
+ 99h (153) (DOS 5.0+,NetWare4) invalid list format
+ 9Ah (154) (DOS 5.0+,NetWare4) volume label too large
+ 9Bh (155) (DOS 5.0+,NetWare4) unable to create another TCB
+ 9Ch (156) (DOS 5.0+,NetWare4) signal refused
+ 9Dh (157) (DOS 5.0+,NetWare4) segment discarded
+ 9Eh (158) (DOS 5.0+,NetWare4) segment not locked
+ 9Fh (159) (DOS 5.0+,NetWare4) invalid thread-ID address
+-----
+ A0h (160) (DOS 5.0+) bad arguments
+ A0h (160) (NetWare4) bad environment pointer
+ A1h (161) (DOS 5.0+,NetWare4) invalid pathname passed to EXEC
+ A2h (162) (DOS 5.0+,NetWare4) signal already pending
+ A3h (163) (DOS 5.0+) uncertain media
+ A3h (163) (NetWare4) ERROR_124 mapping
+ A4h (164) (DOS 5.0+) maximum number of threads reached
+ A4h (164) (NetWare4) no more process slots
+ A5h (165) (NetWare4) ERROR_124 mapping
+ B0h (176) (MS-DOS 7.0) volume is not locked
+ B1h (177) (MS-DOS 7.0) volume is locked in drive
+ B2h (178) (MS-DOS 7.0) volume is not removable
+ B4h (180) (MS-DOS 7.0) lock count has been exceeded
+ B4h (180) (NetWare4) invalid segment number
+ B5h (181) (MS-DOS 7.0) a valid eject request failed
+ B5h (181) (DOS 5.0-6.0,NetWare4) invalid call gate
+ B6h (182) (DOS 5.0+,NetWare4) invalid ordinal
+ B7h (183) (DOS 5.0+,NetWare4) shared segment already exists
+ B8h (184) (DOS 5.0+,NetWare4) no child process to wait for
+ B9h (185) (DOS 5.0+,NetWare4) NoWait specified and child still running
+ BAh (186) (DOS 5.0+,NetWare4) invalid flag number
+ BBh (187) (DOS 5.0+,NetWare4) semaphore does not exist
+ BCh (188) (DOS 5.0+,NetWare4) invalid starting code segment
+ BDh (189) (DOS 5.0+,NetWare4) invalid stack segment
+ BEh (190) (DOS 5.0+,NetWare4) invalid module type (DLL can not be used as
+	      application)
+ BFh (191) (DOS 5.0+,NetWare4) invalid EXE signature
+ C0h (192) (DOS 5.0+,NetWare4) EXE marked invalid
+ C1h (193) (DOS 5.0+,NetWare4) bad EXE format (e.g. DOS-mode program)
+ C2h (194) (DOS 5.0+,NetWare4) iterated data exceeds 64K
+ C3h (195) (DOS 5.0+,NetWare4) invalid minimum allocation size
+ C4h (196) (DOS 5.0+,NetWare4) dynamic link from invalid Ring
+ C5h (197) (DOS 5.0+,NetWare4) IOPL not enabled
+ C6h (198) (DOS 5.0+,NetWare4) invalid segment descriptor privilege level
+ C7h (199) (DOS 5.0+,NetWare4) automatic data segment exceeds 64K
+ C8h (200) (DOS 5.0+,NetWare4) Ring2 segment must be moveable
+ C9h (201) (DOS 5.0+,NetWare4) relocation chain exceeds segment limit
+ CAh (202) (DOS 5.0+,NetWare4) infinite loop in relocation chain
+ CBh (203) (NetWare4) environment variable not found
+ CCh (204) (NetWare4) not current country
+ CDh (205) (NetWare4) no signal sent
+ CEh (206) (NetWare4) file name not 8.3
+ CFh (207) (NetWare4) Ring2 stack in use
+ D0h (208) (NetWare4) meta expansion is too long
+ D1h (209) (NetWare4) invalid signal number
+ D2h (210) (NetWare4) inactive thread
+ D3h (211) (NetWare4) file system information not available
+ D4h (212) (NetWare4) locked error
+ D5h (213) (NetWare4) attempted to execute non-family API call in DOS mode
+ D6h (214) (NetWare4) too many modules
+ D7h (215) (NetWare4) nesting not allowed
+ E6h (230) (NetWare4) non-existent pipe, or bad operation
+ E7h (231) (NetWare4) pipe is busy
+ E8h (232) (NetWare4) no data available for nonblocking read
+ E9h (233) (NetWare4) pipe disconnected by server
+ EAh (234) (NetWare4) more data available
+ FFh (255) (NetWare4) invalid drive
 @end example
 
 Values for error class (@var{class} field):
 @example
-01h  out of resource (storage space or I/O channels)
-02h  temporary situation (file or record lock)
-03h  authorization (denied access)
-04h  internal (system software bug)
-05h  hardware failure
-06h  system failure (configuration file missing or incorrect)
-07h  application program error
-08h  not found
-09h  bad format
-0Ah  locked
-0Bh  media error
-0Ch  already exists
-0Dh  unknown
+ 01h (1)  out of resource (storage space or I/O channels)
+ 02h (2)  temporary situation (file or record lock)
+ 03h (3)  authorization / permission problem (denied access)
+ 04h (4)  internal system error (system software bug)
+ 05h (5)  hardware failure
+ 06h (6)  system failure (configuration file missing or incorrect)
+ 07h (7)  application program error
+ 08h (8)  not found
+ 09h (9)  bad format
+ 0Ah (10) locked
+ 0Bh (11) media error
+ 0Ch (12) already exists / collision with existing item
+ 0Dh (13) unknown / other
+ 0Eh (14) (undoc) cannot
+ 0Fh (15) (undoc) time
 @end example
 
 Values for suggested action (@var{action} field):
 @example
-01h  retry
-02h  delayed retry
-03h  prompt user to reenter input
-04h  abort after cleanup
-05h  immediate abort
-06h  ignore
-07h  retry after user intervention
+ 01h	retry
+ 02h	delayed retry (after pause)
+ 03h	prompt user to reenter input
+ 04h	abort after cleanup
+ 05h	immediate abort ("panic")
+ 06h	ignore
+ 07h	retry after user intervention
 @end example
 
 Values for error locus (@var{locus} field):
 @example
-01h  unknown or not appropriate
-02h  block device (disk error)
-03h  network related
-04h  serial device (timeout)
-05h  memory related
+ 01h	unknown or not appropriate
+ 02h	block device (disk error)
+ 03h	network related
+ 04h	serial device (timeout)
+ 04h	(PTS-DOS 6.51+ & S/DOS 1.0+) character device
+ 05h	memory related
 @end example
 
 @subheading Return Value
@@ -165,21 +302,111 @@
 #include <stdio.h>
 #include <dos.h>
 
-void main(void)
+int main(void)
 @{
   FILE *fp;
-  struct _DOSERROR de;
+  struct DOSERROR de;
 
   fp = fopen("EXAMPLE.DAT","r");
   if ( fp == NULL )
   @{
     puts("Unable to open file for reading.");
-    _dosexterr(&de);
+    dosexterr(&de);
     printf("Extended DOS error information:\n");
     printf("Extended error: %i\n",de.exterror);
     printf("Class:          %x\n",de.class);
     printf("Action:         %x\n",de.action);
     printf("Error Locus:    %x\n",de.locus);
   @}
+  return 0;
+@}
+@end example
+
+@node dostrerr, dos
+@subheading Syntax
+
+@example
+#include <dos.h>
+
+int dostrerr(struct DOSERROR *p_error, struct DOSERROR_str *p_str);
+@end example
+
+@subheading Description
+
+This function accepts the extended error structure from DOS (e.g., from
+the returned parameter from function @code{dosexterr}, see
+@pxref{dosexterr}) and returns the strings which describes that error
+structure in the structure pointed to by the second parameter.  This
+function is a DOS analogue of the ANSI function @code{strerror} (see
+@pxref{strerror}), and can be used to print descriptive messages
+corresponding to the errors described in the @code{DOSERROR} structure.
+
+For a list of the strings returned for each error number and type, see
+@ref{dosexterr}.
+
+@var{p_error} must point to the following structure:
+
+@example
+struct DOSERROR @{
+  int  exterror;
+  char class;
+  char action;
+  char locus;
+@};
+@end example
+
+@var{p_str} must point to the following structure:
+
+@example
+struct DOSERROR_STR @{
+  char *exterror_str;
+  char *class_str;
+  char *action_str;
+  char *locus_str;
+@};
+@end example
+
+
+@subheading Return Value
+
+If either pointer parameter is @code{NULL}, returns -1 and sets
+@code{errno} to EINVAL.  If both parameters are not @code{NULL}, checks
+the value of each member of the @code{DOSERROR} parameter @var{p_error}.
+If each value is within the limits of valid error codes for that member,
+sets parameter @var{p_str} member fields with the corresponding string
+describing the error code.  If any error code is outside of the valid
+values for that code, sets the corresponding @var{p_str} member to the
+string "Unknown error: " followed by the decimal numeric value of the
+error code.
+
+@subheading Portability
+
+@portability !ansi, !posix
+
+@subheading Example
+
+@example
+#include <stdio.h>
+#include <dos.h>
+
+int main(void)
+@{
+  FILE *fp;
+  struct DOSERROR de;
+  struct DOSERROR_STR se;
+
+  fp = fopen("EXAMPLE.DAT","r");
+  if ( fp == NULL )
+  @{
+    puts("Unable to open file for reading.");
+    dosexterr(&de);
+    dostrerr(&de, &se);
+    printf("Extended DOS error information:\n");
+    printf("Extended error: %i : %s\n",de.exterror,se.exterror_str);
+    printf("Class:          %x : %s\n",de.class,se.class_str);
+    printf("Action:         %x : %s\n",de.action,se.action_str);
+    printf("Error Locus:    %x : %s\n",de.locus,se.locus_str);
+  @}
+  return 0;
 @}
 @end example
diff -ruN djgpp-cvs/src/libc/dos/compat/d_strerr.c djgpp/src/libc/dos/compat/d_strerr.c
--- djgpp-cvs/src/libc/dos/compat/d_strerr.c	Thu Jan  1 00:00:00 1970
+++ djgpp/src/libc/dos/compat/d_strerr.c	Tue Dec 12 23:12:50 2000
@@ -0,0 +1,402 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
+/*
+ * D_STRERR.C.
+ *
+ * Written by Peter J. Farley III 2000 <pjfarley AT banet DOT net>.
+ *
+ * This file is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <dos.h>
+#include <libc/unconst.h>
+
+#define RESERVED "Reserved"
+
+/* Values for extended error code (EXTERROR field): */
+const char *__dos_errlist [] = {
+/* ---DOS 2.0+ --- */
+/* 00h (0)   */ "No error",
+/* 01h (1)   */ "Function number invalid",
+/* 02h (2)   */ "File not found",
+/* 03h (3)   */ "Path not found",
+/* 04h (4)   */ "Too many open files (no handles available)",
+/* 05h (5)   */ "Access denied",
+/* 06h (6)   */ "Invalid handle",
+/* 07h (7)   */ "Memory control block destroyed",
+/* 08h (8)   */ "Insufficient memory",
+/* 09h (9)   */ "Memory block address invalid",
+/* 0Ah (10)  */ "Environment invalid (usually >32K in length)",
+/* 0Bh (11)  */ "Format invalid",
+/* 0Ch (12)  */ "Access code invalid",
+/* 0Dh (13)  */ "Data invalid",
+/* 0Eh (14)  */ "Reserved/(PTS-DOS 6.51+, S/DOS 1.0+) fixup overflow",
+/* 0Fh (15)  */ "Invalid drive",
+/* 10h (16)  */ "Attempted to remove current directory",
+/* 11h (17)  */ "Not same device",
+/* 12h (18)  */ "No more files",
+/* ---DOS 3.0+ (INT 24 errors)--- */
+/* 13h (19)  */ "Disk write-protected",
+/* 14h (20)  */ "Unknown unit",
+/* 15h (21)  */ "Drive not ready",
+/* 16h (22)  */ "Unknown command",
+/* 17h (23)  */ "Data error (CRC)",
+/* 18h (24)  */ "Bad request structure length",
+/* 19h (25)  */ "Seek error",
+/* 1Ah (26)  */ "Unknown media type (non-DOS disk)",
+/* 1Bh (27)  */ "Sector not found",
+/* 1Ch (28)  */ "Printer out of paper",
+/* 1Dh (29)  */ "Write fault",
+/* 1Eh (30)  */ "Read fault",
+/* 1Fh (31)  */ "General failure",
+/* 20h (32)  */ "Sharing violation",
+/* 21h (33)  */ "Lock violation",
+/* 22h (34)  */ "Disk change invalid (ES:DI -> media ID structure)(see #01681)",
+/* 23h (35)  */ "FCB unavailable/(PTS-DOS 6.51+, S/DOS 1.0+) Bad FAT",
+/* 24h (36)  */ "Sharing buffer overflow",
+/* 25h (37)  */ "(DOS 4.0+) Code page mismatch",
+/* 26h (38)  */ "(DOS 4.0+) Cannot complete file operation (EOF / out of input)",
+/* 27h (39)  */ "(DOS 4.0+) Insufficient disk space",
+/* 28h (40)  */ RESERVED,
+/* 29h (41)  */ RESERVED,
+/* 2Ah (42)  */ RESERVED,
+/* 2Bh (43)  */ RESERVED,
+/* 2Ch (44)  */ RESERVED,
+/* 2Dh (45)  */ RESERVED,
+/* 2Eh (46)  */ RESERVED,
+/* 2Fh (47)  */ RESERVED,
+/* 30h (48)  */ RESERVED,
+/* 31h (49)  */ RESERVED,
+/* ---OEM network errors (INT 24)--- */
+/* 32h (50)  */ "Network request not supported",
+/* 33h (51)  */ "Remote computer not listening",
+/* 34h (52)  */ "Duplicate name on network",
+/* 35h (53)  */ "Network name not found",
+/* 36h (54)  */ "Network busy",
+/* 37h (55)  */ "Network device no longer exists",
+/* 38h (56)  */ "Network BIOS command limit exceeded",
+/* 39h (57)  */ "Network adapter hardware error",
+/* 3Ah (58)  */ "Incorrect response from network",
+/* 3Bh (59)  */ "Unexpected network error",
+/* 3Ch (60)  */ "Incompatible remote adapter",
+/* 3Dh (61)  */ "Print queue full",
+/* 3Eh (62)  */ "Queue not full",
+/* 3Fh (63)  */ "Not enough space to print file",
+/* 40h (64)  */ "Network name was deleted",
+/* 41h (65)  */ "Network: Access denied",
+/*	  (DOS 3.0+ [maybe 3.3+???]) codepage switching not possible
+	    (see also INT 21/AX=6602h,INT 2F/AX=AD42h) */
+/* 42h (66)  */ "Network device type incorrect",
+/* 43h (67)  */ "Network name not found",
+/* 44h (68)  */ "Network name limit exceeded",
+/* 45h (69)  */ "Network BIOS session limit exceeded",
+/* 46h (70)  */ "Temporarily paused",
+/* 47h (71)  */ "Network request not accepted",
+/* 48h (72)  */ "Network print/disk redirection paused",
+/* 49h (73)  */ "Network software not installed/(LANtastic) Invalid network version",
+/* 4Ah (74)  */ "Unexpected adapter close/(LANtastic) Account expired",
+/* 4Bh (75)  */ "(LANtastic) Password expired",
+/* 4Ch (76)  */ "(LANtastic) Login attempt invalid at this time",
+/* 4Dh (77)  */ "(LANtastic v3+) Disk limit exceeded on network node",
+/* 4Eh (78)  */ "(LANtastic v3+) Not logged in to network node",
+/* 4Fh (79)  */ RESERVED,
+/* ---end of errors reportable via INT 24--- */
+/* 50h (80)  */ "File exists",
+/* 51h (81)  */ "(undoc) Duplicated FCB",
+/* 52h (82)  */ "Cannot make directory",
+/* 53h (83)  */ "Fail on INT 24h",
+/* ---network-related errors (non-INT 24)--- */
+/* 54h (84)  */ "(DOS 3.3+) Too many redirections / out of structures",
+/* 55h (85)  */ "(DOS 3.3+) Duplicate redirection / already assigned",
+/* 56h (86)  */ "(DOS 3.3+) Invalid password",
+/* 57h (87)  */ "(DOS 3.3+) Invalid parameter",
+/* 58h (88)  */ "(DOS 3.3+) Network write fault",
+/* 59h (89)  */ "(DOS 4.0+) Function not supported on network / no process slots available",
+/* 5Ah (90)  */ "(DOS 4.0+) Required system component not installed / not frozen",
+/* 5Bh (91)  */ "(DOS 4.0+,NetWare4) Timer server table overflowed",
+/* 5Ch (92)  */ "(DOS 4.0+,NetWare4) Duplicate in timer service table",
+/* 5Dh (93)  */ "(DOS 4.0+,NetWare4) No items to work on",
+/* 5Eh (94)  */ RESERVED,
+/* 5Fh (95)  */ "(DOS 4.0+,NetWare4) Interrupted / invalid system call",
+/* 60h (96)  */ RESERVED,
+/* 61h (97)  */ RESERVED,
+/* 62h (98)  */ RESERVED,
+/* 63h (99)  */ RESERVED,
+/* 64h (100) */ "(MSCDEX) Unknown error/(DOS 4.0+,NetWare4) Open semaphore limit exceeded",
+/* 65h (101) */ "(MSCDEX) Not ready/(DOS 4.0+,NetWare4) Exclusive semaphore is already owned",
+/* 66h (102) */ "(MSCDEX) EMS memory no longer valid/(DOS 4.0+,NetWare4) Semaphore was set when close attempted",
+/* 67h (103) */ "(MSCDEX) Not High Sierra or ISO-9660 format/(DOS 4.0+,NetWare4) Too many exclusive semaphore requests",
+/* 68h (104) */ "(MSCDEX) Door open/(DOS 4.0+,NetWare4) Operation invalid from interrupt handler",
+/* 69h (105) */ "(DOS 4.0+,NetWare4) Semaphore owner died",
+/* 6Ah (106) */ "(DOS 4.0+,NetWare4) Semaphore limit exceeded",
+/* 6Bh (107) */ "(DOS 4.0+,NetWare4) Insert drive B: disk into A: / disk changed",
+/* 6Ch (108) */ "(DOS 4.0+,NetWare4) Drive locked by another process",
+/* 6Dh (109) */ "(DOS 4.0+,NetWare4) Broken pipe",
+/* 6Eh (110) */ "(DOS 5.0+,NetWare4) Pipe open/create failed",
+/* 6Fh (111) */ "(DOS 5.0+,NetWare4) Pipe buffer overflowed",
+/* 70h (112) */ "(DOS 5.0+,NetWare4) Disk full",
+/* 71h (113) */ "(DOS 5.0+,NetWare4) No more search handles",
+/* 72h (114) */ "(DOS 5.0+,NetWare4) Invalid target handle for dup2",
+/* 73h (115) */ "(DOS 5.0+,NetWare4) Bad user virtual address / protection violation",
+/* 74h (116) */ "(DOS 5.0+) VIOKBD request/(NetWare4) error on console I/O",
+/* 75h (117) */ "(DOS 5.0+,NetWare4) Unknown category code for IOCTL",
+/* 76h (118) */ "(DOS 5.0+,NetWare4) Invalid value for verify flag",
+/* 77h (119) */ "(DOS 5.0+,NetWare4) Level four driver not found by DOS IOCTL",
+/* 78h (120) */ "(DOS 5.0+,NetWare4) Invalid / unimplemented function number",
+/* 79h (121) */ "(DOS 5.0+,NetWare4) Semaphore timeout",
+/* 7Ah (122) */ "(DOS 5.0+,NetWare4) Buffer too small to hold return data",
+/* 7Bh (123) */ "(DOS 5.0+,NetWare4) Invalid character or bad file-system name",
+/* 7Ch (124) */ "(DOS 5.0+,NetWare4) Unimplemented information level",
+/* 7Dh (125) */ "(DOS 5.0+,NetWare4) No volume label found",
+/* 7Eh (126) */ "(DOS 5.0+,NetWare4) Module handle not found",
+/* 7Fh (127) */ "(DOS 5.0+,NetWare4) Procedure address not found",
+/* 80h (128) */ "(DOS 5.0+,NetWare4) CWait found no children",
+/* 81h (129) */ "(DOS 5.0+,NetWare4) CWait children still running",
+/* 82h (130) */ "(DOS 5.0+,NetWare4) Invalid operation for direct disk-access handle",
+/* 83h (131) */ "(DOS 5.0+,NetWare4) Attempted seek to negative offset",
+/* 84h (132) */ "(DOS 5.0+,NetWare4) Attempted to seek on device or pipe",
+/* ---JOIN/SUBST Errors--- */
+/* 85h (133) */ "(DOS 5.0+,NetWare4) Drive already has JOINed drives",
+/* 86h (134) */ "(DOS 5.0+,NetWare4) Drive is already JOINed",
+/* 87h (135) */ "(DOS 5.0+,NetWare4) Drive is already SUBSTed",
+/* 88h (136) */ "(DOS 5.0+,NetWare4) Can not delete drive which is not JOINed",
+/* 89h (137) */ "(DOS 5.0+,NetWare4) Can not delete drive which is not SUBSTed",
+/* 8Ah (138) */ "(DOS 5.0+,NetWare4) Can not JOIN to a JOINed drive",
+/* 8Bh (139) */ "(DOS 5.0+,NetWare4) Can not SUBST to a SUBSTed drive",
+/* 8Ch (140) */ "(DOS 5.0+,NetWare4) Can not JOIN to a SUBSTed drive",
+/* 8Dh (141) */ "(DOS 5.0+,NetWare4) Can not SUBST to a JOINed drive",
+/* 8Eh (142) */ "(DOS 5.0+,NetWare4) Drive is busy",
+/* 8Fh (143) */ "(DOS 5.0+,NetWare4) Can not JOIN/SUBST to same drive",
+/* 90h (144) */ "(DOS 5.0+,NetWare4) Directory must not be root directory",
+/* 91h (145) */ "(DOS 5.0+,NetWare4) Can only JOIN to empty directory",
+/* 92h (146) */ "(DOS 5.0+,NetWare4) Path is already in use for SUBST",
+/* 93h (147) */ "(DOS 5.0+,NetWare4) Path is already in use for JOIN",
+/* 94h (148) */ "(DOS 5.0+,NetWare4) Path is in use by another process",
+/* 95h (149) */ "(DOS 5.0+,NetWare4) Directory previously SUBSTituted",
+/* 96h (150) */ "(DOS 5.0+,NetWare4) System trace error",
+/* 97h (151) */ "(DOS 5.0+,NetWare4) Invalid event count for DosMuxSemWait",
+/* 98h (152) */ "(DOS 5.0+,NetWare4) Too many waiting on mutex",
+/* 99h (153) */ "(DOS 5.0+,NetWare4) Invalid list format",
+/* 9Ah (154) */ "(DOS 5.0+,NetWare4) Volume label too large",
+/* 9Bh (155) */ "(DOS 5.0+,NetWare4) Unable to create another TCB",
+/* 9Ch (156) */ "(DOS 5.0+,NetWare4) Signal refused",
+/* 9Dh (157) */ "(DOS 5.0+,NetWare4) Segment discarded",
+/* 9Eh (158) */ "(DOS 5.0+,NetWare4) Segment not locked",
+/* 9Fh (159) */ "(DOS 5.0+,NetWare4) Invalid thread-ID address",
+/* ----- */
+/* A0h (160) */ "(DOS 5.0+) Bad arguments/(NetWare4) bad environment pointer",
+/* A1h (161) */ "(DOS 5.0+,NetWare4) Invalid pathname passed to EXEC",
+/* A2h (162) */ "(DOS 5.0+,NetWare4) Signal already pending",
+/* A3h (163) */ "(DOS 5.0+) Uncertain media",
+/* A3h (163) */ "(NetWare4) ERROR_124 mapping",
+/* A4h (164) */ "(DOS 5.0+) Maximum number of threads reached/(NetWare4) No more process slots",
+/* A5h (165) */ "(NetWare4) ERROR_124 mapping",
+/* A6h (166) */ RESERVED,
+/* A7h (167) */ RESERVED,
+/* A8h (168) */ RESERVED,
+/* A9h (169) */ RESERVED,
+/* AAh (170) */ RESERVED,
+/* ABh (171) */ RESERVED,
+/* ACh (172) */ RESERVED,
+/* ADh (173) */ RESERVED,
+/* AEh (174) */ RESERVED,
+/* AFh (175) */ RESERVED,
+/* B0h (176) */ "(MS-DOS 7.0) Volume is not locked",
+/* B1h (177) */ "(MS-DOS 7.0) Volume is locked in drive",
+/* B2h (178) */ "(MS-DOS 7.0) Volume is not removable",
+/* B4h (180) */ "(MS-DOS 7.0) Lock count has been exceeded/(NetWare4) Invalid segment number",
+/* B5h (181) */ "(MS-DOS 7.0) A valid eject request failed/(DOS 5.0-6.0,NetWare4) Invalid call gate",
+/* B6h (182) */ "(DOS 5.0+,NetWare4) Invalid ordinal",
+/* B7h (183) */ "(DOS 5.0+,NetWare4) Shared segment already exists",
+/* B8h (184) */ "(DOS 5.0+,NetWare4) No child process to wait for",
+/* B9h (185) */ "(DOS 5.0+,NetWare4) NoWait specified and child still running",
+/* BAh (186) */ "(DOS 5.0+,NetWare4) Invalid flag number",
+/* BBh (187) */ "(DOS 5.0+,NetWare4) Semaphore does not exist",
+/* BCh (188) */ "(DOS 5.0+,NetWare4) Invalid starting code segment",
+/* BDh (189) */ "(DOS 5.0+,NetWare4) Invalid stack segment",
+/* BEh (190) */ "(DOS 5.0+,NetWare4) Invalid module type (DLL can not be used as application)",
+/* BFh (191) */ "(DOS 5.0+,NetWare4) Invalid EXE signature",
+/* C0h (192) */ "(DOS 5.0+,NetWare4) EXE marked invalid",
+/* C1h (193) */ "(DOS 5.0+,NetWare4) Bad EXE format (e.g. DOS-mode program)",
+/* C2h (194) */ "(DOS 5.0+,NetWare4) Iterated data exceeds 64K",
+/* C3h (195) */ "(DOS 5.0+,NetWare4) Invalid minimum allocation size",
+/* C4h (196) */ "(DOS 5.0+,NetWare4) Dynamic link from invalid Ring",
+/* C5h (197) */ "(DOS 5.0+,NetWare4) IOPL not enabled",
+/* C6h (198) */ "(DOS 5.0+,NetWare4) Invalid segment descriptor privilege level",
+/* C7h (199) */ "(DOS 5.0+,NetWare4) Automatic data segment exceeds 64K",
+/* C8h (200) */ "(DOS 5.0+,NetWare4) Ring2 segment must be moveable",
+/* C9h (201) */ "(DOS 5.0+,NetWare4) Relocation chain exceeds segment limit",
+/* CAh (202) */ "(DOS 5.0+,NetWare4) Infinite loop in relocation chain",
+/* CBh (203) */ "(NetWare4) Environment variable not found",
+/* CCh (204) */ "(NetWare4) Not current country",
+/* CDh (205) */ "(NetWare4) No signal sent",
+/* CEh (206) */ "(NetWare4) File name not 8.3",
+/* CFh (207) */ "(NetWare4) Ring2 stack in use",
+/* D0h (208) */ "(NetWare4) Meta expansion is too long",
+/* D1h (209) */ "(NetWare4) Invalid signal number",
+/* D2h (210) */ "(NetWare4) Inactive thread",
+/* D3h (211) */ "(NetWare4) File system information not available",
+/* D4h (212) */ "(NetWare4) Locked error",
+/* D5h (213) */ "(NetWare4) Attempted to execute non-family API call in DOS mode",
+/* D6h (214) */ "(NetWare4) Too many modules",
+/* D7h (215) */ "(NetWare4) Nesting not allowed",
+/* D8h (216) */ RESERVED,
+/* D9h (217) */ RESERVED,
+/* DAh (218) */ RESERVED,
+/* DBh (219) */ RESERVED,
+/* DCh (220) */ RESERVED,
+/* DDh (221) */ RESERVED,
+/* DEh (222) */ RESERVED,
+/* DFh (223) */ RESERVED,
+/* E0h (224) */ RESERVED,
+/* E1h (225) */ RESERVED,
+/* E2h (226) */ RESERVED,
+/* E3h (227) */ RESERVED,
+/* E4h (228) */ RESERVED,
+/* E5h (229) */ RESERVED,
+/* E6h (230) */ "(NetWare4) Non-existent pipe, or bad operation",
+/* E7h (231) */ "(NetWare4) Pipe is busy",
+/* E8h (232) */ "(NetWare4) No data available for nonblocking read",
+/* E9h (233) */ "(NetWare4) Pipe disconnected by server",
+/* EAh (234) */ "(NetWare4) More data available",
+/* EBh (235) */ RESERVED,
+/* ECh (236) */ RESERVED,
+/* EDh (237) */ RESERVED,
+/* EEh (238) */ RESERVED,
+/* EFh (239) */ RESERVED,
+/* F0h (240) */ RESERVED,
+/* F1h (241) */ RESERVED,
+/* F2h (242) */ RESERVED,
+/* F3h (243) */ RESERVED,
+/* F4h (244) */ RESERVED,
+/* F5h (245) */ RESERVED,
+/* F6h (246) */ RESERVED,
+/* F7h (247) */ RESERVED,
+/* F8h (248) */ RESERVED,
+/* F9h (249) */ RESERVED,
+/* FAh (250) */ RESERVED,
+/* FBh (251) */ RESERVED,
+/* FCh (252) */ RESERVED,
+/* FDh (253) */ RESERVED,
+/* FEh (254) */ RESERVED,
+/* FFh (255) */ "(NetWare4) Invalid drive"
+/* (End of list) */ };
+
+int __dos_nerr = sizeof(__dos_errlist) / sizeof(__dos_errlist[0]);
+
+/* Values for error class (CLASS field): */
+const char *__dos_errclass [] = {
+/* 01h (1)  */ "Out of resource (storage space or I/O channels)",
+/* 02h (2)  */ "Temporary situation (file or record lock)",
+/* 03h (3)  */ "Authorization / permission problem (denied access)",
+/* 04h (4)  */ "Internal system error (system software bug)",
+/* 05h (5)  */ "Hardware failure",
+/* 06h (6)  */ "System failure (configuration file missing or incorrect)",
+/* 07h (7)  */ "Application program error",
+/* 08h (8)  */ "Not found",
+/* 09h (9)  */ "Bad format",
+/* 0Ah (10) */ "Locked",
+/* 0Bh (11) */ "Media error",
+/* 0Ch (12) */ "Already exists / collision with existing item",
+/* 0Dh (13) */ "Unknown / other",
+/* 0Eh (14) */ "(Undoc) Cannot",
+/* 0Fh (15) */ "(Undoc) Time"
+/* (End of list) */ };
+
+int __dos_ncls = sizeof(__dos_errclass) / sizeof(__dos_errclass[0]);
+
+/* Values for suggested action (ACTION field): */
+const char *__dos_erraction [] = {
+/* 01h (01) */ "Retry",
+/* 02h (02) */ "Delayed retry",
+/* 03h (03) */ "Prompt user to reenter input",
+/* 04h (04) */ "Abort after cleanup",
+/* 05h (05) */ "Immediate abort",
+/* 06h (06) */ "Ignore",
+/* 07h (07) */ "Retry after user intervention"
+/* (End of list) */ };
+
+int __dos_nact = sizeof(__dos_erraction) / sizeof(__dos_erraction[0]);
+
+/* Values for error locus (LOCUS field): */
+const char *__dos_errlocus [] = {
+/*   01h (01) */  "Unknown or not appropriate",
+/*   02h (02) */  "Block device (disk error)",
+/*   03h (03) */  "Network related",
+/*   04h (04) */  "Serial device (timeout)/(PTS-DOS 6.51+ & S/DOS 1.0+) Character device",
+/*   05h (05) */  "Memory related"
+/* (End of list) */ };
+
+int __dos_nloc = sizeof(__dos_errlocus) / sizeof(__dos_errlocus[0]);
+
+static char *
+_err_unknown(int errnum)
+{
+  static char ebuf[40];         /* 64-bit number + slop */
+  char *cp;
+  int v=1000000, lz=0;
+
+  strcpy(ebuf, "Unknown error: ");
+  cp = ebuf + strlen(ebuf);
+  if (errnum < 0)
+  {
+    *cp++ = '-';
+    errnum = -errnum;
+  }
+  while (v)
+  {
+    int d = errnum / v;
+    if (d || lz || (v == 1))
+    {
+      *cp++ = d+'0';
+      lz = 1;
+    }
+    errnum %= v;
+    v /= 10;
+  }
+
+  return ebuf;
+}
+
+int
+_dostrerr(struct _DOSERROR *p_error, struct _DOSERROR_STR *p_str)
+{
+  if (!p_error || !p_str)
+  {
+    errno = EINVAL;
+    return -1;
+  }
+
+  if (p_error->exterror >= 0 && p_error->exterror < __dos_nerr)
+    p_str->exterror_str = unconst(__dos_errlist[p_error->exterror], char *);
+  else
+    p_str->exterror_str = _err_unknown(p_error->exterror);
+
+  if (strcmp(p_str->exterror_str, RESERVED) == 0)
+    p_str->exterror_str = _err_unknown(p_error->exterror);
+
+  if (p_error->class >= 0 && p_error->class < __dos_ncls)
+  #ifdef __cplusplus
+    p_str->errclass_str = unconst(__dos_errclass[(unsigned char)p_error->errclass], char *);
+  #else
+    p_str->class_str = unconst(__dos_errclass[(unsigned char)p_error->class], char *);
+  #endif
+  else
+    p_str->class_str = _err_unknown(p_error->class);
+
+  if (p_error->action >= 0 && p_error->action < __dos_nact)
+    p_str->action_str = unconst(__dos_erraction[(unsigned char)p_error->action], char *);
+  else
+    p_str->action_str = _err_unknown(p_error->action);
+
+  if (p_error->locus >= 0 && p_error->locus < __dos_nloc)
+    p_str->locus_str = unconst(__dos_errlocus[(unsigned char)p_error->locus], char *);
+  else
+    p_str->locus_str = _err_unknown(p_error->locus);
+
+  return 0;
+}
diff -ruN djgpp-cvs/src/libc/dos/compat/makefile djgpp/src/libc/dos/compat/makefile
--- djgpp-cvs/src/libc/dos/compat/makefile	Sun Aug 27 02:38:32 1995
+++ djgpp/src/libc/dos/compat/makefile	Mon Dec 11 21:56:58 2000
@@ -21,6 +21,7 @@
 SRC += d_setfa.c
 SRC += d_setftm.c
 SRC += d_settim.c
+SRC += d_strerr.c
 SRC += d_write.c
 
 include $(TOP)/../makefile.inc

--=====================_12542069==_
Content-Type: text/plain; charset="us-ascii"; format=flowed

---------------------------------------------------------
Peter J. Farley III (pjfarley AT dorsai DOT org OR
                      pjfarley AT banet DOT net)
--=====================_12542069==_--

- Raw text -


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