1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

Replace IsNT with IS_NT().

Return correct timeval in windows_port.c.
Squelch gcc warnings:
  use 'ares_socket_t' in ares_fds.c.
  Don't cast a 'lvalue' in ares_init.c.
This commit is contained in:
Gisle Vanem 2004-11-10 14:23:20 +00:00
parent dc8688b8dc
commit 6ddc59dadf
5 changed files with 214 additions and 206 deletions

View File

@ -26,7 +26,8 @@
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds) int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
{ {
struct server_state *server; struct server_state *server;
int i, nfds; ares_socket_t nfds;
int i;
/* No queries, no file descriptors. */ /* No queries, no file descriptors. */
if (!channel->queries) if (!channel->queries)
@ -51,5 +52,5 @@ int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
nfds = server->tcp_socket + 1; nfds = server->tcp_socket + 1;
} }
} }
return nfds; return (int)nfds;
} }

View File

@ -149,7 +149,7 @@ static int file_lookup(struct in_addr *addr, struct hostent **host)
#ifdef WIN32 #ifdef WIN32
char PATH_HOSTS[MAX_PATH]; char PATH_HOSTS[MAX_PATH];
if (IsNT) { if (IS_NT()) {
char tmp[MAX_PATH]; char tmp[MAX_PATH];
HKEY hkeyHosts; HKEY hkeyHosts;

View File

@ -221,7 +221,7 @@ static int file_lookup(const char *name, struct hostent **host)
#ifdef WIN32 #ifdef WIN32
char PATH_HOSTS[MAX_PATH]; char PATH_HOSTS[MAX_PATH];
if (IsNT) { if (IS_NT()) {
char tmp[MAX_PATH]; char tmp[MAX_PATH];
HKEY hkeyHosts; HKEY hkeyHosts;

View File

@ -305,7 +305,8 @@ static int get_iphlpapi_dns_info (char *ret_buf, size_t ret_size)
{ {
FIXED_INFO *fi = alloca (sizeof(*fi)); FIXED_INFO *fi = alloca (sizeof(*fi));
DWORD size = sizeof (*fi); DWORD size = sizeof (*fi);
DWORD (WINAPI *GetNetworkParams) (FIXED_INFO*, DWORD*); /* available only on Win-98/2000+ */ typedef DWORD (WINAPI* get_net_param_func) (FIXED_INFO*, DWORD*);
get_net_param_func GetNetworkParams; /* available only on Win-98/2000+ */
HMODULE handle; HMODULE handle;
IP_ADDR_STRING *ipAddr; IP_ADDR_STRING *ipAddr;
int i, count = 0; int i, count = 0;
@ -321,7 +322,7 @@ static int get_iphlpapi_dns_info (char *ret_buf, size_t ret_size)
if (!handle) if (!handle)
return (0); return (0);
(void*)GetNetworkParams = GetProcAddress (handle, "GetNetworkParams"); GetNetworkParams = (get_net_param_func) GetProcAddress (handle, "GetNetworkParams");
if (!GetNetworkParams) if (!GetNetworkParams)
goto quit; goto quit;
@ -375,7 +376,7 @@ quit:
static int init_by_resolv_conf(ares_channel channel) static int init_by_resolv_conf(ares_channel channel)
{ {
char *line = NULL; char *line = NULL;
int status, nservers = 0, nsort = 0; int status = -1, nservers = 0, nsort = 0;
struct server_state *servers = NULL; struct server_state *servers = NULL;
struct apattern *sortlist = NULL; struct apattern *sortlist = NULL;
@ -421,7 +422,7 @@ DhcpNameServer
goto okay; goto okay;
} }
if (IsNT) if (IS_NT())
{ {
if (RegOpenKeyEx( if (RegOpenKeyEx(
HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,

View File

@ -39,28 +39,34 @@ ares_strcasecmp(const char *a, const char *b)
} }
#endif #endif
/*
* Number of micro-seconds between the beginning of the Windows epoch
* (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970).
*/
#if defined(_MSC_VER) || defined(__WATCOMC__)
#define EPOCH_FILETIME 11644473600000000Ui64
#else
#define EPOCH_FILETIME 11644473600000000ULL
#endif
int int
ares_gettimeofday(struct timeval *tv, struct timezone *tz) ares_gettimeofday(struct timeval *tv, struct timezone *tz)
{ {
FILETIME ft; FILETIME ft;
LARGE_INTEGER li; LARGE_INTEGER li;
__int64 t; __int64 t;
static int tzflag;
if (tv) if (tv)
{ {
GetSystemTimeAsFileTime(&ft); GetSystemTimeAsFileTime(&ft);
li.LowPart = ft.dwLowDateTime; li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime; li.HighPart = ft.dwHighDateTime;
t = li.QuadPart; /* In 100-nanosecond intervals */ t = li.QuadPart / 10; /* In micro-second intervals */
#if 0 t -= EPOCH_FILETIME; /* Offset to the Epoch time */
t -= EPOCHFILETIME; /* Offset to the Epoch time */
#endif
t /= 10; /* In microseconds */
tv->tv_sec = (long)(t / 1000000); tv->tv_sec = (long)(t / 1000000);
tv->tv_usec = (long)(t % 1000000); tv->tv_usec = (long)(t % 1000000);
} }
(void) tz;
return 0; return 0;
} }