home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / inetutils-1.2-src.tgz / tar.out / fsf / inetutils / libinetutils / hstrerror.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  1KB  |  47 lines

  1. /* A replacement version of hstrerror
  2.  
  3.    Copyright (C) 1996 Free Software Foundation, Inc.
  4.  
  5.    This program is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU General Public License as
  7.    published by the Free Software Foundation; either version 2, or (at
  8.    your option) any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #ifdef HAVE_CONFIG_H
  20. #include <config.h>
  21. #endif
  22.  
  23. #include <stdio.h>
  24. #include <netdb.h>
  25.  
  26. #if defined (HAVE_H_ERRLIST) && !defined (HAVE_H_ERRLIST_DECL)
  27. extern int h_nerrs;
  28. extern char *h_errlist[];
  29. #endif
  30.  
  31. /* Return a string describing the host lookup error code HERR.  The returned
  32.    value may be in a static buffer (and in any case shouldn't be written to).  */
  33. char *
  34. hstrerror (int herr)
  35. {
  36. #ifdef HAVE_H_ERRLIST
  37.   if (herr >= 0 && herr < h_nerrs && h_errlist[herr])
  38.     return h_errlist[herr];
  39.   else
  40. #endif
  41.     {
  42.       static char buf[100];
  43.       sprintf (buf, "Host lookup error %d", herr);
  44.       return buf;
  45.     }
  46. }
  47.