1 #include <arpa/inet.h>
2 #define T(t) (t*)0;
3 #define C(n) switch(n){case n:;}
4 #define I(t,e) {t x[sizeof(t)==sizeof(e)] = {e};}
f()5 static void f()
6 {
7 T(in_port_t)
8 T(in_addr_t)
9 T(struct in_addr)
10 T(uint32_t)
11 T(uint16_t)
12
13 C(INET_ADDRSTRLEN)
14 C(INET6_ADDRSTRLEN)
15
16 #ifdef htonl
17 I(uint32_t, htonl(0LL))
18 #else
19 {uint32_t(*p)(uint32_t) = htonl;}
20 #endif
21 #ifdef htons
22 I(uint16_t, htons(0LL))
23 #else
24 {uint16_t(*p)(uint16_t) = htons;}
25 #endif
26 #ifdef ntohl
27 I(uint32_t, ntohl(0LL))
28 #else
29 {uint32_t(*p)(uint32_t) = ntohl;}
30 #endif
31 #ifdef ntohs
32 I(uint16_t, ntohs(0LL))
33 #else
34 {uint16_t(*p)(uint16_t) = ntohs;}
35 #endif
36
37 {in_addr_t(*p)(const char*) = inet_addr;}
38 {char*(*p)(struct in_addr) = inet_ntoa;}
39 {const char*(*p)(int,const void*restrict,char*restrict,socklen_t) = inet_ntop;}
40 {int(*p)(int,const char*restrict,void*restrict) = inet_pton;}
41 }
42