]> git.pld-linux.org Git - packages/ecartis.git/blame - ecartis-ipv6.patch
- tabs in preamble
[packages/ecartis.git] / ecartis-ipv6.patch
CommitLineData
c8ad1fe6
PG
1--- ./src/Makefile.dist.org Fri Jul 19 08:45:04 2002
2+++ ./src/Makefile.dist Mon Jul 29 17:55:33 2002
3@@ -93,6 +93,9 @@
4 # If we have the timezone() function, we can try that as well
5 #HAVE_TIMEZONE=-DHAVE_TIMEZONE
6
7+# If we have the getaddrinfo() function, we can try that as well
8+#HAVE_GETADDRINFO=-DHAVE_GETADDRINFO
9+
10 # If we don't have the strchr function then define this
11 #NEED_STRCHR=-DNEED_STRCHR
12
13@@ -129,9 +132,9 @@
14
15 # Now set up the initial command line. SUNOS_5 makes this a bit wierd.
16 ifndef SUNOS_5
17-CFLAGS=-I./inc ${GNU_STRFTIME} ${NEED_SNPRINTF} ${NEED_FLOCK} ${DEC_UNIX} ${IRIX} ${USE_HITCHING_LOCK} ${NO_MEMMOVE} ${NEED_STRERROR} ${NO_TM_GMTOFF} ${HAVE_TZNAME} ${HAVE_TIMEZONE} ${NEED_STRCHR} ${NEED_STRRCHR} ${MY_PRINTF_IS_BRAINDEAD} ${DETECT_BROKEN_HOSTNAME}
18+CFLAGS=-I./inc ${GNU_STRFTIME} ${NEED_SNPRINTF} ${NEED_FLOCK} ${DEC_UNIX} ${IRIX} ${USE_HITCHING_LOCK} ${NO_MEMMOVE} ${NEED_STRERROR} ${NO_TM_GMTOFF} ${HAVE_TZNAME} ${HAVE_TIMEZONE} ${NEED_STRCHR} ${NEED_STRRCHR} ${MY_PRINTF_IS_BRAINDEAD} ${DETECT_BROKEN_HOSTNAME} ${HAVE_GETADDRINFO}
19 else
20-CFLAGS=-I./inc -DSUNOS_5 ${GNU_STRFTIME} ${NEED_SNPRINTF} ${NEED_FLOCK} ${USE_HITCHING_LOCK} ${NO_MEMMOVE} ${NEED_STRERROR} ${NO_TM_GMTOFF} ${HAVE_TZNAME} ${HAVE_TIMEZONE} ${NEED_STRCHR} ${NEED_STRRCHR} ${MY_PRINTF_IS_BRAINDEAD}
21+CFLAGS=-I./inc -DSUNOS_5 ${GNU_STRFTIME} ${NEED_SNPRINTF} ${NEED_FLOCK} ${USE_HITCHING_LOCK} ${NO_MEMMOVE} ${NEED_STRERROR} ${NO_TM_GMTOFF} ${HAVE_TZNAME} ${HAVE_TIMEZONE} ${NEED_STRCHR} ${NEED_STRRCHR} ${MY_PRINTF_IS_BRAINDEAD} ${HAVE_GETADDRINFO}
22 endif
23
24 # Now set up the initial library path. Once again, SUNOS_5 makes this
25--- ./src/io.c.org Fri Jul 19 08:45:04 2002
26+++ ./src/io.c Mon Jul 29 17:59:54 2002
27@@ -119,27 +119,57 @@
28 /* Open a socket to a specific host/port */
29 int sock_open(const char *conhostname, int port, LSOCKET *sock)
30 {
31- struct hostent *conhost;
32- struct sockaddr_in name;
33- int addr_len;
34- int mysock;
35+ int mysock = -1;
36+#ifdef HAVE_GETADDRINFO
37+ char pbuf[NI_MAXSERV];
38+ struct addrinfo hints, *res, *res0;
39+ int gerr = 0;
40
41- conhost = gethostbyname(conhostname);
42- if (conhost == 0)
43- return -1;
44+ sprintf(pbuf, "%d", port);
45+ pbuf[sizeof(pbuf)-1] = '\0';
46+ memset(&hints, 0, sizeof(hints));
47+ hints.ai_family = AF_UNSPEC;
48+ hints.ai_socktype = SOCK_STREAM;
49+ if (getaddrinfo(conhostname, pbuf, &hints, &res0) != 0)
50+ return -1;
51
52- name.sin_port = htons(port);
53- name.sin_family = AF_INET;
54- bcopy((char *)conhost->h_addr, (char *)&name.sin_addr, conhost->h_length);
55- mysock = socket(AF_INET, SOCK_STREAM, 0);
56- addr_len = sizeof(name);
57-
58- if (connect(mysock, (struct sockaddr *)&name, addr_len) == -1)
59- return -1;
60-
61- *sock = mysock;
62-
63- return 0;
64+ for (res = res0; res != NULL; res = res->ai_next) {
65+ mysock = socket(res->ai_family, res->ai_socktype, 0);
66+ if (mysock == -1)
67+ continue;
68+ if (connect(mysock, res->ai_addr, res->ai_addrlen) == -1) {
69+ close(mysock);
70+ continue;
71+ }
72+ gerr++;
73+ break;
74+ }
75+ freeaddrinfo(res0);
76+ if (gerr == 0)
77+ return -1;
78+#else /* HAVE_GETADDRINFO */
79+
80+ struct hostent *conhost;
81+ struct sockaddr_in name;
82+ int addr_len;
83+
84+ conhost = gethostbyname(conhostname);
85+ if (conhost == 0)
86+ return -1;
87+
88+ name.sin_port = htons(port);
89+ name.sin_family = AF_INET;
90+ bcopy((char *)conhost->h_addr, (char *)&name.sin_addr, conhost->h_length);
91+ mysock = socket(AF_INET, SOCK_STREAM, 0);
92+ addr_len = sizeof(name);
93+
94+ if (connect(mysock, (struct sockaddr *)&name, addr_len) == -1)
95+ return -1;
96+#endif /* HAVE_GETADDRINFO */
97+
98+ *sock = mysock;
99+
100+ return 0;
101 }
102
103 int sock_close(LSOCKET sock)
This page took 0.108832 seconds and 4 git commands to generate.