5 /* only do the following on windows
7 #if (defined(WIN32) || defined(WATT32)) && !defined(MSDOS)
16 #include <sys/socket.h>
21 #include "ares_private.h"
25 ares_strncasecmp(const char *a, const char *b, int n)
29 for (i = 0; i < n; i++) {
30 int c1 = isupper(a[i]) ? tolower(a[i]) : a[i];
31 int c2 = isupper(b[i]) ? tolower(b[i]) : b[i];
32 if (c1 != c2) return c1-c2;
38 ares_strcasecmp(const char *a, const char *b)
40 return strncasecmp(a, b, strlen(a)+1);
45 * Number of micro-seconds between the beginning of the Windows epoch
46 * (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970).
48 #if defined(_MSC_VER) || defined(__WATCOMC__)
49 #define EPOCH_FILETIME 11644473600000000Ui64
51 #define EPOCH_FILETIME 11644473600000000ULL
55 ares_gettimeofday(struct timeval *tv, struct timezone *tz)
63 GetSystemTimeAsFileTime(&ft);
64 li.LowPart = ft.dwLowDateTime;
65 li.HighPart = ft.dwHighDateTime;
66 t = li.QuadPart / 10; /* In micro-second intervals */
67 t -= EPOCH_FILETIME; /* Offset to the Epoch time */
68 tv->tv_sec = (long)(t / 1000000);
69 tv->tv_usec = (long)(t % 1000000);
76 ares_writev (ares_socket_t s, const struct iovec *vector, size_t count)
81 /* Find the total number of bytes to write
83 for (i = 0; i < count; i++)
84 bytes += vector[i].iov_len;
86 if (bytes == 0) /* not an error */
89 /* Allocate a temporary buffer to hold the data
91 buffer = bp = (char*) alloca (bytes);
98 /* Copy the data into buffer.
100 for (i = 0; i < count; ++i)
102 memcpy (bp, vector[i].iov_base, vector[i].iov_len);
103 bp += vector[i].iov_len;
105 return send (s, (const void*)buffer, bytes, 0);
107 #endif /* WIN32 builds only */