Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
teach the platform upgrading script about the s/:/_/ in the DTD
[simgrid.git] / tools / tesh2 / src / xerrno.c
index c82cd77..0b8deff 100644 (file)
@@ -4,7 +4,9 @@ typedef struct s_entry
 {\r
        const char* name;\r
        int code;\r
+       unsigned kind : 1;              /* if 1 it's an error of the application else assume it's a system error */\r
        const char* string;\r
+       \r
 }entry_t;\r
 \r
 \r
@@ -13,338 +15,343 @@ entry_t err[] =
 {\r
        \r
        #ifdef E2BIG\r
-       {"E2BIG", E2BIG, "Argument list too long."},\r
+       {"E2BIG", E2BIG, 0, "argument list too long"},\r
        #endif\r
        \r
        #ifdef EACCES\r
-       {"EACCES", EACCES, "Permission denied."},\r
+       {"EACCES", EACCES, 0, "permission denied"},\r
        #endif\r
        \r
        #ifdef EADDRINUSE\r
-       {"EADDRINUSE", EADDRINUSE, "Address in use."},\r
+       {"EADDRINUSE", EADDRINUSE, 0, "address in use"},\r
        #endif\r
        \r
        #ifdef EADDRNOTAVAIL\r
-       {"EADDRNOTAVAIL", EADDRNOTAVAIL, "Address not available."},\r
+       {"EADDRNOTAVAIL", EADDRNOTAVAIL, 0, "address not available"},\r
        #endif\r
        \r
        #ifdef EAFNOSUPPORT\r
-       {"EAFNOSUPPORT", EAFNOSUPPORT, "Address family not supported."},\r
+       {"EAFNOSUPPORT", EAFNOSUPPORT, 0, "address family not supported"},\r
        #endif\r
        \r
        #ifdef EAGAIN\r
-       {"EAGAIN", EAGAIN, "Resource unavailable, try again."},\r
+       {"EAGAIN", EAGAIN, 0, "resource unavailable, try again"},\r
        #endif\r
        \r
        #ifdef EALREADY\r
-       {"EALREADY", EALREADY, "Connection already in progress."},\r
+       {"EALREADY", EALREADY, 0, "connection already in progress"},\r
        #endif\r
        \r
        #ifdef EBADF\r
-       {"EBADF", EBADF, "Bad file descriptor."},\r
+       {"EBADF", EBADF, 0, "bad file descriptor"},\r
        #endif\r
        \r
        #ifdef EBADMSG\r
-       {"EBADMSG", EBADMSG, "Bad message."},\r
+       {"EBADMSG", EBADMSG, 0, "bad message"},\r
        #endif\r
        \r
        #ifdef EBUSY\r
-       {"EBUSY", EBUSY, "Device or resource busy."},\r
+       {"EBUSY", EBUSY, 0, "device or resource busy"},\r
        #endif\r
        \r
        #ifdef ECANCELED\r
-       {"ECANCELED", ECANCELED, "Operation canceled."},\r
+       {"ECANCELED", ECANCELED, 0, "operation canceled"},\r
        #endif\r
        \r
        #ifdef ECHILD\r
-       {"ECHILD", ECHILD, "No child processes."},\r
+       {"ECHILD", ECHILD, 0, "no child processes"},\r
        #endif\r
        \r
        #ifdef ECONNABORTED\r
-       {"ECONNABORTED", ECONNABORTED, "Connection aborted."},\r
+       {"ECONNABORTED", ECONNABORTED, 0, "connection aborted"},\r
        #endif\r
        \r
        #ifdef ECONNREFUSED\r
-       {"ECONNREFUSED", ECONNREFUSED, "Connection refused."},\r
+       {"ECONNREFUSED", ECONNREFUSED, 0, "connection refused"},\r
        #endif\r
        \r
        #ifdef ECONNRESET\r
-       {"ECONNRESET", ECONNRESET, "Connection reset."},\r
+       {"ECONNRESET", ECONNRESET, 0, "connection reset"},\r
        #endif\r
        \r
        #ifdef EDEADLK\r
-       {"EDEADLK", EDEADLK, "Resource deadlock would occur."},\r
+       {"EDEADLK", EDEADLK, 0, "resource deadlock would occur"},\r
        #endif\r
        \r
        #ifdef EDESTADDRREQ\r
-       {"EDESTADDRREQ", EDESTADDRREQ, "Destination address required."},\r
+       {"EDESTADDRREQ", EDESTADDRREQ, 0, "destination address required"},\r
        #endif\r
        \r
        #ifdef EDOM\r
-       {"EDOM", EDOM, "Mathematics argument out of domain of function."},\r
+       {"EDOM", EDOM, 0, "mathematics argument out of domain of function"},\r
        #endif \r
        \r
        #ifdef EEXIST\r
-       {"EEXIST", EEXIST, "File exists."},\r
+       {"EEXIST", EEXIST, 0, "file exists"},\r
        #endif\r
        \r
        #ifdef EFAULT\r
-       {"EFAULT", EFAULT, "Bad address."},\r
+       {"EFAULT", EFAULT, 0, "bad address"},\r
        #endif\r
        \r
        #ifdef EFBIG\r
-       {"EFBIG", EFBIG, "File too large."},\r
+       {"EFBIG", EFBIG, 0, "file too large"},\r
        #endif\r
        \r
        #ifdef EHOSTUNREACH\r
-       {"EHOSTUNREACH", EHOSTUNREACH, "Host is unreachable."},\r
+       {"EHOSTUNREACH", EHOSTUNREACH, 0, "host is unreachable"},\r
        #endif\r
        \r
        #ifdef EIDRM\r
-       {"EIDRM", EIDRM, "Identifier removed."},\r
+       {"EIDRM", EIDRM, 0, "identifier removed"},\r
        #endif\r
        \r
        #ifdef EILSEQ\r
-       {"EILSEQ", EILSEQ, "Illegal byte sequence."},\r
+       {"EILSEQ", EILSEQ, 0, "illegal byte sequence"},\r
        #endif\r
        \r
        #ifdef EINPROGRESS\r
-       {"EINPROGRESS", EINPROGRESS, "Operation in progress."},\r
+       {"EINPROGRESS", EINPROGRESS, 0, "operation in progress"},\r
        #endif\r
        \r
        #ifdef EINTR\r
-       {"EINTR", EINTR, "Interrupted function."},\r
+       {"EINTR", EINTR, 0, "interrupted function"},\r
        #endif\r
        \r
        #ifdef EINVAL\r
-       {"EINVAL", EINVAL, "Invalid argument."},\r
+       {"EINVAL", EINVAL, 0, "invalid argument"},\r
        #endif\r
        \r
        #ifdef EIO\r
-       {"EIO", EIO, "I/O error."},\r
+       {"EIO", EIO, 0, "I/O error"},\r
        #endif\r
        \r
        #ifdef EISCONN\r
-       {"EISCONN", EISCONN, "Socket is connected."},\r
+       {"EISCONN", EISCONN, 0, "socket is connected"},\r
        #endif\r
        \r
        #ifdef EISDIR\r
-       {"EISDIR", EISDIR, "Is a directory."},\r
+       {"EISDIR", EISDIR, 0, "is a directory"},\r
        #endif\r
        \r
        #ifdef ELOOP\r
-       {"ELOOP", ELOOP, "Too many levels of symbolic links."},\r
+       {"ELOOP", ELOOP, 0, "too many levels of symbolic links"},\r
        #endif\r
        \r
        #ifdef EMFILE\r
-       {"EMFILE", EMFILE, "Too many open files."},\r
+       {"EMFILE", EMFILE, 0, "too many open files"},\r
        #endif\r
        \r
        #ifdef EMLINK\r
-       {"EMLINK", EMLINK, "Too many links."},\r
+       {"EMLINK", EMLINK, 0, "too many links"},\r
        #endif\r
        \r
        #ifdef EMSGSIZE\r
-       {"EMSGSIZE", EMSGSIZE, "Message too large."},\r
+       {"EMSGSIZE", EMSGSIZE, 0, "message too large"},\r
        #endif\r
        \r
        #ifdef ENAMETOOLONG\r
-       {"ENAMETOOLONG", ENAMETOOLONG, "Filename too long."},\r
+       {"ENAMETOOLONG", ENAMETOOLONG, 0, "filename too long"},\r
        #endif\r
        \r
        #ifdef ENETDOWN\r
-       {"ENETDOWN", ENETDOWN, "Network is down."},\r
+       {"ENETDOWN", ENETDOWN, 0, "network is down"},\r
        #endif\r
        \r
        #ifdef ENETRESET\r
-       {"ENETRESET", ENETRESET, "Connection aborted by network."},\r
+       {"ENETRESET", ENETRESET, 0, "connection aborted by network"},\r
        #endif\r
        \r
        #ifdef ENETUNREACH\r
-       {"ENETUNREACH", ENETUNREACH, "Network unreachable."},\r
+       {"ENETUNREACH", ENETUNREACH, 0, "network unreachable"},\r
        #endif\r
        \r
        #ifdef ENFILE\r
-       {"ENFILE", ENFILE, "Too many files open in system."},\r
+       {"ENFILE", ENFILE, 0, "too many files open in system"},\r
        #endif\r
        \r
        #ifdef ENOBUFS\r
-       {"ENOBUFS", ENOBUFS, "No buffer space available."},\r
+       {"ENOBUFS", ENOBUFS, 0, "no buffer space available"},\r
        #endif\r
        \r
        #ifdef ENODATA\r
-       {"ENODATA", ENODATA, "No message is available on the STREAM head read queue."},\r
+       {"ENODATA", ENODATA, 0, "no message is available on the STREAM head read queue"},\r
        #endif\r
        \r
        #ifdef ENODEV\r
-       {"ENODEV", ENODEV, "No such device."},\r
+       {"ENODEV", ENODEV, 0, "no such device"},\r
        #endif\r
        \r
        #ifdef ENOENT\r
-       {"ENOENT", ENOENT, "No such file or directory."},\r
+       {"ENOENT", ENOENT, 0, "no such file or directory"},\r
        #endif\r
        \r
        #ifdef ENOEXEC\r
-       {"ENOEXEC", ENOEXEC, "Executable file format error."},\r
+       {"ENOEXEC", ENOEXEC, 0, "executable file format error"},\r
        #endif\r
        \r
        #ifdef ENOLCK\r
-       {"ENOLCK", ENOLCK, "No locks available."},\r
+       {"ENOLCK", ENOLCK, 0, "no locks available"},\r
        #endif\r
        \r
        #ifdef ENOMEM\r
-       {"ENOMEM", ENOMEM, "Not enough space."},\r
+       {"ENOMEM", ENOMEM, 0, "not enough space"},\r
        #endif\r
        \r
        #ifdef ENOMSG\r
-       {"ENOMSG", ENOMSG, "No message of the desired type."},\r
+       {"ENOMSG", ENOMSG, 0, "no message of the desired type"},\r
        #endif\r
        \r
        #ifdef ENOPROTOOPT\r
-       {"ENOPROTOOPT", ENOPROTOOPT, "Protocol not available."},\r
+       {"ENOPROTOOPT", ENOPROTOOPT, 0, "protocol not available"},\r
        #endif\r
        \r
        #ifdef ENOSPC\r
-       {"ENOSPC", ENOSPC, "No space left on device."},\r
+       {"ENOSPC", ENOSPC, 0, "no space left on device"},\r
        #endif\r
        \r
        #ifdef ENOSR\r
-       {"ENOSR", ENOSR, "No stream resources."},\r
+       {"ENOSR", ENOSR, 0, "no stream resources"},\r
        #endif\r
        \r
        #ifdef ENOSTR\r
-       {"ENOSTR", ENOSTR, "Not a stream."},\r
+       {"ENOSTR", ENOSTR, 0, "not a stream"},\r
        #endif\r
        \r
        #ifdef ENOSYS\r
-       {"ENOSYS", ENOSYS, "Function not supported."},\r
+       {"ENOSYS", ENOSYS, 0, "function not supported"},\r
        #endif\r
        \r
        #ifdef ENOTCONN\r
-       {"ENOTCONN", ENOTCONN, "The socket is not connected."},\r
+       {"ENOTCONN", ENOTCONN, 0, "the socket is not connected"},\r
        #endif\r
        \r
        #ifdef ENOTDIR\r
-       {"ENOTDIR", ENOTDIR, "Not a directory."},\r
+       {"ENOTDIR", ENOTDIR, 0, "not a directory"},\r
        #endif\r
        \r
        #ifdef ENOTEMPTY\r
-       {"ENOTEMPTY", ENOTEMPTY, "Directory not empty."},\r
+       {"ENOTEMPTY", ENOTEMPTY, 0, "directory not empty"},\r
        #endif\r
        \r
        #ifdef ENOTSOCK\r
-       {"ENOTSOCK", ENOTSOCK, "Not a socket."},\r
+       {"ENOTSOCK", ENOTSOCK, 0, "not a socket"},\r
        #endif\r
        \r
        #ifdef ENOTSUP\r
-       {"ENOTSUP", ENOTSUP, "Not supported."},\r
+       {"ENOTSUP", ENOTSUP, 0, "not supported"},\r
        #endif\r
        \r
        #ifdef ENOTTY\r
-       {"ENOTTY", ENOTTY, "Inappropriate I/O control operation."},\r
+       {"ENOTTY", ENOTTY, 0, "inappropriate I/O control operation"},\r
        #endif\r
        \r
        #ifdef ENXIO\r
-       {"ENXIO", ENXIO, "No such device or address."},\r
+       {"ENXIO", ENXIO, 0, "no such device or address"},\r
        #endif\r
        \r
        #ifdef EOPNOTSUPP\r
-       {"EOPNOTSUPP", EOPNOTSUPP, "Operation not supported on socket."},\r
+       {"EOPNOTSUPP", EOPNOTSUPP, 0, "operation not supported on socket"},\r
        #endif\r
        \r
        #ifdef EOVERFLOW\r
-       {"EOVERFLOW", EOVERFLOW, "Value too large to be stored in data type."},\r
+       {"EOVERFLOW", EOVERFLOW, 0, "value too large to be stored in data type"},\r
        #endif\r
        \r
        #ifdef EPERM\r
-       {"EPERM", EPERM, "Operation not permitted."},\r
+       {"EPERM", EPERM, 0, "operation not permitted"},\r
        #endif\r
        \r
        #ifdef EPIPE\r
-       {"EPIPE", EPIPE, "Broken pipe."},\r
+       {"EPIPE", EPIPE, 0, "broken pipe"},\r
        #endif\r
        \r
        #ifdef EPROTO\r
-       {"EPROTO", EPROTO, "Protocol error."},\r
+       {"EPROTO", EPROTO, 0, "protocol error"},\r
        #endif\r
        \r
        #ifdef EPROTONOSUPPORT\r
-       {"EPROTONOSUPPORT", EPROTONOSUPPORT, "Protocol not supported."},\r
+       {"EPROTONOSUPPORT", EPROTONOSUPPORT, 0, "protocol not supported"},\r
        #endif\r
        \r
        #ifdef EPROTOTYPE\r
-       {"EPROTOTYPE", EPROTOTYPE, "Protocol wrong type for socket."},\r
+       {"EPROTOTYPE", EPROTOTYPE, 0, "protocol wrong type for socket"},\r
        #endif\r
        \r
        #ifdef ERANGE\r
-       {"ERANGE", ERANGE, "Result too large."},\r
+       {"ERANGE", ERANGE, 0, "result too large"},\r
        #endif\r
        \r
        #ifdef EROFS\r
-       {"EROFS", EROFS, "Read-only file system."},\r
+       {"EROFS", EROFS, 0, "read-only file system"},\r
        #endif\r
        \r
        #ifdef ESPIPE\r
-       {"ESPIPE", ESPIPE, "Invalid seek."},\r
+       {"ESPIPE", ESPIPE, 0, "invalid seek"},\r
        #endif\r
        \r
        #ifdef ESRCH\r
-       {"ESRCH", ESRCH, "No such process."},\r
+       {"ESRCH", ESRCH, 0, "no such process"},\r
        #endif\r
        \r
        #ifdef ETIME\r
-       {"ETIME", ETIME, "Stream ioctl() timeout."},\r
+       {"ETIME", ETIME, 0, "stream ioctl() timeout"},\r
        #endif\r
        \r
        #ifdef ETIMEDOUT\r
-       {"ETIMEDOUT", ETIMEDOUT, "Connection timed out."},\r
+       {"ETIMEDOUT", ETIMEDOUT, 0, "connection timed out"},\r
        #endif\r
        \r
        #ifdef ETXTBSY\r
-       {"ETXTBSY", ETXTBSY, "Text file busy."},\r
+       {"ETXTBSY", ETXTBSY, 0, "text file busy"},\r
        #endif\r
        \r
        #ifdef EWOULDBLOCK\r
-       {"EWOULDBLOCK", EWOULDBLOCK, "Operation would block ."},\r
+       {"EWOULDBLOCK", EWOULDBLOCK, 0, "operation would block"},\r
        #endif\r
        \r
        #ifdef EXDEV\r
-       {"EXDEV", EXDEV, "Cross-device link ."},\r
-       #endif\r
-       \r
-       {"ECMDTIMEDOUT", ECMDTIMEDOUT, "Command timed out"},\r
-       \r
-       {"EEXEC", EEXEC, "can't execute a command"},\r
-       {"EWAIT", EWAIT, "wait function failed"},\r
-       {"ECMDNOTFOUND", ECMDNOTFOUND, "command is not found"},\r
-       {"EEXITCODENOTMATCH", EEXITCODENOTMATCH, "Exit code does not match"},\r
-       {"EOUTPUTNOTMATCH", EOUTPUTNOTMATCH, "Output does not match"},\r
-       {"ESIGNOTMATCH", ESIGNOTMATCH, "Signal does not match"},\r
-       {"EUNXPSIG", EUNXPSIG, "Unexpected signal caught"},\r
-       {"ESIGNOTRECEIPT", ESIGNOTRECEIPT, "Expected signal not receipt"},\r
-       {"EFILENOTFOUND", EFILENOTFOUND, "specified tesh file not found"},\r
-       {"EGETCWD", EGETCWD, "system error : the getcwd() function failed"},\r
-       {"EDIRNOTFOUND", EDIRNOTFOUND, "specified directory not found"},\r
-       {"EPROCCMDLINE", EPROCCMDLINE, "process_command_line() failed : internal error"},\r
-       {"ENOARG", ENOARG, "none optional argument not specified"},\r
-       {"ENOTPOSITIVENUM", ENOTPOSITIVENUM, "argument option not strictly positive"},\r
-       {"ESYNTAX", ESYNTAX, "Syntax error"},\r
-       {"EINVALIDTIMEOUT", EINVALIDTIMEOUT, "timeout value specified by metacommand invalid"},\r
-       {"EINVALIDEXITCODE", EINVALIDEXITCODE, "expected exit code value specified by the metacommand invalid"},\r
-       {"ESIGNOTSUPP", ESIGNOTSUPP, "signal specified by the metacommand not supported (Windows specific)"},\r
-       {"ELEADTIME", ELEADTIME, "lead time"},\r
-       {"EREADMENOTFOUND", EREADMENOTFOUND, "unable to locate the README.txt file"},\r
-       {"EINCLUDENOTFOUND", EINCLUDENOTFOUND, "include file specified by a metacommand is not found"},\r
-       {"ESUFFIXTOOLONG", ESUFFIXTOOLONG, "suffix is too long"},\r
-       {"EFILENOTINSPECDIR", EFILENOTINSPECDIR,"file not found in the specified directories"},\r
-       {"EFILENOTINCURDIR", EFILENOTINCURDIR,"file not found in the current directory"},\r
-       {"EINVCMDLINE", EINVCMDLINE, "invalid command line"},\r
-       {"unkwown", -1, "unknown"}\r
+       {"EXDEV", EXDEV, 0, "cross-device link"},\r
+       #endif\r
+       \r
+       {"ECMDTIMEDOUT", ECMDTIMEDOUT, 1, "command timed out"},\r
+\r
+       {"ECMDNOTFOUND", ECMDNOTFOUND,1,  "command not found"},\r
+\r
+       {"EEXITCODENOTMATCH", EEXITCODENOTMATCH,1,  "exit code mismatch"},\r
+\r
+       {"EOUTPUTNOTMATCH", EOUTPUTNOTMATCH,1,  "output mismatch"},\r
+\r
+       {"ESIGNOTMATCH", ESIGNOTMATCH,1,  "signal mismatch"},\r
+\r
+       {"EUNXPSIG", EUNXPSIG,1,  "unexpected signal caught"},\r
+\r
+       {"ESIGNOTRECEIPT", ESIGNOTRECEIVED,1,  "expected signal not receipt"},\r
+\r
+       {"EPROCCMDLINE", EPROCCMDLINE, 1, "command line processing failed"},\r
+\r
+       {"ENOARG", ENOARG, 1, "none optional argument not specified"},\r
+\r
+       {"ENOTPOSITIVENUM", ENOTPOSITIVENUM, 1, "argument option not strictly positive"},\r
+\r
+       {"ESYNTAX", ESYNTAX,1,  "syntax error"},\r
+\r
+       {"ELEADTIME", ELEADTIME, 1, "timed out"},\r
+\r
+       {"EREADMENOTFOUND", EREADMENOTFOUND,1,  "unable to locate the README.txt file"},\r
+\r
+       {"EINCLUDENOTFOUND", EINCLUDENOTFOUND, 1,  "include file not found"},\r
+\r
+       {"ESUFFIXTOOLONG", ESUFFIXTOOLONG,1,  "suffix too long"},\r
+\r
+       {"EINVCMDLINE", EINVCMDLINE,1,  "invalid command line"},\r
+\r
+       {"unkwown", -1, 0, "unknown"}\r
 };\r
 \r
 #include <stdio.h>\r
 \r
-#ifdef WIN32\r
+#ifdef _XBT_WIN32\r
 static char *\r
 w32error_to_string(DWORD errcode) \r
 {\r
@@ -376,15 +383,17 @@ w32error_to_string(DWORD errcode)
 #endif\r
 \r
 const char*\r
-error_to_string(int errcode)\r
+error_to_string(int errcode, int kind)\r
 {\r
        int i;\r
        \r
        for(i = 0; err[i].code != -1; i++)\r
-               if(err[i].code == errcode)\r
+               if(err[i].code == errcode && err[i].kind == kind)\r
                        return err[i].string;\r
 \r
-       #ifdef WIN32\r
+       #ifdef _XBT_WIN32\r
+\r
+       /* assume it's a W32 error */\r
        return w32error_to_string((DWORD)errcode);\r
        #else\r
        return "unknow error";  \r
@@ -405,24 +414,3 @@ error_get_at(int pos, int* code)
        return err[pos].name;\r
 }\r
 \r
-void\r
-error_register(const char* reason, int errcode, const char* command, const char* unit)\r
-{\r
-       xerror_t error;\r
-       \r
-       xbt_os_mutex_acquire(err_mutex);\r
-       \r
-       if(!exit_code)\r
-               exit_code = errcode;\r
-       \r
-       error = xbt_new0(s_xerror_t, 1);\r
-       \r
-       error->reason = reason;\r
-       error->command = command;\r
-       error->unit = unit;\r
-       error->errcode = errcode;\r
-       \r
-       xbt_dynar_push(errors, &error);\r
-       \r
-       xbt_os_mutex_release(err_mutex);\r
-}\r