]> pd.if.org Git - pdclib/blob - platform/win32/functions/_PDCLIB/_PDCLIB_w32errno.c
PDCLib includes with quotes, not <>.
[pdclib] / platform / win32 / functions / _PDCLIB / _PDCLIB_w32errno.c
1 /* _PDCLIB_allocpages( int const )\r
2 \r
3    This file is part of the Public Domain C Library (PDCLib).\r
4    Permission is granted to use, modify, and / or redistribute at will.\r
5 */\r
6 \r
7 /* This is a stub implementation of _PDCLIB_allocpages\r
8 */\r
9 \r
10 #ifndef REGTEST\r
11 #include <errno.h>\r
12 #include <wchar.h> // Watcom bug: winnt.h assumes string.h defines wchar_t\r
13 #include <windows.h>\r
14 \r
15 void _PDCLIB_w32errno(void);\r
16 \r
17 void _PDCLIB_w32errno(void)\r
18 {\r
19     // Not exhaustive\r
20     switch(GetLastError()) {\r
21         case ERROR_SUCCESS:\r
22             return;\r
23         case ERROR_FILE_NOT_FOUND:\r
24         case ERROR_PATH_NOT_FOUND:\r
25         case ERROR_INVALID_DRIVE:\r
26             errno = ENOENT; break;\r
27         case ERROR_TOO_MANY_OPEN_FILES:\r
28             errno = EMFILE; break;\r
29         case ERROR_ACCESS_DENIED:\r
30         case ERROR_WRITE_PROTECT:\r
31             errno = EPERM; break;\r
32         case ERROR_INVALID_HANDLE:\r
33             errno = EBADF; break;\r
34         case ERROR_NOT_ENOUGH_MEMORY:\r
35         case ERROR_OUTOFMEMORY:\r
36             errno = ENOMEM; break;\r
37         case ERROR_NOT_READY:\r
38             errno = EAGAIN; break;\r
39         case ERROR_BAD_LENGTH:\r
40             errno = EINVAL; break;\r
41         default:\r
42             // TODO: reconsider what to use here?\r
43             errno = ENOSYS; break;\r
44     }\r
45 }\r
46 \r
47 #endif\r
48 \r
49 #ifdef TEST\r
50 #include "_PDCLIB_test.h"\r
51 \r
52 int main( void )\r
53 {\r
54     return TEST_RESULTS;\r
55 }\r
56 \r
57 #endif\r