Browse thread
[Caml-list] getting fd behind a channel from C
-
Jeremy Fincher
-
Olivier Andrieu
-
Jeremy Fincher
- Olivier Andrieu
-
Jeremy Fincher
-
Olivier Andrieu
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Olivier Andrieu <andrieu@i...> |
| Subject: | Re: [Caml-list] getting fd behind a channel from C |
Jeremy Fincher [Tuesday 4 September 2001] :
> > in the OCaml source tree, look at byterun/io.h : it contains
> > definitions and macros to access caml channels from C :
> I already found this, but there's no way to get to this from the standard
> C/O'Caml interface.
You just have to take the io.h from the OCaml tree, put with your C
files, #include it, at it works !
You can just keep the relevant parts :
<<<<<
#ifndef IO_BUFFER_SIZE
#define IO_BUFFER_SIZE 4096
#endif
struct channel {
int fd; /* Unix file descriptor */
long offset; /* Absolute position of fd in the file */
char * end; /* Physical end of the buffer */
char * curr; /* Current position in the buffer */
char * max; /* Logical end of the buffer (for input) */
void * mutex; /* Placeholder for mutex (for systhreads) */
char buff[IO_BUFFER_SIZE]; /* The buffer itself */
};
#define Channel(v) (*((struct channel **) (Data_custom_val(v))))
>>>>>
Oliv
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr