andre@3: /* andre@3: * Copyright (c) 1988, 1993 andre@3: * The Regents of the University of California. All rights reserved. andre@3: * andre@3: * Redistribution and use in source and binary forms, with or without andre@3: * modification, are permitted provided that the following conditions andre@3: * are met: andre@3: * 1. Redistributions of source code must retain the above copyright andre@3: * notice, this list of conditions and the following disclaimer. andre@3: * 2. Redistributions in binary form must reproduce the above copyright andre@3: * notice, this list of conditions and the following disclaimer in the andre@3: * documentation and/or other materials provided with the distribution. andre@3: * 3. ***REMOVED*** - see andre@3: * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change andre@3: * 4. Neither the name of the University nor the names of its contributors andre@3: * may be used to endorse or promote products derived from this software andre@3: * without specific prior written permission. andre@3: * andre@3: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND andre@3: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE andre@3: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE andre@3: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE andre@3: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL andre@3: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS andre@3: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) andre@3: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT andre@3: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY andre@3: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF andre@3: * SUCH DAMAGE. andre@3: */ andre@3: andre@3: #if defined(LIBC_SCCS) && !defined(lint) andre@3: static char sccsid[] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93"; andre@3: #endif /* LIBC_SCCS and not lint */ andre@3: andre@3: #include andre@3: andre@3: #ifdef _DLL andre@3: #define sys_nerr (*_sys_nerr_dll) andre@3: #endif andre@3: andre@3: #ifndef HAVE_STRERROR andre@3: #ifndef _AFXDLL andre@3: char * andre@3: strerror(num) andre@3: int num; andre@3: { andre@3: extern int sys_nerr; andre@3: extern char *sys_errlist[]; andre@3: #define UPREFIX "Unknown error: " andre@3: static char ebuf[40] = UPREFIX; /* 64-bit number + slop */ andre@3: register unsigned int errnum; andre@3: register char *p, *t; andre@3: char tmp[40]; andre@3: andre@3: errnum = num; /* convert to unsigned */ andre@3: if (errnum < sys_nerr) andre@3: return(sys_errlist[errnum]); andre@3: andre@3: /* Do this by hand, so we don't include stdio(3). */ andre@3: t = tmp; andre@3: do { andre@3: *t++ = "0123456789"[errnum % 10]; andre@3: } while (errnum /= 10); andre@3: for (p = ebuf + sizeof(UPREFIX) - 1;;) { andre@3: *p++ = *--t; andre@3: if (t <= tmp) andre@3: break; andre@3: } andre@3: return(ebuf); andre@3: } andre@3: andre@3: #endif andre@3: #endif /* !HAVE_STRERROR */