From ae7ff0f1fb549d6b0025af9292b2985df90d7935 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Thu, 13 Mar 2003 18:38:02 +0000 Subject: [PATCH] Add JAVA API proof of concept. --- contrib/java/.cvsignore | 27 +++++++++++++++++++++++++++ contrib/java/ExampleIDNA.java | 5 +++++ contrib/java/IDNA.c | 18 ++++++++++++++++++ contrib/java/IDNA.java | 7 +++++++ contrib/java/Makefile.am | 34 ++++++++++++++++++++++++++++++++++ contrib/java/README | 29 +++++++++++++++++++++++++++++ contrib/java/autogen.sh | 2 ++ contrib/java/configure.ac | 10 ++++++++++ 8 files changed, 132 insertions(+) create mode 100644 contrib/java/.cvsignore create mode 100644 contrib/java/ExampleIDNA.java create mode 100644 contrib/java/IDNA.c create mode 100644 contrib/java/IDNA.java create mode 100644 contrib/java/Makefile.am create mode 100644 contrib/java/README create mode 100755 contrib/java/autogen.sh create mode 100644 contrib/java/configure.ac diff --git a/contrib/java/.cvsignore b/contrib/java/.cvsignore new file mode 100644 index 0000000..b7cc67e --- /dev/null +++ b/contrib/java/.cvsignore @@ -0,0 +1,27 @@ +.deps +.libs +COPYING +ExampleIDNA.class +IDNA.class +IDNA.h +IDNA.lo +INSTALL +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +config.guess +config.h +config.h.in +config.log +config.status +config.sub +configure +depcomp +install-sh +libidn-java.la +libtool +ltmain.sh +missing +mkinstalldirs +stamp-h1 diff --git a/contrib/java/ExampleIDNA.java b/contrib/java/ExampleIDNA.java new file mode 100644 index 0000000..d5de981 --- /dev/null +++ b/contrib/java/ExampleIDNA.java @@ -0,0 +1,5 @@ +class ExampleIDNA { + public static void main(String[] args) { + System.out.println(new IDNA().toAscii(args[0])); + } +} diff --git a/contrib/java/IDNA.c b/contrib/java/IDNA.c new file mode 100644 index 0000000..71a3912 --- /dev/null +++ b/contrib/java/IDNA.c @@ -0,0 +1,18 @@ +#include +#include "IDNA.h" + +JNIEXPORT jstring JNICALL +Java_IDNA_toAscii(JNIEnv *env, jobject obj, jstring jstr) +{ + const char *in; + const char *out; + int rc; + + in = (*env)->GetStringUTFChars(env, jstr, 0); + + rc = idna_to_ascii_from_utf8 (in, &out, 0, 0); + + (*env)->ReleaseStringUTFChars(env, jstr, in); + + return (*env)->NewStringUTF(env, out); +} diff --git a/contrib/java/IDNA.java b/contrib/java/IDNA.java new file mode 100644 index 0000000..577f9b9 --- /dev/null +++ b/contrib/java/IDNA.java @@ -0,0 +1,7 @@ +class IDNA { + public native String toAscii(String str); + + static { + System.loadLibrary("idn-java"); + } +} diff --git a/contrib/java/Makefile.am b/contrib/java/Makefile.am new file mode 100644 index 0000000..a9c14d3 --- /dev/null +++ b/contrib/java/Makefile.am @@ -0,0 +1,34 @@ +## Process this file with automake to produce Makefile.in +# Copyright (C) 2002, 2003 Simon Josefsson. +# +# This file is part of GNU Libidn. +# +# GNU Libidn is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of +# the License, or (at your option) any later version. +# +# GNU Libidn is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with GNU Libidn; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +lib_LTLIBRARIES = libidn-java.la + +libidn_java_la_SOURCES = IDNA.c +libidn_java_la_LIBADD = -lidn + +%.class: %.java + gcj -C $< + +%.h: %.class + gcjh -jni $* + +IDNA.c: IDNA.h + +clean-local: + rm -f IDNA.h IDNA.class ExampleIDNA.class *~ diff --git a/contrib/java/README b/contrib/java/README new file mode 100644 index 0000000..4ce58c3 --- /dev/null +++ b/contrib/java/README @@ -0,0 +1,29 @@ +Libidn README -- Notes for the JAVA API proof of concept. +Copyright (C) 2003 Simon Josefsson +See the end for copying conditions. + +You need GCJ to build this. It was tested with Sun JDK 1.1 and IBM +JDK 1.1.8 too, after replacing "gcj" with "javac" and "gcjh" with +"javah" in Makefile.am. Some combinations of compilation with one +package and executing using another package (e.g., compile with GCJ, +run with Sun's JRE) also seemed to work. + +$ ./autogen.sh # if building from CVS +$ ./configure +$ make +$ su +# make install +# exit +$ make ExampleIDNA +$ gij ExampleIDNA räksmörgås +xn--rksmrgs-5wao1o +$ + +Please let me know if you want to finish and maintain the Java API +glue. It may involve some tedious work initially, but could be +interesting in the long run. + +---------------------------------------------------------------------- +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. diff --git a/contrib/java/autogen.sh b/contrib/java/autogen.sh new file mode 100755 index 0000000..48e9847 --- /dev/null +++ b/contrib/java/autogen.sh @@ -0,0 +1,2 @@ +#!/bin/sh -x +autoreconf --install --force --verbose diff --git a/contrib/java/configure.ac b/contrib/java/configure.ac new file mode 100644 index 0000000..6e7c4a4 --- /dev/null +++ b/contrib/java/configure.ac @@ -0,0 +1,10 @@ +AC_INIT(libidn-java, 0.0.0, bug-libidn@gnu.org) + +AM_INIT_AUTOMAKE(foreign) +AM_CONFIG_HEADER(config.h) + +AC_PROG_LIBTOOL +AC_PROG_CC + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT -- 2.11.4.GIT