summaryrefslogtreecommitdiff
path: root/src/errstr.c
blob: e2807ef5974f5450ae359a28b4910c3909690b31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#include "error.h"

/**
  @file errstr.c
  @author kp
  @source qlibs
  @brief error output to log for different conditions and OS
*/

#define X(e, s) \
  if (code == e) return s;

extern char *error_str(int);

char *errstr(int code)
{
  // clang-format off
  X(0,                "")                           // NOERROR
  X(error_intr,       "interrupted system call")    // EINTR
  X(EINTR,            "interrupted system call")
  X(error_nomem,      "out of memory")              // ENOMEM
  X(ENOMEM,           "out of memory")
  X(error_noent,      "file does not exist")        // ENOENT
  X(ENOENT,           "file does not exist")
  X(error_txtbsy,     "text busy")                  // ETXTBSY
  X(ETXTBSY,          "text busy")
  X(error_io,         "input/output error")         // EIO
  X(EIO,              "input/output error")
  X(error_exist,      "file already exists")        // EEXISTS
  X(EEXIST,           "file already exists")
  X(error_timeout,    "timed out")                  // ETIMEDOUT
  X(ETIMEDOUT,        "timed out")
  X(error_inprogress, "operation in progress")      // EINPROGRESS
  X(EINPROGRESS,      "operation in progress")
  X(error_again,      "temporary failure")          // EAGAIN
  X(EAGAIN,           "temporary failure")
  X(error_wouldblock, "input/output would block")   // EWOULDBLOCK (intern EAGAIN)
  X(EWOULDBLOCK,      "input/output would block")
  X(error_pipe,       "broken pipe")                // EPIPE
  X(EPIPE,            "broken pipe")
  X(error_perm,       "permission denied")          // EPERM
  X(EPERM,            "permission denied")
  X(error_acces,      "access denied")              // EACCES
  X(EACCES,           "access denied")

  X(ESRCH,            "no such process")

//X(error_nodevice,"device not configured")         // ENXIO
  X(ENXIO,            "device not configured")

  X(E2BIG,            "argument list too long")
  X(ENOEXEC,          "exec format error")
  X(EBADF,            "file descriptor not open")
  X(ECHILD,           "no child processes")
  X(EDEADLK,          "operation would cause deadlock")
  X(EFAULT,           "bad address")
  X(ENOTBLK,          "not a block device")
  X(EBUSY,            "device busy")
  X(EXDEV,            "cross-device link")
  X(ENODEV,           "device does not support operation")
//X(error_notdir,"not a directory")                 // ENOTDIR
  X(ENOTDIR,          "not a directory")
  X(error_isdir,      "is a directory")             // EISDIR
  X(EISDIR,           "is a directory")
  X(EINVAL,           "invalid argument")
  X(ENFILE,           "system cannot open more files")
  X(EMFILE,           "process cannot open more files")
  X(ENOTTY,           "not a tty")
  X(EFBIG,            "file too big")
  X(ENOSPC,           "out of disk space")
  X(ESPIPE,           "unseekable descriptor")
//X(error_rofs,"read-only file system")             // EROFS
  X(EROFS,            "read-only file system")
  X(EMLINK,           "too many links")
  X(EDOM,             "input out of range")
  X(ERANGE,           "output out of range")
  X(EALREADY,         "operation already in progress")
  X(ENOTSOCK,         "not a socket")
  X(EDESTADDRREQ,     "destination address required")
  X(EMSGSIZE,         "message too long")
  X(EPROTOTYPE,       "incorrect protocol type")
  X(ENOPROTOOPT,      "protocol not available")
  X(EPROTONOSUPPORT,  "protocol not supported")
  X(ESOCKTNOSUPPORT,  "socket type not supported")
  X(EOPNOTSUPP,       "operation not supported")
  X(EPFNOSUPPORT,     "protocol family not supported")
  X(EAFNOSUPPORT,     "address family not supported")
  X(EADDRINUSE,       "address already used")
  X(EADDRNOTAVAIL,    "address not available")
  X(ENETDOWN,         "network down")
  X(ENETUNREACH,      "network unreachable")
  X(ENETRESET,        "network reset")
  X(ECONNABORTED,     "connection aborted")
  X(error_connreset,  "connection reset")           // ECONNRESET
  X(ECONNRESET,       "connection reset")
  X(ENOBUFS,          "out of buffer space")
  X(EISCONN,          "already connected")
  X(ENOTCONN,         "not connected")
  X(ESHUTDOWN,        "socket shut down")
  X(ETOOMANYREFS,     "too many references")
  X(error_connrefused,"connection refused")         // ECONNREFUSED
  X(ECONNREFUSED,     "connection refused")
  X(ELOOP,            "symbolic link loop")
  X(ENAMETOOLONG,     "file name too long")
  X(EHOSTDOWN,        "host down")
  X(EHOSTUNREACH,     "host unreachable")
  X(ENOTEMPTY,        "directory not empty")
  X(EUSERS,           "too many users")
  X(EDQUOT,           "disk quota exceeded")
  X(ESTALE,           "stale NFS file handle")

  /* BSD only (all BSD's, NOT on Linux) */
//X(EPROCLIM,         "too many processes")         // -L +FB +OB +NB
//X(EBADRPC,          "RPC structure is bad")       // -L +FB +OB +NB

//X(ERPCMISMATCH,     "RPC version mismatch")       // -L +FB +OB +NB
//X(EPROGUNAVAIL,     "RPC program unavailable")    // -L +FB +OB +NB
//X(EPROGMISMATCH,    "program version mismatch")   // -L +FB +OB +NB
//X(EPROCUNAVAIL,     "bad procedure for program")  // -L +FB +OB +NB
//X(EFTYPE,           "bad file type")              // -L +FB +OB +NB

  X(ENOLCK,           "no locks available")
  X(ENOSYS,           "system call not available")
  X(ENOMSG,           "no message of desired type")
  X(EIDRM,            "identifier removed")

//X(ERREMOTE,         "object not local")           // -L -FB -OB -NB
  X(EREMOTE,          "object not local")           // Linux: "Object is remote"
//X(EREMOTE,          "too many levels of remote in path")

  /* Linux only */
//X(ENONET,           "machine not on network")     // +L -FB -OB -NB
//X(EADV,             "advertise error")            // +L -FB -OB -NB
//X(ESRMNT,           "srmount error")              // +L -FB -OB -NB
//X(ECOMM,            "communication error")        // +L -FB -OB -NB
//X(EREMCHG,          "remote address changed")     // +L -FB -OB -NB

  X(error_proto,      "protocol error")             // EPROTO

  /* EPROTO: see 'error.h' for OpenBSD compat */
  X(EPROTO,           "protocol error")             // +L +FB -OB +NB

  /* Linux and NetBSD */
//X(ENOSTR,           "not a stream device")        // +L -FB -OB +NB
//X(ETIME,            "timer expired")              // +L -FB -OB +NB
//X(ENOSR,            "out of stream resources")    // +L -FB -OB +NB

  /* FreeBSD and NetBSD */
//X(EAUTH,            "authentication error")       // -L +FB -OB +NB
//X(ENEEDAUTH,        "not authenticated")          // -L +FB -OB +NB

  /* NOT on OpenBSD */
//X(EBADMSG,          "bad message type")           // +L +FB -OB +NB
//X(ENOLINK,          "link severed")               // +L +FB -OB +NB
//X(EMULTIHOP,        "multihop attempted")         // +L +FB -OB +NB

  /* Application/DJB specific */
  X(EHARD,            " ")
  X(ESOFT,            " ")
  X(USAGE,            "usage error")                // qmail; explicit
  X(SYNTAX,           "syntax error")               // djbdns, qmail; explicit
  X(DROP,             "connection dropped")         // ucspi-tcp
  X(FATAL,            "unable to continue")         // all
  // clang-format on

  return "unknown error";  // worst case
}