-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherr2str.c
More file actions
122 lines (114 loc) · 3.7 KB
/
err2str.c
File metadata and controls
122 lines (114 loc) · 3.7 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
err2str.c - Part of llf, a cross linker. Part of the macxx tool chain.
Copyright (C) 2008 David Shepperd
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <stdio.h>
#include <inttypes.h>
#if defined(VMS)
typedef struct desc
{
uint16_t len;
unsigned char type;
unsigned char class;
char *ptr;
} Desc;
int err2str$stv=0;
static char undef_msg[256];
static Desc gmsgdesc = {sizeof(undef_msg),0,0,undef_msg};
#else
static char undef_msg[64];
#endif
const char *err2str( int num ) /* modeled after VMS's strerror() */
{
#ifndef __TURBOC__
switch (num)
{
case EPERM: return "not owner";
case ENOENT: return "no such file or directory";
case EIO: return "i/o error";
case ENXIO: return "no such device or address";
case EBADF: return "bad file number";
case EACCES: return "permission denied";
#ifndef WIN32
case ENOTBLK: return "block device required";
#endif
case EBUSY: return "mount device busy";
case EEXIST: return "file exists";
case EISDIR: return "is a directory";
case EXDEV: return "cross-device link";
case ENODEV: return "no such device";
case ENOTDIR: return "not a directory";
case ENFILE: return "file table overflow";
case EMFILE: return "too many open files";
case EFBIG: return "file too large";
case ENOSPC: return "no space left on device";
case ESPIPE: return "illegal seek";
case EROFS: return "read-only file system";
case EMLINK: return "too many links";
#ifdef VMS
case EWOULDBLOCK: "I/O operation would block channel";
#endif
case ESRCH: return "no such process";
case EINTR: return "interrupted system call";
case E2BIG: return "arg list too long";
case ENOEXEC: return "exec format error";
case ECHILD: return "no children";
case EAGAIN: return "no more processes";
case ENOMEM: return "not enough core";
case EFAULT: return "bad address";
case EINVAL: return "invalid argument";
case ENOTTY: return "not a typewriter";
#ifndef WIN32
case ETXTBSY: return "text file busy";
#endif
case EPIPE: return "broken pipe";
case EDOM: return "math argument";
case ERANGE: return "result too large";
#ifdef VMS
case EVMSERR: {
int retlen;
#if 0
struct
{
uint16_t count;
uint16_t options;
uint32_t code;
uint32_t stv;
} msgvec;
msgvec.count = sizeof(msgvec)/sizeof(int32_t)-1;
msgvec.options = 0;
msgvec.code = vaxc$errno;
msgvec.stv = err2str$stv;
#endif
if ((vaxc$errno&0x07FF0000) <= 0x10000)
{
sys$getmsg(vaxc$errno,&retlen,&gmsgdesc,1,(char *)0);
undef_msg[retlen] = 0;
}
else
{
sprintf(undef_msg,"Untranslatable VMS error code of: 0x%08X",vaxc$errno);
}
return undef_msg;
}
#endif
default: {
#endif
sprintf(undef_msg,"Undefined error code: 0x%0X",num);
return undef_msg;
#ifndef __TURBOC__
}
}
#endif
}