Author: iratqq
Date: Sun Dec  7 09:58:19 2008
New Revision: 5641

Added:
   trunk/uim/uim-iconv.h
Modified:
   trunk/uim/iconv.c
   trunk/uim/uim.c

Log:
* uim/uim.c (uim_init_internal):
  Call uim_init_iconv_subrs().
* uim/iconv.c (uim_ext_iconv_open, uim_ext_iconv_code_conv)
  (uim_ext_iconv_release, uim_init_iconv_subrs):
  Export iconv-* functions.
* uim/uim-iconv.h:
  New file.


Modified: trunk/uim/iconv.c
==============================================================================
--- trunk/uim/iconv.c   (original)
+++ trunk/uim/iconv.c   Sun Dec  7 09:58:19 2008
@@ -45,7 +45,9 @@
 #include "uim.h"
 #include "uim-internal.h"
 #include "uim-util.h"
-
+#include "uim-scm.h"
+#include "uim-scm-abbrev.h"
+#include "uim-iconv.h"

 #define MBCHAR_LEN_MAX 6  /* assumes CESU-8 */

@@ -299,4 +301,49 @@
     err = iconv_close((iconv_t)obj);

   UIM_CATCH_ERROR_END();
+}
+
+static uim_lisp
+uim_ext_iconv_open(uim_lisp tocode_, uim_lisp fromcode_)
+{
+  const char *tocode = REFER_C_STR(tocode_);
+  const char *fromcode = REFER_C_STR(fromcode_);
+  iconv_t ic;
+
+  ic = uim_iconv_create(tocode, fromcode);
+  if (!ic)
+    return uim_scm_f();
+
+  return MAKE_PTR(ic);
+}
+
+static uim_lisp
+uim_ext_iconv_code_conv(uim_lisp ic_, uim_lisp inbuf_)
+{
+  uim_lisp outbuf_;
+  char *outbuf;
+
+  outbuf = uim_iconv_code_conv(C_PTR(ic_), REFER_C_STR(inbuf_));
+  if (!outbuf)
+    return uim_scm_f();
+
+  outbuf_ = MAKE_STR(outbuf);
+  free(outbuf);
+
+  return outbuf_;
+}
+
+static uim_lisp
+uim_ext_iconv_release(uim_lisp ic_)
+{
+  uim_iconv_release(C_PTR(ic_));
+  return uim_scm_t();
+}
+
+void
+uim_init_iconv_subrs(void)
+{
+  uim_scm_init_proc2("iconv-open", uim_ext_iconv_open);
+  uim_scm_init_proc2("iconv-code-conv", uim_ext_iconv_code_conv);
+  uim_scm_init_proc1("iconv-release", uim_ext_iconv_release);
 }

Added: trunk/uim/uim-iconv.h
==============================================================================
--- (empty file)
+++ trunk/uim/uim-iconv.h       Sun Dec  7 09:58:19 2008
@@ -0,0 +1,49 @@
+/*
+
+  Copyright (c) 2008 uim Project http://code.google.com/p/uim/
+
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in the
+     documentation and/or other materials provided with the distribution.
+  3. Neither the name of authors nor the names of its contributors
+     may be used to endorse or promote products derived from this software
+     without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  SUCH DAMAGE.
+
+*/
+
+#ifndef UIM_ICONV_H
+#define UIM_ICONV_H
+
+#include "uim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void uim_init_iconv_subrs(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: trunk/uim/uim.c
==============================================================================
--- trunk/uim/uim.c     (original)
+++ trunk/uim/uim.c     Sun Dec  7 09:58:19 2008
@@ -43,6 +43,7 @@
 #include "uim.h"
 #include "uim-internal.h"
 #include "uim-util.h"
+#include "uim-iconv.h"
 #include "uim-posix.h"
 #include "uim-im-switcher.h"
 #include "uim-scm.h"
@@ -131,6 +132,7 @@

   uim_init_im_subrs();
   uim_init_intl_subrs();
+  uim_init_iconv_subrs();
   uim_init_posix_subrs();
   uim_init_util_subrs();
 #if UIM_USE_NOTIFY

Reply via email to