+Sun Jun 24 19:49:23 EEST 2001 Pekka Riikonen <priikone@silcnet.org>
+
+ * 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 <priikone@silcnet.org>
* Moved the lib/silccore/silcsockconn.[ch] to the utility
-
/*
silcincludes.h
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
- 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
#include "silcdefs.h"
#ifdef SILC_WIN32
-#include <windows.h>
-#include <dir.h>
-#include <io.h>
+#include "silcwin32.h"
#endif
#include <stdio.h>
--- /dev/null
+/*
+
+ silcwin32.h
+
+ Author: Pekka Riikonen <priikone@silcnet.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.
+
+*/
+/* Native WIN32 specific includes and definitions. */
+
+#ifndef SILCWIN32_H
+#define SILCWIN32_H
+
+#include <windows.h>
+#include <dir.h>
+#include <io.h>
+
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+
+#endif
+
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
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 */
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 */
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
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
#ifdef HAVE_GETPGRP
silc_rng_xor(rng, getpgrp(), pos++);
#endif
+#endif
#ifdef SILC_RNG_DEBUG
SILC_LOG_HEXDUMP(("pool"), rng->pool, sizeof(rng->pool));
static void silc_rng_get_hard_noise(SilcRng rng)
{
+#ifndef SILC_WIN32
char buf[32];
int fd, len, i;
out:
close(fd);
memset(buf, 0, sizeof(buf));
+#endif
}
/* Execs command and gets noise from its output */
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)
***/
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
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);
+ }
}
}
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);