[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Guile Ports and C Streams

From: Marc Nieper-Wißkirchen
Subject: Guile Ports and C Streams
Date: Fri, 14 Dec 2018 21:30:28 +0100


Hopefully someone can help me with a hint how to solve the following
problem: I am developing a C extension for Guile. One C function I use
expects a C stream (a FILE* object) as an argument.

On the Guile side, I have a Scheme port (of which I know that it is backed
up by a Unix file and thus has a file descriptor. My problem is: What is
the best way to translate the Scheme port to a C file?

The first idea I had was to use scm_fileno and fdopen and to use reference
counting and finalizers for garbage collection and automatic closing of the
C stream.

In general, the C stream will be buffered as will be the Scheme port.
However, the two buffers won't know of each other by the above idea, which
may lead to strange results.

So, is it possible to retrieve a FILE* object that is shared by the
underlying Scheme port?

For example, is it possible to reconstruct/retrieve the C library's stderr
from (current-error-port)?


-- Marc

reply via email to

[Prev in Thread] Current Thread [Next in Thread]