Example #1
0
CAMLprim value win_inchannel_of_filedescr(value handle)
{
  CAMLparam1(handle);
  CAMLlocal1(vchan);
  struct channel * chan;

  chan = caml_open_descriptor_in(win_CRT_fd_of_filedescr(handle));
  if (Descr_kind_val(handle) == KIND_SOCKET)
    chan->flags |= CHANNEL_FLAG_FROM_SOCKET;
  vchan = caml_alloc_channel(chan);
  CAMLreturn(vchan);
}
Example #2
0
File: io.c Project: bobzhang/ocaml
CAMLprim value caml_ml_out_channels_list (value unit)
{
  CAMLparam0 ();
  CAMLlocal3 (res, tail, chan);
  struct channel * channel;

  res = Val_emptylist;
  for (channel = caml_all_opened_channels;
       channel != NULL;
       channel = channel->next)
    /* Testing channel->fd >= 0 looks unnecessary, as
       caml_ml_close_channel changes max when setting fd to -1. */
    if (channel->max == NULL) {
      chan = caml_alloc_channel (channel);
      tail = res;
      res = caml_alloc_small (2, Pair_tag);
      Field (res, 0) = chan;
      Field (res, 1) = tail;
    }
  CAMLreturn (res);
}
Example #3
0
File: io.c Project: bobzhang/ocaml
CAMLprim value caml_ml_open_descriptor_out(value fd)
{
  return caml_alloc_channel(caml_open_descriptor_out(Int_val(fd)));
}