summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/ap/stdio/strerror.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/ape/lib/ap/stdio/strerror.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/ape/lib/ap/stdio/strerror.c')
-rwxr-xr-xsys/src/ape/lib/ap/stdio/strerror.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/sys/src/ape/lib/ap/stdio/strerror.c b/sys/src/ape/lib/ap/stdio/strerror.c
new file mode 100755
index 000000000..71685d906
--- /dev/null
+++ b/sys/src/ape/lib/ap/stdio/strerror.c
@@ -0,0 +1,106 @@
+/*
+ * pANS stdio -- strerror (not really in stdio)
+ *
+ * Shouldn't really call this sys_errlist or make it
+ * externally visible, but too many programs in X assume it...
+ */
+#include <string.h>
+#include <errno.h>
+
+#include "iolib.h"
+
+char *sys_errlist[] = {
+ "Error 0",
+ "Too big",
+ "Access denied",
+ "Try again",
+ "Bad file number",
+ "In use",
+ "No children",
+ "Deadlock",
+ "File exists",
+ "Bad address",
+ "File too large",
+ "Interrupted system call",
+ "Invalid argument",
+ "I/O error",
+ "Is a directory",
+ "Too many open files",
+ "Too many links",
+ "Name too long",
+ "File table overflow",
+ "No such device",
+ "No such file or directory",
+ "Exec format error",
+ "Not enough locks",
+ "Not enough memory",
+ "No space left on device",
+ "No such system call",
+ "Not a directory",
+ "Directory not empty",
+ "Inappropriate ioctl",
+ "No such device or address",
+ "Permission denied",
+ "Broken pipe",
+ "Read-only file system",
+ "Illegal seek",
+ "No such process",
+ "Cross-device link",
+
+ /* bsd networking software */
+ "Not a socket",
+ "Protocol not supported", /* EPROTONOSUPPORT, EPROTOTYPE */
+/* "Protocol wrong type for socket", /* EPROTOTYPE */
+ "Connection refused",
+ "Address family not supported",
+ "No buffers",
+ "OP not supported",
+ "Address in use",
+ "Destination address required",
+ "Message size",
+ "Protocol option not supported",
+ "Socket option not supported",
+ "Protocol family not supported", /* EPFNOSUPPORT */
+ "Address not available",
+ "Network down",
+ "Network unreachable",
+ "Network reset",
+ "Connection aborted",
+ "Connected",
+ "Not connected",
+ "Shut down",
+ "Too many references",
+ "Timed out",
+ "Host down",
+ "Host unreachable",
+ "Unknown error", /* EGREG */
+
+ /* These added in 1003.1b-1993 */
+ "Operation canceled",
+ "Operation in progress"
+};
+#define _IO_nerr (sizeof sys_errlist/sizeof sys_errlist[0])
+int sys_nerr = _IO_nerr;
+extern char _plan9err[];
+
+char *
+strerror(int n)
+{
+ if(n == EPLAN9)
+ return _plan9err;
+ if(n >= 0 && n < _IO_nerr)
+ return sys_errlist[n];
+ if(n == EDOM)
+ return "Domain error";
+ else if(n == ERANGE)
+ return "Range error";
+ else
+ return "Unknown error";
+}
+
+char *
+strerror_r(int n, char *buf, int len)
+{
+ strncpy(buf, strerror(n), len);
+ buf[len-1] = 0;
+}