Skip to content

Commit da523cc

Browse files
dotzengitster
authored andcommitted
compat: add inet_pton and inet_ntop prototypes
Windows doesn't have inet_pton and inet_ntop, so add prototypes in git-compat-util.h for them. At the same time include git-compat-util.h in the sources for these functions, so they use the network-wrappers from there on Windows. Signed-off-by: Mike Pape <[email protected]> Signed-off-by: Erik Faye-Lund <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 088d880 commit da523cc

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,9 +1398,11 @@ endif
13981398
endif
13991399
ifdef NO_INET_NTOP
14001400
LIB_OBJS += compat/inet_ntop.o
1401+
BASIC_CFLAGS += -DNO_INET_NTOP
14011402
endif
14021403
ifdef NO_INET_PTON
14031404
LIB_OBJS += compat/inet_pton.o
1405+
BASIC_CFLAGS += -DNO_INET_PTON
14041406
endif
14051407

14061408
ifdef NO_ICONV

compat/inet_ntop.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
#include <errno.h>
1919
#include <sys/types.h>
20-
#include <sys/socket.h>
21-
#include <netinet/in.h>
22-
#include <arpa/inet.h>
20+
21+
#include "../git-compat-util.h"
22+
2323
#include <stdio.h>
2424
#include <string.h>
2525

compat/inet_pton.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
#include <errno.h>
1919
#include <sys/types.h>
20-
#include <sys/socket.h>
21-
#include <netinet/in.h>
22-
#include <arpa/inet.h>
20+
21+
#include "../git-compat-util.h"
22+
2323
#include <stdio.h>
2424
#include <string.h>
2525

@@ -41,7 +41,9 @@
4141
*/
4242

4343
static int inet_pton4(const char *src, unsigned char *dst);
44+
#ifndef NO_IPV6
4445
static int inet_pton6(const char *src, unsigned char *dst);
46+
#endif
4547

4648
/* int
4749
* inet_pton4(src, dst)

git-compat-util.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,14 @@ static inline void *gitmempcpy(void *dest, const void *src, size_t n)
387387
}
388388
#endif
389389

390+
#ifdef NO_INET_PTON
391+
int inet_pton(int af, const char *src, void *dst);
392+
#endif
393+
394+
#ifdef NO_INET_NTOP
395+
const char *inet_ntop(int af, const void *src, char *dst, size_t size);
396+
#endif
397+
390398
extern void release_pack_memory(size_t, int);
391399

392400
typedef void (*try_to_free_t)(size_t);

0 commit comments

Comments
 (0)