Magellan Linux

Contents of /trunk/mkinitrd-magellan/klibc/usr/klibc/strerror.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (show annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 566 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 /*
2 * strerror.c
3 */
4
5 #include <string.h>
6
7 char *strerror(int errnum)
8 {
9 static char message[32] = "error "; /* enough for error 2^63-1 */
10 char numbuf[32];
11 char *p;
12 unsigned int e = (unsigned int)errnum;
13
14 #ifdef WITH_ERRLIST
15 extern const int sys_nerr;
16 extern const char *const sys_errlist[];
17
18 if (e < (unsigned int)sys_nerr && sys_errlist[e])
19 return (char *)sys_errlist[e];
20 #endif
21
22 p = numbuf + sizeof numbuf;
23 *--p = '\0';
24
25 do {
26 *--p = (e % 10) + '0';
27 e /= 10;
28 } while (e);
29
30 memcpy(message + 6, p, (numbuf + sizeof numbuf) - p);
31
32 return message;
33 }