00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "config.h"
00010
00011 #ifdef HAVE_SYS_ERRLIST
00012
00013
00014
00015
00016
00017 #define sys_nerr sys_nerr__
00018 #define sys_errlist sys_errlist__
00019 #endif
00020
00021 #include "ansidecl.h"
00022 #include "libiberty.h"
00023
00024 #include <stdio.h>
00025 #include <errno.h>
00026
00027 #ifdef HAVE_SYS_ERRLIST
00028 #undef sys_nerr
00029 #undef sys_errlist
00030 #endif
00031
00032
00033
00034 #ifdef HAVE_STDLIB_H
00035 #include <stdlib.h>
00036 #else
00037 extern PTR malloc ();
00038 #endif
00039
00040 #ifdef HAVE_STRING_H
00041 #include <string.h>
00042 #else
00043 extern PTR memset ();
00044 #endif
00045
00046 #ifndef MAX
00047 # define MAX(a,b) ((a) > (b) ? (a) : (b))
00048 #endif
00049
00050 static void init_error_tables PARAMS ((void));
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 struct error_info
00064 {
00065 const int value;
00066 const char *const name;
00067 #ifndef HAVE_SYS_ERRLIST
00068 const char *const msg;
00069 #endif
00070 };
00071
00072 #ifndef HAVE_SYS_ERRLIST
00073 # define ENTRY(value, name, msg) {value, name, msg}
00074 #else
00075 # define ENTRY(value, name, msg) {value, name}
00076 #endif
00077
00078 static const struct error_info error_table[] =
00079 {
00080 #if defined (EPERM)
00081 ENTRY(EPERM, "EPERM", "Not owner"),
00082 #endif
00083 #if defined (ENOENT)
00084 ENTRY(ENOENT, "ENOENT", "No such file or directory"),
00085 #endif
00086 #if defined (ESRCH)
00087 ENTRY(ESRCH, "ESRCH", "No such process"),
00088 #endif
00089 #if defined (EINTR)
00090 ENTRY(EINTR, "EINTR", "Interrupted system call"),
00091 #endif
00092 #if defined (EIO)
00093 ENTRY(EIO, "EIO", "I/O error"),
00094 #endif
00095 #if defined (ENXIO)
00096 ENTRY(ENXIO, "ENXIO", "No such device or address"),
00097 #endif
00098 #if defined (E2BIG)
00099 ENTRY(E2BIG, "E2BIG", "Arg list too long"),
00100 #endif
00101 #if defined (ENOEXEC)
00102 ENTRY(ENOEXEC, "ENOEXEC", "Exec format error"),
00103 #endif
00104 #if defined (EBADF)
00105 ENTRY(EBADF, "EBADF", "Bad file number"),
00106 #endif
00107 #if defined (ECHILD)
00108 ENTRY(ECHILD, "ECHILD", "No child processes"),
00109 #endif
00110 #if defined (EWOULDBLOCK)
00111 ENTRY(EWOULDBLOCK, "EWOULDBLOCK", "Operation would block"),
00112 #endif
00113 #if defined (EAGAIN)
00114 ENTRY(EAGAIN, "EAGAIN", "No more processes"),
00115 #endif
00116 #if defined (ENOMEM)
00117 ENTRY(ENOMEM, "ENOMEM", "Not enough space"),
00118 #endif
00119 #if defined (EACCES)
00120 ENTRY(EACCES, "EACCES", "Permission denied"),
00121 #endif
00122 #if defined (EFAULT)
00123 ENTRY(EFAULT, "EFAULT", "Bad address"),
00124 #endif
00125 #if defined (ENOTBLK)
00126 ENTRY(ENOTBLK, "ENOTBLK", "Block device required"),
00127 #endif
00128 #if defined (EBUSY)
00129 ENTRY(EBUSY, "EBUSY", "Device busy"),
00130 #endif
00131 #if defined (EEXIST)
00132 ENTRY(EEXIST, "EEXIST", "File exists"),
00133 #endif
00134 #if defined (EXDEV)
00135 ENTRY(EXDEV, "EXDEV", "Cross-device link"),
00136 #endif
00137 #if defined (ENODEV)
00138 ENTRY(ENODEV, "ENODEV", "No such device"),
00139 #endif
00140 #if defined (ENOTDIR)
00141 ENTRY(ENOTDIR, "ENOTDIR", "Not a directory"),
00142 #endif
00143 #if defined (EISDIR)
00144 ENTRY(EISDIR, "EISDIR", "Is a directory"),
00145 #endif
00146 #if defined (EINVAL)
00147 ENTRY(EINVAL, "EINVAL", "Invalid argument"),
00148 #endif
00149 #if defined (ENFILE)
00150 ENTRY(ENFILE, "ENFILE", "File table overflow"),
00151 #endif
00152 #if defined (EMFILE)
00153 ENTRY(EMFILE, "EMFILE", "Too many open files"),
00154 #endif
00155 #if defined (ENOTTY)
00156 ENTRY(ENOTTY, "ENOTTY", "Not a typewriter"),
00157 #endif
00158 #if defined (ETXTBSY)
00159 ENTRY(ETXTBSY, "ETXTBSY", "Text file busy"),
00160 #endif
00161 #if defined (EFBIG)
00162 ENTRY(EFBIG, "EFBIG", "File too large"),
00163 #endif
00164 #if defined (ENOSPC)
00165 ENTRY(ENOSPC, "ENOSPC", "No space left on device"),
00166 #endif
00167 #if defined (ESPIPE)
00168 ENTRY(ESPIPE, "ESPIPE", "Illegal seek"),
00169 #endif
00170 #if defined (EROFS)
00171 ENTRY(EROFS, "EROFS", "Read-only file system"),
00172 #endif
00173 #if defined (EMLINK)
00174 ENTRY(EMLINK, "EMLINK", "Too many links"),
00175 #endif
00176 #if defined (EPIPE)
00177 ENTRY(EPIPE, "EPIPE", "Broken pipe"),
00178 #endif
00179 #if defined (EDOM)
00180 ENTRY(EDOM, "EDOM", "Math argument out of domain of func"),
00181 #endif
00182 #if defined (ERANGE)
00183 ENTRY(ERANGE, "ERANGE", "Math result not representable"),
00184 #endif
00185 #if defined (ENOMSG)
00186 ENTRY(ENOMSG, "ENOMSG", "No message of desired type"),
00187 #endif
00188 #if defined (EIDRM)
00189 ENTRY(EIDRM, "EIDRM", "Identifier removed"),
00190 #endif
00191 #if defined (ECHRNG)
00192 ENTRY(ECHRNG, "ECHRNG", "Channel number out of range"),
00193 #endif
00194 #if defined (EL2NSYNC)
00195 ENTRY(EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"),
00196 #endif
00197 #if defined (EL3HLT)
00198 ENTRY(EL3HLT, "EL3HLT", "Level 3 halted"),
00199 #endif
00200 #if defined (EL3RST)
00201 ENTRY(EL3RST, "EL3RST", "Level 3 reset"),
00202 #endif
00203 #if defined (ELNRNG)
00204 ENTRY(ELNRNG, "ELNRNG", "Link number out of range"),
00205 #endif
00206 #if defined (EUNATCH)
00207 ENTRY(EUNATCH, "EUNATCH", "Protocol driver not attached"),
00208 #endif
00209 #if defined (ENOCSI)
00210 ENTRY(ENOCSI, "ENOCSI", "No CSI structure available"),
00211 #endif
00212 #if defined (EL2HLT)
00213 ENTRY(EL2HLT, "EL2HLT", "Level 2 halted"),
00214 #endif
00215 #if defined (EDEADLK)
00216 ENTRY(EDEADLK, "EDEADLK", "Deadlock condition"),
00217 #endif
00218 #if defined (ENOLCK)
00219 ENTRY(ENOLCK, "ENOLCK", "No record locks available"),
00220 #endif
00221 #if defined (EBADE)
00222 ENTRY(EBADE, "EBADE", "Invalid exchange"),
00223 #endif
00224 #if defined (EBADR)
00225 ENTRY(EBADR, "EBADR", "Invalid request descriptor"),
00226 #endif
00227 #if defined (EXFULL)
00228 ENTRY(EXFULL, "EXFULL", "Exchange full"),
00229 #endif
00230 #if defined (ENOANO)
00231 ENTRY(ENOANO, "ENOANO", "No anode"),
00232 #endif
00233 #if defined (EBADRQC)
00234 ENTRY(EBADRQC, "EBADRQC", "Invalid request code"),
00235 #endif
00236 #if defined (EBADSLT)
00237 ENTRY(EBADSLT, "EBADSLT", "Invalid slot"),
00238 #endif
00239 #if defined (EDEADLOCK)
00240 ENTRY(EDEADLOCK, "EDEADLOCK", "File locking deadlock error"),
00241 #endif
00242 #if defined (EBFONT)
00243 ENTRY(EBFONT, "EBFONT", "Bad font file format"),
00244 #endif
00245 #if defined (ENOSTR)
00246 ENTRY(ENOSTR, "ENOSTR", "Device not a stream"),
00247 #endif
00248 #if defined (ENODATA)
00249 ENTRY(ENODATA, "ENODATA", "No data available"),
00250 #endif
00251 #if defined (ETIME)
00252 ENTRY(ETIME, "ETIME", "Timer expired"),
00253 #endif
00254 #if defined (ENOSR)
00255 ENTRY(ENOSR, "ENOSR", "Out of streams resources"),
00256 #endif
00257 #if defined (ENONET)
00258 ENTRY(ENONET, "ENONET", "Machine is not on the network"),
00259 #endif
00260 #if defined (ENOPKG)
00261 ENTRY(ENOPKG, "ENOPKG", "Package not installed"),
00262 #endif
00263 #if defined (EREMOTE)
00264 ENTRY(EREMOTE, "EREMOTE", "Object is remote"),
00265 #endif
00266 #if defined (ENOLINK)
00267 ENTRY(ENOLINK, "ENOLINK", "Link has been severed"),
00268 #endif
00269 #if defined (EADV)
00270 ENTRY(EADV, "EADV", "Advertise error"),
00271 #endif
00272 #if defined (ESRMNT)
00273 ENTRY(ESRMNT, "ESRMNT", "Srmount error"),
00274 #endif
00275 #if defined (ECOMM)
00276 ENTRY(ECOMM, "ECOMM", "Communication error on send"),
00277 #endif
00278 #if defined (EPROTO)
00279 ENTRY(EPROTO, "EPROTO", "Protocol error"),
00280 #endif
00281 #if defined (EMULTIHOP)
00282 ENTRY(EMULTIHOP, "EMULTIHOP", "Multihop attempted"),
00283 #endif
00284 #if defined (EDOTDOT)
00285 ENTRY(EDOTDOT, "EDOTDOT", "RFS specific error"),
00286 #endif
00287 #if defined (EBADMSG)
00288 ENTRY(EBADMSG, "EBADMSG", "Not a data message"),
00289 #endif
00290 #if defined (ENAMETOOLONG)
00291 ENTRY(ENAMETOOLONG, "ENAMETOOLONG", "File name too long"),
00292 #endif
00293 #if defined (EOVERFLOW)
00294 ENTRY(EOVERFLOW, "EOVERFLOW", "Value too large for defined data type"),
00295 #endif
00296 #if defined (ENOTUNIQ)
00297 ENTRY(ENOTUNIQ, "ENOTUNIQ", "Name not unique on network"),
00298 #endif
00299 #if defined (EBADFD)
00300 ENTRY(EBADFD, "EBADFD", "File descriptor in bad state"),
00301 #endif
00302 #if defined (EREMCHG)
00303 ENTRY(EREMCHG, "EREMCHG", "Remote address changed"),
00304 #endif
00305 #if defined (ELIBACC)
00306 ENTRY(ELIBACC, "ELIBACC", "Can not access a needed shared library"),
00307 #endif
00308 #if defined (ELIBBAD)
00309 ENTRY(ELIBBAD, "ELIBBAD", "Accessing a corrupted shared library"),
00310 #endif
00311 #if defined (ELIBSCN)
00312 ENTRY(ELIBSCN, "ELIBSCN", ".lib section in a.out corrupted"),
00313 #endif
00314 #if defined (ELIBMAX)
00315 ENTRY(ELIBMAX, "ELIBMAX", "Attempting to link in too many shared libraries"),
00316 #endif
00317 #if defined (ELIBEXEC)
00318 ENTRY(ELIBEXEC, "ELIBEXEC", "Cannot exec a shared library directly"),
00319 #endif
00320 #if defined (EILSEQ)
00321 ENTRY(EILSEQ, "EILSEQ", "Illegal byte sequence"),
00322 #endif
00323 #if defined (ENOSYS)
00324 ENTRY(ENOSYS, "ENOSYS", "Operation not applicable"),
00325 #endif
00326 #if defined (ELOOP)
00327 ENTRY(ELOOP, "ELOOP", "Too many symbolic links encountered"),
00328 #endif
00329 #if defined (ERESTART)
00330 ENTRY(ERESTART, "ERESTART", "Interrupted system call should be restarted"),
00331 #endif
00332 #if defined (ESTRPIPE)
00333 ENTRY(ESTRPIPE, "ESTRPIPE", "Streams pipe error"),
00334 #endif
00335 #if defined (ENOTEMPTY)
00336 ENTRY(ENOTEMPTY, "ENOTEMPTY", "Directory not empty"),
00337 #endif
00338 #if defined (EUSERS)
00339 ENTRY(EUSERS, "EUSERS", "Too many users"),
00340 #endif
00341 #if defined (ENOTSOCK)
00342 ENTRY(ENOTSOCK, "ENOTSOCK", "Socket operation on non-socket"),
00343 #endif
00344 #if defined (EDESTADDRREQ)
00345 ENTRY(EDESTADDRREQ, "EDESTADDRREQ", "Destination address required"),
00346 #endif
00347 #if defined (EMSGSIZE)
00348 ENTRY(EMSGSIZE, "EMSGSIZE", "Message too long"),
00349 #endif
00350 #if defined (EPROTOTYPE)
00351 ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"),
00352 #endif
00353 #if defined (ENOPROTOOPT)
00354 ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"),
00355 #endif
00356 #if defined (EPROTONOSUPPORT)
00357 ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"),
00358 #endif
00359 #if defined (ESOCKTNOSUPPORT)
00360 ENTRY(ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "Socket type not supported"),
00361 #endif
00362 #if defined (EOPNOTSUPP)
00363 ENTRY(EOPNOTSUPP, "EOPNOTSUPP", "Operation not supported on transport endpoint"),
00364 #endif
00365 #if defined (EPFNOSUPPORT)
00366 ENTRY(EPFNOSUPPORT, "EPFNOSUPPORT", "Protocol family not supported"),
00367 #endif
00368 #if defined (EAFNOSUPPORT)
00369 ENTRY(EAFNOSUPPORT, "EAFNOSUPPORT", "Address family not supported by protocol"),
00370 #endif
00371 #if defined (EADDRINUSE)
00372 ENTRY(EADDRINUSE, "EADDRINUSE", "Address already in use"),
00373 #endif
00374 #if defined (EADDRNOTAVAIL)
00375 ENTRY(EADDRNOTAVAIL, "EADDRNOTAVAIL","Cannot assign requested address"),
00376 #endif
00377 #if defined (ENETDOWN)
00378 ENTRY(ENETDOWN, "ENETDOWN", "Network is down"),
00379 #endif
00380 #if defined (ENETUNREACH)
00381 ENTRY(ENETUNREACH, "ENETUNREACH", "Network is unreachable"),
00382 #endif
00383 #if defined (ENETRESET)
00384 ENTRY(ENETRESET, "ENETRESET", "Network dropped connection because of reset"),
00385 #endif
00386 #if defined (ECONNABORTED)
00387 ENTRY(ECONNABORTED, "ECONNABORTED", "Software caused connection abort"),
00388 #endif
00389 #if defined (ECONNRESET)
00390 ENTRY(ECONNRESET, "ECONNRESET", "Connection reset by peer"),
00391 #endif
00392 #if defined (ENOBUFS)
00393 ENTRY(ENOBUFS, "ENOBUFS", "No buffer space available"),
00394 #endif
00395 #if defined (EISCONN)
00396 ENTRY(EISCONN, "EISCONN", "Transport endpoint is already connected"),
00397 #endif
00398 #if defined (ENOTCONN)
00399 ENTRY(ENOTCONN, "ENOTCONN", "Transport endpoint is not connected"),
00400 #endif
00401 #if defined (ESHUTDOWN)
00402 ENTRY(ESHUTDOWN, "ESHUTDOWN", "Cannot send after transport endpoint shutdown"),
00403 #endif
00404 #if defined (ETOOMANYREFS)
00405 ENTRY(ETOOMANYREFS, "ETOOMANYREFS", "Too many references: cannot splice"),
00406 #endif
00407 #if defined (ETIMEDOUT)
00408 ENTRY(ETIMEDOUT, "ETIMEDOUT", "Connection timed out"),
00409 #endif
00410 #if defined (ECONNREFUSED)
00411 ENTRY(ECONNREFUSED, "ECONNREFUSED", "Connection refused"),
00412 #endif
00413 #if defined (EHOSTDOWN)
00414 ENTRY(EHOSTDOWN, "EHOSTDOWN", "Host is down"),
00415 #endif
00416 #if defined (EHOSTUNREACH)
00417 ENTRY(EHOSTUNREACH, "EHOSTUNREACH", "No route to host"),
00418 #endif
00419 #if defined (EALREADY)
00420 ENTRY(EALREADY, "EALREADY", "Operation already in progress"),
00421 #endif
00422 #if defined (EINPROGRESS)
00423 ENTRY(EINPROGRESS, "EINPROGRESS", "Operation now in progress"),
00424 #endif
00425 #if defined (ESTALE)
00426 ENTRY(ESTALE, "ESTALE", "Stale NFS file handle"),
00427 #endif
00428 #if defined (EUCLEAN)
00429 ENTRY(EUCLEAN, "EUCLEAN", "Structure needs cleaning"),
00430 #endif
00431 #if defined (ENOTNAM)
00432 ENTRY(ENOTNAM, "ENOTNAM", "Not a XENIX named type file"),
00433 #endif
00434 #if defined (ENAVAIL)
00435 ENTRY(ENAVAIL, "ENAVAIL", "No XENIX semaphores available"),
00436 #endif
00437 #if defined (EISNAM)
00438 ENTRY(EISNAM, "EISNAM", "Is a named type file"),
00439 #endif
00440 #if defined (EREMOTEIO)
00441 ENTRY(EREMOTEIO, "EREMOTEIO", "Remote I/O error"),
00442 #endif
00443 ENTRY(0, NULL, NULL)
00444 };
00445
00446 #ifdef EVMSERR
00447
00448
00449 static struct { int value; const char *name, *msg; }
00450 evmserr = { EVMSERR, "EVMSERR", "VMS-specific error" };
00451 #endif
00452
00453
00454
00455
00456 static const char **error_names;
00457 static int num_error_names = 0;
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467 #ifndef HAVE_SYS_ERRLIST
00468
00469 #define sys_nerr sys_nerr__
00470 #define sys_errlist sys_errlist__
00471 static int sys_nerr;
00472 static const char **sys_errlist;
00473
00474 #else
00475
00476 extern int sys_nerr;
00477 extern char *sys_errlist[];
00478
00479 #endif
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509 static void
00510 init_error_tables ()
00511 {
00512 const struct error_info *eip;
00513 int nbytes;
00514
00515
00516
00517
00518 if (num_error_names == 0)
00519 {
00520 for (eip = error_table; eip -> name != NULL; eip++)
00521 {
00522 if (eip -> value >= num_error_names)
00523 {
00524 num_error_names = eip -> value + 1;
00525 }
00526 }
00527 }
00528
00529
00530
00531
00532 if (error_names == NULL)
00533 {
00534 nbytes = num_error_names * sizeof (char *);
00535 if ((error_names = (const char **) malloc (nbytes)) != NULL)
00536 {
00537 memset (error_names, 0, nbytes);
00538 for (eip = error_table; eip -> name != NULL; eip++)
00539 {
00540 error_names[eip -> value] = eip -> name;
00541 }
00542 }
00543 }
00544
00545 #ifndef HAVE_SYS_ERRLIST
00546
00547
00548
00549
00550 if (sys_errlist == NULL)
00551 {
00552 nbytes = num_error_names * sizeof (char *);
00553 if ((sys_errlist = (const char **) malloc (nbytes)) != NULL)
00554 {
00555 memset (sys_errlist, 0, nbytes);
00556 sys_nerr = num_error_names;
00557 for (eip = error_table; eip -> name != NULL; eip++)
00558 {
00559 sys_errlist[eip -> value] = eip -> msg;
00560 }
00561 }
00562 }
00563
00564 #endif
00565
00566 }
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590 int
00591 errno_max ()
00592 {
00593 int maxsize;
00594
00595 if (error_names == NULL)
00596 {
00597 init_error_tables ();
00598 }
00599 maxsize = MAX (sys_nerr, num_error_names);
00600 return (maxsize - 1);
00601 }
00602
00603 #ifndef HAVE_STRERROR
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629 char *
00630 strerror (errnoval)
00631 int errnoval;
00632 {
00633 const char *msg;
00634 static char buf[32];
00635
00636 #ifndef HAVE_SYS_ERRLIST
00637
00638 if (error_names == NULL)
00639 {
00640 init_error_tables ();
00641 }
00642
00643 #endif
00644
00645 if ((errnoval < 0) || (errnoval >= sys_nerr))
00646 {
00647 #ifdef EVMSERR
00648 if (errnoval == evmserr.value)
00649 msg = evmserr.msg;
00650 else
00651 #endif
00652
00653 msg = NULL;
00654 }
00655 else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL))
00656 {
00657
00658 sprintf (buf, "Error %d", errnoval);
00659 msg = buf;
00660 }
00661 else
00662 {
00663
00664 msg = (char *) sys_errlist[errnoval];
00665 }
00666
00667 return (msg);
00668 }
00669
00670 #endif
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696 const char *
00697 strerrno (errnoval)
00698 int errnoval;
00699 {
00700 const char *name;
00701 static char buf[32];
00702
00703 if (error_names == NULL)
00704 {
00705 init_error_tables ();
00706 }
00707
00708 if ((errnoval < 0) || (errnoval >= num_error_names))
00709 {
00710 #ifdef EVMSERR
00711 if (errnoval == evmserr.value)
00712 name = evmserr.name;
00713 else
00714 #endif
00715
00716 name = NULL;
00717 }
00718 else if ((error_names == NULL) || (error_names[errnoval] == NULL))
00719 {
00720
00721 sprintf (buf, "Error %d", errnoval);
00722 name = (const char *) buf;
00723 }
00724 else
00725 {
00726
00727 name = error_names[errnoval];
00728 }
00729
00730 return (name);
00731 }
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744 int
00745 strtoerrno (name)
00746 const char *name;
00747 {
00748 int errnoval = 0;
00749
00750 if (name != NULL)
00751 {
00752 if (error_names == NULL)
00753 {
00754 init_error_tables ();
00755 }
00756 for (errnoval = 0; errnoval < num_error_names; errnoval++)
00757 {
00758 if ((error_names[errnoval] != NULL) &&
00759 (strcmp (name, error_names[errnoval]) == 0))
00760 {
00761 break;
00762 }
00763 }
00764 if (errnoval == num_error_names)
00765 {
00766 #ifdef EVMSERR
00767 if (strcmp (name, evmserr.name) == 0)
00768 errnoval = evmserr.value;
00769 else
00770 #endif
00771 errnoval = 0;
00772 }
00773 }
00774 return (errnoval);
00775 }
00776
00777
00778
00779
00780
00781 #ifdef MAIN
00782
00783 #include <stdio.h>
00784
00785 int
00786 main ()
00787 {
00788 int errn;
00789 int errnmax;
00790 const char *name;
00791 const char *msg;
00792 char *strerror ();
00793
00794 errnmax = errno_max ();
00795 printf ("%d entries in names table.\n", num_error_names);
00796 printf ("%d entries in messages table.\n", sys_nerr);
00797 printf ("%d is max useful index.\n", errnmax);
00798
00799
00800
00801
00802
00803
00804 for (errn = 0; errn <= errnmax; errn++)
00805 {
00806 name = strerrno (errn);
00807 name = (name == NULL) ? "<NULL>" : name;
00808 msg = strerror (errn);
00809 msg = (msg == NULL) ? "<NULL>" : msg;
00810 printf ("%-4d%-18s%s\n", errn, name, msg);
00811 }
00812
00813 return 0;
00814 }
00815
00816 #endif