nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

error_str.c (5848B)


      1 #include <errno.h>
      2 #include "error.h"
      3 #include <string.h>
      4 
      5 extern const int sys_nerr;
      6 #define X(e,s) case e: return s; break;
      7 #define XI(e,s) if (i == e) return s;
      8 
      9 char *error_str(int i)
     10 {
     11   char *err = NULL;
     12   switch (i) {
     13   X(0,"no error")
     14   X(error_intr,"interrupted system call")
     15   X(error_nomem,"out of memory")
     16   X(error_noent,"file does not exist")
     17   X(error_txtbsy,"text busy")
     18   X(error_io,"input/output error")
     19   X(error_exist,"file already exists")
     20   X(error_timeout,"timed out")
     21   X(error_inprogress,"operation in progress")
     22   X(error_again,"temporary failure")
     23   X(error_pipe,"broken pipe")
     24   X(error_perm,"permission denied")
     25   X(error_acces,"access denied")
     26 #ifdef ESRCH
     27   X(ESRCH,"no such process")
     28 #endif
     29 #ifdef ENXIO
     30   X(ENXIO,"device not configured")
     31 #endif
     32 #ifdef E2BIG
     33   X(E2BIG,"argument list too long")
     34 #endif
     35 #ifdef ENOEXEC
     36   X(ENOEXEC,"exec format error")
     37 #endif
     38 #ifdef EBADF
     39   X(EBADF,"file descriptor not open")
     40 #endif
     41 #ifdef ECHILD
     42   X(ECHILD,"no child processes")
     43 #endif
     44 #ifdef EDEADLK
     45   X(EDEADLK,"operation would cause deadlock")
     46 #endif
     47 #ifdef EFAULT
     48   X(EFAULT,"bad address")
     49 #endif
     50 #ifdef ENOTBLK
     51   X(ENOTBLK,"not a block device")
     52 #endif
     53 #ifdef EBUSY
     54   X(EBUSY,"device busy")
     55 #endif
     56 #ifdef EXDEV
     57   X(EXDEV,"cross-device link")
     58 #endif
     59 #ifdef ENODEV
     60   X(ENODEV,"device does not support operation")
     61 #endif
     62 #ifdef ENOTDIR
     63   X(ENOTDIR,"not a directory")
     64 #endif
     65 #ifdef EISDIR
     66   X(EISDIR,"is a directory")
     67 #endif
     68 #ifdef EINVAL
     69   X(EINVAL,"invalid argument")
     70 #endif
     71 #ifdef ENFILE
     72   X(ENFILE,"system cannot open more files")
     73 #endif
     74 #ifdef EMFILE
     75   X(EMFILE,"process cannot open more files")
     76 #endif
     77 #ifdef ENOTTY
     78   X(ENOTTY,"inappropriate ioctl for file or device")
     79 #endif
     80 #ifdef EFBIG
     81   X(EFBIG,"file too big")
     82 #endif
     83 #ifdef ENOSPC
     84   X(ENOSPC,"out of disk space")
     85 #endif
     86 #ifdef ESPIPE
     87   X(ESPIPE,"unseekable descriptor")
     88 #endif
     89 #ifdef EROFS
     90   X(EROFS,"read-only file system")
     91 #endif
     92 #ifdef EMLINK
     93   X(EMLINK,"too many links")
     94 #endif
     95 #ifdef EDOM
     96   X(EDOM,"input out of range")
     97 #endif
     98 #ifdef ERANGE
     99   X(ERANGE,"output out of range")
    100 #endif
    101 #ifdef EALREADY
    102   X(EALREADY,"operation already in progress")
    103 #endif
    104 #ifdef ENOTSOCK
    105   X(ENOTSOCK,"not a socket")
    106 #endif
    107 #ifdef EDESTADDRREQ
    108   X(EDESTADDRREQ,"destination address required")
    109 #endif
    110 #ifdef EMSGSIZE
    111   X(EMSGSIZE,"message too long")
    112 #endif
    113 #ifdef EPROTOTYPE
    114   X(EPROTOTYPE,"incorrect protocol type")
    115 #endif
    116 #ifdef ENOPROTOOPT
    117   X(ENOPROTOOPT,"protocol not available")
    118 #endif
    119 #ifdef EPROTONOSUPPORT
    120   X(EPROTONOSUPPORT,"protocol not supported")
    121 #endif
    122 #ifdef ESOCKTNOSUPPORT
    123   X(ESOCKTNOSUPPORT,"socket type not supported")
    124 #endif
    125 #ifdef EOPNOTSUPP
    126   X(EOPNOTSUPP,"operation not supported")
    127 #endif
    128 #ifdef EPFNOSUPPORT
    129   X(EPFNOSUPPORT,"protocol family not supported")
    130 #endif
    131 #ifdef EAFNOSUPPORT
    132   X(EAFNOSUPPORT,"address family not supported")
    133 #endif
    134 #ifdef EADDRINUSE
    135   X(EADDRINUSE,"address already used")
    136 #endif
    137 #ifdef EADDRNOTAVAIL
    138   X(EADDRNOTAVAIL,"address not available")
    139 #endif
    140 #ifdef ENETDOWN
    141   X(ENETDOWN,"network down")
    142 #endif
    143 #ifdef ENETUNREACH
    144   X(ENETUNREACH,"network unreachable")
    145 #endif
    146 #ifdef ENETRESET
    147   X(ENETRESET,"network reset")
    148 #endif
    149 #ifdef ECONNABORTED
    150   X(ECONNABORTED,"connection aborted")
    151 #endif
    152 #ifdef ECONNRESET
    153   X(ECONNRESET,"connection reset")
    154 #endif
    155 #ifdef ENOBUFS
    156   X(ENOBUFS,"out of buffer space")
    157 #endif
    158 #ifdef EISCONN
    159   X(EISCONN,"already connected")
    160 #endif
    161 #ifdef ENOTCONN
    162   X(ENOTCONN,"not connected")
    163 #endif
    164 #ifdef ESHUTDOWN
    165   X(ESHUTDOWN,"socket shut down")
    166 #endif
    167 #ifdef ETOOMANYREFS
    168   X(ETOOMANYREFS,"too many references")
    169 #endif
    170 #ifdef ECONNREFUSED
    171   X(ECONNREFUSED,"connection refused")
    172 #endif
    173 #ifdef ELOOP
    174   X(ELOOP,"symbolic link loop")
    175 #endif
    176 #ifdef ENAMETOOLONG
    177   X(ENAMETOOLONG,"file name too long")
    178 #endif
    179 #ifdef EHOSTDOWN
    180   X(EHOSTDOWN,"host down")
    181 #endif
    182 #ifdef EHOSTUNREACH
    183   X(EHOSTUNREACH,"host unreachable")
    184 #endif
    185 #ifdef ENOTEMPTY
    186   X(ENOTEMPTY,"directory not empty")
    187 #endif
    188 #ifdef EPROCLIM
    189   X(EPROCLIM,"too many processes")
    190 #endif
    191 #ifdef EUSERS
    192   X(EUSERS,"too many users")
    193 #endif
    194 #ifdef EDQUOT
    195   X(EDQUOT,"disk quota exceeded")
    196 #endif
    197 #ifdef ESTALE
    198   X(ESTALE,"stale NFS file handle")
    199 #endif
    200 #ifdef EREMOTE
    201   X(EREMOTE,"too many levels of remote in path")
    202 #endif
    203 #ifdef EBADRPC
    204   X(EBADRPC,"RPC structure is bad")
    205 #endif
    206 #ifdef ERPCMISMATCH
    207   X(ERPCMISMATCH,"RPC version mismatch")
    208 #endif
    209 #ifdef EPROGUNAVAIL
    210   X(EPROGUNAVAIL,"RPC program unavailable")
    211 #endif
    212 #ifdef EPROGMISMATCH
    213   X(EPROGMISMATCH,"program version mismatch")
    214 #endif
    215 #ifdef EPROCUNAVAIL
    216   X(EPROCUNAVAIL,"bad procedure for program")
    217 #endif
    218 #ifdef ENOLCK
    219   X(ENOLCK,"no locks available")
    220 #endif
    221 #ifdef ENOSYS
    222   X(ENOSYS,"system call not available")
    223 #endif
    224 #ifdef EFTYPE
    225   X(EFTYPE,"bad file type")
    226 #endif
    227 #ifdef EAUTH
    228   X(EAUTH,"authentication error")
    229 #endif
    230 #ifdef ENEEDAUTH
    231   X(ENEEDAUTH,"not authenticated")
    232 #endif
    233 #ifdef ENOSTR
    234   X(ENOSTR,"not a stream device")
    235 #endif
    236 #ifdef ETIME
    237   X(ETIME,"timer expired")
    238 #endif
    239 #ifdef ENOSR
    240   X(ENOSR,"out of stream resources")
    241 #endif
    242 #ifdef ENOMSG
    243   X(ENOMSG,"no message of desired type")
    244 #endif
    245 #ifdef EBADMSG
    246   X(EBADMSG,"bad message type")
    247 #endif
    248 #ifdef EIDRM
    249   X(EIDRM,"identifier removed")
    250 #endif
    251 #ifdef ENONET
    252   X(ENONET,"machine not on network")
    253 #endif
    254 #ifdef ERREMOTE
    255   X(ERREMOTE,"object not local")
    256 #endif
    257 #ifdef ENOLINK
    258   X(ENOLINK,"link severed")
    259 #endif
    260 #ifdef EADV
    261   X(EADV,"advertise error")
    262 #endif
    263 #ifdef ESRMNT
    264   X(ESRMNT,"srmount error")
    265 #endif
    266 #ifdef ECOMM
    267   X(ECOMM,"communication error")
    268 #endif
    269 #ifdef EPROTO
    270   X(EPROTO,"protocol error")
    271 #endif
    272 #ifdef EMULTIHOP
    273   X(EMULTIHOP,"multihop attempted")
    274 #endif
    275 #ifdef EREMCHG
    276   X(EREMCHG,"remote address changed")
    277 #endif
    278   default: /* take advantage of system strerror as a last resort */
    279     XI(error_wouldblock,"input/output would block")
    280     if (i < sys_nerr) err = strerror(i);
    281     return (err == NULL) ? "unknown error" : err;
    282   }
    283 }