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