1 #include <windows.h> 2 #include <fcntl.h> 3 #include <io.h> 4 #include <stdio.h> 5 #include <errno.h> 6 7 /* Extract the mapping of Win32 error codes to errno */ 8 main()9int main() 10 { 11 int i; 12 _setmode(fileno(stdout), O_BINARY); 13 printf("/* Generated file. Do not edit. */\n"); 14 printf("int winerror_to_errno(int winerror)\n"); 15 printf("{\n switch(winerror) {\n"); 16 for(i=1; i < 65000; i++) { 17 _dosmaperr(i); 18 if (errno == EINVAL) { 19 /* Issue #12802 */ 20 if (i == ERROR_DIRECTORY) 21 errno = ENOTDIR; 22 /* Issue #13063 */ 23 else if (i == ERROR_NO_DATA) 24 errno = EPIPE; 25 else 26 continue; 27 } 28 printf(" case %d: return %d;\n", i, errno); 29 } 30 printf(" default: return EINVAL;\n"); 31 printf(" }\n}\n"); 32 } 33