|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "curl_setup.h" |
|
|
|
|
|
#ifdef __AMIGA__ |
|
|
|
|
|
#include <curl/curl.h> |
|
|
|
|
|
#include "hostip.h" |
|
|
#include "amigaos.h" |
|
|
|
|
|
#ifdef HAVE_PROTO_BSDSOCKET_H |
|
|
# if defined(__amigaos4__) |
|
|
# include <bsdsocket/socketbasetags.h> |
|
|
# elif !defined(USE_AMISSL) |
|
|
# include <amitcp/socketbasetags.h> |
|
|
# endif |
|
|
# ifdef __libnix__ |
|
|
# include <stabs.h> |
|
|
# endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#include "curl_memory.h" |
|
|
#include "memdebug.h" |
|
|
|
|
|
#ifdef HAVE_PROTO_BSDSOCKET_H |
|
|
|
|
|
#ifdef __amigaos4__ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <proto/bsdsocket.h> |
|
|
|
|
|
static struct SocketIFace *__CurlISocket = NULL; |
|
|
static uint32 SocketFeatures = 0; |
|
|
|
|
|
#define HAVE_BSDSOCKET_GETHOSTBYNAME_R 0x01 |
|
|
#define HAVE_BSDSOCKET_GETADDRINFO 0x02 |
|
|
|
|
|
CURLcode Curl_amiga_init(void) |
|
|
{ |
|
|
struct SocketIFace *ISocket; |
|
|
struct Library *base = OpenLibrary("bsdsocket.library", 4); |
|
|
|
|
|
if(base) { |
|
|
ISocket = (struct SocketIFace *)GetInterface(base, "main", 1, NULL); |
|
|
if(ISocket) { |
|
|
ULONG enabled = 0; |
|
|
|
|
|
SocketBaseTags(SBTM_SETVAL(SBTC_CAN_SHARE_LIBRARY_BASES), TRUE, |
|
|
SBTM_GETREF(SBTC_HAVE_GETHOSTADDR_R_API), (ULONG)&enabled, |
|
|
TAG_DONE); |
|
|
|
|
|
if(enabled) { |
|
|
SocketFeatures |= HAVE_BSDSOCKET_GETHOSTBYNAME_R; |
|
|
} |
|
|
|
|
|
__CurlISocket = ISocket; |
|
|
|
|
|
atexit(Curl_amiga_cleanup); |
|
|
|
|
|
return CURLE_OK; |
|
|
} |
|
|
CloseLibrary(base); |
|
|
} |
|
|
|
|
|
return CURLE_FAILED_INIT; |
|
|
} |
|
|
|
|
|
void Curl_amiga_cleanup(void) |
|
|
{ |
|
|
if(__CurlISocket) { |
|
|
struct Library *base = __CurlISocket->Data.LibBase; |
|
|
DropInterface((struct Interface *)__CurlISocket); |
|
|
CloseLibrary(base); |
|
|
__CurlISocket = NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
#ifdef CURLRES_AMIGA |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, |
|
|
int port) |
|
|
{ |
|
|
struct Curl_addrinfo *ai = NULL; |
|
|
struct hostent *h; |
|
|
struct SocketIFace *ISocket = __CurlISocket; |
|
|
|
|
|
if(SocketFeatures & HAVE_BSDSOCKET_GETHOSTBYNAME_R) { |
|
|
LONG h_errnop = 0; |
|
|
struct hostent *buf; |
|
|
|
|
|
buf = calloc(1, CURL_HOSTENT_SIZE); |
|
|
if(buf) { |
|
|
h = gethostbyname_r((STRPTR)hostname, buf, |
|
|
(char *)buf + sizeof(struct hostent), |
|
|
CURL_HOSTENT_SIZE - sizeof(struct hostent), |
|
|
&h_errnop); |
|
|
if(h) { |
|
|
ai = Curl_he2ai(h, port); |
|
|
} |
|
|
free(buf); |
|
|
} |
|
|
} |
|
|
else { |
|
|
#ifdef CURLRES_THREADED |
|
|
|
|
|
|
|
|
|
|
|
struct Library *base = OpenLibrary("bsdsocket.library", 4); |
|
|
if(base) { |
|
|
ISocket = (struct SocketIFace *)GetInterface(base, "main", 1, NULL); |
|
|
if(ISocket) { |
|
|
h = gethostbyname((STRPTR)hostname); |
|
|
if(h) { |
|
|
ai = Curl_he2ai(h, port); |
|
|
} |
|
|
DropInterface((struct Interface *)ISocket); |
|
|
} |
|
|
CloseLibrary(base); |
|
|
} |
|
|
#else |
|
|
|
|
|
h = gethostbyname(hostname); |
|
|
if(h) { |
|
|
ai = Curl_he2ai(h, port); |
|
|
} |
|
|
#endif |
|
|
} |
|
|
|
|
|
return ai; |
|
|
} |
|
|
#endif |
|
|
|
|
|
#ifdef USE_AMISSL |
|
|
#include <signal.h> |
|
|
int Curl_amiga_select(int nfds, fd_set *readfds, fd_set *writefds, |
|
|
fd_set *errorfds, struct timeval *timeout) |
|
|
{ |
|
|
int r = WaitSelect(nfds, readfds, writefds, errorfds, timeout, 0); |
|
|
|
|
|
if((r == -1) && (SOCKERRNO == EINTR)) |
|
|
raise(SIGINT); |
|
|
return r; |
|
|
} |
|
|
#endif |
|
|
|
|
|
#elif !defined(USE_AMISSL) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Library *SocketBase = NULL; |
|
|
extern int errno, h_errno; |
|
|
|
|
|
#ifdef __libnix__ |
|
|
void __request(const char *msg); |
|
|
#else |
|
|
# define __request(msg) Printf(msg "\n\a") |
|
|
#endif |
|
|
|
|
|
void Curl_amiga_cleanup(void) |
|
|
{ |
|
|
if(SocketBase) { |
|
|
CloseLibrary(SocketBase); |
|
|
SocketBase = NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
CURLcode Curl_amiga_init(void) |
|
|
{ |
|
|
if(!SocketBase) |
|
|
SocketBase = OpenLibrary("bsdsocket.library", 4); |
|
|
|
|
|
if(!SocketBase) { |
|
|
__request("No TCP/IP Stack running!"); |
|
|
return CURLE_FAILED_INIT; |
|
|
} |
|
|
|
|
|
if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG) &errno, |
|
|
SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG) "curl", |
|
|
TAG_DONE)) { |
|
|
__request("SocketBaseTags ERROR"); |
|
|
return CURLE_FAILED_INIT; |
|
|
} |
|
|
|
|
|
#ifndef __libnix__ |
|
|
atexit(Curl_amiga_cleanup); |
|
|
#endif |
|
|
|
|
|
return CURLE_OK; |
|
|
} |
|
|
|
|
|
#ifdef __libnix__ |
|
|
ADD2EXIT(Curl_amiga_cleanup, -50); |
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|
|
|
#endif |
|
|
|