Back to index

lightning-sunbird  0.9+nobinonly
strerror.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1988, 1993
00003  *     The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. ***REMOVED*** - see 
00014  *    ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
00015  * 4. Neither the name of the University nor the names of its contributors
00016  *    may be used to endorse or promote products derived from this software
00017  *    without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00020  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00023  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00024  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00025  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00026  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00027  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00028  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00029  * SUCH DAMAGE.
00030  */
00031 
00032 #if defined(LIBC_SCCS) && !defined(lint)
00033 static char sccsid[] = "@(#)strerror.c    8.1 (Berkeley) 6/4/93";
00034 #endif /* LIBC_SCCS and not lint */
00035 
00036 #include "watcomfx.h"
00037 
00038 #include <string.h>
00039 
00040 #ifdef _DLL
00041 #define sys_nerr    (*_sys_nerr_dll)
00042 #endif
00043 
00044 #ifndef HAVE_STRERROR
00045 #ifndef _AFXDLL
00046 char *
00047 strerror(num)
00048        int num;
00049 {
00050        extern int sys_nerr;
00051        extern char *sys_errlist[];
00052 #define       UPREFIX       "Unknown error: "
00053        static char ebuf[40] = UPREFIX;           /* 64-bit number + slop */
00054        register unsigned int errnum;
00055        register char *p, *t;
00056        char tmp[40];
00057 
00058        errnum = num;                      /* convert to unsigned */
00059        if (errnum < sys_nerr)
00060               return(sys_errlist[errnum]);
00061 
00062        /* Do this by hand, so we don't include stdio(3). */
00063        t = tmp;
00064        do {
00065               *t++ = "0123456789"[errnum % 10];
00066        } while (errnum /= 10);
00067        for (p = ebuf + sizeof(UPREFIX) - 1;;) {
00068               *p++ = *--t;
00069               if (t <= tmp)
00070                      break;
00071        }
00072        return(ebuf);
00073 }
00074 
00075 #endif
00076 #endif /* !HAVE_STRERROR */