Hi Johannes, The following might give you some ideas: module Main where import Control.Monad import Foreign import Foreign.ForeignPtr import Foreign.C.String import Foreign.C.Types #include <stdio.h> {#pointer *FILE as File foreign finalizer fclose newtype#} {#fun fopen as ^ {`String', `String'} -> `File'#} {#fun fgetc as ^ {`File'} -> `Int'#} main :: IO () main = do fp <- fopen "tst.dat" "r" c <- fgetc fp print c (The "foreign finalizer" thing requires a recent C2HS.) Cheers, Ian. On 17 December 2014 at 09:19, Johannes Waldmann < waldmann@imn.htwk-leipzig.de> wrote:
Hi.
I could use an example of how to handle files (FILE *) with c2hs, but could not find any.
I want to call some "void dump (..., FILE * f)" function. I want to use this for a handle that I obtained in Haskell land.
Sure I can rewrite/add the C code so that it takes a filepath (string) and opens the file by itself, but should I?
- J.W.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Ian Ross Tel: +43(0)6804451378 ian@skybluetrades.net www.skybluetrades.net