home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / famapi.zip / INCLUDE.ZIP / ERRNO.H < prev    next >
C/C++ Source or Header  |  1993-05-04  |  7KB  |  154 lines

  1. //
  2. //      **************************************************************
  3. //       JdeBP C++ Library Routines      General Public Licence v1.00
  4. //          Copyright (c) 1991,1992  Jonathan de Boyne Pollard
  5. //      **************************************************************
  6. //
  7. //  ERROR NUMBERS (ANSI and POSIX)
  8. //
  9. // XENIX is a trademark of Microsoft Corporation.
  10. //
  11.  
  12. #if !defined(___STDDEF_H_INCLUDED)
  13. #include <_stddef.h>
  14. #endif
  15.  
  16. #if !defined(__ERRNO_H_INCLUDED)
  17.  
  18. //
  19. // ANSI Requires these to be defined, and positive.
  20. //
  21. // How I would like to change these, as they conflict with MS-DOS error
  22. // returns!  Unfortunately, a *lot* of code assumes these values.
  23. //
  24. #define EDOM        33          /* (XENIX = 33) ANSI Maths domain error */
  25. #define ERANGE      34          /* (XENIX = 34) ANSI Maths range error */
  26.  
  27. //
  28. // To be strict, this is not an error code, and is against the spirit of
  29. // the Standard.  Only user code may assign this value to errno.
  30. //
  31. #define EZERO       0
  32.  
  33. //
  34. // Since neither ANSI nor POSIX.1 give numeric values to error codes,
  35. // MS-DOS error return values are mapped directly into errno.  Although
  36. // _doserrno is supported (as the underlying value of errno in a single
  37. // threaded library), code should not depend upon it or use it.
  38. //
  39. // Borland C uses MS-DOS errors, although allows some library routines to
  40. // assign POSIX errors that have no meaning under MS-DOS (e.g. as errors
  41. // from "system calls" that MS-DOS does not have); whereas Microsoft C
  42. // attempts to retain numeric compatibility with XENIX.
  43. //
  44. // POSIX.1 error codes that have no meaning under MS-DOS are mapped into
  45. // negative integers.  ANSI functions that assign to errno may only assign
  46. // positive values.  However, the Standard dictates that all NON-ZERO values
  47. // are error codes.
  48. //
  49. #define EINVFUNC    1   /* Invalid function number */
  50. #define ENOENT      2   /* File not found (XENIX =  2) */
  51. #define ENOPATH     3   /* Path not found */
  52. #define EMFILE      4   /* Too many open files (XENIX = 24) */
  53. #define EACCESS     5   /* Access denied (XENIX = 13) */
  54. #define EBADF       6   /* Bad file descriptor (XENIX =  9) */
  55. #define EARENA      7   /* Memory arena corrupted */
  56. #define ENOMEM      8   /* No room in memory (XENIX = 12) */
  57. #define EFAULT      9   /* Invalid memory address (XENIX = 14) */
  58. #define EINVENV     10  /* Invalid environment */
  59. #define EINVFMT     11  /* Invalid format */
  60. #define EINVACC     12  /* Invalid Access */
  61. #define EINVDAT     13  /* Invalid data */
  62. #define ENODEV      15  /* No driver for that device (XENIX = 19) */
  63. #define ECURDIR     16  /* Cannot remove current directory */
  64. #define EXDEV       17  /* Different device (XENIX = 18 BOR=22) */
  65. #define ENMFILES    18  /* No more files */
  66. #define EROFS       19  /* Read-Only File system (XENIX = 30) */
  67. #define ENXIO       20  /* Unknown device unit (XENIX =  6) */
  68. #define ENREADY     21  /* Device not ready */
  69. #define EIOCMD      22  /* Unknown IO command */
  70. #define ECRC        23  /* CRC error */
  71. #define EBADRQST    24  /* Bad IO request packet */
  72. #define ESEEK       25  /* Seek error */
  73. #define EMEDIUM     26  /* Unknown medium type */
  74. #define ENSECTOR    27  /* Sector not found */
  75. #define EOOPAPER    28  /* Out of Paper */
  76. #define EIOWRITE    29  /* Write error */
  77. #define EIOREAD     30  /* Read error */
  78. #define EIOGENRL    31  /* General Failure error */
  79. #define ENSHARE     32  /* Sharing violation */
  80. #define EDEADLOCK   33  /* Locking violation (XENIX = 36) */
  81. #define EDISKCHANGE 34  /* Unauthorised disk change */
  82. #define ENFCB       35  /* FCB not available */
  83.  
  84. #define E2BIG       40  /* Argument list too large (XENIX =  7 BOR=20) */
  85. #define ENOEXEC     41  /* File is not in executable format (XENIX =  8 BOR=21) */
  86. #define ECHILD      42  /* No child processes to wait for (XENIX = 10) */
  87. #define EAGAIN      43  /* No more process slots available (XENIX = 11) */
  88. #define EINVAL      44  /* Invalid arguments to system call (XENIX = 22 BOR=19) */
  89. #define ENOSPC      45  /* No space left on device (XENIX = 28) */
  90.  
  91. #define EEXIST      80  /* File already exists (XENIX = 17 BOR=35) */
  92. #define EDUPFCB     81  /* Duplicate FCB found */
  93. #define EMKDIR      82  /* Cannot create directory */
  94. #define ECRITFAILED 83  /* Fail after int 24H */
  95.  
  96. #define EPERM       -1  /* (XENIX =  1) Permission denied */
  97. #define ESRCH       -3  /* (XENIX =  3) No such process */
  98. #define EINTR       -4  /* (XENIX =  4) System call interrupted */
  99. #define EIO         -5  /* (XENIX =  5) Physical I/O error */
  100. #define ENOTBLK     -15 /* (XENIX = 15) Not a Block device */
  101. #define EBUSY       -16 /* (XENIX = 16) Resource busy */
  102. #define ENOTDIR     -20 /* (XENIX = 20) Directory operation on non-directory */
  103. #define EISDIR      -21 /* (XENIX = 21) File operation on directory */
  104. #define ENFILE      -23 /* (XENIX = 23) System file table full */
  105. #define ENOTTY      -25 /* (XENIX = 25) Not a TTY device */
  106. #define ETXTBSY     -26 /* (XENIX = 26) File is a running program */
  107. #define EFBIG       -27 /* (XENIX = 27) File is too large */
  108. #define ESPIPE      -29 /* (XENIX = 29) Cannot SEEK on a pipe */
  109. #define EMLINK      -31 /* (XENIX = 31) Too many links */
  110. #define EPIPE       -32 /* (XENIX = 32) Write on broken pipe */
  111. #define EUCLEAN     -35 /* (XENIX = 35) */
  112. #define ENAMETOOLONG    -40 /* Filename is too long */
  113. #define ENOLCK      -41 /* No locks available */
  114. #define ENOSYS      -42 /* Function not supported on operating system */
  115. #define ENOTEMPTY   -43 /* Directory not empty */
  116. #define ENOTTTY     -44 /* Inappropriate ioctl() operation */
  117.  
  118. #define EDEADLK     EDEADLOCK
  119.  
  120. extern int _CDECL _DosErrno;                        // DOS system error
  121. extern const char * const _CDECL _Sys_ErrList[];    // Error messages
  122. extern const int _CDECL _Sys_NumErrs;               // Size of above
  123.  
  124. extern "C" {
  125.  
  126. int *   _CDECL  _Errno  (void);
  127.  
  128. char *  _CDECL  _Strerror   (int, char *);
  129.  
  130. #if _POSIX1_SOURCE > 0
  131. #define sys_errlist _Sys_ErrList
  132. #define sys_nerr    _Sys_NumErrs
  133. #endif
  134.  
  135. }
  136.  
  137. //
  138. //    ANSI states that errno is a MACRO which expands to a modifiable lvalue.
  139. //
  140. //    For POSIX.1 compatibility, if the macro is #undef'd, then this
  141. //    implementation will fall back to an external int variable.  However,
  142. //    this variable is NOT declared in any standard header.
  143. //
  144. //    Multithreaded programs must NOT look behind the errno macro.
  145. //
  146. #define errno (*_Errno())
  147.  
  148. #if _MSDOS_SOURCE > 0
  149. #define _doserrno   _DosErrno
  150. #endif
  151.  
  152. #define __ERRNO_H_INCLUDED
  153. #endif
  154.