caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Andrieu <andrieu@ijm.jussieu.fr>
To: "Jeremy Fincher" <tweedgeezer@hotmail.com>
Cc: <caml-list@pauillac.inria.fr>
Subject: Re: [Caml-list] getting fd behind a channel from C
Date: Tue, 4 Sep 2001 17:08:41 +0200	[thread overview]
Message-ID: <15252.61049.619888.392717@akasha.ijm.jussieu.fr> (raw)
In-Reply-To: <DAV3478v1QB1q6Fd3Yt00001994@hotmail.com>

 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


      reply	other threads:[~2001-09-04 15:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-04  6:23 Jeremy Fincher
2001-09-04  8:30 ` Olivier Andrieu
2001-09-04 14:37   ` Jeremy Fincher
2001-09-04 15:08     ` Olivier Andrieu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15252.61049.619888.392717@akasha.ijm.jussieu.fr \
    --to=andrieu@ijm.jussieu.fr \
    --cc=caml-list@pauillac.inria.fr \
    --cc=tweedgeezer@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).