-
Notifications
You must be signed in to change notification settings - Fork 0
/
ceerrno.c
109 lines (99 loc) · 1.75 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
99
100
101
102
103
104
105
106
107
108
109
// ceerrno.c
//
// Time-stamp: <18/02/01 19:33:25 keuchel@w2k>
#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;
case ERROR_ALREADY_EXISTS:
return EEXIST;
default:
return EOSERR;
}
return EOSERR;
}
void
xceperror(const char *s)
{
char buf[126];
xceprinterror("%s: %s\n", s, xcestrerror(errno));
}
char *
xcestrerror(int n)
{
static char buf[125];
if(n < 0)
{
sprintf(buf, "Strange Error %d", n);
}
else if(n == EOSERR)
{
sprintf(buf, "OsError: %d", GetLastError());
}
else if(n > ENOSYS)
{
// maybe its a socket error/windows error
strcpy(buf, xcewinstrerror(n));
}
else
{
strcpy(buf, _error_list[n]);
}
return buf;
}