|
@@ -26,12 +26,15 @@
|
|
|
*
|
|
|
* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
|
|
|
|
|
|
+#define _STDIO_UTILITY
|
|
|
#define _GNU_SOURCE
|
|
|
#include <string.h>
|
|
|
#include <strings.h>
|
|
|
+#include <stdio.h>
|
|
|
#include <limits.h>
|
|
|
#include <ctype.h>
|
|
|
#include <stdlib.h>
|
|
|
+#include <errno.h>
|
|
|
|
|
|
#ifdef WANT_WIDE
|
|
|
#include <wchar.h>
|
|
@@ -53,6 +56,291 @@ typedef unsigned char __string_uchar_t;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ * have to be changed! */
|
|
|
+
|
|
|
+#if _SYS_ERRMSG_MAXLEN < __UIM_BUFLEN_INT + 14
|
|
|
+#define _STRERROR_BUFSIZE (__UIM_BUFLEN_INT + 14)
|
|
|
+#else
|
|
|
+#define _STRERROR_BUFSIZE _SYS_ERRMSG_MAXLEN
|
|
|
+#endif
|
|
|
+
|
|
|
+#define _SYS_NERR 125
|
|
|
+#define _SYS_ERRMSG_MAXLEN 50
|
|
|
+
|
|
|
+extern const char _string_syserrmsgs[];
|
|
|
+
|
|
|
+
|
|
|
+#ifdef L__string_syserrmsgs
|
|
|
+
|
|
|
+const char _string_syserrmsgs[] = {
|
|
|
+ "Success\0"
|
|
|
+ "Operation not permitted\0"
|
|
|
+ "No such file or directory\0"
|
|
|
+ "No such process\0"
|
|
|
+ "Interrupted system call\0"
|
|
|
+ "Input/output error\0"
|
|
|
+ "No such device or address\0"
|
|
|
+ "Argument list too long\0"
|
|
|
+ "Exec format error\0"
|
|
|
+ "Bad file descriptor\0"
|
|
|
+ "No child processes\0"
|
|
|
+ "Resource temporarily unavailable\0"
|
|
|
+ "Cannot allocate memory\0"
|
|
|
+ "Permission denied\0"
|
|
|
+ "Bad address\0"
|
|
|
+ "Block device required\0"
|
|
|
+ "Device or resource busy\0"
|
|
|
+ "File exists\0"
|
|
|
+ "Invalid cross-device link\0"
|
|
|
+ "No such device\0"
|
|
|
+ "Not a directory\0"
|
|
|
+ "Is a directory\0"
|
|
|
+ "Invalid argument\0"
|
|
|
+ "Too many open files in system\0"
|
|
|
+ "Too many open files\0"
|
|
|
+ "Inappropriate ioctl for device\0"
|
|
|
+ "Text file busy\0"
|
|
|
+ "File too large\0"
|
|
|
+ "No space left on device\0"
|
|
|
+ "Illegal seek\0"
|
|
|
+ "Read-only file system\0"
|
|
|
+ "Too many links\0"
|
|
|
+ "Broken pipe\0"
|
|
|
+ "Numerical argument out of domain\0"
|
|
|
+ "Numerical result out of range\0"
|
|
|
+ "Resource deadlock avoided\0"
|
|
|
+ "File name too long\0"
|
|
|
+ "No locks available\0"
|
|
|
+ "Function not implemented\0"
|
|
|
+ "Directory not empty\0"
|
|
|
+ "Too many levels of symbolic links\0"
|
|
|
+ "\0"
|
|
|
+ "No message of desired type\0"
|
|
|
+ "Identifier removed\0"
|
|
|
+ "Channel number out of range\0"
|
|
|
+ "Level 2 not synchronized\0"
|
|
|
+ "Level 3 halted\0"
|
|
|
+ "Level 3 reset\0"
|
|
|
+ "Link number out of range\0"
|
|
|
+ "Protocol driver not attached\0"
|
|
|
+ "No CSI structure available\0"
|
|
|
+ "Level 2 halted\0"
|
|
|
+ "Invalid exchange\0"
|
|
|
+ "Invalid request descriptor\0"
|
|
|
+ "Exchange full\0"
|
|
|
+ "No anode\0"
|
|
|
+ "Invalid request code\0"
|
|
|
+ "Invalid slot\0"
|
|
|
+ "\0"
|
|
|
+ "Bad font file format\0"
|
|
|
+ "Device not a stream\0"
|
|
|
+ "No data available\0"
|
|
|
+ "Timer expired\0"
|
|
|
+ "Out of streams resources\0"
|
|
|
+ "Machine is not on the network\0"
|
|
|
+ "Package not installed\0"
|
|
|
+ "Object is remote\0"
|
|
|
+ "Link has been severed\0"
|
|
|
+ "Advertise error\0"
|
|
|
+ "Srmount error\0"
|
|
|
+ "Communication error on send\0"
|
|
|
+ "Protocol error\0"
|
|
|
+ "Multihop attempted\0"
|
|
|
+ "RFS specific error\0"
|
|
|
+ "Bad message\0"
|
|
|
+ "Value too large for defined data type\0"
|
|
|
+ "Name not unique on network\0"
|
|
|
+ "File descriptor in bad state\0"
|
|
|
+ "Remote address changed\0"
|
|
|
+ "Can not access a needed shared library\0"
|
|
|
+ "Accessing a corrupted shared library\0"
|
|
|
+ ".lib section in a.out corrupted\0"
|
|
|
+ "Attempting to link in too many shared libraries\0"
|
|
|
+ "Cannot exec a shared library directly\0"
|
|
|
+ "Invalid or incomplete multibyte or wide character\0"
|
|
|
+ "Interrupted system call should be restarted\0"
|
|
|
+ "Streams pipe error\0"
|
|
|
+ "Too many users\0"
|
|
|
+ "Socket operation on non-socket\0"
|
|
|
+ "Destination address required\0"
|
|
|
+ "Message too long\0"
|
|
|
+ "Protocol wrong type for socket\0"
|
|
|
+ "Protocol not available\0"
|
|
|
+ "Protocol not supported\0"
|
|
|
+ "Socket type not supported\0"
|
|
|
+ "Operation not supported\0"
|
|
|
+ "Protocol family not supported\0"
|
|
|
+ "Address family not supported by protocol\0"
|
|
|
+ "Address already in use\0"
|
|
|
+ "Cannot assign requested address\0"
|
|
|
+ "Network is down\0"
|
|
|
+ "Network is unreachable\0"
|
|
|
+ "Network dropped connection on reset\0"
|
|
|
+ "Software caused connection abort\0"
|
|
|
+ "Connection reset by peer\0"
|
|
|
+ "No buffer space available\0"
|
|
|
+ "Transport endpoint is already connected\0"
|
|
|
+ "Transport endpoint is not connected\0"
|
|
|
+ "Cannot send after transport endpoint shutdown\0"
|
|
|
+ "Too many references: cannot splice\0"
|
|
|
+ "Connection timed out\0"
|
|
|
+ "Connection refused\0"
|
|
|
+ "Host is down\0"
|
|
|
+ "No route to host\0"
|
|
|
+ "Operation already in progress\0"
|
|
|
+ "Operation now in progress\0"
|
|
|
+ "Stale NFS file handle\0"
|
|
|
+ "Structure needs cleaning\0"
|
|
|
+ "Not a XENIX named type file\0"
|
|
|
+ "No XENIX semaphores available\0"
|
|
|
+ "Is a named type file\0"
|
|
|
+ "Remote I/O error\0"
|
|
|
+ "Disk quota exceeded\0"
|
|
|
+ "No medium found\0"
|
|
|
+ "Wrong medium type"
|
|
|
+};
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+#ifdef L_sys_errlist
|
|
|
+
|
|
|
+link_warning(_sys_errlist, "sys_nerr and sys_errlist are obsolete and uClibc support for them (in at least some configurations) will probably be unavailable in the near future.")
|
|
|
+
|
|
|
+int sys_nerr = _SYS_NERR;
|
|
|
+
|
|
|
+const char *const sys_errlist[] = {
|
|
|
+ _string_syserrmsgs + 0,
|
|
|
+ _string_syserrmsgs + 8,
|
|
|
+ _string_syserrmsgs + 32,
|
|
|
+ _string_syserrmsgs + 58,
|
|
|
+ _string_syserrmsgs + 74,
|
|
|
+ _string_syserrmsgs + 98,
|
|
|
+ _string_syserrmsgs + 117,
|
|
|
+ _string_syserrmsgs + 143,
|
|
|
+ _string_syserrmsgs + 166,
|
|
|
+ _string_syserrmsgs + 184,
|
|
|
+ _string_syserrmsgs + 204,
|
|
|
+ _string_syserrmsgs + 223,
|
|
|
+ _string_syserrmsgs + 256,
|
|
|
+ _string_syserrmsgs + 279,
|
|
|
+ _string_syserrmsgs + 297,
|
|
|
+ _string_syserrmsgs + 309,
|
|
|
+ _string_syserrmsgs + 331,
|
|
|
+ _string_syserrmsgs + 355,
|
|
|
+ _string_syserrmsgs + 367,
|
|
|
+ _string_syserrmsgs + 393,
|
|
|
+ _string_syserrmsgs + 408,
|
|
|
+ _string_syserrmsgs + 424,
|
|
|
+ _string_syserrmsgs + 439,
|
|
|
+ _string_syserrmsgs + 456,
|
|
|
+ _string_syserrmsgs + 486,
|
|
|
+ _string_syserrmsgs + 506,
|
|
|
+ _string_syserrmsgs + 537,
|
|
|
+ _string_syserrmsgs + 552,
|
|
|
+ _string_syserrmsgs + 567,
|
|
|
+ _string_syserrmsgs + 591,
|
|
|
+ _string_syserrmsgs + 604,
|
|
|
+ _string_syserrmsgs + 626,
|
|
|
+ _string_syserrmsgs + 641,
|
|
|
+ _string_syserrmsgs + 653,
|
|
|
+ _string_syserrmsgs + 686,
|
|
|
+ _string_syserrmsgs + 716,
|
|
|
+ _string_syserrmsgs + 742,
|
|
|
+ _string_syserrmsgs + 761,
|
|
|
+ _string_syserrmsgs + 780,
|
|
|
+ _string_syserrmsgs + 805,
|
|
|
+ _string_syserrmsgs + 825,
|
|
|
+
|
|
|
+ NULL,
|
|
|
+ _string_syserrmsgs + 860,
|
|
|
+ _string_syserrmsgs + 887,
|
|
|
+ _string_syserrmsgs + 906,
|
|
|
+ _string_syserrmsgs + 934,
|
|
|
+ _string_syserrmsgs + 959,
|
|
|
+ _string_syserrmsgs + 974,
|
|
|
+ _string_syserrmsgs + 988,
|
|
|
+ _string_syserrmsgs + 1013,
|
|
|
+ _string_syserrmsgs + 1042,
|
|
|
+ _string_syserrmsgs + 1069,
|
|
|
+ _string_syserrmsgs + 1084,
|
|
|
+ _string_syserrmsgs + 1101,
|
|
|
+ _string_syserrmsgs + 1128,
|
|
|
+ _string_syserrmsgs + 1142,
|
|
|
+ _string_syserrmsgs + 1151,
|
|
|
+ _string_syserrmsgs + 1172,
|
|
|
+
|
|
|
+ NULL,
|
|
|
+ _string_syserrmsgs + 1186,
|
|
|
+ _string_syserrmsgs + 1207,
|
|
|
+ _string_syserrmsgs + 1227,
|
|
|
+ _string_syserrmsgs + 1245,
|
|
|
+ _string_syserrmsgs + 1259,
|
|
|
+ _string_syserrmsgs + 1284,
|
|
|
+ _string_syserrmsgs + 1314,
|
|
|
+ _string_syserrmsgs + 1336,
|
|
|
+ _string_syserrmsgs + 1353,
|
|
|
+ _string_syserrmsgs + 1375,
|
|
|
+ _string_syserrmsgs + 1391,
|
|
|
+ _string_syserrmsgs + 1405,
|
|
|
+ _string_syserrmsgs + 1433,
|
|
|
+ _string_syserrmsgs + 1448,
|
|
|
+ _string_syserrmsgs + 1467,
|
|
|
+ _string_syserrmsgs + 1486,
|
|
|
+ _string_syserrmsgs + 1498,
|
|
|
+ _string_syserrmsgs + 1536,
|
|
|
+ _string_syserrmsgs + 1563,
|
|
|
+ _string_syserrmsgs + 1592,
|
|
|
+ _string_syserrmsgs + 1615,
|
|
|
+ _string_syserrmsgs + 1654,
|
|
|
+ _string_syserrmsgs + 1691,
|
|
|
+ _string_syserrmsgs + 1723,
|
|
|
+ _string_syserrmsgs + 1771,
|
|
|
+ _string_syserrmsgs + 1809,
|
|
|
+ _string_syserrmsgs + 1859,
|
|
|
+ _string_syserrmsgs + 1903,
|
|
|
+ _string_syserrmsgs + 1922,
|
|
|
+ _string_syserrmsgs + 1937,
|
|
|
+ _string_syserrmsgs + 1968,
|
|
|
+ _string_syserrmsgs + 1997,
|
|
|
+ _string_syserrmsgs + 2014,
|
|
|
+ _string_syserrmsgs + 2045,
|
|
|
+ _string_syserrmsgs + 2068,
|
|
|
+ _string_syserrmsgs + 2091,
|
|
|
+ _string_syserrmsgs + 2117,
|
|
|
+ _string_syserrmsgs + 2141,
|
|
|
+ _string_syserrmsgs + 2171,
|
|
|
+ _string_syserrmsgs + 2212,
|
|
|
+ _string_syserrmsgs + 2235,
|
|
|
+ _string_syserrmsgs + 2267,
|
|
|
+ _string_syserrmsgs + 2283,
|
|
|
+ _string_syserrmsgs + 2306,
|
|
|
+ _string_syserrmsgs + 2342,
|
|
|
+ _string_syserrmsgs + 2375,
|
|
|
+ _string_syserrmsgs + 2400,
|
|
|
+ _string_syserrmsgs + 2426,
|
|
|
+ _string_syserrmsgs + 2466,
|
|
|
+ _string_syserrmsgs + 2502,
|
|
|
+ _string_syserrmsgs + 2548,
|
|
|
+ _string_syserrmsgs + 2583,
|
|
|
+ _string_syserrmsgs + 2604,
|
|
|
+ _string_syserrmsgs + 2623,
|
|
|
+ _string_syserrmsgs + 2636,
|
|
|
+ _string_syserrmsgs + 2653,
|
|
|
+ _string_syserrmsgs + 2683,
|
|
|
+ _string_syserrmsgs + 2709,
|
|
|
+ _string_syserrmsgs + 2731,
|
|
|
+ _string_syserrmsgs + 2756,
|
|
|
+ _string_syserrmsgs + 2784,
|
|
|
+ _string_syserrmsgs + 2814,
|
|
|
+ _string_syserrmsgs + 2835,
|
|
|
+ _string_syserrmsgs + 2852,
|
|
|
+ _string_syserrmsgs + 2872,
|
|
|
+ _string_syserrmsgs + 2888,
|
|
|
+};
|
|
|
+
|
|
|
+#endif
|
|
|
|
|
|
#ifdef L_wmemcpy
|
|
|
#define L_memcpy
|
|
@@ -255,7 +543,7 @@ Wchar *Wstrncat(Wchar * __restrict s1, register const Wchar * __restrict s2,
|
|
|
#ifdef L_memcmp
|
|
|
|
|
|
#ifndef L_wmemcmp
|
|
|
-weak_alias(memcmp,bcmp)
|
|
|
+weak_alias(memcmp,bcmp);
|
|
|
#endif
|
|
|
|
|
|
int Wmemcmp(const Wvoid *s1, const Wvoid *s2, size_t n)
|
|
@@ -418,7 +706,7 @@ Wvoid *Wmemchr(const Wvoid *s, Wint c, size_t n)
|
|
|
#ifdef L_strchr
|
|
|
|
|
|
#ifndef L_wcschr
|
|
|
-weak_alias(strchr,index)
|
|
|
+weak_alias(strchr,index);
|
|
|
#endif
|
|
|
|
|
|
Wchar *Wstrchr(register const Wchar *s, Wint c)
|
|
@@ -492,7 +780,7 @@ Wchar *Wstrpbrk(const Wchar *s1, const Wchar *s2)
|
|
|
#ifdef L_strrchr
|
|
|
|
|
|
#ifndef L_wcsrchr
|
|
|
-weak_alias(strrchr,rindex)
|
|
|
+weak_alias(strrchr,rindex);
|
|
|
#endif
|
|
|
|
|
|
Wchar *Wstrrchr(register const Wchar *s, Wint c)
|
|
@@ -548,7 +836,7 @@ size_t Wstrspn(const Wchar *s1, const Wchar *s2)
|
|
|
|
|
|
|
|
|
#ifdef L_wcsstr
|
|
|
-weak_alias(wcsstr,wcswcs)
|
|
|
+weak_alias(wcsstr,wcswcs);
|
|
|
#endif
|
|
|
|
|
|
Wchar *Wstrstr(const Wchar *s1, const Wchar *s2)
|
|
@@ -672,11 +960,6 @@ Wvoid *Wmemset(Wvoid *s, Wint c, size_t n)
|
|
|
}
|
|
|
#undef np
|
|
|
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef L_strerror
|
|
|
-#error implement strerror
|
|
|
-
|
|
|
#endif
|
|
|
|
|
|
#ifdef L_wcslen
|
|
@@ -888,10 +1171,92 @@ Wchar *Wstrdup(register const Wchar *s1)
|
|
|
return s;
|
|
|
}
|
|
|
|
|
|
+#endif
|
|
|
+
|
|
|
+#ifdef L_strerror
|
|
|
+
|
|
|
+char *strerror(int errnum)
|
|
|
+{
|
|
|
+ static char buf[_SYS_ERRMSG_MAXLEN];
|
|
|
+
|
|
|
+ return (_susv3_strerror_r(errnum, buf, sizeof(buf)) == 0) ? buf : NULL;
|
|
|
+}
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#ifdef L__susv3_strerror_r
|
|
|
+
|
|
|
+int _susv3_strerror_r(int errnum, char *strerrbuf, size_t buflen)
|
|
|
+{
|
|
|
+ register char *s;
|
|
|
+ int i, retval;
|
|
|
+ char buf[_SYS_ERRMSG_MAXLEN];
|
|
|
+ static const char unknown[14] = {
|
|
|
+ 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r', ' '
|
|
|
+ };
|
|
|
+
|
|
|
+ retval = EINVAL;
|
|
|
+
|
|
|
+ if (((unsigned int) errnum) < _SYS_NERR) {
|
|
|
+
|
|
|
+ * so rather than keeping an array of pointers for the different
|
|
|
+ * messages, just run through the buffer until we find the
|
|
|
+ * correct string. */
|
|
|
+ for (s = (char *) _string_syserrmsgs, i = errnum ; i ; ++s) {
|
|
|
+ if (!*s) {
|
|
|
+ --i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (*s) {
|
|
|
+ retval = 0;
|
|
|
+ goto GOT_MESG;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ s = _int10tostr(buf+sizeof(buf)-1, errnum) - sizeof(unknown);
|
|
|
+ memcpy(s, unknown, sizeof(unknown));
|
|
|
+
|
|
|
+ GOT_MESG:
|
|
|
+ if (!strerrbuf) {
|
|
|
+ buflen = 0;
|
|
|
+ }
|
|
|
+ i = strlen(s) + 1;
|
|
|
+ if (i > buflen) {
|
|
|
+ i = buflen;
|
|
|
+ retval = ERANGE;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (i) {
|
|
|
+ memcpy(strerrbuf, s, i);
|
|
|
+ strerrbuf[i-1] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (retval) {
|
|
|
+ __set_errno(retval);
|
|
|
+ }
|
|
|
+
|
|
|
+ return retval;
|
|
|
+}
|
|
|
+
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
+#ifdef L__glibc_strerror_r
|
|
|
+
|
|
|
+weak_alias(_glibc_strerror_r,__strerror_r);
|
|
|
+
|
|
|
+char *_glibc_strerror_r(int errnum, char *strerrbuf, size_t buflen)
|
|
|
+{
|
|
|
+ _susv3_strerror_r(errnum, strerrbuf, buflen);
|
|
|
+
|
|
|
+ return strerrbuf;
|
|
|
+}
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
#ifdef L_wmempcpy
|
|
|
#define L_mempcpy
|
|
|
#define Wmempcpy wmempcpy
|
|
@@ -903,7 +1268,7 @@ Wchar *Wstrdup(register const Wchar *s1)
|
|
|
|
|
|
#ifndef L_wmempcpy
|
|
|
|
|
|
-weak_alias(mempcpy,__mempcpy)
|
|
|
+weak_alias(mempcpy,__mempcpy);
|
|
|
#endif
|
|
|
|
|
|
Wvoid *Wmempcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n)
|