From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA04821; Tue, 4 Sep 2001 10:30:14 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA28781 for ; Tue, 4 Sep 2001 10:30:13 +0200 (MET DST) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f848UDf05635 for ; Tue, 4 Sep 2001 10:30:13 +0200 (MET DST) Received: from akasha.ijm.jussieu.fr (akasha.ijm.jussieu.fr [134.157.173.57]) by shiva.jussieu.fr (8.11.3/jtpda-5.3.3) with ESMTP id f848UAO21176 ; Tue, 4 Sep 2001 10:30:10 +0200 (CEST) Received: by akasha.ijm.jussieu.fr (Postfix, from userid 11004) id CFDDB3C15A; Tue, 4 Sep 2001 10:30:02 +0200 (CEST) From: Olivier Andrieu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15252.37130.686271.39272@akasha.ijm.jussieu.fr> Date: Tue, 4 Sep 2001 10:30:02 +0200 To: "Jeremy Fincher" Cc: Subject: Re: [Caml-list] getting fd behind a channel from C In-Reply-To: References: X-Mailer: VM 6.95 under Emacs 20.7.1 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jeremy Fincher [Tuesday 4 September 2001] : > > I can't for the life of me figure out how, from C, to take an in_channel and > get the file descriptor of it. How do I write a C function that takes an > in_channel and then does some work on the underlying file descriptor? in the OCaml source tree, look at byterun/io.h : it contains definitions and macros to access caml channels from C : - struct channel has a field fd for the file descriptor. - the macro Channel takes a Caml value and gives you a struct channel* so (Channel(ml_channel))->fd does what you want. There's also the Unix.descr_of_in_channel and Unix.descr_of_out_channel functions. Olivier ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr