summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2012-06-09 18:13:07 +0100
committerChris Young <chris@unsatisfactorysoftware.co.uk>2012-06-09 18:13:07 +0100
commit327fb51cec5393bd84b560ad7df5b85298f96e3c (patch)
tree722aeac2e1db27a4b5e032988b2000a724751d20
parentb9bfc7684b94bf052203034cbddfdf01e26205e5 (diff)
downloadlibgit2-327fb51cec5393bd84b560ad7df5b85298f96e3c.tar.gz
Fix gethostbyname compatibility
-rw-r--r--include/git2/common.h6
-rw-r--r--src/netops.c12
2 files changed, 11 insertions, 7 deletions
diff --git a/include/git2/common.h b/include/git2/common.h
index 045ba85c4..99018d4f5 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -56,11 +56,7 @@
#endif
#ifdef __amigaos4__
-/* Network byte order is big-endian... so is PPC, so these functions are NOP */
-#define htonl(x) x
-#define ntohl(x) x
-#define htons(x) x
-#define ntohs(x) x
+#include <netinet/in.h>
#endif
/**
diff --git a/src/netops.c b/src/netops.c
index fdbd965b1..6808c8ee7 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -382,7 +382,9 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
#else
int p;
struct hostent *hent;
+ struct servent *sent;
struct sockaddr_in saddr;
+ long port_num = 0;
#endif
int ret;
GIT_SOCKET s = INVALID_SOCKET;
@@ -397,6 +399,12 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
}
#else
hent = gethostbyname(host);
+ sent = getservbyname(port, 0);
+
+ if(sent)
+ port_num = sent->s_port;
+ else
+ port_num = atol(port);
#endif
#ifndef __amigaos4__
@@ -413,9 +421,9 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
#ifndef __amigaos4__
if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0)
#else
- saddr.sin_addr.s_addr = *hent->h_addr_list[p];
+ memcpy(&saddr.sin_addr, hent->h_addr_list[p], hent->h_length);
saddr.sin_family = hent->h_addrtype;
- saddr.sin_port = port;
+ saddr.sin_port = port_num;
if (connect(s, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)) == 0)
#endif
break;