move msghdr and cmsghdr out of bits/socket.h
[musl.git] / src / errno / strerror.c
blobe3ed771a719dba9eb26249d8c9f32e0e6f16a580
1 #include <errno.h>
2 #include <string.h>
3 #include "locale_impl.h"
5 #define E(a,b) ((unsigned char)a),
6 static const unsigned char errid[] = {
7 #include "__strerror.h"
8 };
10 #undef E
11 #define E(a,b) b "\0"
12 static const char errmsg[] =
13 #include "__strerror.h"
16 char *__strerror_l(int e, locale_t loc)
18 const char *s;
19 int i;
20 /* mips has one error code outside of the 8-bit range due to a
21 * historical typo, so we just remap it. */
22 if (EDQUOT==1133) {
23 if (e==109) e=-1;
24 else if (e==EDQUOT) e=109;
26 for (i=0; errid[i] && errid[i] != e; i++);
27 for (s=errmsg; i; s++, i--) for (; *s; s++);
28 return (char *)LCTRANS(s, LC_MESSAGES, loc);
31 char *strerror(int e)
33 return __strerror_l(e, CURRENT_LOCALE);
36 weak_alias(__strerror_l, strerror_l);