* Do not use ptime structure or any of the posix process
functions on WIN32 in lib/silccrypt/silrng.c.
+ * Added silc_gettimeofday to provide generic function
+ for struct timeval on all platforms. Added the function
+ to lib/silcutil/silcutil.h.
+
Sun Jun 24 12:19:52 EEST 2001 Pekka Riikonen <priikone@silcnet.org>
* Moved the lib/silccore/silcsockconn.[ch] to the utility
if SILC_DIST_CLIENT
all: remove libsilc.a libsilcclient.a
else
+if SILC_DIST_TOOLKIT
+all: remove libsilc.a libsilcclient.a
+else
+if SILC_DIST_WIN32DLL
+all: remove libsilc.a libsilcclient.a
+else
all: remove libsilc.a
endif
+endif
+endif
remove:
-rm -rf libsilc.a
noinst_LIBRARIES = libcontrib.a
if SILC_WIN32
-libcontrib_a_SOURCES = \
- getopt.c \
- getopt1.c
+libcontrib_a_SOURCES =
else
libcontrib_a_SOURCES = \
getopt.c \
int silc_net_get_socket_opt(int sock, int level, int option,
void *optval, int *opt_len)
{
- return getsockopt(sock, level, option, optval, (socklen_t *)opt_len);
+ return getsockopt(sock, level, option, optval, opt_len);
}
/* Checks whether IP address sent as argument is valid IP address. */
task = NULL; \
\
/* Get the current time */ \
- gettimeofday(&curtime, NULL); \
+ silc_gettimeofday(&curtime); \
schedule->timeout = NULL; \
\
/* First task in the task queue has always the smallest timeout. */ \
case 0:
/* Timeout */
SILC_LOG_DEBUG(("Running timeout tasks"));
- gettimeofday(&curtime, NULL);
+ silc_gettimeofday(&curtime);
SILC_SCHEDULE_RUN_TIMEOUT_TASKS;
break;
default:
/* Create timeout if marked to be timeout task */
if (((seconds + useconds) > 0) && (type == SILC_TASK_TIMEOUT)) {
- gettimeofday(&new->timeout, NULL);
+ silc_gettimeofday(&new->timeout);
new->timeout.tv_sec += seconds + (useconds / 1000000L);
new->timeout.tv_usec += (useconds % 1000000L);
if (new->timeout.tv_usec > 999999L) {
char *silc_client_chmode(uint32 mode, const char *cipher, const char *hmac);
char *silc_client_chumode(uint32 mode);
char *silc_client_chumode_char(uint32 mode);
+int silc_gettimeofday(struct timeval *p);
#endif
return realname;
}
+
+/* Return current time to struct timeval. */
+
+int silc_gettimeofday(struct timeval *p)
+{
+ return gettimeofday(p, NULL);
+}
libsilcwin32util_a_SOURCES = \
silcwin32net.c \
silcwin32schedule.c \
- silcwin32sockconn.c
+ silcwin32sockconn.c \
+ silcwin32util.c
include $(top_srcdir)/Makefile.defines.in
--- /dev/null
+/*
+
+ silcwin32util.c
+
+ Author: Pekka Riikonen <priikone@sillcnet.org>
+
+ Copyright (C) 2001 Pekka Riikonen
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+*/
+/* $Id$ */
+
+#include "silcincludes.h"
+
+#define FILETIME_1970 0x019db1ded53e8000
+const BYTE DWLEN = sizeof(DWORD) * 8;
+
+/* Return current time in struct timeval. Code ripped from some xntp
+ implementation on http://src.openresources.com. */
+
+int silc_gettimeofday(struct timeval *tv)
+{
+ FILETIME ft;
+ __int64 msec;
+
+ GetSystemTimeAsFileTime(&ft);
+ msec = (__int64) ft.dwHighDateTime << DWLEN | ft.dwLowDateTime;
+ msec = (msec - FILETIME_1970) / 10;
+ tv->tv_sec = (long) (msec / 1000000);
+ tv->tv_usec = (long) (msec % 1000000);
+
+ return 0;
+}