home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / sviluppo / sed-3.02 / lib / strerror.c < prev   
Encoding:
C/C++ Source or Header  |  1998-05-09  |  1.5 KB  |  51 lines

  1. /* strerror -- return a string corresponding to an error number.
  2.    This is a quickie version only intended as compatability glue
  3.    for systems which predate the ANSI C definition of the function;
  4.    the glibc version is recommended for more general use.
  5.  
  6.    Copyright (C) 1998 Free Software Foundation, Inc.
  7.  
  8.    This program is free software; you can redistribute it and/or modify it
  9.    under the terms of the GNU General Public License as published by the
  10.    Free Software Foundation; either version 2, or (at your option) any
  11.    later version.
  12.  
  13.    This program is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    GNU General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with this program; if not, write to the Free Software
  20.    Foundation, 59 Temple Place - Suite 330,
  21.    Boston, MA 02111-1307, USA.  */
  22.  
  23. #include "config.h"
  24.  
  25. #ifndef HAVE_STRERROR
  26.  
  27. # include <stdio.h>
  28. # ifdef HAVE_STRING_H
  29. #  include <string.h>
  30. # endif
  31. # include <errno.h>
  32. # undef strerror
  33.  
  34. extern int sys_nerr;
  35. extern char *sys_errlist[];
  36.  
  37. char *
  38. strerror(e)
  39.   int e;
  40. {
  41.   static char unknown_string[] =
  42.     "Unknown error code #xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  43.  
  44.   if (0<=e && e<sys_nerr)
  45.     return sys_errlist[e];
  46.   sprintf(unknown_string+20, "%d", e);
  47.   return unknown_string;
  48. }
  49.  
  50. #endif /* !HAVE_STRERROR */
  51.