blob: 0323cd4a08d429735d71ad93e52b856b6fc3723c [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;
22 else
23 continue;
24 }
25 printf(" case %d: return %d;\n", i, errno);
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000026 }
Antoine Pitroua7622852011-09-01 21:37:43 +020027 printf(" default: return EINVAL;\n");
28 printf(" }\n}\n");
Thomas Wouters477c8d52006-05-27 19:21:47 +000029}