@matheusbsbs / matheus-bagliano / commits / da523cc597
Fork 0

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 <dotzenlabs@gmail.com> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Mike Pape committed Nov 4, 2010 at 02:35 UTC da523cc597b1be7fe61ee870cf93b142e70fab7f
4 files changed +18 -6
Makefile
+2
@@ -1398,9 +1398,11 @@ endif
1398 endif
1399 ifdef NO_INET_NTOP
1400 LIB_OBJS += compat/inet_ntop.o
1401 + BASIC_CFLAGS += -DNO_INET_NTOP
1402 endif
1403 ifdef NO_INET_PTON
1404 LIB_OBJS += compat/inet_pton.o
1405 + BASIC_CFLAGS += -DNO_INET_PTON
1406 endif
1407
1408 ifdef NO_ICONV
compat/inet_ntop.c
+3 -3
@@ -17,9 +17,9 @@
17
18 #include <errno.h>
19 #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 +
23 #include <stdio.h>
24 #include <string.h>
25
compat/inet_pton.c
+5 -3
@@ -17,9 +17,9 @@
17
18 #include <errno.h>
19 #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 +
23 #include <stdio.h>
24 #include <string.h>
25
@@ -41,7 +41,9 @@
41 */
42
43 static int inet_pton4(const char *src, unsigned char *dst);
44 +#ifndef NO_IPV6
45 static int inet_pton6(const char *src, unsigned char *dst);
46 +#endif
47
48 /* int
49 * inet_pton4(src, dst)
git-compat-util.h
+8
@@ -387,6 +387,14 @@ static inline void *gitmempcpy(void *dest, const void *src, size_t n)
387 }
388 #endif
389
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 +
398 extern void release_pack_memory(size_t, int);
399
400 typedef void (*try_to_free_t)(size_t);