Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/comms/aprsd/files/patch-src_osdep.h
16461 views
1
--- src/osdep.h.orig 2003-04-20 18:34:47 UTC
2
+++ src/osdep.h
3
@@ -32,6 +32,14 @@
4
extern "C"
5
{
6
#include <netdb.h>
7
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
8
+#include <sys/param.h>
9
+#endif
10
+#ifdef BSD
11
+#include <sys/types.h>
12
+#include <sys/socket.h>
13
+#include <netdb.h>
14
+#endif
15
16
#if TIME_WITH_SYS_TIME
17
# include <sys/time.h>
18
@@ -63,10 +71,27 @@ namespace aprsd
19
char *buf, size_t buflen, struct hostent **result,
20
int *h_errnop)
21
{
22
-#ifdef __GLIBC__
23
+#ifdef BSD
24
+#if (__FreeBSD_version >= 600000)
25
return ::gethostbyname_r (name.c_str (), result_buf,
26
buf, buflen, result, h_errnop);
27
#else
28
+ struct hostent *h;
29
+ h = gethostbyname (name.c_str());
30
+ if (h != NULL) {
31
+ memcpy(result_buf,h,sizeof(*h));
32
+ *result = h;
33
+ *h_errnop = 0;
34
+ return 0;
35
+ } else {
36
+ *h_errnop = 0;
37
+ return 1;
38
+ }
39
+#endif
40
+#endif
41
+#ifdef __GLIBC__
42
+ return ::gethostbyname_r (name.c_str (), result_buf,
43
+ buf, buflen, result, h_errnop);
44
if (buflen < sizeof (hostent_data))
45
{
46
if (h_errnop != NULL)
47
48