Deleted Added
full compact
herror.c (156953) herror.c (156956)
1/*
2 * Copyright (c) 1987, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 38 unchanged lines hidden (view full) ---

47 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
48 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49 */
50
51#if defined(LIBC_SCCS) && !defined(lint)
52static const char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93";
53static const char rcsid[] = "$Id: herror.c,v 1.2.206.1 2004/03/09 08:33:54 marka Exp $";
54#endif /* LIBC_SCCS and not lint */
1/*
2 * Copyright (c) 1987, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 38 unchanged lines hidden (view full) ---

47 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
48 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49 */
50
51#if defined(LIBC_SCCS) && !defined(lint)
52static const char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93";
53static const char rcsid[] = "$Id: herror.c,v 1.2.206.1 2004/03/09 08:33:54 marka Exp $";
54#endif /* LIBC_SCCS and not lint */
55#include <sys/cdefs.h>
56__FBSDID("$FreeBSD: head/lib/libc/resolv/herror.c 156956 2006-03-21 15:37:16Z ume $");
55
56#include "port_before.h"
57
57
58#include "port_before.h"
59
60#include "namespace.h"
58#include <sys/types.h>
59#include <sys/param.h>
60#include <sys/uio.h>
61
62#include <netinet/in.h>
63#include <arpa/nameser.h>
64
65#include <netdb.h>
66#include <resolv.h>
67#include <string.h>
68#include <unistd.h>
61#include <sys/types.h>
62#include <sys/param.h>
63#include <sys/uio.h>
64
65#include <netinet/in.h>
66#include <arpa/nameser.h>
67
68#include <netdb.h>
69#include <resolv.h>
70#include <string.h>
71#include <unistd.h>
69#include <irs.h>
72#include "un-namespace.h"
70
71#include "port_after.h"
72
73const char *h_errlist[] = {
74 "Resolver Error 0 (no error)",
75 "Unknown host", /* 1 HOST_NOT_FOUND */
76 "Host name lookup failure", /* 2 TRY_AGAIN */
77 "Unknown server error", /* 3 NO_RECOVERY */
78 "No address associated with name", /* 4 NO_ADDRESS */
79};
73
74#include "port_after.h"
75
76const char *h_errlist[] = {
77 "Resolver Error 0 (no error)",
78 "Unknown host", /* 1 HOST_NOT_FOUND */
79 "Host name lookup failure", /* 2 TRY_AGAIN */
80 "Unknown server error", /* 3 NO_RECOVERY */
81 "No address associated with name", /* 4 NO_ADDRESS */
82};
80int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] };
83const int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] };
81
84
82#if !(__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
83#undef h_errno
84int h_errno;
85#undef h_errno
86int h_errno;
85#endif
86
87/*
88 * herror --
89 * print the error indicated by the h_errno value.
90 */
91void
92herror(const char *s) {
93 struct iovec iov[4], *v = iov;

--- 11 unchanged lines hidden (view full) ---

105 }
106 DE_CONST(hstrerror(*__h_errno()), t);
107 v->iov_base = t;
108 v->iov_len = strlen(v->iov_base);
109 v++;
110 DE_CONST("\n", t);
111 v->iov_base = t;
112 v->iov_len = 1;
87
88/*
89 * herror --
90 * print the error indicated by the h_errno value.
91 */
92void
93herror(const char *s) {
94 struct iovec iov[4], *v = iov;

--- 11 unchanged lines hidden (view full) ---

106 }
107 DE_CONST(hstrerror(*__h_errno()), t);
108 v->iov_base = t;
109 v->iov_len = strlen(v->iov_base);
110 v++;
111 DE_CONST("\n", t);
112 v->iov_base = t;
113 v->iov_len = 1;
113 writev(STDERR_FILENO, iov, (v - iov) + 1);
114 _writev(STDERR_FILENO, iov, (v - iov) + 1);
114}
115
116/*
117 * hstrerror --
118 * return the string associated with a given "host" errno value.
119 */
120const char *
121hstrerror(int err) {
122 if (err < 0)
123 return ("Resolver internal error");
124 else if (err < h_nerr)
125 return (h_errlist[err]);
126 return ("Unknown resolver error");
127}
115}
116
117/*
118 * hstrerror --
119 * return the string associated with a given "host" errno value.
120 */
121const char *
122hstrerror(int err) {
123 if (err < 0)
124 return ("Resolver internal error");
125 else if (err < h_nerr)
126 return (h_errlist[err]);
127 return ("Unknown resolver error");
128}