Merge branch 'vendor/BINUTILS221'
[dragonfly.git] / contrib / opie / libmissing / strerror.c
1 /* strerror.c: A replacement for the strerror function
2
3 %%% copyright-cmetz
4 This software is Copyright 1996 by Craig Metz, All Rights Reserved.
5 The Inner Net License Version 2 applies to this software.
6 You should have received a copy of the license with this software. If
7 you didn't get a copy, you may request one from <license@inner.net>.
8
9         History:
10
11         Created by cmetz for OPIE 2.2.
12 */
13
14 #include "opie_cfg.h"
15 #include "opie.h"
16
17 char *strerror FUNCTION((errnum), int errnum)
18 {
19 #if HAVE_SYS_ERRLIST
20   extern char *sys_errlist[];
21   return sys_errlist[errnum];
22 #else /* NEED_STRERROR */
23 #if HAVE__SYS_ERRLIST
24   extern char *_sys_errlist[];
25   return sys_errlist[errnum];
26 #else /* HAVE__SYS_ERRLIST */
27   static char hexdigits[] = "0123456789abcdef";
28   static char buffer[] = "System error 0x42";
29   buffer[15] = hexdigits[(errnum >> 4) & 0x0f];
30   buffer[16] = hexdigits[errnum & 0x0f];
31   return buffer;
32 #endif /* HAVE__SYS_ERRLIST */
33 #endif  /* NEED_STRERROR */
34 }