Antoine Pitrou | a762285 | 2011-09-01 21:37:43 +0200 | [diff] [blame] | 1 | #include <windows.h> |
| 2 | #include <fcntl.h> |
| 3 | #include <io.h> |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 4 | #include <stdio.h> |
| 5 | #include <errno.h> |
| 6 | |
| 7 | /* Extract the mapping of Win32 error codes to errno */ |
| 8 | |
| 9 | int main() |
| 10 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 11 | int i; |
Antoine Pitrou | a762285 | 2011-09-01 21:37:43 +0200 | [diff] [blame] | 12 | _setmode(fileno(stdout), O_BINARY); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 13 | printf("/* Generated file. Do not edit. */\n"); |
| 14 | printf("int winerror_to_errno(int winerror)\n"); |
Antoine Pitrou | a762285 | 2011-09-01 21:37:43 +0200 | [diff] [blame] | 15 | printf("{\n switch(winerror) {\n"); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 16 | for(i=1; i < 65000; i++) { |
| 17 | _dosmaperr(i); |
Antoine Pitrou | a762285 | 2011-09-01 21:37:43 +0200 | [diff] [blame] | 18 | if (errno == EINVAL) { |
| 19 | /* Issue #12802 */ |
| 20 | if (i == ERROR_DIRECTORY) |
| 21 | errno = ENOTDIR; |
Antoine Pitrou | 586bfe4 | 2011-10-07 16:16:31 +0200 | [diff] [blame] | 22 | /* Issue #13063 */ |
| 23 | else if (i == ERROR_NO_DATA) |
| 24 | errno = EPIPE; |
Antoine Pitrou | a762285 | 2011-09-01 21:37:43 +0200 | [diff] [blame] | 25 | else |
| 26 | continue; |
| 27 | } |
| 28 | printf(" case %d: return %d;\n", i, errno); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 29 | } |
Antoine Pitrou | a762285 | 2011-09-01 21:37:43 +0200 | [diff] [blame] | 30 | printf(" default: return EINVAL;\n"); |
| 31 | printf(" }\n}\n"); |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 32 | } |