• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /* Errno module
3 
4     Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
5     This program and the accompanying materials are licensed and made available under
6     the terms and conditions of the BSD License that accompanies this distribution.
7     The full text of the license may be found at
8     http://opensource.org/licenses/bsd-license.
9 
10     THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11     WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 */
13 
14 #include "Python.h"
15 
16 /* Windows socket errors (WSA*)  */
17 #ifdef MS_WINDOWS
18 #include <windows.h>
19 #endif
20 
21 /*
22  * Pull in the system error definitions
23  */
24 
25 static PyMethodDef errno_methods[] = {
26     {NULL,              NULL}
27 };
28 
29 /* Helper function doing the dictionary inserting */
30 
31 static void
_inscode(PyObject * d,PyObject * de,char * name,int code)32 _inscode(PyObject *d, PyObject *de, char *name, int code)
33 {
34     PyObject *u = PyString_FromString(name);
35     PyObject *v = PyInt_FromLong((long) code);
36 
37     /* Don't bother checking for errors; they'll be caught at the end
38      * of the module initialization function by the caller of
39      * initerrno().
40      */
41     if (u && v) {
42         /* insert in modules dict */
43         PyDict_SetItem(d, u, v);
44         /* insert in errorcode dict */
45         PyDict_SetItem(de, v, u);
46     }
47     Py_XDECREF(u);
48     Py_XDECREF(v);
49 }
50 
51 PyDoc_STRVAR(errno__doc__,
52 "This module makes available standard errno system symbols.\n\
53 \n\
54 The value of each symbol is the corresponding integer value,\n\
55 e.g., on most systems, errno.ENOENT equals the integer 2.\n\
56 \n\
57 The dictionary errno.errorcode maps numeric codes to symbol names,\n\
58 e.g., errno.errorcode[2] could be the string 'ENOENT'.\n\
59 \n\
60 Symbols that are not relevant to the underlying system are not defined.\n\
61 \n\
62 To map error codes to error messages, use the function os.strerror(),\n\
63 e.g. os.strerror(2) could return 'No such file or directory'.");
64 
65 PyMODINIT_FUNC
initerrno(void)66 initerrno(void)
67 {
68     PyObject *m, *d, *de;
69     m = Py_InitModule3("errno", errno_methods, errno__doc__);
70     if (m == NULL)
71         return;
72     d = PyModule_GetDict(m);
73     de = PyDict_New();
74     if (!d || !de || PyDict_SetItemString(d, "errorcode", de) < 0)
75         return;
76 
77 /* Macro so I don't have to edit each and every line below... */
78 #define inscode(d, ds, de, name, code, comment) _inscode(d, de, name, code)
79 
80     /*
81      * The names and comments are borrowed from linux/include/errno.h,
82      * which should be pretty all-inclusive
83      */
84 
85 #ifdef ENODEV
86     inscode(d, ds, de, "ENODEV", ENODEV, "No such device");
87 #endif
88 #ifdef ENOCSI
89     inscode(d, ds, de, "ENOCSI", ENOCSI, "No CSI structure available");
90 #endif
91 #ifdef EHOSTUNREACH
92     inscode(d, ds, de, "EHOSTUNREACH", EHOSTUNREACH, "No route to host");
93 #else
94 #ifdef WSAEHOSTUNREACH
95     inscode(d, ds, de, "EHOSTUNREACH", WSAEHOSTUNREACH, "No route to host");
96 #endif
97 #endif
98 #ifdef ENOMSG
99     inscode(d, ds, de, "ENOMSG", ENOMSG, "No message of desired type");
100 #endif
101 #ifdef EUCLEAN
102     inscode(d, ds, de, "EUCLEAN", EUCLEAN, "Structure needs cleaning");
103 #endif
104 #ifdef EL2NSYNC
105     inscode(d, ds, de, "EL2NSYNC", EL2NSYNC, "Level 2 not synchronized");
106 #endif
107 #ifdef EL2HLT
108     inscode(d, ds, de, "EL2HLT", EL2HLT, "Level 2 halted");
109 #endif
110 #ifdef ENODATA
111     inscode(d, ds, de, "ENODATA", ENODATA, "No data available");
112 #endif
113 #ifdef ENOTBLK
114     inscode(d, ds, de, "ENOTBLK", ENOTBLK, "Block device required");
115 #endif
116 #ifdef ENOSYS
117     inscode(d, ds, de, "ENOSYS", ENOSYS, "Function not implemented");
118 #endif
119 #ifdef EPIPE
120     inscode(d, ds, de, "EPIPE", EPIPE, "Broken pipe");
121 #endif
122 #ifdef EINVAL
123     inscode(d, ds, de, "EINVAL", EINVAL, "Invalid argument");
124 #else
125 #ifdef WSAEINVAL
126     inscode(d, ds, de, "EINVAL", WSAEINVAL, "Invalid argument");
127 #endif
128 #endif
129 #ifdef EOVERFLOW
130     inscode(d, ds, de, "EOVERFLOW", EOVERFLOW, "Value too large for defined data type");
131 #endif
132 #ifdef EADV
133     inscode(d, ds, de, "EADV", EADV, "Advertise error");
134 #endif
135 #ifdef EINTR
136     inscode(d, ds, de, "EINTR", EINTR, "Interrupted system call");
137 #else
138 #ifdef WSAEINTR
139     inscode(d, ds, de, "EINTR", WSAEINTR, "Interrupted system call");
140 #endif
141 #endif
142 #ifdef EUSERS
143     inscode(d, ds, de, "EUSERS", EUSERS, "Too many users");
144 #else
145 #ifdef WSAEUSERS
146     inscode(d, ds, de, "EUSERS", WSAEUSERS, "Too many users");
147 #endif
148 #endif
149 #ifdef ENOTEMPTY
150     inscode(d, ds, de, "ENOTEMPTY", ENOTEMPTY, "Directory not empty");
151 #else
152 #ifdef WSAENOTEMPTY
153     inscode(d, ds, de, "ENOTEMPTY", WSAENOTEMPTY, "Directory not empty");
154 #endif
155 #endif
156 #ifdef ENOBUFS
157     inscode(d, ds, de, "ENOBUFS", ENOBUFS, "No buffer space available");
158 #else
159 #ifdef WSAENOBUFS
160     inscode(d, ds, de, "ENOBUFS", WSAENOBUFS, "No buffer space available");
161 #endif
162 #endif
163 #ifdef EPROTO
164     inscode(d, ds, de, "EPROTO", EPROTO, "Protocol error");
165 #endif
166 #ifdef EREMOTE
167     inscode(d, ds, de, "EREMOTE", EREMOTE, "Object is remote");
168 #else
169 #ifdef WSAEREMOTE
170     inscode(d, ds, de, "EREMOTE", WSAEREMOTE, "Object is remote");
171 #endif
172 #endif
173 #ifdef ENAVAIL
174     inscode(d, ds, de, "ENAVAIL", ENAVAIL, "No XENIX semaphores available");
175 #endif
176 #ifdef ECHILD
177     inscode(d, ds, de, "ECHILD", ECHILD, "No child processes");
178 #endif
179 #ifdef ELOOP
180     inscode(d, ds, de, "ELOOP", ELOOP, "Too many symbolic links encountered");
181 #else
182 #ifdef WSAELOOP
183     inscode(d, ds, de, "ELOOP", WSAELOOP, "Too many symbolic links encountered");
184 #endif
185 #endif
186 #ifdef EXDEV
187     inscode(d, ds, de, "EXDEV", EXDEV, "Cross-device link");
188 #endif
189 #ifdef E2BIG
190     inscode(d, ds, de, "E2BIG", E2BIG, "Arg list too long");
191 #endif
192 #ifdef ESRCH
193     inscode(d, ds, de, "ESRCH", ESRCH, "No such process");
194 #endif
195 #ifdef EMSGSIZE
196     inscode(d, ds, de, "EMSGSIZE", EMSGSIZE, "Message too long");
197 #else
198 #ifdef WSAEMSGSIZE
199     inscode(d, ds, de, "EMSGSIZE", WSAEMSGSIZE, "Message too long");
200 #endif
201 #endif
202 #ifdef EAFNOSUPPORT
203     inscode(d, ds, de, "EAFNOSUPPORT", EAFNOSUPPORT, "Address family not supported by protocol");
204 #else
205 #ifdef WSAEAFNOSUPPORT
206     inscode(d, ds, de, "EAFNOSUPPORT", WSAEAFNOSUPPORT, "Address family not supported by protocol");
207 #endif
208 #endif
209 #ifdef EBADR
210     inscode(d, ds, de, "EBADR", EBADR, "Invalid request descriptor");
211 #endif
212 #ifdef EHOSTDOWN
213     inscode(d, ds, de, "EHOSTDOWN", EHOSTDOWN, "Host is down");
214 #else
215 #ifdef WSAEHOSTDOWN
216     inscode(d, ds, de, "EHOSTDOWN", WSAEHOSTDOWN, "Host is down");
217 #endif
218 #endif
219 #ifdef EPFNOSUPPORT
220     inscode(d, ds, de, "EPFNOSUPPORT", EPFNOSUPPORT, "Protocol family not supported");
221 #else
222 #ifdef WSAEPFNOSUPPORT
223     inscode(d, ds, de, "EPFNOSUPPORT", WSAEPFNOSUPPORT, "Protocol family not supported");
224 #endif
225 #endif
226 #ifdef ENOPROTOOPT
227     inscode(d, ds, de, "ENOPROTOOPT", ENOPROTOOPT, "Protocol not available");
228 #else
229 #ifdef WSAENOPROTOOPT
230     inscode(d, ds, de, "ENOPROTOOPT", WSAENOPROTOOPT, "Protocol not available");
231 #endif
232 #endif
233 #ifdef EBUSY
234     inscode(d, ds, de, "EBUSY", EBUSY, "Device or resource busy");
235 #endif
236 #ifdef EWOULDBLOCK
237     inscode(d, ds, de, "EWOULDBLOCK", EWOULDBLOCK, "Operation would block");
238 #else
239 #ifdef WSAEWOULDBLOCK
240     inscode(d, ds, de, "EWOULDBLOCK", WSAEWOULDBLOCK, "Operation would block");
241 #endif
242 #endif
243 #ifdef EBADFD
244     inscode(d, ds, de, "EBADFD", EBADFD, "File descriptor in bad state");
245 #endif
246 #ifdef EDOTDOT
247     inscode(d, ds, de, "EDOTDOT", EDOTDOT, "RFS specific error");
248 #endif
249 #ifdef EISCONN
250     inscode(d, ds, de, "EISCONN", EISCONN, "Transport endpoint is already connected");
251 #else
252 #ifdef WSAEISCONN
253     inscode(d, ds, de, "EISCONN", WSAEISCONN, "Transport endpoint is already connected");
254 #endif
255 #endif
256 #ifdef ENOANO
257     inscode(d, ds, de, "ENOANO", ENOANO, "No anode");
258 #endif
259 #ifdef ESHUTDOWN
260     inscode(d, ds, de, "ESHUTDOWN", ESHUTDOWN, "Cannot send after transport endpoint shutdown");
261 #else
262 #ifdef WSAESHUTDOWN
263     inscode(d, ds, de, "ESHUTDOWN", WSAESHUTDOWN, "Cannot send after transport endpoint shutdown");
264 #endif
265 #endif
266 #ifdef ECHRNG
267     inscode(d, ds, de, "ECHRNG", ECHRNG, "Channel number out of range");
268 #endif
269 #ifdef ELIBBAD
270     inscode(d, ds, de, "ELIBBAD", ELIBBAD, "Accessing a corrupted shared library");
271 #endif
272 #ifdef ENONET
273     inscode(d, ds, de, "ENONET", ENONET, "Machine is not on the network");
274 #endif
275 #ifdef EBADE
276     inscode(d, ds, de, "EBADE", EBADE, "Invalid exchange");
277 #endif
278 #ifdef EBADF
279     inscode(d, ds, de, "EBADF", EBADF, "Bad file number");
280 #else
281 #ifdef WSAEBADF
282     inscode(d, ds, de, "EBADF", WSAEBADF, "Bad file number");
283 #endif
284 #endif
285 #ifdef EMULTIHOP
286     inscode(d, ds, de, "EMULTIHOP", EMULTIHOP, "Multihop attempted");
287 #endif
288 #ifdef EIO
289     inscode(d, ds, de, "EIO", EIO, "I/O error");
290 #endif
291 #ifdef EUNATCH
292     inscode(d, ds, de, "EUNATCH", EUNATCH, "Protocol driver not attached");
293 #endif
294 #ifdef EPROTOTYPE
295     inscode(d, ds, de, "EPROTOTYPE", EPROTOTYPE, "Protocol wrong type for socket");
296 #else
297 #ifdef WSAEPROTOTYPE
298     inscode(d, ds, de, "EPROTOTYPE", WSAEPROTOTYPE, "Protocol wrong type for socket");
299 #endif
300 #endif
301 #ifdef ENOSPC
302     inscode(d, ds, de, "ENOSPC", ENOSPC, "No space left on device");
303 #endif
304 #ifdef ENOEXEC
305     inscode(d, ds, de, "ENOEXEC", ENOEXEC, "Exec format error");
306 #endif
307 #ifdef EALREADY
308     inscode(d, ds, de, "EALREADY", EALREADY, "Operation already in progress");
309 #else
310 #ifdef WSAEALREADY
311     inscode(d, ds, de, "EALREADY", WSAEALREADY, "Operation already in progress");
312 #endif
313 #endif
314 #ifdef ENETDOWN
315     inscode(d, ds, de, "ENETDOWN", ENETDOWN, "Network is down");
316 #else
317 #ifdef WSAENETDOWN
318     inscode(d, ds, de, "ENETDOWN", WSAENETDOWN, "Network is down");
319 #endif
320 #endif
321 #ifdef ENOTNAM
322     inscode(d, ds, de, "ENOTNAM", ENOTNAM, "Not a XENIX named type file");
323 #endif
324 #ifdef EACCES
325     inscode(d, ds, de, "EACCES", EACCES, "Permission denied");
326 #else
327 #ifdef WSAEACCES
328     inscode(d, ds, de, "EACCES", WSAEACCES, "Permission denied");
329 #endif
330 #endif
331 #ifdef ELNRNG
332     inscode(d, ds, de, "ELNRNG", ELNRNG, "Link number out of range");
333 #endif
334 #ifdef EILSEQ
335     inscode(d, ds, de, "EILSEQ", EILSEQ, "Illegal byte sequence");
336 #endif
337 #ifdef ENOTDIR
338     inscode(d, ds, de, "ENOTDIR", ENOTDIR, "Not a directory");
339 #endif
340 #ifdef ENOTUNIQ
341     inscode(d, ds, de, "ENOTUNIQ", ENOTUNIQ, "Name not unique on network");
342 #endif
343 #ifdef EPERM
344     inscode(d, ds, de, "EPERM", EPERM, "Operation not permitted");
345 #endif
346 #ifdef EDOM
347     inscode(d, ds, de, "EDOM", EDOM, "Math argument out of domain of func");
348 #endif
349 #ifdef EXFULL
350     inscode(d, ds, de, "EXFULL", EXFULL, "Exchange full");
351 #endif
352 #ifdef ECONNREFUSED
353     inscode(d, ds, de, "ECONNREFUSED", ECONNREFUSED, "Connection refused");
354 #else
355 #ifdef WSAECONNREFUSED
356     inscode(d, ds, de, "ECONNREFUSED", WSAECONNREFUSED, "Connection refused");
357 #endif
358 #endif
359 #ifdef EISDIR
360     inscode(d, ds, de, "EISDIR", EISDIR, "Is a directory");
361 #endif
362 #ifdef EPROTONOSUPPORT
363     inscode(d, ds, de, "EPROTONOSUPPORT", EPROTONOSUPPORT, "Protocol not supported");
364 #else
365 #ifdef WSAEPROTONOSUPPORT
366     inscode(d, ds, de, "EPROTONOSUPPORT", WSAEPROTONOSUPPORT, "Protocol not supported");
367 #endif
368 #endif
369 #ifdef EROFS
370     inscode(d, ds, de, "EROFS", EROFS, "Read-only file system");
371 #endif
372 #ifdef EADDRNOTAVAIL
373     inscode(d, ds, de, "EADDRNOTAVAIL", EADDRNOTAVAIL, "Cannot assign requested address");
374 #else
375 #ifdef WSAEADDRNOTAVAIL
376     inscode(d, ds, de, "EADDRNOTAVAIL", WSAEADDRNOTAVAIL, "Cannot assign requested address");
377 #endif
378 #endif
379 #ifdef EIDRM
380     inscode(d, ds, de, "EIDRM", EIDRM, "Identifier removed");
381 #endif
382 #ifdef ECOMM
383     inscode(d, ds, de, "ECOMM", ECOMM, "Communication error on send");
384 #endif
385 #ifdef ESRMNT
386     inscode(d, ds, de, "ESRMNT", ESRMNT, "Srmount error");
387 #endif
388 #ifdef EREMOTEIO
389     inscode(d, ds, de, "EREMOTEIO", EREMOTEIO, "Remote I/O error");
390 #endif
391 #ifdef EL3RST
392     inscode(d, ds, de, "EL3RST", EL3RST, "Level 3 reset");
393 #endif
394 #ifdef EBADMSG
395     inscode(d, ds, de, "EBADMSG", EBADMSG, "Not a data message");
396 #endif
397 #ifdef ENFILE
398     inscode(d, ds, de, "ENFILE", ENFILE, "File table overflow");
399 #endif
400 #ifdef ELIBMAX
401     inscode(d, ds, de, "ELIBMAX", ELIBMAX, "Attempting to link in too many shared libraries");
402 #endif
403 #ifdef ESPIPE
404     inscode(d, ds, de, "ESPIPE", ESPIPE, "Illegal seek");
405 #endif
406 #ifdef ENOLINK
407     inscode(d, ds, de, "ENOLINK", ENOLINK, "Link has been severed");
408 #endif
409 #ifdef ENETRESET
410     inscode(d, ds, de, "ENETRESET", ENETRESET, "Network dropped connection because of reset");
411 #else
412 #ifdef WSAENETRESET
413     inscode(d, ds, de, "ENETRESET", WSAENETRESET, "Network dropped connection because of reset");
414 #endif
415 #endif
416 #ifdef ETIMEDOUT
417     inscode(d, ds, de, "ETIMEDOUT", ETIMEDOUT, "Connection timed out");
418 #else
419 #ifdef WSAETIMEDOUT
420     inscode(d, ds, de, "ETIMEDOUT", WSAETIMEDOUT, "Connection timed out");
421 #endif
422 #endif
423 #ifdef ENOENT
424     inscode(d, ds, de, "ENOENT", ENOENT, "No such file or directory");
425 #endif
426 #ifdef EEXIST
427     inscode(d, ds, de, "EEXIST", EEXIST, "File exists");
428 #endif
429 #ifdef EDQUOT
430     inscode(d, ds, de, "EDQUOT", EDQUOT, "Quota exceeded");
431 #else
432 #ifdef WSAEDQUOT
433     inscode(d, ds, de, "EDQUOT", WSAEDQUOT, "Quota exceeded");
434 #endif
435 #endif
436 #ifdef ENOSTR
437     inscode(d, ds, de, "ENOSTR", ENOSTR, "Device not a stream");
438 #endif
439 #ifdef EBADSLT
440     inscode(d, ds, de, "EBADSLT", EBADSLT, "Invalid slot");
441 #endif
442 #ifdef EBADRQC
443     inscode(d, ds, de, "EBADRQC", EBADRQC, "Invalid request code");
444 #endif
445 #ifdef ELIBACC
446     inscode(d, ds, de, "ELIBACC", ELIBACC, "Can not access a needed shared library");
447 #endif
448 #ifdef EFAULT
449     inscode(d, ds, de, "EFAULT", EFAULT, "Bad address");
450 #else
451 #ifdef WSAEFAULT
452     inscode(d, ds, de, "EFAULT", WSAEFAULT, "Bad address");
453 #endif
454 #endif
455 #ifdef EFBIG
456     inscode(d, ds, de, "EFBIG", EFBIG, "File too large");
457 #endif
458 #ifdef EDEADLK
459     inscode(d, ds, de, "EDEADLK", EDEADLK, "Resource deadlock would occur");
460 #endif
461 #ifdef ENOTCONN
462     inscode(d, ds, de, "ENOTCONN", ENOTCONN, "Transport endpoint is not connected");
463 #else
464 #ifdef WSAENOTCONN
465     inscode(d, ds, de, "ENOTCONN", WSAENOTCONN, "Transport endpoint is not connected");
466 #endif
467 #endif
468 #ifdef EDESTADDRREQ
469     inscode(d, ds, de, "EDESTADDRREQ", EDESTADDRREQ, "Destination address required");
470 #else
471 #ifdef WSAEDESTADDRREQ
472     inscode(d, ds, de, "EDESTADDRREQ", WSAEDESTADDRREQ, "Destination address required");
473 #endif
474 #endif
475 #ifdef ELIBSCN
476     inscode(d, ds, de, "ELIBSCN", ELIBSCN, ".lib section in a.out corrupted");
477 #endif
478 #ifdef ENOLCK
479     inscode(d, ds, de, "ENOLCK", ENOLCK, "No record locks available");
480 #endif
481 #ifdef EISNAM
482     inscode(d, ds, de, "EISNAM", EISNAM, "Is a named type file");
483 #endif
484 #ifdef ECONNABORTED
485     inscode(d, ds, de, "ECONNABORTED", ECONNABORTED, "Software caused connection abort");
486 #else
487 #ifdef WSAECONNABORTED
488     inscode(d, ds, de, "ECONNABORTED", WSAECONNABORTED, "Software caused connection abort");
489 #endif
490 #endif
491 #ifdef ENETUNREACH
492     inscode(d, ds, de, "ENETUNREACH", ENETUNREACH, "Network is unreachable");
493 #else
494 #ifdef WSAENETUNREACH
495     inscode(d, ds, de, "ENETUNREACH", WSAENETUNREACH, "Network is unreachable");
496 #endif
497 #endif
498 #ifdef ESTALE
499     inscode(d, ds, de, "ESTALE", ESTALE, "Stale NFS file handle");
500 #else
501 #ifdef WSAESTALE
502     inscode(d, ds, de, "ESTALE", WSAESTALE, "Stale NFS file handle");
503 #endif
504 #endif
505 #ifdef ENOSR
506     inscode(d, ds, de, "ENOSR", ENOSR, "Out of streams resources");
507 #endif
508 #ifdef ENOMEM
509     inscode(d, ds, de, "ENOMEM", ENOMEM, "Out of memory");
510 #endif
511 #ifdef ENOTSOCK
512     inscode(d, ds, de, "ENOTSOCK", ENOTSOCK, "Socket operation on non-socket");
513 #else
514 #ifdef WSAENOTSOCK
515     inscode(d, ds, de, "ENOTSOCK", WSAENOTSOCK, "Socket operation on non-socket");
516 #endif
517 #endif
518 #ifdef ESTRPIPE
519     inscode(d, ds, de, "ESTRPIPE", ESTRPIPE, "Streams pipe error");
520 #endif
521 #ifdef EMLINK
522     inscode(d, ds, de, "EMLINK", EMLINK, "Too many links");
523 #endif
524 #ifdef ERANGE
525     inscode(d, ds, de, "ERANGE", ERANGE, "Math result not representable");
526 #endif
527 #ifdef ELIBEXEC
528     inscode(d, ds, de, "ELIBEXEC", ELIBEXEC, "Cannot exec a shared library directly");
529 #endif
530 #ifdef EL3HLT
531     inscode(d, ds, de, "EL3HLT", EL3HLT, "Level 3 halted");
532 #endif
533 #ifdef ECONNRESET
534     inscode(d, ds, de, "ECONNRESET", ECONNRESET, "Connection reset by peer");
535 #else
536 #ifdef WSAECONNRESET
537     inscode(d, ds, de, "ECONNRESET", WSAECONNRESET, "Connection reset by peer");
538 #endif
539 #endif
540 #ifdef EADDRINUSE
541     inscode(d, ds, de, "EADDRINUSE", EADDRINUSE, "Address already in use");
542 #else
543 #ifdef WSAEADDRINUSE
544     inscode(d, ds, de, "EADDRINUSE", WSAEADDRINUSE, "Address already in use");
545 #endif
546 #endif
547 #ifdef EOPNOTSUPP
548     inscode(d, ds, de, "EOPNOTSUPP", EOPNOTSUPP, "Operation not supported on transport endpoint");
549 #else
550 #ifdef WSAEOPNOTSUPP
551     inscode(d, ds, de, "EOPNOTSUPP", WSAEOPNOTSUPP, "Operation not supported on transport endpoint");
552 #endif
553 #endif
554 #ifdef EREMCHG
555     inscode(d, ds, de, "EREMCHG", EREMCHG, "Remote address changed");
556 #endif
557 #ifdef EAGAIN
558     inscode(d, ds, de, "EAGAIN", EAGAIN, "Try again");
559 #endif
560 #ifdef ENAMETOOLONG
561     inscode(d, ds, de, "ENAMETOOLONG", ENAMETOOLONG, "File name too long");
562 #else
563 #ifdef WSAENAMETOOLONG
564     inscode(d, ds, de, "ENAMETOOLONG", WSAENAMETOOLONG, "File name too long");
565 #endif
566 #endif
567 #ifdef ENOTTY
568     inscode(d, ds, de, "ENOTTY", ENOTTY, "Not a typewriter");
569 #endif
570 #ifdef ERESTART
571     inscode(d, ds, de, "ERESTART", ERESTART, "Interrupted system call should be restarted");
572 #endif
573 #ifdef ESOCKTNOSUPPORT
574     inscode(d, ds, de, "ESOCKTNOSUPPORT", ESOCKTNOSUPPORT, "Socket type not supported");
575 #else
576 #ifdef WSAESOCKTNOSUPPORT
577     inscode(d, ds, de, "ESOCKTNOSUPPORT", WSAESOCKTNOSUPPORT, "Socket type not supported");
578 #endif
579 #endif
580 #ifdef ETIME
581     inscode(d, ds, de, "ETIME", ETIME, "Timer expired");
582 #endif
583 #ifdef EBFONT
584     inscode(d, ds, de, "EBFONT", EBFONT, "Bad font file format");
585 #endif
586 #ifdef EDEADLOCK
587     inscode(d, ds, de, "EDEADLOCK", EDEADLOCK, "Error EDEADLOCK");
588 #endif
589 #ifdef ETOOMANYREFS
590     inscode(d, ds, de, "ETOOMANYREFS", ETOOMANYREFS, "Too many references: cannot splice");
591 #else
592 #ifdef WSAETOOMANYREFS
593     inscode(d, ds, de, "ETOOMANYREFS", WSAETOOMANYREFS, "Too many references: cannot splice");
594 #endif
595 #endif
596 #ifdef EMFILE
597     inscode(d, ds, de, "EMFILE", EMFILE, "Too many open files");
598 #else
599 #ifdef WSAEMFILE
600     inscode(d, ds, de, "EMFILE", WSAEMFILE, "Too many open files");
601 #endif
602 #endif
603 #ifdef ETXTBSY
604     inscode(d, ds, de, "ETXTBSY", ETXTBSY, "Text file busy");
605 #endif
606 #ifdef EINPROGRESS
607     inscode(d, ds, de, "EINPROGRESS", EINPROGRESS, "Operation now in progress");
608 #else
609 #ifdef WSAEINPROGRESS
610     inscode(d, ds, de, "EINPROGRESS", WSAEINPROGRESS, "Operation now in progress");
611 #endif
612 #endif
613 #ifdef ENXIO
614     inscode(d, ds, de, "ENXIO", ENXIO, "No such device or address");
615 #endif
616 #ifdef ENOPKG
617     inscode(d, ds, de, "ENOPKG", ENOPKG, "Package not installed");
618 #endif
619 #ifdef WSASY
620     inscode(d, ds, de, "WSASY", WSASY, "Error WSASY");
621 #endif
622 #ifdef WSAEHOSTDOWN
623     inscode(d, ds, de, "WSAEHOSTDOWN", WSAEHOSTDOWN, "Host is down");
624 #endif
625 #ifdef WSAENETDOWN
626     inscode(d, ds, de, "WSAENETDOWN", WSAENETDOWN, "Network is down");
627 #endif
628 #ifdef WSAENOTSOCK
629     inscode(d, ds, de, "WSAENOTSOCK", WSAENOTSOCK, "Socket operation on non-socket");
630 #endif
631 #ifdef WSAEHOSTUNREACH
632     inscode(d, ds, de, "WSAEHOSTUNREACH", WSAEHOSTUNREACH, "No route to host");
633 #endif
634 #ifdef WSAELOOP
635     inscode(d, ds, de, "WSAELOOP", WSAELOOP, "Too many symbolic links encountered");
636 #endif
637 #ifdef WSAEMFILE
638     inscode(d, ds, de, "WSAEMFILE", WSAEMFILE, "Too many open files");
639 #endif
640 #ifdef WSAESTALE
641     inscode(d, ds, de, "WSAESTALE", WSAESTALE, "Stale NFS file handle");
642 #endif
643 #ifdef WSAVERNOTSUPPORTED
644     inscode(d, ds, de, "WSAVERNOTSUPPORTED", WSAVERNOTSUPPORTED, "Error WSAVERNOTSUPPORTED");
645 #endif
646 #ifdef WSAENETUNREACH
647     inscode(d, ds, de, "WSAENETUNREACH", WSAENETUNREACH, "Network is unreachable");
648 #endif
649 #ifdef WSAEPROCLIM
650     inscode(d, ds, de, "WSAEPROCLIM", WSAEPROCLIM, "Error WSAEPROCLIM");
651 #endif
652 #ifdef WSAEFAULT
653     inscode(d, ds, de, "WSAEFAULT", WSAEFAULT, "Bad address");
654 #endif
655 #ifdef WSANOTINITIALISED
656     inscode(d, ds, de, "WSANOTINITIALISED", WSANOTINITIALISED, "Error WSANOTINITIALISED");
657 #endif
658 #ifdef WSAEUSERS
659     inscode(d, ds, de, "WSAEUSERS", WSAEUSERS, "Too many users");
660 #endif
661 #ifdef WSAMAKEASYNCREPL
662     inscode(d, ds, de, "WSAMAKEASYNCREPL", WSAMAKEASYNCREPL, "Error WSAMAKEASYNCREPL");
663 #endif
664 #ifdef WSAENOPROTOOPT
665     inscode(d, ds, de, "WSAENOPROTOOPT", WSAENOPROTOOPT, "Protocol not available");
666 #endif
667 #ifdef WSAECONNABORTED
668     inscode(d, ds, de, "WSAECONNABORTED", WSAECONNABORTED, "Software caused connection abort");
669 #endif
670 #ifdef WSAENAMETOOLONG
671     inscode(d, ds, de, "WSAENAMETOOLONG", WSAENAMETOOLONG, "File name too long");
672 #endif
673 #ifdef WSAENOTEMPTY
674     inscode(d, ds, de, "WSAENOTEMPTY", WSAENOTEMPTY, "Directory not empty");
675 #endif
676 #ifdef WSAESHUTDOWN
677     inscode(d, ds, de, "WSAESHUTDOWN", WSAESHUTDOWN, "Cannot send after transport endpoint shutdown");
678 #endif
679 #ifdef WSAEAFNOSUPPORT
680     inscode(d, ds, de, "WSAEAFNOSUPPORT", WSAEAFNOSUPPORT, "Address family not supported by protocol");
681 #endif
682 #ifdef WSAETOOMANYREFS
683     inscode(d, ds, de, "WSAETOOMANYREFS", WSAETOOMANYREFS, "Too many references: cannot splice");
684 #endif
685 #ifdef WSAEACCES
686     inscode(d, ds, de, "WSAEACCES", WSAEACCES, "Permission denied");
687 #endif
688 #ifdef WSATR
689     inscode(d, ds, de, "WSATR", WSATR, "Error WSATR");
690 #endif
691 #ifdef WSABASEERR
692     inscode(d, ds, de, "WSABASEERR", WSABASEERR, "Error WSABASEERR");
693 #endif
694 #ifdef WSADESCRIPTIO
695     inscode(d, ds, de, "WSADESCRIPTIO", WSADESCRIPTIO, "Error WSADESCRIPTIO");
696 #endif
697 #ifdef WSAEMSGSIZE
698     inscode(d, ds, de, "WSAEMSGSIZE", WSAEMSGSIZE, "Message too long");
699 #endif
700 #ifdef WSAEBADF
701     inscode(d, ds, de, "WSAEBADF", WSAEBADF, "Bad file number");
702 #endif
703 #ifdef WSAECONNRESET
704     inscode(d, ds, de, "WSAECONNRESET", WSAECONNRESET, "Connection reset by peer");
705 #endif
706 #ifdef WSAGETSELECTERRO
707     inscode(d, ds, de, "WSAGETSELECTERRO", WSAGETSELECTERRO, "Error WSAGETSELECTERRO");
708 #endif
709 #ifdef WSAETIMEDOUT
710     inscode(d, ds, de, "WSAETIMEDOUT", WSAETIMEDOUT, "Connection timed out");
711 #endif
712 #ifdef WSAENOBUFS
713     inscode(d, ds, de, "WSAENOBUFS", WSAENOBUFS, "No buffer space available");
714 #endif
715 #ifdef WSAEDISCON
716     inscode(d, ds, de, "WSAEDISCON", WSAEDISCON, "Error WSAEDISCON");
717 #endif
718 #ifdef WSAEINTR
719     inscode(d, ds, de, "WSAEINTR", WSAEINTR, "Interrupted system call");
720 #endif
721 #ifdef WSAEPROTOTYPE
722     inscode(d, ds, de, "WSAEPROTOTYPE", WSAEPROTOTYPE, "Protocol wrong type for socket");
723 #endif
724 #ifdef WSAHOS
725     inscode(d, ds, de, "WSAHOS", WSAHOS, "Error WSAHOS");
726 #endif
727 #ifdef WSAEADDRINUSE
728     inscode(d, ds, de, "WSAEADDRINUSE", WSAEADDRINUSE, "Address already in use");
729 #endif
730 #ifdef WSAEADDRNOTAVAIL
731     inscode(d, ds, de, "WSAEADDRNOTAVAIL", WSAEADDRNOTAVAIL, "Cannot assign requested address");
732 #endif
733 #ifdef WSAEALREADY
734     inscode(d, ds, de, "WSAEALREADY", WSAEALREADY, "Operation already in progress");
735 #endif
736 #ifdef WSAEPROTONOSUPPORT
737     inscode(d, ds, de, "WSAEPROTONOSUPPORT", WSAEPROTONOSUPPORT, "Protocol not supported");
738 #endif
739 #ifdef WSASYSNOTREADY
740     inscode(d, ds, de, "WSASYSNOTREADY", WSASYSNOTREADY, "Error WSASYSNOTREADY");
741 #endif
742 #ifdef WSAEWOULDBLOCK
743     inscode(d, ds, de, "WSAEWOULDBLOCK", WSAEWOULDBLOCK, "Operation would block");
744 #endif
745 #ifdef WSAEPFNOSUPPORT
746     inscode(d, ds, de, "WSAEPFNOSUPPORT", WSAEPFNOSUPPORT, "Protocol family not supported");
747 #endif
748 #ifdef WSAEOPNOTSUPP
749     inscode(d, ds, de, "WSAEOPNOTSUPP", WSAEOPNOTSUPP, "Operation not supported on transport endpoint");
750 #endif
751 #ifdef WSAEISCONN
752     inscode(d, ds, de, "WSAEISCONN", WSAEISCONN, "Transport endpoint is already connected");
753 #endif
754 #ifdef WSAEDQUOT
755     inscode(d, ds, de, "WSAEDQUOT", WSAEDQUOT, "Quota exceeded");
756 #endif
757 #ifdef WSAENOTCONN
758     inscode(d, ds, de, "WSAENOTCONN", WSAENOTCONN, "Transport endpoint is not connected");
759 #endif
760 #ifdef WSAEREMOTE
761     inscode(d, ds, de, "WSAEREMOTE", WSAEREMOTE, "Object is remote");
762 #endif
763 #ifdef WSAEINVAL
764     inscode(d, ds, de, "WSAEINVAL", WSAEINVAL, "Invalid argument");
765 #endif
766 #ifdef WSAEINPROGRESS
767     inscode(d, ds, de, "WSAEINPROGRESS", WSAEINPROGRESS, "Operation now in progress");
768 #endif
769 #ifdef WSAGETSELECTEVEN
770     inscode(d, ds, de, "WSAGETSELECTEVEN", WSAGETSELECTEVEN, "Error WSAGETSELECTEVEN");
771 #endif
772 #ifdef WSAESOCKTNOSUPPORT
773     inscode(d, ds, de, "WSAESOCKTNOSUPPORT", WSAESOCKTNOSUPPORT, "Socket type not supported");
774 #endif
775 #ifdef WSAGETASYNCERRO
776     inscode(d, ds, de, "WSAGETASYNCERRO", WSAGETASYNCERRO, "Error WSAGETASYNCERRO");
777 #endif
778 #ifdef WSAMAKESELECTREPL
779     inscode(d, ds, de, "WSAMAKESELECTREPL", WSAMAKESELECTREPL, "Error WSAMAKESELECTREPL");
780 #endif
781 #ifdef WSAGETASYNCBUFLE
782     inscode(d, ds, de, "WSAGETASYNCBUFLE", WSAGETASYNCBUFLE, "Error WSAGETASYNCBUFLE");
783 #endif
784 #ifdef WSAEDESTADDRREQ
785     inscode(d, ds, de, "WSAEDESTADDRREQ", WSAEDESTADDRREQ, "Destination address required");
786 #endif
787 #ifdef WSAECONNREFUSED
788     inscode(d, ds, de, "WSAECONNREFUSED", WSAECONNREFUSED, "Connection refused");
789 #endif
790 #ifdef WSAENETRESET
791     inscode(d, ds, de, "WSAENETRESET", WSAENETRESET, "Network dropped connection because of reset");
792 #endif
793 #ifdef WSAN
794     inscode(d, ds, de, "WSAN", WSAN, "Error WSAN");
795 #endif
796 
797 /* These symbols are added for EDK II support.  */
798 #ifdef EMINERRORVAL
799   inscode(d, ds, de, "EMINERRORVAL", EMINERRORVAL, "Lowest valid error value");
800 #endif
801 #ifdef ENOTSUP
802   inscode(d, ds, de, "ENOTSUP", ENOTSUP, "Operation not supported");
803 #endif
804 #ifdef EBADRPC
805   inscode(d, ds, de, "EBADRPC", EBADRPC, "RPC struct is bad");
806 #endif
807 #ifdef ERPCMISMATCH
808   inscode(d, ds, de, "ERPCMISMATCH", ERPCMISMATCH, "RPC version wrong");
809 #endif
810 #ifdef EPROGUNAVAIL
811   inscode(d, ds, de, "EPROGUNAVAIL", EPROGUNAVAIL, "RPC prog. not avail");
812 #endif
813 #ifdef EPROGMISMATCH
814   inscode(d, ds, de, "EPROGMISMATCH", EPROGMISMATCH, "Program version wrong");
815 #endif
816 #ifdef EPROCUNAVAIL
817   inscode(d, ds, de, "EPROCUNAVAIL", EPROCUNAVAIL, "Bad procedure for program");
818 #endif
819 #ifdef EFTYPE
820   inscode(d, ds, de, "EFTYPE", EFTYPE, "Inappropriate file type or format");
821 #endif
822 #ifdef EAUTH
823   inscode(d, ds, de, "EAUTH", EAUTH, "Authentication error");
824 #endif
825 #ifdef ENEEDAUTH
826   inscode(d, ds, de, "ENEEDAUTH", ENEEDAUTH, "Need authenticator");
827 #endif
828 #ifdef ECANCELED
829   inscode(d, ds, de, "ECANCELED", ECANCELED, "Operation canceled");
830 #endif
831 #ifdef ENOATTR
832   inscode(d, ds, de, "ENOATTR", ENOATTR, "Attribute not found");
833 #endif
834 #ifdef EDOOFUS
835   inscode(d, ds, de, "EDOOFUS", EDOOFUS, "Programming Error");
836 #endif
837 #ifdef EBUFSIZE
838   inscode(d, ds, de, "EBUFSIZE", EBUFSIZE, "Buffer too small to hold result");
839 #endif
840 #ifdef EMAXERRORVAL
841   inscode(d, ds, de, "EMAXERRORVAL", EMAXERRORVAL, "One more than the highest defined error value");
842 #endif
843 
844     Py_DECREF(de);
845 }
846