| #include <errno.h> |
| |
| static int errno_private = 0; |
| |
| #if 0 |
| |
| struct errentry { |
| unsigned long int ntstatus; |
| int errno; |
| }; |
| |
| static struct errentry errtable[] = { |
| { 0x00000000L, 0 }, |
| { 0x00000102L, ETIME } |
| }; |
| |
| int ntstatus_to_errno(unsigned long int ntstatus){ |
| int i; |
| for(i = 0; i < (sizeof errtable / sizeof *errtable); i++) if(ntstatus == errtable.ntstatus) return errno_private = errtable.errno; |
| return errno_private = ntstatus_to_errno_other(ntstatus); |
| } |
| |
| #else |
| |
| static int ntstatus_to_errno_other(unsigned long int ntstatus){ |
| if(ntstatus <= 0xC0000403L && ntstatus >= 0xC0000401L) return EDQUOT; |
| if(ntstatus <= 0xC0000018L && ntstatus >= 0xC000001BL) return EFAULT; |
| if(ntstatus <= 0x80000015L && ntstatus >= 0x80000013L) return EINVAL; |
| if(ntstatus <= 0x000000BFL && ntstatus >= 0x00000080L) return EOWNERDEAD; |
| } |
| |
| int ntstatus_to_errno(unsigned long int ntstatus){ |
| switch(ntstatus){ |
| case 0x00000000L: return errno_private = 0; |
| case 0x00000102L: return errno_private = ETIME; |
| case 0x00000106L: return errno_private = EACCES |
| case 0x00000104L: |
| case 0x00000118L: return errno_private = ENOLINK; |
| case 0x00000107L: return errno_private = ENOMSG; |
| case 0x0000010DL: |
| case 0xC0000007L: |
| case 0xC0000031L: |
| case 0xC0000044L: |
| case 0xC000012CL: |
| case 0xC00002E7L: |
| case 0xC0000410L: |
| case 0xC0000802L: return errno_private = EDQUOT; |
| case 0x0000010EL: return errno_private = ECONNABORTED; |
| case 0x00000114L: return errno_private = EHWPOISON; |
| case 0x00000119L: |
| case 0x80000011L: |
| case 0xC0000016L: return errno_private = EBUSY; |
| |
| case 0x40000003L: |
| case 0x4000000EL: |
| case 0x40000023L: return errno_private = ENOEXEC; |
| case 0x4000001BL: |
| case 0x40190035L: return errno_private = EALREADY; |
| case 0x401E000AL: |
| case 0x80000001L: |
| case 0x80000005L: |
| case 0x801C0001L: |
| case 0xC0000023L: return errno_private = ENOBUFS; |
| case 0x401E034BL: |
| case 0x401E034CL: |
| case 0xC0000008L: return errno_private = EBADR; |
| case 0x401E042FL: |
| case 0x8000000FL: |
| case 0xC000000EL: return errno_private = ENODEV; |
| case 0x80000017L: return errno_private = EMSGSIZE; |
| case 0x80000025L: |
| case 0x80130004L: |
| case 0xC0000037L: return errno_private = ENOTCONN; |
| case 0x80000288L: return errno_private = EUCLEAN; |
| case 0x80130003L: return errno_private = EISCONN; |
| case 0x80190031L: |
| case 0xC0000022L: |
| case 0xC0000038L: return errno_private = EACCES; |
| case 0x80210001L: |
| case 0xC0000006L: |
| case 0xC0000020L: |
| case 0xC000002BL: |
| case 0xC0000032L: return errno_private = EIO; |
| case 0xC0000002L: return errno_private = ENOSYS; |
| case 0xC0000003L: |
| case 0xC000000DL: |
| case 0xC000001CL: |
| case 0xC000001FL: |
| case 0xC0000030L: |
| case 0xC0000033L: return errno_private = EINVAL; |
| case 0xC0000005L: |
| case 0xC0000009L: |
| case 0xC000000AL: |
| case 0xC000001DL: |
| case 0xC0000025L: |
| case 0xC000002CL: return errno_private = EFAULT; |
| case 0xC000000FL: |
| case 0xC0000034L: |
| case 0xC000003AL: return errno_private = ENOENT; |
| case 0xC0000010L: return errno_private = EPERM; |
| case 0xC0000012L: |
| case 0xC0000014L: return errno_private = EMEDIUMTYPE; |
| case 0xC0000013L: return errno_private = ENOMEDIUM; |
| case 0xC0000467L: return errno_private = ETXTBSY; |
| //case 0x00000080L: return errno_private = EOWNERDEAD; |
| //default: return errno_private = EINVAL; |
| //default: return errno_private = -1; |
| } |
| return errno_private = ntstatus_to_errno_other(ntstatus); |
| } |
| |
| #endif |
| |
| int *_errno(){ |
| return &errno_private; |
| } |