OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [libiberty/] [strerror.c] - Diff between revs 227 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 227 Rev 816
/* Extended support for using errno values.
/* Extended support for using errno values.
   Written by Fred Fish.  fnf@cygnus.com
   Written by Fred Fish.  fnf@cygnus.com
   This file is in the public domain.  --Per Bothner.  */
   This file is in the public domain.  --Per Bothner.  */
 
 
#include "config.h"
#include "config.h"
 
 
#ifdef HAVE_SYS_ERRLIST
#ifdef HAVE_SYS_ERRLIST
/* Note that errno.h (not sure what OS) or stdio.h (BSD 4.4, at least)
/* Note that errno.h (not sure what OS) or stdio.h (BSD 4.4, at least)
   might declare sys_errlist in a way that the compiler might consider
   might declare sys_errlist in a way that the compiler might consider
   incompatible with our later declaration, perhaps by using const
   incompatible with our later declaration, perhaps by using const
   attributes.  So we hide the declaration in errno.h (if any) using a
   attributes.  So we hide the declaration in errno.h (if any) using a
   macro. */
   macro. */
#define sys_nerr sys_nerr__
#define sys_nerr sys_nerr__
#define sys_errlist sys_errlist__
#define sys_errlist sys_errlist__
#endif
#endif
 
 
#include "ansidecl.h"
#include "ansidecl.h"
#include "libiberty.h"
#include "libiberty.h"
 
 
#include <stdio.h>
#include <stdio.h>
#include <errno.h>
#include <errno.h>
 
 
#ifdef HAVE_SYS_ERRLIST
#ifdef HAVE_SYS_ERRLIST
#undef sys_nerr
#undef sys_nerr
#undef sys_errlist
#undef sys_errlist
#endif
#endif
 
 
/*  Routines imported from standard C runtime libraries. */
/*  Routines imported from standard C runtime libraries. */
 
 
#ifdef HAVE_STDLIB_H
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#include <stdlib.h>
#else
#else
extern PTR malloc ();
extern PTR malloc ();
#endif
#endif
 
 
#ifdef HAVE_STRING_H
#ifdef HAVE_STRING_H
#include <string.h>
#include <string.h>
#else
#else
extern PTR memset ();
extern PTR memset ();
#endif
#endif
 
 
#ifndef MAX
#ifndef MAX
#  define MAX(a,b) ((a) > (b) ? (a) : (b))
#  define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
#endif
 
 
static void init_error_tables (void);
static void init_error_tables (void);
 
 
/* Translation table for errno values.  See intro(2) in most UNIX systems
/* Translation table for errno values.  See intro(2) in most UNIX systems
   Programmers Reference Manuals.
   Programmers Reference Manuals.
 
 
   Note that this table is generally only accessed when it is used at runtime
   Note that this table is generally only accessed when it is used at runtime
   to initialize errno name and message tables that are indexed by errno
   to initialize errno name and message tables that are indexed by errno
   value.
   value.
 
 
   Not all of these errnos will exist on all systems.  This table is the only
   Not all of these errnos will exist on all systems.  This table is the only
   thing that should have to be updated as new error numbers are introduced.
   thing that should have to be updated as new error numbers are introduced.
   It's sort of ugly, but at least its portable. */
   It's sort of ugly, but at least its portable. */
 
 
struct error_info
struct error_info
{
{
  const int value;              /* The numeric value from <errno.h> */
  const int value;              /* The numeric value from <errno.h> */
  const char *const name;       /* The equivalent symbolic value */
  const char *const name;       /* The equivalent symbolic value */
#ifndef HAVE_SYS_ERRLIST
#ifndef HAVE_SYS_ERRLIST
  const char *const msg;        /* Short message about this value */
  const char *const msg;        /* Short message about this value */
#endif
#endif
};
};
 
 
#ifndef HAVE_SYS_ERRLIST
#ifndef HAVE_SYS_ERRLIST
#   define ENTRY(value, name, msg)      {value, name, msg}
#   define ENTRY(value, name, msg)      {value, name, msg}
#else
#else
#   define ENTRY(value, name, msg)      {value, name}
#   define ENTRY(value, name, msg)      {value, name}
#endif
#endif
 
 
static const struct error_info error_table[] =
static const struct error_info error_table[] =
{
{
#if defined (EPERM)
#if defined (EPERM)
  ENTRY(EPERM, "EPERM", "Not owner"),
  ENTRY(EPERM, "EPERM", "Not owner"),
#endif
#endif
#if defined (ENOENT)
#if defined (ENOENT)
  ENTRY(ENOENT, "ENOENT", "No such file or directory"),
  ENTRY(ENOENT, "ENOENT", "No such file or directory"),
#endif
#endif
#if defined (ESRCH)
#if defined (ESRCH)
  ENTRY(ESRCH, "ESRCH", "No such process"),
  ENTRY(ESRCH, "ESRCH", "No such process"),
#endif
#endif
#if defined (EINTR)
#if defined (EINTR)
  ENTRY(EINTR, "EINTR", "Interrupted system call"),
  ENTRY(EINTR, "EINTR", "Interrupted system call"),
#endif
#endif
#if defined (EIO)
#if defined (EIO)
  ENTRY(EIO, "EIO", "I/O error"),
  ENTRY(EIO, "EIO", "I/O error"),
#endif
#endif
#if defined (ENXIO)
#if defined (ENXIO)
  ENTRY(ENXIO, "ENXIO", "No such device or address"),
  ENTRY(ENXIO, "ENXIO", "No such device or address"),
#endif
#endif
#if defined (E2BIG)
#if defined (E2BIG)
  ENTRY(E2BIG, "E2BIG", "Arg list too long"),
  ENTRY(E2BIG, "E2BIG", "Arg list too long"),
#endif
#endif
#if defined (ENOEXEC)
#if defined (ENOEXEC)
  ENTRY(ENOEXEC, "ENOEXEC", "Exec format error"),
  ENTRY(ENOEXEC, "ENOEXEC", "Exec format error"),
#endif
#endif
#if defined (EBADF)
#if defined (EBADF)
  ENTRY(EBADF, "EBADF", "Bad file number"),
  ENTRY(EBADF, "EBADF", "Bad file number"),
#endif
#endif
#if defined (ECHILD)
#if defined (ECHILD)
  ENTRY(ECHILD, "ECHILD", "No child processes"),
  ENTRY(ECHILD, "ECHILD", "No child processes"),
#endif
#endif
#if defined (EWOULDBLOCK)       /* Put before EAGAIN, sometimes aliased */
#if defined (EWOULDBLOCK)       /* Put before EAGAIN, sometimes aliased */
  ENTRY(EWOULDBLOCK, "EWOULDBLOCK", "Operation would block"),
  ENTRY(EWOULDBLOCK, "EWOULDBLOCK", "Operation would block"),
#endif
#endif
#if defined (EAGAIN)
#if defined (EAGAIN)
  ENTRY(EAGAIN, "EAGAIN", "No more processes"),
  ENTRY(EAGAIN, "EAGAIN", "No more processes"),
#endif
#endif
#if defined (ENOMEM)
#if defined (ENOMEM)
  ENTRY(ENOMEM, "ENOMEM", "Not enough space"),
  ENTRY(ENOMEM, "ENOMEM", "Not enough space"),
#endif
#endif
#if defined (EACCES)
#if defined (EACCES)
  ENTRY(EACCES, "EACCES", "Permission denied"),
  ENTRY(EACCES, "EACCES", "Permission denied"),
#endif
#endif
#if defined (EFAULT)
#if defined (EFAULT)
  ENTRY(EFAULT, "EFAULT", "Bad address"),
  ENTRY(EFAULT, "EFAULT", "Bad address"),
#endif
#endif
#if defined (ENOTBLK)
#if defined (ENOTBLK)
  ENTRY(ENOTBLK, "ENOTBLK", "Block device required"),
  ENTRY(ENOTBLK, "ENOTBLK", "Block device required"),
#endif
#endif
#if defined (EBUSY)
#if defined (EBUSY)
  ENTRY(EBUSY, "EBUSY", "Device busy"),
  ENTRY(EBUSY, "EBUSY", "Device busy"),
#endif
#endif
#if defined (EEXIST)
#if defined (EEXIST)
  ENTRY(EEXIST, "EEXIST", "File exists"),
  ENTRY(EEXIST, "EEXIST", "File exists"),
#endif
#endif
#if defined (EXDEV)
#if defined (EXDEV)
  ENTRY(EXDEV, "EXDEV", "Cross-device link"),
  ENTRY(EXDEV, "EXDEV", "Cross-device link"),
#endif
#endif
#if defined (ENODEV)
#if defined (ENODEV)
  ENTRY(ENODEV, "ENODEV", "No such device"),
  ENTRY(ENODEV, "ENODEV", "No such device"),
#endif
#endif
#if defined (ENOTDIR)
#if defined (ENOTDIR)
  ENTRY(ENOTDIR, "ENOTDIR", "Not a directory"),
  ENTRY(ENOTDIR, "ENOTDIR", "Not a directory"),
#endif
#endif
#if defined (EISDIR)
#if defined (EISDIR)
  ENTRY(EISDIR, "EISDIR", "Is a directory"),
  ENTRY(EISDIR, "EISDIR", "Is a directory"),
#endif
#endif
#if defined (EINVAL)
#if defined (EINVAL)
  ENTRY(EINVAL, "EINVAL", "Invalid argument"),
  ENTRY(EINVAL, "EINVAL", "Invalid argument"),
#endif
#endif
#if defined (ENFILE)
#if defined (ENFILE)
  ENTRY(ENFILE, "ENFILE", "File table overflow"),
  ENTRY(ENFILE, "ENFILE", "File table overflow"),
#endif
#endif
#if defined (EMFILE)
#if defined (EMFILE)
  ENTRY(EMFILE, "EMFILE", "Too many open files"),
  ENTRY(EMFILE, "EMFILE", "Too many open files"),
#endif
#endif
#if defined (ENOTTY)
#if defined (ENOTTY)
  ENTRY(ENOTTY, "ENOTTY", "Not a typewriter"),
  ENTRY(ENOTTY, "ENOTTY", "Not a typewriter"),
#endif
#endif
#if defined (ETXTBSY)
#if defined (ETXTBSY)
  ENTRY(ETXTBSY, "ETXTBSY", "Text file busy"),
  ENTRY(ETXTBSY, "ETXTBSY", "Text file busy"),
#endif
#endif
#if defined (EFBIG)
#if defined (EFBIG)
  ENTRY(EFBIG, "EFBIG", "File too large"),
  ENTRY(EFBIG, "EFBIG", "File too large"),
#endif
#endif
#if defined (ENOSPC)
#if defined (ENOSPC)
  ENTRY(ENOSPC, "ENOSPC", "No space left on device"),
  ENTRY(ENOSPC, "ENOSPC", "No space left on device"),
#endif
#endif
#if defined (ESPIPE)
#if defined (ESPIPE)
  ENTRY(ESPIPE, "ESPIPE", "Illegal seek"),
  ENTRY(ESPIPE, "ESPIPE", "Illegal seek"),
#endif
#endif
#if defined (EROFS)
#if defined (EROFS)
  ENTRY(EROFS, "EROFS", "Read-only file system"),
  ENTRY(EROFS, "EROFS", "Read-only file system"),
#endif
#endif
#if defined (EMLINK)
#if defined (EMLINK)
  ENTRY(EMLINK, "EMLINK", "Too many links"),
  ENTRY(EMLINK, "EMLINK", "Too many links"),
#endif
#endif
#if defined (EPIPE)
#if defined (EPIPE)
  ENTRY(EPIPE, "EPIPE", "Broken pipe"),
  ENTRY(EPIPE, "EPIPE", "Broken pipe"),
#endif
#endif
#if defined (EDOM)
#if defined (EDOM)
  ENTRY(EDOM, "EDOM", "Math argument out of domain of func"),
  ENTRY(EDOM, "EDOM", "Math argument out of domain of func"),
#endif
#endif
#if defined (ERANGE)
#if defined (ERANGE)
  ENTRY(ERANGE, "ERANGE", "Math result not representable"),
  ENTRY(ERANGE, "ERANGE", "Math result not representable"),
#endif
#endif
#if defined (ENOMSG)
#if defined (ENOMSG)
  ENTRY(ENOMSG, "ENOMSG", "No message of desired type"),
  ENTRY(ENOMSG, "ENOMSG", "No message of desired type"),
#endif
#endif
#if defined (EIDRM)
#if defined (EIDRM)
  ENTRY(EIDRM, "EIDRM", "Identifier removed"),
  ENTRY(EIDRM, "EIDRM", "Identifier removed"),
#endif
#endif
#if defined (ECHRNG)
#if defined (ECHRNG)
  ENTRY(ECHRNG, "ECHRNG", "Channel number out of range"),
  ENTRY(ECHRNG, "ECHRNG", "Channel number out of range"),
#endif
#endif
#if defined (EL2NSYNC)
#if defined (EL2NSYNC)
  ENTRY(EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"),
  ENTRY(EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"),
#endif
#endif
#if defined (EL3HLT)
#if defined (EL3HLT)
  ENTRY(EL3HLT, "EL3HLT", "Level 3 halted"),
  ENTRY(EL3HLT, "EL3HLT", "Level 3 halted"),
#endif
#endif
#if defined (EL3RST)
#if defined (EL3RST)
  ENTRY(EL3RST, "EL3RST", "Level 3 reset"),
  ENTRY(EL3RST, "EL3RST", "Level 3 reset"),
#endif
#endif
#if defined (ELNRNG)
#if defined (ELNRNG)
  ENTRY(ELNRNG, "ELNRNG", "Link number out of range"),
  ENTRY(ELNRNG, "ELNRNG", "Link number out of range"),
#endif
#endif
#if defined (EUNATCH)
#if defined (EUNATCH)
  ENTRY(EUNATCH, "EUNATCH", "Protocol driver not attached"),
  ENTRY(EUNATCH, "EUNATCH", "Protocol driver not attached"),
#endif
#endif
#if defined (ENOCSI)
#if defined (ENOCSI)
  ENTRY(ENOCSI, "ENOCSI", "No CSI structure available"),
  ENTRY(ENOCSI, "ENOCSI", "No CSI structure available"),
#endif
#endif
#if defined (EL2HLT)
#if defined (EL2HLT)
  ENTRY(EL2HLT, "EL2HLT", "Level 2 halted"),
  ENTRY(EL2HLT, "EL2HLT", "Level 2 halted"),
#endif
#endif
#if defined (EDEADLK)
#if defined (EDEADLK)
  ENTRY(EDEADLK, "EDEADLK", "Deadlock condition"),
  ENTRY(EDEADLK, "EDEADLK", "Deadlock condition"),
#endif
#endif
#if defined (ENOLCK)
#if defined (ENOLCK)
  ENTRY(ENOLCK, "ENOLCK", "No record locks available"),
  ENTRY(ENOLCK, "ENOLCK", "No record locks available"),
#endif
#endif
#if defined (EBADE)
#if defined (EBADE)
  ENTRY(EBADE, "EBADE", "Invalid exchange"),
  ENTRY(EBADE, "EBADE", "Invalid exchange"),
#endif
#endif
#if defined (EBADR)
#if defined (EBADR)
  ENTRY(EBADR, "EBADR", "Invalid request descriptor"),
  ENTRY(EBADR, "EBADR", "Invalid request descriptor"),
#endif
#endif
#if defined (EXFULL)
#if defined (EXFULL)
  ENTRY(EXFULL, "EXFULL", "Exchange full"),
  ENTRY(EXFULL, "EXFULL", "Exchange full"),
#endif
#endif
#if defined (ENOANO)
#if defined (ENOANO)
  ENTRY(ENOANO, "ENOANO", "No anode"),
  ENTRY(ENOANO, "ENOANO", "No anode"),
#endif
#endif
#if defined (EBADRQC)
#if defined (EBADRQC)
  ENTRY(EBADRQC, "EBADRQC", "Invalid request code"),
  ENTRY(EBADRQC, "EBADRQC", "Invalid request code"),
#endif
#endif
#if defined (EBADSLT)
#if defined (EBADSLT)
  ENTRY(EBADSLT, "EBADSLT", "Invalid slot"),
  ENTRY(EBADSLT, "EBADSLT", "Invalid slot"),
#endif
#endif
#if defined (EDEADLOCK)
#if defined (EDEADLOCK)
  ENTRY(EDEADLOCK, "EDEADLOCK", "File locking deadlock error"),
  ENTRY(EDEADLOCK, "EDEADLOCK", "File locking deadlock error"),
#endif
#endif
#if defined (EBFONT)
#if defined (EBFONT)
  ENTRY(EBFONT, "EBFONT", "Bad font file format"),
  ENTRY(EBFONT, "EBFONT", "Bad font file format"),
#endif
#endif
#if defined (ENOSTR)
#if defined (ENOSTR)
  ENTRY(ENOSTR, "ENOSTR", "Device not a stream"),
  ENTRY(ENOSTR, "ENOSTR", "Device not a stream"),
#endif
#endif
#if defined (ENODATA)
#if defined (ENODATA)
  ENTRY(ENODATA, "ENODATA", "No data available"),
  ENTRY(ENODATA, "ENODATA", "No data available"),
#endif
#endif
#if defined (ETIME)
#if defined (ETIME)
  ENTRY(ETIME, "ETIME", "Timer expired"),
  ENTRY(ETIME, "ETIME", "Timer expired"),
#endif
#endif
#if defined (ENOSR)
#if defined (ENOSR)
  ENTRY(ENOSR, "ENOSR", "Out of streams resources"),
  ENTRY(ENOSR, "ENOSR", "Out of streams resources"),
#endif
#endif
#if defined (ENONET)
#if defined (ENONET)
  ENTRY(ENONET, "ENONET", "Machine is not on the network"),
  ENTRY(ENONET, "ENONET", "Machine is not on the network"),
#endif
#endif
#if defined (ENOPKG)
#if defined (ENOPKG)
  ENTRY(ENOPKG, "ENOPKG", "Package not installed"),
  ENTRY(ENOPKG, "ENOPKG", "Package not installed"),
#endif
#endif
#if defined (EREMOTE)
#if defined (EREMOTE)
  ENTRY(EREMOTE, "EREMOTE", "Object is remote"),
  ENTRY(EREMOTE, "EREMOTE", "Object is remote"),
#endif
#endif
#if defined (ENOLINK)
#if defined (ENOLINK)
  ENTRY(ENOLINK, "ENOLINK", "Link has been severed"),
  ENTRY(ENOLINK, "ENOLINK", "Link has been severed"),
#endif
#endif
#if defined (EADV)
#if defined (EADV)
  ENTRY(EADV, "EADV", "Advertise error"),
  ENTRY(EADV, "EADV", "Advertise error"),
#endif
#endif
#if defined (ESRMNT)
#if defined (ESRMNT)
  ENTRY(ESRMNT, "ESRMNT", "Srmount error"),
  ENTRY(ESRMNT, "ESRMNT", "Srmount error"),
#endif
#endif
#if defined (ECOMM)
#if defined (ECOMM)
  ENTRY(ECOMM, "ECOMM", "Communication error on send"),
  ENTRY(ECOMM, "ECOMM", "Communication error on send"),
#endif
#endif
#if defined (EPROTO)
#if defined (EPROTO)
  ENTRY(EPROTO, "EPROTO", "Protocol error"),
  ENTRY(EPROTO, "EPROTO", "Protocol error"),
#endif
#endif
#if defined (EMULTIHOP)
#if defined (EMULTIHOP)
  ENTRY(EMULTIHOP, "EMULTIHOP", "Multihop attempted"),
  ENTRY(EMULTIHOP, "EMULTIHOP", "Multihop attempted"),
#endif
#endif
#if defined (EDOTDOT)
#if defined (EDOTDOT)
  ENTRY(EDOTDOT, "EDOTDOT", "RFS specific error"),
  ENTRY(EDOTDOT, "EDOTDOT", "RFS specific error"),
#endif
#endif
#if defined (EBADMSG)
#if defined (EBADMSG)
  ENTRY(EBADMSG, "EBADMSG", "Not a data message"),
  ENTRY(EBADMSG, "EBADMSG", "Not a data message"),
#endif
#endif
#if defined (ENAMETOOLONG)
#if defined (ENAMETOOLONG)
  ENTRY(ENAMETOOLONG, "ENAMETOOLONG", "File name too long"),
  ENTRY(ENAMETOOLONG, "ENAMETOOLONG", "File name too long"),
#endif
#endif
#if defined (EOVERFLOW)
#if defined (EOVERFLOW)
  ENTRY(EOVERFLOW, "EOVERFLOW", "Value too large for defined data type"),
  ENTRY(EOVERFLOW, "EOVERFLOW", "Value too large for defined data type"),
#endif
#endif
#if defined (ENOTUNIQ)
#if defined (ENOTUNIQ)
  ENTRY(ENOTUNIQ, "ENOTUNIQ", "Name not unique on network"),
  ENTRY(ENOTUNIQ, "ENOTUNIQ", "Name not unique on network"),
#endif
#endif
#if defined (EBADFD)
#if defined (EBADFD)
  ENTRY(EBADFD, "EBADFD", "File descriptor in bad state"),
  ENTRY(EBADFD, "EBADFD", "File descriptor in bad state"),
#endif
#endif
#if defined (EREMCHG)
#if defined (EREMCHG)
  ENTRY(EREMCHG, "EREMCHG", "Remote address changed"),
  ENTRY(EREMCHG, "EREMCHG", "Remote address changed"),
#endif
#endif
#if defined (ELIBACC)
#if defined (ELIBACC)
  ENTRY(ELIBACC, "ELIBACC", "Can not access a needed shared library"),
  ENTRY(ELIBACC, "ELIBACC", "Can not access a needed shared library"),
#endif
#endif
#if defined (ELIBBAD)
#if defined (ELIBBAD)
  ENTRY(ELIBBAD, "ELIBBAD", "Accessing a corrupted shared library"),
  ENTRY(ELIBBAD, "ELIBBAD", "Accessing a corrupted shared library"),
#endif
#endif
#if defined (ELIBSCN)
#if defined (ELIBSCN)
  ENTRY(ELIBSCN, "ELIBSCN", ".lib section in a.out corrupted"),
  ENTRY(ELIBSCN, "ELIBSCN", ".lib section in a.out corrupted"),
#endif
#endif
#if defined (ELIBMAX)
#if defined (ELIBMAX)
  ENTRY(ELIBMAX, "ELIBMAX", "Attempting to link in too many shared libraries"),
  ENTRY(ELIBMAX, "ELIBMAX", "Attempting to link in too many shared libraries"),
#endif
#endif
#if defined (ELIBEXEC)
#if defined (ELIBEXEC)
  ENTRY(ELIBEXEC, "ELIBEXEC", "Cannot exec a shared library directly"),
  ENTRY(ELIBEXEC, "ELIBEXEC", "Cannot exec a shared library directly"),
#endif
#endif
#if defined (EILSEQ)
#if defined (EILSEQ)
  ENTRY(EILSEQ, "EILSEQ", "Illegal byte sequence"),
  ENTRY(EILSEQ, "EILSEQ", "Illegal byte sequence"),
#endif
#endif
#if defined (ENOSYS)
#if defined (ENOSYS)
  ENTRY(ENOSYS, "ENOSYS", "Operation not applicable"),
  ENTRY(ENOSYS, "ENOSYS", "Operation not applicable"),
#endif
#endif
#if defined (ELOOP)
#if defined (ELOOP)
  ENTRY(ELOOP, "ELOOP", "Too many symbolic links encountered"),
  ENTRY(ELOOP, "ELOOP", "Too many symbolic links encountered"),
#endif
#endif
#if defined (ERESTART)
#if defined (ERESTART)
  ENTRY(ERESTART, "ERESTART", "Interrupted system call should be restarted"),
  ENTRY(ERESTART, "ERESTART", "Interrupted system call should be restarted"),
#endif
#endif
#if defined (ESTRPIPE)
#if defined (ESTRPIPE)
  ENTRY(ESTRPIPE, "ESTRPIPE", "Streams pipe error"),
  ENTRY(ESTRPIPE, "ESTRPIPE", "Streams pipe error"),
#endif
#endif
#if defined (ENOTEMPTY)
#if defined (ENOTEMPTY)
  ENTRY(ENOTEMPTY, "ENOTEMPTY", "Directory not empty"),
  ENTRY(ENOTEMPTY, "ENOTEMPTY", "Directory not empty"),
#endif
#endif
#if defined (EUSERS)
#if defined (EUSERS)
  ENTRY(EUSERS, "EUSERS", "Too many users"),
  ENTRY(EUSERS, "EUSERS", "Too many users"),
#endif
#endif
#if defined (ENOTSOCK)
#if defined (ENOTSOCK)
  ENTRY(ENOTSOCK, "ENOTSOCK", "Socket operation on non-socket"),
  ENTRY(ENOTSOCK, "ENOTSOCK", "Socket operation on non-socket"),
#endif
#endif
#if defined (EDESTADDRREQ)
#if defined (EDESTADDRREQ)
  ENTRY(EDESTADDRREQ, "EDESTADDRREQ", "Destination address required"),
  ENTRY(EDESTADDRREQ, "EDESTADDRREQ", "Destination address required"),
#endif
#endif
#if defined (EMSGSIZE)
#if defined (EMSGSIZE)
  ENTRY(EMSGSIZE, "EMSGSIZE", "Message too long"),
  ENTRY(EMSGSIZE, "EMSGSIZE", "Message too long"),
#endif
#endif
#if defined (EPROTOTYPE)
#if defined (EPROTOTYPE)
  ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"),
  ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"),
#endif
#endif
#if defined (ENOPROTOOPT)
#if defined (ENOPROTOOPT)
  ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"),
  ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"),
#endif
#endif
#if defined (EPROTONOSUPPORT)
#if defined (EPROTONOSUPPORT)
  ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"),
  ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"),
#endif
#endif
#if defined (ESOCKTNOSUPPORT)
#if defined (ESOCKTNOSUPPORT)
  ENTRY(ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "Socket type not supported"),
  ENTRY(ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "Socket type not supported"),
#endif
#endif
#if defined (EOPNOTSUPP)
#if defined (EOPNOTSUPP)
  ENTRY(EOPNOTSUPP, "EOPNOTSUPP", "Operation not supported on transport endpoint"),
  ENTRY(EOPNOTSUPP, "EOPNOTSUPP", "Operation not supported on transport endpoint"),
#endif
#endif
#if defined (EPFNOSUPPORT)
#if defined (EPFNOSUPPORT)
  ENTRY(EPFNOSUPPORT, "EPFNOSUPPORT", "Protocol family not supported"),
  ENTRY(EPFNOSUPPORT, "EPFNOSUPPORT", "Protocol family not supported"),
#endif
#endif
#if defined (EAFNOSUPPORT)
#if defined (EAFNOSUPPORT)
  ENTRY(EAFNOSUPPORT, "EAFNOSUPPORT", "Address family not supported by protocol"),
  ENTRY(EAFNOSUPPORT, "EAFNOSUPPORT", "Address family not supported by protocol"),
#endif
#endif
#if defined (EADDRINUSE)
#if defined (EADDRINUSE)
  ENTRY(EADDRINUSE, "EADDRINUSE", "Address already in use"),
  ENTRY(EADDRINUSE, "EADDRINUSE", "Address already in use"),
#endif
#endif
#if defined (EADDRNOTAVAIL)
#if defined (EADDRNOTAVAIL)
  ENTRY(EADDRNOTAVAIL, "EADDRNOTAVAIL","Cannot assign requested address"),
  ENTRY(EADDRNOTAVAIL, "EADDRNOTAVAIL","Cannot assign requested address"),
#endif
#endif
#if defined (ENETDOWN)
#if defined (ENETDOWN)
  ENTRY(ENETDOWN, "ENETDOWN", "Network is down"),
  ENTRY(ENETDOWN, "ENETDOWN", "Network is down"),
#endif
#endif
#if defined (ENETUNREACH)
#if defined (ENETUNREACH)
  ENTRY(ENETUNREACH, "ENETUNREACH", "Network is unreachable"),
  ENTRY(ENETUNREACH, "ENETUNREACH", "Network is unreachable"),
#endif
#endif
#if defined (ENETRESET)
#if defined (ENETRESET)
  ENTRY(ENETRESET, "ENETRESET", "Network dropped connection because of reset"),
  ENTRY(ENETRESET, "ENETRESET", "Network dropped connection because of reset"),
#endif
#endif
#if defined (ECONNABORTED)
#if defined (ECONNABORTED)
  ENTRY(ECONNABORTED, "ECONNABORTED", "Software caused connection abort"),
  ENTRY(ECONNABORTED, "ECONNABORTED", "Software caused connection abort"),
#endif
#endif
#if defined (ECONNRESET)
#if defined (ECONNRESET)
  ENTRY(ECONNRESET, "ECONNRESET", "Connection reset by peer"),
  ENTRY(ECONNRESET, "ECONNRESET", "Connection reset by peer"),
#endif
#endif
#if defined (ENOBUFS)
#if defined (ENOBUFS)
  ENTRY(ENOBUFS, "ENOBUFS", "No buffer space available"),
  ENTRY(ENOBUFS, "ENOBUFS", "No buffer space available"),
#endif
#endif
#if defined (EISCONN)
#if defined (EISCONN)
  ENTRY(EISCONN, "EISCONN", "Transport endpoint is already connected"),
  ENTRY(EISCONN, "EISCONN", "Transport endpoint is already connected"),
#endif
#endif
#if defined (ENOTCONN)
#if defined (ENOTCONN)
  ENTRY(ENOTCONN, "ENOTCONN", "Transport endpoint is not connected"),
  ENTRY(ENOTCONN, "ENOTCONN", "Transport endpoint is not connected"),
#endif
#endif
#if defined (ESHUTDOWN)
#if defined (ESHUTDOWN)
  ENTRY(ESHUTDOWN, "ESHUTDOWN", "Cannot send after transport endpoint shutdown"),
  ENTRY(ESHUTDOWN, "ESHUTDOWN", "Cannot send after transport endpoint shutdown"),
#endif
#endif
#if defined (ETOOMANYREFS)
#if defined (ETOOMANYREFS)
  ENTRY(ETOOMANYREFS, "ETOOMANYREFS", "Too many references: cannot splice"),
  ENTRY(ETOOMANYREFS, "ETOOMANYREFS", "Too many references: cannot splice"),
#endif
#endif
#if defined (ETIMEDOUT)
#if defined (ETIMEDOUT)
  ENTRY(ETIMEDOUT, "ETIMEDOUT", "Connection timed out"),
  ENTRY(ETIMEDOUT, "ETIMEDOUT", "Connection timed out"),
#endif
#endif
#if defined (ECONNREFUSED)
#if defined (ECONNREFUSED)
  ENTRY(ECONNREFUSED, "ECONNREFUSED", "Connection refused"),
  ENTRY(ECONNREFUSED, "ECONNREFUSED", "Connection refused"),
#endif
#endif
#if defined (EHOSTDOWN)
#if defined (EHOSTDOWN)
  ENTRY(EHOSTDOWN, "EHOSTDOWN", "Host is down"),
  ENTRY(EHOSTDOWN, "EHOSTDOWN", "Host is down"),
#endif
#endif
#if defined (EHOSTUNREACH)
#if defined (EHOSTUNREACH)
  ENTRY(EHOSTUNREACH, "EHOSTUNREACH", "No route to host"),
  ENTRY(EHOSTUNREACH, "EHOSTUNREACH", "No route to host"),
#endif
#endif
#if defined (EALREADY)
#if defined (EALREADY)
  ENTRY(EALREADY, "EALREADY", "Operation already in progress"),
  ENTRY(EALREADY, "EALREADY", "Operation already in progress"),
#endif
#endif
#if defined (EINPROGRESS)
#if defined (EINPROGRESS)
  ENTRY(EINPROGRESS, "EINPROGRESS", "Operation now in progress"),
  ENTRY(EINPROGRESS, "EINPROGRESS", "Operation now in progress"),
#endif
#endif
#if defined (ESTALE)
#if defined (ESTALE)
  ENTRY(ESTALE, "ESTALE", "Stale NFS file handle"),
  ENTRY(ESTALE, "ESTALE", "Stale NFS file handle"),
#endif
#endif
#if defined (EUCLEAN)
#if defined (EUCLEAN)
  ENTRY(EUCLEAN, "EUCLEAN", "Structure needs cleaning"),
  ENTRY(EUCLEAN, "EUCLEAN", "Structure needs cleaning"),
#endif
#endif
#if defined (ENOTNAM)
#if defined (ENOTNAM)
  ENTRY(ENOTNAM, "ENOTNAM", "Not a XENIX named type file"),
  ENTRY(ENOTNAM, "ENOTNAM", "Not a XENIX named type file"),
#endif
#endif
#if defined (ENAVAIL)
#if defined (ENAVAIL)
  ENTRY(ENAVAIL, "ENAVAIL", "No XENIX semaphores available"),
  ENTRY(ENAVAIL, "ENAVAIL", "No XENIX semaphores available"),
#endif
#endif
#if defined (EISNAM)
#if defined (EISNAM)
  ENTRY(EISNAM, "EISNAM", "Is a named type file"),
  ENTRY(EISNAM, "EISNAM", "Is a named type file"),
#endif
#endif
#if defined (EREMOTEIO)
#if defined (EREMOTEIO)
  ENTRY(EREMOTEIO, "EREMOTEIO", "Remote I/O error"),
  ENTRY(EREMOTEIO, "EREMOTEIO", "Remote I/O error"),
#endif
#endif
  ENTRY(0, NULL, NULL)
  ENTRY(0, NULL, NULL)
};
};
 
 
#ifdef EVMSERR
#ifdef EVMSERR
/* This is not in the table, because the numeric value of EVMSERR (32767)
/* This is not in the table, because the numeric value of EVMSERR (32767)
   lies outside the range of sys_errlist[].  */
   lies outside the range of sys_errlist[].  */
static struct { int value; const char *name, *msg; }
static struct { int value; const char *name, *msg; }
  evmserr = { EVMSERR, "EVMSERR", "VMS-specific error" };
  evmserr = { EVMSERR, "EVMSERR", "VMS-specific error" };
#endif
#endif
 
 
/* Translation table allocated and initialized at runtime.  Indexed by the
/* Translation table allocated and initialized at runtime.  Indexed by the
   errno value to find the equivalent symbolic value. */
   errno value to find the equivalent symbolic value. */
 
 
static const char **error_names;
static const char **error_names;
static int num_error_names = 0;
static int num_error_names = 0;
 
 
/* Translation table allocated and initialized at runtime, if it does not
/* Translation table allocated and initialized at runtime, if it does not
   already exist in the host environment.  Indexed by the errno value to find
   already exist in the host environment.  Indexed by the errno value to find
   the descriptive string.
   the descriptive string.
 
 
   We don't export it for use in other modules because even though it has the
   We don't export it for use in other modules because even though it has the
   same name, it differs from other implementations in that it is dynamically
   same name, it differs from other implementations in that it is dynamically
   initialized rather than statically initialized. */
   initialized rather than statically initialized. */
 
 
#ifndef HAVE_SYS_ERRLIST
#ifndef HAVE_SYS_ERRLIST
 
 
#define sys_nerr sys_nerr__
#define sys_nerr sys_nerr__
#define sys_errlist sys_errlist__
#define sys_errlist sys_errlist__
static int sys_nerr;
static int sys_nerr;
static const char **sys_errlist;
static const char **sys_errlist;
 
 
#else
#else
 
 
extern int sys_nerr;
extern int sys_nerr;
extern char *sys_errlist[];
extern char *sys_errlist[];
 
 
#endif
#endif
 
 
/*
/*
 
 
NAME
NAME
 
 
        init_error_tables -- initialize the name and message tables
        init_error_tables -- initialize the name and message tables
 
 
SYNOPSIS
SYNOPSIS
 
 
        static void init_error_tables ();
        static void init_error_tables ();
 
 
DESCRIPTION
DESCRIPTION
 
 
        Using the error_table, which is initialized at compile time, generate
        Using the error_table, which is initialized at compile time, generate
        the error_names and the sys_errlist (if needed) tables, which are
        the error_names and the sys_errlist (if needed) tables, which are
        indexed at runtime by a specific errno value.
        indexed at runtime by a specific errno value.
 
 
BUGS
BUGS
 
 
        The initialization of the tables may fail under low memory conditions,
        The initialization of the tables may fail under low memory conditions,
        in which case we don't do anything particularly useful, but we don't
        in which case we don't do anything particularly useful, but we don't
        bomb either.  Who knows, it might succeed at a later point if we free
        bomb either.  Who knows, it might succeed at a later point if we free
        some memory in the meantime.  In any case, the other routines know
        some memory in the meantime.  In any case, the other routines know
        how to deal with lack of a table after trying to initialize it.  This
        how to deal with lack of a table after trying to initialize it.  This
        may or may not be considered to be a bug, that we don't specifically
        may or may not be considered to be a bug, that we don't specifically
        warn about this particular failure mode.
        warn about this particular failure mode.
 
 
*/
*/
 
 
static void
static void
init_error_tables (void)
init_error_tables (void)
{
{
  const struct error_info *eip;
  const struct error_info *eip;
  int nbytes;
  int nbytes;
 
 
  /* If we haven't already scanned the error_table once to find the maximum
  /* If we haven't already scanned the error_table once to find the maximum
     errno value, then go find it now. */
     errno value, then go find it now. */
 
 
  if (num_error_names == 0)
  if (num_error_names == 0)
    {
    {
      for (eip = error_table; eip -> name != NULL; eip++)
      for (eip = error_table; eip -> name != NULL; eip++)
        {
        {
          if (eip -> value >= num_error_names)
          if (eip -> value >= num_error_names)
            {
            {
              num_error_names = eip -> value + 1;
              num_error_names = eip -> value + 1;
            }
            }
        }
        }
    }
    }
 
 
  /* Now attempt to allocate the error_names table, zero it out, and then
  /* Now attempt to allocate the error_names table, zero it out, and then
     initialize it from the statically initialized error_table. */
     initialize it from the statically initialized error_table. */
 
 
  if (error_names == NULL)
  if (error_names == NULL)
    {
    {
      nbytes = num_error_names * sizeof (char *);
      nbytes = num_error_names * sizeof (char *);
      if ((error_names = (const char **) malloc (nbytes)) != NULL)
      if ((error_names = (const char **) malloc (nbytes)) != NULL)
        {
        {
          memset (error_names, 0, nbytes);
          memset (error_names, 0, nbytes);
          for (eip = error_table; eip -> name != NULL; eip++)
          for (eip = error_table; eip -> name != NULL; eip++)
            {
            {
              error_names[eip -> value] = eip -> name;
              error_names[eip -> value] = eip -> name;
            }
            }
        }
        }
    }
    }
 
 
#ifndef HAVE_SYS_ERRLIST
#ifndef HAVE_SYS_ERRLIST
 
 
  /* Now attempt to allocate the sys_errlist table, zero it out, and then
  /* Now attempt to allocate the sys_errlist table, zero it out, and then
     initialize it from the statically initialized error_table. */
     initialize it from the statically initialized error_table. */
 
 
  if (sys_errlist == NULL)
  if (sys_errlist == NULL)
    {
    {
      nbytes = num_error_names * sizeof (char *);
      nbytes = num_error_names * sizeof (char *);
      if ((sys_errlist = (const char **) malloc (nbytes)) != NULL)
      if ((sys_errlist = (const char **) malloc (nbytes)) != NULL)
        {
        {
          memset (sys_errlist, 0, nbytes);
          memset (sys_errlist, 0, nbytes);
          sys_nerr = num_error_names;
          sys_nerr = num_error_names;
          for (eip = error_table; eip -> name != NULL; eip++)
          for (eip = error_table; eip -> name != NULL; eip++)
            {
            {
              sys_errlist[eip -> value] = eip -> msg;
              sys_errlist[eip -> value] = eip -> msg;
            }
            }
        }
        }
    }
    }
 
 
#endif
#endif
 
 
}
}
 
 
/*
/*
 
 
 
 
@deftypefn Extension int errno_max (void)
@deftypefn Extension int errno_max (void)
 
 
Returns the maximum @code{errno} value for which a corresponding
Returns the maximum @code{errno} value for which a corresponding
symbolic name or message is available.  Note that in the case where we
symbolic name or message is available.  Note that in the case where we
use the @code{sys_errlist} supplied by the system, it is possible for
use the @code{sys_errlist} supplied by the system, it is possible for
there to be more symbolic names than messages, or vice versa.  In
there to be more symbolic names than messages, or vice versa.  In
fact, the manual page for @code{perror(3C)} explicitly warns that one
fact, the manual page for @code{perror(3C)} explicitly warns that one
should check the size of the table (@code{sys_nerr}) before indexing
should check the size of the table (@code{sys_nerr}) before indexing
it, since new error codes may be added to the system before they are
it, since new error codes may be added to the system before they are
added to the table.  Thus @code{sys_nerr} might be smaller than value
added to the table.  Thus @code{sys_nerr} might be smaller than value
implied by the largest @code{errno} value defined in @code{<errno.h>}.
implied by the largest @code{errno} value defined in @code{<errno.h>}.
 
 
We return the maximum value that can be used to obtain a meaningful
We return the maximum value that can be used to obtain a meaningful
symbolic name or message.
symbolic name or message.
 
 
@end deftypefn
@end deftypefn
 
 
*/
*/
 
 
int
int
errno_max (void)
errno_max (void)
{
{
  int maxsize;
  int maxsize;
 
 
  if (error_names == NULL)
  if (error_names == NULL)
    {
    {
      init_error_tables ();
      init_error_tables ();
    }
    }
  maxsize = MAX (sys_nerr, num_error_names);
  maxsize = MAX (sys_nerr, num_error_names);
  return (maxsize - 1);
  return (maxsize - 1);
}
}
 
 
#ifndef HAVE_STRERROR
#ifndef HAVE_STRERROR
 
 
/*
/*
 
 
@deftypefn Supplemental char* strerror (int @var{errnoval})
@deftypefn Supplemental char* strerror (int @var{errnoval})
 
 
Maps an @code{errno} number to an error message string, the contents
Maps an @code{errno} number to an error message string, the contents
of which are implementation defined.  On systems which have the
of which are implementation defined.  On systems which have the
external variables @code{sys_nerr} and @code{sys_errlist}, these
external variables @code{sys_nerr} and @code{sys_errlist}, these
strings will be the same as the ones used by @code{perror}.
strings will be the same as the ones used by @code{perror}.
 
 
If the supplied error number is within the valid range of indices for
If the supplied error number is within the valid range of indices for
the @code{sys_errlist}, but no message is available for the particular
the @code{sys_errlist}, but no message is available for the particular
error number, then returns the string @samp{Error @var{num}}, where
error number, then returns the string @samp{Error @var{num}}, where
@var{num} is the error number.
@var{num} is the error number.
 
 
If the supplied error number is not a valid index into
If the supplied error number is not a valid index into
@code{sys_errlist}, returns @code{NULL}.
@code{sys_errlist}, returns @code{NULL}.
 
 
The returned string is only guaranteed to be valid only until the
The returned string is only guaranteed to be valid only until the
next call to @code{strerror}.
next call to @code{strerror}.
 
 
@end deftypefn
@end deftypefn
 
 
*/
*/
 
 
char *
char *
strerror (int errnoval)
strerror (int errnoval)
{
{
  const char *msg;
  const char *msg;
  static char buf[32];
  static char buf[32];
 
 
#ifndef HAVE_SYS_ERRLIST
#ifndef HAVE_SYS_ERRLIST
 
 
  if (error_names == NULL)
  if (error_names == NULL)
    {
    {
      init_error_tables ();
      init_error_tables ();
    }
    }
 
 
#endif
#endif
 
 
  if ((errnoval < 0) || (errnoval >= sys_nerr))
  if ((errnoval < 0) || (errnoval >= sys_nerr))
    {
    {
#ifdef EVMSERR
#ifdef EVMSERR
      if (errnoval == evmserr.value)
      if (errnoval == evmserr.value)
        msg = evmserr.msg;
        msg = evmserr.msg;
      else
      else
#endif
#endif
      /* Out of range, just return NULL */
      /* Out of range, just return NULL */
      msg = NULL;
      msg = NULL;
    }
    }
  else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL))
  else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL))
    {
    {
      /* In range, but no sys_errlist or no entry at this index. */
      /* In range, but no sys_errlist or no entry at this index. */
      sprintf (buf, "Error %d", errnoval);
      sprintf (buf, "Error %d", errnoval);
      msg = buf;
      msg = buf;
    }
    }
  else
  else
    {
    {
      /* In range, and a valid message.  Just return the message. */
      /* In range, and a valid message.  Just return the message. */
      msg = (char *) sys_errlist[errnoval];
      msg = (char *) sys_errlist[errnoval];
    }
    }
 
 
  return (msg);
  return (msg);
}
}
 
 
#endif  /* ! HAVE_STRERROR */
#endif  /* ! HAVE_STRERROR */
 
 
 
 
/*
/*
 
 
@deftypefn Replacement {const char*} strerrno (int @var{errnum})
@deftypefn Replacement {const char*} strerrno (int @var{errnum})
 
 
Given an error number returned from a system call (typically returned
Given an error number returned from a system call (typically returned
in @code{errno}), returns a pointer to a string containing the
in @code{errno}), returns a pointer to a string containing the
symbolic name of that error number, as found in @code{<errno.h>}.
symbolic name of that error number, as found in @code{<errno.h>}.
 
 
If the supplied error number is within the valid range of indices for
If the supplied error number is within the valid range of indices for
symbolic names, but no name is available for the particular error
symbolic names, but no name is available for the particular error
number, then returns the string @samp{Error @var{num}}, where @var{num}
number, then returns the string @samp{Error @var{num}}, where @var{num}
is the error number.
is the error number.
 
 
If the supplied error number is not within the range of valid
If the supplied error number is not within the range of valid
indices, then returns @code{NULL}.
indices, then returns @code{NULL}.
 
 
The contents of the location pointed to are only guaranteed to be
The contents of the location pointed to are only guaranteed to be
valid until the next call to @code{strerrno}.
valid until the next call to @code{strerrno}.
 
 
@end deftypefn
@end deftypefn
 
 
*/
*/
 
 
const char *
const char *
strerrno (int errnoval)
strerrno (int errnoval)
{
{
  const char *name;
  const char *name;
  static char buf[32];
  static char buf[32];
 
 
  if (error_names == NULL)
  if (error_names == NULL)
    {
    {
      init_error_tables ();
      init_error_tables ();
    }
    }
 
 
  if ((errnoval < 0) || (errnoval >= num_error_names))
  if ((errnoval < 0) || (errnoval >= num_error_names))
    {
    {
#ifdef EVMSERR
#ifdef EVMSERR
      if (errnoval == evmserr.value)
      if (errnoval == evmserr.value)
        name = evmserr.name;
        name = evmserr.name;
      else
      else
#endif
#endif
      /* Out of range, just return NULL */
      /* Out of range, just return NULL */
      name = NULL;
      name = NULL;
    }
    }
  else if ((error_names == NULL) || (error_names[errnoval] == NULL))
  else if ((error_names == NULL) || (error_names[errnoval] == NULL))
    {
    {
      /* In range, but no error_names or no entry at this index. */
      /* In range, but no error_names or no entry at this index. */
      sprintf (buf, "Error %d", errnoval);
      sprintf (buf, "Error %d", errnoval);
      name = (const char *) buf;
      name = (const char *) buf;
    }
    }
  else
  else
    {
    {
      /* In range, and a valid name.  Just return the name. */
      /* In range, and a valid name.  Just return the name. */
      name = error_names[errnoval];
      name = error_names[errnoval];
    }
    }
 
 
  return (name);
  return (name);
}
}
 
 
/*
/*
 
 
@deftypefn Extension int strtoerrno (const char *@var{name})
@deftypefn Extension int strtoerrno (const char *@var{name})
 
 
Given the symbolic name of a error number (e.g., @code{EACCES}), map it
Given the symbolic name of a error number (e.g., @code{EACCES}), map it
to an errno value.  If no translation is found, returns 0.
to an errno value.  If no translation is found, returns 0.
 
 
@end deftypefn
@end deftypefn
 
 
*/
*/
 
 
int
int
strtoerrno (const char *name)
strtoerrno (const char *name)
{
{
  int errnoval = 0;
  int errnoval = 0;
 
 
  if (name != NULL)
  if (name != NULL)
    {
    {
      if (error_names == NULL)
      if (error_names == NULL)
        {
        {
          init_error_tables ();
          init_error_tables ();
        }
        }
      for (errnoval = 0; errnoval < num_error_names; errnoval++)
      for (errnoval = 0; errnoval < num_error_names; errnoval++)
        {
        {
          if ((error_names[errnoval] != NULL) &&
          if ((error_names[errnoval] != NULL) &&
              (strcmp (name, error_names[errnoval]) == 0))
              (strcmp (name, error_names[errnoval]) == 0))
            {
            {
              break;
              break;
            }
            }
        }
        }
      if (errnoval == num_error_names)
      if (errnoval == num_error_names)
        {
        {
#ifdef EVMSERR
#ifdef EVMSERR
          if (strcmp (name, evmserr.name) == 0)
          if (strcmp (name, evmserr.name) == 0)
            errnoval = evmserr.value;
            errnoval = evmserr.value;
          else
          else
#endif
#endif
          errnoval = 0;
          errnoval = 0;
        }
        }
    }
    }
  return (errnoval);
  return (errnoval);
}
}
 
 
 
 
/* A simple little main that does nothing but print all the errno translations
/* A simple little main that does nothing but print all the errno translations
   if MAIN is defined and this file is compiled and linked. */
   if MAIN is defined and this file is compiled and linked. */
 
 
#ifdef MAIN
#ifdef MAIN
 
 
#include <stdio.h>
#include <stdio.h>
 
 
int
int
main (void)
main (void)
{
{
  int errn;
  int errn;
  int errnmax;
  int errnmax;
  const char *name;
  const char *name;
  const char *msg;
  const char *msg;
  char *strerror ();
  char *strerror ();
 
 
  errnmax = errno_max ();
  errnmax = errno_max ();
  printf ("%d entries in names table.\n", num_error_names);
  printf ("%d entries in names table.\n", num_error_names);
  printf ("%d entries in messages table.\n", sys_nerr);
  printf ("%d entries in messages table.\n", sys_nerr);
  printf ("%d is max useful index.\n", errnmax);
  printf ("%d is max useful index.\n", errnmax);
 
 
  /* Keep printing values until we get to the end of *both* tables, not
  /* Keep printing values until we get to the end of *both* tables, not
     *either* table.  Note that knowing the maximum useful index does *not*
     *either* table.  Note that knowing the maximum useful index does *not*
     relieve us of the responsibility of testing the return pointer for
     relieve us of the responsibility of testing the return pointer for
     NULL. */
     NULL. */
 
 
  for (errn = 0; errn <= errnmax; errn++)
  for (errn = 0; errn <= errnmax; errn++)
    {
    {
      name = strerrno (errn);
      name = strerrno (errn);
      name = (name == NULL) ? "<NULL>" : name;
      name = (name == NULL) ? "<NULL>" : name;
      msg = strerror (errn);
      msg = strerror (errn);
      msg = (msg == NULL) ? "<NULL>" : msg;
      msg = (msg == NULL) ? "<NULL>" : msg;
      printf ("%-4d%-18s%s\n", errn, name, msg);
      printf ("%-4d%-18s%s\n", errn, name, msg);
    }
    }
 
 
  return 0;
  return 0;
}
}
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.