/[inetutils]/inetutils/libinetutils/strerror.c
ViewVC logotype

Diff of /inetutils/libinetutils/strerror.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by miles, Wed Sep 10 15:52:47 1997 UTC revision 1.3 by jbailey, Wed Dec 11 13:19:52 2002 UTC
# Line 1  Line 1 
1  /* A replacement version of strerror  /* strerror.c --- ANSI C compatible system error routine
2    
3     Copyright (C) 1996 Free Software Foundation, Inc.     Copyright (C) 1986, 1988, 1989, 1991, 2002 Free Software Foundation, Inc.
4    
5     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or modify
6     modify it under the terms of the GNU General Public License as     it under the terms of the GNU General Public License as published by
7     published by the Free Software Foundation; either version 2, or (at     the Free Software Foundation; either version 2, or (at your option)
8     your option) any later version.     any later version.
9    
10     This program is distributed in the hope that it will be useful, but     This program is distributed in the hope that it will be useful,
11     WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     General Public License for more details.     GNU General Public License for more details.
14    
15     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software     along with this program; if not, write to the Free Software Foundation,
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18    
19  #ifdef HAVE_CONFIG_H  #if 0
20  #include <config.h>  # include <stdio.h>
21  #endif  #endif
22    
 #include <stdio.h>  
 #ifdef HAVE_ERRNO_H  
 #include <errno.h>  
 #endif  
   
 #if defined (HAVE_SYS_ERRLIST) && !defined (HAVE_SYS_ERRLIST_DECL)  
23  extern int sys_nerr;  extern int sys_nerr;
24  extern char *sys_errlist[];  extern char *sys_errlist[];
 #endif  
25    
26  /* Return a string describing the system error code ERR.  The returned value  char *
27     may be in a static buffer (and in any case shouldn't be written to).  */  strerror(n)
28  const char *  int n;
 strerror (int err)  
29  {  {
30  #ifdef HAVE_SYS_ERRLIST          static char mesg[30];
31    if (err >= 0 && err < sys_nerr && sys_errlist[err])  
32      return sys_errlist[err];          if (n < 0 || n >= sys_nerr) {
33    else                  sprintf(mesg, "Unknown error (%d)", n);
34  #endif                  return mesg;
35      {          } else
36        static char buf[100];                  return sys_errlist[n];
       sprintf (buf, "Error %d", err);  
       return buf;  
     }  
37  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26