2 \r typedef struct s_entry
\r {
5 \r unsigned kind:1; /* if 1 it's an error of the application else assume it's a system error */
8 \r\r\rstatic const
\r entry_t err[] =
\r{
\r\r
10 {"E2BIG", E2BIG, 0, "argument list too long"},
\r
14 {"EACCES", EACCES, 0, "permission denied"},
\r
18 {"EADDRINUSE", EADDRINUSE, 0, "address in use"},
\r
21 #ifdef EADDRNOTAVAIL
\r
22 {"EADDRNOTAVAIL", EADDRNOTAVAIL, 0, "address not available"},
\r
26 {"EAFNOSUPPORT", EAFNOSUPPORT, 0, "address family not supported"},
\r
30 {"EAGAIN", EAGAIN, 0, "resource unavailable, try again"},
\r
34 {"EALREADY", EALREADY, 0, "connection already in progress"},
\r
38 {"EBADF", EBADF, 0, "bad file descriptor"},
\r
42 {"EBADMSG", EBADMSG, 0, "bad message"},
\r
46 {"EBUSY", EBUSY, 0, "device or resource busy"},
\r
50 {"ECANCELED", ECANCELED, 0, "operation canceled"},
\r
54 {"ECHILD", ECHILD, 0, "no child processes"},
\r
58 {"ECONNABORTED", ECONNABORTED, 0, "connection aborted"},
\r
62 {"ECONNREFUSED", ECONNREFUSED, 0, "connection refused"},
\r
66 {"ECONNRESET", ECONNRESET, 0, "connection reset"},
\r
70 {"EDEADLK", EDEADLK, 0, "resource deadlock would occur"},
\r
74 {"EDESTADDRREQ", EDESTADDRREQ, 0, "destination address required"},
\r
78 {"EDOM", EDOM, 0, "mathematics argument out of domain of function"},
\r
82 {"EEXIST", EEXIST, 0, "file exists"},
\r
86 {"EFAULT", EFAULT, 0, "bad address"},
\r
90 {"EFBIG", EFBIG, 0, "file too large"},
\r
94 {"EHOSTUNREACH", EHOSTUNREACH, 0, "host is unreachable"},
\r
98 {"EIDRM", EIDRM, 0, "identifier removed"},
\r
102 {"EILSEQ", EILSEQ, 0, "illegal byte sequence"},
\r
106 {"EINPROGRESS", EINPROGRESS, 0, "operation in progress"},
\r
110 {"EINTR", EINTR, 0, "interrupted function"},
\r
114 {"EINVAL", EINVAL, 0, "invalid argument"},
\r
118 {"EIO", EIO, 0, "I/O error"},
\r
122 {"EISCONN", EISCONN, 0, "socket is connected"},
\r
126 {"EISDIR", EISDIR, 0, "is a directory"},
\r
130 {"ELOOP", ELOOP, 0, "too many levels of symbolic links"},
\r
134 {"EMFILE", EMFILE, 0, "too many open files"},
\r
138 {"EMLINK", EMLINK, 0, "too many links"},
\r
142 {"EMSGSIZE", EMSGSIZE, 0, "message too large"},
\r
145 #ifdef ENAMETOOLONG
\r
146 {"ENAMETOOLONG", ENAMETOOLONG, 0, "filename too long"},
\r
150 {"ENETDOWN", ENETDOWN, 0, "network is down"},
\r
154 {"ENETRESET", ENETRESET, 0, "connection aborted by network"},
\r
158 {"ENETUNREACH", ENETUNREACH, 0, "network unreachable"},
\r
162 {"ENFILE", ENFILE, 0, "too many files open in system"},
\r
166 {"ENOBUFS", ENOBUFS, 0, "no buffer space available"},
\r
170 {"ENODATA", ENODATA, 0,
171 "no message is available on the STREAM head read queue"},
\r
175 {"ENODEV", ENODEV, 0, "no such device"},
\r
179 {"ENOENT", ENOENT, 0, "no such file or directory"},
\r
183 {"ENOEXEC", ENOEXEC, 0, "executable file format error"},
\r
187 {"ENOLCK", ENOLCK, 0, "no locks available"},
\r
191 {"ENOMEM", ENOMEM, 0, "not enough space"},
\r
195 {"ENOMSG", ENOMSG, 0, "no message of the desired type"},
\r
199 {"ENOPROTOOPT", ENOPROTOOPT, 0, "protocol not available"},
\r
203 {"ENOSPC", ENOSPC, 0, "no space left on device"},
\r
207 {"ENOSR", ENOSR, 0, "no stream resources"},
\r
211 {"ENOSTR", ENOSTR, 0, "not a stream"},
\r
215 {"ENOSYS", ENOSYS, 0, "function not supported"},
\r
219 {"ENOTCONN", ENOTCONN, 0, "the socket is not connected"},
\r
223 {"ENOTDIR", ENOTDIR, 0, "not a directory"},
\r
227 {"ENOTEMPTY", ENOTEMPTY, 0, "directory not empty"},
\r
231 {"ENOTSOCK", ENOTSOCK, 0, "not a socket"},
\r
235 {"ENOTSUP", ENOTSUP, 0, "not supported"},
\r
239 {"ENOTTY", ENOTTY, 0, "inappropriate I/O control operation"},
\r
243 {"ENXIO", ENXIO, 0, "no such device or address"},
\r
247 {"EOPNOTSUPP", EOPNOTSUPP, 0, "operation not supported on socket"},
\r
251 {"EOVERFLOW", EOVERFLOW, 0, "value too large to be stored in data type"},
\r
255 {"EPERM", EPERM, 0, "operation not permitted"},
\r
259 {"EPIPE", EPIPE, 0, "broken pipe"},
\r
263 {"EPROTO", EPROTO, 0, "protocol error"},
\r
266 #ifdef EPROTONOSUPPORT
\r
267 {"EPROTONOSUPPORT", EPROTONOSUPPORT, 0, "protocol not supported"},
\r
271 {"EPROTOTYPE", EPROTOTYPE, 0, "protocol wrong type for socket"},
\r
275 {"ERANGE", ERANGE, 0, "result too large"},
\r
279 {"EROFS", EROFS, 0, "read-only file system"},
\r
283 {"ESPIPE", ESPIPE, 0, "invalid seek"},
\r
287 {"ESRCH", ESRCH, 0, "no such process"},
\r
291 {"ETIME", ETIME, 0, "stream ioctl() timeout"},
\r
295 {"ETIMEDOUT", ETIMEDOUT, 0, "connection timed out"},
\r
299 {"ETXTBSY", ETXTBSY, 0, "text file busy"},
\r
303 {"EWOULDBLOCK", EWOULDBLOCK, 0, "operation would block"},
\r
307 {"EXDEV", EXDEV, 0, "cross-device link"},
\r
310 {"ECMDTIMEDOUT", ECMDTIMEDOUT, 1, "command timed out"},
\r\r
311 {"ECMDNOTFOUND", ECMDNOTFOUND, 1, "command not found"},
\r\r
312 {"EEXITCODENOTMATCH", EEXITCODENOTMATCH, 1, "exit code mismatch"},
\r\r
313 {"EOUTPUTNOTMATCH", EOUTPUTNOTMATCH, 1, "output mismatch"},
\r\r
314 {"ESIGNOTMATCH", ESIGNOTMATCH, 1, "signal mismatch"},
\r\r
315 {"EUNXPSIG", EUNXPSIG, 1, "unexpected signal caught"},
\r\r
316 {"ESIGNOTRECEIPT", ESIGNOTRECEIVED, 1,
317 "expected signal not receipt"},
\r\r{"EPROCCMDLINE", EPROCCMDLINE, 1,
318 "command line processing failed"},
319 \r\r{"ENOARG", ENOARG, 1, "none optional argument not specified"},
320 \r\r{"ENOTPOSITIVENUM", ENOTPOSITIVENUM, 1,
321 "argument option not strictly positive"},
\r\r{"ESYNTAX", ESYNTAX,
323 \r\r{"ELEADTIME", ELEADTIME, 1, "timed out"},
\r\r{"EREADMENOTFOUND",
325 "unable to locate the README.txt file"},
326 \r\r{"EINCLUDENOTFOUND", EINCLUDENOTFOUND, 1,
327 "include file not found"},
\r\r{"ESUFFIXTOOLONG", ESUFFIXTOOLONG, 1,
329 \r\r{"EINVCMDLINE", EINVCMDLINE, 1, "invalid command line"},
330 \r\r{"unkwown", -1, 0, "unknown"}
\r
337 static char *
\r w32error_to_string(DWORD errcode)
\r
339 \rstatic char buffer[128];
342 * Special code for winsock error handling.
\r
344 if (errcode > WSABASEERR)
346 \rHMODULE hModule = GetModuleHandle("wsock32");
349 \rFormatMessage(FORMAT_MESSAGE_FROM_HMODULE, hModule, errcode,
350 LANG_NEUTRAL, buffer, 128, NULL);
351 \rFreeLibrary(hModule);
359 * Default system message handling
\r
361 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errcode,
362 LANG_NEUTRAL, buffer, 128, NULL);
369 \rconst char *
\r error_to_string(int errcode, int kind)
\r
372 \r\rfor (i = 0; err[i].code != -1; i++)
373 \rif (err[i].code == errcode && err[i].kind == kind)
374 \rreturn err[i].string;
378 /* assume it's a W32 error */
\r
379 return w32error_to_string((DWORD) errcode);
382 return "unknow error";
387 \r\rconst char *
\r error_get_at(int pos, int *code)
\r
389 \rif (pos < 0 || (pos > (sizeof(err) / sizeof(entry_t)) - 2))
394 \r\r*code = err[pos].code;
395 \rreturn err[pos].name;