home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / clib / strerror.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  6.9 KB  |  177 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: strerror.c,v 1.1 1996/12/11 11:18:28 aros Exp $
  4.  
  5.     Desc: ANSI C function strerror()
  6.     Lang: english
  7. */
  8. #include <errno.h>
  9. #include <stdio.h>
  10.  
  11. static const char * _errstrings[] =
  12. {
  13.     /* 0           */    "No error",
  14.     /* EPERM           */    "Operation not permitted",
  15.     /* ENOENT           */    "No such file or directory",
  16.     /* ESRCH           */    "No such process",
  17.     /* EINTR           */    "Interrupted system call",
  18.     /* EIO           */    "I/O error",
  19.     /* ENXIO           */    "No such device or address",
  20.     /* E2BIG           */    "Arg list too long",
  21.     /* ENOEXEC           */    "Exec format error",
  22.     /* EBADF           */    "Bad file number",
  23.     /* ECHILD           */    "No child processes",
  24.     /* EAGAIN           */    "Try again",
  25.     /* ENOMEM           */    "Out of memory",
  26.     /* EACCES           */    "Permission denied",
  27.     /* EFAULT           */    "Bad address",
  28.     /* ENOTBLK           */    "Block device required",
  29.     /* EBUSY           */    "Device or resource busy",
  30.     /* EEXIST           */    "File exists",
  31.     /* EXDEV           */    "Cross-device link",
  32.     /* ENODEV           */    "No such device",
  33.     /* ENOTDIR           */    "Not a directory",
  34.     /* EISDIR           */    "Is a directory",
  35.     /* EINVAL           */    "Invalid argument",
  36.     /* ENFILE           */    "File table overflow",
  37.     /* EMFILE           */    "Too many open files",
  38.     /* ENOTTY           */    "Not a typewriter",
  39.     /* ETXTBSY           */    "Text file busy",
  40.     /* EFBIG           */    "File too large",
  41.     /* ENOSPC           */    "No space left on device",
  42.     /* ESPIPE           */    "Illegal seek",
  43.     /* EROFS           */    "Read-only file system",
  44.     /* EMLINK           */    "Too many links",
  45.     /* EPIPE           */    "Broken pipe",
  46.     /* EDOM           */    "Math argument out of domain of func",
  47.     /* ERANGE           */    "Math result not representable",
  48.     /* EDEADLK           */    "Resource deadlock would occur",
  49.     /* ENAMETOOLONG    */    "File name too long",
  50.     /* ENOLCK           */    "No record locks available",
  51.     /* ENOSYS           */    "Function not implemented",
  52.     /* ENOTEMPTY       */    "Directory not empty",
  53.     /* ELOOP           */    "Too many symbolic links encountered",
  54.     /* EWOULDBLOCK=EAGAIN */    NULL,
  55.     /* ENOMSG           */    "No message of desired type",
  56.     /* EIDRM           */    "Identifier removed",
  57.     /* ECHRNG           */    "Channel number out of range",
  58.     /* EL2NSYNC        */    "Level 2 not synchronized",
  59.     /* EL3HLT           */    "Level 3 halted",
  60.     /* EL3RST           */    "Level 3 reset",
  61.     /* ELNRNG           */    "Link number out of range",
  62.     /* EUNATCH           */    "Protocol driver not attached",
  63.     /* ENOCSI           */    "No CSI structure available",
  64.     /* EL2HLT           */    "Level 2 halted",
  65.     /* EBADE           */    "Invalid exchange",
  66.     /* EBADR           */    "Invalid request descriptor",
  67.     /* EXFULL           */    "Exchange full",
  68.     /* ENOANO           */    "No anode",
  69.     /* EBADRQC           */    "Invalid request code",
  70.     /* EBADSLT           */    "Invalid slot",
  71.     /* EDEADLOCK=EDEADLK */    NULL,
  72.     /* EBFONT           */    "Bad font file format",
  73.     /* ENOSTR           */    "Device not a stream",
  74.     /* ENODATA           */    "No data available",
  75.     /* ETIME           */    "Timer expired",
  76.     /* ENOSR           */    "Out of streams resources",
  77.     /* ENONET           */    "Machine is not on the network",
  78.     /* ENOPKG           */    "Package not installed",
  79.     /* EREMOTE           */    "Object is remote",
  80.     /* ENOLINK           */    "Link has been severed",
  81.     /* EADV           */    "Advertise error",
  82.     /* ESRMNT           */    "Srmount error",
  83.     /* ECOMM           */    "Communication error on send",
  84.     /* EPROTO           */    "Protocol error",
  85.     /* EMULTIHOP       */    "Multihop attempted",
  86.     /* EDOTDOT           */    "RFS specific error",
  87.     /* EBADMSG           */    "Not a data message",
  88.     /* EOVERFLOW       */    "Value too large for defined data type",
  89.     /* ENOTUNIQ        */    "Name not unique on network",
  90.     /* EBADFD           */    "File descriptor in bad state",
  91.     /* EREMCHG           */    "Remote address changed",
  92.     /* ELIBACC           */    "Can not access a needed shared library",
  93.     /* ELIBBAD           */    "Accessing a corrupted shared library",
  94.     /* ELIBSCN           */    ".lib section in a.out corrupted",
  95.     /* ELIBMAX           */    "Attempting to link in too many shared libraries",
  96.     /* ELIBEXEC        */    "Cannot exec a shared library directly",
  97.     /* EILSEQ           */    "Illegal byte sequence",
  98.     /* ERESTART        */    "Interrupted system call should be restarted",
  99.     /* ESTRPIPE        */    "Streams pipe error",
  100.     /* EUSERS           */    "Too many users",
  101.     /* ENOTSOCK        */    "Socket operation on non-socket",
  102.     /* EDESTADDRREQ    */    "Destination address required",
  103.     /* EMSGSIZE        */    "Message too long",
  104.     /* EPROTOTYPE      */    "Protocol wrong type for socket",
  105.     /* ENOPROTOOPT     */    "Protocol not available",
  106.     /* EPROTONOSUPPORT */    "Protocol not supported",
  107.     /* ESOCKTNOSUPPORT */    "Socket type not supported",
  108.     /* EOPNOTSUPP      */    "Operation not supported on transport endpoint",
  109.     /* EPFNOSUPPORT    */    "Protocol family not supported",
  110.     /* EAFNOSUPPORT    */    "Address family not supported by protocol",
  111.     /* EADDRINUSE      */    "Address already in use",
  112.     /* EADDRNOTAVAIL   */    "Cannot assign requested address",
  113.     /* ENETDOWN        */    "Network is down",
  114.     /* ENETUNREACH     */    "Network is unreachable",
  115.     /* ENETRESET       */    "Network dropped connection because of reset",
  116.     /* ECONNABORTED    */    "Software caused connection abort",
  117.     /* ECONNRESET      */    "Connection reset by peer",
  118.     /* ENOBUFS           */    "No buffer space available",
  119.     /* EISCONN           */    "Transport endpoint is already connected",
  120.     /* ENOTCONN        */    "Transport endpoint is not connected",
  121.     /* ESHUTDOWN       */    "Cannot send after transport endpoint shutdown",
  122.     /* ETOOMANYREFS    */    "Too many references: cannot splice",
  123.     /* ETIMEDOUT       */    "Connection timed out",
  124.     /* ECONNREFUSED    */    "Connection refused",
  125.     /* EHOSTDOWN       */    "Host is down",
  126.     /* EHOSTUNREACH    */    "No route to host",
  127.     /* EALREADY        */    "Operation already in progress",
  128.     /* EINPROGRESS     */    "Operation now in progress",
  129.     /* ESTALE           */    "Stale NFS file handle",
  130.     /* EUCLEAN           */    "Structure needs cleaning",
  131.     /* ENOTNAM           */    "Not a XENIX named type file",
  132.     /* ENAVAIL           */    "No XENIX semaphores available",
  133.     /* EISNAM           */    "Is a named type file",
  134.     /* EREMOTEIO       */    "Remote I/O error",
  135.     /* EDQUOT           */    "Quota exceeded",
  136. };
  137.  
  138. /*****************************************************************************
  139.  
  140.     NAME */
  141. #include <string.h>
  142.  
  143.     char * strerror (
  144.  
  145. /*  SYNOPSIS */
  146.     size_t n)
  147.  
  148. /*  FUNCTION
  149.     Returns a readable string for an error number in errno.
  150.  
  151.     INPUTS
  152.     n - The contents of errno or a #define from errno.h
  153.  
  154.     RESULT
  155.     A string describing the error.
  156.  
  157.     NOTES
  158.  
  159.     EXAMPLE
  160.  
  161.     BUGS
  162.  
  163.     SEE ALSO
  164.  
  165.     INTERNALS
  166.  
  167.     HISTORY
  168.  
  169. ******************************************************************************/
  170. {
  171.     if (n >= MAX_ERRNO)
  172.     return "Illegal error code";
  173.  
  174.     return (char *)_errstrings[n];
  175. } /* strerror */
  176.  
  177.