1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
|
/* Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: J.Wielemaker@vu.nl
WWW: http://www.swi-prolog.org
Copyright (c) 2019, VU University Amsterdam
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Below are the error codes as defined in Linux, which we hope is a
superset for most POSIX systems. They are converted using
`scripts/esymbols.pl` in SWI-Prolog's main repository and based on
- errno -l
- man gai_strerror, extracted by pattern
- man hstrerror, extracted by hand
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
typedef struct error_symbol_t
{ int code;
char *symbol;
} error_symbol_t;
static const char *
error_symbol(int code, const error_symbol_t *set)
{ const error_symbol_t *es;
static char tmp[100];
for(es=set; es->code; es++)
{ if ( es->code == code )
return es->symbol;
}
sprintf(tmp, "ERROR_%d", code);
return (const char*) tmp;
}
#ifdef __WINDOWS__
static const error_symbol_t wsa_errno_symbols[] =
{
#ifdef WSAEACCES
{ WSAEACCES, "wsaeacces" },
#endif
#ifdef WSAEADDRINUSE
{ WSAEADDRINUSE, "wsaeaddrinuse" },
#endif
#ifdef WSAEADDRNOTAVAIL
{ WSAEADDRNOTAVAIL, "wsaeaddrnotavail" },
#endif
#ifdef WSAEAFNOSUPPORT
{ WSAEAFNOSUPPORT, "wsaeafnosupport" },
#endif
#ifdef WSAEALREADY
{ WSAEALREADY, "wsaealready" },
#endif
#ifdef WSAECONNABORTED
{ WSAECONNABORTED, "wsaeconnaborted" },
#endif
#ifdef WSAECONNREFUSED
{ WSAECONNREFUSED, "wsaeconnrefused" },
#endif
#ifdef WSAECONNRESET
{ WSAECONNRESET, "wsaeconnreset" },
#endif
#ifdef WSAEDESTADDRREQ
{ WSAEDESTADDRREQ, "wsaedestaddrreq" },
#endif
#ifdef WSAEFAULT
{ WSAEFAULT, "wsaefault" },
#endif
#ifdef WSAEHOSTDOWN
{ WSAEHOSTDOWN, "wsaehostdown" },
#endif
#ifdef WSAEHOSTUNREACH
{ WSAEHOSTUNREACH, "wsaehostunreach" },
#endif
#ifdef WSAEINPROGRESS
{ WSAEINPROGRESS, "wsaeinprogress" },
#endif
#ifdef WSAEINTR
{ WSAEINTR, "wsaeintr" },
#endif
#ifdef WSAEINVAL
{ WSAEINVAL, "wsaeinval" },
#endif
#ifdef WSAEISCONN
{ WSAEISCONN, "wsaeisconn" },
#endif
#ifdef WSAEMFILE
{ WSAEMFILE, "wsaemfile" },
#endif
#ifdef WSAEMSGSIZE
{ WSAEMSGSIZE, "wsaemsgsize" },
#endif
#ifdef WSAENETDOWN
{ WSAENETDOWN, "wsaenetdown" },
#endif
#ifdef WSAENETRESET
{ WSAENETRESET, "wsaenetreset" },
#endif
#ifdef WSAENETUNREACH
{ WSAENETUNREACH, "wsaenetunreach" },
#endif
#ifdef WSAENOBUFS
{ WSAENOBUFS, "wsaenobufs" },
#endif
#ifdef WSAENOPROTOOPT
{ WSAENOPROTOOPT, "wsaenoprotoopt" },
#endif
#ifdef WSAENOTCONN
{ WSAENOTCONN, "wsaenotconn" },
#endif
#ifdef WSAENOTSOCK
{ WSAENOTSOCK, "wsaenotsock" },
#endif
#ifdef WSAEOPNOTSUPP
{ WSAEOPNOTSUPP, "wsaeopnotsupp" },
#endif
#ifdef WSAEPFNOSUPPORT
{ WSAEPFNOSUPPORT, "wsaepfnosupport" },
#endif
#ifdef WSAEPROCLIM
{ WSAEPROCLIM, "wsaeproclim" },
#endif
#ifdef WSAEPROTONOSUPPORT
{ WSAEPROTONOSUPPORT, "wsaeprotonosupport" },
#endif
#ifdef WSAEPROTOTYPE
{ WSAEPROTOTYPE, "wsaeprototype" },
#endif
#ifdef WSAESHUTDOWN
{ WSAESHUTDOWN, "wsaeshutdown" },
#endif
#ifdef WSAESOCKTNOSUPPORT
{ WSAESOCKTNOSUPPORT, "wsaesocktnosupport" },
#endif
#ifdef WSAETIMEDOUT
{ WSAETIMEDOUT, "wsaetimedout" },
#endif
#ifdef WSAEWOULDBLOCK
{ WSAEWOULDBLOCK, "wsaewouldblock" },
#endif
#ifdef WSAEDISCON
{ WSAEDISCON, "wsaediscon" },
#endif
#ifdef WSANOTINITIALISED
{ WSANOTINITIALISED, "wsanotinitialised" },
#endif
#ifdef WSAHOST_NOT_FOUND
{ WSAHOST_NOT_FOUND, "wsahost_not_found" },
#endif
#ifdef WSANO_DATA
{ WSANO_DATA, "wsano_data" },
#endif
{ 0, NULL }
};
#else /*__WINDOWS__*/
static const error_symbol_t errno_symbols[] =
{
#ifdef EPERM
{ EPERM, "eperm" },
#endif
#ifdef ENOENT
{ ENOENT, "enoent" },
#endif
#ifdef ESRCH
{ ESRCH, "esrch" },
#endif
#ifdef EINTR
{ EINTR, "eintr" },
#endif
#ifdef EIO
{ EIO, "eio" },
#endif
#ifdef ENXIO
{ ENXIO, "enxio" },
#endif
#ifdef E2BIG
{ E2BIG, "e2big" },
#endif
#ifdef ENOEXEC
{ ENOEXEC, "enoexec" },
#endif
#ifdef EBADF
{ EBADF, "ebadf" },
#endif
#ifdef ECHILD
{ ECHILD, "echild" },
#endif
#ifdef EAGAIN
{ EAGAIN, "eagain" },
#endif
#ifdef ENOMEM
{ ENOMEM, "enomem" },
#endif
#ifdef EACCES
{ EACCES, "eacces" },
#endif
#ifdef EFAULT
{ EFAULT, "efault" },
#endif
#ifdef ENOTBLK
{ ENOTBLK, "enotblk" },
#endif
#ifdef EBUSY
{ EBUSY, "ebusy" },
#endif
#ifdef EEXIST
{ EEXIST, "eexist" },
#endif
#ifdef EXDEV
{ EXDEV, "exdev" },
#endif
#ifdef ENODEV
{ ENODEV, "enodev" },
#endif
#ifdef ENOTDIR
{ ENOTDIR, "enotdir" },
#endif
#ifdef EISDIR
{ EISDIR, "eisdir" },
#endif
#ifdef EINVAL
{ EINVAL, "einval" },
#endif
#ifdef ENFILE
{ ENFILE, "enfile" },
#endif
#ifdef EMFILE
{ EMFILE, "emfile" },
#endif
#ifdef ENOTTY
{ ENOTTY, "enotty" },
#endif
#ifdef ETXTBSY
{ ETXTBSY, "etxtbsy" },
#endif
#ifdef EFBIG
{ EFBIG, "efbig" },
#endif
#ifdef ENOSPC
{ ENOSPC, "enospc" },
#endif
#ifdef ESPIPE
{ ESPIPE, "espipe" },
#endif
#ifdef EROFS
{ EROFS, "erofs" },
#endif
#ifdef EMLINK
{ EMLINK, "emlink" },
#endif
#ifdef EPIPE
{ EPIPE, "epipe" },
#endif
#ifdef EDOM
{ EDOM, "edom" },
#endif
#ifdef ERANGE
{ ERANGE, "erange" },
#endif
#ifdef EDEADLK
{ EDEADLK, "edeadlk" },
#endif
#ifdef ENAMETOOLONG
{ ENAMETOOLONG, "enametoolong" },
#endif
#ifdef ENOLCK
{ ENOLCK, "enolck" },
#endif
#ifdef ENOSYS
{ ENOSYS, "enosys" },
#endif
#ifdef ENOTEMPTY
{ ENOTEMPTY, "enotempty" },
#endif
#ifdef ELOOP
{ ELOOP, "eloop" },
#endif
#ifdef EWOULDBLOCK
{ EWOULDBLOCK, "ewouldblock" },
#endif
#ifdef ENOMSG
{ ENOMSG, "enomsg" },
#endif
#ifdef EIDRM
{ EIDRM, "eidrm" },
#endif
#ifdef ECHRNG
{ ECHRNG, "echrng" },
#endif
#ifdef EL2NSYNC
{ EL2NSYNC, "el2nsync" },
#endif
#ifdef EL3HLT
{ EL3HLT, "el3hlt" },
#endif
#ifdef EL3RST
{ EL3RST, "el3rst" },
#endif
#ifdef ELNRNG
{ ELNRNG, "elnrng" },
#endif
#ifdef EUNATCH
{ EUNATCH, "eunatch" },
#endif
#ifdef ENOCSI
{ ENOCSI, "enocsi" },
#endif
#ifdef EL2HLT
{ EL2HLT, "el2hlt" },
#endif
#ifdef EBADE
{ EBADE, "ebade" },
#endif
#ifdef EBADR
{ EBADR, "ebadr" },
#endif
#ifdef EXFULL
{ EXFULL, "exfull" },
#endif
#ifdef ENOANO
{ ENOANO, "enoano" },
#endif
#ifdef EBADRQC
{ EBADRQC, "ebadrqc" },
#endif
#ifdef EBADSLT
{ EBADSLT, "ebadslt" },
#endif
#ifdef EDEADLOCK
{ EDEADLOCK, "edeadlock" },
#endif
#ifdef EBFONT
{ EBFONT, "ebfont" },
#endif
#ifdef ENOSTR
{ ENOSTR, "enostr" },
#endif
#ifdef ENODATA
{ ENODATA, "enodata" },
#endif
#ifdef ETIME
{ ETIME, "etime" },
#endif
#ifdef ENOSR
{ ENOSR, "enosr" },
#endif
#ifdef ENONET
{ ENONET, "enonet" },
#endif
#ifdef ENOPKG
{ ENOPKG, "enopkg" },
#endif
#ifdef EREMOTE
{ EREMOTE, "eremote" },
#endif
#ifdef ENOLINK
{ ENOLINK, "enolink" },
#endif
#ifdef EADV
{ EADV, "eadv" },
#endif
#ifdef ESRMNT
{ ESRMNT, "esrmnt" },
#endif
#ifdef ECOMM
{ ECOMM, "ecomm" },
#endif
#ifdef EPROTO
{ EPROTO, "eproto" },
#endif
#ifdef EMULTIHOP
{ EMULTIHOP, "emultihop" },
#endif
#ifdef EDOTDOT
{ EDOTDOT, "edotdot" },
#endif
#ifdef EBADMSG
{ EBADMSG, "ebadmsg" },
#endif
#ifdef EOVERFLOW
{ EOVERFLOW, "eoverflow" },
#endif
#ifdef ENOTUNIQ
{ ENOTUNIQ, "enotuniq" },
#endif
#ifdef EBADFD
{ EBADFD, "ebadfd" },
#endif
#ifdef EREMCHG
{ EREMCHG, "eremchg" },
#endif
#ifdef ELIBACC
{ ELIBACC, "elibacc" },
#endif
#ifdef ELIBBAD
{ ELIBBAD, "elibbad" },
#endif
#ifdef ELIBSCN
{ ELIBSCN, "elibscn" },
#endif
#ifdef ELIBMAX
{ ELIBMAX, "elibmax" },
#endif
#ifdef ELIBEXEC
{ ELIBEXEC, "elibexec" },
#endif
#ifdef EILSEQ
{ EILSEQ, "eilseq" },
#endif
#ifdef ERESTART
{ ERESTART, "erestart" },
#endif
#ifdef ESTRPIPE
{ ESTRPIPE, "estrpipe" },
#endif
#ifdef EUSERS
{ EUSERS, "eusers" },
#endif
#ifdef ENOTSOCK
{ ENOTSOCK, "enotsock" },
#endif
#ifdef EDESTADDRREQ
{ EDESTADDRREQ, "edestaddrreq" },
#endif
#ifdef EMSGSIZE
{ EMSGSIZE, "emsgsize" },
#endif
#ifdef EPROTOTYPE
{ EPROTOTYPE, "eprototype" },
#endif
#ifdef ENOPROTOOPT
{ ENOPROTOOPT, "enoprotoopt" },
#endif
#ifdef EPROTONOSUPPORT
{ EPROTONOSUPPORT, "eprotonosupport" },
#endif
#ifdef ESOCKTNOSUPPORT
{ ESOCKTNOSUPPORT, "esocktnosupport" },
#endif
#ifdef EOPNOTSUPP
{ EOPNOTSUPP, "eopnotsupp" },
#endif
#ifdef EPFNOSUPPORT
{ EPFNOSUPPORT, "epfnosupport" },
#endif
#ifdef EAFNOSUPPORT
{ EAFNOSUPPORT, "eafnosupport" },
#endif
#ifdef EADDRINUSE
{ EADDRINUSE, "eaddrinuse" },
#endif
#ifdef EADDRNOTAVAIL
{ EADDRNOTAVAIL, "eaddrnotavail" },
#endif
#ifdef ENETDOWN
{ ENETDOWN, "enetdown" },
#endif
#ifdef ENETUNREACH
{ ENETUNREACH, "enetunreach" },
#endif
#ifdef ENETRESET
{ ENETRESET, "enetreset" },
#endif
#ifdef ECONNABORTED
{ ECONNABORTED, "econnaborted" },
#endif
#ifdef ECONNRESET
{ ECONNRESET, "econnreset" },
#endif
#ifdef ENOBUFS
{ ENOBUFS, "enobufs" },
#endif
#ifdef EISCONN
{ EISCONN, "eisconn" },
#endif
#ifdef ENOTCONN
{ ENOTCONN, "enotconn" },
#endif
#ifdef ESHUTDOWN
{ ESHUTDOWN, "eshutdown" },
#endif
#ifdef ETOOMANYREFS
{ ETOOMANYREFS, "etoomanyrefs" },
#endif
#ifdef ETIMEDOUT
{ ETIMEDOUT, "etimedout" },
#endif
#ifdef ECONNREFUSED
{ ECONNREFUSED, "econnrefused" },
#endif
#ifdef EHOSTDOWN
{ EHOSTDOWN, "ehostdown" },
#endif
#ifdef EHOSTUNREACH
{ EHOSTUNREACH, "ehostunreach" },
#endif
#ifdef EALREADY
{ EALREADY, "ealready" },
#endif
#ifdef EINPROGRESS
{ EINPROGRESS, "einprogress" },
#endif
#ifdef ESTALE
{ ESTALE, "estale" },
#endif
#ifdef EUCLEAN
{ EUCLEAN, "euclean" },
#endif
#ifdef ENOTNAM
{ ENOTNAM, "enotnam" },
#endif
#ifdef ENAVAIL
{ ENAVAIL, "enavail" },
#endif
#ifdef EISNAM
{ EISNAM, "eisnam" },
#endif
#ifdef EREMOTEIO
{ EREMOTEIO, "eremoteio" },
#endif
#ifdef EDQUOT
{ EDQUOT, "edquot" },
#endif
#ifdef ENOMEDIUM
{ ENOMEDIUM, "enomedium" },
#endif
#ifdef EMEDIUMTYPE
{ EMEDIUMTYPE, "emediumtype" },
#endif
#ifdef ECANCELED
{ ECANCELED, "ecanceled" },
#endif
#ifdef ENOKEY
{ ENOKEY, "enokey" },
#endif
#ifdef EKEYEXPIRED
{ EKEYEXPIRED, "ekeyexpired" },
#endif
#ifdef EKEYREVOKED
{ EKEYREVOKED, "ekeyrevoked" },
#endif
#ifdef EKEYREJECTED
{ EKEYREJECTED, "ekeyrejected" },
#endif
#ifdef EOWNERDEAD
{ EOWNERDEAD, "eownerdead" },
#endif
#ifdef ENOTRECOVERABLE
{ ENOTRECOVERABLE, "enotrecoverable" },
#endif
#ifdef ERFKILL
{ ERFKILL, "erfkill" },
#endif
#ifdef EHWPOISON
{ EHWPOISON, "ehwpoison" },
#endif
#ifdef ENOTSUP
{ ENOTSUP, "enotsup" },
#endif
{ 0, NULL }
};
static const error_symbol_t gai_errno_symbols[] =
{
#ifdef EAI_ADDRFAMILY
{ EAI_ADDRFAMILY, "eai_addrfamily" },
#endif
#ifdef EAI_AGAIN
{ EAI_AGAIN, "eai_again" },
#endif
#ifdef EAI_BADFLAGS
{ EAI_BADFLAGS, "eai_badflags" },
#endif
#ifdef EAI_FAIL
{ EAI_FAIL, "eai_fail" },
#endif
#ifdef EAI_FAMILY
{ EAI_FAMILY, "eai_family" },
#endif
#ifdef EAI_MEMORY
{ EAI_MEMORY, "eai_memory" },
#endif
#ifdef EAI_NODATA
{ EAI_NODATA, "eai_nodata" },
#endif
#ifdef EAI_NONAME
{ EAI_NONAME, "eai_noname" },
#endif
#ifdef EAI_SERVICE
{ EAI_SERVICE, "eai_service" },
#endif
#ifdef EAI_SOCKTYPE
{ EAI_SOCKTYPE, "eai_socktype" },
#endif
#ifdef EAI_SYSTEM
{ EAI_SYSTEM, "eai_system" },
#endif
{ 0, NULL }
};
static const error_symbol_t h_errno_symbols[] =
{
#ifdef HOST_NOT_FOUND
{ HOST_NOT_FOUND, "host_not_found" },
#endif
#ifdef NO_DATA
{ NO_DATA, "no_data" },
#endif
#ifdef NO_RECOVERY
{ NO_RECOVERY, "no_recovery" },
#endif
#ifdef TRY_AGAIN
{ TRY_AGAIN, "try_again" },
#endif
{ 0, NULL }
};
#endif /*__WINDOWS__*/
|