Ejemplo n.º 1
0
static uim_lisp
uim_sqlite3_close(uim_lisp db_)
{
  if (sqlite3_close(C_PTR(db_)) != SQLITE_OK)
    ERROR_OBJ(sqlite3_errmsg(C_PTR(db_)), db_);
  return uim_scm_t();
}
Ejemplo n.º 2
0
static uim_lisp
uim_sqlite3_open(uim_lisp filename_)
{
  sqlite3 *db;

  if (sqlite3_open(REFER_C_STR(filename_), &db) != SQLITE_OK)
    ERROR_OBJ(sqlite3_errmsg(db), filename_);
  return MAKE_PTR(db);
}
Ejemplo n.º 3
0
static uim_lisp
uim_sqlite3_prepare(uim_lisp db_, uim_lisp zSql_, uim_lisp nBytes_)
{
  sqlite3_stmt *ppStmt;
  const char *pzTail;

  if (sqlite3_prepare(C_PTR(db_), REFER_C_STR(zSql_), C_INT(nBytes_), &ppStmt, &pzTail) != SQLITE_OK)
    ERROR_OBJ(sqlite3_errmsg(C_PTR(db_)), zSql_);
  return CONS(MAKE_PTR(ppStmt), MAKE_STR(pzTail));
}
Ejemplo n.º 4
0
static uim_lisp
file_mtime(uim_lisp filename)
{
  struct stat st;
  int err;

  err = stat(REFER_C_STR(filename), &st);
  if (err)
    ERROR_OBJ("stat failed for file", filename);

  return MAKE_INT(st.st_mtime);
}
Ejemplo n.º 5
0
static void
validate_segment_index(anthy_context_t ac, int i)
{
  int err;
  struct anthy_conv_stat cs;

  err = anthy_get_stat(ac, &cs);
  if (err)
    uim_fatal_error("anthy_get_stat() failed");
  if (!(0 <= i && i < cs.nr_segment))
    ERROR_OBJ("invalid segment index", MAKE_INT(i));
}
Ejemplo n.º 6
0
static uim_lisp
c_file_position_set(uim_lisp fildes_, uim_lisp offset_, uim_lisp whence_)
{
  int ret = 0;

  ret = lseek(C_INT(fildes_), C_INT(offset_), C_INT(whence_));
  if (ret == -1) {
    uim_lisp err_ = LIST3(fildes_, offset_, whence_);
    ERROR_OBJ(strerror(errno), err_);
  }
  return MAKE_INT(ret);
}
Ejemplo n.º 7
0
Archivo: ffi.c Proyecto: NgoHuy/uim
static object_type
select_object_type(uim_lisp type_)
{
  if (strcmp(REFER_C_STR(type_), "void") == 0)
    return RET_VOID;
  if (strcmp(REFER_C_STR(type_), "unsigned-char") == 0)
    return RET_UCHAR;
  if (strcmp(REFER_C_STR(type_), "signed-char") == 0)
    return RET_SCHAR;
  if (strcmp(REFER_C_STR(type_), "char") == 0)
    return RET_SCHAR;
  if (strcmp(REFER_C_STR(type_), "unsigned-short") == 0)
    return RET_USHORT;
  if (strcmp(REFER_C_STR(type_), "signed-short") == 0)
    return RET_SSHORT;
  if (strcmp(REFER_C_STR(type_), "short") == 0)
    return RET_SSHORT;
  if (strcmp(REFER_C_STR(type_), "unsigned-int") == 0)
    return RET_SINT;
  if (strcmp(REFER_C_STR(type_), "signed-int") == 0)
    return RET_SINT;
  if (strcmp(REFER_C_STR(type_), "int") == 0)
    return RET_SINT;
  if (strcmp(REFER_C_STR(type_), "unsigned-long") == 0)
    return RET_ULONG;
  if (strcmp(REFER_C_STR(type_), "signed-long") == 0)
    return RET_SLONG;
  if (strcmp(REFER_C_STR(type_), "long") == 0)
    return RET_SLONG;
  if (strcmp(REFER_C_STR(type_), "float") == 0)
    return RET_FLOAT;
  if (strcmp(REFER_C_STR(type_), "double") == 0)
    return RET_DOUBLE;
  if (strcmp(REFER_C_STR(type_), "string") == 0)
    return RET_STR;
  if (strcmp(REFER_C_STR(type_), "pointer") == 0)
    return RET_PTR;
  if (strcmp(REFER_C_STR(type_), "scheme-object") == 0)
    return RET_SCM;

  ERROR_OBJ("unknown object type", type_);
  return RET_UNKNOWN;
}