From: Pekka Riikonen Date: Sun, 24 Jun 2001 17:00:55 +0000 (+0000) Subject: updates. X-Git-Tag: robodoc-323~136 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=ef391ef4209fbfce60a77109d3930bc49f3cdc71 updates. --- diff --git a/CHANGES b/CHANGES index 879db1ce..0021e573 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +Sun Jun 24 19:49:23 EEST 2001 Pekka Riikonen + + * lib/contrib/regex.c is not compiled on WIN32. + + * Added silc_net_get_socket_opt function to the + lib/silcutil/silcnet.h. + + * Added includes/silcwin32.h for WIN32 specific includes + and definitions. + Sun Jun 24 12:19:52 EEST 2001 Pekka Riikonen * Moved the lib/silccore/silcsockconn.[ch] to the utility diff --git a/includes/silcincludes.h b/includes/silcincludes.h index 63f9e675..f1686d27 100644 --- a/includes/silcincludes.h +++ b/includes/silcincludes.h @@ -1,11 +1,10 @@ - /* silcincludes.h - Author: Pekka Riikonen + Author: Pekka Riikonen - Copyright (C) 1997 - 2000 Pekka Riikonen + Copyright (C) 1997 - 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 @@ -30,9 +29,7 @@ #include "silcdefs.h" #ifdef SILC_WIN32 -#include -#include -#include +#include "silcwin32.h" #endif #include diff --git a/includes/silcwin32.h b/includes/silcwin32.h new file mode 100644 index 00000000..9a0cddd8 --- /dev/null +++ b/includes/silcwin32.h @@ -0,0 +1,33 @@ +/* + + silcwin32.h + + Author: Pekka Riikonen + + 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. + +*/ +/* Native WIN32 specific includes and definitions. */ + +#ifndef SILCWIN32_H +#define SILCWIN32_H + +#include +#include +#include + +#define snprintf _snprintf +#define vsnprintf _vsnprintf + +#endif + diff --git a/lib/contrib/Makefile.am b/lib/contrib/Makefile.am index e5fcf4c4..73f34fdd 100644 --- a/lib/contrib/Makefile.am +++ b/lib/contrib/Makefile.am @@ -20,10 +20,16 @@ AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign noinst_LIBRARIES = libcontrib.a +if SILC_WIN32 +libcontrib_a_SOURCES = \ + getopt.c \ + getopt1.c +else libcontrib_a_SOURCES = \ getopt.c \ getopt1.c \ regex.c +endif EXTRA_DIST = *.h diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index dde26d53..4cd047fd 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -369,7 +369,7 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_start) SILC_LOG_DEBUG(("Start")); /* Check the socket status as it might be in error */ - getsockopt(fd, SOL_SOCKET, SO_ERROR, &opt, &opt_len); + silc_net_get_socket_opt(fd, SOL_SOCKET, SO_ERROR, &opt, &opt_len); if (opt != 0) { if (ctx->tries < 2) { /* Connection failed but lets try again */ diff --git a/lib/silcclient/client_keyagr.c b/lib/silcclient/client_keyagr.c index e4a6a25c..6ceb851f 100644 --- a/lib/silcclient/client_keyagr.c +++ b/lib/silcclient/client_keyagr.c @@ -416,7 +416,7 @@ SILC_TASK_CALLBACK(silc_client_perform_key_agreement_start) SILC_LOG_DEBUG(("Start")); /* Check the socket status as it might be in error */ - getsockopt(fd, SOL_SOCKET, SO_ERROR, &opt, &opt_len); + silc_net_get_socket_opt(fd, SOL_SOCKET, SO_ERROR, &opt, &opt_len); if (opt != 0) { if (ctx->tries < 2) { /* Connection failed but lets try again */ diff --git a/lib/silccrypt/silcrng.c b/lib/silccrypt/silcrng.c index 3aecd117..e6af9540 100644 --- a/lib/silccrypt/silcrng.c +++ b/lib/silccrypt/silcrng.c @@ -191,12 +191,15 @@ void silc_rng_init(SilcRng rng) static void silc_rng_get_soft_noise(SilcRng rng) { +#ifndef SILC_WIN32 struct tms ptime; +#endif uint32 pos; pos = silc_rng_get_position(rng); silc_rng_xor(rng, clock(), 0); +#ifndef SILC_WIN32 #ifdef HAVE_GETPID silc_rng_xor(rng, getpid(), 1); #ifdef HAVE_GETPGID @@ -222,7 +225,9 @@ static void silc_rng_get_soft_noise(SilcRng rng) silc_rng_xor(rng, (ptime.tms_stime ^ ptime.tms_cutime), pos++); silc_rng_xor(rng, (ptime.tms_cutime + ptime.tms_stime), pos++); silc_rng_xor(rng, (ptime.tms_stime << 8), pos++); +#endif silc_rng_xor(rng, clock() << 4, pos++); +#ifndef SILC_WIN32 #ifdef HAVE_GETPGID silc_rng_xor(rng, getpgid(getpid() << 8), pos++); #endif @@ -237,6 +242,7 @@ static void silc_rng_get_soft_noise(SilcRng rng) #ifdef HAVE_GETPGRP silc_rng_xor(rng, getpgrp(), pos++); #endif +#endif #ifdef SILC_RNG_DEBUG SILC_LOG_HEXDUMP(("pool"), rng->pool, sizeof(rng->pool)); @@ -265,6 +271,7 @@ static void silc_rng_get_medium_noise(SilcRng rng) static void silc_rng_get_hard_noise(SilcRng rng) { +#ifndef SILC_WIN32 char buf[32]; int fd, len, i; @@ -289,6 +296,7 @@ static void silc_rng_get_hard_noise(SilcRng rng) out: close(fd); memset(buf, 0, sizeof(buf)); +#endif } /* Execs command and gets noise from its output */ diff --git a/lib/silcutil/silcnet.c b/lib/silcutil/silcnet.c index f8e75fd0..826c2cc2 100644 --- a/lib/silcutil/silcnet.c +++ b/lib/silcutil/silcnet.c @@ -36,6 +36,13 @@ int silc_net_set_socket_opt(int sock, int level, int option, int on) return setsockopt(sock, level, option, (void *)&on, sizeof(on)); } +/* Get socket options */ + +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); +} /* Checks whether IP address sent as argument is valid IP address. */ bool silc_net_is_ip(const char *addr) diff --git a/lib/silcutil/silcnet.h b/lib/silcutil/silcnet.h index 2bb23e75..68ef0814 100644 --- a/lib/silcutil/silcnet.h +++ b/lib/silcutil/silcnet.h @@ -142,6 +142,21 @@ int silc_net_set_socket_nonblock(int sock); ***/ int silc_net_set_socket_opt(int sock, int level, int option, int on); +/****f* silcutil/SilcNetAPI/silc_net_get_socket_opt + * + * SYNOPSIS + * + * int silc_net_get_socket_opt(int sock, int level, int option, + * void *optval, int *opt_len); + * + * DESCRIPTION + * + * Return socket options to the `optval' and `opt_len'. + * + ***/ +int silc_net_get_socket_opt(int sock, int level, int option, + void *optval, int *opt_len); + /****f* silcutil/SilcNetAPI/silc_net_is_ip * * SYNOPSIS diff --git a/lib/silcutil/win32/silcwin32schedule.c b/lib/silcutil/win32/silcwin32schedule.c index 6db27fd7..2d481d96 100644 --- a/lib/silcutil/win32/silcwin32schedule.c +++ b/lib/silcutil/win32/silcwin32schedule.c @@ -72,23 +72,31 @@ int silc_select(int n, fd_set *readfds, fd_set *writefds, return 1; } - timeo = (timeout ? (timeout.tv_sec * 1000) + (timeout.tv_usec / 1000) : + timeo = (timeout ? (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000) : INFINITE); /* If we have nothing to wait and timeout is set then register a timeout and wait just for windows messages. */ if (nhandles == 0 && timeout) { UINT timer = SetTimer(NULL, 0, timeo, NULL); - if (timer) { + curtime = GetTickCount(); + while (timer) { WaitMessage(); KillTimer(NULL, timer); while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + if (msg.message == WM_TIMER) + return 0; TranslateMessage(&msg); DispatchMessage(&msg); } - return 0; + if (timeo != INFINITE) { + timeo -= GetTickCount() - curtime; + if (timeo < 0) + timeo = 0; + timer = SetTimer(NULL, 0, timeo, NULL); + } } } @@ -140,13 +148,13 @@ int silc_select(int n, fd_set *readfds, fd_set *writefds, i = 0; do { /* Set the handle to fd set */ - FD_SET(handle[ready], readfds); + FD_SET((int)handles[ready], readfds); i++; /* Check the status of the next handle and set it's fd to the fd set if data is available. */ while (++ready < n) - if (WaitForSingleObject(handle[ready], 0) == WAIT_OBJECT_0) + if (WaitForSingleObject(handles[ready], 0) == WAIT_OBJECT_0) break; } while (ready < n);