libextractor-java

GNU libextractor
Log | Files | Refs | README | LICENSE

commit 5a09459feb119c988aa3b4c046dd555ca85cb1ed
parent 764f6d675c085bb87cf8178db65af67b5be3cd03
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon,  4 Jul 2005 15:12:52 +0000

update

Diffstat:
AAUTHORS | 1+
ACOPYING | 340+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AChangeLog | 3+++
AINSTALL | 236+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AMakefile.am | 4++++
ANEWS | 1+
AREADME | 2++
Am4/README | 24++++++++++++++++++++++++
Am4/ac_check_class.m4 | 107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Am4/ac_check_classpath.m4 | 26++++++++++++++++++++++++++
Am4/ac_check_rqrd_class.m4 | 26++++++++++++++++++++++++++
Am4/ac_java_options.m4 | 32++++++++++++++++++++++++++++++++
Am4/ac_prog_jar.m4 | 10++++++++++
Am4/ac_prog_java.m4 | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Am4/ac_prog_java_works.m4 | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Am4/ac_prog_javac.m4 | 43+++++++++++++++++++++++++++++++++++++++++++
Am4/ac_prog_javac_works.m4 | 35+++++++++++++++++++++++++++++++++++
Am4/ac_try_compile_java.m4 | 39+++++++++++++++++++++++++++++++++++++++
Am4/ac_try_run_java.m4 | 40++++++++++++++++++++++++++++++++++++++++
Anative/Makefile.am | 13+++++++++++++
Anative/extractor.c | 229+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Anative/org_gnunet_libextractor_Extractor.h | 109+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aorg/Makefile.am | 1+
Aorg/gnunet/Makefile.am | 1+
Aorg/gnunet/libextractor/.cvsignore | 1+
Aorg/gnunet/libextractor/Extractor.java | 290+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aorg/gnunet/libextractor/Makefile.am | 7+++++++
Aorg/gnunet/libextractor/Xtract.java | 45+++++++++++++++++++++++++++++++++++++++++++++
28 files changed, 1839 insertions(+), 0 deletions(-)

diff --git a/AUTHORS b/AUTHORS @@ -0,0 +1 @@ +Christian Grothoff <christian@grothoff.org> diff --git a/COPYING b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog @@ -0,0 +1,3 @@ +Mon Jul 4 16:58:53 CEST 2005 + Moved Java code out of main libextractor tree. + This ChangeLog started. diff --git a/INSTALL b/INSTALL @@ -0,0 +1,236 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free +Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + +By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PREFIX', the package will +use PREFIX as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). Here is a another example: + + /bin/bash ./configure CONFIG_SHELL=/bin/bash + +Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent +configuration-related scripts to be executed by `/bin/bash'. + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am @@ -0,0 +1,4 @@ +SUBDIRS = native org . +EXTRA_DIST = \ + config.rpath \ +ACLOCAL_AMFLAGS = -I m4 diff --git a/NEWS b/NEWS @@ -0,0 +1 @@ +See ChangeLog. diff --git a/README b/README @@ -0,0 +1,2 @@ +This is a Java binding for libextractor. You need +libextractor installed in order to use this code. diff --git a/m4/README b/m4/README @@ -0,0 +1,24 @@ +$Id: README,v 1.5 2000/01/03 10:13:19 bortz Exp $ + +These files are autoconf macros intended to be submitted to the +autoconf archive <http://peti.cys.de/autoconf-archive/>. + +They are in separate files because of the archive's requirments but +they are made to be used together. + +The Web page for this work is: +http://www.internatif.org/bortzmeyer/autoconf-Java/ + +A CVS snapshot of the latest release is at: +ftp://ftp.internatif.org/pub/unix/autoconf-Java/ + +The documentation is in ac_prog_java.m4. + +The licence is the GPL <http://www.gnu.org/copyleft/gpl.html>. + +Many thanks to Devin Weaver <ktohg@tritarget.com> for a lot +of work on the macros. + + +-- +Stephane Bortzmeyer <bortzmeyer@pasteur.fr> diff --git a/m4/ac_check_class.m4 b/m4/ac_check_class.m4 @@ -0,0 +1,107 @@ +dnl @synopsis AC_CHECK_CLASS +dnl +dnl AC_CHECK_CLASS tests the existence of a given Java class, either in +dnl a jar or in a '.class' file. +dnl +dnl *Warning*: its success or failure can depend on a proper setting of the +dnl CLASSPATH env. variable. +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java programs. +dnl It is VERY IMPORTANT that you download the whole set, some +dnl macros depend on other. Unfortunately, the autoconf archive does not +dnl support the concept of set of macros, so I had to break it for +dnl submission. +dnl The general documentation, as well as the sample configure.in, is +dnl included in the AC_PROG_JAVA macro. +dnl +dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr> +dnl @version $Id: ac_check_class.m4,v 1.3 2000/01/28 11:54:26 bortz Exp $ +dnl +AC_DEFUN([AC_CHECK_CLASS],[ +AC_REQUIRE([AC_PROG_JAVA]) +ac_var_name=`echo $1 | sed 's/\./_/g'` +dnl Normaly I'd use a AC_CACHE_CHECK here but since the variable name is +dnl dynamic I need an extra level of extraction +AC_MSG_CHECKING([for $1 class]) +AC_CACHE_VAL(ac_cv_class_$ac_var_name, [ +if test x$ac_cv_prog_uudecode_base64 = xyes; then +dnl /** +dnl * Test.java: used to test dynamicaly if a class exists. +dnl */ +dnl public class Test +dnl { +dnl +dnl public static void +dnl main( String[] argv ) +dnl { +dnl Class lib; +dnl if (argv.length < 1) +dnl { +dnl System.err.println ("Missing argument"); +dnl System.exit (77); +dnl } +dnl try +dnl { +dnl lib = Class.forName (argv[0]); +dnl } +dnl catch (ClassNotFoundException e) +dnl { +dnl System.exit (1); +dnl } +dnl lib = null; +dnl System.exit (0); +dnl } +dnl +dnl } +cat << \EOF > Test.uue +begin-base64 644 Test.class +yv66vgADAC0AKQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE +bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 +bWJlclRhYmxlDAAKAAsBAANlcnIBABVMamF2YS9pby9QcmludFN0cmVhbTsJ +AA0ACQcADgEAEGphdmEvbGFuZy9TeXN0ZW0IABABABBNaXNzaW5nIGFyZ3Vt +ZW50DAASABMBAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWCgAV +ABEHABYBABNqYXZhL2lvL1ByaW50U3RyZWFtDAAYABkBAARleGl0AQAEKEkp +VgoADQAXDAAcAB0BAAdmb3JOYW1lAQAlKExqYXZhL2xhbmcvU3RyaW5nOylM +amF2YS9sYW5nL0NsYXNzOwoAHwAbBwAgAQAPamF2YS9sYW5nL0NsYXNzBwAi +AQAgamF2YS9sYW5nL0NsYXNzTm90Rm91bmRFeGNlcHRpb24BAAY8aW5pdD4B +AAMoKVYMACMAJAoAAwAlAQAKU291cmNlRmlsZQEACVRlc3QuamF2YQAhAAEA +AwAAAAAAAgAJAAUABgABAAcAAABtAAMAAwAAACkqvgSiABCyAAwSD7YAFBBN +uAAaKgMyuAAeTKcACE0EuAAaAUwDuAAasQABABMAGgAdACEAAQAIAAAAKgAK +AAAACgAAAAsABgANAA4ADgATABAAEwASAB4AFgAiABgAJAAZACgAGgABACMA +JAABAAcAAAAhAAEAAQAAAAUqtwAmsQAAAAEACAAAAAoAAgAAAAQABAAEAAEA +JwAAAAIAKA== +==== +EOF + if uudecode$EXEEXT Test.uue; then + : + else + echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC + echo "configure: failed file was:" >&AC_FD_CC + cat Test.uue >&AC_FD_CC + ac_cv_prog_uudecode_base64=no + fi + rm -f Test.uue + if AC_TRY_COMMAND($JAVA $JAVAFLAGS Test $1) >/dev/null 2>&1; then + eval "ac_cv_class_$ac_var_name=yes" + else + eval "ac_cv_class_$ac_var_name=no" + fi + rm -f Test.class +else + AC_TRY_COMPILE_JAVA([$1], , [eval "ac_cv_class_$ac_var_name=yes"], + [eval "ac_cv_class_$ac_var_name=no"]) +fi +eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`" +eval "HAVE_$ac_var_name=$`echo ac_cv_class_$ac_var_val`" +HAVE_LAST_CLASS=$ac_var_val +if test x$ac_var_val = xyes; then + ifelse([$2], , :, [$2]) +else + ifelse([$3], , :, [$3]) +fi +]) +dnl for some reason the above statment didn't fall though here? +dnl do scripts have variable scoping? +eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`" +AC_MSG_RESULT($ac_var_val) +]) diff --git a/m4/ac_check_classpath.m4 b/m4/ac_check_classpath.m4 @@ -0,0 +1,26 @@ +dnl @synopsis AC_CHECK_CLASSPATH +dnl +dnl AC_CHECK_CLASSPATH just displays the CLASSPATH, for the edification +dnl of the user. +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java programs. +dnl It is VERY IMPORTANT that you download the whole set, some +dnl macros depend on other. Unfortunately, the autoconf archive does not +dnl support the concept of set of macros, so I had to break it for +dnl submission. +dnl The general documentation, as well as the sample configure.in, is +dnl included in the AC_PROG_JAVA macro. +dnl +dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr> +dnl @version $Id: ac_check_classpath.m4,v 1.3 1999/12/29 10:45:03 bortz Exp $ +dnl +AC_DEFUN([AC_CHECK_CLASSPATH],[ +if test "x$CLASSPATH" = x; then + echo "You have no CLASSPATH, I hope it is good" +else + echo "You have CLASSPATH $CLASSPATH, hope it is correct" +fi +]) + + + diff --git a/m4/ac_check_rqrd_class.m4 b/m4/ac_check_rqrd_class.m4 @@ -0,0 +1,26 @@ +dnl @synopsis AC_CHECK_RQRD_CLASS +dnl +dnl AC_CHECK_RQRD_CLASS tests the existence of a given Java class, either in +dnl a jar or in a '.class' file and fails if it doesn't exist. +dnl Its success or failure can depend on a proper setting of the +dnl CLASSPATH env. variable. +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java programs. +dnl It is VERY IMPORTANT that you download the whole set, some +dnl macros depend on other. Unfortunately, the autoconf archive does not +dnl support the concept of set of macros, so I had to break it for +dnl submission. +dnl The general documentation, as well as the sample configure.in, is +dnl included in the AC_PROG_JAVA macro. +dnl +dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr> +dnl @version $Id: ac_check_rqrd_class.m4,v 1.1 1999/12/29 09:22:26 bortz Exp $ +dnl + +AC_DEFUN([AC_CHECK_RQRD_CLASS],[ +CLASS=`echo $1|sed 's/\./_/g'` +AC_CHECK_CLASS($1) +if test "$HAVE_LAST_CLASS" = "no"; then + AC_MSG_ERROR([Required class $1 missing, exiting.]) +fi +]) diff --git a/m4/ac_java_options.m4 b/m4/ac_java_options.m4 @@ -0,0 +1,32 @@ +dnl @synopsis AC_JAVA_OPTIONS +dnl +dnl AC_JAVA_OPTIONS adds configure command line options used for Java m4 +dnl macros. This Macro is optional. +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java programs. +dnl It is VERY IMPORTANT that you download the whole set, some +dnl macros depend on other. Unfortunately, the autoconf archive does not +dnl support the concept of set of macros, so I had to break it for +dnl submission. +dnl The general documentation, as well as the sample configure.in, is +dnl included in the AC_PROG_JAVA macro. +dnl +dnl @author Devin Weaver <ktohg@tritarget.com> +dnl @version $Id: ac_java_options.m4,v 1.2 2000/01/02 16:07:12 bortz Exp $ +dnl +AC_DEFUN([AC_JAVA_OPTIONS],[ +AC_ARG_WITH(java-prefix, + [ --with-java-prefix=PFX prefix where Java runtime is installed (optional)]) +AC_ARG_WITH(javac-flags, + [ --with-javac-flags=FLAGS flags to pass to the Java compiler (optional)]) +AC_ARG_WITH(java-flags, + [ --with-java-flags=FLAGS flags to pass to the Java VM (optional)]) +JAVAPREFIX=$with_java_prefix +JAVACFLAGS=$with_javac_flags +JAVAFLAGS=$with_java_flags +AC_SUBST(JAVAPREFIX)dnl +AC_SUBST(JAVACFLAGS)dnl +AC_SUBST(JAVAFLAGS)dnl +AC_SUBST(JAVA)dnl +AC_SUBST(JAVAC)dnl +]) diff --git a/m4/ac_prog_jar.m4 b/m4/ac_prog_jar.m4 @@ -0,0 +1,10 @@ +AC_DEFUN([AC_PROG_JAR],[ +AC_REQUIRE([AC_EXEEXT])dnl +if test "x$JAVAPREFIX" = x; then + test "x$JAR" = x && AC_CHECK_PROGS(JAR, jar$EXEEXT) +else + test "x$JAR" = x && AC_CHECK_PROGS(JAR, jar, $JAVAPREFIX) +fi +test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH]) +AC_PROVIDE([$0])dnl +]) diff --git a/m4/ac_prog_java.m4 b/m4/ac_prog_java.m4 @@ -0,0 +1,77 @@ +dnl @synopsis AC_PROG_JAVA +dnl +dnl Here is a summary of the main macros: +dnl +dnl AC_PROG_JAVAC: finds a Java compiler. +dnl +dnl AC_PROG_JAVA: finds a Java virtual machine. +dnl +dnl AC_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!). +dnl +dnl AC_CHECK_RQRD_CLASS: finds if we have the given class and stops otherwise. +dnl +dnl AC_TRY_COMPILE_JAVA: attempt to compile user given source. +dnl +dnl AC_TRY_RUN_JAVA: attempt to compile and run user given source. +dnl +dnl AC_JAVA_OPTIONS: adds Java configure options. +dnl +dnl AC_PROG_JAVA tests an existing Java virtual machine. It uses the +dnl environment variable JAVA then tests in sequence various common Java +dnl virtual machines. For political reasons, it starts with the free ones. +dnl You *must* call [AC_PROG_JAVAC] before. +dnl +dnl If you want to force a specific VM: +dnl +dnl - at the configure.in level, set JAVA=yourvm before calling AC_PROG_JAVA +dnl (but after AC_INIT) +dnl +dnl - at the configure level, setenv JAVA +dnl +dnl You can use the JAVA variable in your Makefile.in, with @JAVA@. +dnl +dnl *Warning*: its success or failure can depend on a proper setting of the +dnl CLASSPATH env. variable. +dnl +dnl TODO: allow to exclude virtual machines (rationale: most Java programs +dnl cannot run with some VM like kaffe). +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java programs. +dnl It is VERY IMPORTANT that you download the whole set, some +dnl macros depend on other. Unfortunately, the autoconf archive does not +dnl support the concept of set of macros, so I had to break it for +dnl submission. +dnl +dnl A Web page, with a link to the latest CVS snapshot is at +dnl <http://www.internatif.org/bortzmeyer/autoconf-Java/>. +dnl +dnl This is a sample configure.in +dnl Process this file with autoconf to produce a configure script. +dnl +dnl AC_INIT(UnTag.java) +dnl +dnl dnl Checks for programs. +dnl AC_CHECK_CLASSPATH +dnl AC_PROG_JAVAC +dnl AC_PROG_JAVA +dnl +dnl dnl Checks for classes +dnl AC_CHECK_RQRD_CLASS(org.xml.sax.Parser) +dnl AC_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver) +dnl +dnl AC_OUTPUT(Makefile) +dnl +dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr> +dnl @version $Id: ac_prog_java.m4,v 1.5 2000/01/02 16:07:12 bortz Exp $ +dnl +AC_DEFUN([AC_PROG_JAVA],[ +AC_REQUIRE([AC_EXEEXT])dnl +if test x$JAVAPREFIX = x; then + test x$JAVA = x && AC_CHECK_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT) +else + test x$JAVA = x && AC_CHECK_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT, $JAVAPREFIX) +fi +test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH]) +AC_PROG_JAVA_WORKS +AC_PROVIDE([$0])dnl +]) diff --git a/m4/ac_prog_java_works.m4 b/m4/ac_prog_java_works.m4 @@ -0,0 +1,97 @@ +dnl @synopsis AC_PROG_JAVA_WORKS +dnl +dnl Internal use ONLY. +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java programs. +dnl It is VERY IMPORTANT that you download the whole set, some +dnl macros depend on other. Unfortunately, the autoconf archive does not +dnl support the concept of set of macros, so I had to break it for +dnl submission. +dnl The general documentation, as well as the sample configure.in, is +dnl included in the AC_PROG_JAVA macro. +dnl +dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr> +dnl @version $Id: ac_prog_java_works.m4,v 1.2 1999/12/29 09:58:48 bortz Exp $ +dnl +AC_DEFUN([AC_PROG_JAVA_WORKS], [ +AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes) +if test x$uudecode = xyes; then +AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [ +dnl /** +dnl * Test.java: used to test if java compiler works. +dnl */ +dnl public class Test +dnl { +dnl +dnl public static void +dnl main( String[] argv ) +dnl { +dnl System.exit (0); +dnl } +dnl +dnl } +cat << \EOF > Test.uue +begin-base64 644 Test.class +yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE +bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 +bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s +YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG +aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB +AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB +AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ= +==== +EOF +if uudecode$EXEEXT Test.uue; then + ac_cv_prog_uudecode_base64=yes +else + echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC + echo "configure: failed file was:" >&AC_FD_CC + cat Test.uue >&AC_FD_CC + ac_cv_prog_uudecode_base64=no +fi +rm -f Test.uue]) +fi +if test x$ac_cv_prog_uudecode_base64 != xyes; then + rm -f Test.class + AC_MSG_WARN([I have to compile Test.class from scratch]) + if test x$ac_cv_prog_javac_works = xno; then + AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly]) + fi + if test x$ac_cv_prog_javac_works = x; then + AC_PROG_JAVAC + fi +fi +AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +TEST=Test +changequote(, )dnl +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +public static void main (String args[]) { + System.exit (0); +} } +EOF +changequote([, ])dnl +if test x$ac_cv_prog_uudecode_base64 != xyes; then + if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then + : + else + echo "configure: failed program was:" >&AC_FD_CC + cat $JAVA_TEST >&AC_FD_CC + AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)) + fi +fi +if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then + ac_cv_prog_java_works=yes +else + echo "configure: failed program was:" >&AC_FD_CC + cat $JAVA_TEST >&AC_FD_CC + AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?)) +fi +rm -fr $JAVA_TEST $CLASS_TEST Test.uue +]) +AC_PROVIDE([$0])dnl +] +) diff --git a/m4/ac_prog_javac.m4 b/m4/ac_prog_javac.m4 @@ -0,0 +1,43 @@ +dnl @synopsis AC_PROG_JAVAC +dnl +dnl AC_PROG_JAVAC tests an existing Java compiler. It uses the environment +dnl variable JAVAC then tests in sequence various common Java compilers. For +dnl political reasons, it starts with the free ones. +dnl +dnl If you want to force a specific compiler: +dnl +dnl - at the configure.in level, set JAVAC=yourcompiler before calling +dnl AC_PROG_JAVAC +dnl +dnl - at the configure level, setenv JAVAC +dnl +dnl You can use the JAVAC variable in your Makefile.in, with @JAVAC@. +dnl +dnl *Warning*: its success or failure can depend on a proper setting of the +dnl CLASSPATH env. variable. +dnl +dnl TODO: allow to exclude compilers (rationale: most Java programs cannot compile +dnl with some compilers like guavac). +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java programs. +dnl It is VERY IMPORTANT that you download the whole set, some +dnl macros depend on other. Unfortunately, the autoconf archive does not +dnl support the concept of set of macros, so I had to break it for +dnl submission. +dnl The general documentation, as well as the sample configure.in, is +dnl included in the AC_PROG_JAVA macro. +dnl +dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr> +dnl @version $Id: ac_prog_javac.m4,v 1.3 1999/12/29 10:46:15 bortz Exp $ +dnl +AC_DEFUN([AC_PROG_JAVAC],[ +AC_REQUIRE([AC_EXEEXT])dnl +if test "x$JAVAPREFIX" = x; then + test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "gcj$EXEEXT -C" guavac$EXEEXT jikes$EXEEXT javac$EXEEXT) +else + test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "gcj$EXEEXT -C" guavac$EXEEXT jikes$EXEEXT javac$EXEEXT, $JAVAPREFIX) +fi +test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) +AC_PROG_JAVAC_WORKS +AC_PROVIDE([$0])dnl +]) diff --git a/m4/ac_prog_javac_works.m4 b/m4/ac_prog_javac_works.m4 @@ -0,0 +1,35 @@ +dnl @synopsis AC_PROG_JAVAC_WORKS +dnl +dnl Internal use ONLY. +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java programs. +dnl It is VERY IMPORTANT that you download the whole set, some +dnl macros depend on other. Unfortunately, the autoconf archive does not +dnl support the concept of set of macros, so I had to break it for +dnl submission. +dnl The general documentation, as well as the sample configure.in, is +dnl included in the AC_PROG_JAVA macro. +dnl +dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr> +dnl @version $Id: ac_prog_javac_works.m4,v 1.2 1999/12/29 09:58:48 bortz Exp $ +dnl +AC_DEFUN([AC_PROG_JAVAC_WORKS],[ +AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [ +JAVA_TEST=Test.java +CLASS_TEST=Test.class +cat << \EOF > $JAVA_TEST +/* [#]line __oline__ "configure" */ +public class Test { +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then + ac_cv_prog_javac_works=yes +else + AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) + echo "configure: failed program was:" >&AC_FD_CC + cat $JAVA_TEST >&AC_FD_CC +fi +rm -f $JAVA_TEST $CLASS_TEST +]) +AC_PROVIDE([$0])dnl +]) diff --git a/m4/ac_try_compile_java.m4 b/m4/ac_try_compile_java.m4 @@ -0,0 +1,39 @@ +dnl @synopsis AC_TRY_COMPILE_JAVA +dnl +dnl AC_TRY_COMPILE_JAVA attempt to compile user given source. +dnl +dnl *Warning*: its success or failure can depend on a proper setting of the +dnl CLASSPATH env. variable. +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java programs. +dnl It is VERY IMPORTANT that you download the whole set, some +dnl macros depend on other. Unfortunately, the autoconf archive does not +dnl support the concept of set of macros, so I had to break it for +dnl submission. +dnl The general documentation, as well as the sample configure.in, is +dnl included in the AC_PROG_JAVA macro. +dnl +dnl @author Devin Weaver <ktohg@tritarget.com> +dnl @version $Id: ac_try_compile_java.m4,v 1.1 1999/12/29 09:59:34 bortz Exp $ +dnl +AC_DEFUN([AC_TRY_COMPILE_JAVA],[ +AC_REQUIRE([AC_PROG_JAVAC])dnl +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +ifelse([$1], , , [import $1;]) +public class Test { +[$2] +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class +then +dnl Don't remove the temporary files here, so they can be examined. + ifelse([$3], , :, [$3]) +else + echo "configure: failed program was:" >&AC_FD_CC + cat Test.java >&AC_FD_CC +ifelse([$4], , , [ rm -fr Test* + $4 +])dnl +fi +rm -fr Test*]) diff --git a/m4/ac_try_run_java.m4 b/m4/ac_try_run_java.m4 @@ -0,0 +1,40 @@ +dnl @synopsis AC_TRY_RUN_JAVA +dnl +dnl AC_TRY_RUN_JAVA attempt to compile and run user given source. +dnl +dnl *Warning*: its success or failure can depend on a proper setting of the +dnl CLASSPATH env. variable. +dnl +dnl Note: This is part of the set of autoconf M4 macros for Java programs. +dnl It is VERY IMPORTANT that you download the whole set, some +dnl macros depend on other. Unfortunately, the autoconf archive does not +dnl support the concept of set of macros, so I had to break it for +dnl submission. +dnl The general documentation, as well as the sample configure.in, is +dnl included in the AC_PROG_JAVA macro. +dnl +dnl @author Devin Weaver <ktohg@tritarget.com> +dnl @version $Id: ac_try_run_java.m4,v 1.1 1999/12/29 09:59:34 bortz Exp $ +dnl +AC_DEFUN([AC_TRY_RUN_JAVA],[ +AC_REQUIRE([AC_PROG_JAVAC])dnl +AC_REQUIRE([AC_PROG_JAVA])dnl +cat << \EOF > Test.java +/* [#]line __oline__ "configure" */ +ifelse([$1], , , [include $1;]) +public class Test { +[$2] +} +EOF +if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class && ($JAVA $JAVAFLAGS Test; exit) 2>/dev/null +then +dnl Don't remove the temporary files here, so they can be examined. + ifelse([$3], , :, [$3]) +else + echo "configure: failed program was:" >&AC_FD_CC + cat Test.java >&AC_FD_CC +ifelse([$4], , , [ rm -fr Test* + $4 +])dnl +fi +rm -fr Test*]) diff --git a/native/Makefile.am b/native/Makefile.am @@ -0,0 +1,13 @@ +SUBDIRS = . + +lib_LTLIBRARIES = \ + libextractor_java.la + +libextractor_java_la_LDFLAGS = \ + -export-dynamic -version-info 0:0:0 +libextractor_java_la_LIBADD = \ + -lextractor + +libextractor_java_la_SOURCES = \ + extractor.c \ + org_gnunet_libextractor_Extractor.h diff --git a/native/extractor.c b/native/extractor.c @@ -0,0 +1,229 @@ +/* + This file is part of libextractor. + (C) 2002, 2003, 2004, 2005 Vidyut Samanta and Christian Grothoff + + libextractor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 2, or (at your + option) any later version. + + libextractor 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 + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libextractor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +#include "config.h" +#include <extractor.h> +#include <jni.h> + +/* gcj's jni.h does not define JNIEXPORT/JNICALL (at least + * not in my version). Sun defines it to 'empty' on GNU/Linux, + * so that should work */ +#ifndef JNIEXPORT +#define JNIEXPORT +#endif +#ifndef JNICALL +#define JNICALL +#endif + +#include "org_gnunet_libextractor_Extractor.h" + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: loadDefaultInternal + * Signature: ()J + */ +JNIEXPORT jlong JNICALL +Java_org_gnunet_libextractor_Extractor_loadDefaultInternal(JNIEnv * env, + jclass c) { + return (jlong) (long) EXTRACTOR_loadDefaultLibraries(); +} + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: unloadInternal + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_org_gnunet_libextractor_Extractor_unloadInternal(JNIEnv * env, + jclass c, + jlong arg) { + EXTRACTOR_removeAll((EXTRACTOR_ExtractorList*) (long) arg); +} + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: extractInternal + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_org_gnunet_libextractor_Extractor_extractInternal(JNIEnv * env, + jclass c, + jlong arg, + jstring f) { + const char * fname; + jboolean bo; + jlong ret; + + bo = JNI_FALSE; + fname = (*env)->GetStringUTFChars(env, f, &bo); + ret = (jlong) (long) EXTRACTOR_getKeywords((EXTRACTOR_ExtractorList*) (long) arg, + fname); + (*env)->ReleaseStringUTFChars(env, f, fname); + return ret; +} + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: freeInternal + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_org_gnunet_libextractor_Extractor_freeInternal(JNIEnv * env, + jclass c, + jlong list) { + EXTRACTOR_freeKeywords( (EXTRACTOR_KeywordList*) (long) list); +} + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: typeInternal + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_org_gnunet_libextractor_Extractor_typeInternal(JNIEnv * env, + jclass c, + jlong list) { + if (list == 0) + return -1; /* error! */ + return ((EXTRACTOR_KeywordList*) (long) list)->keywordType; +} + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: keywordInternal + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_org_gnunet_libextractor_Extractor_keywordInternal(JNIEnv * env, + jclass c, + jlong list) { + char * str; + if (list == 0) + return NULL; /* error! */ + str = ((EXTRACTOR_KeywordList*) (long) list)->keyword; + return (*env)->NewStringUTF(env, str); +} + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: nextInternal + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_org_gnunet_libextractor_Extractor_nextInternal(JNIEnv * env, + jclass j, + jlong list) { + if (list == 0) + return 0; /* error! */ + return (jlong) (long) ((EXTRACTOR_KeywordList*) (long) list)->next; +} + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: getTypeAsStringInternal + * Signature: (I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_org_gnunet_libextractor_Extractor_getTypeAsStringInternal(JNIEnv * env, + jclass c, + jint type) { + const char * str; + if ( (type < 0) || (type > HIGHEST_TYPE_NUMBER) ) + return NULL; /* error! */ + str = gettext(keywordTypes[type]); + if (str == NULL) + return NULL; + return (*env)->NewStringUTF(env, + str); +} + + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: getVersionInternal + * Signature: ()I + */ +JNIEXPORT jint JNICALL +Java_org_gnunet_libextractor_Extractor_getVersionInternal(JNIEnv * env, + jclass c) { + return EXTRACTOR_VERSION; +} + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: getMaxTypeInternal + * Signature: ()I + */ +JNIEXPORT jint JNICALL +Java_org_gnunet_libextractor_Extractor_getMaxTypeInternal(JNIEnv * env, + jclass c) { + return HIGHEST_TYPE_NUMBER; +} + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: unloadPlugin + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_org_gnunet_libextractor_Extractor_unloadPlugin(JNIEnv * env, + jclass c, + jlong handle, + jstring name) { + const char * lname; + jboolean bo; + jlong ret; + + bo = JNI_FALSE; + lname = (*env)->GetStringUTFChars(env, name, &bo); + ret = (jlong) (long) EXTRACTOR_removeLibrary((EXTRACTOR_ExtractorList*) (long) handle, + lname); + (*env)->ReleaseStringUTFChars(env, name, lname); + return ret; +} + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: loadPlugin + * Signature: (JLjava/lang/String;Z)J + */ +JNIEXPORT jlong JNICALL +Java_org_gnunet_libextractor_Extractor_loadPlugin(JNIEnv * env, + jclass c, + jlong handle, + jstring name, + jboolean place) { + const char * lname; + jboolean bo; + jlong ret; + + bo = JNI_FALSE; + lname = (*env)->GetStringUTFChars(env, name, &bo); + if (place == JNI_TRUE) { + ret = (jlong) (long) EXTRACTOR_addLibraryLast((EXTRACTOR_ExtractorList*) (long) handle, + lname); + } else { + ret = (jlong) (long) EXTRACTOR_addLibrary((EXTRACTOR_ExtractorList*) (long) handle, + lname); + } + (*env)->ReleaseStringUTFChars(env, name, lname); + return ret; +} + diff --git a/native/org_gnunet_libextractor_Extractor.h b/native/org_gnunet_libextractor_Extractor.h @@ -0,0 +1,109 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class org_gnunet_libextractor_Extractor */ + +#ifndef _Included_org_gnunet_libextractor_Extractor +#define _Included_org_gnunet_libextractor_Extractor +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_gnunet_libextractor_Extractor + * Method: loadDefaultInternal + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_loadDefaultInternal + (JNIEnv *, jclass); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: unloadInternal + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_gnunet_libextractor_Extractor_unloadInternal + (JNIEnv *, jclass, jlong); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: extractInternal + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_extractInternal + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: freeInternal + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_gnunet_libextractor_Extractor_freeInternal + (JNIEnv *, jclass, jlong); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: typeInternal + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_gnunet_libextractor_Extractor_typeInternal + (JNIEnv *, jclass, jlong); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: keywordInternal + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_gnunet_libextractor_Extractor_keywordInternal + (JNIEnv *, jclass, jlong); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: nextInternal + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_nextInternal + (JNIEnv *, jclass, jlong); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: getTypeAsStringInternal + * Signature: (I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_gnunet_libextractor_Extractor_getTypeAsStringInternal + (JNIEnv *, jclass, jint); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: getVersionInternal + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_gnunet_libextractor_Extractor_getVersionInternal + (JNIEnv *, jclass); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: getMaxTypeInternal + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_gnunet_libextractor_Extractor_getMaxTypeInternal + (JNIEnv *, jclass); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: unloadPlugin + * Signature: (JLjava/lang/String;)J + */ +JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_unloadPlugin + (JNIEnv *, jclass, jlong, jstring); + +/* + * Class: org_gnunet_libextractor_Extractor + * Method: loadPlugin + * Signature: (JLjava/lang/String;Z)J + */ +JNIEXPORT jlong JNICALL Java_org_gnunet_libextractor_Extractor_loadPlugin + (JNIEnv *, jclass, jlong, jstring, jboolean); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/org/Makefile.am b/org/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = gnunet diff --git a/org/gnunet/Makefile.am b/org/gnunet/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = libextractor diff --git a/org/gnunet/libextractor/.cvsignore b/org/gnunet/libextractor/.cvsignore @@ -0,0 +1 @@ +*.class diff --git a/org/gnunet/libextractor/Extractor.java b/org/gnunet/libextractor/Extractor.java @@ -0,0 +1,289 @@ +/* + This file is part of libextractor. + (C) 2002, 2003, 2004 Vidyut Samanta and Christian Grothoff + + libextractor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 2, or (at your + option) any later version. + + libextractor 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 + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libextractor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ +package org.gnunet.libextractor; + +import java.util.Vector; +import java.io.File; + +/** + * Java Binding for libextractor. + * + * @see Xtract + * @author Christian Grothoff + */ +public final class Extractor { + + private static boolean warn_; + + /** + * LE version. 0 if LE was compiled without JNI/Java support, in which + * case we better not call any native methods... + */ + private final static int version_; + + /** + * Cached list of Strings describing keyword types. + */ + private final static String[] typeCache_; + + static { + // first, initialize warn_ + boolean warn = false; + try { + if (System.getProperty("libextractor.warn") != null) + warn = true; + } catch (SecurityException se) { + // ignore + } finally { + warn_ = warn; + } + + // next, load library and determine version_ + int ver = 0; + try { + System.loadLibrary("extractor"); + } catch (UnsatisfiedLinkError ule) { + ver = -1; + warn("Did not find libextractor library: " + ule); + } + if (ver == 0) { + try { + ver = getVersionInternal(); + } catch (UnsatisfiedLinkError ule) { + // warn: libextractor compiled without Java support + warn("libextractor library compiled without Java support: " + ule); + } + } + version_ = ver; + + // finally, initialize typeCache_ + if (ver > 0) { + typeCache_ = new String[getMaxTypeInternal()]; + } else { + typeCache_ = null; + } + } + + private static void warn(String warning) { + if (warn_) + System.err.println("WARNING: " + warning); + } + + /** + * @return -1 if LE library was not found, 0 if LE library + * was found but compiled without JNI support, otherwise + * the LE version number + */ + public static int getVersion() { + return version_; + } + + /** + * Get the 'default' extractor, that is an extractor that loads + * the default set of extractor plugins. + */ + public static Extractor getDefault() { + if (version_ > 0) + return new Extractor(loadDefaultInternal()); + else + return new Extractor(0); + } + + /** + * Get the 'empty' extractor, that is an extractor that does not + * have any plugins loaded. This is useful to manually construct + * an Extractor from scratch. + */ + public static Extractor getEmpty() { + return new Extractor(0L); + } + + /** + * Note that the current implementation of function is quite + * costly, we should probably build a cache (String[]) of all + * keyword types on startup and keep that around instead of + * doing a native call each time (initialize cache lazily!, + * just determine the size in the static initializer!). + * + * @throws IllegalArgumentException if the type is not within range + * @return an empty string if LE was not loaded + */ + public static String getTypeAsString(int type) { + if (version_ > 0) { + if ( (type >= 0) && (type <= typeCache_.length)) { + if (typeCache_[type] == null) + typeCache_[type] + = getTypeAsStringInternal(type); + return typeCache_[type]; + } else + throw new IllegalArgumentException("Type out of range [0,"+typeCache_.length+")"); + } else + return ""; + } + + /** + * Handle to the list of plugins (a C pointer, long to support + * 64-bit architectures!). + */ + private long pluginHandle_; + + /** + * Creates an extractor. + * + * @param pluginHandle the internal handle (C pointer!) refering + * to the list of plugins. 0 means no plugins. + */ + private Extractor(long pluginHandle) { + this.pluginHandle_ = pluginHandle; + } + + protected void finalize() { + if (pluginHandle_ != 0) + unloadInternal(pluginHandle_); + } + + public void unloadPlugin(String pluginName) { + if (pluginHandle_ != 0) { + pluginHandle_ = unloadPlugin(pluginHandle_, + pluginName); + } + } + + /** + * @param append if true, add the plugin at the end, otherwise at the + * beginning + */ + public void loadPlugin(String pluginName, + boolean append) { + if (version_ <= 0) + return; + pluginHandle_ = loadPlugin(pluginHandle_, + pluginName, + append); + } + + /** + * Extract keywords (meta-data) from the given file. + * + * @param f the file to extract meta-data from + * @return a Vector of Extractor.Keywords + */ + public Vector extract(File f) { + return extract(f.getName()); + } + + /** + * Extract keywords (meta-data) from the given file. + * + * @param file the name of the file + * @return a Vector of Extractor.Keywords + */ + public Vector extract(String filename) { + if (pluginHandle_ == 0) + return new Vector(0); // fast way out + long list + = extractInternal(pluginHandle_, + filename); // toChars? + long pos + = list; + Vector res + = new Vector(); + while (pos != 0) { + int type + = typeInternal(pos); + String keyword + = keywordInternal(pos); + res.add(new Keyword(type, keyword)); + pos = nextInternal(pos); + } + freeInternal(list); + return res; + } + + + /* ********************* native calls ******************** */ + + private static native long loadDefaultInternal(); + + private static native void unloadInternal(long handle); + + private static native long extractInternal(long handle, + String filename); + + // free memory allocated by extractInternal + private static native void freeInternal(long list); + + private static native int typeInternal(long pos); + + private static native String keywordInternal(long pos); + + private static native long nextInternal(long pos); + + private static native String getTypeAsStringInternal(int type); + + private static native int getVersionInternal(); + + private static native int getMaxTypeInternal(); + + private static native long unloadPlugin(long handle, + String pluginName); + + /** + * @param append if true, add the plugin at the end, otherwise at the + * beginning + */ + private static native long loadPlugin(long handle, + String pluginName, + boolean append); + + /** + * Representation of a keyword. Each keyword in libextractor + * has a type (in Java modeled as an int) which describes what + * the keyword is about. + * + * @author Christian Grothoff + */ + public static final class Keyword { + + private final int type_; + + private final String keyword_; + + Keyword(int type, + String key) { + this.type_ = type; + this.keyword_ = key; + } + + public String toString() { + return getTypeAsString(type_) + ": " + keyword_; + } + + public int getType() { + return type_; + } + + public String getKeyword() { + return keyword_; + } + + } // end of Extractor.Keyword + +} // end of Extractor +\ No newline at end of file diff --git a/org/gnunet/libextractor/Makefile.am b/org/gnunet/libextractor/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = . +noinst_JAVA = \ + Extractor.java \ + Xtract.java + +install-exec-local: + @jar@ -cvf libextractor.jar *.class diff --git a/org/gnunet/libextractor/Xtract.java b/org/gnunet/libextractor/Xtract.java @@ -0,0 +1,44 @@ +/* + This file is part of libextractor. + (C) 2002, 2003, 2004 Vidyut Samanta and Christian Grothoff + + libextractor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 2, or (at your + option) any later version. + + libextractor 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 + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with libextractor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ +package org.gnunet.libextractor; + +import java.util.Vector; + +/** + * Java version of extract. This is just a tiny demo-application + * to show how to use the Java API. The C version of extract is + * much better and should probably be used in practice. + * + * @author Christian Grothoff + */ +public final class Xtract { + + public static void main(String[] args) { + Extractor ex = Extractor.getDefault(); + for (int i=0;i<args.length;i++) { + Vector keywords = ex.extract(args[i]); + System.out.println("Keywords for " + args[i] + ":\n"); + for (int j=0;j<keywords.size();j++) + System.out.println(keywords.elementAt(j)); + } + // no need to unload, finalizer does the rest... + } + +} // end of Xtract +\ No newline at end of file