summaryrefslogtreecommitdiff
path: root/mcon/U/d_getaddrinfo.U
blob: d36e50486ec213393363541c67ecac391ecf5c31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
?RCS: $Id$
?RCS:
?RCS: Copyright (c) 2006, Christian Biere
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?MAKE:d_getaddrinfo: Trylink cat i_arpainet i_netdb i_syssock \
	i_winsock2 i_ws2tcpip i_niin d_windows
?MAKE:	-pick add $@ %<
?S:d_getaddrinfo:
?S:	This variable conditionally defines the HAS_GETADDRINFO symbol, which
?S:	indicates to the C program that the getaddrinfo() routine is available.
?S:.
?C:HAS_GETADDRINFO:
?C:	This symbol is defined when getaddrinfo() can be used.
?C:.
?H:#$d_getaddrinfo HAS_GETADDRINFO
?H:.
?LINT: set d_getaddrinfo
: can we use getaddrinfo?
$cat >try.c <<EOC
#$i_syssock I_SYS_SOCKET
#$i_winsock2 I_WINSOCK2
#$i_ws2tcpip I_WS2TCPIP
#$i_niin I_NETINET_IN
#$i_arpainet I_ARPA_INET
#$i_netdb I_NETDB
#$d_windows WINDOWS_SYSTEM
#ifdef WINDOWS_SYSTEM
#define WINVER 0x0501
#endif
#include <sys/types.h>
#ifdef I_SYS_SOCKET
#include <sys/socket.h>
#endif
#ifdef I_NETINET_IN
#include <netinet/in.h>
#endif
#ifdef I_ARPA_INET
#include <arpa/inet.h>
#endif
#ifdef I_NETDB
#include <netdb.h>
#endif
#ifdef I_WINSOCK2
#include <Winsock2.h>
#endif
#ifdef I_WS2TCPIP
#include <Ws2tcpip.h>
#endif
int main(void)
{
	struct addrinfo hints, *res;
	int ret;

	hints.ai_flags = 1;
	hints.ai_family = PF_UNSPEC;
	hints.ai_socktype = 1;
	hints.ai_protocol = 1;
	hints.ai_addrlen = (socklen_t) 1;
	hints.ai_canonname = "canonname";
	hints.ai_addr = (struct sockaddr *) 0;
	hints.ai_next = (struct addrinfo *) 0;
	ret = getaddrinfo("localhost", "www", &hints, &res);
	if (0 != ret) {
		const char *s;
		s = gai_strerror(ret);
		(void) s;
	}
	if (res)
		freeaddrinfo(res);
	return 0;
}
EOC
cyn=getaddrinfo
set d_getaddrinfo '-lWs2_32'
eval $trylink