X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=aros%2Faros_compat.c;h=9b745e53a551bfa37d7f296a42d1391cedbcd134;hb=HEAD;hp=955f8e382d5a5ce176ce1859ea1450c45a0d1e41;hpb=5c9c5f15f17e02722298de56f40feffffdddf191;p=deb_libnfs.git diff --git a/aros/aros_compat.c b/aros/aros_compat.c index 955f8e3..9b745e5 100644 --- a/aros/aros_compat.c +++ b/aros/aros_compat.c @@ -1,5 +1,19 @@ +/* + Copyright (C) 2013 by Ronnie Sahlberg -#ifdef AROS + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, see . +*/ #include #include @@ -9,6 +23,8 @@ #include #include #include "aros_compat.h" +#include +#include #undef poll @@ -60,8 +76,11 @@ void aros_freeaddrinfo(struct addrinfo *res) int aros_inet_pton(int af, char *src, void *dst) { - printf("No inet_pton yet"); - exit(10); + 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; } @@ -77,19 +96,30 @@ 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("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); + } } 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. @@ -110,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 @@ -124,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; @@ -145,5 +178,3 @@ int aros_poll(struct pollfd *fds, unsigned int nfds, int timo) return rc; } -#endif -