summaryrefslogtreecommitdiff
path: root/src/lib/evil
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2017-10-01 17:07:02 +0100
committerAndy Williams <andy@andywilliams.me>2017-10-01 18:09:46 +0100
commit10ba064b65e02befec19cfb89657ebf86a0a95f1 (patch)
tree6bda091cc7cdaedd18f8a2c59505eff1e7bc5d4e /src/lib/evil
parent3462390b5cda12ca0b37cf00a2a20a5d3636d4b5 (diff)
Windows: remove XP support and forbid compilation and run on this platform
Test Plan: run on XP Reviewers: jpeg, cedric, ajwillia.ms Reviewed By: ajwillia.ms Subscribers: ajwillia.ms Differential Revision: https://phab.enlightenment.org/D5245
Diffstat (limited to 'src/lib/evil')
-rw-r--r--src/lib/evil/Evil.h1
-rw-r--r--src/lib/evil/evil_inet.c645
-rw-r--r--src/lib/evil/evil_inet.h141
-rw-r--r--src/lib/evil/evil_macro.h4
-rw-r--r--src/lib/evil/evil_macro_wrapper.h23
-rw-r--r--src/lib/evil/evil_main.c11
6 files changed, 15 insertions, 810 deletions
diff --git a/src/lib/evil/Evil.h b/src/lib/evil/Evil.h
index 837803c..c8f1f68 100644
--- a/src/lib/evil/Evil.h
+++ b/src/lib/evil/Evil.h
@@ -110,7 +110,6 @@ typedef unsigned long gid_t;
110#include "evil_macro.h" 110#include "evil_macro.h"
111#include "evil_dlfcn.h" 111#include "evil_dlfcn.h"
112#include "evil_fcntl.h" 112#include "evil_fcntl.h"
113#include "evil_inet.h"
114#include "evil_langinfo.h" 113#include "evil_langinfo.h"
115#include "evil_locale.h" 114#include "evil_locale.h"
116#include "evil_main.h" 115#include "evil_main.h"
diff --git a/src/lib/evil/evil_inet.c b/src/lib/evil/evil_inet.c
deleted file mode 100644
index 54cee3d..0000000
--- a/src/lib/evil/evil_inet.c
+++ /dev/null
@@ -1,645 +0,0 @@
1
2/*
3 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
4 * Copyright (c) 1996,1999 by Internet Software Consortium.
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
16 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
20 * Modifications: Vincent Torri, for the integration in Evil
21 * - modification of the name of some functions
22 * * modification of the management of the error
23 */
24
25#if ! (_WIN32_WINNT >= 0x600 /* _WIN32_WINNT_VISTA */)
26
27#ifdef HAVE_CONFIG_H
28# include "config.h"
29#endif /* HAVE_CONFIG_H */
30
31#include <errno.h>
32#include <stdio.h>
33#include <ctype.h>
34
35#ifndef WIN32_LEAN_AND_MEAN
36# define WIN32_LEAN_AND_MEAN
37#endif
38#include <winsock2.h>
39#undef WIN32_LEAN_AND_MEAN
40
41#include "evil_macro.h"
42#include "evil_inet.h"
43
44#ifndef EMSGSIZE
45# define EMSGSIZE WSAEMSGSIZE
46#endif
47
48#ifndef EAFNOSUPPORT
49# define EAFNOSUPPORT WSAEAFNOSUPPORT
50#endif
51
52#define SPRINTF(x) ((size_t)sprintf x)
53
54#define ERRNO ((int)GetLastError())
55#define SET_ERRNO(x) (SetLastError((DWORD)(x)))
56
57#define ISDIGIT(x) (isdigit((int) ((unsigned char)x)))
58#define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
59#define ISUPPER(x) (isupper((int) ((unsigned char)x)))
60
61#define NS_IN6ADDRSZ 16
62#define NS_INT16SZ 2
63#define NS_INADDRSZ sizeof(IN_ADDR)
64
65
66struct ares_in6_addr {
67 union {
68 unsigned char _S6_u8[16];
69 } _S6_un;
70};
71
72const struct ares_in6_addr ares_in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
73
74
75/*
76 * static int
77 * inet_net_pton_ipv4(src, dst, size)
78 * convert IPv4 network number from presentation to network format.
79 * accepts hex octets, hex strings, decimal octets, and /CIDR.
80 * "size" is in bytes and describes "dst".
81 * return:
82 * number of bits, either imputed classfully or specified with /CIDR,
83 * or -1 if some failure occurred (check errno). ENOENT means it was
84 * not an IPv4 network specification.
85 * note:
86 * network byte order assumed. this means 192.5.5.240/28 has
87 * 0b11110000 in its fourth octet.
88 * note:
89 * On Windows we store the error in the thread errno, not
90 * in the winsock error code. This is to avoid loosing the
91 * actual last winsock error. So use macro ERRNO to fetch the
92 * errno this funtion sets when returning (-1), not SOCKERRNO.
93 * author:
94 * Paul Vixie (ISC), June 1996
95 */
96static int
97inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
98{
99 static const char xdigits[] = "0123456789abcdef";
100 static const char digits[] = "0123456789";
101 int n, ch, tmp = 0, dirty, bits;
102 const unsigned char *odst = dst;
103
104 ch = *src++;
105 if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
106 && ISXDIGIT(src[1])) {
107 /* Hexadecimal: Eat nybble string. */
108 if (!size)
109 goto emsgsize;
110 dirty = 0;
111 src++; /* skip x or X. */
112 while ((ch = *src++) != '\0' && ISXDIGIT(ch)) {
113 if (ISUPPER(ch))
114 ch = tolower(ch);
115 n = (int)(strchr(xdigits, ch) - xdigits);
116 if (dirty == 0)
117 tmp = n;
118 else
119 tmp = (tmp << 4) | n;
120 if (++dirty == 2) {
121 if (!size--)
122 goto emsgsize;
123 *dst++ = (unsigned char) tmp;
124 dirty = 0;
125 }
126 }
127 if (dirty) { /* Odd trailing nybble? */
128 if (!size--)
129 goto emsgsize;
130 *dst++ = (unsigned char) (tmp << 4);
131 }
132 } else if (ISDIGIT(ch)) {
133 /* Decimal: eat dotted digit string. */
134 for (;;) {
135 tmp = 0;
136 do {
137 n = (int)(strchr(digits, ch) - digits);
138 tmp *= 10;
139 tmp += n;
140 if (tmp > 255)
141 goto enoent;
142 } while ((ch = *src++) != '\0' &&
143 ISDIGIT(ch));
144 if (!size--)
145 goto emsgsize;
146 *dst++ = (unsigned char) tmp;
147 if (ch == '\0' || ch == '/')
148 break;
149 if (ch != '.')
150 goto enoent;
151 ch = *src++;
152 if (!ISDIGIT(ch))
153 goto enoent;
154 }
155 } else
156 goto enoent;
157
158 bits = -1;
159 if (ch == '/' &&
160 ISDIGIT(src[0]) && dst > odst) {
161 /* CIDR width specifier. Nothing can follow it. */
162 ch = *src++; /* Skip over the /. */
163 bits = 0;
164 do {
165 n = (int)(strchr(digits, ch) - digits);
166 bits *= 10;
167 bits += n;
168 } while ((ch = *src++) != '\0' && ISDIGIT(ch));
169 if (ch != '\0')
170 goto enoent;
171 if (bits > 32)
172 goto emsgsize;
173 }
174
175 /* Firey death and destruction unless we prefetched EOS. */
176 if (ch != '\0')
177 goto enoent;
178
179 /* If nothing was written to the destination, we found no address. */
180 if (dst == odst)
181 goto enoent;
182 /* If no CIDR spec was given, infer width from net class. */
183 if (bits == -1) {
184 if (*odst >= 240) /* Class E */
185 bits = 32;
186 else if (*odst >= 224) /* Class D */
187 bits = 8;
188 else if (*odst >= 192) /* Class C */
189 bits = 24;
190 else if (*odst >= 128) /* Class B */
191 bits = 16;
192 else /* Class A */
193 bits = 8;
194 /* If imputed mask is narrower than specified octets, widen. */
195 if (bits < ((dst - odst) * 8))
196 bits = (int)(dst - odst) * 8;
197 /*
198 * If there are no additional bits specified for a class D
199 * address adjust bits to 4.
200 */
201 if (bits == 8 && *odst == 224)
202 bits = 4;
203 }
204 /* Extend network to cover the actual mask. */
205 while (bits > ((dst - odst) * 8)) {
206 if (!size--)
207 goto emsgsize;
208 *dst++ = '\0';
209 }
210 return (bits);
211
212 enoent:
213 SET_ERRNO(ENOENT);
214 return (-1);
215
216 emsgsize:
217 SET_ERRNO(EMSGSIZE);
218 return (-1);
219}
220
221static int
222getbits(const char *src, int *bitsp)
223{
224 static const char digits[] = "0123456789";
225 int n;
226 int val;
227 char ch;
228
229 val = 0;
230 n = 0;
231 while ((ch = *src++) != '\0') {
232 const char *pch;
233
234 pch = strchr(digits, ch);
235 if (pch != NULL) {
236 if (n++ != 0 && val == 0) /* no leading zeros */
237 return (0);
238 val *= 10;
239 val += (pch - digits);
240 if (val > 128) /* range */
241 return (0);
242 continue;
243 }
244 return (0);
245 }
246 if (n == 0)
247 return (0);
248 *bitsp = val;
249 return (1);
250}
251
252static int
253getv4(const char *src, unsigned char *dst, int *bitsp)
254{
255 static const char digits[] = "0123456789";
256 unsigned char *odst = dst;
257 int n;
258 unsigned int val;
259 char ch;
260
261 val = 0;
262 n = 0;
263 while ((ch = *src++) != '\0') {
264 const char *pch;
265
266 pch = strchr(digits, ch);
267 if (pch != NULL) {
268 if (n++ != 0 && val == 0) /* no leading zeros */
269 return (0);
270 val *= 10;
271 val += (pch - digits);
272 if (val > 255) /* range */
273 return (0);
274 continue;
275 }
276 if (ch == '.' || ch == '/') {
277 if (dst - odst > 3) /* too many octets? */
278 return (0);
279 *dst++ = (unsigned char)val;
280 if (ch == '/')
281 return (getbits(src, bitsp));
282 val = 0;
283 n = 0;
284 continue;
285 }
286 return (0);
287 }
288 if (n == 0)
289 return (0);
290 if (dst - odst > 3) /* too many octets? */
291 return (0);
292 *dst++ = (unsigned char)val;
293 return (1);
294}
295
296static int
297inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size)
298{
299 static const char xdigits_l[] = "0123456789abcdef",
300 xdigits_u[] = "0123456789ABCDEF";
301 unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
302 const char *xdigits, *curtok;
303 int ch, saw_xdigit;
304 unsigned int val;
305 int digits;
306 int bits;
307 size_t bytes;
308 int words;
309 int ipv4;
310
311 memset((tp = tmp), '\0', NS_IN6ADDRSZ);
312 endp = tp + NS_IN6ADDRSZ;
313 colonp = NULL;
314 /* Leading :: requires some special handling. */
315 if (*src == ':')
316 if (*++src != ':')
317 goto enoent;
318 curtok = src;
319 saw_xdigit = 0;
320 val = 0;
321 digits = 0;
322 bits = -1;
323 ipv4 = 0;
324 while ((ch = *src++) != '\0') {
325 const char *pch;
326
327 if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
328 pch = strchr((xdigits = xdigits_u), ch);
329 if (pch != NULL) {
330 val <<= 4;
331 val |= (pch - xdigits);
332 if (++digits > 4)
333 goto enoent;
334 saw_xdigit = 1;
335 continue;
336 }
337 if (ch == ':') {
338 curtok = src;
339 if (!saw_xdigit) {
340 if (colonp)
341 goto enoent;
342 colonp = tp;
343 continue;
344 } else if (*src == '\0')
345 goto enoent;
346 if (tp + NS_INT16SZ > endp)
347 return (0);
348 *tp++ = (unsigned char)((val >> 8) & 0xff);
349 *tp++ = (unsigned char)(val & 0xff);
350 saw_xdigit = 0;
351 digits = 0;
352 val = 0;
353 continue;
354 }
355 if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
356 getv4(curtok, tp, &bits) > 0) {
357 tp += NS_INADDRSZ;
358 saw_xdigit = 0;
359 ipv4 = 1;
360 break; /* '\0' was seen by inet_pton4(). */
361 }
362 if (ch == '/' && getbits(src, &bits) > 0)
363 break;
364 goto enoent;
365 }
366 if (saw_xdigit) {
367 if (tp + NS_INT16SZ > endp)
368 goto enoent;
369 *tp++ = (unsigned char)((val >> 8) & 0xff);
370 *tp++ = (unsigned char)(val & 0xff);
371 }
372 if (bits == -1)
373 bits = 128;
374
375 words = (bits + 15) / 16;
376 if (words < 2)
377 words = 2;
378 if (ipv4)
379 words = 8;
380 endp = tmp + 2 * words;
381
382 if (colonp != NULL) {
383 /*
384 * Since some memmove()'s erroneously fail to handle
385 * overlapping regions, we'll do the shift by hand.
386 */
387 const ssize_t n = tp - colonp;
388 ssize_t i;
389
390 if (tp == endp)
391 goto enoent;
392 for (i = 1; i <= n; i++) {
393 *(endp - i) = *(colonp + n - i);
394 *(colonp + n - i) = 0;
395 }
396 tp = endp;
397 }
398 if (tp != endp)
399 goto enoent;
400
401 bytes = (bits + 7) / 8;
402 if (bytes > size)
403 goto emsgsize;
404 memcpy(dst, tmp, bytes);
405 return (bits);
406
407 enoent:
408 SET_ERRNO(ENOENT);
409 return (-1);
410
411 emsgsize:
412 SET_ERRNO(EMSGSIZE);
413 return (-1);
414}
415
416/*
417 * int
418 * inet_net_pton(af, src, dst, size)
419 * convert network number from presentation to network format.
420 * accepts hex octets, hex strings, decimal octets, and /CIDR.
421 * "size" is in bytes and describes "dst".
422 * return:
423 * number of bits, either imputed classfully or specified with /CIDR,
424 * or -1 if some failure occurred (check errno). ENOENT means it was
425 * not a valid network specification.
426 * note:
427 * On Windows we store the error in the thread errno, not
428 * in the winsock error code. This is to avoid loosing the
429 * actual last winsock error. So use macro ERRNO to fetch the
430 * errno this funtion sets when returning (-1), not SOCKERRNO.
431 * author:
432 * Paul Vixie (ISC), June 1996
433 */
434static int
435ares_inet_net_pton(int af, const char *src, void *dst, size_t size)
436{
437 switch (af) {
438 case AF_INET:
439 return (inet_net_pton_ipv4(src, dst, size));
440 case AF_INET6:
441 return (inet_net_pton_ipv6(src, dst, size));
442 default:
443 SET_ERRNO(EAFNOSUPPORT);
444 return (-1);
445 }
446}
447
448int
449evil_inet_pton(int af, const char *src, void *dst)
450{
451 int result;
452 size_t size;
453
454 if (af == AF_INET)
455 size = sizeof(struct in_addr);
456 else if (af == AF_INET6)
457 size = sizeof(struct ares_in6_addr);
458 else
459 {
460 SET_ERRNO(EAFNOSUPPORT);
461 return -1;
462 }
463 result = ares_inet_net_pton(af, src, dst, size);
464 if ((result == -1) && (ERRNO == ENOENT))
465 return 0;
466 return (result > -1 ? 1 : -1);
467}
468
469/* const char *
470 * inet_ntop4(src, dst, size)
471 * format an IPv4 address, more or less like inet_ntoa()
472 * return:
473 * `dst' (as a const)
474 * notes:
475 * (1) uses no statics
476 * (2) takes a unsigned char* not an in_addr as input
477 * author:
478 * Paul Vixie, 1996.
479 */
480static const char *
481inet_ntop4(const unsigned char *src, char *dst, size_t size)
482{
483 static const char fmt[] = "%u.%u.%u.%u";
484 char tmp[sizeof "255.255.255.255"];
485
486 if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size)
487 {
488 SET_ERRNO(ENOSPC);
489 return (NULL);
490 }
491 strcpy(dst, tmp);
492 return (dst);
493}
494
495/* const char *
496 * inet_ntop6(src, dst, size)
497 * convert IPv6 binary address into presentation (printable) format
498 * author:
499 * Paul Vixie, 1996.
500 */
501static const char *
502inet_ntop6(const unsigned char *src, char *dst, size_t size)
503{
504 /*
505 * Note that int32_t and int16_t need only be "at least" large enough
506 * to contain a value of the specified size. On some systems, like
507 * Crays, there is no such thing as an integer variable with 16 bits.
508 * Keep this in mind if you think this function should have been coded
509 * to use pointer overlays. All the world's not a VAX.
510 */
511 char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
512 char *tp;
513 struct {
514 long base;
515 long len;
516 } best, cur;
517 unsigned long words[NS_IN6ADDRSZ / NS_INT16SZ];
518 int i;
519
520 /*
521 * Preprocess:
522 * Copy the input (bytewise) array into a wordwise array.
523 * Find the longest run of 0x00's in src[] for :: shorthanding.
524 */
525 memset(words, '\0', sizeof(words));
526 for (i = 0; i < NS_IN6ADDRSZ; i++)
527 words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
528
529 best.base = -1;
530 cur.base = -1;
531 best.len = 0;
532 cur.len = 0;
533
534 for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
535 {
536 if (words[i] == 0)
537 {
538 if (cur.base == -1)
539 cur.base = i, cur.len = 1;
540 else
541 cur.len++;
542 }
543 else
544 {
545 if (cur.base != -1)
546 {
547 if (best.base == -1 || cur.len > best.len)
548 best = cur;
549 cur.base = -1;
550 }
551 }
552 }
553 if (cur.base != -1)
554 {
555 if (best.base == -1 || cur.len > best.len)
556 best = cur;
557 }
558 if (best.base != -1 && best.len < 2)
559 best.base = -1;
560
561 /*
562 * Format the result.
563 */
564 tp = tmp;
565 for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
566 {
567 /* Are we inside the best run of 0x00's? */
568 if (best.base != -1 && i >= best.base &&
569 i < (best.base + best.len))
570 {
571 if (i == best.base)
572 *tp++ = ':';
573 continue;
574 }
575 /* Are we following an initial run of 0x00s or any real hex? */
576 if (i != 0)
577 *tp++ = ':';
578 /* Is this address an encapsulated IPv4? */
579 if (i == 6 && best.base == 0 &&
580 (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
581 {
582 if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
583 return (NULL);
584 tp += strlen(tp);
585 break;
586 }
587 tp += SPRINTF((tp, "%lx", words[i]));
588 }
589
590 /* Was it a trailing run of 0x00's? */
591 if (best.base != -1 && (best.base + best.len) == (NS_IN6ADDRSZ / NS_INT16SZ))
592 *tp++ = ':';
593 *tp++ = '\0';
594
595 /*
596 * Check for overflow, copy, and we're done.
597 */
598 if ((size_t)(tp - tmp) > size)
599 {
600 SET_ERRNO(ENOSPC);
601 return (NULL);
602 }
603 strcpy(dst, tmp);
604 return (dst);
605}
606
607/* char *
608 * inet_ntop(af, src, dst, size)
609 * convert a network format address to presentation format.
610 * return:
611 * pointer to presentation format address (`dst'), or NULL (see errno).
612 * note:
613 * On Windows we store the error in the thread errno, not
614 * in the winsock error code. This is to avoid loosing the
615 * actual last winsock error. So use macro ERRNO to fetch the
616 * errno this funtion sets when returning NULL, not SOCKERRNO.
617 * author:
618 * Paul Vixie, 1996.
619 */
620static const char *
621ares_inet_ntop(int af, const void *src, char *dst, size_t size)
622{
623 switch (af)
624 {
625 case AF_INET:
626 return (inet_ntop4(src, dst, size));
627 case AF_INET6:
628 return (inet_ntop6(src, dst, size));
629 default:
630 SET_ERRNO(EAFNOSUPPORT);
631 return (NULL);
632 }
633 /* NOTREACHED */
634}
635
636const char *evil_inet_ntop(int af, const char *src, void *dst, size_t size)
637{
638 const char *result;
639 result = ares_inet_ntop(af, src, dst, size);
640 if ((result == NULL) && (ERRNO == ENOSPC))
641 return NULL;
642 return result;
643}
644
645#endif
diff --git a/src/lib/evil/evil_inet.h b/src/lib/evil/evil_inet.h
deleted file mode 100644
index fb4e072..0000000
--- a/src/lib/evil/evil_inet.h
+++ /dev/null
@@ -1,141 +0,0 @@
1
2/* Copyright (C) 2005 by Daniel Stenberg
3 *
4 * Permission to use, copy, modify, and distribute this
5 * software and its documentation for any purpose and without
6 * fee is hereby granted, provided that the above copyright
7 * notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting
9 * documentation, and that the name of M.I.T. not be used in
10 * advertising or publicity pertaining to distribution of the
11 * software without specific, written prior permission.
12 * M.I.T. makes no representations about the suitability of
13 * this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
15 */
16
17#ifndef __EVIL_INET_H__
18#define __EVIL_INET_H__
19
20
21#if ! (_WIN32_WINNT >= 0x600 /* _WIN32_WINNT_VISTA */)
22
23
24/**
25 * @file evil_inet.h
26 * @brief The file that provides functions ported from Unix in arpa/inet.h.
27 * @defgroup Evil_Inet_Group Inet.h functions
28 * @ingroup Evil
29 *
30 * This header provides functions ported from Unix in arpa/inet.h.
31 *
32 * @{
33 */
34
35/**
36 * @brief Convert IPv4 and IPv6 addresses from text to binary form.
37 *
38 * @param af The address family.
39 * @param src The address to convert.
40 * @param dst The converted address structure.
41 * @return 1 on success, 0 or -1 otherwise.
42 *
43 * This function converts IPv4 and IPv6 addresses from @p src to the
44 * binary form @p dst. The following address families to pass to @p af
45 * are currently supported:
46 *
47 * <ul>
48 * <li>i AF_INET: @p src points to a character string containing an IPv4
49 * network address in dotted-decimal format, "ddd.ddd.ddd.ddd", where
50 * ddd is a decimal number of up to three digits in the range 0 to
51 * 255. The address is converted to a struct in_addr and copied to
52 * dst, which must be sizeof(struct in_addr) (4) bytes (32 bits) long.
53 * <li> AF_INET6: @p src points to a character string containing an
54 * IPv6 network address. The address is converted to a struct in6_addr
55 * and copied to dst, which must be sizeof(struct in6_addr) (16) bytes
56 * (128 bits) long. The allowed formats for IPv6 addresses follow
57 * these rules:
58 * <ol>
59 * <li>The preferred format is x:x:x:x:x:x:x:x. This form consists of
60 * eight hexadecimal numbers, each of which expresses a 16-bit value
61 * (i.e., each x can be up to 4 hex digits).
62 * <li>A series of contiguous zero values in the preferred format can
63 * be abbreviated to ::. Only one instance of :: can occur in an
64 * address. For example, the loopback address 0:0:0:0:0:0:0:1 can be
65 * abbreviated as ::1. The wildcard address, consisting of all zeros,
66 * can be written as ::.
67 * <li>An alternate format is useful for expressing IPv4-mapped IPv6
68 * addresses. This form is written as x:x:x:x:x:x:d.d.d.d, where the
69 * six leading xs are hexadecimal values that define the six
70 * most-significant 16-bit pieces of the address (i.e., 96 bits), and
71 * the ds express a value in dotted-decimal notation that defines the
72 * least significant 32 bits of the address. An example of such an
73 * address is :: FFFF:204.152.189.116.
74 * </ul>
75 * </ul>
76 * On success this function returns 1 (network address was successfully
77 * converted). 0 is returned if @p src does not contain a character
78 * string representing a valid network address in the specified
79 * address family. If af does not contain a valid address family, -1
80 * is returned and errno is set to EAFNOSUPPORT.
81 *
82 * @see evil_inet_ntop()
83 * @see inet_ntop()
84 *
85 * Conformity: POSIX.1-2001.
86 *
87 * Supported OS: Windows XP, CE.
88 *
89 */
90EAPI int evil_inet_pton(int af, const char *src, void *dst);
91
92/**
93 * @brief Convert IPv4 and IPv6 addresses from binary to text form.
94 *
95 * @param af The address family.
96 * @param src The address structure to convert.
97 * @param dst A buffer containing the converted string.
98 * @param size The size of the buffer.
99 * @return 1 on success, 0 otherwise.
100 *
101 * This function converts the network address structure @p src in the
102 * @p af address family into a character string. The resulting string
103 * is copied to the buffer pointed to by @p dst, which must be a
104 * non-NULL pointer. The caller specifies the number of bytes
105 * available in this buffer in the argument @p size. The following
106 * address families to pass to @p af are currently supported:
107 *
108 * @li AF_INET: @p src points to a struct in_addr (in network byte
109 * order) which is converted to an IPv4 network address in the
110 * dotted-decimal format, "ddd.ddd.ddd.ddd". The buffer @p dst must be
111 * at least INET_ADDRSTRLEN bytes long.
112 * @li AF_INET6: @p src points to a struct in6_addr (in network byte
113 * order) which is converted to a representation of this address in
114 * the most appropriate IPv6 network address format for this
115 * address. The buffer @p dst must be at least INET6_ADDRSTRLEN bytes
116 * long.
117 *
118 * On success, this function returns a non-NULL pointer to @p dst. NULL is
119 * returned if there was an error, with errno set to indicate the
120 * error.
121 *
122 * @see evil_inet_pton()
123 * @see inet_pton()
124 *
125 * Conformity: POSIX.1-2001.
126 *
127 * Supported OS: Windows XP, CE.
128 *
129 */
130EAPI const char *evil_inet_ntop(int af, const char *src, void *dst, size_t size);
131
132
133#endif /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */
134
135
136/**
137 * @}
138 */
139
140
141#endif /* __EVIL_INET_H__ */
diff --git a/src/lib/evil/evil_macro.h b/src/lib/evil/evil_macro.h
index 70de652..966710c 100644
--- a/src/lib/evil/evil_macro.h
+++ b/src/lib/evil/evil_macro.h
@@ -1,6 +1,10 @@
1#ifndef __EVIL_MACRO_H__ 1#ifndef __EVIL_MACRO_H__
2#define __EVIL_MACRO_H__ 2#define __EVIL_MACRO_H__
3 3
4#if _WIN32_WINNT < 0x0600
5# error Windows XP not supported anymore
6#endif
7
4#ifdef EAPI 8#ifdef EAPI
5# undef EAPI 9# undef EAPI
6#endif 10#endif
diff --git a/src/lib/evil/evil_macro_wrapper.h b/src/lib/evil/evil_macro_wrapper.h
index 4eea1fa..ae74867 100644
--- a/src/lib/evil/evil_macro_wrapper.h
+++ b/src/lib/evil/evil_macro_wrapper.h
@@ -3,29 +3,6 @@
3 3
4 4
5/* 5/*
6 * evil_inet.h
7 */
8
9#if ! (_WIN32_WINNT >= 0x600 /* _WIN32_WINNT_VISTA */)
10
11/**
12 * @def inet_pton(x,y,z)
13 *
14 * Wrapper around evil_inet_pton().
15 */
16#define inet_pton(x,y,z) evil_inet_pton(x,y,z)
17
18/**
19 * @def inet_ntop(x,y,z,s)
20 *
21 * Wrapper around evil_inet_ntop().
22 */
23#define inet_ntop(x,y,z,s) evil_inet_ntop(x,y,z,s)
24
25
26#endif /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */
27
28/*
29 * evil_locale.h 6 * evil_locale.h
30 */ 7 */
31 8
diff --git a/src/lib/evil/evil_main.c b/src/lib/evil/evil_main.c
index 2b7ae51..8ddd85f 100644
--- a/src/lib/evil/evil_main.c
+++ b/src/lib/evil/evil_main.c
@@ -35,6 +35,17 @@ evil_init(void)
35 if (++_evil_init_count != 1) 35 if (++_evil_init_count != 1)
36 return _evil_init_count; 36 return _evil_init_count;
37 37
38 {
39 DWORD v;
40
41 v = GetVersion();
42 if (!v || ((DWORD)(LOBYTE(LOWORD(v))) < 6))
43 {
44 fprintf(stderr, "Windows XP not supported anymore, exiting.\n");
45 return 0;
46 }
47 }
48
38 if (!QueryPerformanceFrequency(&freq)) 49 if (!QueryPerformanceFrequency(&freq))
39 return 0; 50 return 0;
40 51