Ejemplo n.º 1
0
static uim_lisp
uim_sqlite3_bind_text(uim_lisp pStmt_, uim_lisp idx_, uim_lisp str_, uim_lisp nBytes_)
{
  if (sqlite3_bind_text(C_PTR(pStmt_), C_INT(idx_), REFER_C_STR(str_), C_INT(nBytes_), SQLITE_TRANSIENT) != SQLITE_OK)
    uim_scm_f();
  return uim_scm_t();
}
Ejemplo n.º 2
0
static uim_lisp
get_nth_candidate(uim_lisp ac_, uim_lisp seg_, uim_lisp nth_)
{
  anthy_context_t ac;
  int seg, nth, buflen;
  char *buf;
  uim_lisp buf_;
  
  ac = get_anthy_context(ac_);
  seg = C_INT(seg_);
  nth  = C_INT(nth_);

  buflen = anthy_get_segment(ac, seg, nth, NULL, 0);
  if (buflen == -1)
    uim_fatal_error("anthy_get_segment() failed");

  buf = uim_malloc(buflen + 1);
  buflen = anthy_get_segment(ac, seg, nth, buf, buflen + 1);
  if (buflen == -1) {
    free(buf);
    uim_fatal_error("anthy_get_segment() failed");
  }
  buf_ = MAKE_STR_DIRECTLY(buf);

  return buf_;
}
Ejemplo n.º 3
0
static uim_lisp
uim_sqlite3_bind_int(uim_lisp pStmt_, uim_lisp idx_, uim_lisp val_)
{
  if (sqlite3_bind_int(C_PTR(pStmt_), C_INT(idx_), C_INT(val_)) != SQLITE_OK)
    uim_scm_f();
  return uim_scm_t();
}
Ejemplo n.º 4
0
static uim_lisp
c_file_poll(uim_lisp fds_, uim_lisp timeout_)
{
  struct pollfd *fds;
  int timeout = C_INT(timeout_);
  int nfds = uim_scm_length(fds_);
  uim_lisp fd_ = uim_scm_f();
  int i;
  int ret;
  uim_lisp ret_;
  struct c_file_poll_args args;

  fds = uim_calloc(nfds, sizeof(struct pollfd));

  for (i = 0; i < nfds; i++) {
    fd_ = CAR(fds_);
    fds[i].fd = C_INT(CAR(fd_));
    fds[i].events = C_INT(CDR(fd_));
    fds_ = CDR(fds_);
  }

  ret = poll(fds, nfds, timeout);
  if (ret == -1)
    return uim_scm_f();
  else if (ret == 0)
    return uim_scm_null();

  args.fds = fds;
  args.nfds = nfds;
  ret_ = (uim_lisp)uim_scm_call_with_gc_ready_stack((uim_gc_gate_func_ptr)c_file_poll_internal,
						    (void *)&args);
  free(fds);
  return uim_scm_callf("reverse", "o", ret_);
}
Ejemplo n.º 5
0
static uim_lisp
c_duplicate2_fileno(uim_lisp oldd_, uim_lisp newd_)
{
  if (FALSEP(newd_))
    return MAKE_INT(dup(C_INT(oldd_)));
  return MAKE_INT(dup2(C_INT(oldd_), C_INT(newd_)));
}
Ejemplo n.º 6
0
Archivo: intl.c Proyecto: ghpenguin/uim
static uim_lisp
intl_dcngettext(uim_lisp domainname, uim_lisp msgid1, uim_lisp msgid2, uim_lisp n, uim_lisp category)
{
    return MAKE_STR(dcngettext(REFER_C_STR(domainname),
                               REFER_C_STR(msgid1),
                               REFER_C_STR(msgid2),
                               C_INT(n),
                               C_INT(category)));
}
Ejemplo n.º 7
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.º 8
0
static uim_lisp
commit_segment(uim_lisp ac_, uim_lisp seg_, uim_lisp nth_)
{
  anthy_context_t ac;
  int seg, nth;

  ac = get_anthy_context(ac_);
  seg = C_INT(seg_);
  nth = C_INT(nth_);

  anthy_commit_segment(ac, seg, nth);
  return uim_scm_f();
}
Ejemplo n.º 9
0
static uim_lisp
resize_segment(uim_lisp ac_, uim_lisp seg_, uim_lisp delta_)
{
  anthy_context_t ac;
  int seg, delta;

  ac = get_anthy_context(ac_);
  seg = C_INT(seg_);
  delta = C_INT(delta_);

  anthy_resize_segment(ac, seg, delta);
  return uim_scm_f();
}
Ejemplo n.º 10
0
static uim_lisp
get_nth_prediction(uim_lisp ac_, uim_lisp nth_)
{
#ifdef HAS_ANTHY_PREDICTION
  anthy_context_t ac;
  int nth, buflen;
  char *buf;
  uim_lisp buf_;

  ac = get_anthy_context(ac_);
  nth = C_INT(nth_); 

  buflen = anthy_get_prediction(ac, nth, NULL, 0);
  if (buflen == -1)
    uim_fatal_error("anthy_get_prediction() failed");

  buf = uim_malloc(buflen + 1);
  buflen = anthy_get_prediction(ac, nth, buf, buflen + 1);
  if (buflen == -1) {
    free(buf);
    uim_fatal_error("anthy_get_prediction() failed");
  }
  buf_ = MAKE_STR_DIRECTLY(buf);

  return buf_;
#else
  return uim_scm_f();
#endif
}
Ejemplo n.º 11
0
static uim_lisp
c_getaddrinfo(uim_lisp hostname_, uim_lisp servname_, uim_lisp hint_)
{
  const char *hostname;
  char *servname = NULL;
  struct addrinfo *hints = C_PTR(hint_);
  struct addrinfo *res, *res0;
  uim_lisp ret_ = uim_scm_null();
  int error;

  if (INTP(servname_)) {
    uim_asprintf(&servname, "%d", C_INT(servname_));
  } else {
    servname = C_STR(servname_);
  }

  if (FALSEP(hostname_))
    hostname = NULL;
  else
    hostname = REFER_C_STR(hostname_);
  error = getaddrinfo(hostname, servname, hints, &res0);
  if (error) {
    const char *errstr = gai_strerror(error);
    uim_notify_fatal("getaddrinfo: %s", errstr);
    free(servname);
    return uim_scm_f();
  }

  free(servname);
  for (res = res0; res; res = res->ai_next) {
    ret_ = CONS(MAKE_PTR(res) , ret_);
  }
  return uim_scm_callf("reverse", "o", ret_);
}
Ejemplo n.º 12
0
static uim_lisp
home_directory(uim_lisp user_)
{
  int uid;
  char home[MAXPATHLEN];

  if (INTP(user_)) {
    uid = C_INT(user_);
  } else if (STRP(user_)) {
    struct passwd *pw;

    pw = getpwnam(REFER_C_STR(user_));

    if (!pw)
      return uim_scm_f();

    uid = pw->pw_uid;
    endpwent();
  } else {
    return uim_scm_f();
  }

  if (!uim_get_home_directory(home, sizeof(home), uid)) {
    char *home_env = getenv("HOME");
    if (home_env)
      return MAKE_STR(home_env);
    return uim_scm_f();
  }

  return MAKE_STR(home);
}
Ejemplo n.º 13
0
Archivo: m17nlib.c Proyecto: NgoHuy/uim
static uim_lisp
get_right_of_candidate(uim_lisp id_)
{
  int id, i;
  uim_lisp buf_;
  char *buf, *p;
  MInputContext *ic;

  id = C_INT(id_);
  ic = ic_array[id].mic;

  if (!ic)
    return MAKE_STR("");

  buf = convert_mtext2str(ic->preedit);
  p = buf;

  for (i = 0; i < ic->candidate_to ;i++)
    p = m17nlib_utf8_find_next_char(p);

  buf_ = MAKE_STR(p);
  free(buf);

  return buf_;
}
Ejemplo n.º 14
0
Archivo: m17nlib.c Proyecto: NgoHuy/uim
static uim_lisp
get_selected_candidate(uim_lisp id_)
{
  int id, i;
  uim_lisp buf_;
  char *buf, *p, *start;
  MInputContext *ic;

  id = C_INT(id_);
  ic = ic_array[id].mic;

  if (!ic)
    return MAKE_STR("");

  buf = convert_mtext2str(ic->preedit);
  p = buf;

  if (!p)
    return MAKE_STR("");

  for (i = 0; i < ic->candidate_from ;i++)
    p = m17nlib_utf8_find_next_char(p);
  start = p;

  for (i = 0; i < ic->candidate_to - ic->candidate_from ;i++)
    p = m17nlib_utf8_find_next_char(p);
  *p = '\0';

  buf_ = MAKE_STR(start);
  free(buf);

  return buf_;
}
Ejemplo n.º 15
0
Archivo: m17nlib.c Proyecto: NgoHuy/uim
static uim_lisp
get_left_of_cursor(uim_lisp id_)
{
  int id, i;
  uim_lisp buf_;
  char *buf, *p;
  MInputContext *ic;

  id = C_INT(id_);
  ic = ic_array[id].mic;

  if (!ic)
    return MAKE_STR("");

  if (ic->cursor_pos == 0)
    return MAKE_STR("");

  buf = convert_mtext2str(ic->preedit);
  p = buf;

  for (i = 0; i < ic->cursor_pos ;i++)
    p = m17nlib_utf8_find_next_char(p);
  *p = '\0';

  buf_ = MAKE_STR_DIRECTLY(buf);

  return buf_;
}
Ejemplo n.º 16
0
static uim_lisp
create_context(uim_lisp encoding_)
{
  anthy_context_t ac;
  uim_lisp ac_;
  int encoding;

  /* 0: compiled, 1: EUC-JP, 2: UTF-8 */
  encoding = C_INT(encoding_);

  if (!iconv_cd_e2u)
    iconv_cd_e2u = uim_iconv->create("UTF-8", "EUC-JP");

  if (!iconv_cd_u2e)
    iconv_cd_u2e = uim_iconv->create("EUC-JP", "UTF-8");

  ac = anthy_create_context();
  if (!ac)
    uim_fatal_error("anthy_create_context() failed");

  anthy_context_set_encoding(ac, encoding);
  ac_ = MAKE_PTR(ac);
  context_list = uim_scm_callf("cons", "oo", ac_, context_list);

  return ac_;
}
Ejemplo n.º 17
0
static uim_lisp
im_activate_candidate_selector(uim_lisp uc_,
                               uim_lisp nr_, uim_lisp display_limit_)
{
    uim_context uc;
    int nr, display_limit;

    uc = retrieve_uim_context(uc_);
    nr = C_INT(nr_);
    display_limit = C_INT(display_limit_);

    if (uc->candidate_selector_activate_cb)
        uc->candidate_selector_activate_cb(uc->ptr, nr, display_limit);

    return uim_scm_f();
}
Ejemplo n.º 18
0
Archivo: intl.c Proyecto: ghpenguin/uim
static uim_lisp
intl_ngettext(uim_lisp msgid1, uim_lisp msgid2, uim_lisp n)
{
    return MAKE_STR(ngettext(REFER_C_STR(msgid1),
                             REFER_C_STR(msgid2),
                             C_INT(n)));
}
Ejemplo n.º 19
0
static uim_lisp
c_addrinfo_set_ai_protocol(uim_lisp addrinfo_, uim_lisp ai_protocol_)
{
  struct addrinfo *addrinfo = C_PTR(addrinfo_);

  addrinfo->ai_protocol = C_INT(ai_protocol_);
  return uim_scm_t();
}
Ejemplo n.º 20
0
static uim_lisp
uim_sqlite3_column_text(uim_lisp pStmt_, uim_lisp iCol_)
{
  const unsigned char *ret = sqlite3_column_text(C_PTR(pStmt_), C_INT(iCol_));
  if (ret)
    return MAKE_STR(ret);
  return uim_scm_f();
}
Ejemplo n.º 21
0
static long 
verbose_level(void)
{
  uim_lisp vlevel;

  vlevel = uim_scm_callf("verbose", "");
  return C_INT(vlevel);
}
Ejemplo n.º 22
0
static uim_lisp
c_addrinfo_set_ai_family(uim_lisp addrinfo_, uim_lisp ai_family_)
{
  struct addrinfo *addrinfo = C_PTR(addrinfo_);

  addrinfo->ai_family = C_INT(ai_family_);
  return uim_scm_t();
}
Ejemplo n.º 23
0
Archivo: intl.c Proyecto: ghpenguin/uim
static uim_lisp
intl_dngettext(uim_lisp domainname, uim_lisp msgid1, uim_lisp msgid2, uim_lisp n)
{
    return MAKE_STR(dngettext(REFER_C_STR(domainname),
                              REFER_C_STR(msgid1),
                              REFER_C_STR(msgid2),
                              C_INT(n)));
}
Ejemplo n.º 24
0
static uim_lisp
c_addrinfo_set_ai_socktype(uim_lisp addrinfo_, uim_lisp ai_socktype_)
{
  struct addrinfo *addrinfo = C_PTR(addrinfo_);

  addrinfo->ai_socktype = C_INT(ai_socktype_);
  return uim_scm_t();
}
Ejemplo n.º 25
0
static uim_lisp
c_set_sockaddr_un_sun_family(uim_lisp sun_, uim_lisp family_)
{
  struct sockaddr_un *s_un = C_PTR(sun_);

  s_un->sun_family = C_INT(family_);
  return uim_scm_t();
}
Ejemplo n.º 26
0
static uim_lisp
c_process_waitpid(uim_lisp pid_, uim_lisp options_)
{
  uim_lisp ret_ = uim_scm_null();
  int status;

  ret_ = MAKE_INT(waitpid(C_INT(pid_), &status, C_INT(options_)));
  if (WIFEXITED(status))
    return LIST5(ret_, uim_scm_t(), uim_scm_f(), uim_scm_f(), MAKE_INT(WEXITSTATUS(status)));
  else if (WIFSIGNALED(status))
    return LIST5(ret_, uim_scm_f(), uim_scm_t(), uim_scm_f(), MAKE_INT(WTERMSIG(status)));
#ifdef WIFSTOPPED
  else if (WIFSTOPPED(status))
    return LIST5(ret_, uim_scm_f(), uim_scm_f(), uim_scm_t(), MAKE_INT(WSTOPSIG(status)));
#endif

  return LIST5(ret_, uim_scm_f(), uim_scm_f(), uim_scm_f(), MAKE_INT(status));
}
Ejemplo n.º 27
0
Archivo: m17nlib.c Proyecto: NgoHuy/uim
static uim_lisp
get_input_method_short_desc(uim_lisp nth_)
{
  int nth;
  char *str = NULL, *p;
  uim_lisp ret;

  nth = C_INT(nth_);

  if (nth < nr_input_methods) {
    MInputMethod *im;
    MText *desc;

    im = im_instance(nth);
    if (!im)
      return MAKE_STR(N_("m17n library IM open error"));

    desc = minput_get_description(im->language, im->name);
    if (desc) {
      int i, len;

      str = convert_mtext2str(desc);
      p = strchr(str, '.');
      if (p)
	*p = '\0';
      len = strlen(str);

      /*
       * Workaround for the descriptions which lack period.
       * Also we avoid the description with non English words.
       * See https://bugs.freedesktop.org/show_bug.cgi?id=6972
       */
      for (i = 0; i < len; i++) {
	if (str[i] == '\n') {
	  str[i] = '\0';
	  break;
	}
#ifdef HAVE_ISASCII
	else if (!isascii((int)str[i])) {
#else
	else if ((int)str[i] & ~0x7f) {
#endif
	  free(str);
	  str = NULL;
	  break;
	}
      }
      m17n_object_unref(desc);
    }

    if (str) {
      ret = MAKE_STR(str);
      free(str);
    } else {
      ret = MAKE_STR(N_("An input method provided by the m17n library"));
    }
  } else
Ejemplo n.º 28
0
static uim_lisp
c_accept(uim_lisp s_, uim_lisp storage_)
{
  socklen_t storagelen;
  struct sockaddr_storage *storage = C_PTR(storage_);

  storagelen = sizeof(struct sockaddr_storage);
  return MAKE_INT(accept(C_INT(s_), (struct sockaddr *)storage, &storagelen));
}
Ejemplo n.º 29
0
static uim_lisp
c_getpeereid(uim_lisp s_)
{
  uid_t euid;
  gid_t egid;

  if (getpeereid(C_INT(s_), &euid, &egid) == -1)
    return uim_scm_f();
  return CONS(MAKE_INT(euid), MAKE_INT(egid));
}
Ejemplo n.º 30
0
Archivo: expat.c Proyecto: DirtYiCE/uim
static void *
uim_xml_parse_internal(struct uim_xml_parse_args *args)
{
  uim_xml_ctx *ctx = C_PTR(args->ctx_);
  const XML_Char *s = REFER_C_STR(args->s_);
  int isFinal = C_INT(args->isFinal_);

  XML_SetUserData(ctx->parser, ctx->data);
  return MAKE_INT(XML_Parse(ctx->parser, s, strlen(s), isFinal));
}