X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=aros%2Faros_compat.c;h=9b745e53a551bfa37d7f296a42d1391cedbcd134;hb=HEAD;hp=202f614779514feb7b172f3031ade07ffcfa9609;hpb=2cdf4fcb07a2d4ec0fbeb66096afd9e8f9cd03a1;p=deb_libnfs.git diff --git a/aros/aros_compat.c b/aros/aros_compat.c index 202f614..9b745e5 100644 --- a/aros/aros_compat.c +++ b/aros/aros_compat.c @@ -15,18 +15,76 @@ along with this program; if not, see . */ -#ifdef AROS - #include #include -#include +#include #include #include +#include +#include #include "aros_compat.h" +#include +#include #undef poll -/* unix device major/minor numbers dont make much sense on amiga */ +int aros_getnameinfo(const struct sockaddr *sa, socklen_t salen, +char *host, size_t hostlen, +char *serv, size_t servlen, int flags) +{ + struct sockaddr_in *sin = (struct sockaddr_in *)sa; + + if (host) { + snprintf(host, hostlen, Inet_NtoA(sin->sin_addr.s_addr)); + } + + return 0; +} + +int aros_getaddrinfo(const char *node, const char*service, +const struct addrinfo *hints, +struct addrinfo **res) +{ + struct sockaddr_in *sin; + + sin = malloc(sizeof(struct sockaddr_in)); + sin->sin_len = sizeof(struct sockaddr_in); + sin->sin_family=AF_INET; + + /* Some error checking would be nice */ + sin->sin_addr.s_addr = inet_addr(node); + + sin->sin_port=0; + if (service) { + sin->sin_port=htons(atoi(service)); + } + + *res = malloc(sizeof(struct addrinfo)); + + (*res)->ai_family = AF_INET; + (*res)->ai_addrlen = sizeof(struct sockaddr_in); + (*res)->ai_addr = (struct sockaddr *)sin; + + return 0; +} + +void aros_freeaddrinfo(struct addrinfo *res) +{ + free(res->ai_addr); + free(res); +} + +int aros_inet_pton(int af, char *src, void *dst) +{ + struct sockaddr_in sin; + + sin.sin_addr.s_addr = inet_addr(src); + memcpy(dst, &sin.sin_addr.s_addr, sizeof(sin.sin_addr.s_addr)); + return 1; +} + + +/* unix device numbers dont really make much sense on aros ... */ int major(int i) { return 1; @@ -38,10 +96,21 @@ int minor(int i) struct Library * SocketBase = NULL; +extern int errno; +int h_errno = 0; + + void aros_init_socket(void) { if (!(SocketBase = OpenLibrary("bsdsocket.library", 4))) { - printf("No TCP/IP stack available.\n"); + printf("NoTCP/IP Stack available"); + exit(10); + } + if (SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), + (IPTR)&errno, + SBTM_SETVAL(SBTC_HERRNOLONGPTR), + (IPTR)&h_errno, TAG_DONE)) { + printf("Failed to set ERRNO"); exit(10); } } @@ -50,7 +119,7 @@ int aros_poll(struct pollfd *fds, unsigned int nfds, int timo) { struct timeval timeout, *toptr; fd_set ifds, ofds, efds, *ip, *op; - unsigned int i; + unsigned int i, maxfd = 0; int rc; // Set up the file-descriptor sets in ifds, ofds and efds. @@ -71,6 +140,9 @@ int aros_poll(struct pollfd *fds, unsigned int nfds, int timo) FD_SET(fds[i].fd, op); } FD_SET(fds[i].fd, &efds); + if (fds[i].fd > maxfd) { + maxfd = fds[i].fd; + } } // Set up the timeval structure for the timeout parameter @@ -85,7 +157,7 @@ int aros_poll(struct pollfd *fds, unsigned int nfds, int timo) timeout.tv_usec = (timo - timeout.tv_sec * 1000) * 1000; } - rc = WaitSelect(0, ip, op, &efds, toptr, NULL); + rc = WaitSelect(maxfd + 1, ip, op, &efds, toptr, NULL); if(rc <= 0) return rc; @@ -106,4 +178,3 @@ int aros_poll(struct pollfd *fds, unsigned int nfds, int timo) return rc; } -#endif