-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathceerrno.c
98 lines (87 loc) · 1.56 KB
/
ceerrno.c
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
// ceerrno.c
//
// Time-stamp: <03/02/01 10:37:48 keuchel@lightning>
#include "celib.h"
#include "errno.h"
#ifndef _MT
int errno;
#endif
char *_error_list[] = {
"No error", // 0
"EPERM",
"No such file or directory", // ENOENT
"ESRCH",
"EINTR",
"EIO",
"ENXIO",
"E2BIG",
"ENOEXEC",
"Bad file descriptor", // EBADF
"ECHILD",
"EAGAIN",
"ENOMEM",
"Permission denied", // EACCESS
"EFAULT",
"NOSUCHERROR",
"EBUSY",
"File exists", // EEXISTS
"EXDEV",
"ENODEV",
"ENOTDIR",
"EISDIR",
"Invalid argument", // EINVAL
"ENFILE",
"EMFILE",
"ENOTTY",
"NOSUCHERROR",
"EFBIG",
"Disk full", // ENOSPC
"ESPIPE",
"EROFS",
"EMLINK",
"Broken pipe", // EPIPE
"EDOM",
"ERANGE",
"NOSUCHERROR",
"EDEADLK",
"Unimplemented system call", // ENOSYS
NULL
};
int
_winerror2errno(DWORD werror)
{
switch(werror)
{
case 0:
return 0;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
return ENOENT;
case ERROR_ACCESS_DENIED:
return EACCES;
case ERROR_DEV_NOT_EXIST:
return ENODEV;
default:
return EOSERR;
}
return EOSERR;
}
void
xceperror(const char *s)
{
char buf[126];
sprintf(buf, "%s: %s", s, xcestrerror(errno));
XCEShowMessageA(buf);
}
char *
xcestrerror(int n)
{
static char buf[125];
if(n < 0 || n > ENOSYS)
return "NOSUCHERROR";
if(n == EOSERR)
sprintf(buf, "OsError: %d", GetLastError());
else
strcpy(buf, _error_list[n]);
return buf;
}