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 PAA17240; Tue, 6 Aug 2002 15:04:21 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA17198 for ; Tue, 6 Aug 2002 15:04:20 +0200 (MET DST) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g76D4J103435 for ; Tue, 6 Aug 2002 15:04:19 +0200 (MET DST) Received: from akasha.ijm.jussieu.fr (akasha.ijm.jussieu.fr [134.157.173.57]) by shiva.jussieu.fr (8.12.5/jtpda-5.4) with ESMTP id g76D4HjR082916 ; Tue, 6 Aug 2002 15:04:17 +0200 (CEST) Received: by akasha.ijm.jussieu.fr (Postfix, from userid 11004) id 31BF03C9E1; Tue, 6 Aug 2002 15:04:12 +0200 (CEST) From: Olivier Andrieu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15695.51531.965211.875413@akasha.ijm.jussieu.fr> Date: Tue, 6 Aug 2002 15:04:11 +0200 To: Michael Tucker Cc: caml-list@inria.fr Subject: Re: [Caml-list] Sharing Files between OCaml and C In-Reply-To: References: <200208051929.VAA0000007257@beaune.inria.fr> X-Mailer: VM 7.07 under Emacs 20.7.1 X-Antivirus: scanned by sophie at shiva.jussieu.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Michael Tucker [Monday 5 August 2002] : > > Hi, > > I would like to share access to a file between a C function and an > OCaml function in an application put together with CamlIDL. If I > have a C function with prototype: > > int manip_file(FILE* f, int x); > > Is there any support in CamlIDL for passing a file that was opened in > OCaml. I checked the archives, and found a message that described > pulling out the integer file descriptor, and passing that to fdopen > on the C side, but that was it -- the same message asked about > better support from CamlIDL (this was winter 2000), but I couldn't > find a response. Has this changed over the past year and a half, or > is that the best method? Yes, I think that's still the best method : - get the descriptor with Unix.descr_of_in_channel or Unix.descr_of_out_channel - fdopen it on the C side You might also want to call dup() on the fd so that your FILE* stream is still working if the original caml channel is closed. But maybe CamlIDL has improved, I don't know. -- Olivier ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners