summaryrefslogtreecommitdiffstats
path: root/plugins/gethostbyname.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/gethostbyname.h')
-rw-r--r--plugins/gethostbyname.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/plugins/gethostbyname.h b/plugins/gethostbyname.h
new file mode 100644
index 0000000..2b96399
--- /dev/null
+++ b/plugins/gethostbyname.h
@@ -0,0 +1,103 @@
1/*
2 * This file is a ghastly hack because nobody can agree on
3 * gethostbyname_r()'s prototype.
4 *
5 * Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22/*************************************************************************
23 Usage:
24
25 #include <errno.h>
26 #include "gethostbyname.h"
27
28 f ()
29 {
30 struct ghbnctx ctx;
31
32 errno = 0;
33 hp = gethostbyname_ctx (host, &ctx);
34 if (hp == NULL)
35 {
36 if (errno != 0)
37 handle_value_of_errno (errno);
38 else
39 handle_value_of_h_errno (h_error_ctx (&ctx));
40 }
41 else
42 {
43 ...
44 }
45 free_ghbnctx (&ctx);
46 }
47 *************************************************************************/
48
49#ifndef _gethostbyname_h
50#define _gethostbyname_h
51
52#if HAVE_GETIPNODEBYNAME
53
54struct ghbnctx
55 {
56 int h_err;
57 struct hostent *hostent;
58 };
59
60#elif HAVE_GETHOSTBYNAME_R == 6
61
62struct ghbnctx
63 {
64 int h_err;
65 struct hostent hostent;
66 char *hostbuf;
67 size_t hostbuf_len;
68 };
69
70#elif HAVE_GETHOSTBYNAME_R == 5
71
72struct ghbnctx
73 {
74 int h_err;
75 struct hostent hostent;
76 char *hostbuf;
77 int hostbuf_len;
78 };
79
80#elif HAVE_GETHOSTBYNAME_R == 3
81
82struct ghbnctx
83 {
84 int h_err;
85 struct hostent_data hostent_data;
86 struct hostent hostent;
87 };
88
89#else
90
91struct ghbnctx
92 {
93 int h_err;
94 };
95
96#endif
97
98struct hostent *gethostbyname_ctx (const char *host, struct ghbnctx *ctx);
99int h_error_ctx (struct ghbnctx *ctx);
100void free_ghbnctx (struct ghbnctx *ctx);
101
102#endif
103