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

passing a file pointer from T to C (under UNIX)



T streams are made up from (or are higher level abstractions of) T channels.
Channels are implemented in a machine-dependent way, whereas streams are
machine-independent.

first open a file (say for reading) using "maybe-open". this will return
a stream. from this stream, extract its corresponding channel (using the
operation "stream->channel" available in *t-implementation-env*. this channel
can now be passed as a parameter to a C function using the dynamic loading
package for UNIX. on the C side, the function should expect a FILE *
(file pointer).
for example:

(define-c foo fixnum channel)

declares a T function "foo" which takes a T channel as an argument and
returns a T fixnum. the corresponding C function, that would be
called by the T function, can be declared as:

    int foo (filedesc)
    FILE *filedesc;
    {
    ...
    }

'dorab