herror.c revision 7ecaf695072a0a63905c6999a69079219bf45418
e44e0ff3850931e7a79e4c86363f52990536f7bfDavid Lawrence/*
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater * Portions Copyright (C) 2000, 2001 Internet Software Consortium.
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington *
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
e44e0ff3850931e7a79e4c86363f52990536f7bfDavid Lawrence * copyright notice and this permission notice appear in all copies.
e44e0ff3850931e7a79e4c86363f52990536f7bfDavid Lawrence *
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
e44e0ff3850931e7a79e4c86363f52990536f7bfDavid Lawrence */
e44e0ff3850931e7a79e4c86363f52990536f7bfDavid Lawrence
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews/*
821644d49b73b49f2abc5463bc53a3132f612478Mark Andrews * Copyright (c) 1987, 1993
821644d49b73b49f2abc5463bc53a3132f612478Mark Andrews * The Regents of the University of California. All rights reserved.
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence *
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * Redistribution and use in source and binary forms, with or without
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * modification, are permitted provided that the following conditions
f333ea9bdd3f85b74ae790e6c8ce2684295b3483Andreas Gustafsson * are met:
4f37905cc38162128a507e619e38ae535720686bAndreas Gustafsson * 1. Redistributions of source code must retain the above copyright
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * notice, this list of conditions and the following disclaimer.
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * 2. Redistributions in binary form must reproduce the above copyright
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * notice, this list of conditions and the following disclaimer in the
5a77e9620a0b2f7417469c98be374de49d0eccc6Andreas Gustafsson * documentation and/or other materials provided with the distribution.
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * 3. All advertising materials mentioning features or use of this software
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * must display the following acknowledgement:
50105afc551903541608b11851d73278b23579a3Mark Andrews * This product includes software developed by the University of
cfe92110ce4eaf19f7f3255d2961710879bdc9ddMark Andrews * California, Berkeley and its contributors.
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * 4. Neither the name of the University nor the names of its contributors
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * may be used to endorse or promote products derived from this software
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * without specific prior written permission.
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington *
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews * SUCH DAMAGE.
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews */
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington#if defined(LIBC_SCCS) && !defined(lint)
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellingtonstatic const char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93";
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellingtonstatic const char rcsid[] =
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington "$Id: herror.c,v 1.10 2001/07/18 20:14:52 gson Exp $";
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington#endif /* LIBC_SCCS and not lint */
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington#include <config.h>
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington#include <stdio.h>
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington#include <lwres/netdb.h>
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington#include <lwres/platform.h>
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian Wellington
cc1eee4f5188a8174f10ab86da273fee50aa481aBrian WellingtonLIBLWRES_EXTERNAL_DATA int lwres_h_errno;
243ac4ecc1f45db7106c9166cd4187843507644cBrian Wellington
243ac4ecc1f45db7106c9166cd4187843507644cBrian Wellington/*
243ac4ecc1f45db7106c9166cd4187843507644cBrian Wellington * these have never been declared in any header file so make them static
243ac4ecc1f45db7106c9166cd4187843507644cBrian Wellington */
243ac4ecc1f45db7106c9166cd4187843507644cBrian Wellington
static const char *h_errlist[] = {
"Resolver Error 0 (no error)",
"Unknown host", /* 1 HOST_NOT_FOUND */
"Host name lookup failure", /* 2 TRY_AGAIN */
"Unknown server error", /* 3 NO_RECOVERY */
"No address associated with name", /* 4 NO_ADDRESS */
};
static int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] };
/*
* herror --
* print the error indicated by the h_errno value.
*/
void
lwres_herror(const char *s) {
fprintf(stderr, "%s: %s\n", s, lwres_hstrerror(lwres_h_errno));
}
/*
* hstrerror --
* return the string associated with a given "host" errno value.
*/
const char *
lwres_hstrerror(int err) {
if (err < 0)
return ("Resolver internal error");
else if (err < h_nerr)
return (h_errlist[err]);
return ("Unknown resolver error");
}