AROS: add inet_pton emulation and make sure we use recv/send and not read/write
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Sat, 13 Apr 2013 14:40:46 +0000 (07:40 -0700)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Sat, 13 Apr 2013 14:40:46 +0000 (07:40 -0700)
aros/aros_compat.c
lib/socket.c

index 92da9a370c35d83172a316508ae96c27fbc1ad71..9a6cd3b385c3922c8451f4d3bf5e37b88fc38980 100644 (file)
@@ -78,8 +78,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;
 }
 
 
index 1dbbdeae5eb5c21758f5e1c7789765f706706d71..9b16b1b5bc96d045c136945d1dbdd6f69f3a433b 100644 (file)
@@ -118,7 +118,7 @@ static int rpc_write_to_socket(struct rpc_context *rpc)
 
                total = rpc->outqueue->outdata.size;
 
-#if defined(WIN32)
+#if defined(WIN32) | defined(AROS)
                count = send(rpc->fd, rpc->outqueue->outdata.data + rpc->outqueue->written, total - rpc->outqueue->written, 0);
 #else
                count = write(rpc->fd, rpc->outqueue->outdata.data + rpc->outqueue->written, total - rpc->outqueue->written);
@@ -202,7 +202,7 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
        if (rpc->inpos < 4) {
                size = 4 - rpc->inpos;
 
-#if defined(WIN32)
+#if defined(WIN32) | defined(AROS)
                count = recv(rpc->fd, rpc->inbuf + rpc->inpos, size, 0);
 #else
                count = read(rpc->fd, rpc->inbuf + rpc->inpos, size);
@@ -242,7 +242,7 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
                size = rpc->insize - rpc->inpos;
        }
 
-#if defined(WIN32)
+#if defined(WIN32) | defined(AROS)
        count = recv(rpc->fd, rpc->inbuf + rpc->inpos, size, 0);
 #else
        count = read(rpc->fd, rpc->inbuf + rpc->inpos, size);