diff --git a/src/acconfig.h b/src/acconfig.h
index 991d97bc85cfb4995db024a3a691c10320dd3896..41a19a38440c25bd0896a2f59dc3ad899570b3d3 100644
--- a/src/acconfig.h
+++ b/src/acconfig.h
@@ -169,6 +169,7 @@
 
 /* How to set a socket non-blocking */
 #undef USE_IOCTL_FIONBIO
+#undef USE_IOCTLSOCKET_FIONBIO
 #undef USE_FCNTL_O_NDELAY
 #undef USE_FCNTL_FNDELAY
 #undef USE_FCNTL_O_NONBLOCK
diff --git a/src/backend.c b/src/backend.c
index 05d56986faabb25aaaedbfb1d0f3b475a3e6c500..400641493abf56056f9bb6b8db3dc5501cbe7d70 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -4,13 +4,15 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: backend.c,v 1.18 1997/11/01 21:56:36 grubba Exp $");
+RCSID("$Id: backend.c,v 1.19 1997/12/23 06:26:04 hubbe Exp $");
 #include "backend.h"
 #include <errno.h>
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 #include <string.h>
 #include "interpret.h"
 #include "object.h"
diff --git a/src/configure.in b/src/configure.in
index 23763b10d64f3e466f057e6c2db6dc30e66a51a4..1de0a9d0e8178a2c315da0b491a56a4f34627031 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1,4 +1,4 @@
-AC_REVISION("$Id: configure.in,v 1.142 1997/12/22 17:38:25 hubbe Exp $")
+AC_REVISION("$Id: configure.in,v 1.143 1997/12/23 06:26:05 hubbe Exp $")
 AC_INIT(interpret.c)
 AC_CONFIG_HEADER(machine.h)
 
@@ -212,6 +212,8 @@ if test $cflags_is_set = no; then
 
   if test "x$with_cdebug" = "xno" ; then
     AC_SYS_COMPILER_FLAG(-fomit-frame-pointer,fomit_frame_pointer,OPTIMIZE)
+  else
+    CFLAGS=`echo " $CFLAGS " | sed -e 's@ -g @@g'`
   fi  
 
 ### Optimize for different SUN machines. If there is no working 'uname'
@@ -241,7 +243,10 @@ if test $cflags_is_set = no; then
 
   # OSF/1
   AC_SYS_OS_COMPILER_FLAG(OSF1,-fast,fast,OPTIMIZE)
-  AC_SYS_OS_COMPILER_FLAG(OSF1,-g3,g3,OPTIMIZE)
+
+  if test "x$with_cdebug" = "x" ; then
+    AC_SYS_OS_COMPILER_FLAG(OSF1,-g3,g3,OPTIMIZE)
+  fi
   AC_SYS_OS_COMPILER_FLAG(OSF1,-host,host,OPTIMIZE)
   AC_SYS_OS_COMPILER_FLAG(OSF1,-std1,std1,WARN)
   AC_SYS_OS_COMPILER_FLAG(OSF1,-warnprotos,warnprotos,WARN)
@@ -613,7 +618,8 @@ AC_HEADER_STDC
 AC_CHECK_HEADERS(sys/rusage.h time.h sys/time.h sys/types.h unistd.h stdlib.h \
 memory.h values.h string.h strings.h fcntl.h sys/filio.h sys/sockio.h crypt.h \
 locale.h sys/resource.h sys/select.h sys/mman.h setjmp.h limits.h pthread.h \
-thread.h dlfcn.h dld.h sys/times.h sched.h sys/procfs.h sys/param.h winsock.h)
+thread.h dlfcn.h dld.h sys/times.h sched.h sys/procfs.h sys/param.h winsock.h \
+sys/ioct.h sys/socket.h)
 
 AC_SIZEOF_TYPE(char *)
 AC_SIZEOF_TYPE(long)
@@ -1637,8 +1643,13 @@ AC_CACHE_VAL(pike_cv_sys_nonblock,
 #define USE_IOCTL_FIONBIO
 #include "$srcdir/fd_control.c"
 ], pike_cv_sys_nonblock=USE_IOCTL_FIONBIO,
+    AC_TRY_RUN([
+#define TESTING
+#define USE_IOCTLSOCKET_FIONBIO
+#include "$srcdir/fd_control.c"
+], pike_cv_sys_nonblock=USE_IOCTLSOCKET_FIONBIO,
 unset pike_cv_sys_nonblock
-    ))))
+    )))))
   fi
 ])
 
diff --git a/src/fd_control.c b/src/fd_control.c
index b139da5884a355126bd846fea33b5983e0eb5d1d..967318743cf15bf06058a623f541b86e4d8f95cf 100644
--- a/src/fd_control.c
+++ b/src/fd_control.c
@@ -4,9 +4,6 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include "fd_control.h"
 
 #ifndef TESTING
 #include "global.h"
@@ -15,6 +12,20 @@
 #undef DEBUG
 #endif
 
+#include "fd_control.h"
+
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
@@ -25,7 +36,7 @@
 #include <sys/sockio.h>
 #endif
 
-void set_nonblocking(int fd,int which)
+static void low_set_nonblocking(int fd,int which)
 {
 #ifdef DEBUG
   if(fd<0 || fd >MAX_OPEN_FILEDESCRIPTORS)
@@ -47,7 +58,14 @@ void set_nonblocking(int fd,int which)
 #ifdef USE_FCNTL_FNDELAY
   fcntl(fd, F_SETFL, which?FNDELAY:0);
 #else
+
+#ifdef USE_IOCTLSOCKET_FIONBIO
+  ioctlsocket(fd, FIONBIO, (void *)&which);
+#else
+
 #error Do not know how to set your filedescriptors nonblocking.
+
+#endif
 #endif
 #endif
 #endif
@@ -61,11 +79,6 @@ int query_nonblocking(int fd)
     fatal("Filedescriptor out of range.\n");
 #endif
 
-#ifdef USE_IOCTL_FIONBIO
-  /* I don't know how to query this!!!! */
-  return 0;
-#else
-
 #ifdef USE_FCNTL_O_NDELAY
   return fcntl(fd, F_GETFL, 0) & O_NDELAY;
 #else
@@ -77,8 +90,7 @@ int query_nonblocking(int fd)
 #ifdef USE_FCNTL_FNDELAY
   return fcntl(fd, F_GETFL, 0) & FNDELAY;
 #else
-#error Do not know how to set your filedescriptors nonblocking.
-#endif
+  return 0;
 #endif
 #endif
 #endif
@@ -86,11 +98,23 @@ int query_nonblocking(int fd)
 
 int set_close_on_exec(int fd, int which)
 {
+#ifdef F_SETFD
   return fcntl(fd, F_SETFD, !!which);
+#else
+  return 0;
+#endif
 }
 
 #ifdef TESTING
 
+
+#if defined(HAVE_WINSOCK_H) && defined(USE_IOCTLSOCKET_FIONBIO)
+int main()
+{
+  exit(0);
+}
+#else
+
 #include <signal.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -100,17 +124,156 @@ int set_close_on_exec(int fd, int which)
 RETSIGTYPE sigalrm_handler0(int tmp) { exit(0); }
 RETSIGTYPE sigalrm_handler1(int tmp) { exit(1); }
 
-main()
+/* Protected since errno may expand to a function call. */
+#ifndef errno
+extern int errno;
+#endif /* !errno */
+
+int my_socketpair(int family, int type, int protocol, int sv[2])
+{
+  static int fd=-1;
+  static struct sockaddr_in my_addr;
+  struct sockaddr_in addr,addr2;
+  int len;
+
+  MEMSET((char *)&addr,0,sizeof(struct sockaddr_in));
+
+  /* We lie, we actually create an AF_INET socket... */
+  if(family != AF_UNIX || type != SOCK_STREAM)
+  {
+    errno=EINVAL;
+    return -1; 
+  }
+
+  if(fd==-1)
+  {
+    if((fd=socket(AF_INET, SOCK_STREAM, 0)) < 0) return -1;
+    
+    /* I wonder what is most common a loopback on ip# 127.0.0.1 or
+     * a loopback with the name "localhost"?
+     * Let's hope those few people who don't have socketpair have
+     * a loopback on 127.0.0.1
+     */
+    my_addr.sin_addr.s_addr=htonl(INADDR_ANY);
+    my_addr.sin_port=htons(0);
+    
+    /* Bind our sockets on any port */
+    if(bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
+    {
+      close(fd);
+      fd=-1;
+      return -1;
+    }
+
+    /* Check what ports we got.. */
+    len=sizeof(my_addr);
+    if(getsockname(fd,(struct sockaddr *)&my_addr,&len) < 0)
+    {
+      close(fd);
+      fd=-1;
+      return -1;
+    }
+
+    /* Listen to connections on our new socket */
+    if(listen(fd, 5) < 0)
+    {
+      close(fd);
+      fd=-1;
+      return -1;
+    }
+  }
+  
+  if((sv[1]=socket(AF_INET, SOCK_STREAM, 0)) <0) return -1;
+
+  addr.sin_addr.s_addr=inet_addr("127.0.0.1");
+
+/*  set_nonblocking(sv[1],1); */
+  
+  if(connect(sv[1], (struct sockaddr *)&my_addr, sizeof(my_addr)) < 0)
+  {
+    int tmp2;
+    for(tmp2=0;tmp2<20;tmp2++)
+    {
+      int tmp;
+      len=sizeof(addr);
+      tmp=accept(fd,(struct sockaddr *)&addr,&len);
+
+      if(tmp!=-1) close(tmp);
+      if(connect(sv[1], (struct sockaddr *)&my_addr, sizeof(my_addr))>=0)
+	break;
+    }
+    if(tmp2>=20)
+      return -1;
+  }
+
+  len=sizeof(addr);
+  if(getsockname(sv[1],(struct sockaddr *)&addr2,&len) < 0) return -1;
+
+  /* Accept connection
+   * Make sure this connection was our OWN connection,
+   * otherwise some wizeguy could interfere with our
+   * pipe by guessing our socket and connecting at
+   * just the right time... Pike is supposed to be
+   * pretty safe...
+   */
+  do
+  {
+    len=sizeof(addr);
+    sv[0]=accept(fd,(struct sockaddr *)&addr,&len);
+
+    if(sv[0] < 0) {
+      close(sv[1]);
+      return -1;
+    }
+
+    /* We do not trust accept */
+    len=sizeof(addr);
+    if(getpeername(sv[0], (struct sockaddr *)&addr,&len)) return -1;
+  }while(len < (int)sizeof(addr) ||
+	 addr2.sin_addr.s_addr != addr.sin_addr.s_addr ||
+	 addr2.sin_port != addr.sin_port);
+
+/*   set_nonblocking(sv[1],0); */
+
+  return 0;
+}
+
+int socketpair_ultra(int family, int type, int protocol, int sv[2])
+{
+  int retries=0;
+
+  while(1)
+  {
+    int ret=my_socketpair(family, type, protocol, sv);
+    if(ret>=0) return ret;
+    
+    switch(errno)
+    {
+      case EAGAIN: break;
+
+#ifdef EADDRINUSE
+      case EADDRINUSE:
+#endif
+
+#ifdef WSAEADDRINUSE
+	if(retries++ > 10) return ret;
+	break;
+#endif
+
+      default:
+	return ret;
+    }
+  }
+}
+
+int main()
 {
   int tmp[2];
   char foo[1000];
 
   tmp[0]=0;
   tmp[1]=0;
-#ifdef HAVE_PIPE
-  pipe(tmp);
-#endif
-  
+
   set_nonblocking(tmp[0],1);
   signal(SIGALRM, sigalrm_handler1);
   alarm(1);
@@ -122,3 +285,4 @@ main()
   exit(1);
 }
 #endif
+#endif
diff --git a/src/lex.c b/src/lex.c
index e829172ebfc61d77afb582a948dc0a9a764b4e2e..d877f0e32e8862ce1fa455f5cc3b46f9775d3490 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: lex.c,v 1.34 1997/12/20 19:36:48 grubba Exp $");
+RCSID("$Id: lex.c,v 1.35 1997/12/23 06:26:07 hubbe Exp $");
 #include "language.h"
 #include "array.h"
 #include "lex.h"
@@ -25,7 +25,9 @@ RCSID("$Id: lex.c,v 1.34 1997/12/20 19:36:48 grubba Exp $");
 #include "mapping.h"
 
 #include "pike_macros.h"
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 #include <ctype.h>
 #include <math.h>
 #include <fcntl.h>
diff --git a/src/modules/files/acconfig.h b/src/modules/files/acconfig.h
index 5f1e0de3e69850b3dcbaf705396810777edecc7a..d4e6e3124f8dadd60a8c825d1e387e5ba852d086 100644
--- a/src/modules/files/acconfig.h
+++ b/src/modules/files/acconfig.h
@@ -1,5 +1,5 @@
 /*
- * $Id: acconfig.h,v 1.4 1997/12/02 21:28:30 grubba Exp $
+ * $Id: acconfig.h,v 1.5 1997/12/23 06:26:09 hubbe Exp $
  */
 
 #ifndef FILE_MACHINE_H
@@ -41,5 +41,11 @@
 /* Buffer size to use on open sockets */
 #undef SOCKET_BUFFER_MAX 
 
+/* Number of args to mkdir() */
+#define MKDIR_ARGS 2
+
+/* Can we declare 'extern char ** environ;' ? */
+#undef DECLARE_ENVIRON
+
 #endif
 
diff --git a/src/modules/files/configure.in b/src/modules/files/configure.in
index 796f18529502b18f28669a76ef3b48f6cebae7af..5fe7ea3976f4cbc67591537dc4e1f865bda08bed 100644
--- a/src/modules/files/configure.in
+++ b/src/modules/files/configure.in
@@ -5,13 +5,45 @@ sinclude(../module_configure.in)
 
 AC_HAVE_HEADERS(sys/types.h arpa/inet.h sys/socketvar.h netinet/in.h \
  sys/mount.h ustat.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/param.h \
- sys/socket.h sys/stream.h sys/protosw.h netdb.h sys/sysproto.h)
+ sys/socket.h sys/stream.h sys/protosw.h netdb.h sys/sysproto.h winsock.h \
+ direct.h sys/wait.h)
 AC_HEADER_DIRENT
 AC_CHECK_LIB(bind, __inet_ntoa)
 AC_CHECK_LIB(socket, socket)
 
 AC_HAVE_FUNCS(getwd perror fork1 readdir_r statvfs statfs ustat)
 
+AC_MSG_CHECKING(if we can declare environ)
+AC_CACHE_VAL(pike_cv_declare_environ,[
+AC_TRY_COMPILE([
+#include <stdlib.h>
+],[
+  extern char **environ;
+  exit(0);
+],pike_cv_declare_environ=yes,pike_cv_declare_environ=no)
+])
+
+AC_MSG_RESULT($pike_cv_declare_environ)
+if test "x$pike_cv_declare_environ" = xyes ; then
+  AC_DEFINE(DECLARE_ENVIRON)
+fi
+
+AC_MSG_CHECKING(if mkdir takes 1 or 2 arguments)
+AC_CACHE_VAL(pike_cv_func_mkdir_args,[
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <unistd.h>
+#ifdef HAVE_DIRECT_H
+#include <direct.h>
+#endif
+],[
+  mkdir("conftestdir",0666);
+],pike_cv_func_mkdir_args=2,pike_cv_func_mkdir_args=1)
+])
+
+AC_MSG_RESULT($pike_cv_func_mkdir_args)
+AC_DEFINE_UNQUOTED(MKDIR_ARGS,$pike_cv_func_mkdir_args)
+
 if test x$ac_cv_func_readdir_r = xyes ; then
   AC_MSG_CHECKING(if readdir_r takes 2(Solaris & HPUX) or 3(Posix) arguments)
   AC_CACHE_VAL(pike_cv_func_posix_readdir_r, [
diff --git a/src/modules/files/efuns.c b/src/modules/files/efuns.c
index 10b7a5062da753954906ca47d2b561f7b875fece..b366fb9159f7667ae5be9318d131b8dde0ebaf21 100644
--- a/src/modules/files/efuns.c
+++ b/src/modules/files/efuns.c
@@ -35,16 +35,27 @@
 # include <dirent.h>
 # define NAMLEN(dirent) strlen((dirent)->d_name)
 #else
-# define dirent direct
-# define NAMLEN(dirent) (dirent)->d_namlen
 # if HAVE_SYS_NDIR_H
 #  include <sys/ndir.h>
+#   define dirent direct
+#   define NAMLEN(dirent) (dirent)->d_namlen
 # endif
 # if HAVE_SYS_DIR_H
 #  include <sys/dir.h>
+#  define dirent direct
+#  define NAMLEN(dirent) (dirent)->d_namlen
 # endif
 # if HAVE_NDIR_H
 #  include <ndir.h>
+#  define dirent direct
+#  define NAMLEN(dirent) (dirent)->d_namlen
+# endif
+#endif
+
+#ifndef NAMELEN
+# if HAVE_DIRECT_H
+#  include <direct.h>
+#  define NAMLEN(dirent) strlen((dirent)->d_name)
 # endif
 #endif
 
@@ -57,7 +68,9 @@ struct array *encode_stat(struct stat *s)
   {
   case S_IFREG: ITEM(a)[1].u.integer=s->st_size; break;
   case S_IFDIR: ITEM(a)[1].u.integer=-2; break;
+#ifdef S_IFLNK
   case S_IFLNK: ITEM(a)[1].u.integer=-3; break;
+#endif
   default: ITEM(a)[1].u.integer=-4; break;
   }
   ITEM(a)[2].u.integer=s->st_atime;
@@ -336,7 +349,11 @@ void f_mkdir(INT32 args)
   }
   s=sp[-args].u.string->str;
   THREADS_ALLOW();
+#if MKDIR_ARGS == 2
   i=mkdir(s, i) != -1;
+#else
+  i=mkdir(s) != -1;
+#endif
   THREADS_DISALLOW();
   pop_n_elems(args);
   push_int(i);
@@ -568,7 +585,9 @@ void f_exece(INT32 args)
 {
   INT32 e;
   char **argv, **env;
+#ifdef DECLARE_ENVIRON
   extern char **environ;
+#endif
   struct svalue *save_sp;
   struct mapping *en;
 
diff --git a/src/modules/files/file.c b/src/modules/files/file.c
index c2f2a37faafee755d08058e6a66de97ba135036b..47721c4f1d74b8e850665cf15f570b84173e6b8f 100644
--- a/src/modules/files/file.c
+++ b/src/modules/files/file.c
@@ -6,7 +6,7 @@
 #define READ_BUFFER 8192
 
 #include "global.h"
-RCSID("$Id: file.c,v 1.61 1997/11/08 01:35:41 hubbe Exp $");
+RCSID("$Id: file.c,v 1.62 1997/12/23 06:26:10 hubbe Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "stralloc.h"
@@ -31,12 +31,26 @@ RCSID("$Id: file.c,v 1.61 1997/11/08 01:35:41 hubbe Exp $");
 #endif
 
 #include <sys/stat.h>
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
 
-#include <sys/socket.h>
+#ifdef HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+#endif
+
+#ifdef HAVE_WINSOCK_H
+#  include <winsock.h>
+#ifndef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#endif
+#ifndef EADDRINUSE
+#define EADDRINUSE WSAEADDRINUSE
+#endif
+#endif
 
 #ifdef HAVE_SYS_STREAM_H
 #include <sys/stream.h>
@@ -80,6 +94,7 @@ struct file_struct
 
 #define FD (((struct file_struct *)(fp->current_storage))->fd)
 #define ERRNO (((struct file_struct *)(fp->current_storage))->my_errno)
+#undef THIS
 #define THIS (files + FD)
 
 static struct my_file files[MAX_OPEN_FILEDESCRIPTORS];
diff --git a/src/modules/files/socket.c b/src/modules/files/socket.c
index 87a8a63e3424e864efe782deb0020ae9a7a791e0..5ed4210345c2aecd089cb3b006c6ef9cafb41f1b 100644
--- a/src/modules/files/socket.c
+++ b/src/modules/files/socket.c
@@ -21,12 +21,22 @@
 #include <sys/types.h>
 #endif
 
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
+#ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
 
 #ifdef HAVE_SYS_STREAM_H
 #include <sys/stream.h>
@@ -54,6 +64,7 @@ struct port
   struct svalue id;
 };
 
+#undef THIS
 #define THIS ((struct port *)(fp->current_storage))
 static void port_accept_callback(int fd,void *data);
 
diff --git a/src/modules/spider/accesseddb.c b/src/modules/spider/accesseddb.c
index ecea475466d24f43f5cdb2605a5bac838dfb2e82..691b28ce1c835adf4ec55a584fe965710508dd39 100644
--- a/src/modules/spider/accesseddb.c
+++ b/src/modules/spider/accesseddb.c
@@ -63,6 +63,7 @@
 #define BASE_OFFSET 48
 #define BUFFLEN 8192
 #define FUZZ 60
+#undef THIS
 #define THIS ((struct file_head *)(fp->current_storage))
 #define N_SIZE(S) (((MAX((S).len,SHORT_FILE_NAME)+sizeof(struct node)-1)/8+1)*8)
 #define HASH(X) MAX(((int)(((X)>>10)^(X))&CACHESIZE)-FUZZ,0)
diff --git a/src/modules/spider/configure.in b/src/modules/spider/configure.in
index e2d9f35b658ffb83d4a4e070ac775e7e3af58a20..3d32656977e924b7c194b05307afa85ed976d314 100644
--- a/src/modules/spider/configure.in
+++ b/src/modules/spider/configure.in
@@ -11,8 +11,8 @@ AC_CHECK_LIB(nsl, gethostbyname)
 
 AC_HAVE_HEADERS(arpa/inet.h sys/socketvar.h sys/protosw.h \
 	netinet/in.h sys/mman.h sys/utsname.h netdb.h sys/socket.h \
-        sync.h sys/sockio.h sys/conf.h stropts.h \
-	sys/uio.h linux/mman.h sys/stream.h unistd.h)
+        sync.h sys/sockio.h sys/conf.h stropts.h sys/param.h\
+	sys/uio.h linux/mman.h sys/stream.h unistd.h winsock.h)
 
 AC_FUNC_MMAP
 
diff --git a/src/modules/spider/dumudp.c b/src/modules/spider/dumudp.c
index fb6f4019467da31a3d9dfe2d2ac35b8c1f601b4f..d5dd9857564423badd93d53e9c0f54315477b103 100644
--- a/src/modules/spider/dumudp.c
+++ b/src/modules/spider/dumudp.c
@@ -1,7 +1,7 @@
 #include "config.h"
 
 #include "global.h"
-RCSID("$Id: dumudp.c,v 1.28 1997/12/07 21:58:12 grubba Exp $");
+RCSID("$Id: dumudp.c,v 1.29 1997/12/23 06:26:12 hubbe Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "stralloc.h"
@@ -21,11 +21,27 @@ RCSID("$Id: dumudp.c,v 1.28 1997/12/07 21:58:12 grubba Exp $");
 #endif
 
 #include <sys/stat.h>
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+
+#if ! defined(EWOULDBLOCK) && defined(WSAEWOULDBLOCK)
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#endif
+#if ! defined(EADDRINUSE) && defined(WSAEADDRINUSE)
+#define EADDRINUSE WSAEADDRINUSE
+#endif
+
 
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
@@ -65,6 +81,7 @@ struct dumudp {
   struct svalue read_callback;
 };
 
+#undef THIS
 #define THIS ((struct dumudp *)fp->current_storage)
 #define FD (THIS->fd)
 
@@ -179,7 +196,9 @@ void udp_read(INT32 args)
      case EBADF:
       set_read_callback( FD, 0, 0 );
       error("Socket closed\n");
+#ifdef ESTALE
      case ESTALE:
+#endif
      case EIO:
       set_read_callback( FD, 0, 0 );
       error("I/O error\n");
@@ -188,8 +207,10 @@ void udp_read(INT32 args)
      case ENOSR:
 #endif /* ENOSR */
       error("Out of memory\n");
+#ifdef ENOTSOCK
      case ENOTSOCK:
       fatal("reading from non-socket fd!!!\n");
+#endif
      case EWOULDBLOCK:
       push_int( 0 );
       return;
@@ -256,7 +277,9 @@ void udp_sendto(INT32 args)
   {
     switch(errno)
     {
+#ifdef EMSGSIZE
      case EMSGSIZE:
+#endif
       error("Too big message\n");
      case EBADF:
       set_read_callback( FD, 0, 0 );
@@ -267,9 +290,11 @@ void udp_sendto(INT32 args)
 #endif /* ENOSR */
       error("Out of memory\n");
      case EINVAL:
+#ifdef ENOTSOCK
      case ENOTSOCK:
       set_read_callback( FD, 0, 0 );
       error("Not a socket!!!\n");
+#endif
      case EWOULDBLOCK:
       return;
     }
diff --git a/src/modules/system/configure.in b/src/modules/system/configure.in
index 6fa51a174c12e949f6ffe37cc7b699bb8836f664..8c5c3fec8320ba4a259d074aa6f382cd56655b9c 100644
--- a/src/modules/system/configure.in
+++ b/src/modules/system/configure.in
@@ -9,11 +9,11 @@ AC_CHECK_LIB(nsl, gethostbyname)
 
 AC_HAVE_HEADERS(syslog.h sys/syslog.h sys/types.h errno.h unistd.h pwd.h \
 	sys/conf.h sys/socket.h netinet/in.h arpa/inet.h netdb.h stdarg.h \
-	sys/utsname.h pwd.h passwd.h shadow.h grp.h sys/stat.h)
+	sys/utsname.h pwd.h passwd.h shadow.h grp.h sys/stat.h winsock.h)
 
 AC_HAVE_FUNCS(syslog link symlink readlink \
 	initgroups setgroups seteuid setresuid setegid setresgid \
-        geteuid getpgrp getpgid getppid \
+        geteuid getpgrp getpgid getppid getuid getgid setuid setgid \
 	getpwnam getspnam getpwent setpwent endpwent \
 	chroot fchroot uname gethostname gethostbyname)
 
diff --git a/src/modules/system/system.c b/src/modules/system/system.c
index deb83401e3b9aae14ae86c73ef003f6ddb09e6c7..15e56a3caff0ee62b7d14f308706cee1b7b23748 100644
--- a/src/modules/system/system.c
+++ b/src/modules/system/system.c
@@ -1,5 +1,5 @@
 /*
- * $Id: system.c,v 1.31 1997/12/07 22:01:35 grubba Exp $
+ * $Id: system.c,v 1.32 1997/12/23 06:26:14 hubbe Exp $
  *
  * System-call module for Pike
  *
@@ -14,7 +14,7 @@
 #include "system.h"
 
 #include "global.h"
-RCSID("$Id: system.c,v 1.31 1997/12/07 22:01:35 grubba Exp $");
+RCSID("$Id: system.c,v 1.32 1997/12/23 06:26:14 hubbe Exp $");
 #include "module_support.h"
 #include "las.h"
 #include "interpret.h"
@@ -59,6 +59,10 @@ RCSID("$Id: system.c,v 1.31 1997/12/07 22:01:35 grubba Exp $");
 #include <sys/stat.h>
 #endif /* HAVE_SYS_STAT_H */
 
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+
 /*
  * Functions
  */
@@ -302,7 +306,8 @@ void f_cleargroups(INT32 args)
 /* int setgroup(array(int) gids) */
 /* NOT Implemented in Pike 0.5 */
 #endif /* HAVE_SETGROUPS */
- 
+
+#ifdef HAVE_SETUID 
 void f_setuid(INT32 args)
 {
   INT32 id;
@@ -320,7 +325,9 @@ void f_setuid(INT32 args)
   setuid(id);
   pop_n_elems(args-1);
 }
+#endif
 
+#ifdef HAVE_SETGID
 void f_setgid(INT32 args)
 {
   int id;
@@ -338,6 +345,7 @@ void f_setgid(INT32 args)
   setgid(id);
   pop_n_elems(args-1);
 }
+#endif
 
 #if defined(HAVE_SETEUID) || defined(HAVE_SETRESUID)
 /* int seteuid(int euid) */
@@ -425,8 +433,13 @@ void f_getpgrp(INT32 args)
 
 #define f_get(X,Y) void X(INT32 args){ pop_n_elems(args); push_int((INT32)Y()); }
 
+#ifdef HAVE_GETUID
 f_get(f_getuid, getuid)
+#endif
+
+#ifdef HAVE_GETGID
 f_get(f_getgid, getgid)
+#endif
  
 #ifdef HAVE_GETEUID
 f_get(f_geteuid, geteuid)
@@ -798,8 +811,12 @@ void pike_module_init(void)
   /* NOT Implemented in Pike 0.5 */
   /* add_efun("setgroups", f_setgroups, "function(array(int):int)", OPT_SIDE_EFFECT); */
 #endif /* HAVE_SETGROUPS */
+#ifdef HAVE_SETUID
   add_efun("setuid", f_setuid, "function(int:void)", OPT_SIDE_EFFECT);
+#endif
+#ifdef HAVE_SETGID
   add_efun("setgid", f_setgid, "function(int:void)", OPT_SIDE_EFFECT);
+#endif
 #if defined(HAVE_SETEUID) || defined(HAVE_SETRESUID)
   add_efun("seteuid", f_seteuid, "function(int:int)", OPT_SIDE_EFFECT);
 #endif /* HAVE_SETEUID || HAVE_SETRESUID */
@@ -807,8 +824,13 @@ void pike_module_init(void)
   add_efun("setegid", f_setegid, "function(int:int)", OPT_SIDE_EFFECT);
 #endif /* HAVE_SETEGID || HAVE_SETRESGID */
 
+#ifdef HAVE_GETUID
   add_efun("getuid", f_getuid, "function(:int)", OPT_EXTERNAL_DEPEND);
+#endif
+
+#ifdef HAVE_GETGID
   add_efun("getgid", f_getgid, "function(:int)", OPT_EXTERNAL_DEPEND);
+#endif
  
 #ifdef HAVE_GETEUID
   add_efun("geteuid", f_geteuid, "function(:int)", OPT_EXTERNAL_DEPEND);
diff --git a/src/pike_macros.h b/src/pike_macros.h
index 30b4cd35b8aefb4341098de35cbf0289b3a974fd..cf44e79140226d499f4aaa79a0653a8ef1fd7102 100644
--- a/src/pike_macros.h
+++ b/src/pike_macros.h
@@ -6,7 +6,12 @@
 #ifndef MACROS_H
 #define MACROS_H
 
+#include <global.h>
+
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
+
 #include "pike_memory.h"
 
 #define OFFSETOF(str_type, field) ((long)& (((struct str_type *)0)->field))
diff --git a/src/signal_handler.c b/src/signal_handler.c
index 0b2f26b7b80257585e2e5db16b8a8912fba99827..326dd82ee366be44a486691cb73ce81b43dccadc 100644
--- a/src/signal_handler.c
+++ b/src/signal_handler.c
@@ -13,7 +13,9 @@
 #include "error.h"
 #include "callback.h"
 #include <signal.h>
+#ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
+#endif
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -223,8 +225,10 @@ static RETSIGTYPE sig_child(int arg)
 #endif /* HAVE_WAITPID */
 
 #ifdef SIGNAL_ONESHOT
+#ifdef SIGCHLD
   my_signal(SIGCHLD, sig_child);
 #endif
+#endif
 }
 
 static RETSIGTYPE receive_signal(int signum)
@@ -236,7 +240,9 @@ static RETSIGTYPE receive_signal(int signum)
   if(tmp != lastsig)
     sigbuf[firstsig=tmp]=signum;
 
+#ifdef SIGCHLD
   if(signum==SIGCHLD) sig_child(signum);
+#endif
 
   wake_up_backend();
 
@@ -345,13 +351,17 @@ static void f_signal(int args)
 
     switch(signum)
     {
+#ifdef SIGCHLD
     case SIGCHLD:
       func=sig_child;
       break;
+#endif
 
+#ifdef SIGPIPE
     case SIGPIPE:
       func=(sigfunctype) SIG_IGN;
       break;
+#endif
 
     default:
       func=(sigfunctype) SIG_DFL;
@@ -461,8 +471,13 @@ void init_signals(void)
 {
   int e;
 
+#ifdef SIGCHLD
   my_signal(SIGCHLD, sig_child);
+#endif
+
+#ifdef SIGPIPE
   my_signal(SIGPIPE, SIG_IGN);
+#endif
 
   for(e=0;e<MAX_SIGNALS;e++)
     signal_callbacks[e].type=T_INT;
diff --git a/src/time_stuff.h b/src/time_stuff.h
index 9e10b88754771a82e396aa5c8dac2666e3a9c57e..49900b51bcde7afd81bdfe657c2bccd7e384ef33 100644
--- a/src/time_stuff.h
+++ b/src/time_stuff.h
@@ -21,6 +21,11 @@
 # endif
 #endif
 
+#ifdef HAVE_WINSOCK_H
+# include <winsock.h>
+# undef HAVE_WINSOCK_H
+#endif
+
 #undef HAVE_SYS_TIME_H
 #undef HAVE_TIME_H
 #undef TIME_WITH_SYS_TIME
diff --git a/src/version.c b/src/version.c
index 6eb2485de9036c968978ff78a7de16c1a8cabf4c..448fa29737c11b163a24316dfd269ab85fb4a4a2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -12,5 +12,5 @@
 void f_version(INT32 args)
 {
   pop_n_elems(args);
-  push_text("Pike v0.5 release 45");
+  push_text("Pike v0.6 release 0");
 }