Back to index

nagios-plugins  1.4.16
gai_strerror.c
Go to the documentation of this file.
00001 /* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008, 2009, 2010 Free
00002    Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3, or (at your option)
00009    any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software Foundation,
00018    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00019 
00020 #ifndef _LIBC
00021 # include <config.h>
00022 #endif
00023 
00024 #include <stdio.h>
00025 #include <netdb.h>
00026 
00027 #ifdef _LIBC
00028 # include <libintl.h>
00029 #else
00030 # include "gettext.h"
00031 # define _(String) gettext (String)
00032 # define N_(String) String
00033 #endif
00034 
00035 static struct
00036   {
00037     int code;
00038     const char *msg;
00039   }
00040 values[] =
00041   {
00042     { EAI_ADDRFAMILY, N_("Address family for hostname not supported") },
00043     { EAI_AGAIN, N_("Temporary failure in name resolution") },
00044     { EAI_BADFLAGS, N_("Bad value for ai_flags") },
00045     { EAI_FAIL, N_("Non-recoverable failure in name resolution") },
00046     { EAI_FAMILY, N_("ai_family not supported") },
00047     { EAI_MEMORY, N_("Memory allocation failure") },
00048     { EAI_NODATA, N_("No address associated with hostname") },
00049     { EAI_NONAME, N_("Name or service not known") },
00050     { EAI_SERVICE, N_("Servname not supported for ai_socktype") },
00051     { EAI_SOCKTYPE, N_("ai_socktype not supported") },
00052     { EAI_SYSTEM, N_("System error") },
00053     { EAI_OVERFLOW, N_("Argument buffer too small") },
00054 #ifdef EAI_INPROGRESS
00055     { EAI_INPROGRESS, N_("Processing request in progress") },
00056     { EAI_CANCELED, N_("Request canceled") },
00057     { EAI_NOTCANCELED, N_("Request not canceled") },
00058     { EAI_ALLDONE, N_("All requests done") },
00059     { EAI_INTR, N_("Interrupted by a signal") },
00060     { EAI_IDN_ENCODE, N_("Parameter string not correctly encoded") }
00061 #endif
00062   };
00063 
00064 const char *
00065 gai_strerror (int code)
00066 {
00067   size_t i;
00068   for (i = 0; i < sizeof (values) / sizeof (values[0]); ++i)
00069     if (values[i].code == code)
00070       return _(values[i].msg);
00071 
00072   return _("Unknown error");
00073 }
00074 #ifdef _LIBC
00075 libc_hidden_def (gai_strerror)
00076 #endif