mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 17:33:35 +00:00
Fix gethostbyname compatibility
This commit is contained in:
parent
b9bfc7684b
commit
327fb51cec
@ -56,11 +56,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __amigaos4__
|
#ifdef __amigaos4__
|
||||||
/* Network byte order is big-endian... so is PPC, so these functions are NOP */
|
#include <netinet/in.h>
|
||||||
#define htonl(x) x
|
|
||||||
#define ntohl(x) x
|
|
||||||
#define htons(x) x
|
|
||||||
#define ntohs(x) x
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
12
src/netops.c
12
src/netops.c
@ -382,7 +382,9 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
|
|||||||
#else
|
#else
|
||||||
int p;
|
int p;
|
||||||
struct hostent *hent;
|
struct hostent *hent;
|
||||||
|
struct servent *sent;
|
||||||
struct sockaddr_in saddr;
|
struct sockaddr_in saddr;
|
||||||
|
long port_num = 0;
|
||||||
#endif
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
GIT_SOCKET s = INVALID_SOCKET;
|
GIT_SOCKET s = INVALID_SOCKET;
|
||||||
@ -397,6 +399,12 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
hent = gethostbyname(host);
|
hent = gethostbyname(host);
|
||||||
|
sent = getservbyname(port, 0);
|
||||||
|
|
||||||
|
if(sent)
|
||||||
|
port_num = sent->s_port;
|
||||||
|
else
|
||||||
|
port_num = atol(port);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __amigaos4__
|
#ifndef __amigaos4__
|
||||||
@ -413,9 +421,9 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
|
|||||||
#ifndef __amigaos4__
|
#ifndef __amigaos4__
|
||||||
if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0)
|
if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0)
|
||||||
#else
|
#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_family = hent->h_addrtype;
|
||||||
saddr.sin_port = port;
|
saddr.sin_port = port_num;
|
||||||
if (connect(s, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)) == 0)
|
if (connect(s, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)) == 0)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user