Ejemplo n.º 1
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.º 2
0
static uim_lisp
time_t_to_uim_lisp(time_t t)
{
  char t_str[64];

  snprintf(t_str, sizeof(t_str), "%.32g", (double)t);
  return MAKE_STR(t_str);
}
Ejemplo n.º 3
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.º 4
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.º 5
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);
}
Ejemplo n.º 6
0
Archivo: expat.c Proyecto: DirtYiCE/uim
static void
xml_end_element_handler(void *userData, const XML_Char *name)
{
  uim_xml_userdata *data = (uim_xml_userdata *)userData;

  if (data && data->end_) {
    uim_scm_call(data->end_, LIST1(MAKE_STR(name)));
  }
}
Ejemplo n.º 7
0
static uim_lisp
user_name(void)
{
  char name[BUFSIZ];

  if (!uim_get_user_name(name, sizeof(name), getuid()))
    return uim_scm_f();

  return MAKE_STR(name);
}
Ejemplo n.º 8
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.º 9
0
static uim_lisp
c_prepare_config_path(uim_lisp is_getenv_)
{
  char path[MAXPATHLEN];
  int need_prepare = UIM_TRUE;

  if (!uim_get_config_path_internal(path, sizeof(path), C_BOOL(is_getenv_), need_prepare))
    return uim_scm_f();
  return MAKE_STR(path);
}
Ejemplo n.º 10
0
void CPluginStream::BeginNode(LPCTSTR id)
{
	STREAM_DATA dt;
	ZeroMemory(&dt, sizeof(dt));
	MAKE_STR(dt.id, id);
	dt.type = SDT_BEGINNODE;
	m_data.Add(&dt);
	int nodeIndex = m_data.GetCount() - 1;
	m_nodes.Add(&nodeIndex);
}
Ejemplo n.º 11
0
BOOL CBatchRunBtn::Load(IStream *data)
{ 
	CPluginStream stream;
	if(stream.Load(data))
	{
		if(stream.OpenNode(TEXT("settings")))
		{
			MAKE_STR(m_iconLocation, stream.GetString(TEXT("iconLocation")));
			m_hotKey = stream.GetWORD(TEXT("runhotkey"), 0);
			stream.CloseNode();

			if(m_hotKey)
			{
				m_container->SetHotKey(m_hotKey, HOTKEY_RUN);
			}
		}
		if(stream.OpenNode(TEXT("progs")))
		{
			int cnt = stream.GetDWORD(TEXT("count"), 0);
			for(int i=0; i < cnt; i++)
			{
				TCHAR node[255];
				wsprintf(node, TEXT("app#%d"), i);
				if(stream.OpenNode(node))
				{
					FILE_TO_RUN fl;
					ZeroMemory(&fl, sizeof(FILE_TO_RUN));
					MAKE_STR(fl.fileName,	stream.GetString(TEXT("path")));
					MAKE_STR(fl.params,		stream.GetString(TEXT("params")));
					MAKE_STR(fl.workingDir, stream.GetString(TEXT("workDir")));
					m_progs.Add(&fl);

					stream.CloseNode();
				}
			}

			stream.CloseNode();
		}
	}

	return TRUE; 
}
Ejemplo n.º 12
0
static uim_lisp
c_get_config_path(uim_lisp is_getenv_)
{
  char path[MAXPATHLEN];
  int need_prepare = UIM_FALSE;

  /* No need to check the existence of path in this function */
  uim_get_config_path_internal(path, sizeof(path), C_BOOL(is_getenv_), need_prepare);

  return MAKE_STR(path);
}
Ejemplo n.º 13
0
static uim_lisp
c_getenv(uim_lisp str)
{
  char *val;

  ENSURE_TYPE(str, str);

  val = getenv(REFER_C_STR(str));

  return (val) ? MAKE_STR(val) : uim_scm_f();
}
Ejemplo n.º 14
0
Archivo: curl.c Proyecto: NgoHuy/uim
static void *
uim_curl_post_internal(struct uim_curl_post_args *args)
{
  uim_lisp post_ = args->post;
  uim_lisp post_car_, post_cdr_;
  uim_lisp fetched_str_;
  const char *url = REFER_C_STR(args->url);
  CURL *curl;
  CURLcode res;
  struct curl_memory_struct chunk;
  struct curl_httppost* post_first = NULL;
  struct curl_httppost* post_last = NULL;

  curl = curl_easy_init();

  if(curl == NULL)
    return uim_scm_f();

  memset(&chunk, 0, sizeof(struct curl_memory_struct));

  curl_easy_setopt(curl, CURLOPT_URL, url);
  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, uim_curl_write_func);
  curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);

  for(post_cdr_ = post_;
      !NULLP(post_cdr_);
      post_cdr_ = CDR(post_cdr_)) {
      const char *name, *value;
      post_car_ = CAR(post_cdr_);

      name = REFER_C_STR(CAR(post_car_));
      value = REFER_C_STR(CDR(post_car_));

      curl_formadd(&post_first, &post_last,
		   CURLFORM_COPYNAME, name,
		   CURLFORM_COPYCONTENTS, value,
		   CURLFORM_END);
  }

  curl_easy_setopt(curl, CURLOPT_HTTPPOST, post_first);

  res = uim_curl_perform(curl);

  fetched_str_ = (chunk.str != NULL) ? MAKE_STR(chunk.str) : uim_scm_f();

  curl_easy_cleanup(curl);
  curl_formfree(post_first);
  curl_global_cleanup();
  free(chunk.str);

  return (void *)fetched_str_;
}
Ejemplo n.º 15
0
Archivo: intl.c Proyecto: ghpenguin/uim
static uim_lisp
intl_dgettext(uim_lisp domainname, uim_lisp msgid)
{
    const char *translated;

    if (!STRP(domainname) || !STRP(msgid))
        return uim_scm_f();

    translated = dgettext(REFER_C_STR(domainname),
                          REFER_C_STR(msgid));

    return MAKE_STR(translated);
}
Ejemplo n.º 16
0
void CPluginStream::saveData(LPCTSTR id, DWORD type, LPBYTE data, DWORD cbSize)
{
	STREAM_DATA dt;
	ZeroMemory(&dt, sizeof(dt));
	MAKE_STR(dt.id, id);
	dt.type = type;
	dt.cbSize = cbSize;
	if(cbSize) 
	{
		dt.lpData = new BYTE[cbSize];
		memcpy(dt.lpData, data, cbSize);
	}
	m_data.Add(&dt);
}
Ejemplo n.º 17
0
Archivo: expat.c Proyecto: DirtYiCE/uim
static void
xml_characterdata_handler(void *userData, const XML_Char *s, int len)
{
  uim_xml_userdata *data = (uim_xml_userdata *)userData;

  char *str = uim_malloc(len + 1);

  memcpy(str, s, len);
  str[len] = '\0';

  if (data && data->characterdata_) {
    uim_scm_call(data->characterdata_, LIST1(MAKE_STR(str)));
  }

  free(str);
}
Ejemplo n.º 18
0
Archivo: expat.c Proyecto: DirtYiCE/uim
static void
xml_start_element_handler(void *userData, const XML_Char *name, const XML_Char *atts[])
{
  uim_xml_userdata *data = (uim_xml_userdata *)userData;

  if (data && data->start_) {
    uim_lisp atts_;

    atts_ = (uim_lisp)uim_scm_call_with_gc_ready_stack((uim_gc_gate_func_ptr)xml_start_element_handler_internal,
						       (void *)atts);

    atts_ = uim_scm_callf("reverse", "o", atts_);

    uim_scm_call(data->start_, LIST2(MAKE_STR(name), atts_));
  }
}
Ejemplo n.º 19
0
Archivo: m17nlib.c Proyecto: NgoHuy/uim
static uim_lisp
get_input_method_lang(uim_lisp nth_)
{
  int nth;
  const char *lang;

  nth = C_INT(nth_);

  if (nth < nr_input_methods) {
    lang = im_array[nth].lang;
    /* "*" is wildcard language. See langgroup-covers? and
     * find-im-for-locale. */
    return MAKE_STR((strcmp(lang, "t") == 0) ? "*" : lang);
  }

  return uim_scm_f();
}
Ejemplo n.º 20
0
Archivo: intl.c Proyecto: ghpenguin/uim
static uim_lisp
intl_textdomain(uim_lisp domainname)
{
    const char *new_domain;

    if (FALSEP(domainname)) {
#if ENABLE_NLS
        new_domain = textdomain(NULL);
#else
        new_domain = "";
#endif
    } else {
        new_domain = textdomain(REFER_C_STR(domainname));
    }

    return MAKE_STR(new_domain);
}
PyMODINIT_FUNC ATTK_INIT_FUNC(void) {
    PyObject *m;

    #ifdef DEBUG
    printf("ATTK_INIT_FUNC (%s) START\n", MAKE_STR(ATTK_INIT_FUNC));
    #endif

    if (PyType_Ready(&AttackClass) < 0)
        return;

    m = Py_InitModule3(ATTK_MODULE_NAME, attk_plug_methods, ATTK_MODULE_DOC);

    build_dict(m, "init_args", attk_data_init_args_d);
    build_dict(m, "start_args", attk_start_args_d);

    Py_INCREF(&AttackClass);
    PyModule_AddObject(m, "attack_class", (PyObject *)&AttackClass);
}
Ejemplo n.º 22
0
Archivo: host-lib.c Proyecto: Oldes/r3
*/	int OS_Get_Current_Dir(REBCHR **path)
/*
**		Return the current directory path as a string and
**		its length in chars (not bytes).
**
**		The result should be freed after copy/conversion.
**
***********************************************************************/
{
	int len;

	len = GetCurrentDirectory(0, NULL); // length, incl terminator.
	*path = MAKE_STR(len);
	GetCurrentDirectory(len, *path);
	len--; // less terminator

	return len; // Be sure to call free() after usage
}
Ejemplo n.º 23
0
Archivo: m17nlib.c Proyecto: NgoHuy/uim
static uim_lisp
get_input_method_name(uim_lisp nth_)
{
  int nth;
  char name[BUFSIZ];
  
  nth = C_INT(nth_);

  if (nth < nr_input_methods) {
    if (!strcmp(im_array[nth].lang, "t"))
      snprintf(name, sizeof(name), "m17n-%s", im_array[nth].name);
    else
      snprintf(name, sizeof(name), "m17n-%s-%s", im_array[nth].lang, im_array[nth].name);

    return MAKE_STR(name);
  }

  return uim_scm_f();
}
Ejemplo n.º 24
0
Archivo: intl.c Proyecto: ghpenguin/uim
static uim_lisp
intl_bindtextdomain(uim_lisp domainname, uim_lisp dirname)
{
    const char *domain, *new_dir;

    domain = REFER_C_STR(domainname);

    if (FALSEP(dirname)) {
#if ENABLE_NLS
        new_dir = bindtextdomain(domain, NULL);
#else
        new_dir = "";
#endif
    } else {
        new_dir = bindtextdomain(domain, REFER_C_STR(dirname));
    }

    return MAKE_STR(new_dir);
}
Ejemplo n.º 25
0
*/	static void Store_Line(STD_TERM *term)
/*
**		Makes a copy of the current buffer and store it in the
**		history list. Returns the copied string.
**
***********************************************************************/
{
	term->buffer[term->end] = 0;
	term->out = MAKE_STR(term->end + 1);
	strcpy(term->out, term->buffer);

	// If max history, drop older lines (but not [0] empty line):
	if (Line_Count >= MAX_HISTORY) {
		free(Line_History[1]);
		memmove(Line_History+1, Line_History+2, (MAX_HISTORY-2)*sizeof(char*));
		Line_Count = MAX_HISTORY-1;
	}

	Line_History[Line_Count++] = term->out;
}
Ejemplo n.º 26
0
Archivo: intl.c Proyecto: ghpenguin/uim
static uim_lisp
intl_bind_textdomain_codeset(uim_lisp domainname, uim_lisp codeset)
{
    const char *c_current_codeset, *c_codeset;
    uim_lisp current_codeset;

    if (!STRP(domainname)
            || !(STRP(codeset) || FALSEP(codeset)))
        return uim_scm_f();

    c_codeset = (FALSEP(codeset)) ? NULL : REFER_C_STR(codeset);
    c_current_codeset
        = bind_textdomain_codeset(REFER_C_STR(domainname), c_codeset);
    if (c_current_codeset) {
        current_codeset = MAKE_STR(c_current_codeset);
    } else {
        current_codeset = uim_scm_f();
    }

    return current_codeset;
}
Ejemplo n.º 27
0
Archivo: curl.c Proyecto: NgoHuy/uim
static void *
uim_curl_url_escape_internal(void *url_)
{
  uim_lisp escaped_url_;
  const char *unescaped_url = REFER_C_STR((uim_lisp)url_);
  char *escaped_url;
  CURL *curl;

  curl = curl_easy_init();

  if(curl == NULL)
    return uim_scm_f();

  escaped_url = curl_easy_escape(curl, unescaped_url, strlen(unescaped_url));
  escaped_url_ = (escaped_url != NULL) ? MAKE_STR(escaped_url) : uim_scm_f();

  curl_free(escaped_url);
  curl_easy_cleanup(curl);
  curl_global_cleanup();

  return (void *)escaped_url_;
}
Ejemplo n.º 28
0
Archivo: look.c Proyecto: DirtYiCE/uim
static uim_lisp
uim_look_look_internal(struct uim_look_look_internal_args *args)
{
  uim_lisp ret_ = uim_scm_null();
  int words = args->words;
  char buf[8192];
  size_t len = strlen(args->dict_str);

  while (uim_look_get(args->dict_str, buf, sizeof(buf), args->ctx) != 0) {
    /* don't use the word itself */
    if (strcasecmp(buf, args->dict_str) == 0)
      continue;
    if (len < strlen(buf))
      ret_ = CONS(MAKE_STR(buf + len), ret_);
    if (words != -1) {
      words--;
      if (words == 0)
	break;
    }
  }
  return ret_;
}
Ejemplo n.º 29
0
Archivo: curl.c Proyecto: NgoHuy/uim
static void *
uim_curl_url_unescape_internal(void *url_)
{
  uim_lisp unescaped_url_;
  const char *escaped_url = REFER_C_STR((uim_lisp)url_);
  char *unescaped_url;
  int len; /* curl_easy_unescape uses int, not size_t */
  CURL *curl;

  curl = curl_easy_init();

  if(curl == NULL)
    return uim_scm_f();

  unescaped_url = curl_easy_unescape(curl, escaped_url,
				     strlen(escaped_url), &len);
  unescaped_url_ = (len > 0) ? MAKE_STR(unescaped_url) : uim_scm_f();

  curl_free(unescaped_url);
  curl_easy_cleanup(curl);
  curl_global_cleanup();

  return (void *)unescaped_url_;
}
Ejemplo n.º 30
0
Archivo: ffi.c Proyecto: NgoHuy/uim
static uim_lisp
c_ffi_call(uim_lisp result_, uim_lisp fun_, uim_lisp argv_)
{
  ffi_cif cif;
  ffi_type **arg_types;
  void **arg_values;
  ffi_status status;
  ffi_type *result_type = NULL;
  void *result;
  int args;
  int i;
  void *p;
  uim_lisp ret_;
  object_type return_object_type;
  int input_void = 0;

  args = uim_scm_length(argv_);
  arg_types = uim_malloc(args * sizeof(void *));
  arg_values = uim_malloc(args * sizeof(ffi_type *));

  return_object_type = select_object_type(result_);

  switch (return_object_type) {
  case RET_UNKNOWN:
    break;
  case RET_VOID:
    result_type = &ffi_type_void;
    break;
  case RET_UCHAR:
    result_type = &ffi_type_uchar;
    break;
  case RET_SCHAR:
    result_type = &ffi_type_schar;
    break;
  case RET_USHORT:
    result_type = &ffi_type_ushort;
    break;
  case RET_SSHORT:
    result_type = &ffi_type_sshort;
    break;
  case RET_ULONG:
    result_type = &ffi_type_ulong;
    break;
  case RET_SLONG:
    result_type = &ffi_type_slong;
    break;
  case RET_UINT:
    result_type = &ffi_type_uint;
    break;
  case RET_SINT:
    result_type = &ffi_type_sint;
    break;
  case RET_FLOAT:
    result_type = &ffi_type_float;
    break;
  case RET_DOUBLE:
    result_type = &ffi_type_double;
    break;
  case RET_STR:
    result_type = &ffi_type_pointer;
    break;
  case RET_PTR:
    result_type = &ffi_type_pointer;
    break;
  case RET_SCM:
    result_type = &ffi_type_pointer;
    break;
  }

  result = uim_malloc(1024); /* huge? */

  for (i = 0; i < args; i++) {
    uim_lisp arg_ = CAR(argv_);

    switch (select_object_type(CAR(arg_))) {
    case RET_UNKNOWN:
      break;
    case RET_VOID:
      input_void = 1;
      break;
    case RET_UCHAR:
      p = uim_malloc(sizeof(unsigned char));
      *((unsigned char *)p) = C_CHAR(CDR(arg_));
      arg_types[i] = &ffi_type_uchar;
      arg_values[i] = p;
      break;
    case RET_SCHAR:
      p = uim_malloc(sizeof(signed char));
      *((signed char *)p) = C_CHAR(CDR(arg_));
      arg_types[i] = &ffi_type_schar;
      arg_values[i] = p;
      break;
    case RET_USHORT:
      p = uim_malloc(sizeof(unsigned short));
      *((unsigned short *)p) = C_INT(CDR(arg_));
      arg_types[i] = &ffi_type_ushort;
      arg_values[i] = p;
      break;
    case RET_SSHORT:
      p = uim_malloc(sizeof(unsigned short));
      *((signed short *)p) = C_INT(CDR(arg_));
      arg_types[i] = &ffi_type_sshort;
      arg_values[i] = p;
      break;
    case RET_UINT:
      p = uim_malloc(sizeof(unsigned int));
      *((unsigned int *)p) = C_INT(CDR(arg_));
      arg_types[i] = &ffi_type_uint;
      arg_values[i] = p;
      break;
    case RET_SINT:
      p = uim_malloc(sizeof(signed int));
      *((signed int *)p) = C_INT(CDR(arg_));
      arg_types[i] = &ffi_type_sint;
      arg_values[i] = p;
      break;
    case RET_ULONG:
      p = uim_malloc(sizeof(unsigned long));
      *((unsigned long *)p) = C_INT(CDR(arg_));
      arg_types[i] = &ffi_type_ulong;
      arg_values[i] = p;
      break;
    case RET_SLONG:
      p = uim_malloc(sizeof(signed long));
      *((signed long *)p) = C_INT(CDR(arg_));
      arg_types[i] = &ffi_type_slong;
      arg_values[i] = p;
      break;
    case RET_FLOAT:
      {
	char *endptr;
	p = uim_malloc(sizeof(float));
	*((double *)p) = strtof(REFER_C_STR(CDR(arg_)), &endptr);
	arg_types[i] = &ffi_type_float;
	arg_values[i] = p;
      }
      break;
    case RET_DOUBLE:
      {
	char *endptr;
	p = uim_malloc(sizeof(double));
	*((double *)p) = strtod(REFER_C_STR(CDR(arg_)), &endptr);
	arg_types[i] = &ffi_type_double;
	arg_values[i] = p;
      }
      break;
    case RET_STR:
      p = uim_malloc(sizeof(void *));
      *((void **)p) = (void *)REFER_C_STR(CDR(arg_));
      arg_types[i] = &ffi_type_pointer;
      arg_values[i] = p;
      break;
    case RET_PTR:
      p = uim_malloc(sizeof(void *));
      if (NULLP(CDR(arg_)))
	*((void **)p) = NULL;
      else
	*((void **)p) = C_PTR(CDR(arg_));
      arg_types[i] = &ffi_type_pointer;
      arg_values[i] = p;
      break;
    case RET_SCM:
      p = uim_malloc(sizeof(void *));
      *((void **)p) = CDR(arg_);
      arg_types[i] = &ffi_type_pointer;
      arg_values[i] = p;
    }
    argv_ = CDR(argv_);
  }

  if (input_void)
    args = 0;
  status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, args, result_type, arg_types);
  switch (status) {
  case FFI_OK:
    break;
  case FFI_BAD_TYPEDEF:
    ffi_strerr_ = ffi_strerr_messages[FFI_STRERR_BAD_TYPEDEF];
    break;
  case FFI_BAD_ABI:
    ffi_strerr_ = ffi_strerr_messages[FFI_STRERR_BAD_ABI];
    break;
  default:
    ffi_strerr_ = ffi_strerr_messages[FFI_STRERR_UNKOWN];
  }

  if (status == FFI_OK)
    ffi_call(&cif, (void (*)(void))C_PTR(fun_), result, arg_values);

  for (i = 0; i < args; i++)
    free(arg_values[i]);
  free(arg_types);
  free(arg_values);

  if (status != FFI_OK) {
    free(result);
    return uim_scm_f();
  }
  ret_ = uim_scm_f();

  switch (return_object_type) {
  case RET_UNKNOWN:
  case RET_VOID:
    break;
  case RET_UCHAR:
    ret_ = MAKE_CHAR(*(unsigned char *)result);
    break;
  case RET_SCHAR:
    ret_ = MAKE_CHAR(*(signed char *)result);
    break;
  case RET_USHORT:
    ret_ = MAKE_INT(*(unsigned short *)result);
    break;
  case RET_SSHORT:
    ret_ = MAKE_INT(*(signed short *)result);
    break;
  case RET_UINT:
    ret_ = MAKE_INT(*(unsigned int *)result);
    break;
  case RET_SINT:
    ret_ = MAKE_INT(*(signed int *)result);
    break;
  case RET_ULONG:
    ret_ = MAKE_INT(*(unsigned long *)result);
    break;
  case RET_SLONG:
    ret_ = MAKE_INT(*(signed long *)result);
    break;
  case RET_FLOAT:
    {
      char str[1024];
      snprintf(str, sizeof(str), "%f", *((float *)result));
      ret_ = MAKE_STR(str);
    }
    break;
  case RET_DOUBLE:
    {
      char str[1024];
      snprintf(str, sizeof(str), "%f", *((double *)result));
      ret_ = MAKE_STR(str);
    }
    break;
  case RET_STR:
    ret_ = MAKE_STR(*((char **)result));
    break;
  case RET_PTR:
    ret_ = MAKE_PTR(*((void **)result));
    break;
  case RET_SCM:
    ret_ = *(uim_lisp *)result;
    break;
  }

  free(result);

  ffi_strerr_ = NULL;

  return ret_;
}