Author: iratqq
Date: Mon Mar  2 04:15:01 2009
New Revision: 5875

Added:
   trunk/m4/openssl.m4
   trunk/scm/openssl.scm
   trunk/uim/openssl.c
Modified:
   trunk/configure.ac
   trunk/scm/Makefile.am
   trunk/uim/Makefile.am

Log:
* uim/openssl.c:
  - New file.
* uim/Makefile.am:
  - Add libuim-openssl.
* m4/openssl.m4:
  - Import from openssh-portable/configure.ac
* configure.ac:
  - Check OpenSSL.
* scm/Makefile.am (SCM_FILES):
  - Add openssl.scm
* scm/openssl.scm:
  - New file.

  Add new uim module 'uim-openssl' to treat SSL protocol.
  default is `--disable-openssl'.


Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac  (original)
+++ trunk/configure.ac  Mon Mar  2 04:15:01 2009
@@ -266,6 +266,21 @@
 expat_found=no
 AM_WITH_EXPAT

+# ***********************
+# *** Tests for OpenSSL ***
+# ***********************
+AC_ARG_ENABLE(openssl,
+  AC_HELP_STRING([--enable-openssl],
+                 [enable openssl @<:@default=no@:>@]),
+  [
+    use_openssl="yes"
+    AM_WITH_OPENSSL
+  ],
+  [
+    use_openssl="no"
+  ])
+
+
 PKG_CHECK_MODULES(X11, x11, x11_use_new_dir="yes", x11_use_new_dir="no")
 AC_PATH_XTRA

@@ -1019,6 +1034,7 @@
 AM_CONDITIONAL(SKK, true)
 AM_CONDITIONAL(CURL, test x$use_curl = xyes)
 AM_CONDITIONAL(EXPAT, test x$expat_found = xyes)
+AM_CONDITIONAL(OPENSSL, test x$use_openssl = xyes)
 AM_CONDITIONAL(GTK2, test x$use_gtk2 = xyes)
 AM_CONDITIONAL(GTK2_4, test x$use_gtk2_4 = xyes)
 AM_CONDITIONAL(DEFAULT_TOOLKIT_GTK, test x$default_toolkit = xgtk)
@@ -1596,6 +1612,7 @@
    SCIM            : ${use_scim}
    cURL            : ${use_curl}
    expat           : ${expat_found}
+   OpenSSL         : ${use_openssl}
    Gtk+            : ${use_gtk2}
    Gnome Applet    : ${use_applet_gnome}
    Qt3             : ${use_qt}

Added: trunk/m4/openssl.m4
==============================================================================
--- (empty file)
+++ trunk/m4/openssl.m4 Mon Mar  2 04:15:01 2009
@@ -0,0 +1,246 @@
+# openssl.m4
+# Configure paths for libwnn
+
+dnl AM_PATH_OPENSSL([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl Test for OpenSSL, and define OPENSSL_CPPFLAGS and OEPNSSL_LIBS
+dnl
+AC_DEFUN([AM_WITH_OPENSSL],
+[dnl
+dnl Get the cflags and libraries
+dnl
+
+saved_CPPFLAGS="$CPPFLAGS"
+saved_LDFLAGS="$LDFLAGS"
+saved_saved_LIBS="$LIBS"
+AC_ARG_WITH(ssl-dir,
+       [  --with-openssl-dir=PATH     Specify path to OpenSSL installation ],
+       [
+               if test "x$withval" != "xno" ; then
+                       case "$withval" in
+                               # Relative paths
+                               ./*|../*)       withval="`pwd`/$withval"
+                       esac
+                       if test -d "$withval/lib"; then
+                               if test -n "${need_dash_r}"; then
+                                       LDFLAGS="-L${withval}/lib -R${withval}/lib 
${LDFLAGS}"
+                               else
+                                       LDFLAGS="-L${withval}/lib ${LDFLAGS}"
+                               fi
+                       else
+                               if test -n "${need_dash_r}"; then
+                                       LDFLAGS="-L${withval} -R${withval} 
${LDFLAGS}"
+                               else
+                                       LDFLAGS="-L${withval} ${LDFLAGS}"
+                               fi
+                       fi
+                       if test -d "$withval/include"; then
+                               CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
+                       else
+                               CPPFLAGS="-I${withval} ${CPPFLAGS}"
+                       fi
+               fi
+       ]
+       [use_openssl="no"]
+)
+
+LIBS="-lcrypto $LIBS"
+AC_CHECK_LIB(ssl, SSL_CTX_new,
+       [
+               LIBS="-lssl $LIBS"
+       ], [
+       AC_MSG_WARN("libssl not found. OpenSSL Disabled...")
+               use_openssl="no"
+       ])
+
+AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL, 1,
+       [Define if your ssl headers are included
+       with #include <openssl/header.h>]),
+       [
+               dnl Check default openssl install dir
+               if test -n "${need_dash_r}"; then
+                       LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib 
${saved_LDFLAGS}"
+               else
+                       LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
+               fi
+               CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
+               AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
+                       [
+ AC_MSG_WARN([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
+                               use_openssl="no"
+                       ]
+               )
+       ]
+)
+
+# Determine OpenSSL header version
+AC_MSG_CHECKING([OpenSSL header version])
+AC_RUN_IFELSE(
+       [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+#include <openssl/opensslv.h>
+#define DATA "conftest.sslincver"
+int main(void) {
+       FILE *fd;
+       int rc;
+
+       fd = fopen(DATA,"w");
+       if(fd == NULL)
+               exit(1);
+
+ if ((rc = fprintf(fd ,"%x (%s)\n", OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT)) <0)
+               exit(1);
+
+       exit(0);
+}
+       ]])],
+       [
+               ssl_header_ver=`cat conftest.sslincver`
+               AC_MSG_RESULT($ssl_header_ver)
+       ],
+       [
+               AC_MSG_RESULT(not found)
+               AC_MSG_WARN(OpenSSL version header not found.)
+               use_openssl="no"
+       ],
+       [
+               AC_MSG_WARN([cross compiling: not checking])
+       ]
+)
+
+# Determine OpenSSL library version
+AC_MSG_CHECKING([OpenSSL library version])
+AC_RUN_IFELSE(
+       [AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <string.h>
+#include <openssl/opensslv.h>
+#include <openssl/crypto.h>
+#define DATA "conftest.ssllibver"
+int main(void) {
+       FILE *fd;
+       int rc;
+
+       fd = fopen(DATA,"w");
+       if(fd == NULL)
+               exit(1);
+
+ if ((rc = fprintf(fd ,"%x (%s)\n", SSLeay(), SSLeay_version(SSLEAY_VERSION))) <0)
+               exit(1);
+
+       exit(0);
+}
+       ]])],
+       [
+               ssl_library_ver=`cat conftest.ssllibver`
+               AC_MSG_RESULT($ssl_library_ver)
+       ],
+       [
+               AC_MSG_RESULT(not found)
+               AC_MSG_WARN(OpenSSL library not found.)
+               use_openssl="no"
+       ],
+       [
+               AC_MSG_WARN([cross compiling: not checking])
+       ]
+)
+
+AC_ARG_WITH(openssl-header-check,
+ [ --without-openssl-header-check Disable OpenSSL version consistency check],
+       [  if test "x$withval" = "xno" ; then
+               openssl_check_nonfatal=1
+          fi
+       ]
+)
+
+# Sanity check OpenSSL headers
+AC_MSG_CHECKING([whether OpenSSL's headers match the library])
+AC_RUN_IFELSE(
+       [AC_LANG_SOURCE([[
+#include <string.h>
+#include <openssl/opensslv.h>
+int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
+       ]])],
+       [
+               AC_MSG_RESULT(yes)
+       ],
+       [
+               AC_MSG_RESULT(no)
+               if test "x$openssl_check_nonfatal" = "x"; then
+                       AC_MSG_WARN([Your OpenSSL headers do not match your
+library. Check config.log for details.
+If you are sure your installation is consistent, you can disable the check
+by running "./configure --without-openssl-header-check".
+Also see contrib/findssl.sh for help identifying header/library mismatches.
+])
+                       use_openssl="no"
+               else
+                       AC_MSG_WARN([Your OpenSSL headers do not match your
+library. Check config.log for details.
+Also see contrib/findssl.sh for help identifying header/library mismatches.])
+                       use_openssl="no"
+               fi
+       ],
+       [
+               AC_MSG_WARN([cross compiling: not checking])
+       ]
+)
+
+AC_MSG_CHECKING([if programs using OpenSSL functions will link])
+AC_LINK_IFELSE(
+       [AC_LANG_SOURCE([[
+#include <openssl/evp.h>
+int main(void) { SSLeay_add_all_algorithms(); }
+       ]])],
+       [
+               AC_MSG_RESULT(yes)
+       ],
+       [
+               AC_MSG_RESULT(no)
+               saved_LIBS="$LIBS"
+               LIBS="$LIBS -ldl"
+               AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
+               AC_LINK_IFELSE(
+                       [AC_LANG_SOURCE([[
+#include <openssl/evp.h>
+int main(void) { SSLeay_add_all_algorithms(); }
+                       ]])],
+                       [
+                               AC_MSG_RESULT(yes)
+                       ],
+                       [
+                               AC_MSG_RESULT(no)
+                               LIBS="$saved_LIBS"
+                       ]
+               )
+       ]
+)
+
+AC_ARG_WITH(ssl-engine,
+       [  --with-ssl-engine       Enable OpenSSL (hardware) ENGINE support ],
+       [ if test "x$withval" != "xno" ; then
+               AC_MSG_CHECKING(for OpenSSL ENGINE support)
+               AC_TRY_COMPILE(
+                       [ #include <openssl/engine.h>],
+                       [
+ENGINE_load_builtin_engines();ENGINE_register_all_complete();
+                       ],
+                       [ AC_MSG_RESULT(yes)
+                         AC_DEFINE(USE_OPENSSL_ENGINE, 1,
+                            [Enable OpenSSL engine support])
+                       ],
+                       [ AC_MSG_WARN(OpenSSL ENGINE support not found)]
+               )
+         fi ]
+)
+
+OPENSSL_CPPFLAGS="$CPPFLAGS"
+OPENSSL_LIBS="$LDFLAGS $LIBS"
+
+CPPFLAGS="$saved_CPPFLAGS"
+LDFLAGS="$saved_LDFLAGS"
+LIBS="$saved_saved_LIBS"
+
+AC_SUBST(OPENSSL_CPPFLAGS)
+AC_SUBST(OPENSSL_LIBS)
+])

Modified: trunk/scm/Makefile.am
==============================================================================
--- trunk/scm/Makefile.am       (original)
+++ trunk/scm/Makefile.am       Mon Mar  2 04:15:01 2009
@@ -44,6 +44,7 @@
  yahoo-jp.scm yahoo-jp-custom.scm yahoo-jp-key-custom.scm \
  uim-module-manager.scm \
  fileio.scm socket.scm http-client.scm process.scm \
+ openssl.scm \
  input-parse.scm match.scm

 ETAGS_ARGS=$(SCM_FILES) $(GENERATED_SCM_FILES)

Added: trunk/scm/openssl.scm
==============================================================================
--- (empty file)
+++ trunk/scm/openssl.scm       Mon Mar  2 04:15:01 2009
@@ -0,0 +1,91 @@
+;;; openssl.scm: low-level OpenSSL functions for uim.
+;;;
+;;; Copyright (c) 2009 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.
+;;;;
+
+(require-extension (srfi 9))
+(require "fileio.scm")
+
+(and (not (provided? "openssl"))
+     (module-load "openssl")
+
+     ;; init
+     (SSL-load-error-strings)
+     (SSL-library-init)
+
+     (provide "openssl"))
+
+(define-record-type openssl-file-internal
+  (make-openssl-file-internal-port ssl-ctx ssl) openssl-file-internal?
+  (ssl-ctx  ssl-ctx?  ssl-ctx!)
+  (ssl      ssl?      ssl!))
+
+(define (ssl-read-internal ssl-port bytes)
+  (SSL-read (ssl? ssl-port) bytes))
+(define (ssl-write-internal ssl-port bytes)
+  (SSL-write (ssl? ssl-port) bytes))
+
+(define (call-with-open-openssl-file-port fd method thunk)
+  (and (not (null? fd))
+       (< 0 fd)
+       (let* ((port (open-openssl-file-port fd method))
+              (ctx (context? port))
+              (ret (thunk port)))
+         (SSL-shutdown (ssl? ctx))
+         (SSL-free (ssl? ctx))
+         (SSL-CTX-free (ssl-ctx? ctx))
+         (file-close fd)
+         ret)))
+
+(define (open-openssl-file-port fd method)
+  (call/cc
+   (lambda (block)
+     (let ((ssl-ctx (SSL-CTX-new method)))
+       (if (not ssl-ctx)
+ (begin (uim-notify-fatal (format "SSL-CTX-new: ~a" (ERR-error-string (ERR-get-error))))
+                  (block #f)))
+       (let ((ssl (SSL-new ssl-ctx)))
+         (if (not ssl)
+ (begin (uim-notify-fatal (format "SSL-new: ~a" (ERR-error-string (ERR-get-error))))
+                    (SSL-CTX-free ctx)
+                    (block #f)))
+         (if (< (SSL-set-fd ssl fd) 0)
+ (begin (uim-notify-fatal (format "SSL-set-fd: ~a" (ERR-error-string (ERR-get-error))))
+                    (SSL-CTX-free ctx)
+                    (SSL-free ctx)
+                    (block #f)))
+         (if (< (SSL-connect ssl) 0)
+ (begin (uim-notify-fatal (format "SSL-connect: ~a" (ERR-error-string (ERR-get-error))))
+                    (SSL-CTX-free ctx)
+                    (SSL-free ctx)
+                    (block #f)))
+         (make-file-port (make-openssl-file-internal-port ssl-ctx ssl)
+                         fd
+ file-bufsiz '() ssl-read-internal ssl-write-internal))))))
+

Modified: trunk/uim/Makefile.am
==============================================================================
--- trunk/uim/Makefile.am       (original)
+++ trunk/uim/Makefile.am       Mon Mar  2 04:15:01 2009
@@ -166,6 +166,14 @@
 libuim_expat_la_CPPFLAGS = -I$(top_srcdir) @EXPAT_CFLAGS@
 endif

+if OPENSSL
+uim_plugin_LTLIBRARIES += libuim-openssl.la
+libuim_openssl_la_SOURCES = openssl.c
+libuim_openssl_la_LIBADD = @OPENSSL_LIBS@ libuim.la
+libuim_openssl_la_LDFLAGS = -rpath $(uim_plugindir) -avoid-version -module
+libuim_openssl_la_CPPFLAGS = -I$(top_srcdir) @OPENSSL_CPPFLAGS@
+endif
+
 uim_plugin_LTLIBRARIES += libuim-skk.la
 libuim_skk_la_SOURCES = skk.c bsdlook.h
 libuim_skk_la_LIBADD = libuim-scm.la libuim.la libuim-bsdlook.la @NETLIBS@

Added: trunk/uim/openssl.c
==============================================================================
--- (empty file)
+++ trunk/uim/openssl.c Mon Mar  2 04:15:01 2009
@@ -0,0 +1,333 @@
+/*
+
+  Copyright (c) 2009-2009 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.
+
+*/
+
+#include <config.h>
+#include <openssl/crypto.h>
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+
+#include "uim.h"
+#include "uim-scm.h"
+#include "uim-scm-abbrev.h"
+#include "uim-posix.h"
+#include "uim-notify.h"
+#include "dynlib.h"
+
+#ifdef USE_OPENSSL_ENGINE
+# include <openssl/engine.h>
+#endif
+
+static uim_lisp
+c_SSL_load_error_strings(void)
+{
+  SSL_load_error_strings();
+  return uim_scm_t();
+}
+
+static uim_lisp
+c_ERR_get_error(void)
+{
+  return MAKE_INT(ERR_get_error());
+}
+
+static uim_lisp
+c_ERR_error_string(uim_lisp e_)
+{
+  char buf[BUFSIZ];
+
+  /* XXX: long->int */
+  ERR_error_string_n(C_INT(e_), buf, sizeof(buf));
+  return MAKE_STR(buf);
+}
+
+static uim_lisp
+c_SSL_library_init(void)
+{
+  int ret;
+
+  /* too old? */
+  ret = SSLeay_add_ssl_algorithms();
+  if (!ret)
+    return MAKE_INT(ret);
+  ret = SSL_library_init();
+  if (!ret)
+    return MAKE_INT(ret);
+#ifdef  USE_OPENSSL_ENGINE
+  ENGINE_load_builtin_engines();
+  ENGINE_register_all_complete();
+#endif
+
+  return MAKE_INT(ret);
+}
+
+static uim_lisp
+c_SSL_CTX_new(uim_lisp meth_)
+{
+  SSL_CTX *ctx = SSL_CTX_new(C_PTR(meth_));
+
+  if (!ctx)
+    return uim_scm_f();
+  return MAKE_PTR(ctx);
+}
+
+static uim_lisp
+c_SSL_CTX_free(uim_lisp ctx_)
+{
+  SSL_CTX_free(C_PTR(ctx_));
+  return uim_scm_t();
+}
+
+
+static uim_lisp
+c_SSL_new(uim_lisp ctx_)
+{
+  SSL *ssl = SSL_new(C_PTR(ctx_));
+
+  if (!ssl)
+    return uim_scm_f();
+
+  return MAKE_PTR(ssl);
+}
+
+static uim_lisp
+c_SSL_free(uim_lisp s_)
+{
+  SSL_free(C_PTR(s_));
+  return uim_scm_t();
+}
+
+static uim_lisp
+c_SSL_get_version(uim_lisp s_)
+{
+  return MAKE_STR(SSL_get_version(C_PTR(s_)));
+}
+
+
+static uim_lisp
+c_SSL_get_cipher(uim_lisp s_)
+{
+  return MAKE_STR(SSL_get_cipher(C_PTR(s_)));
+}
+
+
+static uim_lisp
+c_SSL_shutdown(uim_lisp s_)
+{
+  return MAKE_INT(SSL_shutdown(C_PTR(s_)));
+}
+
+static uim_lisp
+c_SSL_set_fd(uim_lisp s_, uim_lisp fd_)
+{
+  return MAKE_INT(SSL_set_fd(C_PTR(s_), C_INT(fd_)));
+}
+
+static uim_lisp
+c_SSL_connect(uim_lisp s_)
+{
+  return MAKE_INT(SSL_connect(C_PTR(s_)));
+}
+
+static uim_lisp
+c_SSL_read(uim_lisp s_, uim_lisp nbytes_)
+{
+  char *buf;
+  uim_lisp ret_;
+  int nbytes = C_INT(nbytes_);
+  int i;
+  int nr;
+  char *p;
+
+  buf = uim_malloc(nbytes);
+  if ((nr = SSL_read(C_PTR(s_), buf, nbytes)) == -1) {
+    char err[BUFSIZ];
+
+    snprintf(err, sizeof(err), "SSL-read: %s", strerror(errno));
+    uim_notify_fatal(err);
+    ERROR_OBJ(err, s_);
+  }
+
+  p = buf;
+  ret_ = uim_scm_null();
+  for (i = 0; i < nr; i++) {
+    ret_ = CONS(MAKE_INT(*p & 0xff), ret_);
+    p++;
+  }
+  free(buf);
+  return uim_scm_callf("reverse", "o", ret_);
+}
+
+static uim_lisp
+c_SSL_write(uim_lisp s_, uim_lisp buf_)
+{
+  int nbytes = uim_scm_length(buf_);
+  uim_lisp ret_;
+  char *buf;
+  char *p;
+
+  buf = p = uim_malloc(nbytes);
+  while (!NULLP(buf_)) {
+    *p = (char)C_INT(CAR(buf_));
+    p++;
+    buf_ = CDR(buf_);
+  }
+  ret_ = MAKE_INT((int)SSL_write(C_PTR(s_), buf, nbytes));
+  free(buf);
+  return ret_;
+}
+
+/* SSLv2 */
+static uim_lisp
+c_SSLv2_method(void)
+{
+  return MAKE_PTR(SSLv2_method());
+}
+static uim_lisp
+c_SSLv2_server_method(void)
+{
+  return MAKE_PTR(SSLv2_server_method());
+}
+static uim_lisp
+c_SSLv2_client_method(void)
+{
+  return MAKE_PTR(SSLv2_client_method());
+}
+
+/* SSLv3 */
+static uim_lisp
+c_SSLv3_method(void)
+{
+  return MAKE_PTR(SSLv3_method());
+}
+static uim_lisp
+c_SSLv3_server_method(void)
+{
+  return MAKE_PTR(SSLv3_server_method());
+}
+static uim_lisp
+c_SSLv3_client_method(void)
+{
+  return MAKE_PTR(SSLv3_client_method());
+}
+
+/* SSLv3 but can rollback to v2 */
+static uim_lisp
+c_SSLv23_method(void)
+{
+  return MAKE_PTR(SSLv23_method());
+}
+static uim_lisp
+c_SSLv23_server_method(void)
+{
+  return MAKE_PTR(SSLv23_server_method());
+}
+static uim_lisp
+c_SSLv23_client_method(void)
+{
+  return MAKE_PTR(SSLv23_client_method());
+}
+
+/* TLSv1.0 */
+static uim_lisp
+c_TLSv1_method(void)
+{
+  return MAKE_PTR(TLSv1_method());
+}
+static uim_lisp
+c_TLSv1_server_method(void)
+{
+  return MAKE_PTR(TLSv1_server_method());
+}
+static uim_lisp
+c_TLSv1_client_method(void)
+{
+  return MAKE_PTR(TLSv1_client_method());
+}
+
+/* DTLSv1.0 */
+static uim_lisp
+c_DTLSv1_method(void)
+{
+  return MAKE_PTR(DTLSv1_method());
+}
+static uim_lisp
+c_DTLSv1_server_method(void)
+{
+  return MAKE_PTR(DTLSv1_server_method());
+}
+static uim_lisp
+c_DTLSv1_client_method(void)
+{
+  return MAKE_PTR(DTLSv1_client_method());
+}
+
+
+void
+uim_plugin_instance_init(void)
+{
+  uim_scm_init_proc0("SSL-load-error-strings", c_SSL_load_error_strings);
+  uim_scm_init_proc0("ERR-get-error", c_ERR_get_error);
+  uim_scm_init_proc1("ERR-error-string", c_ERR_error_string);
+  uim_scm_init_proc0("SSL-library-init", c_SSL_library_init);
+  uim_scm_init_proc1("SSL-CTX-new", c_SSL_CTX_new);
+  uim_scm_init_proc1("SSL-CTX-free", c_SSL_CTX_free);
+  uim_scm_init_proc1("SSL-new", c_SSL_new);
+  uim_scm_init_proc1("SSL-free", c_SSL_free);
+  uim_scm_init_proc1("SSL-get-version", c_SSL_get_version);
+  uim_scm_init_proc1("SSL-get-cipher", c_SSL_get_cipher);
+  uim_scm_init_proc1("SSL-shutdown", c_SSL_shutdown);
+  uim_scm_init_proc2("SSL-set-fd", c_SSL_set_fd);
+  uim_scm_init_proc1("SSL-connect", c_SSL_connect);
+  uim_scm_init_proc2("SSL-read", c_SSL_read);
+  uim_scm_init_proc2("SSL-write", c_SSL_write);
+  uim_scm_init_proc0("SSLv2-method", c_SSLv2_method);
+  uim_scm_init_proc0("SSLv2-server-method", c_SSLv2_server_method);
+  uim_scm_init_proc0("SSLv2-client-method", c_SSLv2_client_method);
+  uim_scm_init_proc0("SSLv3-method", c_SSLv3_method);
+  uim_scm_init_proc0("SSLv3-server-method", c_SSLv3_server_method);
+  uim_scm_init_proc0("SSLv3-client-method", c_SSLv3_client_method);
+  uim_scm_init_proc0("SSLv23-method", c_SSLv23_method);
+  uim_scm_init_proc0("SSLv23-server-method", c_SSLv23_server_method);
+  uim_scm_init_proc0("SSLv23-client-method", c_SSLv23_client_method);
+  uim_scm_init_proc0("TLSv1-method", c_TLSv1_method);
+  uim_scm_init_proc0("TLSv1-server-method", c_TLSv1_server_method);
+  uim_scm_init_proc0("TLSv1-client-method", c_TLSv1_client_method);
+  uim_scm_init_proc0("DTLSv1-method", c_DTLSv1_method);
+  uim_scm_init_proc0("DTLSv1-server-metho", c_DTLSv1_server_method);
+  uim_scm_init_proc0("DTLSv1-client-method", c_DTLSv1_client_method);
+}
+
+void
+uim_plugin_instance_quit(void)
+{
+}

Reply via email to