Пример #1
0
static sexp sexp_file_access_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  sexp res;
  if (! sexp_stringp(arg0))
    return sexp_type_exception(ctx, self, SEXP_STRING, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  res = sexp_make_integer(ctx, access(sexp_string_data(arg0), sexp_sint_value(arg1)));
  return res;
}
Пример #2
0
static sexp sexp_open_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2) {
  sexp res;
  if (! sexp_stringp(arg0))
    return sexp_type_exception(ctx, self, SEXP_STRING, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  res = sexp_make_fileno(ctx, sexp_make_fixnum(open(sexp_string_data(arg0), sexp_sint_value(arg1), sexp_sint_value(arg2))), SEXP_FALSE);
  return res;
}
Пример #3
0
static sexp
sexp_yuniffi_nccc_call_bridge(sexp ctx, sexp self, sexp_sint_t n,
                              sexp func,
                              sexp in,  sexp in_offs,  sexp in_len,
                              sexp out, sexp out_offs, sexp out_len){
    sexp res;
    REQUIRE_TAG(ctx, self, func, sexp_pointerp, SEXP_CPOINTER);
    REQUIRE(ctx, self, in_offs, sexp_exact_integerp, SEXP_FIXNUM);
    REQUIRE(ctx, self, in_len, sexp_exact_integerp, SEXP_FIXNUM);
    REQUIRE(ctx, self, out_offs, sexp_exact_integerp, SEXP_FIXNUM);
    REQUIRE(ctx, self, out_len, sexp_exact_integerp, SEXP_FIXNUM);

    yuniffi_nccc_call(ctx, (void*)sexp_cpointer_value(func),
                      in, 
                      sexp_sint_value(in_offs), 
                      sexp_sint_value(in_len),
                      out,
                      sexp_sint_value(out_offs), 
                      sexp_sint_value(out_len));

    return SEXP_VOID;
}
Пример #4
0
static sexp sexp_make_timeval_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  struct timeval* r;
  sexp_gc_var1(res);
  sexp_gc_preserve1(ctx, res);
  res = sexp_alloc_tagged(ctx, sexp_sizeof(cpointer), sexp_unbox_fixnum(sexp_opcode_return_type(self)));
  sexp_cpointer_value(res) = calloc(1, sizeof(struct timeval));
  r = (struct timeval*) sexp_cpointer_value(res);
  memset(r, 0, sizeof(struct timeval));
  sexp_freep(res) = 1;
  r->tv_sec = sexp_unshift_epoch(sexp_uint_value(arg0));
  r->tv_usec = sexp_sint_value(arg1);
  sexp_gc_release1(ctx);
  return res;
}
Пример #5
0
static sexp sexp_create_directory_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) {
  int err;
  sexp res;
  if (! sexp_stringp(arg0))
    return sexp_type_exception(ctx, self, SEXP_STRING, arg0);
  if (! sexp_exact_integerp(arg1))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg1);
  err = mkdir(sexp_string_data(arg0), sexp_sint_value(arg1));
  if (err) {
  res = SEXP_FALSE;
  } else {
  res = SEXP_TRUE;
  }
  return res;
}
Пример #6
0
static sexp sexp_fstat_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0) {
  int err;
  struct stat* tmp1;
  sexp res;
  sexp_gc_var1(res1);
  if (! sexp_exact_integerp(arg0))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg0);
  sexp_gc_preserve1(ctx, res1);
  tmp1 = (struct stat*) calloc(1, 1 + sizeof(tmp1[0]));
  err = fstat(sexp_sint_value(arg0), tmp1);
  if (err) {
  res = SEXP_FALSE;
  } else {
  res1 = sexp_make_cpointer(ctx, sexp_unbox_fixnum(sexp_opcode_arg2_type(self)), tmp1, SEXP_FALSE, 1);
  res = res1;
  }
  sexp_gc_release1(ctx);
  return res;
}
Пример #7
0
static sexp sexp_make_tm_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2, sexp arg3, sexp arg4, sexp arg5, sexp arg6) {
  struct tm* r;
  sexp_gc_var1(res);
  sexp_gc_preserve1(ctx, res);
  res = sexp_alloc_tagged(ctx, sexp_sizeof(cpointer), sexp_unbox_fixnum(sexp_opcode_return_type(self)));
  sexp_cpointer_value(res) = calloc(1, sizeof(struct tm));
  r = (struct tm*) sexp_cpointer_value(res);
  memset(r, 0, sizeof(struct tm));
  sexp_freep(res) = 1;
  r->tm_sec = sexp_sint_value(arg0);
  r->tm_min = sexp_sint_value(arg1);
  r->tm_hour = sexp_sint_value(arg2);
  r->tm_mday = sexp_sint_value(arg3);
  r->tm_mon = sexp_sint_value(arg4);
  r->tm_year = sexp_sint_value(arg5);
  r->tm_isdst = sexp_sint_value(arg6);
  sexp_gc_release1(ctx);
  return res;
}
Пример #8
0
static sexp sexp_set_file_descriptor_flags_x_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg2) {
  int err;
  sexp res;
  if (! (sexp_portp(arg0) || sexp_filenop(arg0) || sexp_fixnump(arg0)))
    return sexp_xtype_exception(ctx, self, "not a port or file descriptor",arg0);
  if (! sexp_exact_integerp(arg2))
    return sexp_type_exception(ctx, self, SEXP_FIXNUM, arg2);
  err = fcntl((sexp_portp(arg0) ? sexp_port_fileno(arg0) : sexp_filenop(arg0) ? sexp_fileno_fd(arg0) : sexp_unbox_fixnum(arg0)), F_SETFD, sexp_sint_value(arg2));
  if (err) {
  res = SEXP_FALSE;
  } else {
  res = SEXP_TRUE;
  }
  return res;
}