3 typedef struct s_entry
\r
7 unsigned kind : 1; /* if 1 it's an error of the application else assume it's a system error */
\r
18 {"E2BIG", E2BIG, 0, "argument list too long"},
\r
22 {"EACCES", EACCES, 0, "permission denied"},
\r
26 {"EADDRINUSE", EADDRINUSE, 0, "address in use"},
\r
29 #ifdef EADDRNOTAVAIL
\r
30 {"EADDRNOTAVAIL", EADDRNOTAVAIL, 0, "address not available"},
\r
34 {"EAFNOSUPPORT", EAFNOSUPPORT, 0, "address family not supported"},
\r
38 {"EAGAIN", EAGAIN, 0, "resource unavailable, try again"},
\r
42 {"EALREADY", EALREADY, 0, "connection already in progress"},
\r
46 {"EBADF", EBADF, 0, "bad file descriptor"},
\r
50 {"EBADMSG", EBADMSG, 0, "bad message"},
\r
54 {"EBUSY", EBUSY, 0, "device or resource busy"},
\r
58 {"ECANCELED", ECANCELED, 0, "operation canceled"},
\r
62 {"ECHILD", ECHILD, 0, "no child processes"},
\r
66 {"ECONNABORTED", ECONNABORTED, 0, "connection aborted"},
\r
70 {"ECONNREFUSED", ECONNREFUSED, 0, "connection refused"},
\r
74 {"ECONNRESET", ECONNRESET, 0, "connection reset"},
\r
78 {"EDEADLK", EDEADLK, 0, "resource deadlock would occur"},
\r
82 {"EDESTADDRREQ", EDESTADDRREQ, 0, "destination address required"},
\r
86 {"EDOM", EDOM, 0, "mathematics argument out of domain of function"},
\r
90 {"EEXIST", EEXIST, 0, "file exists"},
\r
94 {"EFAULT", EFAULT, 0, "bad address"},
\r
98 {"EFBIG", EFBIG, 0, "file too large"},
\r
101 #ifdef EHOSTUNREACH
\r
102 {"EHOSTUNREACH", EHOSTUNREACH, 0, "host is unreachable"},
\r
106 {"EIDRM", EIDRM, 0, "identifier removed"},
\r
110 {"EILSEQ", EILSEQ, 0, "illegal byte sequence"},
\r
114 {"EINPROGRESS", EINPROGRESS, 0, "operation in progress"},
\r
118 {"EINTR", EINTR, 0, "interrupted function"},
\r
122 {"EINVAL", EINVAL, 0, "invalid argument"},
\r
126 {"EIO", EIO, 0, "I/O error"},
\r
130 {"EISCONN", EISCONN, 0, "socket is connected"},
\r
134 {"EISDIR", EISDIR, 0, "is a directory"},
\r
138 {"ELOOP", ELOOP, 0, "too many levels of symbolic links"},
\r
142 {"EMFILE", EMFILE, 0, "too many open files"},
\r
146 {"EMLINK", EMLINK, 0, "too many links"},
\r
150 {"EMSGSIZE", EMSGSIZE, 0, "message too large"},
\r
153 #ifdef ENAMETOOLONG
\r
154 {"ENAMETOOLONG", ENAMETOOLONG, 0, "filename too long"},
\r
158 {"ENETDOWN", ENETDOWN, 0, "network is down"},
\r
162 {"ENETRESET", ENETRESET, 0, "connection aborted by network"},
\r
166 {"ENETUNREACH", ENETUNREACH, 0, "network unreachable"},
\r
170 {"ENFILE", ENFILE, 0, "too many files open in system"},
\r
174 {"ENOBUFS", ENOBUFS, 0, "no buffer space available"},
\r
178 {"ENODATA", ENODATA, 0, "no message is available on the STREAM head read queue"},
\r
182 {"ENODEV", ENODEV, 0, "no such device"},
\r
186 {"ENOENT", ENOENT, 0, "no such file or directory"},
\r
190 {"ENOEXEC", ENOEXEC, 0, "executable file format error"},
\r
194 {"ENOLCK", ENOLCK, 0, "no locks available"},
\r
198 {"ENOMEM", ENOMEM, 0, "not enough space"},
\r
202 {"ENOMSG", ENOMSG, 0, "no message of the desired type"},
\r
206 {"ENOPROTOOPT", ENOPROTOOPT, 0, "protocol not available"},
\r
210 {"ENOSPC", ENOSPC, 0, "no space left on device"},
\r
214 {"ENOSR", ENOSR, 0, "no stream resources"},
\r
218 {"ENOSTR", ENOSTR, 0, "not a stream"},
\r
222 {"ENOSYS", ENOSYS, 0, "function not supported"},
\r
226 {"ENOTCONN", ENOTCONN, 0, "the socket is not connected"},
\r
230 {"ENOTDIR", ENOTDIR, 0, "not a directory"},
\r
234 {"ENOTEMPTY", ENOTEMPTY, 0, "directory not empty"},
\r
238 {"ENOTSOCK", ENOTSOCK, 0, "not a socket"},
\r
242 {"ENOTSUP", ENOTSUP, 0, "not supported"},
\r
246 {"ENOTTY", ENOTTY, 0, "inappropriate I/O control operation"},
\r
250 {"ENXIO", ENXIO, 0, "no such device or address"},
\r
254 {"EOPNOTSUPP", EOPNOTSUPP, 0, "operation not supported on socket"},
\r
258 {"EOVERFLOW", EOVERFLOW, 0, "value too large to be stored in data type"},
\r
262 {"EPERM", EPERM, 0, "operation not permitted"},
\r
266 {"EPIPE", EPIPE, 0, "broken pipe"},
\r
270 {"EPROTO", EPROTO, 0, "protocol error"},
\r
273 #ifdef EPROTONOSUPPORT
\r
274 {"EPROTONOSUPPORT", EPROTONOSUPPORT, 0, "protocol not supported"},
\r
278 {"EPROTOTYPE", EPROTOTYPE, 0, "protocol wrong type for socket"},
\r
282 {"ERANGE", ERANGE, 0, "result too large"},
\r
286 {"EROFS", EROFS, 0, "read-only file system"},
\r
290 {"ESPIPE", ESPIPE, 0, "invalid seek"},
\r
294 {"ESRCH", ESRCH, 0, "no such process"},
\r
298 {"ETIME", ETIME, 0, "stream ioctl() timeout"},
\r
302 {"ETIMEDOUT", ETIMEDOUT, 0, "connection timed out"},
\r
306 {"ETXTBSY", ETXTBSY, 0, "text file busy"},
\r
310 {"EWOULDBLOCK", EWOULDBLOCK, 0, "operation would block"},
\r
314 {"EXDEV", EXDEV, 0, "cross-device link"},
\r
317 {"ECMDTIMEDOUT", ECMDTIMEDOUT, 1, "command timed out"},
\r
319 {"ECMDNOTFOUND", ECMDNOTFOUND,1, "command not found"},
\r
321 {"EEXITCODENOTMATCH", EEXITCODENOTMATCH,1, "exit code mismatch"},
\r
323 {"EOUTPUTNOTMATCH", EOUTPUTNOTMATCH,1, "output mismatch"},
\r
325 {"ESIGNOTMATCH", ESIGNOTMATCH,1, "signal mismatch"},
\r
327 {"EUNXPSIG", EUNXPSIG,1, "unexpected signal caught"},
\r
329 {"ESIGNOTRECEIPT", ESIGNOTRECEIPT,1, "expected signal not receipt"},
\r
331 {"EPROCCMDLINE", EPROCCMDLINE, 1, "command line processing failed"},
\r
333 {"ENOARG", ENOARG, 1, "none optional argument not specified"},
\r
335 {"ENOTPOSITIVENUM", ENOTPOSITIVENUM, 1, "argument option not strictly positive"},
\r
337 {"ESYNTAX", ESYNTAX,1, "syntax error"},
\r
339 {"ELEADTIME", ELEADTIME, 1, "timed out"},
\r
341 {"EREADMENOTFOUND", EREADMENOTFOUND,1, "unable to locate the README.txt file"},
\r
343 {"EINCLUDENOTFOUND", EINCLUDENOTFOUND, 1, "include file not found"},
\r
345 {"ESUFFIXTOOLONG", ESUFFIXTOOLONG,1, "suffix too long"},
\r
347 {"EINVCMDLINE", EINVCMDLINE,1, "invalid command line"},
\r
349 {"unkwown", -1, 0, "unknown"}
\r
356 w32error_to_string(DWORD errcode)
\r
358 static char buffer[128];
\r
361 * Special code for winsock error handling.
\r
363 if (errcode > WSABASEERR)
\r
365 HMODULE hModule = GetModuleHandle("wsock32");
\r
369 FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,hModule, errcode, LANG_NEUTRAL, buffer, 128, NULL);
\r
370 FreeLibrary(hModule);
\r
376 * Default system message handling
\r
378 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errcode, LANG_NEUTRAL, buffer, 128, NULL);
\r
386 error_to_string(int errcode, int kind)
\r
390 for(i = 0; err[i].code != -1; i++)
\r
391 if(err[i].code == errcode && err[i].kind == kind)
\r
392 return err[i].string;
\r
396 /* assume it's a W32 error */
\r
397 return w32error_to_string((DWORD)errcode);
\r
399 return "unknow error";
\r
405 error_get_at(int pos, int* code)
\r
407 if(pos < 0 || (pos > (sizeof(err)/sizeof(entry_t)) - 2))
\r
413 *code = err[pos].code;
\r
414 return err[pos].name;
\r