-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul Meurer <[EMAIL PROTECTED]> writes:

> The signature of the C function is:
>
>    void print_prolog_graph(FILE *stream);

That's not a Unix stream, that's a C stdio stream.  It layers
buffering and stuff over the underlying Unix file descriptor.

>    (with-open-file (stream "temp.lisp" :direction :output :if-exists :supersede)
>        (print-prolog-graph (common-lisp::fd-stream-obuf-sap stream)))

CMUCL streams are not C streams.  CMUCL does its own buffering etc,
but not in a C-compatible manner.

> Any idea how to do this right?

You can get the underlying Unix fd from a CMUCL stream with
SYSTEM:FD-STREAM-FD - e.g.

* (with-open-file (i "/dev/zero") (system:fd-stream-fd i))
6

- - be sure to FORCE-OUTPUT before passing this to C code if you've
written to the file from Lisp, otherwise output will arrive in a
strange order.

If there's no equivalent of print_prolog_graph that takes a unix file
descriptor directly, you can use fdopen() to convert it into a
stream.  That can then get slightly messy, though, as if you then
close it with fclose(), that will close() the underlying fd and 
Lisp will quite possibly get upset at having its streams closed behind
its back.

Did that make any sense at all?  


- -dan

- -- 

   http://www.cliki.net/ - Link farm for free CL-on-Unix resources 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+9xjcHDK5ZnWQiRMRAhOjAKCNXzbcDGpHnjDkquH6LGgd8tcwnwCeMqaF
LqR6q8ugU0E8zYIL84Dnxag=
=7loF
-----END PGP SIGNATURE-----


Reply via email to