-
Notifications
You must be signed in to change notification settings - Fork 1
/
err2str.c
83 lines (79 loc) · 2.86 KB
/
err2str.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
/*
err2str.c - Part of macxx, a cross assembler family for various micro-processors
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 <stdio.h>
#include <errno.h>
#include <string.h>
char *error2str( int num) /* modeled after VMS's strerror() */
{
#ifndef HAS_STRERROR
static char undef_msg[64];
#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";
case ENOTBLK: return "block device required";
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";
case ETXTBSY: return "text file busy";
case EPIPE: return "broken pipe";
case EDOM: return "math argument";
case ERANGE: return "result too large";
#ifdef VMS
case EVMSERR: {
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
#else
return strerror(num);
#endif
}