Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1f7a7959a0fcc9f4258eb6d841685e9fa2cb4f61
[simgrid.git] / tools / tesh2 / src / error.c
1 #include <error.h>\r
2 \r
3 typedef struct s_entry\r
4 {\r
5         int code;\r
6         const char* string;\r
7 }entry_t;\r
8 \r
9 static const\r
10 entry_t err[] =\r
11 {\r
12         {EREAD, "a read pipe operation failed"},\r
13         {EREADPIPE, "a pipe used to read from the stdout of a command is broken"},\r
14         {ETIMEOUT, "a command is timeouted"},\r
15         {EWRITE, "a write operation failed"},\r
16         {EWRITEPIPE, "a pipe used to write to the stdin of a command is broken"},\r
17         {EEXEC, "can't execute a command"},\r
18         {EWAIT, "wait function failed"},\r
19         {ECMDNOTFOUND, "command is not found"},\r
20         {EEXITCODENOTMATCH, "exit codes don't match"},\r
21         {EOUTPUTNOTMATCH, "outputs don't match"},\r
22         {ESIGNOTMATCH, "signals don't match"},\r
23         {EUNEXPECTEDSIG, "unexpected signal caught"},\r
24         {ESIGNOTRECEIPT, "expected signal not receipt"},\r
25         {EFILENOTFOUND, "specified tesh file not found"},\r
26         {EGETCWD, "system error : the getcwd() function failed"},\r
27         {EDIRNOTFOUND, "specified directory not found"},\r
28         {ECHDIR, "system error : the chdir() function failed"},\r
29         {EPROCESSCMDLINE, "internal error : the process_command_line() function failed"},\r
30         {EARGNOTSPEC, "none optional argument not specified in the command line"},\r
31         {ENOTPOSITIVENUM, "argument option not strictly positive"},\r
32         {ESYNTAX, "syntax error"},\r
33         {EINVALIDTIMEOUT, "timeout value specified by metacommand invalid"},\r
34         {EINVALIDEXITCODE, "expected exit code value specified by the metacommand invalid"},\r
35         {ESIGNOTSUPP, "signal specified by the metacommand not supported (Windows specific)"},\r
36         {ELEADTIME, "lead time"},\r
37         {EREADMENOTFOUND, "unable to locate the README.txt file"},\r
38         {EINCLUDENOTFOUND, "include file specified by a metacommand is not found"},\r
39         {ESUFFIXTOOLONG, "suffix is too long"},\r
40         {EFILENOTINSPECDIR,"file not found in the specified directories"},\r
41         {EFILENOTINCURDIR,"file not found in the current directory"},\r
42         {-1, "unknown"}\r
43 };\r
44 \r
45 const char*\r
46 error_to_string(int error)\r
47 {\r
48         int i;\r
49         \r
50         for(i = 0; error >= 0 && err[i].code != -1; i++)\r
51         {\r
52                 if(err[i].code == error)\r
53                         return err[i].string;\r
54         } \r
55         \r
56         return "unknow error";  \r
57 }\r