summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--otherlibs/unix/.depend178
-rw-r--r--otherlibs/unix/accept.c2
-rw-r--r--otherlibs/unix/access.c2
-rw-r--r--otherlibs/unix/addrofstr.c4
-rw-r--r--otherlibs/unix/alarm.c2
-rw-r--r--otherlibs/unix/bind.c2
-rw-r--r--otherlibs/unix/chdir.c2
-rw-r--r--otherlibs/unix/chmod.c2
-rw-r--r--otherlibs/unix/chown.c2
-rw-r--r--otherlibs/unix/chroot.c2
-rw-r--r--otherlibs/unix/close.c2
-rw-r--r--otherlibs/unix/closedir.c2
-rw-r--r--otherlibs/unix/connect.c2
-rw-r--r--otherlibs/unix/cstringv.c2
-rw-r--r--otherlibs/unix/dup.c2
-rw-r--r--otherlibs/unix/dup2.c2
-rw-r--r--otherlibs/unix/execv.c2
-rw-r--r--otherlibs/unix/execve.c2
-rw-r--r--otherlibs/unix/execvp.c20
-rw-r--r--otherlibs/unix/exit.c2
-rw-r--r--otherlibs/unix/fchmod.c2
-rw-r--r--otherlibs/unix/fchown.c2
-rw-r--r--otherlibs/unix/fcntl.c2
-rw-r--r--otherlibs/unix/fork.c2
-rw-r--r--otherlibs/unix/ftruncate.c2
-rw-r--r--otherlibs/unix/getcwd.c6
-rw-r--r--otherlibs/unix/getegid.c2
-rw-r--r--otherlibs/unix/geteuid.c2
-rw-r--r--otherlibs/unix/getgid.c2
-rw-r--r--otherlibs/unix/getgr.c2
-rw-r--r--otherlibs/unix/getgroups.c2
-rw-r--r--otherlibs/unix/gethost.c4
-rw-r--r--otherlibs/unix/gethostname.c6
-rw-r--r--otherlibs/unix/getlogin.c2
-rw-r--r--otherlibs/unix/getpeername.c2
-rw-r--r--otherlibs/unix/getpid.c2
-rw-r--r--otherlibs/unix/getppid.c2
-rw-r--r--otherlibs/unix/getproto.c6
-rw-r--r--otherlibs/unix/getpw.c2
-rw-r--r--otherlibs/unix/getserv.c7
-rw-r--r--otherlibs/unix/getsockname.c2
-rw-r--r--otherlibs/unix/gettimeofday.c2
-rw-r--r--otherlibs/unix/getuid.c2
-rw-r--r--otherlibs/unix/gmtime.c2
-rw-r--r--otherlibs/unix/ioctl.c2
-rw-r--r--otherlibs/unix/itimer.c2
-rw-r--r--otherlibs/unix/kill.c2
-rw-r--r--otherlibs/unix/link.c2
-rw-r--r--otherlibs/unix/listen.c2
-rw-r--r--otherlibs/unix/lockf.c2
-rw-r--r--otherlibs/unix/lseek.c2
-rw-r--r--otherlibs/unix/mkdir.c2
-rw-r--r--otherlibs/unix/mkfifo.c2
-rw-r--r--otherlibs/unix/nice.c2
-rw-r--r--otherlibs/unix/open.c2
-rw-r--r--otherlibs/unix/opendir.c2
-rw-r--r--otherlibs/unix/pause.c2
-rw-r--r--otherlibs/unix/pipe.c2
-rw-r--r--otherlibs/unix/read.c2
-rw-r--r--otherlibs/unix/readdir.c2
-rw-r--r--otherlibs/unix/readlink.c2
-rw-r--r--otherlibs/unix/rename.c2
-rw-r--r--otherlibs/unix/rewinddir.c2
-rw-r--r--otherlibs/unix/rmdir.c2
-rw-r--r--otherlibs/unix/select.c2
-rw-r--r--otherlibs/unix/sendrecv.c2
-rw-r--r--otherlibs/unix/setgid.c2
-rw-r--r--otherlibs/unix/setuid.c2
-rw-r--r--otherlibs/unix/shutdown.c2
-rw-r--r--otherlibs/unix/sleep.c2
-rw-r--r--otherlibs/unix/socket.c2
-rw-r--r--otherlibs/unix/socketaddr.c6
-rw-r--r--otherlibs/unix/socketaddr.h1
-rw-r--r--otherlibs/unix/socketpair.c2
-rw-r--r--otherlibs/unix/sockopt.c2
-rw-r--r--otherlibs/unix/stat.c5
-rw-r--r--otherlibs/unix/strofaddr.c4
-rw-r--r--otherlibs/unix/symlink.c2
-rw-r--r--otherlibs/unix/termios.c2
-rw-r--r--otherlibs/unix/time.c2
-rw-r--r--otherlibs/unix/times.c2
-rw-r--r--otherlibs/unix/truncate.c2
-rw-r--r--otherlibs/unix/umask.c2
-rw-r--r--otherlibs/unix/unix.ml11
-rw-r--r--otherlibs/unix/unix.mli11
-rw-r--r--otherlibs/unix/unixsupport.c2
-rw-r--r--otherlibs/unix/unixsupport.h (renamed from otherlibs/unix/unix.h)0
-rw-r--r--otherlibs/unix/unlink.c2
-rw-r--r--otherlibs/unix/utimes.c6
-rw-r--r--otherlibs/unix/wait.c2
-rw-r--r--otherlibs/unix/write.c2
91 files changed, 245 insertions, 180 deletions
diff --git a/otherlibs/unix/.depend b/otherlibs/unix/.depend
index acc90c0af..6efce8cbd 100644
--- a/otherlibs/unix/.depend
+++ b/otherlibs/unix/.depend
@@ -1,91 +1,91 @@
-accept.o : accept.c unix.h socketaddr.h
-access.o : access.c unix.h
-addrofstr.o : addrofstr.c unix.h socketaddr.h
-alarm.o : alarm.c unix.h
-bind.o : bind.c unix.h socketaddr.h
-chdir.o : chdir.c unix.h
-chmod.o : chmod.c unix.h
-chown.o : chown.c unix.h
-chroot.o : chroot.c unix.h
-close.o : close.c unix.h
-closedir.o : closedir.c unix.h
-connect.o : connect.c unix.h socketaddr.h
-cst2constr.o : cst2constr.c cst2constr.h
-cstringv.o : cstringv.c unix.h
-dup.o : dup.c unix.h
-dup2.o : dup2.c unix.h
-envir.o : envir.c
-errmsg.o : errmsg.c
-execv.o : execv.c unix.h
-execve.o : execve.c unix.h
-execvp.o : execvp.c unix.h
-exit.o : exit.c unix.h
-fchmod.o : fchmod.c unix.h
-fchown.o : fchown.c unix.h
-fcntl.o : fcntl.c unix.h
-fork.o : fork.c unix.h
-ftruncate.o : ftruncate.c unix.h
-getcwd.o : getcwd.c unix.h
-getegid.o : getegid.c unix.h
-geteuid.o : geteuid.c unix.h
-getgid.o : getgid.c unix.h
-getgr.o : getgr.c unix.h
-getgroups.o : getgroups.c unix.h
-gethost.o : gethost.c unix.h socketaddr.h
-gethostname.o : gethostname.c unix.h
-getlogin.o : getlogin.c unix.h
-getpeername.o : getpeername.c unix.h socketaddr.h
-getpid.o : getpid.c unix.h
-getppid.o : getppid.c unix.h
-getproto.o : getproto.c unix.h
-getpw.o : getpw.c unix.h
-getserv.o : getserv.c unix.h
-getsockname.o : getsockname.c unix.h socketaddr.h
-gettimeofday.o : gettimeofday.c unix.h
-getuid.o : getuid.c unix.h
-gmtime.o : gmtime.c unix.h
-ioctl.o : ioctl.c unix.h
-itimer.o : itimer.c unix.h
-kill.o : kill.c unix.h
-link.o : link.c unix.h
-listen.o : listen.c unix.h
-lockf.o : lockf.c unix.h
-lseek.o : lseek.c unix.h
-mkdir.o : mkdir.c unix.h
-mkfifo.o : mkfifo.c unix.h
-nice.o : nice.c unix.h
-open.o : open.c unix.h
-opendir.o : opendir.c unix.h
-pause.o : pause.c unix.h
-pipe.o : pipe.c unix.h
-read.o : read.c unix.h
-readdir.o : readdir.c unix.h
-readlink.o : readlink.c unix.h
-rename.o : rename.c unix.h
-rewinddir.o : rewinddir.c unix.h
-rmdir.o : rmdir.c unix.h
-select.o : select.c unix.h
-sendrecv.o : sendrecv.c unix.h socketaddr.h
-setgid.o : setgid.c unix.h
-setuid.o : setuid.c unix.h
-shutdown.o : shutdown.c unix.h
-sleep.o : sleep.c unix.h
-socket.o : socket.c unix.h
-socketaddr.o : socketaddr.c unix.h socketaddr.h
-socketpair.o : socketpair.c unix.h
-sockopt.o : sockopt.c unix.h
-stat.o : stat.c unix.h cst2constr.h
-strofaddr.o : strofaddr.c unix.h socketaddr.h
-symlink.o : symlink.c unix.h
-termios.o : termios.c unix.h
-time.o : time.c unix.h
-times.o : times.c unix.h
-truncate.o : truncate.c unix.h
-umask.o : umask.c unix.h
-unixsupport.o : unixsupport.c unix.h cst2constr.h
-unlink.o : unlink.c unix.h
-utimes.o : utimes.c unix.h
-wait.o : wait.c unix.h
-write.o : write.c unix.h
+accept.o: accept.c unixsupport.h socketaddr.h
+access.o: access.c unixsupport.h
+addrofstr.o: addrofstr.c unixsupport.h socketaddr.h
+alarm.o: alarm.c unixsupport.h
+bind.o: bind.c unixsupport.h socketaddr.h
+chdir.o: chdir.c unixsupport.h
+chmod.o: chmod.c unixsupport.h
+chown.o: chown.c unixsupport.h
+chroot.o: chroot.c unixsupport.h
+close.o: close.c unixsupport.h
+closedir.o: closedir.c unixsupport.h
+connect.o: connect.c unixsupport.h socketaddr.h
+cst2constr.o: cst2constr.c cst2constr.h
+cstringv.o: cstringv.c unixsupport.h
+dup.o: dup.c unixsupport.h
+dup2.o: dup2.c unixsupport.h
+envir.o: envir.c
+errmsg.o: errmsg.c
+execv.o: execv.c unixsupport.h
+execve.o: execve.c unixsupport.h
+execvp.o: execvp.c unixsupport.h
+exit.o: exit.c unixsupport.h
+fchmod.o: fchmod.c unixsupport.h
+fchown.o: fchown.c unixsupport.h
+fcntl.o: fcntl.c unixsupport.h
+fork.o: fork.c unixsupport.h
+ftruncate.o: ftruncate.c unixsupport.h
+getcwd.o: getcwd.c unixsupport.h
+getegid.o: getegid.c unixsupport.h
+geteuid.o: geteuid.c unixsupport.h
+getgid.o: getgid.c unixsupport.h
+getgr.o: getgr.c unixsupport.h
+getgroups.o: getgroups.c unixsupport.h
+gethost.o: gethost.c unixsupport.h socketaddr.h
+gethostname.o: gethostname.c unixsupport.h
+getlogin.o: getlogin.c unixsupport.h
+getpeername.o: getpeername.c unixsupport.h socketaddr.h
+getpid.o: getpid.c unixsupport.h
+getppid.o: getppid.c unixsupport.h
+getproto.o: getproto.c unixsupport.h
+getpw.o: getpw.c unixsupport.h
+getserv.o: getserv.c unixsupport.h
+getsockname.o: getsockname.c unixsupport.h socketaddr.h
+gettimeofday.o: gettimeofday.c unixsupport.h
+getuid.o: getuid.c unixsupport.h
+gmtime.o: gmtime.c unixsupport.h
+ioctl.o: ioctl.c unixsupport.h
+itimer.o: itimer.c unixsupport.h
+kill.o: kill.c unixsupport.h
+link.o: link.c unixsupport.h
+listen.o: listen.c unixsupport.h
+lockf.o: lockf.c unixsupport.h
+lseek.o: lseek.c unixsupport.h
+mkdir.o: mkdir.c unixsupport.h
+mkfifo.o: mkfifo.c unixsupport.h
+nice.o: nice.c unixsupport.h
+open.o: open.c unixsupport.h
+opendir.o: opendir.c unixsupport.h
+pause.o: pause.c unixsupport.h
+pipe.o: pipe.c unixsupport.h
+read.o: read.c unixsupport.h
+readdir.o: readdir.c unixsupport.h
+readlink.o: readlink.c unixsupport.h
+rename.o: rename.c unixsupport.h
+rewinddir.o: rewinddir.c unixsupport.h
+rmdir.o: rmdir.c unixsupport.h
+select.o: select.c unixsupport.h
+sendrecv.o: sendrecv.c unixsupport.h socketaddr.h
+setgid.o: setgid.c unixsupport.h
+setuid.o: setuid.c unixsupport.h
+shutdown.o: shutdown.c unixsupport.h
+sleep.o: sleep.c unixsupport.h
+socket.o: socket.c unixsupport.h
+socketaddr.o: socketaddr.c unixsupport.h socketaddr.h
+socketpair.o: socketpair.c unixsupport.h
+sockopt.o: sockopt.c unixsupport.h
+stat.o: stat.c unixsupport.h cst2constr.h
+strofaddr.o: strofaddr.c unixsupport.h socketaddr.h
+symlink.o: symlink.c unixsupport.h
+termios.o: termios.c unixsupport.h
+time.o: time.c unixsupport.h
+times.o: times.c unixsupport.h
+truncate.o: truncate.c unixsupport.h
+umask.o: umask.c unixsupport.h
+unixsupport.o: unixsupport.c unixsupport.h cst2constr.h
+unlink.o: unlink.c unixsupport.h
+utimes.o: utimes.c unixsupport.h
+wait.o: wait.c unixsupport.h
+write.o: write.c unixsupport.h
unix.cmo: unix.cmi
unix.cmx: unix.cmi
diff --git a/otherlibs/unix/accept.c b/otherlibs/unix/accept.c
index 2b7940e2b..b2e1c9d5c 100644
--- a/otherlibs/unix/accept.c
+++ b/otherlibs/unix/accept.c
@@ -14,7 +14,7 @@
#include <mlvalues.h>
#include <alloc.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
diff --git a/otherlibs/unix/access.c b/otherlibs/unix/access.c
index 96ef61c0e..4041a1780 100644
--- a/otherlibs/unix/access.c
+++ b/otherlibs/unix/access.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_UNISTD
#include <unistd.h>
diff --git a/otherlibs/unix/addrofstr.c b/otherlibs/unix/addrofstr.c
index 3a376bd38..0e47c8d83 100644
--- a/otherlibs/unix/addrofstr.c
+++ b/otherlibs/unix/addrofstr.c
@@ -13,14 +13,12 @@
#include <mlvalues.h>
#include <fail.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
#include "socketaddr.h"
-extern unsigned long inet_addr();
-
value unix_inet_addr_of_string(s) /* ML */
value s;
{
diff --git a/otherlibs/unix/alarm.c b/otherlibs/unix/alarm.c
index 76709c904..c9224313f 100644
--- a/otherlibs/unix/alarm.c
+++ b/otherlibs/unix/alarm.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_alarm(t) /* ML */
value t;
diff --git a/otherlibs/unix/bind.c b/otherlibs/unix/bind.c
index 5c0aaa3e4..11bbec0aa 100644
--- a/otherlibs/unix/bind.c
+++ b/otherlibs/unix/bind.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
diff --git a/otherlibs/unix/chdir.c b/otherlibs/unix/chdir.c
index c1f21ef87..ccd502347 100644
--- a/otherlibs/unix/chdir.c
+++ b/otherlibs/unix/chdir.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_chdir(path) /* ML */
value path;
diff --git a/otherlibs/unix/chmod.c b/otherlibs/unix/chmod.c
index 07a84d6a1..1dbfc3702 100644
--- a/otherlibs/unix/chmod.c
+++ b/otherlibs/unix/chmod.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_chmod(path, perm) /* ML */
value path, perm;
diff --git a/otherlibs/unix/chown.c b/otherlibs/unix/chown.c
index de2f74086..1457c325c 100644
--- a/otherlibs/unix/chown.c
+++ b/otherlibs/unix/chown.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_chown(path, uid, gid) /* ML */
value path, uid, gid;
diff --git a/otherlibs/unix/chroot.c b/otherlibs/unix/chroot.c
index 5c074f007..864690367 100644
--- a/otherlibs/unix/chroot.c
+++ b/otherlibs/unix/chroot.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_chroot(path) /* ML */
value path;
diff --git a/otherlibs/unix/close.c b/otherlibs/unix/close.c
index 41dfca5e9..e750c0dc0 100644
--- a/otherlibs/unix/close.c
+++ b/otherlibs/unix/close.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_close(fd) /* ML */
value fd;
diff --git a/otherlibs/unix/closedir.c b/otherlibs/unix/closedir.c
index 985a7d333..c0feae1f9 100644
--- a/otherlibs/unix/closedir.c
+++ b/otherlibs/unix/closedir.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <sys/types.h>
#ifdef HAS_DIRENT
#include <dirent.h>
diff --git a/otherlibs/unix/connect.c b/otherlibs/unix/connect.c
index ad16fde7a..77b172014 100644
--- a/otherlibs/unix/connect.c
+++ b/otherlibs/unix/connect.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
diff --git a/otherlibs/unix/cstringv.c b/otherlibs/unix/cstringv.c
index 9563b5e6a..b7a8619e4 100644
--- a/otherlibs/unix/cstringv.c
+++ b/otherlibs/unix/cstringv.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
char ** cstringvect(arg)
value arg;
diff --git a/otherlibs/unix/dup.c b/otherlibs/unix/dup.c
index 4feaf44fd..c3c8d881c 100644
--- a/otherlibs/unix/dup.c
+++ b/otherlibs/unix/dup.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_dup(fd) /* ML */
value fd;
diff --git a/otherlibs/unix/dup2.c b/otherlibs/unix/dup2.c
index 1e9af1b76..242885778 100644
--- a/otherlibs/unix/dup2.c
+++ b/otherlibs/unix/dup2.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_DUP2
diff --git a/otherlibs/unix/execv.c b/otherlibs/unix/execv.c
index 7df864208..755b2406e 100644
--- a/otherlibs/unix/execv.c
+++ b/otherlibs/unix/execv.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
extern char ** cstringvect();
diff --git a/otherlibs/unix/execve.c b/otherlibs/unix/execve.c
index 6d1a2fb4a..52fc28f19 100644
--- a/otherlibs/unix/execve.c
+++ b/otherlibs/unix/execve.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
extern char ** cstringvect();
diff --git a/otherlibs/unix/execvp.c b/otherlibs/unix/execvp.c
index 579f08faa..870075bd9 100644
--- a/otherlibs/unix/execvp.c
+++ b/otherlibs/unix/execvp.c
@@ -13,9 +13,10 @@
#include <mlvalues.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
extern char ** cstringvect();
+extern char ** environ;
value unix_execvp(path, args) /* ML */
value path, args;
@@ -29,3 +30,20 @@ value unix_execvp(path, args) /* ML */
/* from smart compilers */
}
+value unix_execvpe(path, args, env) /* ML */
+ value path, args, env;
+{
+ char ** argv;
+ char ** saved_environ;
+ argv = cstringvect(args);
+ saved_environ = environ;
+ environ = cstringvect(env);
+ (void) execvp(String_val(path), argv);
+ stat_free((char *) argv);
+ stat_free((char *) environ);
+ environ = saved_environ;
+ uerror("execvp", path);
+ return Val_unit; /* never reached, but suppress warnings */
+ /* from smart compilers */
+}
+
diff --git a/otherlibs/unix/exit.c b/otherlibs/unix/exit.c
index 9eba09ba5..8317ddbcd 100644
--- a/otherlibs/unix/exit.c
+++ b/otherlibs/unix/exit.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_exit(n) /* ML */
value n;
diff --git a/otherlibs/unix/fchmod.c b/otherlibs/unix/fchmod.c
index d0fea9b50..22da62215 100644
--- a/otherlibs/unix/fchmod.c
+++ b/otherlibs/unix/fchmod.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_FCHMOD
diff --git a/otherlibs/unix/fchown.c b/otherlibs/unix/fchown.c
index df23d4d76..3272a3043 100644
--- a/otherlibs/unix/fchown.c
+++ b/otherlibs/unix/fchown.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_FCHMOD
diff --git a/otherlibs/unix/fcntl.c b/otherlibs/unix/fcntl.c
index 54f4a7a3c..1324aa2bc 100644
--- a/otherlibs/unix/fcntl.c
+++ b/otherlibs/unix/fcntl.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_UNISTD
#include <unistd.h>
#endif
diff --git a/otherlibs/unix/fork.c b/otherlibs/unix/fork.c
index 748cc6955..82c4fde4c 100644
--- a/otherlibs/unix/fork.c
+++ b/otherlibs/unix/fork.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_fork(unit) /* ML */
value unit;
diff --git a/otherlibs/unix/ftruncate.c b/otherlibs/unix/ftruncate.c
index 5748238e6..e0b68ab4c 100644
--- a/otherlibs/unix/ftruncate.c
+++ b/otherlibs/unix/ftruncate.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_TRUNCATE
diff --git a/otherlibs/unix/getcwd.c b/otherlibs/unix/getcwd.c
index cf7a94ef7..5d97b0ba4 100644
--- a/otherlibs/unix/getcwd.c
+++ b/otherlibs/unix/getcwd.c
@@ -13,11 +13,15 @@
#include <mlvalues.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_GETCWD
+#ifndef _WIN32
#include <sys/param.h>
+#else
+#define MAXPATHLEN 512
+#endif
value unix_getcwd() /* ML */
{
diff --git a/otherlibs/unix/getegid.c b/otherlibs/unix/getegid.c
index d9bc680bf..43f38d04d 100644
--- a/otherlibs/unix/getegid.c
+++ b/otherlibs/unix/getegid.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_getegid() /* ML */
{
diff --git a/otherlibs/unix/geteuid.c b/otherlibs/unix/geteuid.c
index 287289274..a77b646fc 100644
--- a/otherlibs/unix/geteuid.c
+++ b/otherlibs/unix/geteuid.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_geteuid() /* ML */
{
diff --git a/otherlibs/unix/getgid.c b/otherlibs/unix/getgid.c
index 6595ffdef..5cc3899f1 100644
--- a/otherlibs/unix/getgid.c
+++ b/otherlibs/unix/getgid.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_getgid() /* ML */
{
diff --git a/otherlibs/unix/getgr.c b/otherlibs/unix/getgr.c
index 9217ab267..b1538e4c1 100644
--- a/otherlibs/unix/getgr.c
+++ b/otherlibs/unix/getgr.c
@@ -15,7 +15,7 @@
#include <fail.h>
#include <alloc.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <stdio.h>
#include <grp.h>
diff --git a/otherlibs/unix/getgroups.c b/otherlibs/unix/getgroups.c
index 088dae199..3fe4bef24 100644
--- a/otherlibs/unix/getgroups.c
+++ b/otherlibs/unix/getgroups.c
@@ -18,7 +18,7 @@
#include <sys/types.h>
#include <sys/param.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_getgroups() /* ML */
{
diff --git a/otherlibs/unix/gethost.c b/otherlibs/unix/gethost.c
index c32d9927a..3f9983da6 100644
--- a/otherlibs/unix/gethost.c
+++ b/otherlibs/unix/gethost.c
@@ -15,12 +15,14 @@
#include <alloc.h>
#include <memory.h>
#include <fail.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
#include "socketaddr.h"
+#ifndef _WIN32
#include <netdb.h>
+#endif
static int entry_h_length;
diff --git a/otherlibs/unix/gethostname.c b/otherlibs/unix/gethostname.c
index 90a0b3ace..ca5da31ae 100644
--- a/otherlibs/unix/gethostname.c
+++ b/otherlibs/unix/gethostname.c
@@ -13,8 +13,12 @@
#include <mlvalues.h>
#include <alloc.h>
+#ifndef _WIN32
#include <sys/param.h>
-#include "unix.h"
+#else
+#include <winsock.h>
+#endif
+#include "unixsupport.h"
#ifdef HAS_GETHOSTNAME
diff --git a/otherlibs/unix/getlogin.c b/otherlibs/unix/getlogin.c
index 1f1515ae6..42f46f393 100644
--- a/otherlibs/unix/getlogin.c
+++ b/otherlibs/unix/getlogin.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <errno.h>
extern char * getlogin();
diff --git a/otherlibs/unix/getpeername.c b/otherlibs/unix/getpeername.c
index bafa5ec41..3f00060af 100644
--- a/otherlibs/unix/getpeername.c
+++ b/otherlibs/unix/getpeername.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
diff --git a/otherlibs/unix/getpid.c b/otherlibs/unix/getpid.c
index e54b0777e..6d95c615e 100644
--- a/otherlibs/unix/getpid.c
+++ b/otherlibs/unix/getpid.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_getpid() /* ML */
{
diff --git a/otherlibs/unix/getppid.c b/otherlibs/unix/getppid.c
index 851e499d9..d403209b4 100644
--- a/otherlibs/unix/getppid.c
+++ b/otherlibs/unix/getppid.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_getppid() /* ML */
{
diff --git a/otherlibs/unix/getproto.c b/otherlibs/unix/getproto.c
index 1bb223461..7892a0c87 100644
--- a/otherlibs/unix/getproto.c
+++ b/otherlibs/unix/getproto.c
@@ -15,11 +15,15 @@
#include <alloc.h>
#include <memory.h>
#include <fail.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
+#ifndef _WIN32
#include <netdb.h>
+#else
+#include <winsock.h>
+#endif
static value alloc_proto_entry(entry)
struct protoent * entry;
diff --git a/otherlibs/unix/getpw.c b/otherlibs/unix/getpw.c
index 0f321adca..e8f8a033d 100644
--- a/otherlibs/unix/getpw.c
+++ b/otherlibs/unix/getpw.c
@@ -15,7 +15,7 @@
#include <alloc.h>
#include <memory.h>
#include <fail.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <pwd.h>
static value alloc_passwd_entry(entry)
diff --git a/otherlibs/unix/getserv.c b/otherlibs/unix/getserv.c
index 675f2499a..2b9600927 100644
--- a/otherlibs/unix/getserv.c
+++ b/otherlibs/unix/getserv.c
@@ -15,14 +15,19 @@
#include <alloc.h>
#include <memory.h>
#include <fail.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
#include <sys/types.h>
+
+#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
+#else
+#include <winsock.h>
+#endif
static value alloc_service_entry(entry)
struct servent * entry;
diff --git a/otherlibs/unix/getsockname.c b/otherlibs/unix/getsockname.c
index b2ad75357..4831618a8 100644
--- a/otherlibs/unix/getsockname.c
+++ b/otherlibs/unix/getsockname.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
diff --git a/otherlibs/unix/gettimeofday.c b/otherlibs/unix/gettimeofday.c
index f67e82bdf..d1fd6cb64 100644
--- a/otherlibs/unix/gettimeofday.c
+++ b/otherlibs/unix/gettimeofday.c
@@ -1,6 +1,6 @@
#include <mlvalues.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_GETTIMEOFDAY
diff --git a/otherlibs/unix/getuid.c b/otherlibs/unix/getuid.c
index 7fb3e8089..58d62cce4 100644
--- a/otherlibs/unix/getuid.c
+++ b/otherlibs/unix/getuid.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_getuid() /* ML */
{
diff --git a/otherlibs/unix/gmtime.c b/otherlibs/unix/gmtime.c
index 0a101b5c5..45d1d9b57 100644
--- a/otherlibs/unix/gmtime.c
+++ b/otherlibs/unix/gmtime.c
@@ -14,7 +14,7 @@
#include <mlvalues.h>
#include <alloc.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <time.h>
static value alloc_tm(tm)
diff --git a/otherlibs/unix/ioctl.c b/otherlibs/unix/ioctl.c
index 22717760d..e2fd9ed28 100644
--- a/otherlibs/unix/ioctl.c
+++ b/otherlibs/unix/ioctl.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_ioctl_int(fd, request, arg)
value fd, request, arg;
diff --git a/otherlibs/unix/itimer.c b/otherlibs/unix/itimer.c
index b2242ff89..c2d53f46e 100644
--- a/otherlibs/unix/itimer.c
+++ b/otherlibs/unix/itimer.c
@@ -14,7 +14,7 @@
#include <mlvalues.h>
#include <alloc.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SETITIMER
diff --git a/otherlibs/unix/kill.c b/otherlibs/unix/kill.c
index b296f06a1..e117200b7 100644
--- a/otherlibs/unix/kill.c
+++ b/otherlibs/unix/kill.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <fail.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <signal.h>
extern int posix_signals[]; /* defined in byterun/signals.c */
diff --git a/otherlibs/unix/link.c b/otherlibs/unix/link.c
index 7c0c8a8c2..b9c17e4d1 100644
--- a/otherlibs/unix/link.c
+++ b/otherlibs/unix/link.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_link(path1, path2) /* ML */
value path1, path2;
diff --git a/otherlibs/unix/listen.c b/otherlibs/unix/listen.c
index bcb8f398b..969c2b844 100644
--- a/otherlibs/unix/listen.c
+++ b/otherlibs/unix/listen.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
diff --git a/otherlibs/unix/lockf.c b/otherlibs/unix/lockf.c
index 5a27c0db6..0da87549d 100644
--- a/otherlibs/unix/lockf.c
+++ b/otherlibs/unix/lockf.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_LOCKF
#ifdef HAS_UNISTD
diff --git a/otherlibs/unix/lseek.c b/otherlibs/unix/lseek.c
index 3ed1b2e4e..c785f1c8d 100644
--- a/otherlibs/unix/lseek.c
+++ b/otherlibs/unix/lseek.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_UNISTD
#include <unistd.h>
diff --git a/otherlibs/unix/mkdir.c b/otherlibs/unix/mkdir.c
index 8f551118d..08bf1f0ae 100644
--- a/otherlibs/unix/mkdir.c
+++ b/otherlibs/unix/mkdir.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_mkdir(path, perm) /* ML */
value path, perm;
diff --git a/otherlibs/unix/mkfifo.c b/otherlibs/unix/mkfifo.c
index 8177871b6..d53c3ccb7 100644
--- a/otherlibs/unix/mkfifo.c
+++ b/otherlibs/unix/mkfifo.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_MKFIFO
diff --git a/otherlibs/unix/nice.c b/otherlibs/unix/nice.c
index 71cd865b5..609873aaf 100644
--- a/otherlibs/unix/nice.c
+++ b/otherlibs/unix/nice.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <errno.h>
#ifdef HAS_GETPRIORITY
diff --git a/otherlibs/unix/open.c b/otherlibs/unix/open.c
index f76c52719..32ccc20b1 100644
--- a/otherlibs/unix/open.c
+++ b/otherlibs/unix/open.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <fcntl.h>
#ifndef O_NONBLOCK
diff --git a/otherlibs/unix/opendir.c b/otherlibs/unix/opendir.c
index fcbe4a8f3..924ab05f2 100644
--- a/otherlibs/unix/opendir.c
+++ b/otherlibs/unix/opendir.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <sys/types.h>
#ifdef HAS_DIRENT
#include <dirent.h>
diff --git a/otherlibs/unix/pause.c b/otherlibs/unix/pause.c
index 0becf9bce..d8f337e16 100644
--- a/otherlibs/unix/pause.c
+++ b/otherlibs/unix/pause.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_pause() /* ML */
{
diff --git a/otherlibs/unix/pipe.c b/otherlibs/unix/pipe.c
index 596e641ea..e3446108e 100644
--- a/otherlibs/unix/pipe.c
+++ b/otherlibs/unix/pipe.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_pipe() /* ML */
{
diff --git a/otherlibs/unix/read.c b/otherlibs/unix/read.c
index 6373c57ea..5401f83ff 100644
--- a/otherlibs/unix/read.c
+++ b/otherlibs/unix/read.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_read(fd, buf, ofs, len) /* ML */
value fd, buf, ofs, len;
diff --git a/otherlibs/unix/readdir.c b/otherlibs/unix/readdir.c
index dd9a288b5..330cd485d 100644
--- a/otherlibs/unix/readdir.c
+++ b/otherlibs/unix/readdir.c
@@ -14,7 +14,7 @@
#include <mlvalues.h>
#include <fail.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <sys/types.h>
#ifdef HAS_DIRENT
#include <dirent.h>
diff --git a/otherlibs/unix/readlink.c b/otherlibs/unix/readlink.c
index d8c4fbbc4..fa467a3ca 100644
--- a/otherlibs/unix/readlink.c
+++ b/otherlibs/unix/readlink.c
@@ -17,7 +17,7 @@
#ifdef HAS_SYMLINK
#include <sys/param.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_readlink(path) /* ML */
value path;
diff --git a/otherlibs/unix/rename.c b/otherlibs/unix/rename.c
index cd0409b5f..5bc2425be 100644
--- a/otherlibs/unix/rename.c
+++ b/otherlibs/unix/rename.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_rename(path1, path2) /* ML */
value path1, path2;
diff --git a/otherlibs/unix/rewinddir.c b/otherlibs/unix/rewinddir.c
index bfe3b77b2..56d6f9d84 100644
--- a/otherlibs/unix/rewinddir.c
+++ b/otherlibs/unix/rewinddir.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <sys/types.h>
#ifdef HAS_DIRENT
#include <dirent.h>
diff --git a/otherlibs/unix/rmdir.c b/otherlibs/unix/rmdir.c
index 10a986810..20907492b 100644
--- a/otherlibs/unix/rmdir.c
+++ b/otherlibs/unix/rmdir.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_rmdir(path) /* ML */
value path;
diff --git a/otherlibs/unix/select.c b/otherlibs/unix/select.c
index 7b4e6aaeb..8cff88def 100644
--- a/otherlibs/unix/select.c
+++ b/otherlibs/unix/select.c
@@ -15,7 +15,7 @@
#include <alloc.h>
#include <memory.h>
#include <signals.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SELECT
diff --git a/otherlibs/unix/sendrecv.c b/otherlibs/unix/sendrecv.c
index ea531e7e4..b6f35b262 100644
--- a/otherlibs/unix/sendrecv.c
+++ b/otherlibs/unix/sendrecv.c
@@ -14,7 +14,7 @@
#include <mlvalues.h>
#include <alloc.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
#include "socketaddr.h"
diff --git a/otherlibs/unix/setgid.c b/otherlibs/unix/setgid.c
index 0f159601a..482f25a8b 100644
--- a/otherlibs/unix/setgid.c
+++ b/otherlibs/unix/setgid.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_setgid(gid) /* ML */
value gid;
diff --git a/otherlibs/unix/setuid.c b/otherlibs/unix/setuid.c
index d8b69705c..4b3a1d9b4 100644
--- a/otherlibs/unix/setuid.c
+++ b/otherlibs/unix/setuid.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_setuid(uid) /* ML */
value uid;
diff --git a/otherlibs/unix/shutdown.c b/otherlibs/unix/shutdown.c
index ae66d69a5..f0750cf7e 100644
--- a/otherlibs/unix/shutdown.c
+++ b/otherlibs/unix/shutdown.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
diff --git a/otherlibs/unix/sleep.c b/otherlibs/unix/sleep.c
index d7590b81c..c09f195f2 100644
--- a/otherlibs/unix/sleep.c
+++ b/otherlibs/unix/sleep.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_sleep(t) /* ML */
value t;
diff --git a/otherlibs/unix/socket.c b/otherlibs/unix/socket.c
index 3f197b536..bdf884d38 100644
--- a/otherlibs/unix/socket.c
+++ b/otherlibs/unix/socket.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
diff --git a/otherlibs/unix/socketaddr.c b/otherlibs/unix/socketaddr.c
index b46f290ee..6660390e8 100644
--- a/otherlibs/unix/socketaddr.c
+++ b/otherlibs/unix/socketaddr.c
@@ -16,7 +16,7 @@
#include <memory.h>
#include <str.h>
#include <errno.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
@@ -35,6 +35,7 @@ void get_sockaddr(a)
value a;
{
switch(Tag_val(a)) {
+#ifndef _WIN32
case 0: /* ADDR_UNIX */
{ value path;
mlsize_t len;
@@ -50,6 +51,7 @@ void get_sockaddr(a)
+ len;
break;
}
+#endif
case 1: /* ADDR_INET */
{
char * p;
@@ -70,6 +72,7 @@ value alloc_sockaddr()
{
value res;
switch(sock_addr.s_gen.sa_family) {
+#ifndef _WIN32
case AF_UNIX:
{ Push_roots(n, 1);
n[0] = copy_string(sock_addr.s_unix.sun_path);
@@ -78,6 +81,7 @@ value alloc_sockaddr()
Pop_roots();
break;
}
+#endif
case AF_INET:
{ Push_roots(a, 1);
a[0] = alloc_inet_addr(sock_addr.s_inet.sin_addr.s_addr);
diff --git a/otherlibs/unix/socketaddr.h b/otherlibs/unix/socketaddr.h
index 803aed27e..52245ed92 100644
--- a/otherlibs/unix/socketaddr.h
+++ b/otherlibs/unix/socketaddr.h
@@ -16,6 +16,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
union {
struct sockaddr s_gen;
diff --git a/otherlibs/unix/socketpair.c b/otherlibs/unix/socketpair.c
index fedc939a6..655667c4e 100644
--- a/otherlibs/unix/socketpair.c
+++ b/otherlibs/unix/socketpair.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
diff --git a/otherlibs/unix/sockopt.c b/otherlibs/unix/sockopt.c
index cdb23ba02..3186cea17 100644
--- a/otherlibs/unix/sockopt.c
+++ b/otherlibs/unix/sockopt.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
diff --git a/otherlibs/unix/stat.c b/otherlibs/unix/stat.c
index 41e0e23f6..1791e0e33 100644
--- a/otherlibs/unix/stat.c
+++ b/otherlibs/unix/stat.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
#include "cst2constr.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -27,6 +27,9 @@
#ifndef S_IFSOCK
#define S_IFSOCK 0
#endif
+#ifndef S_IFBLK
+#define S_IFBLK 0
+#endif
static int file_kind_table[] = {
S_IFREG, S_IFDIR, S_IFCHR, S_IFBLK, S_IFLNK, S_IFIFO, S_IFSOCK
diff --git a/otherlibs/unix/strofaddr.c b/otherlibs/unix/strofaddr.c
index d14cc2742..4503f6c30 100644
--- a/otherlibs/unix/strofaddr.c
+++ b/otherlibs/unix/strofaddr.c
@@ -13,14 +13,12 @@
#include <mlvalues.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SOCKETS
#include "socketaddr.h"
-extern char * inet_ntoa();
-
value unix_string_of_inet_addr(a) /* ML */
value a;
{
diff --git a/otherlibs/unix/symlink.c b/otherlibs/unix/symlink.c
index 177c3dc9a..9d5bf15f9 100644
--- a/otherlibs/unix/symlink.c
+++ b/otherlibs/unix/symlink.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_SYMLINK
diff --git a/otherlibs/unix/termios.c b/otherlibs/unix/termios.c
index ec0a6a589..0e04281c8 100644
--- a/otherlibs/unix/termios.c
+++ b/otherlibs/unix/termios.c
@@ -13,7 +13,7 @@
#include <mlvalues.h>
#include <alloc.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_TERMIOS
diff --git a/otherlibs/unix/time.c b/otherlibs/unix/time.c
index 2fa973f75..6a16ff00e 100644
--- a/otherlibs/unix/time.c
+++ b/otherlibs/unix/time.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
extern long time();
diff --git a/otherlibs/unix/times.c b/otherlibs/unix/times.c
index 79c799799..c69e1277d 100644
--- a/otherlibs/unix/times.c
+++ b/otherlibs/unix/times.c
@@ -14,7 +14,7 @@
#include <mlvalues.h>
#include <alloc.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <time.h>
#include <sys/types.h>
#include <sys/times.h>
diff --git a/otherlibs/unix/truncate.c b/otherlibs/unix/truncate.c
index 3670a7e9d..d3e0407ea 100644
--- a/otherlibs/unix/truncate.c
+++ b/otherlibs/unix/truncate.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_TRUNCATE
diff --git a/otherlibs/unix/umask.c b/otherlibs/unix/umask.c
index f2475677f..5cd445d62 100644
--- a/otherlibs/unix/umask.c
+++ b/otherlibs/unix/umask.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_umask(perm) /* ML */
value perm;
diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml
index 7daa12d29..4f2427536 100644
--- a/otherlibs/unix/unix.ml
+++ b/otherlibs/unix/unix.ml
@@ -120,6 +120,7 @@ type wait_flag =
external execv : string -> string array -> unit = "unix_execv"
external execve : string -> string array -> string array -> unit = "unix_execve"
external execvp : string -> string array -> unit = "unix_execvp"
+external execvpe : string -> string array -> string array -> unit = "unix_execvpe"
external fork : unit -> int = "unix_fork"
external wait : unit -> int * process_status = "unix_wait"
external waitpid : wait_flag list -> int -> int * process_status = "unix_waitpid"
@@ -523,6 +524,16 @@ let create_process cmd args new_stdin new_stdout new_stderr =
exit 127
| id -> id
+let create_process_env cmd args env new_stdin new_stdout new_stderr =
+ match fork() with
+ 0 ->
+ if new_stdin <> stdin then dup2 new_stdin stdin;
+ if new_stdout <> stdout then dup2 new_stdout stdout;
+ if new_stderr <> stderr then dup2 new_stderr stderr;
+ execvpe cmd args env;
+ exit 127
+ | id -> id
+
type popen_process =
Process of in_channel * out_channel
| Process_in of in_channel
diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli
index 722e7a6cc..f50b132a4 100644
--- a/otherlibs/unix/unix.mli
+++ b/otherlibs/unix/unix.mli
@@ -142,7 +142,9 @@ external execve : string -> string array -> string array -> unit = "unix_execve"
(* Same as [execv], except that the third argument provides the
environment to the program executed. *)
external execvp : string -> string array -> unit = "unix_execvp"
- (* Same as [execv], except that the program is searched in the path. *)
+external execvpe : string -> string array -> string array -> unit = "unix_execvpe"
+ (* Same as [execv] and [execvp] respectively, except that
+ the program is searched in the path. *)
external fork : unit -> int = "unix_fork"
(* Fork a new process. The returned integer is 0 for the child
process, the pid of the child process for the parent process. *)
@@ -408,6 +410,13 @@ val create_process :
new process, except those redirected to standard input and
outputs. *)
+val create_process_env :
+ string -> string array -> string array ->
+ file_descr -> file_descr -> file_descr -> int
+ (* [create_process_env prog args env new_stdin new_stdout new_stderr]
+ works as [create_process], except that the extra argument
+ [env] specifies the environment passed to the program. *)
+
val open_process_in: string -> in_channel
val open_process_out: string -> out_channel
val open_process: string -> in_channel * out_channel
diff --git a/otherlibs/unix/unixsupport.c b/otherlibs/unix/unixsupport.c
index 188e9501a..20053eaa9 100644
--- a/otherlibs/unix/unixsupport.c
+++ b/otherlibs/unix/unixsupport.c
@@ -15,7 +15,7 @@
#include <alloc.h>
#include <memory.h>
#include <fail.h>
-#include "unix.h"
+#include "unixsupport.h"
#include "cst2constr.h"
#include <errno.h>
diff --git a/otherlibs/unix/unix.h b/otherlibs/unix/unixsupport.h
index 78d333375..78d333375 100644
--- a/otherlibs/unix/unix.h
+++ b/otherlibs/unix/unixsupport.h
diff --git a/otherlibs/unix/unlink.c b/otherlibs/unix/unlink.c
index 407ad11c0..d1f89347b 100644
--- a/otherlibs/unix/unlink.c
+++ b/otherlibs/unix/unlink.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_unlink(path) /* ML */
value path;
diff --git a/otherlibs/unix/utimes.c b/otherlibs/unix/utimes.c
index b7108b33c..8874a4e0a 100644
--- a/otherlibs/unix/utimes.c
+++ b/otherlibs/unix/utimes.c
@@ -12,12 +12,16 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
#ifdef HAS_UTIME
#include <sys/types.h>
+#ifndef _WIN32
#include <utime.h>
+#else
+#include <sys/utime.h>
+#endif
value unix_utimes(path, atime, mtime) /* ML */
value path, atime, mtime;
diff --git a/otherlibs/unix/wait.c b/otherlibs/unix/wait.c
index 38d0631dd..12bfed25d 100644
--- a/otherlibs/unix/wait.c
+++ b/otherlibs/unix/wait.c
@@ -14,7 +14,7 @@
#include <mlvalues.h>
#include <alloc.h>
#include <memory.h>
-#include "unix.h"
+#include "unixsupport.h"
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/otherlibs/unix/write.c b/otherlibs/unix/write.c
index 6b292bbf3..6569fe3a6 100644
--- a/otherlibs/unix/write.c
+++ b/otherlibs/unix/write.c
@@ -12,7 +12,7 @@
/* $Id$ */
#include <mlvalues.h>
-#include "unix.h"
+#include "unixsupport.h"
value unix_write(fd, buf, ofs, len) /* ML */
value fd, buf, ofs, len;