1 #include "../include/sane/config.h"
2
3 #ifndef HAVE_INET_NTOP
4
5 #include <string.h>
6 #include <sys/types.h>
7 #ifdef HAVE_WINSOCK2_H
8 #include <winsock2.h>
9 #endif
10 #ifdef HAVE_SYS_SOCKET_H
11 #include <sys/socket.h>
12 #include <netinet/in.h>
13 #include <arpa/inet.h>
14 #endif
15
16
17 const char *
inet_ntop(int af,const void * src,char * dst,size_t cnt)18 inet_ntop (int af, const void *src, char *dst, size_t cnt)
19 {
20 struct in_addr in;
21 char *text_addr;
22
23 #ifdef HAVE_INET_NTOA
24 if (af == AF_INET)
25 {
26 memcpy (&in.s_addr, src, sizeof (in.s_addr));
27 text_addr = inet_ntoa (in);
28 if (text_addr && dst)
29 {
30 strncpy (dst, text_addr, cnt);
31 return dst;
32 }
33 else
34 return 0;
35 }
36 #endif /* HAVE_INET_NTOA */
37 return 0;
38 }
39
40 #endif /* !HAVE_INET_NTOP */
41