summaryrefslogtreecommitdiff
path: root/sdk/recipes/patches/libcurl/ppc-amigaos/lib.hostip4.c.p
blob: 8d3ffa171aaf3d802375b9c470df68694fddfc42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--- lib/hostip4.c	2022-01-04 10:57:27.790270827 +0000
+++ lib/hostip4.c	2022-01-04 11:01:43.125967497 +0000
@@ -120,6 +120,10 @@ struct Curl_addrinfo *Curl_getaddrinfo(s
  * implying that only threadsafe code and function calls may be used.
  *
  */
+#ifdef __amigaos4__
+#include <proto/exec.h>
+#include <proto/bsdsocket.h>
+#endif
 struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
                                           int port)
 {
@@ -129,6 +133,9 @@ struct Curl_addrinfo *Curl_ipv4_resolve_
   struct Curl_addrinfo *ai = NULL;
   struct hostent *h = NULL;
   struct hostent *buf = NULL;
+#ifdef __amigaos4__
+  struct SocketIFace *ISocket = NULL;
+#endif
 
 #if defined(HAVE_GETADDRINFO_THREADSAFE)
   struct addrinfo hints;
@@ -284,7 +291,20 @@ struct Curl_addrinfo *Curl_ipv4_resolve_
    * getaddrinfo() nor gethostbyname_r() function or for which
    * gethostbyname() is the preferred one.
    */
+#ifdef __amigaos4__
+    struct Library *SocketBase = IExec->OpenLibrary("bsdsocket.library", 4);
+    if (SocketBase)
+    {
+       ISocket = (struct SocketIFace *)IExec->GetInterface(SocketBase, "main", 1, NULL);
+    }
+
+    if (ISocket)
+    {
+       h = ISocket->gethostbyname((void*)hostname);
+    }
+#else
   h = gethostbyname((void *)hostname);
+#endif
 #endif /* HAVE_GETADDRINFO_THREADSAFE || HAVE_GETHOSTBYNAME_R */
 
   if(h) {
@@ -294,6 +314,14 @@ struct Curl_addrinfo *Curl_ipv4_resolve_
       free(buf);
   }
 
+#ifdef __amigaos4__
+  if (ISocket)
+  {
+     struct Library *SocketBase = ISocket->Data.LibBase;
+     IExec->DropInterface((struct Interface *)ISocket);
+     IExec->CloseLibrary(SocketBase);
+  }
+#endif
   return ai;
 }
 #endif /* defined(CURLRES_IPV4) && !defined(CURLRES_ARES) */