home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
gnu
/
libg++-2.6-fsf.lha
/
libg++-2.6
/
libiberty
/
strerror.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-20
|
21KB
|
824 lines
/* Extended support for using errno values.
Copyright (C) 1992 Free Software Foundation, Inc.
Written by Fred Fish. fnf@cygnus.com
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
#include "ansidecl.h"
#include "libiberty.h"
#include "config.h"
#ifndef NEED_sys_errlist
/* 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
incompatible with our later declaration, perhaps by using const
attributes. So we hide the declaration in errno.h (if any) using a
macro. */
#define sys_errlist sys_errlist__
#endif
#include <stdio.h>
#include <errno.h>
#ifndef NEED_sys_errlist
#undef sys_errlist
#endif
/* Routines imported from standard C runtime libraries. */
#ifdef __STDC__
#include <stddef.h>
extern void *malloc (size_t size); /* 4.10.3.3 */
extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */
#else /* !__STDC__ */
extern char *malloc (); /* Standard memory allocater */
extern char *memset ();
#endif /* __STDC__ */
#ifndef MAX
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
/* Translation table for errno values. See intro(2) in most UNIX systems
Programmers Reference Manuals.
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
value.
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.
It's sort of ugly, but at least its portable. */
struct error_info
{
int value; /* The numeric value from <errno.h> */
const char *name; /* The equivalent symbolic value */
#ifdef NEED_sys_errlist
const char *msg; /* Short message about this value */
#endif
};
#ifdef NEED_sys_errlist
# define ENTRY(value, name, msg) {value, name, msg}
#else
# define ENTRY(value, name, msg) {value, name}
#endif
static const struct error_info error_table[] =
{
#if defined (EPERM)
ENTRY(EPERM, "EPERM", "Not owner"),
#endif
#if defined (ENOENT)
ENTRY(ENOENT, "ENOENT", "No such file or directory"),
#endif
#if defined (ESRCH)
ENTRY(ESRCH, "ESRCH", "No such process"),
#endif
#if defined (EINTR)
ENTRY(EINTR, "EINTR", "Interrupted system call"),
#endif
#if defined (EIO)
ENTRY(EIO, "EIO", "I/O error"),
#endif
#if defined (ENXIO)
ENTRY(ENXIO, "ENXIO", "No such device or address"),
#endif
#if defined (E2BIG)
ENTRY(E2BIG, "E2BIG", "Arg list too long"),
#endif
#if defined (ENOEXEC)
ENTRY(ENOEXEC, "ENOEXEC", "Exec format error"),
#endif
#if defined (EBADF)
ENTRY(EBADF, "EBADF", "Bad file number"),
#endif
#if defined (ECHILD)
ENTRY(ECHILD, "ECHILD", "No child processes"),
#endif
#if defined (EWOULDBLOCK) /* Put before EAGAIN, sometimes aliased */
ENTRY(EWOULDBLOCK, "EWOULDBLOCK", "Operation would block"),
#endif
#if defined (EAGAIN)
ENTRY(EAGAIN, "EAGAIN", "No more processes"),
#endif
#if defined (ENOMEM)
ENTRY(ENOMEM, "ENOMEM", "Not enough space"),
#endif
#if defined (EACCES)
ENTRY(EACCES, "EACCES", "Permission denied"),
#endif
#if defined (EFAULT)
ENTRY(EFAULT, "EFAULT", "Bad address"),
#endif
#if defined (ENOTBLK)
ENTRY(ENOTBLK, "ENOTBLK", "Block device required"),
#endif
#if defined (EBUSY)
ENTRY(EBUSY, "EBUSY", "Device busy"),
#endif
#if defined (EEXIST)
ENTRY(EEXIST, "EEXIST", "File exists"),
#endif
#if defined (EXDEV)
ENTRY(EXDEV, "EXDEV", "Cross-device link"),
#endif
#if defined (ENODEV)
ENTRY(ENODEV, "ENODEV", "No such device"),
#endif
#if defined (ENOTDIR)
ENTRY(ENOTDIR, "ENOTDIR", "Not a directory"),
#endif
#if defined (EISDIR)
ENTRY(EISDIR, "EISDIR", "Is a directory"),
#endif
#if defined (EINVAL)
ENTRY(EINVAL, "EINVAL", "Invalid argument"),
#endif
#if defined (ENFILE)
ENTRY(ENFILE, "ENFILE", "File table overflow"),
#endif
#if defined (EMFILE)
ENTRY(EMFILE, "EMFILE", "Too many open files"),
#endif
#if defined (ENOTTY)
ENTRY(ENOTTY, "ENOTTY", "Not a typewriter"),
#endif
#if defined (ETXTBSY)
ENTRY(ETXTBSY, "ETXTBSY", "Text file busy"),
#endif
#if defined (EFBIG)
ENTRY(EFBIG, "EFBIG", "File too large"),
#endif
#if defined (ENOSPC)
ENTRY(ENOSPC, "ENOSPC", "No space left on device"),
#endif
#if defined (ESPIPE)
ENTRY(ESPIPE, "ESPIPE", "Illegal seek"),
#endif
#if defined (EROFS)
ENTRY(EROFS, "EROFS", "Read-only file system"),
#endif
#if defined (EMLINK)
ENTRY(EMLINK, "EMLINK", "Too many links"),
#endif
#if defined (EPIPE)
ENTRY(EPIPE, "EPIPE", "Broken pipe"),
#endif
#if defined (EDOM)
ENTRY(EDOM, "EDOM", "Math argument out of domain of func"),
#endif
#if defined (ERANGE)
ENTRY(ERANGE, "ERANGE", "Math result not representable"),
#endif
#if defined (ENOMSG)
ENTRY(ENOMSG, "ENOMSG", "No message of desired type"),
#endif
#if defined (EIDRM)
ENTRY(EIDRM, "EIDRM", "Identifier removed"),
#endif
#if defined (ECHRNG)
ENTRY(ECHRNG, "ECHRNG", "Channel number out of range"),
#endif
#if defined (EL2NSYNC)
ENTRY(EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"),
#endif
#if defined (EL3HLT)
ENTRY(EL3HLT, "EL3HLT", "Level 3 halted"),
#endif
#if defined (EL3RST)
ENTRY(EL3RST, "EL3RST", "Level 3 reset"),
#endif
#if defined (ELNRNG)
ENTRY(ELNRNG, "ELNRNG", "Link number out of range"),
#endif
#if defined (EUNATCH)
ENTRY(EUNATCH, "EUNATCH", "Protocol driver not attached"),
#endif
#if defined (ENOCSI)
ENTRY(ENOCSI, "ENOCSI", "No CSI structure available"),
#endif
#if defined (EL2HLT)
ENTRY(EL2HLT, "EL2HLT", "Level 2 halted"),
#endif
#if defined (EDEADLK)
ENTRY(EDEADLK, "EDEADLK", "Deadlock condition"),
#endif
#if defined (ENOLCK)
ENTRY(ENOLCK, "ENOLCK", "No record locks available"),
#endif
#if defined (EBADE)
ENTRY(EBADE, "EBADE", "Invalid exchange"),
#endif
#if defined (EBADR)
ENTRY(EBADR, "EBADR", "Invalid request descriptor"),
#endif
#if defined (EXFULL)
ENTRY(EXFULL, "EXFULL", "Exchange full"),
#endif
#if defined (ENOANO)
ENTRY(ENOANO, "ENOANO", "No anode"),
#endif
#if defined (EBADRQC)
ENTRY(EBADRQC, "EBADRQC", "Invalid request code"),
#endif
#if defined (EBADSLT)
ENTRY(EBADSLT, "EBADSLT", "Invalid slot"),
#endif
#if defined (EDEADLOCK)
ENTRY(EDEADLOCK, "EDEADLOCK", "File locking deadlock error"),
#endif
#if defined (EBFONT)
ENTRY(EBFONT, "EBFONT", "Bad font file format"),
#endif
#if defined (ENOSTR)
ENTRY(ENOSTR, "ENOSTR", "Device not a stream"),
#endif
#if defined (ENODATA)
ENTRY(ENODATA, "ENODATA", "No data available"),
#endif
#if defined (ETIME)
ENTRY(ETIME, "ETIME", "Timer expired"),
#endif
#if defined (ENOSR)
ENTRY(ENOSR, "ENOSR", "Out of streams resources"),
#endif
#if defined (ENONET)
ENTRY(ENONET, "ENONET", "Machine is not on the network"),
#endif
#if defined (ENOPKG)
ENTRY(ENOPKG, "ENOPKG", "Package not installed"),
#endif
#if defined (EREMOTE)
ENTRY(EREMOTE, "EREMOTE", "Object is remote"),
#endif
#if defined (ENOLINK)
ENTRY(ENOLINK, "ENOLINK", "Link has been severed"),
#endif
#if defined (EADV)
ENTRY(EADV, "EADV", "Advertise error"),
#endif
#if defined (ESRMNT)
ENTRY(ESRMNT, "ESRMNT", "Srmount error"),
#endif
#if defined (ECOMM)
ENTRY(ECOMM, "ECOMM", "Communication error on send"),
#endif
#if defined (EPROTO)
ENTRY(EPROTO, "EPROTO", "Protocol error"),
#endif
#if defined (EMULTIHOP)
ENTRY(EMULTIHOP, "EMULTIHOP", "Multihop attempted"),
#endif
#if defined (EDOTDOT)
ENTRY(EDOTDOT, "EDOTDOT", "RFS specific error"),
#endif
#if defined (EBADMSG)
ENTRY(EBADMSG, "EBADMSG", "Not a data message"),
#endif
#if defined (ENAMETOOLONG)