Beispiel #1
0
static uim_lisp
c_time(void)
{
  time_t now;

  if ((time(&now)) == (time_t) -1)
    return CONS(MAKE_SYM("error"), MAKE_STR(strerror(errno)));
  return time_t_to_uim_lisp(now);
}
Beispiel #2
0
Datei: ffi.c Projekt: NgoHuy/uim
static uim_lisp
make_arg_cons(const opt_args *arg)
{
  return CONS(MAKE_SYM(arg->arg), MAKE_INT(arg->flag));
}
Beispiel #3
0
/*
 * Scheme interfaces
 */
static uim_lisp
notify_get_plugins_internal(void)
{
  uim_lisp ret_;
  DIR *dirp;
  struct dirent *dp;
  size_t plen, slen;
  const uim_notify_desc *desc;
  void *handle;
  uim_notify_desc *(*desc_func)(void);
  const char *str;

  plen = sizeof(NOTIFY_PLUGIN_PREFIX);
  slen = sizeof(NOTIFY_PLUGIN_SUFFIX);

  desc = uim_notify_stderr_get_desc();
  ret_ = CONS(LIST3(MAKE_SYM(desc->name),
		    MAKE_STR(desc->name),
		    MAKE_STR(desc->desc)),
	      uim_scm_null());

  if (getenv("UIM_DISABLE_NOTIFY") != NULL)
    return uim_scm_callf("reverse", "o", ret_);

  dirp = opendir(NOTIFY_PLUGIN_PATH);
  if (dirp) {
    while ((dp = readdir(dirp)) != NULL) {
      size_t len = strlen(dp->d_name);
      char path[PATH_MAX];
      if ((len < plen + slen - 1) ||
	  (PATH_MAX < (sizeof(NOTIFY_PLUGIN_PATH "/") + len)) ||
	  (strcmp(dp->d_name, NOTIFY_PLUGIN_PREFIX) <= 0) ||
	  (strcmp(dp->d_name + len + 1 - slen, NOTIFY_PLUGIN_SUFFIX) != 0))
	continue;

      snprintf(path, sizeof(path), "%s/%s", NOTIFY_PLUGIN_PATH, dp->d_name);
      handle = dlopen(path, RTLD_NOW);
      if ((str = dlerror()) != NULL) {
	fprintf(stderr, "load failed %s(%s)\n", path, str);
	continue;
      }
      desc_func = (uim_notify_desc *(*)(void))dlfunc(handle, "uim_notify_plugin_get_desc");
      if (!desc_func) {
	fprintf(stderr, "cannot found 'uim_notify_get_desc()' in %s\n", path);
	dlclose(handle);
	continue;
      }

      desc = desc_func();

      ret_ = CONS(LIST3(MAKE_SYM(desc->name),
			MAKE_STR(desc->name),
			MAKE_STR(desc->desc)),
		  ret_);

      dlclose(handle);
    }
    (void)closedir(dirp);
  }
  return uim_scm_callf("reverse", "o", ret_);
}