diff options
-rw-r--r-- | otherlibs/threads/unix.ml | 1 | ||||
-rw-r--r-- | otherlibs/unix/Makefile | 2 | ||||
-rw-r--r-- | otherlibs/unix/isatty.c | 22 | ||||
-rw-r--r-- | otherlibs/unix/unix.ml | 1 | ||||
-rw-r--r-- | otherlibs/unix/unix.mli | 3 | ||||
-rw-r--r-- | otherlibs/unix/unixLabels.mli | 4 |
6 files changed, 32 insertions, 1 deletions
diff --git a/otherlibs/threads/unix.ml b/otherlibs/threads/unix.ml index 59f4c5ea6..6d6fa91bf 100644 --- a/otherlibs/threads/unix.ml +++ b/otherlibs/threads/unix.ml @@ -274,6 +274,7 @@ type stats = external stat : string -> stats = "unix_stat" external lstat : string -> stats = "unix_lstat" external fstat : file_descr -> stats = "unix_fstat" +external isatty : file_descr -> bool = "unix_isatty" external unlink : string -> unit = "unix_unlink" external rename : string -> string -> unit = "unix_rename" external link : string -> string -> unit = "unix_link" diff --git a/otherlibs/unix/Makefile b/otherlibs/unix/Makefile index da701d5dc..c9ce69c4a 100644 --- a/otherlibs/unix/Makefile +++ b/otherlibs/unix/Makefile @@ -33,7 +33,7 @@ OBJS=accept.o access.o addrofstr.o alarm.o bind.o chdir.o chmod.o \ getgr.o getgroups.o gethost.o gethostname.o getlogin.o \ getnameinfo.o getpeername.o getpid.o getppid.o getproto.o getpw.o \ gettimeofday.o getserv.o getsockname.o getuid.o \ - gmtime.o itimer.o kill.o link.o listen.o lockf.o lseek.o mkdir.o \ + gmtime.o isatty.o itimer.o kill.o link.o listen.o lockf.o lseek.o mkdir.o \ mkfifo.o nice.o open.o opendir.o pipe.o putenv.o read.o \ readdir.o readlink.o rename.o rewinddir.o rmdir.o select.o sendrecv.o \ setgid.o setsid.o setuid.o shutdown.o signals.o \ diff --git a/otherlibs/unix/isatty.c b/otherlibs/unix/isatty.c new file mode 100644 index 000000000..f534dd773 --- /dev/null +++ b/otherlibs/unix/isatty.c @@ -0,0 +1,22 @@ +/***********************************************************************/ +/* */ +/* Objective Caml */ +/* */ +/* Xavier Leroy, projet Gallium, INRIA Rocquencourt */ +/* */ +/* Copyright 2006 Institut National de Recherche en Informatique et */ +/* en Automatique. All rights reserved. This file is distributed */ +/* under the terms of the GNU Library General Public License, with */ +/* the special exception on linking described in file ../../LICENSE. */ +/* */ +/***********************************************************************/ + +/* $Id$ */ + +#include <mlvalues.h> +#include "unixsupport.h" + +CAMLprim value unix_isatty(value fd) +{ + return (Val_bool(isatty(Int_val(fd)))); +} diff --git a/otherlibs/unix/unix.ml b/otherlibs/unix/unix.ml index c1c010256..8f5b3fc55 100644 --- a/otherlibs/unix/unix.ml +++ b/otherlibs/unix/unix.ml @@ -223,6 +223,7 @@ type stats = external stat : string -> stats = "unix_stat" external lstat : string -> stats = "unix_lstat" external fstat : file_descr -> stats = "unix_fstat" +external isatty : file_descr -> bool = "unix_isatty" external unlink : string -> unit = "unix_unlink" external rename : string -> string -> unit = "unix_rename" external link : string -> string -> unit = "unix_link" diff --git a/otherlibs/unix/unix.mli b/otherlibs/unix/unix.mli index daa3c9d9d..6f68c9a73 100644 --- a/otherlibs/unix/unix.mli +++ b/otherlibs/unix/unix.mli @@ -349,6 +349,9 @@ val fstat : file_descr -> stats (** Return the informations for the file associated with the given descriptor. *) +val isatty : file_descr -> bool +(** Return [true] if the given file descriptor refers to a terminal or + console window, [false] otherwise. *) (** {6 File operations on large files} *) diff --git a/otherlibs/unix/unixLabels.mli b/otherlibs/unix/unixLabels.mli index 1f081c81f..05d1181c2 100644 --- a/otherlibs/unix/unixLabels.mli +++ b/otherlibs/unix/unixLabels.mli @@ -357,6 +357,10 @@ val fstat : file_descr -> stats (** Return the information for the file associated with the given descriptor. *) +val isatty : file_descr -> bool +(** Return [true] if the given file descriptor refers to a terminal or + console window, [false] otherwise. *) + (** {6 Seeking, truncating and statistics on large files} *) |