blob: 953344c0d7959787189de3a16797f2b43ffa3c41 [file] [log] [blame]
Antoine Pitroua7622852011-09-01 21:37:43 +02001#include <windows.h>
2#include <fcntl.h>
3#include <io.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00004#include <stdio.h>
5#include <errno.h>
6
7/* Extract the mapping of Win32 error codes to errno */
8
9int main()
10{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000011 int i;
Antoine Pitroua7622852011-09-01 21:37:43 +020012 _setmode(fileno(stdout), O_BINARY);
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000013 printf("/* Generated file. Do not edit. */\n");
14 printf("int winerror_to_errno(int winerror)\n");
Antoine Pitroua7622852011-09-01 21:37:43 +020015 printf("{\n switch(winerror) {\n");
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000016 for(i=1; i < 65000; i++) {
17 _dosmaperr(i);
Antoine Pitroua7622852011-09-01 21:37:43 +020018 if (errno == EINVAL) {
19 /* Issue #12802 */
20 if (i == ERROR_DIRECTORY)
21 errno = ENOTDIR;
Antoine Pitrou586bfe42011-10-07 16:16:31 +020022 /* Issue #13063 */
23 else if (i == ERROR_NO_DATA)
24 errno = EPIPE;
Antoine Pitroua7622852011-09-01 21:37:43 +020025 else
26 continue;
27 }
28 printf(" case %d: return %d;\n", i, errno);
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000029 }
Antoine Pitroua7622852011-09-01 21:37:43 +020030 printf(" default: return EINVAL;\n");
31 printf(" }\n}\n");
Thomas Wouters477c8d52006-05-27 19:21:47 +000032}