updates.
authorPekka Riikonen <priikone@silcnet.org>
Sun, 24 Jun 2001 18:10:18 +0000 (18:10 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 24 Jun 2001 18:10:18 +0000 (18:10 +0000)
CHANGES
lib/Makefile.am.pre
lib/contrib/Makefile.am
lib/silcutil/silcnet.c
lib/silcutil/silcschedule.c
lib/silcutil/silctask.c
lib/silcutil/silcutil.h
lib/silcutil/unix/silcunixutil.c
lib/silcutil/win32/Makefile.am
lib/silcutil/win32/silcwin32util.c [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index c1c2e9da8cb539430fe5dffb266550a7b2c039fd..5fed3955a779dda5f564608fcc470efe4ab5e4e5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -11,6 +11,10 @@ Sun Jun 24 19:49:23 EEST 2001  Pekka Riikonen <priikone@silcnet.org>
        * 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
index d5c989003f63258fdfd6c5ce046ecce9d1698749..60b16fb12cd8c9f525d9e3c3c60a13cde825e8de 100644 (file)
@@ -56,8 +56,16 @@ DISTCLEANFILES = libsilc.a libsilcclient.a
 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
index 73f34fdd36112ddcdac011b683f9c9346dd9043a..78f02843efde0666653762b9c9bffa722fd6c04d 100644 (file)
@@ -21,9 +21,7 @@ AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign
 noinst_LIBRARIES = libcontrib.a
 
 if SILC_WIN32
-libcontrib_a_SOURCES = \
-       getopt.c \
-       getopt1.c
+libcontrib_a_SOURCES =
 else
 libcontrib_a_SOURCES = \
        getopt.c \
index 826c2cc228659b1a91a2c0ea406062e970a37834..d92d80a69d70da8a500874c68579693ba557cf25 100644 (file)
@@ -41,7 +41,7 @@ int silc_net_set_socket_opt(int sock, int level, int option, int on)
 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. */
 
index 5a673d041a0d40bcffe729456d2a95e501c576e1..b7e99ed406dd8fa081e62668e33b5cac4d7c2037 100644 (file)
@@ -390,7 +390,7 @@ do {                                                                            \
     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. */            \
@@ -572,7 +572,7 @@ bool silc_schedule_one(SilcSchedule schedule, int timeout_usecs)
   case 0:
     /* Timeout */
     SILC_LOG_DEBUG(("Running timeout tasks"));
-    gettimeofday(&curtime, NULL);
+    silc_gettimeofday(&curtime);
     SILC_SCHEDULE_RUN_TIMEOUT_TASKS;
     break;
   default:
index 5697a3ac5986e3dee45c938d796f13a49b6e848f..5a1c6a3eb699319f2b09a9c6a20db22d614bb576 100644 (file)
@@ -312,7 +312,7 @@ SilcTask silc_task_register(SilcTaskQueue queue, int fd,
 
   /* 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) {
index 33cf92c06defea42493c172a64e575571e3ecdcb..5499f8a826445feae3116fbe34574c07489a6d87 100644 (file)
@@ -62,5 +62,6 @@ bool silc_hash_data_compare(void *key1, void *key2, void *user_context);
 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
index 2dc40e142a62b8eff70a7a53baaf4edd483616ac..581c7daf2041c603ee7cdb5797bd8430a1d9928a 100644 (file)
@@ -167,3 +167,10 @@ char *silc_get_real_name()
 
   return realname;
 }
+
+/* Return current time to struct timeval. */
+
+int silc_gettimeofday(struct timeval *p)
+{
+  return gettimeofday(p, NULL);
+}
index 14616887bd6eeb0108224cc8c1be78892acbb0bb..70e1d45f7fa0a4e7ebd50fded0176619ef6a7bba 100644 (file)
@@ -23,6 +23,7 @@ noinst_LIBRARIES = libsilcwin32util.a
 libsilcwin32util_a_SOURCES =   \
        silcwin32net.c          \
        silcwin32schedule.c     \
-       silcwin32sockconn.c
+       silcwin32sockconn.c     \
+       silcwin32util.c
 
 include $(top_srcdir)/Makefile.defines.in
diff --git a/lib/silcutil/win32/silcwin32util.c b/lib/silcutil/win32/silcwin32util.c
new file mode 100644 (file)
index 0000000..e12fa0a
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+
+  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;
+}