pax_global_header00006660000000000000000000000064130347405220014512gustar00rootroot0000000000000052 comment=1057b8e542f7dd27e3e591e93c07d58bd2143b76 LRDF-0.6.1/000077500000000000000000000000001303474052200122455ustar00rootroot00000000000000LRDF-0.6.1/.gitignore000066400000000000000000000004101303474052200142300ustar00rootroot00000000000000Makefile Makefile.in aclocal.m4 autom4te.cache compile config.guess config.h config.h.in config.h.in~ config.log config.status config.sub configure depcomp install-sh libtool lrdf.pc lrdf.py lrdf_wrap.c ltmain.sh m4 missing stamp-h stamp-h.in stamp-h1 test-driver LRDF-0.6.1/AUTHORS000066400000000000000000000001101303474052200133050ustar00rootroot00000000000000Steve Harris Taybin Rutkin LRDF-0.6.1/COPYING000066400000000000000000000431101303474052200132770ustar00rootroot00000000000000 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. Copyright (C) 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. , 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. LRDF-0.6.1/ChangeLog000066400000000000000000000004641303474052200140230ustar00rootroot000000000000000.0.1 First release ... 0.2.3 Added patches from Taybin Rutkin and Paul Davis 0.2.4 Fixed buffer overrun in rebuild_taxonomic_closure reported by Taybin Rutkin Fixed some memory leaks: know remaining leak in the triple list allocator. 0.4.0 Better genid creation. 0.5.0 Use raptor2 and openssl for MD5 LRDF-0.6.1/INSTALL000066400000000000000000000172271303474052200133070ustar00rootroot00000000000000Basic 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, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). 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 at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' 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. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure 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 supports 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=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH 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=PATH' 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' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM 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 host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. 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. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--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. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. LRDF-0.6.1/Makefile.am000066400000000000000000000011071303474052200143000ustar00rootroot00000000000000ACLOCAL_AMFLAGS = -I m4 MAINTAINERCLEANFILES = aclocal.m4 config.guess config.h config.log \ config.status config.sub configure depcomp install-sh libtool ltmain.sh Makefile Makefile.in missing mkinstalldirs stamp-h include_HEADERS = lrdf.h lrdf_types.h EXTRA_DIST = autogen.sh lrdf.i SUBDIRS = src examples pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = lrdf.pc python: lrdf.i swig -python lrdf.i gcc -c src/lrdf.c src/lrdf_multi.c src/md5.c lrdf_wrap.c -I/usr/include/python2.3/ ld -shared lrdf_multi.o lrdf.o lrdf_wrap.o md5.o -lraptor -o _lrdf.so LRDF-0.6.1/NEWS000066400000000000000000000000251303474052200127410ustar00rootroot00000000000000No news is good news LRDF-0.6.1/README000066400000000000000000000003641303474052200131300ustar00rootroot00000000000000This is a library to make it easy to manipulate RDF files describing LADSPA plugins. It can also be used for general RDF manipulation. It can read RDF/XLM and N3 files and export N3 files, it also has a light taxonomic inference capablility. LRDF-0.6.1/autogen.sh000077500000000000000000000011671303474052200142530ustar00rootroot00000000000000#!/bin/sh gprefix=`which glibtoolize 2>&1 > /dev/null` if [ $? -eq 0 ]; then LIBTOOLIZE=glibtoolize else LIBTOOLIZE=libtoolize fi $LIBTOOLIZE --force || { echo "libtoolize failed, exiting..." exit 1 } aclocal $ACLOCAL_FLAGS || { echo "aclocal \$ACLOCAL_FLAGS where \$ACLOCAL_FLAGS= failed, exiting..." exit 1 } autoheader || { echo "autoheader failed, exiting..." exit 1 } automake --add-missing --foreign || { echo "automake --add-missing --foreign failed, exiting..." exit 1 } autoconf || { echo "autoconf failed, exiting..." exit 1 } echo "Running ./configure $@..." ./configure $@ LRDF-0.6.1/configure.ac000066400000000000000000000016221303474052200145340ustar00rootroot00000000000000# Process this file with autoconf to produce a configure script. AC_INIT(src/lrdf.c) AC_CONFIG_MACRO_DIR([m4]) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(liblrdf, 0.5.0) LRDF_LIBTOOL_VERSION=2:0:0 # Checks for programs. AC_PROG_AWK AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AM_PROG_LIBTOOL # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([errno.h limits.h stdlib.h string.h unistd.h]) PKG_CHECK_MODULES(RAPTOR, raptor2 >= 2.0.0) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T # Checks for library functions. dnl AC_FUNC_MALLOC AC_FUNC_VPRINTF AC_CHECK_FUNCS([getcwd strcasecmp strchr strdup strerror strncasecmp strrchr]) LIBS="$LIBS $RAPTOR_LIBS" AM_CFLAGS="$CFLAGS $RAPTOR_CFLAGS" AC_SUBST(AM_CFLAGS) AC_SUBST(LIBS) AC_SUBST(LRDF_LIBTOOL_VERSION) AC_OUTPUT([lrdf.pc Makefile src/Makefile examples/Makefile]) LRDF-0.6.1/examples/000077500000000000000000000000001303474052200140635ustar00rootroot00000000000000LRDF-0.6.1/examples/.gitignore000066400000000000000000000010421303474052200160500ustar00rootroot00000000000000*.o .deps .libs Makefile Makefile.in add_test add_test.log add_test.trs dumpstatements dumpstatements.log dumpstatements.trs export_test export_test.log export_test.trs instances_test instances_test.log instances_test.trs multi_test multi_test.log multi_test.trs preset-out.n3 remove_test remove_test.log remove_test.trs scale_test scale_test.log scale_test.trs setting_test setting_test.log setting_test.trs showdefaults showtaxonomy showtaxonomy.log showtaxonomy.trs subclass_test subclass_test.log subclass_test.trs test-out.n3 test-suite.log LRDF-0.6.1/examples/Makefile.am000066400000000000000000000006741303474052200161260ustar00rootroot00000000000000TESTS = showtaxonomy dumpstatements export_test \ subclass_test add_test instances_test remove_test multi_test \ setting_test scale_test check_PROGRAMS = showdefaults $(TESTS) remove_test AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src LIBS = ../src/liblrdf.la pkgdata_DATA = ladspa.rdfs pkgdatadir = $(datadir)/ladspa/rdf EXTRA_DIST = default-sample.rdf example.rdf sample.rdf scale-example.rdf \ ladspa.rdfs test-in.n3 preset-in.n3 LRDF-0.6.1/examples/add_test.c000066400000000000000000000020661303474052200160220ustar00rootroot00000000000000#include #include #include "lrdf.h" int main(int argc, char *argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", NULL }; const char *src = "test:add"; lrdf_init(); if (lrdf_read_files(rdf_uris)) { fprintf(stderr, "failed to open a file\n"); exit(1); } lrdf_add_triple(src, "test:id1", "test:foo", "1", lrdf_literal); lrdf_add_triple(src, "test:id1", "test:bar", "2", lrdf_literal); lrdf_add_triple(src, "test:id1", "test:baz", "3", lrdf_literal); lrdf_add_triple(src, "test:id2", "test:like", "test:id1", lrdf_uri); lrdf_add_triple(src, "test:id2", "test:foo", "4", lrdf_literal); lrdf_add_triple(src, "test:id2", "test:bar", "5", lrdf_literal); lrdf_add_triple(src, "test:id2", "test:baz", "6", lrdf_literal); lrdf_rebuild_caches(); lrdf_add_triple(src, "test:id2", "test:bar", "5", lrdf_literal); lrdf_add_triple(src, "test:id2", "test:baz", "6", lrdf_literal); lrdf_rebuild_caches(); lrdf_export_by_source(src, "test-out.n3"); lrdf_cleanup(); return 0; } LRDF-0.6.1/examples/default-sample.rdf000066400000000000000000000035631303474052200174720ustar00rootroot00000000000000 ]> No change 2002-07-16 Steve Harris Concert A sine (soft) LRDF-0.6.1/examples/dumpstatements.c000066400000000000000000000013621303474052200173060ustar00rootroot00000000000000#include #include #include "lrdf.h" int main(int argc, char*argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", "file:example.rdf", NULL }; const char *external_rdf_uris[] = { NULL, NULL }; lrdf_statement *s; lrdf_statement *it; lrdf_init(); if (argc == 1) { if (lrdf_read_files(rdf_uris)) { fprintf(stderr, "failed to open a file\n"); exit(1); } } else { external_rdf_uris[0] = argv[1]; if (lrdf_read_files(external_rdf_uris)) { fprintf(stderr, "failed to open a file\n"); exit(1); } } s = lrdf_all_statements(); for (it = s; it != NULL; it = it->next) { printf("(%s, %s, %s)\n", it->subject, it->predicate, it->object); } lrdf_cleanup(); return 0; } LRDF-0.6.1/examples/example.rdf000066400000000000000000002670041303474052200162240ustar00rootroot00000000000000 ]> LRDF-0.6.1/examples/export_test.c000066400000000000000000000006311303474052200166070ustar00rootroot00000000000000#include #include #include "lrdf.h" int main(int argc, char*argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", "file:test-in.n3", NULL }; lrdf_init(); if (lrdf_read_files(rdf_uris)) { fprintf(stderr, "failed to open a file\n"); exit(1); } lrdf_export_by_source("file:test-in.n3", "file:test-out.n3"); lrdf_cleanup(); return 0; } LRDF-0.6.1/examples/instances_test.c000066400000000000000000000016601303474052200172600ustar00rootroot00000000000000#include #include #include "lrdf.h" int main(int argc, char*argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", "file:///usr/local/share/ladspa/rdf/swh-plugins.rdf", NULL }; lrdf_uris *ulist; unsigned int i; lrdf_init(); if (lrdf_read_files(rdf_uris)) { fprintf(stderr, "failed to open a file\n"); exit(1); } printf("Instances of http://ladspa.org/ontology#Plugin\n"); ulist = lrdf_get_all_instances("http://ladspa.org/ontology#Plugin"); for (i = 0; ulist && i < ulist->count; i++) { printf(" %s\n", ulist->items[i]); } printf("\n"); lrdf_free_uris(ulist); printf("Instances of http://ladspa.org/ontology#FilterPlugin\n"); ulist = lrdf_get_all_instances("http://ladspa.org/ontology#FilterPlugin"); for (i = 0; ulist && i < ulist->count; i++) { printf(" %s\n", ulist->items[i]); } printf("\n"); lrdf_free_uris(ulist); lrdf_cleanup(); return 0; } LRDF-0.6.1/examples/ladspa.rdfs000066400000000000000000000172211303474052200162120ustar00rootroot00000000000000 ]> LRDF-0.6.1/examples/multi_test.c000066400000000000000000000023431303474052200164220ustar00rootroot00000000000000#include #include #include "lrdf.h" int main(int argc, char*argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", "file:sample.rdf", "file:example.rdf", NULL }; lrdf_uris *ulist; unsigned int i; lrdf_statement p1, p2; lrdf_init(); if (lrdf_read_files(rdf_uris)) { fprintf(stderr, "failed to open a file\n"); exit(1); } printf("Matches for (?, ladspa:hasLabel, gain)\n"); p1.subject = "?"; p1.predicate = "http://ladspa.org/ontology#hasLabel"; p1.object = "gain"; p1.next = NULL; ulist = lrdf_match_multi(&p1); for (i = 0; ulist && i < ulist->count; i++) { printf(" %s\n", ulist->items[i]); } printf("\n"); lrdf_free_uris(ulist); printf("Matches for (?, ladspa:hasLabel, freq), (?, ladspa:hasUnits, ladspa:Hz)\n"); p1.subject = "?"; p1.predicate = "http://ladspa.org/ontology#hasLabel"; p1.object = "freq"; p1.next = &p2; p2.subject = "?"; p2.predicate = "http://ladspa.org/ontology#hasUnits"; p2.object = "http://ladspa.org/ontology#Hz"; p2.next = NULL; ulist = lrdf_match_multi(&p1); for (i = 0; ulist && i < ulist->count; i++) { printf(" %s\n", ulist->items[i]); } printf("\n"); lrdf_free_uris(ulist); lrdf_cleanup(); return 0; } LRDF-0.6.1/examples/preset-in.n3000066400000000000000000000025551303474052200162420ustar00rootroot00000000000000 . "30.300000" . . . "20.200000" . . . "10.100000" . . "test" . . . LRDF-0.6.1/examples/remove_test.c000066400000000000000000000051511303474052200165650ustar00rootroot00000000000000#include #include #include "lrdf.h" int main(int argc, char*argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", "file:///usr/local/share/ladspa/rdf/swh-plugins.rdf", NULL }; lrdf_uris *ulist; const char *src = "test:add"; unsigned int i; lrdf_statement *s; lrdf_statement *it; lrdf_statement p; lrdf_init(); if (lrdf_read_files(rdf_uris)) { fprintf(stderr, "failed to open a file\n"); exit(1); } p.subject = "http://ladspa.org/ontology#1407"; p.predicate = NULL; p.object = NULL; s = lrdf_one_match(&p); printf("First match...\n"); printf("(%s, %s, %s)\n\n", s->subject, s->predicate, s->object); s = lrdf_matches(&p); printf("Triples before removing...\n"); for (it = s; it; it = it->next) { printf("(%s, %s, %s)\n", it->subject, it->predicate, it->object); } printf("...end\n"); lrdf_free_statements(s); lrdf_remove_matches(&p); s = lrdf_matches(&p); printf("Triples after removing...\n"); for (it = s; it; it = it->next) { printf("(%s, %s, %s)\n", it->subject, it->predicate, it->object); } printf("...end\n"); lrdf_free_statements(s); lrdf_add_triple(src, p.subject, "test:foo", "1", lrdf_literal); lrdf_add_triple(src, p.subject, "test:bar", "2", lrdf_literal); lrdf_add_triple(src, p.subject, "test:baz", "3", lrdf_literal); s = lrdf_matches(&p); printf("Triples after adding...\n"); for (it = s; it; it = it->next) { printf("(%s, %s, %s)\n", it->subject, it->predicate, it->object); } lrdf_free_statements(s); lrdf_remove_matches(&p); /* Just in case */ lrdf_rebuild_caches(); s = lrdf_matches(&p); printf("Triples after removing...\n"); for (it = s; it; it = it->next) { printf("(%s, %s, %s)\n", it->subject, it->predicate, it->object); } printf("...end\n"); lrdf_free_statements(s); lrdf_add_triple(src, p.subject, p.subject, "1", lrdf_literal); lrdf_add_triple(src, "foo", p.subject, p.subject, lrdf_literal); lrdf_add_triple(src, p.subject, "pred", p.subject, lrdf_literal); lrdf_add_triple(src, "object", "pred", p.subject, lrdf_literal); lrdf_remove_uri_matches(p.subject); s = lrdf_matches(&p); printf("Triples after removing...\n"); for (it = s; it; it = it->next) { printf("(%s, %s, %s)\n", it->subject, it->predicate, it->object); } printf("...end\n"); lrdf_free_statements(s); /* Just str a fre things that should be NOPs to catch corner cases */ lrdf_rebuild_caches(); lrdf_remove_uri_matches(p.subject); lrdf_rebuild_caches(); lrdf_remove_matches(&p); lrdf_remove_matches(&p); lrdf_remove_matches(&p); printf("\nend\n"); lrdf_cleanup(); return 0; } LRDF-0.6.1/examples/sample.rdf000066400000000000000000000036531303474052200160500ustar00rootroot00000000000000 ]> gain wave LRDF-0.6.1/examples/scale-example.rdf000066400000000000000000000016311303474052200173010ustar00rootroot00000000000000 ]> LRDF-0.6.1/examples/scale_test.c000066400000000000000000000014761303474052200163650ustar00rootroot00000000000000#include #include #include "lrdf.h" const float settings[] = { 0.1, 0.2, 0.3 }; int main(int argc, char *argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", "file:scale-example.rdf", NULL }; lrdf_defaults *defs; int i; lrdf_init(); if (lrdf_read_files(rdf_uris)) { fprintf(stderr, "failed to open a file\n"); exit(1); } defs = lrdf_get_scale_values(100, 1); for (i = 0; defs && i < defs->count; i++) { printf("%f = '%s'\n", defs->items[i].value, defs->items[i].label); } lrdf_free_setting_values(defs); /* check for bugs when looking for ports that have no scales */ defs = lrdf_get_scale_values(999999, 1); if (defs) { printf("error: lrdf_get_scale_values(999999, 1) returned non-NULL\n"); } lrdf_cleanup(); return 0; } LRDF-0.6.1/examples/setting_test.c000066400000000000000000000021641303474052200167460ustar00rootroot00000000000000#include #include #include "lrdf.h" const float settings[] = {0.1, 0.2, 0.3}; int main(int argc, char*argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", "file:example.rdf", "file:preset-in.n3", NULL }; lrdf_defaults *defs; lrdf_defaults d; lrdf_portvalue pv[3]; lrdf_uris * set_uris; int i; lrdf_init(); if (lrdf_read_files(rdf_uris)) { fprintf(stderr, "failed to open a file\n"); exit(1); } d.items = pv; d.count = 3; for (i=0; iitems[0]); printf("name: %s\n", lrdf_get_label(set_uris->items[0])); for (i=0; i < defs->count; i++) { printf("\tport %d = %f\n", defs->items[i].pid, defs->items[i].value); } lrdf_free_setting_values(defs); lrdf_export_by_source("file:preset-out.n3", "file:preset-out.n3"); lrdf_cleanup(); return 0; } LRDF-0.6.1/examples/showdefaults.c000066400000000000000000000016321303474052200167410ustar00rootroot00000000000000#include #include #include #include "lrdf.h" int main(int argc, char*argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", "file:example.rdf", NULL }; int uid; char *def_uri; lrdf_defaults *defs; int i; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); return 1; } lrdf_init(); if(lrdf_read_files(rdf_uris)) { fprintf(stderr, "failed to parse a file\n"); exit(1); } uid = atoi(argv[1]); def_uri = lrdf_get_default_uri(uid); if (def_uri == NULL) { printf("(none known)\n"); return 1; } printf("Defaults for plugin %d: %s\n", uid, lrdf_get_setting_metadata(def_uri, "title")); defs = lrdf_get_setting_values(def_uri); for (i=0; i < defs->count; i++) { printf("\tport %d (%s) = %f\n", defs->items[i].pid, defs->items[i].label, defs->items[i].value); } lrdf_free_setting_values(defs); lrdf_cleanup(); return 0; } LRDF-0.6.1/examples/showtaxonomy.c000066400000000000000000000021111303474052200170010ustar00rootroot00000000000000#include #include #include #include #include "lrdf.h" void decend(char *uri, char *base); int main(int argc, char *argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", "file:example.rdf", NULL }; lrdf_init(); if (lrdf_read_files(rdf_uris)) { fprintf(stderr, "showtaxonomy: failed to parse all files\n"); exit(1); } decend(LADSPA_BASE "Plugin", ""); lrdf_cleanup(); return 0; } void decend(char *uri, char *base) { lrdf_uris *uris; unsigned int i; char *newbase; char *label; uris = lrdf_get_instances(uri); if (uris != NULL) { for (i = 0; i < uris->count; i++) { printf("%s/[%ld]\n", base, lrdf_get_uid(uris->items[i])); } lrdf_free_uris(uris); } uris = lrdf_get_subclasses(uri); if (uris != NULL) { for (i = 0; i < uris->count; i++) { label = lrdf_get_label(uris->items[i]); newbase = malloc(strlen(base) + strlen(label) + 2); sprintf(newbase, "%s/%s", base, label); printf("%s\n", newbase); decend(uris->items[i], newbase); free(newbase); } lrdf_free_uris(uris); } } LRDF-0.6.1/examples/subclass_test.c000066400000000000000000000016121303474052200171050ustar00rootroot00000000000000#include #include #include "lrdf.h" int main(int argc, char*argv[]) { const char *rdf_uris[] = { "file:ladspa.rdfs", "file:example.rdf", NULL }; lrdf_uris *ulist; unsigned int i; lrdf_init(); if (lrdf_read_files(rdf_uris)) { fprintf(stderr, "failed to open a file\n"); exit(1); } printf("Subclasses of http://ladspa.org/ontology#Plugin\n"); ulist = lrdf_get_all_subclasses("http://ladspa.org/ontology#Plugin"); for (i = 0; ulist && i < ulist->count; i++) { printf(" %s\n", ulist->items[i]); } printf("\n"); lrdf_free_uris(ulist); printf("Superclasses of http://ladspa.org/ontology#Plugin\n"); ulist = lrdf_get_all_superclasses("http://ladspa.org/ontology#Plugin"); for (i = 0; ulist && i < ulist->count; i++) { printf(" %s\n", ulist->items[i]); } printf("\n"); lrdf_free_uris(ulist); lrdf_cleanup(); return 0; } LRDF-0.6.1/examples/test-in.n3000066400000000000000000000070501303474052200157120ustar00rootroot00000000000000 . "instab" . . . "warm" . . . . "freq" . . . <_:genid1.3e1e12da> . <_:genid1.3e1e12da> <_:genid5.3e1e12da> . <_:genid5.3e1e12da> "4" . <_:genid5.3e1e12da> "Saw" . <_:genid5.3e1e12da> . <_:genid1.3e1e12da> <_:genid4.3e1e12da> . <_:genid4.3e1e12da> "3" . <_:genid4.3e1e12da> "Square" . <_:genid4.3e1e12da> . <_:genid1.3e1e12da> <_:genid3.3e1e12da> . <_:genid3.3e1e12da> "2" . <_:genid3.3e1e12da> "Triangle" . <_:genid3.3e1e12da> . <_:genid1.3e1e12da> <_:genid2.3e1e12da> . <_:genid2.3e1e12da> "1" . <_:genid2.3e1e12da> "Sine" . <_:genid2.3e1e12da> . <_:genid1.3e1e12da> . "wave" . . . . . "gain" . . . LRDF-0.6.1/lrdf.h000066400000000000000000000154231303474052200133520ustar00rootroot00000000000000#ifndef LRDF_H #define LRDF_H #ifdef __cplusplus extern "C" { #endif #include #include #include #include "lrdf_types.h" // #define DEBUG 1 #define RDF_BASE "http://www.w3.org/1999/02/22-rdf-syntax-ns#" #define RDF_TYPE RDF_BASE "type" #define RDF_RESOURCE RDF_BASE "Resource" #define RDFS_BASE "http://www.w3.org/2000/01/rdf-schema#" #define RDFS_CLASS RDFS_BASE "Class" #define RDFS_SUBCLASSOF RDFS_BASE "subClassOf" #define LADSPA_BASE "http://ladspa.org/ontology#" #define DC_BASE "http://purl.org/dc/elements/1.1/" /* Data functions */ /* Call lrdf_init before using any of the functions below */ void lrdf_init(); /* Call this at the end to clean up the caches and so on */ void lrdf_cleanup(); /* Call lrdf_read_files to read a set of files, it is more efficient than * calling lrdf_read_file repeatedly * * Pass in the files as file: uri, eg * "file:///usr/local/share/ladspa/rdf/ladspa.rdfs". This URI will be written * stored as the source of the triple. See lrdf_add_triple, and * lrdf_export_by_source for uses for this. */ int lrdf_read_files(const char *uri[]); /* lrdf_read_file: * * Loads the file specifed by uri into the internal representation. * * uri can point to either an RDF-XML .rdf file or an RDF-Ntriples .n3 file. * the source of the triples will be set to the file uri. c.f. lrdf_read_file */ int lrdf_read_file(const char *uri); /* lrdf_add_triple: * * This is a way to manually add a triple to the store. * * The source argument is a way of grouping triples so that they can be * exported later. If you do not care set it to NULL. See examples/add_test.c * for an example. * * The subject and predicate arguments are fully qualified URIs for those * parts. object may also be a string, if indicated by literal. * * The literal argument specifies wether the object argument is to be * interpreted as a URI or Literal. Set it to lrdf_literal for literals and * lrdf_uri for uris. * * NB If you add any triples relating to the taxonomy (Classes) you /must/ * run lrdf_rebuild_caches() afterwards, otherwise you will get odd results * from queries. */ void lrdf_add_triple(const char *source, const char *subject, const char *predicate, const char *object, enum lrdf_objtype literal); /* lrdf_add_preset: * * This function adds a preset object to the store. * * source must be a unique URI that represents the setting object (I recommend * the file: URI it will be saved under), label is a name for the preset, ID is * the UID number of the plugin and vals is a pointer to a lrdf_defaults * structure containing the values to be written. * * returns the URI of the added preset. The caller is responsible for freeing * it. */ char* lrdf_add_preset(const char *source, const char *label, unsigned long id, lrdf_defaults *vals); /* lrdf_remove_matches: * * This function will remove all triples from the store that match the * specified pattern. * * NB. It is horribly inefficient! Currently O(N) complexity. If you need to * make extensive use of it please contact me and I will look at restructuring * the data to make it faster. */ void lrdf_remove_matches(lrdf_statement *pattern); /* lrdf_remove_uri_matches: * * This function will remove all triples contating the URI passed in as an * argument. */ void lrdf_remove_uri_matches(const char *uri); /* lrdf_rebuild_caches * * The rebuilds the taxonomic closue matrix thats used to accelerate taxonomic * inference queries. User should only need to call this after manually adding * triples with lrdf_add_triple. */ void lrdf_rebuild_caches(); /* lrdf_export_by_source * * writes all the triples associated with the source 'src' to the file 'file', * file can be specified as a UNIX path for file: URI. Currently the export * format is NTriples (.n3), but it may change to RDF-XML in the future. */ int lrdf_export_by_source(const char *src, const char *file); /* Generic RDF access functions */ /* lrdf_match_multi: * * Returns a lrdf_uris vector of all the URIs (or Literals) that match the * pattern list specified. eg: * * ("?", "rdfs:label", NULL), ("?", "foo:bpm", "120") * * Will return all the values for '?' which match the patterns, ie. have an * rdfs:label and have the foo:bpm value of 120. */ lrdf_uris *lrdf_match_multi(lrdf_statement *patterns); /* lrdf_matches: * * Returns a NULL terminated vector of lrdf_statements that match the * sepecifed pattern, where a NULL in any position matches any uri. * * To free the space allocated call lrdf_free_statements() on the return value; */ lrdf_statement *lrdf_matches(lrdf_statement *pattern); /* lrdf_one_match: * * returns a pointer to the first matching triple if one exists, or NULL * otherwise */ lrdf_statement *lrdf_one_match(lrdf_statement *pattern); /* lrdf_exists_match: * * returns 1 if a triple mathcing the pattern exists, 0 otherwise */ int lrdf_exists_match(lrdf_statement *pattern); /* lrdf_get_all_superclasses: * * Returns a list of all the superlasses of uri, including itsself */ lrdf_uris *lrdf_get_all_superclasses(const char *uri); /* lrdf_get_subclasses * * Returns a list of the direct subclasses of a given class, ie. all classes * that have been explicity asserted to be subclasses of uri. Does not * (usually) include itsself. */ lrdf_uris *lrdf_get_subclasses(const char *uri); /* lrdf_get_all_subclasses: * * Returns a list of all the sublasses of uri */ lrdf_uris *lrdf_get_all_subclasses(const char *uri); /* lrdf_get_instances * * Returns a list of the instances of a given class */ lrdf_uris *lrdf_get_instances(const char *uri); /* lrdf_get_all_instances: * * Returns the URIs of all the instances of 'uri' and all the instances of all * its subclasses. * * Doesn't currently remove duplicates, but it could be changed to do that if * required. */ lrdf_uris *lrdf_get_all_instances(const char *uri); /* lrdf_all_statements: * * Returns a pointer to a list of all the triples in the system, DO NOT free * the returned list, it is hte real list. */ lrdf_statement *lrdf_all_statements(); /* lrdf_free_uris: * * Called on the return values from lrdf_get_subclasses etc. to free up the * memory allocated by them. */ void lrdf_free_uris(lrdf_uris *u); void lrdf_free_statements(lrdf_statement *s); /* LADSPA Ontology specific functions */ char *lrdf_get_setting_metadata(const char *uri, const char *element); char *lrdf_get_default_uri(unsigned long id); lrdf_uris *lrdf_get_setting_uris(unsigned long id); unsigned long lrdf_get_uid(const char *uri); lrdf_defaults *lrdf_get_setting_values(const char *uri); lrdf_defaults *lrdf_get_scale_values(unsigned long id, unsigned long port); void lrdf_free_setting_values(lrdf_defaults *def); char *lrdf_get_label(const char *uri); #ifdef __cplusplus } #endif #endif LRDF-0.6.1/lrdf.i000066400000000000000000000001501303474052200133420ustar00rootroot00000000000000%module lrdf %{ #include "lrdf.h" #include "lrdf_types.h" %} %include "lrdf.h" %include "lrdf_types.h" LRDF-0.6.1/lrdf.pc.in000066400000000000000000000004341303474052200141260ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: liblrdf Version: @VERSION@ Description: liblrdf, a lightweight RDF library with extensions for LADSPA Libs: -L${libdir} -llrdf Libs.private: @RAPTOR_LIBS@ Cflags: @RAPTOR_CFLAGS@ -I${includedir} LRDF-0.6.1/lrdf_types.h000066400000000000000000000021371303474052200145740ustar00rootroot00000000000000#ifndef LRDF_TYPES_H #define LRDF_TYPES_H #ifdef __cplusplus extern "C" { #endif #include enum lrdf_objtype { lrdf_uri, lrdf_literal }; typedef int64_t lrdf_hash; typedef struct _lrdf_statement { char *subject; char *predicate; char *object; enum lrdf_objtype object_type; struct _lrdf_statement *next; lrdf_hash shash; lrdf_hash phash; lrdf_hash ohash; lrdf_hash source; } lrdf_statement; typedef struct _lrdf_string_hash { lrdf_hash hash; char *str; struct _lrdf_string_hash *next; } lrdf_string_hash; typedef struct _lrdf_triple_hash { lrdf_hash hash; lrdf_statement *triple; struct _lrdf_triple_hash *next; } lrdf_triple_hash; typedef struct _lrdf_closure_hash { lrdf_hash subject; lrdf_hash object; struct _lrdf_closure_hash *next; } lrdf_closure_hash; typedef struct { unsigned long pid; char *label; float value; } lrdf_portvalue; typedef struct { unsigned int count; lrdf_portvalue *items; } lrdf_defaults; typedef struct { unsigned int size; unsigned int count; char **items; } lrdf_uris; #ifdef __cplusplus } #endif #endif LRDF-0.6.1/src/000077500000000000000000000000001303474052200130345ustar00rootroot00000000000000LRDF-0.6.1/src/.gitignore000066400000000000000000000001151303474052200150210ustar00rootroot00000000000000.deps .libs Makefile Makefile.in liblrdf.la lrdf.lo lrdf_multi.lo md5.lo *.o LRDF-0.6.1/src/Makefile.am000066400000000000000000000003641303474052200150730ustar00rootroot00000000000000AM_CFLAGS = -Wall -g -I@top_srcdir@ @AM_CFLAGS@ lib_LTLIBRARIES = liblrdf.la noinst_HEADERS = ladspa.h liblrdf_la_SOURCES = lrdf.c lrdf_multi.c md5.c liblrdf_la_LIBADD = @RAPTOR_LIBS@ liblrdf_la_LDFLAGS = -version-info @LRDF_LIBTOOL_VERSION@ LRDF-0.6.1/src/ladspa.h000066400000000000000000000654671303474052200144730ustar00rootroot00000000000000/* ladspa.h Linux Audio Developer's Simple Plugin API Version 1.1[provisional, LGPL]. Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis, Stefan Westerfeld. This library 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. This library 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 this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #ifndef LADSPA_INCLUDED #define LADSPA_INCLUDED #ifdef __cplusplus extern "C" { #endif /*****************************************************************************/ /* Overview: There is a large number of synthesis packages in use or development on the Linux platform at this time. This API (`The Linux Audio Developer's Simple Plugin API') attempts to give programmers the ability to write simple `plugin' audio processors in C/C++ and link them dynamically (`plug') into a range of these packages (`hosts'). It should be possible for any host and any plugin to communicate completely through this interface. This API is deliberately short and simple. To achieve compatibility with a range of promising Linux sound synthesis packages it attempts to find the `greatest common divisor' in their logical behaviour. Having said this, certain limiting decisions are implicit, notably the use of a fixed type (LADSPA_Data) for all data transfer and absence of a parameterised `initialisation' phase. See below for the LADSPA_Data typedef. Plugins are expected to distinguish between control and audio data. Plugins have `ports' that are inputs or outputs for audio or control data and each plugin is `run' for a `block' corresponding to a short time interval measured in samples. Audio data is communicated using arrays of LADSPA_Data, allowing a block of audio to be processed by the plugin in a single pass. Control data is communicated using single LADSPA_Data values. Control data has a single value at the start of a call to the `run()' or `run_adding()' function, and may be considered to remain this value for its duration. The plugin may assume that all its input and output ports have been connected to the relevant data location (see the `connect_port()' function below) before it is asked to run. Plugins will reside in shared object files suitable for dynamic linking by dlopen() and family. The file will provide a number of `plugin types' that can be used to instantiate actual plugins (sometimes known as `plugin instances') that can be connected together to perform tasks. This API contains very limited error-handling. */ /*****************************************************************************/ /* Fundamental data type passed in and out of plugin. This data type is used to communicate audio samples and control values. It is assumed that the plugin will work sensibly given any numeric input value although it may have a preferred range (see hints below). For audio it is generally assumed that 1.0f is the `0dB' reference amplitude and is a `normal' signal level. */ typedef float LADSPA_Data; /*****************************************************************************/ /* Special Plugin Properties: Optional features of the plugin type are encapsulated in the LADSPA_Properties type. This is assembled by ORing individual properties together. */ typedef int LADSPA_Properties; /* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a real-time dependency (e.g. listens to a MIDI device) and so its output must not be cached or subject to significant latency. */ #define LADSPA_PROPERTY_REALTIME 0x1 /* Property LADSPA_PROPERTY_INPLACE_BROKEN indicates that the plugin may cease to work correctly if the host elects to use the same data location for both input and output (see connect_port()). This should be avoided as enabling this flag makes it impossible for hosts to use the plugin to process audio `in-place.' */ #define LADSPA_PROPERTY_INPLACE_BROKEN 0x2 /* Property LADSPA_PROPERTY_HARD_RT_CAPABLE indicates that the plugin is capable of running not only in a conventional host but also in a `hard real-time' environment. To qualify for this the plugin must satisfy all of the following: (1) The plugin must not use malloc(), free() or other heap memory management within its run() or run_adding() functions. All new memory used in run() must be managed via the stack. These restrictions only apply to the run() function. (2) The plugin will not attempt to make use of any library functions with the exceptions of functions in the ANSI standard C and C maths libraries, which the host is expected to provide. (3) The plugin will not access files, devices, pipes, sockets, IPC or any other mechanism that might result in process or thread blocking. (4) The plugin will take an amount of time to execute a run() or run_adding() call approximately of form (A+B*SampleCount) where A and B depend on the machine and host in use. This amount of time may not depend on input signals or plugin state. The host is left the responsibility to perform timings to estimate upper bounds for A and B. */ #define LADSPA_PROPERTY_HARD_RT_CAPABLE 0x4 #define LADSPA_IS_REALTIME(x) ((x) & LADSPA_PROPERTY_REALTIME) #define LADSPA_IS_INPLACE_BROKEN(x) ((x) & LADSPA_PROPERTY_INPLACE_BROKEN) #define LADSPA_IS_HARD_RT_CAPABLE(x) ((x) & LADSPA_PROPERTY_HARD_RT_CAPABLE) /*****************************************************************************/ /* Plugin Ports: Plugins have `ports' that are inputs or outputs for audio or data. Ports can communicate arrays of LADSPA_Data (for audio inputs/outputs) or single LADSPA_Data values (for control input/outputs). This information is encapsulated in the LADSPA_PortDescriptor type which is assembled by ORing individual properties together. Note that a port must be an input or an output port but not both and that a port must be a control or audio port but not both. */ typedef int LADSPA_PortDescriptor; /* Property LADSPA_PORT_INPUT indicates that the port is an input. */ #define LADSPA_PORT_INPUT 0x1 /* Property LADSPA_PORT_OUTPUT indicates that the port is an output. */ #define LADSPA_PORT_OUTPUT 0x2 /* Property LADSPA_PORT_CONTROL indicates that the port is a control port. */ #define LADSPA_PORT_CONTROL 0x4 /* Property LADSPA_PORT_AUDIO indicates that the port is a audio port. */ #define LADSPA_PORT_AUDIO 0x8 #define LADSPA_IS_PORT_INPUT(x) ((x) & LADSPA_PORT_INPUT) #define LADSPA_IS_PORT_OUTPUT(x) ((x) & LADSPA_PORT_OUTPUT) #define LADSPA_IS_PORT_CONTROL(x) ((x) & LADSPA_PORT_CONTROL) #define LADSPA_IS_PORT_AUDIO(x) ((x) & LADSPA_PORT_AUDIO) /*****************************************************************************/ /* Plugin Port Range Hints: The host may wish to provide a representation of data entering or leaving a plugin (e.g. to generate a GUI automatically). To make this more meaningful, the plugin should provide `hints' to the host describing the usual values taken by the data. Note that these are only hints. The host may ignore them and the plugin must not assume that data supplied to it is meaningful. If the plugin receives invalid input data it is expected to continue to run without failure and, where possible, produce a sensible output (e.g. a high-pass filter given a negative cutoff frequency might switch to an all-pass mode). Hints are meaningful for all input and output ports but hints for input control ports are expected to be particularly useful. More hint information is encapsulated in the LADSPA_PortRangeHintDescriptor type which is assembled by ORing individual hint types together. Hints may require further LowerBound and UpperBound information. All the hint information for a particular port is aggregated in the LADSPA_PortRangeHint structure. */ typedef int LADSPA_PortRangeHintDescriptor; /* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field of the LADSPA_PortRangeHint should be considered meaningful. The value in this field should be considered the (inclusive) lower bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also specified then the value of LowerBound should be multiplied by the sample rate. */ #define LADSPA_HINT_BOUNDED_BELOW 0x1 /* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field of the LADSPA_PortRangeHint should be considered meaningful. The value in this field should be considered the (inclusive) upper bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also specified then the value of UpperBound should be multiplied by the sample rate. */ #define LADSPA_HINT_BOUNDED_ABOVE 0x2 /* Hint LADSPA_HINT_TOGGLED indicates that the data item should be considered a Boolean toggle. Data less than or equal to zero should be considered `off' or `false,' and data above zero should be considered `on' or `true.' LADSPA_HINT_TOGGLED may not be used in conjunction with any other hint except LADSPA_HINT_DEFAULT_0 or LADSPA_HINT_DEFAULT_1. */ #define LADSPA_HINT_TOGGLED 0x4 /* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified should be interpreted as multiples of the sample rate. For instance, a frequency range from 0Hz to the Nyquist frequency (half the sample rate) could be requested by this hint in conjunction with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds at all must support this hint to retain meaning. */ #define LADSPA_HINT_SAMPLE_RATE 0x8 /* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the user will find it more intuitive to view values using a logarithmic scale. This is particularly useful for frequencies and gains. */ #define LADSPA_HINT_LOGARITHMIC 0x10 /* Hint LADSPA_HINT_INTEGER indicates that a user interface would probably wish to provide a stepped control taking only integer values. Any bounds set should be slightly wider than the actual integer range required to avoid floating point rounding errors. For instance, the integer set {0,1,2,3} might be described as [-0.1, 3.1]. */ #define LADSPA_HINT_INTEGER 0x20 /* The various LADSPA_HINT_HAS_DEFAULT_* hints indicate a `normal' value for the port that is sensible as a default. For instance, this value is suitable for use as an initial value in a user interface or as a value the host might assign to a control port when the user has not provided one. Defaults are encoded using a mask so only one default may be specified for a port. Some of the hints make use of lower and upper bounds, in which case the relevant bound or bounds must be available and LADSPA_HINT_SAMPLE_RATE must be applied as usual. The resulting default must be rounded if LADSPA_HINT_INTEGER is present. Default values were introduced in LADSPA v1.1. */ #define LADSPA_HINT_DEFAULT_MASK 0x3C0 /* This default values indicates that no default is provided. */ #define LADSPA_HINT_DEFAULT_NONE 0x0 /* This default hint indicates that the suggested lower bound for the port should be used. */ #define LADSPA_HINT_DEFAULT_MINIMUM 0x40 /* This default hint indicates that a low value between the suggested lower and upper bounds should be chosen. For ports with LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.75 + log(upper) * 0.25). Otherwise, this should be (lower * 0.75 + upper * 0.25). */ #define LADSPA_HINT_DEFAULT_LOW 0x80 /* This default hint indicates that a middle value between the suggested lower and upper bounds should be chosen. For ports with LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.5 + log(upper) * 0.5). Otherwise, this should be (lower * 0.5 + upper * 0.5). */ #define LADSPA_HINT_DEFAULT_MIDDLE 0xC0 /* This default hint indicates that a high value between the suggested lower and upper bounds should be chosen. For ports with LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.25 + log(upper) * 0.75). Otherwise, this should be (lower * 0.25 + upper * 0.75). */ #define LADSPA_HINT_DEFAULT_HIGH 0x100 /* This default hint indicates that the suggested upper bound for the port should be used. */ #define LADSPA_HINT_DEFAULT_MAXIMUM 0x140 /* This default hint indicates that the number 0 should be used. Note that this default may be used in conjunction with LADSPA_HINT_TOGGLED. */ #define LADSPA_HINT_DEFAULT_0 0x200 /* This default hint indicates that the number 1 should be used. Note that this default may be used in conjunction with LADSPA_HINT_TOGGLED. */ #define LADSPA_HINT_DEFAULT_1 0x240 /* This default hint indicates that the number 100 should be used. */ #define LADSPA_HINT_DEFAULT_100 0x280 /* This default hint indicates that the Hz frequency of `concert A' should be used. This will be 440 unless the host uses an unusual tuning convention, in which case it may be within a few Hz. */ #define LADSPA_HINT_DEFAULT_440 0x2C0 #define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW) #define LADSPA_IS_HINT_BOUNDED_ABOVE(x) ((x) & LADSPA_HINT_BOUNDED_ABOVE) #define LADSPA_IS_HINT_TOGGLED(x) ((x) & LADSPA_HINT_TOGGLED) #define LADSPA_IS_HINT_SAMPLE_RATE(x) ((x) & LADSPA_HINT_SAMPLE_RATE) #define LADSPA_IS_HINT_LOGARITHMIC(x) ((x) & LADSPA_HINT_LOGARITHMIC) #define LADSPA_IS_HINT_INTEGER(x) ((x) & LADSPA_HINT_INTEGER) #define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK) #define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_MINIMUM) #define LADSPA_IS_HINT_DEFAULT_LOW(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_LOW) #define LADSPA_IS_HINT_DEFAULT_MIDDLE(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_MIDDLE) #define LADSPA_IS_HINT_DEFAULT_HIGH(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_HIGH) #define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_MAXIMUM) #define LADSPA_IS_HINT_DEFAULT_0(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_0) #define LADSPA_IS_HINT_DEFAULT_1(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_1) #define LADSPA_IS_HINT_DEFAULT_100(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_100) #define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ == LADSPA_HINT_DEFAULT_440) typedef struct _LADSPA_PortRangeHint { /* Hints about the port. */ LADSPA_PortRangeHintDescriptor HintDescriptor; /* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When LADSPA_HINT_SAMPLE_RATE is also active then this value should be multiplied by the relevant sample rate. */ LADSPA_Data LowerBound; /* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When LADSPA_HINT_SAMPLE_RATE is also active then this value should be multiplied by the relevant sample rate. */ LADSPA_Data UpperBound; } LADSPA_PortRangeHint; /*****************************************************************************/ /* Plugin Handles: This plugin handle indicates a particular instance of the plugin concerned. It is valid to compare this to NULL (0 for C++) but otherwise the host should not attempt to interpret it. The plugin may use it to reference internal instance data. */ typedef void * LADSPA_Handle; /*****************************************************************************/ /* Descriptor for a Type of Plugin: This structure is used to describe a plugin type. It provides a number of functions to examine the type, instantiate it, link it to buffers and workspaces and to run it. */ typedef struct _LADSPA_Descriptor { /* This numeric identifier indicates the plugin type uniquely. Plugin programmers may reserve ranges of IDs from a central body to avoid clashes. Hosts may assume that IDs are below 0x1000000. */ unsigned long UniqueID; /* This identifier can be used as a unique, case-sensitive identifier for the plugin type within the plugin file. Plugin types should be identified by file and label rather than by index or plugin name, which may be changed in new plugin versions. Labels must not contain white-space characters. */ const char * Label; /* This indicates a number of properties of the plugin. */ LADSPA_Properties Properties; /* This member points to the null-terminated name of the plugin (e.g. "Sine Oscillator"). */ const char * Name; /* This member points to the null-terminated string indicating the maker of the plugin. This can be an empty string but not NULL. */ const char * Maker; /* This member points to the null-terminated string indicating any copyright applying to the plugin. If no Copyright applies the string "None" should be used. */ const char * Copyright; /* This indicates the number of ports (input AND output) present on the plugin. */ unsigned long PortCount; /* This member indicates an array of port descriptors. Valid indices vary from 0 to PortCount-1. */ const LADSPA_PortDescriptor * PortDescriptors; /* This member indicates an array of null-terminated strings describing ports (e.g. "Frequency (Hz)"). Valid indices vary from 0 to PortCount-1. */ const char * const * PortNames; /* This member indicates an array of range hints for each port (see above). Valid indices vary from 0 to PortCount-1. */ const LADSPA_PortRangeHint * PortRangeHints; /* This may be used by the plugin developer to pass any custom implementation data into an instantiate call. It must not be used or interpreted by the host. It is expected that most plugin writers will not use this facility as LADSPA_Handle should be used to hold instance data. */ void * ImplementationData; /* This member is a function pointer that instantiates a plugin. A handle is returned indicating the new plugin instance. The instantiation function accepts a sample rate as a parameter. The plugin descriptor from which this instantiate function was found must also be passed. This function must return NULL if instantiation fails. Note that instance initialisation should generally occur in activate() rather than here. */ LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor, unsigned long SampleRate); /* This member is a function pointer that connects a port on an instantiated plugin to a memory location at which a block of data for the port will be read/written. The data location is expected to be an array of LADSPA_Data for audio ports or a single LADSPA_Data value for control ports. Memory issues will be managed by the host. The plugin must read/write the data at these locations every time run() or run_adding() is called and the data present at the time of this connection call should not be considered meaningful. connect_port() may be called more than once for a plugin instance to allow the host to change the buffers that the plugin is reading or writing. These calls may be made before or after activate() or deactivate() calls. connect_port() must be called at least once for each port before run() or run_adding() is called. When working with blocks of LADSPA_Data the plugin should pay careful attention to the block size passed to the run function as the block allocated may only just be large enough to contain the block of samples. Plugin writers should be aware that the host may elect to use the same buffer for more than one port and even use the same buffer for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN). However, overlapped buffers or use of a single buffer for both audio and control data may result in unexpected behaviour. */ void (*connect_port)(LADSPA_Handle Instance, unsigned long Port, LADSPA_Data * DataLocation); /* This member is a function pointer that initialises a plugin instance and activates it for use. This is separated from instantiate() to aid real-time support and so that hosts can reinitialise a plugin instance by calling deactivate() and then activate(). In this case the plugin instance must reset all state information dependent on the history of the plugin instance except for any data locations provided by connect_port() and any gain set by set_run_adding_gain(). If there is nothing for activate() to do then the plugin writer may provide a NULL rather than an empty function. When present, hosts must call this function once before run() (or run_adding()) is called for the first time. This call should be made as close to the run() call as possible and indicates to real-time plugins that they are now live. Plugins should not rely on a prompt call to run() after activate(). activate() may not be called again unless deactivate() is called first. Note that connect_port() may be called before or after a call to activate(). */ void (*activate)(LADSPA_Handle Instance); /* This method is a function pointer that runs an instance of a plugin for a block. Two parameters are required: the first is a handle to the particular instance to be run and the second indicates the block size (in samples) for which the plugin instance may run. Note that if an activate() function exists then it must be called before run() or run_adding(). If deactivate() is called for a plugin instance then the plugin instance may not be reused until activate() has been called again. If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE then there are various things that the plugin should not do within the run() or run_adding() functions (see above). */ void (*run)(LADSPA_Handle Instance, unsigned long SampleCount); /* This method is a function pointer that runs an instance of a plugin for a block. This has identical behaviour to run() except in the way data is output from the plugin. When run() is used, values are written directly to the memory areas associated with the output ports. However when run_adding() is called, values must be added to the values already present in the memory areas. Furthermore, output values written must be scaled by the current gain set by set_run_adding_gain() (see below) before addition. run_adding() is optional. When it is not provided by a plugin, this function pointer must be set to NULL. When it is provided, the function set_run_adding_gain() must be provided also. */ void (*run_adding)(LADSPA_Handle Instance, unsigned long SampleCount); /* This method is a function pointer that sets the output gain for use when run_adding() is called (see above). If this function is never called the gain is assumed to default to 1. Gain information should be retained when activate() or deactivate() are called. This function should be provided by the plugin if and only if the run_adding() function is provided. When it is absent this function pointer must be set to NULL. */ void (*set_run_adding_gain)(LADSPA_Handle Instance, LADSPA_Data Gain); /* This is the counterpart to activate() (see above). If there is nothing for deactivate() to do then the plugin writer may provide a NULL rather than an empty function. Hosts must deactivate all activated units after they have been run() (or run_adding()) for the last time. This call should be made as close to the last run() call as possible and indicates to real-time plugins that they are no longer live. Plugins should not rely on prompt deactivation. Note that connect_port() may be called before or after a call to deactivate(). Deactivation is not similar to pausing as the plugin instance will be reinitialised when activate() is called to reuse it. */ void (*deactivate)(LADSPA_Handle Instance); /* Once an instance of a plugin has been finished with it can be deleted using the following function. The instance handle passed ceases to be valid after this call. If activate() was called for a plugin instance then a corresponding call to deactivate() must be made before cleanup() is called. */ void (*cleanup)(LADSPA_Handle Instance); } LADSPA_Descriptor; /**********************************************************************/ /* Accessing a Plugin: */ /* The exact mechanism by which plugins are loaded is host-dependent, however all most hosts will need to know is the name of shared object file containing the plugin types. To allow multiple hosts to share plugin types, hosts may wish to check for environment variable LADSPA_PATH. If present, this should contain a colon-separated path indicating directories that should be searched (in order) when loading plugin types. A plugin programmer must include a function called "ladspa_descriptor" with the following function prototype within the shared object file. This function will have C-style linkage (if you are using C++ this is taken care of by the `extern "C"' clause at the top of the file). A host will find the plugin shared object file by one means or another, find the ladspa_descriptor() function, call it, and proceed from there. Plugin types are accessed by index (not ID) using values from 0 upwards. Out of range indexes must result in this function returning NULL, so the plugin count can be determined by checking for the least index that results in NULL being returned. */ const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index); /* Datatype corresponding to the ladspa_descriptor() function. */ typedef const LADSPA_Descriptor * (*LADSPA_Descriptor_Function)(unsigned long Index); /**********************************************************************/ #ifdef __cplusplus } #endif #endif /* LADSPA_INCLUDED */ /* EOF */ LRDF-0.6.1/src/lrdf.c000066400000000000000000000775271303474052200141510ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include "md5.h" #include "lrdf.h" /* XXX The size if that hash table, should be dyunamic, but this will do for * now */ #define LRDF_HASH_SIZE 1024 static unsigned int lrdf_uid = 0; /* A unique(ish) id to append to genid's to * avoid clashses */ static raptor_world *world = NULL; static lrdf_statement *triples = NULL; static lrdf_statement *free_triples; static lrdf_string_hash *resources_hash[LRDF_HASH_SIZE]; static lrdf_string_hash *literals_hash[LRDF_HASH_SIZE]; static lrdf_triple_hash *subj_hash[LRDF_HASH_SIZE]; static lrdf_triple_hash *obj_hash[LRDF_HASH_SIZE]; static lrdf_triple_hash *pred_hash[LRDF_HASH_SIZE]; static lrdf_closure_hash *subclass_hash[LRDF_HASH_SIZE]; static lrdf_closure_hash *superclass_hash[LRDF_HASH_SIZE]; static lrdf_hash rdf_resource_h; /* Internal functions */ void lrdf_more_triples(int count); lrdf_statement *lrdf_alloc_statement(); lrdf_statement *lrdf_all_triples(); static char *lrdf_check_hash(lrdf_string_hash ** tbl, lrdf_hash hash, const char *str); static char *lrdf_find_string_hash(lrdf_string_hash ** tbl, lrdf_hash hash); static void lrdf_add_triple_hash(lrdf_triple_hash ** tbl, lrdf_hash hash, lrdf_statement * s); static void lrdf_remove_triple_hash(lrdf_triple_hash ** tbl, lrdf_hash hash, lrdf_statement * s); static void lrdf_add_closure_hash(lrdf_closure_hash ** tbl, lrdf_hash subject, lrdf_hash object); static void lrdf_store(void *user_data, raptor_statement * statement); void lrdf_free_statements(lrdf_statement * s); void lrdf_copy_statement(lrdf_statement * from, lrdf_statement * to); void lrdf_rebuild_taxonomic_closure(lrdf_closure_hash ** fwd_tbl, lrdf_closure_hash ** rev_tbl); static lrdf_uris *lrdf_uris_new(int size); int lrdf_read_file_intl(const char *uri); static void lrdf_uris_append(lrdf_uris * base, lrdf_uris * add); static inline lrdf_hash lrdf_gen_hash(const char *str); void lrdf_free_string_hash(lrdf_string_hash * h[]); void lrdf_free_triple_hash(lrdf_triple_hash * h[]); void lrdf_free_closure_hash(lrdf_closure_hash * h[]); static inline lrdf_hash lrdf_gen_hash(const char *str) { lrdf_hash data[2]; MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, str, strlen(str)); MD5_Final((unsigned char*)data, &ctx); return data[0]; } void lrdf_init() { unsigned int i; struct timeval tv; world = raptor_new_world(); lrdf_more_triples(256); /* A UID to add to genids to make them safer */ gettimeofday(&tv, NULL); lrdf_uid = (unsigned int) getpid(); lrdf_uid ^= (unsigned int) tv.tv_usec; /* Global value for the hash of rdf:Resource, saves time */ rdf_resource_h = lrdf_gen_hash(RDF_RESOURCE); /* Make sure all the hashes are empty, just incase */ for (i = 0; i < LRDF_HASH_SIZE; i++) { resources_hash[i] = NULL; literals_hash[i] = NULL; subj_hash[i] = NULL; obj_hash[i] = NULL; pred_hash[i] = NULL; subclass_hash[i] = NULL; superclass_hash[i] = NULL; } /* Make sure we have rdf:Resource in our hash tables */ lrdf_check_hash(resources_hash, rdf_resource_h, RDF_RESOURCE); } void lrdf_more_triples(int count) { int i; lrdf_statement *new; new = (lrdf_statement *) calloc(count, sizeof(lrdf_statement)); for (i = 0; i < count - 1; i++) { new[i].next = new + i + 1; } new[count - 1].next = free_triples; free_triples = new; } void lrdf_cleanup() { raptor_free_world(world); world = NULL; lrdf_free_string_hash(resources_hash); lrdf_free_string_hash(literals_hash); lrdf_free_triple_hash(subj_hash); lrdf_free_triple_hash(obj_hash); lrdf_free_triple_hash(pred_hash); lrdf_free_closure_hash(subclass_hash); lrdf_free_closure_hash(superclass_hash); } lrdf_statement *lrdf_alloc_statement() { lrdf_statement *s; if (free_triples == NULL) { lrdf_more_triples(256); } s = free_triples; free_triples = free_triples->next; s->next = NULL; return s; } void lrdf_free_statements(lrdf_statement * s) { lrdf_statement *next; for (; s != NULL; s = next) { next = s->next; s->next = free_triples; free_triples = s; } } void lrdf_add_triple(const char *source, const char *subject, const char *predicate, const char *object, enum lrdf_objtype literal) { lrdf_statement *s = lrdf_alloc_statement(); s->shash = lrdf_gen_hash(subject); s->phash = lrdf_gen_hash(predicate); s->ohash = lrdf_gen_hash(object); s->next = triples; triples = s; s->subject = lrdf_check_hash(resources_hash, s->shash, subject); s->predicate = lrdf_check_hash(resources_hash, s->phash, predicate); if (literal == lrdf_literal) { s->object = lrdf_check_hash(literals_hash, s->ohash, object); s->object_type = lrdf_literal; } else { s->object = lrdf_check_hash(resources_hash, s->ohash, object); s->object_type = lrdf_uri; } lrdf_add_triple_hash(subj_hash, s->shash, s); lrdf_add_triple_hash(obj_hash, s->ohash, s); lrdf_add_triple_hash(pred_hash, s->phash, s); if (source) { s->source = lrdf_gen_hash(source); } else { s->source = 0; } } void lrdf_remove_uri_matches(const char *uri) { lrdf_statement p; p.subject = (char *)uri; p.predicate = NULL; p.object = NULL; lrdf_remove_matches(&p); p.subject = NULL; p.predicate = (char *)uri; lrdf_remove_matches(&p); p.predicate = NULL; p.object = (char *)uri; lrdf_remove_matches(&p); /* we could also remove the hash of the uri from the lookup tables, but we * don't. natch */ } void lrdf_remove_matches(lrdf_statement *pattern) { lrdf_statement *s; lrdf_statement *it; while ((s = lrdf_one_match(pattern))) { /* If the head triple is the one we want to remove */ if (triples == s) { triples = s->next; lrdf_remove_triple_hash(subj_hash, s->shash, s); lrdf_remove_triple_hash(pred_hash, s->phash, s); lrdf_remove_triple_hash(obj_hash, s->ohash, s); s->next = NULL; lrdf_free_statements(s); continue; } /* Else its somwehere in the tail of the list */ for (it = triples; it; it = it->next) { if (it->next == s) { it->next = it->next->next; lrdf_remove_triple_hash(subj_hash, s->shash, s); lrdf_remove_triple_hash(pred_hash, s->phash, s); lrdf_remove_triple_hash(obj_hash, s->ohash, s); s->next = NULL; lrdf_free_statements(s); break; } } } } static const char *lrdf_term_as_string(char *tmp, int tmp_len, const raptor_term *term) { switch (term->type) { case RAPTOR_TERM_TYPE_URI: return (const char *) raptor_uri_as_string(term->value.uri); case RAPTOR_TERM_TYPE_LITERAL: return (const char *) term->value.literal.string; case RAPTOR_TERM_TYPE_BLANK: snprintf(tmp, tmp_len, "_:%s.%x", term->value.blank.string, lrdf_uid); return tmp; default: return "(?)"; } } static void lrdf_store(void *user_data, raptor_statement * statement) { lrdf_statement *s = lrdf_alloc_statement(); char tmps[128], tmpp[128], tmpo[128]; const char *subj = lrdf_term_as_string(tmps, 128, statement->subject), *pred = lrdf_term_as_string(tmpp, 128, statement->predicate), *obj = lrdf_term_as_string(tmpo, 128, statement->object); s->shash = lrdf_gen_hash(subj); s->phash = lrdf_gen_hash(pred); s->ohash = lrdf_gen_hash(obj); s->next = triples; triples = s; s->subject = lrdf_check_hash(resources_hash, s->shash, subj); s->predicate = lrdf_check_hash(resources_hash, s->phash, pred); if (statement->object->type == RAPTOR_TERM_TYPE_LITERAL) { s->object = lrdf_check_hash(literals_hash, s->ohash, obj); s->object_type = lrdf_literal; } else { s->object = lrdf_check_hash(resources_hash, s->ohash, obj); s->object_type = lrdf_uri; } lrdf_add_triple_hash(subj_hash, s->shash, s); lrdf_add_triple_hash(obj_hash, s->ohash, s); lrdf_add_triple_hash(pred_hash, s->phash, s); s->source = *((lrdf_hash *) user_data); } static char *lrdf_check_hash(lrdf_string_hash ** tbl, lrdf_hash hash, const char *str) { lrdf_string_hash *tmp, *newe; char *tmps, *newstr; if ((tmps = lrdf_find_string_hash(tbl, hash))) { return tmps; } else { tmp = tbl[hash & (LRDF_HASH_SIZE - 1)]; newstr = strdup(str); newe = (lrdf_string_hash *) malloc(sizeof(lrdf_string_hash)); newe->hash = hash; newe->str = newstr; newe->next = tmp; tbl[hash & (LRDF_HASH_SIZE - 1)] = newe; return newstr; } } static char *lrdf_find_string_hash(lrdf_string_hash ** tbl, lrdf_hash hash) { lrdf_string_hash *p = tbl[hash & (LRDF_HASH_SIZE - 1)]; while (p) { if (p->hash == hash) { return p->str; } p = p->next; } return NULL; } static void lrdf_add_triple_hash(lrdf_triple_hash ** tbl, lrdf_hash hash, lrdf_statement * s) { lrdf_triple_hash *p = tbl[hash & (LRDF_HASH_SIZE - 1)]; lrdf_triple_hash *newe = malloc(sizeof(lrdf_triple_hash)); newe->hash = hash; newe->triple = s; newe->next = p; tbl[hash & (LRDF_HASH_SIZE - 1)] = newe; } static void lrdf_remove_triple_hash(lrdf_triple_hash ** tbl, lrdf_hash hash, lrdf_statement * s) { lrdf_triple_hash *p = tbl[hash & (LRDF_HASH_SIZE - 1)]; lrdf_triple_hash *it; /* The entry we want to remove is the first */ if (p && p->triple == s) { it = p->next; free(p); tbl[hash & (LRDF_HASH_SIZE - 1)] = it; return; } /* The entry is somewhere in the list */ for (it = p; it; it = it->next) { if (it->next && it->next->triple == s) { p = it->next; it->next = it->next->next; free(p); return; } } fprintf(stderr, "lrdf: tried to remove non-existant triple hash %llx\n", hash); } static void lrdf_add_closure_hash(lrdf_closure_hash ** tbl, lrdf_hash subject, lrdf_hash object) { lrdf_closure_hash *p = tbl[subject & (LRDF_HASH_SIZE - 1)]; lrdf_closure_hash *newe = malloc(sizeof(lrdf_closure_hash)); newe->subject = subject; newe->object = object; newe->next = p; tbl[subject & (LRDF_HASH_SIZE - 1)] = newe; } int lrdf_export_by_source(const char *src, const char *file) { lrdf_hash source = lrdf_gen_hash(src); lrdf_statement *s; const char *outfile = file; FILE *out; if (!strncasecmp(file, "file:", 5)) { outfile = file + 5; } if (!(out = fopen(outfile, "w"))) { fprintf(stderr, "lrdf: trying to write '%s'\n", outfile); perror(""); return -1; } for (s = triples; s; s = s->next) { if (s->source == source) { if (s->object_type == lrdf_uri) { fprintf(out, "<%s> <%s> <%s> .\n", s->subject, s->predicate, s->object); } else { fprintf(out, "<%s> <%s> \"%s\" .\n", s->subject, s->predicate, s->object); } } } fclose(out); return 0; } void lrdf_rebuild_caches() { lrdf_rebuild_taxonomic_closure(subclass_hash, superclass_hash); } void lrdf_rebuild_taxonomic_closure(lrdf_closure_hash ** fwd_tbl, lrdf_closure_hash ** rev_tbl) { lrdf_string_hash *tmp[LRDF_HASH_SIZE]; lrdf_string_hash *hit; char **uris; int *pathto; lrdf_statement q; lrdf_statement *m; lrdf_statement *it; unsigned int class_count = 0; unsigned int i, j, k; /* Ensure the tmp table is cleared out */ for (i = 0; i < LRDF_HASH_SIZE; i++) { tmp[i] = NULL; } /* Find all explicitly named classes */ q.subject = NULL; q.predicate = RDF_TYPE; q.object = RDFS_CLASS; m = lrdf_matches(&q); for (it = m; it; it = it->next) { lrdf_check_hash(tmp, it->shash, it->subject); } lrdf_free_statements(m); /* Find all implicitly name classes */ q.subject = NULL; q.predicate = RDFS_SUBCLASSOF; q.object = NULL; m = lrdf_matches(&q); for (it = m; it != NULL; it = it->next) { lrdf_check_hash(tmp, it->shash, it->subject); lrdf_check_hash(tmp, it->ohash, it->object); } /* Count unique class uris */ for (i = 0; i < LRDF_HASH_SIZE; i++) { for (hit = tmp[i]; hit; hit = hit->next) { class_count++; } } uris = malloc(class_count * sizeof(char *)); class_count = 0; for (i = 0; i < LRDF_HASH_SIZE; i++) { for (hit = tmp[i]; hit; hit = hit->next) { uris[class_count] = hit->str; hit->str = (char *) class_count++; } } pathto = calloc(class_count * class_count, sizeof(int)); for (it = m; it != NULL; it = it->next) { /* The subclass is the matrix column */ int c = (int) lrdf_find_string_hash(tmp, it->shash); /* And the superclass is the row */ int r = (int) lrdf_find_string_hash(tmp, it->ohash); pathto[c + class_count * r] = 1; } lrdf_free_statements(m); /* Warshall's algorithm * * $adjacent[X][Z] and $adjacent[Z][Y] => $adjacent[X][Y] */ for (k = 0; k < class_count; k++) { for (i = 0; i < class_count; i++) { for (j = 0; j < class_count; j++) { if (pathto[i + class_count * j] != 1) { pathto[i + class_count * j] = pathto[i + class_count * k] && pathto[k + class_count * j]; } } } } /* Clear out and free the forward and reverse tables */ for (i = 0; i < LRDF_HASH_SIZE; i++) { lrdf_closure_hash *next; lrdf_closure_hash *hit; for (hit = fwd_tbl[i]; hit; hit = next) { next = hit->next; free(hit); } fwd_tbl[i] = NULL; for (hit = rev_tbl[i]; hit; hit = next) { next = hit->next; free(hit); } rev_tbl[i] = NULL; } for (i = 0; i < class_count; i++) { lrdf_hash class_h = lrdf_gen_hash(uris[i]); lrdf_hash subclass_h; /* Every class is a subclass of itsself */ lrdf_add_closure_hash(fwd_tbl, class_h, class_h); lrdf_add_closure_hash(rev_tbl, class_h, class_h); /* ...and rdf:Resource */ lrdf_add_closure_hash(fwd_tbl, rdf_resource_h, class_h); lrdf_add_closure_hash(rev_tbl, class_h, rdf_resource_h); for (j = 0; j < class_count; j++) { subclass_h = lrdf_gen_hash(uris[j]); if (pathto[j + class_count * i]) { lrdf_add_closure_hash(fwd_tbl, class_h, subclass_h); lrdf_add_closure_hash(rev_tbl, subclass_h, class_h); } } } for (i = 0; i < LRDF_HASH_SIZE; i++) { lrdf_string_hash *next; lrdf_string_hash *hit; for (hit = tmp[i]; hit; hit = next) { next = hit->next; free(hit); } } for (i = 0; i < class_count; i++) { free(uris[i]); } free(uris); free(pathto); } static void lrdf_log_handler(void *data, raptor_log_message *message); static void lrdf_log_handler(void *data, raptor_log_message *message) { const char *severity = "error"; if (message->level == RAPTOR_LOG_LEVEL_WARN) { severity = "warning"; } fprintf(stderr, "liblrdf: %s - ", severity); raptor_locator_print(message->locator, stderr); fprintf(stderr, " - %s\n", message->text); if (message->level != RAPTOR_LOG_LEVEL_WARN) { raptor_parser_parse_abort((raptor_parser*)data); } } int lrdf_read_files(const char *uri[]) { unsigned int i; for (i = 0; uri[i] != NULL; i++) { if (lrdf_read_file_intl(uri[i]) != 0) { return 1; } } lrdf_rebuild_caches(); return 0; } int lrdf_read_file(const char *uri) { int ret; ret = lrdf_read_file_intl(uri); lrdf_rebuild_caches(); return ret; } int lrdf_read_file_intl(const char *uri) { raptor_parser *parser = NULL; raptor_uri *ruri, *furi; lrdf_hash source; //printf("lrdf: reading %s\n", uri); ruri = raptor_new_uri(world, (const unsigned char *) uri); furi = raptor_new_uri(world, (const unsigned char *) uri); source = lrdf_gen_hash(uri); lrdf_check_hash(resources_hash, source, uri); if (strstr(uri, ".rdf")) { parser = raptor_new_parser(world, "rdfxml"); } else { parser = raptor_new_parser(world, "ntriples"); } if (!parser) { fprintf(stderr, "liblrdf: failed to create parser\n"); raptor_free_uri(ruri); return 1; } raptor_world_set_log_handler(world, parser, lrdf_log_handler); raptor_parser_set_statement_handler(parser, &source, lrdf_store); raptor_world_set_generate_bnodeid_parameters(world, NULL, ++lrdf_uid); if (raptor_parser_parse_file(parser, furi, ruri)) { raptor_free_uri(furi); raptor_free_uri(ruri); raptor_free_parser(parser); return 1; } raptor_free_uri(ruri); raptor_free_parser(parser); return 0; } char *lrdf_get_default_uri(unsigned long id) { lrdf_statement *types; lrdf_statement *it; lrdf_statement type_s; lrdf_statement plugin_s; char *uri = NULL; char plugin_uri[64]; snprintf(plugin_uri, 64, "http://ladspa.org/ontology#%ld", id); type_s.subject = NULL; type_s.predicate = RDF_TYPE; type_s.object_type = lrdf_uri; type_s.object = "http://ladspa.org/ontology#Default"; types = lrdf_matches(&type_s); for (it = types; it != NULL; it = it->next) { plugin_s.subject = plugin_uri; plugin_s.predicate = LADSPA_BASE "hasSetting"; plugin_s.object = it->subject; if (lrdf_exists_match(&plugin_s)) { uri = it->subject; break; } } lrdf_free_statements(types); return uri; } lrdf_uris *lrdf_get_setting_uris(unsigned long id) { lrdf_statement *settings; lrdf_statement *it; lrdf_statement plugin_s; lrdf_uris *ret; char **uris; char plugin_uri[64]; int scnt = 0; snprintf(plugin_uri, 64, "http://ladspa.org/ontology#%ld", id); plugin_s.subject = plugin_uri; plugin_s.predicate = LADSPA_BASE "hasSetting"; plugin_s.object = NULL; settings = lrdf_matches(&plugin_s); for (it = settings; it != NULL; it = it->next) { scnt++; } ret = malloc(sizeof(lrdf_uris)); uris = (char **) calloc(scnt + 1, sizeof(char **)); ret->items = uris; for (it = settings, scnt = 0; it != NULL; it = it->next) { uris[scnt++] = it->object; } lrdf_free_statements(settings); ret->count = scnt; return ret; } lrdf_defaults *lrdf_get_setting_values(const char *uri) { lrdf_statement *portvalues; lrdf_statement *it; lrdf_statement *port; lrdf_statement portv_s; lrdf_statement port_s; lrdf_defaults *ret; lrdf_portvalue *list; int pvcount = 0; char *pos; char *port_uri; if (!uri) { return NULL; } /* Find portvalues associated with setting URI */ portv_s.subject = (char *)uri; portv_s.predicate = LADSPA_BASE "hasPortValue"; portv_s.object = NULL; portvalues = lrdf_matches(&portv_s); for (it = portvalues; it != NULL; it = it->next) { pvcount++; } if (pvcount == 0) { return NULL; } ret = (lrdf_defaults *) calloc(1, sizeof(lrdf_defaults)); list = (lrdf_portvalue *) calloc(pvcount, sizeof(lrdf_portvalue)); ret->count = pvcount; ret->items = list; for (it = portvalues, pvcount = 0; it != NULL; it = it->next, pvcount++) { /* Find setting's port */ port_s.subject = it->object; port_s.predicate = LADSPA_BASE "forPort"; port_s.object = NULL; port = lrdf_one_match(&port_s); if (port != NULL) { port_uri = port->object; pos = strrchr(port_uri, '.'); list[pvcount].pid = atoi(pos + 1); /* Find port's set value */ port_s.predicate = RDF_BASE "value"; port = lrdf_one_match(&port_s); if (port != NULL) { list[pvcount].value = atof(port->object); } /* Find port's short name */ port_s.subject = port_uri; port_s.predicate = LADSPA_BASE "hasLabel"; port_s.object = NULL; port = lrdf_one_match(&port_s); if (port != NULL && port->object != NULL) { list[pvcount].label = port->object; } } } return ret; } lrdf_defaults *lrdf_get_scale_values(unsigned long id, unsigned long port) { char port_uri[128]; lrdf_statement scale_p; lrdf_statement *scale_s; char *scale_uri; lrdf_statement p1; lrdf_uris *ulist; lrdf_defaults *ret; lrdf_portvalue *list; int i; snprintf(port_uri, 127, LADSPA_BASE "%ld.%ld", id, port); /* Find Scale associated with port */ scale_p.subject = port_uri; scale_p.predicate = LADSPA_BASE "hasScale"; scale_p.object = NULL; scale_s = lrdf_matches(&scale_p); if (!scale_s) { return NULL; } scale_uri = scale_s->object; p1.subject = scale_uri; p1.predicate = LADSPA_BASE "hasPoint"; p1.object = "?"; p1.next = NULL; ulist = lrdf_match_multi(&p1); if (!ulist) { return NULL; } ret = (lrdf_defaults *) calloc(1, sizeof(lrdf_defaults)); list = (lrdf_portvalue *) calloc(ulist->count, sizeof(lrdf_portvalue)); ret->count = ulist->count; ret->items = list; for (i=0; i < ulist->count; i++) { list[i].pid = port; scale_p.subject = ulist->items[i]; scale_p.predicate = RDF_BASE "value"; scale_p.object = NULL; scale_s = lrdf_one_match(&scale_p); list[i].value = atof(scale_s->object); scale_p.predicate = LADSPA_BASE "hasLabel"; scale_s = lrdf_one_match(&scale_p); list[i].label = scale_s->object; } return ret; } void lrdf_free_setting_values(lrdf_defaults * def) { if (def) { free(def->items); free(def); } } char *lrdf_get_setting_metadata(const char *uri, const char *element) { lrdf_statement meta_s; lrdf_statement *m; char dc_uri[128]; snprintf(dc_uri, 128, DC_BASE "%s", element); meta_s.subject = (char *)uri; meta_s.predicate = dc_uri; meta_s.object = NULL; m = lrdf_one_match(&meta_s); if (m) { return m->object; } return NULL; } /* lrdf_free_uris: * * Called on the return values from lrdf_get_subclasses etc. to free up the * memory allocated by them. */ void lrdf_free_uris(lrdf_uris * u) { if (u) { free(u->items); free(u); } } static lrdf_uris *lrdf_uris_new(int size) { lrdf_uris *nu; nu = malloc(sizeof(lrdf_uris)); nu->items = malloc(size * sizeof(char *)); nu->size = size; nu->count = 0; return nu; } static void lrdf_uris_append(lrdf_uris * base, lrdf_uris * add) { unsigned int i; if (!add) { return; } if (base->count + add->count > base->size) { base->size *= 2; base->items = realloc(base->items, base->size); } for (i = 0; i < add->count; i++) { base->items[i + base->count] = add->items[i]; } base->count += add->count; } /* lrdf_get_subclasses * * Returns a list of the direct subclasses of a given class */ lrdf_uris *lrdf_get_subclasses(const char *uri) { lrdf_statement sc_s; lrdf_statement *m; lrdf_statement *it; lrdf_uris *ret; char **uris; int count = 0; ret = malloc(sizeof(lrdf_uris)); uris = malloc(256 * sizeof(char *)); ret->items = uris; sc_s.subject = NULL; sc_s.predicate = RDFS_BASE "subClassOf"; sc_s.object = (char *)uri; m = lrdf_matches(&sc_s); if (m == NULL) { free(ret); free(uris); return NULL; } for (it = m; it != NULL; it = it->next) { uris[count++] = it->subject; } lrdf_free_statements(m); ret->count = count; return ret; } /* lrdf_get_all_subclasses: * * Returns a list of all the subclasses of uri */ lrdf_uris *lrdf_get_all_subclasses(const char *uri) { lrdf_uris *ret; lrdf_closure_hash *ch; lrdf_closure_hash *hit; lrdf_hash class; int count = 0; ret = malloc(sizeof(lrdf_uris)); class = lrdf_gen_hash(uri); ch = subclass_hash[class & (LRDF_HASH_SIZE - 1)]; for (hit = ch; hit; hit = hit->next) { if (class == hit->subject) { count++; } } if (count == 0) { return NULL; } ret = lrdf_uris_new(count); ret->count = count; count = 0; for (hit = ch; hit; hit = hit->next) { if (class == hit->subject) { ret->items[count++] = lrdf_find_string_hash(resources_hash, hit->object); } } return ret; } /* lrdf_get_all_superclasses: * * Returns a list of all the superlasses of uri */ lrdf_uris *lrdf_get_all_superclasses(const char *uri) { lrdf_uris *ret; lrdf_closure_hash *ch; lrdf_closure_hash *hit; lrdf_hash class; int count = 0; ret = malloc(sizeof(lrdf_uris)); class = lrdf_gen_hash(uri); ch = superclass_hash[class & (LRDF_HASH_SIZE - 1)]; for (hit = ch; hit; hit = hit->next) { if (class == hit->subject) { count++; } } if (count == 0) { return NULL; } ret = lrdf_uris_new(count); ret->count = count; count = 0; for (hit = ch; hit; hit = hit->next) { if (class == hit->subject) { ret->items[count++] = lrdf_find_string_hash(resources_hash, hit->object); } } return ret; } /* lrdf_get_instances * * Returns a list of the instances of a given class */ lrdf_uris *lrdf_get_instances(const char *uri) { lrdf_statement inst_s; lrdf_statement *m; lrdf_statement *it; lrdf_uris *ret; char **uris; int count = 0; ret = lrdf_uris_new(256); uris = ret->items; inst_s.subject = NULL; inst_s.predicate = RDF_BASE "type"; inst_s.object = (char *)uri; m = lrdf_matches(&inst_s); if (m == NULL) { free(ret); free(uris); return NULL; } for (it = m; it != NULL; it = it->next) { uris[count++] = it->subject; } lrdf_free_statements(m); ret->count = count; return ret; } /* lrdf_get_all_instances: * * Returns the URIs of all the instances of 'uri' and all the instances of all * its subclasses. */ lrdf_uris *lrdf_get_all_instances(const char *uri) { unsigned int i; lrdf_uris *u, *v; lrdf_uris *ret = NULL; u = lrdf_get_all_subclasses(uri); if (u->count > 0) { ret = lrdf_uris_new(256); for (i = 0; i < u->count; i++) { v = lrdf_get_instances(u->items[i]); lrdf_uris_append(ret, v); lrdf_free_uris(v); } } return ret; } char *lrdf_get_label(const char *uri) { lrdf_statement lab_s; lrdf_statement *label; lab_s.subject = (char *)uri; lab_s.predicate = LADSPA_BASE "hasLabel"; lab_s.object = NULL; label = lrdf_one_match(&lab_s); if (label == NULL) { return NULL; } return label->object; } /* XXX nasty hack */ unsigned long lrdf_get_uid(const char *uri) { char *pos; pos = strrchr(uri, '#'); if (pos != NULL) { return atol(pos + 1); } return 0; } /* lrdf_matches: * * Returns a NULL terminated vector of lrdf_statements that match the * sepecifed pattern, where a NULL in any position matches any uri. */ lrdf_statement *lrdf_matches(lrdf_statement * pattern) { lrdf_triple_hash *th; lrdf_triple_hash *start; lrdf_statement *s; lrdf_statement *ret = NULL; #ifdef DEBUG printf("Looking for (%s, %s, %s)\n", pattern->subject, pattern->predicate, pattern->object); #endif if (pattern->subject) { pattern->shash = lrdf_gen_hash(pattern->subject); } if (pattern->predicate) { pattern->phash = lrdf_gen_hash(pattern->predicate); } if (pattern->object) { pattern->ohash = lrdf_gen_hash(pattern->object); } if (pattern->subject) { start = subj_hash[pattern->shash & (LRDF_HASH_SIZE - 1)]; } else if (pattern->predicate) { start = pred_hash[pattern->phash & (LRDF_HASH_SIZE - 1)]; } else if (pattern->object) { start = obj_hash[pattern->ohash & (LRDF_HASH_SIZE - 1)]; } else { /* None of the triple parts were specified, can't do anything * useful with that, except return everything and that is * stupid. If you want everything look thorugh the list */ fprintf(stderr, "lrdf: null triple specified for search\n"); return NULL; } for (th = start; th; th = th->next) { s = th->triple; if ((pattern->subject == NULL || pattern->shash == s->shash) && (pattern->predicate == NULL || pattern->phash == s->phash) && (pattern->object == NULL || pattern->ohash == s->ohash)) { lrdf_statement *new = lrdf_alloc_statement(); #ifdef DEBUG printf("Found (%s, %s, %s)\n", pattern->subject, pattern->predicate, pattern->object); printf(" = (%s, %s, %s)\n", s->subject, s->predicate, s->object); printf(" (%llx, %llx, %llx)\n", pattern->shash, pattern->phash, pattern->ohash); printf(" = (%llx, %llx, %llx)\n", s->shash, s->phash, s->ohash); #endif lrdf_copy_statement(s, new); new->next = ret; ret = new; } } return ret; } /* lrdf_one_match: * * returns a pointer to the first matching triple if one exists, or NULL * otherwise */ lrdf_statement *lrdf_one_match(lrdf_statement *pattern) { lrdf_triple_hash *th; lrdf_triple_hash *start; lrdf_statement *s; if (pattern->subject) { pattern->shash = lrdf_gen_hash(pattern->subject); } if (pattern->predicate) { pattern->phash = lrdf_gen_hash(pattern->predicate); } if (pattern->object) { pattern->ohash = lrdf_gen_hash(pattern->object); } if (pattern->subject) { start = subj_hash[pattern->shash & (LRDF_HASH_SIZE - 1)]; } else if (pattern->predicate) { start = pred_hash[pattern->phash & (LRDF_HASH_SIZE - 1)]; } else if (pattern->object) { start = obj_hash[pattern->ohash & (LRDF_HASH_SIZE - 1)]; } else { /* None of the triple parts were specified, can't do anything * useful with that, except return everything and that is * stupid. If you want everything look thorugh the list */ fprintf(stderr, "lrdf: null triple specified for search\n"); return NULL; } for (th = start; th; th = th->next) { s = th->triple; if ((pattern->subject == NULL || pattern->shash == s->shash) && (pattern->predicate == NULL || pattern->phash == s->phash) && (pattern->object == NULL || pattern->ohash == s->ohash)) { return s; } } return NULL; } /* lrdf_exists_match: * * returns true if a triple mathcing the pattern exists, false otherwise */ int lrdf_exists_match(lrdf_statement *pattern) { return (lrdf_one_match(pattern) != NULL); } /* lrdf_copy_statement: * * copies the subject, predicate and object of a statement to another * statement. does not affect the linked list pointer. */ void lrdf_copy_statement(lrdf_statement * from, lrdf_statement * to) { to->subject = from->subject; to->predicate = from->predicate; to->object = from->object; to->object_type = from->object_type; to->shash = from->shash; to->phash = from->phash; to->ohash = from->ohash; } void lrdf_free_string_hash(lrdf_string_hash * h[]) { unsigned int i; for (i = 0; i < LRDF_HASH_SIZE; i++) { lrdf_string_hash *next; lrdf_string_hash *hit; for (hit = h[i]; hit; hit = next) { next = hit->next; free(hit->str); free(hit); } } } void lrdf_free_triple_hash(lrdf_triple_hash * h[]) { unsigned int i; for (i = 0; i < LRDF_HASH_SIZE; i++) { lrdf_triple_hash *next; lrdf_triple_hash *hit; for (hit = h[i]; hit; hit = next) { next = hit->next; free(hit); } } } void lrdf_free_closure_hash(lrdf_closure_hash * h[]) { unsigned int i; for (i = 0; i < LRDF_HASH_SIZE; i++) { lrdf_closure_hash *next; lrdf_closure_hash *hit; for (hit = h[i]; hit; hit = next) { next = hit->next; free(hit); } } } lrdf_statement *lrdf_all_statements() { return triples; } char* lrdf_add_preset(const char *source, const char *label, unsigned long id, lrdf_defaults *vals) { char plugin_uri[64]; char* setting_uri; static int sid = 0; int i; setting_uri = malloc(64 * sizeof(char)); snprintf(plugin_uri, 64, "http://ladspa.org/ontology#%ld", id); snprintf(setting_uri, 64, "http://plugin.org.uk/genid#%d.%d", lrdf_uid, sid++); lrdf_add_triple(source, plugin_uri, LADSPA_BASE "hasSetting", setting_uri, lrdf_uri); lrdf_add_triple(source, setting_uri, RDF_BASE "type", LADSPA_BASE "Preset", lrdf_uri); lrdf_add_triple(source, setting_uri, LADSPA_BASE "hasLabel", label, lrdf_literal); for (i=0; icount; i++) { char value_uri[64]; char port_uri[64]; char value_lit[64]; snprintf(value_uri, 64, "http://plugin.org.uk/genid#%d.%d", lrdf_uid, sid++); snprintf(port_uri, 64, "%s.%ld", plugin_uri, vals->items[i].pid); snprintf(value_lit, 64, "%f", vals->items[i].value); lrdf_add_triple(source, setting_uri, LADSPA_BASE "hasPortValue", value_uri, lrdf_uri); lrdf_add_triple(source, value_uri, RDF_BASE "value", value_lit, lrdf_literal); lrdf_add_triple(source, value_uri, LADSPA_BASE "forPort", port_uri, lrdf_uri); } return setting_uri; } /* vi:set ts=8 sts=4 sw=4: */ LRDF-0.6.1/src/lrdf_multi.c000066400000000000000000000053331303474052200153450ustar00rootroot00000000000000#include #include #include #include #include #include "lrdf.h" typedef struct _lrdf_uri_list { char *uri; struct _lrdf_uri_list *next; } lrdf_uri_list; lrdf_uris *lrdf_match_multi(lrdf_statement *patterns) { lrdf_uris *ret = NULL; lrdf_uri_list *uris = NULL, *allocd = NULL; lrdf_uri_list *uit, *prev; lrdf_statement *it; lrdf_statement *matches; lrdf_statement *mit; lrdf_statement match; int count = 0, i, j, rept; for (it = patterns; it; it = it->next) { if (uris) { /* We allready have a candidate list for the return list, so * iterate over those and check to see if they are possible given * the current pattern */ for (prev = NULL, uit = uris; uit; prev = uit, uit = uit->next) { match.subject = *(it->subject) == '?' ? uit->uri : it->subject; match.predicate = *(it->predicate) == '?' ? uit->uri : it->predicate; match.object = *(it->object) == '?' ? uit->uri : it->object; /* If this pattern didn't match then remove the URI from the * list of candidates */ if (!lrdf_exists_match(&match)) { count--; if (prev) { prev->next = uit->next; } else { uris = uit->next; } } } } else { /* We dont currently have a candidate list for the returns, so * build one from the matches for this pattern */ match.subject = *(it->subject) == '?' ? NULL : it->subject; match.predicate = *(it->predicate) == '?' ? NULL : it->predicate; match.object = *(it->object) == '?' ? NULL : it->object; matches = lrdf_matches(&match); if (matches == NULL) { return NULL; } for (count = 0, mit = matches; mit; count++, mit=mit->next) { } uris = malloc(count * sizeof(lrdf_uri_list)); allocd = uris; for (i=0, mit=matches; inext) { uris[i].next = &uris[i+1]; if (*(it->subject) == '?') { uris[i].uri = mit->subject; } else if (*(it->predicate) == '?') { uris[i].uri = mit->predicate; } else if (*(it->object) == '?') { uris[i].uri = mit->object; } else { free(allocd); allocd = NULL; uris = NULL; break; } } if (uris) { uris[count - 1].next = NULL; } } } ret = malloc(sizeof(lrdf_uris)); ret->size = count; ret->items = malloc(count * sizeof(char *)); for (uit = uris, i=0; uit; uit=uit->next) { rept = 0; for (j=0; juri, ret->items[j])) { rept = 1; break; } } /* If the URI has allready been added to the list. */ if (rept) { continue; } else { ret->items[i++] = uit->uri; } } ret->count = i; free(allocd); return ret; } /* vi:set ts=8 sts=4 sw=4: */ LRDF-0.6.1/src/md5.c000066400000000000000000000206131303474052200136670ustar00rootroot00000000000000/* * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. * MD5 Message-Digest Algorithm (RFC 1321). * * Homepage: * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 * * Author: * Alexander Peslyak, better known as Solar Designer * * This software was written by Alexander Peslyak in 2001. No copyright is * claimed, and the software is hereby placed in the public domain. * In case this attempt to disclaim copyright and place the software in the * public domain is deemed null and void, then the software is * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the * general public under the following terms: * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. * * (This is a heavily cut-down "BSD license".) * * This differs from Colin Plumb's older public domain implementation in that * no exactly 32-bit integer data type is required (any 32-bit or wider * unsigned integer data type will do), there's no compile-time endianness * configuration, and the function prototypes match OpenSSL's. No code from * Colin Plumb's implementation has been reused; this comment merely compares * the properties of the two independent implementations. * * The primary goals of this implementation are portability and ease of use. * It is meant to be fast, but not as fast as possible. Some known * optimizations are not included to reduce source code size and avoid * compile-time configuration. */ #ifndef HAVE_OPENSSL #include #include "md5.h" /* * The basic MD5 functions. * * F and G are optimized compared to their RFC 1321 definitions for * architectures that lack an AND-NOT instruction, just like in Colin Plumb's * implementation. */ #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) #define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) #define H(x, y, z) (((x) ^ (y)) ^ (z)) #define H2(x, y, z) ((x) ^ ((y) ^ (z))) #define I(x, y, z) ((y) ^ ((x) | ~(z))) /* * The MD5 transformation for all four rounds. */ #define STEP(f, a, b, c, d, x, t, s) \ (a) += f((b), (c), (d)) + (x) + (t); \ (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ (a) += (b); /* * SET reads 4 input bytes in little-endian byte order and stores them * in a properly aligned word in host byte order. * * The check for little-endian architectures that tolerate unaligned * memory accesses is just an optimization. Nothing will break if it * doesn't work. */ #if defined(__i386__) || defined(__x86_64__) || defined(__vax__) #define SET(n) \ (*(MD5_u32plus *)&ptr[(n) * 4]) #define GET(n) \ SET(n) #else #define SET(n) \ (ctx->block[(n)] = \ (MD5_u32plus)ptr[(n) * 4] | \ ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ ((MD5_u32plus)ptr[(n) * 4 + 3] << 24)) #define GET(n) \ (ctx->block[(n)]) #endif /* * This processes one or more 64-byte data blocks, but does NOT update * the bit counters. There are no alignment requirements. */ static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) { const unsigned char *ptr; MD5_u32plus a, b, c, d; MD5_u32plus saved_a, saved_b, saved_c, saved_d; ptr = (const unsigned char *)data; a = ctx->a; b = ctx->b; c = ctx->c; d = ctx->d; do { saved_a = a; saved_b = b; saved_c = c; saved_d = d; /* Round 1 */ STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7) STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12) STEP(F, c, d, a, b, SET(2), 0x242070db, 17) STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22) STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7) STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12) STEP(F, c, d, a, b, SET(6), 0xa8304613, 17) STEP(F, b, c, d, a, SET(7), 0xfd469501, 22) STEP(F, a, b, c, d, SET(8), 0x698098d8, 7) STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12) STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17) STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22) STEP(F, a, b, c, d, SET(12), 0x6b901122, 7) STEP(F, d, a, b, c, SET(13), 0xfd987193, 12) STEP(F, c, d, a, b, SET(14), 0xa679438e, 17) STEP(F, b, c, d, a, SET(15), 0x49b40821, 22) /* Round 2 */ STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5) STEP(G, d, a, b, c, GET(6), 0xc040b340, 9) STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14) STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20) STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5) STEP(G, d, a, b, c, GET(10), 0x02441453, 9) STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14) STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20) STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5) STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9) STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14) STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20) STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5) STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9) STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14) STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20) /* Round 3 */ STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11) STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23) STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11) STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23) STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11) STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23) STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11) STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23) /* Round 4 */ STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) STEP(I, d, a, b, c, GET(7), 0x432aff97, 10) STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15) STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21) STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6) STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10) STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15) STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21) STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6) STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10) STEP(I, c, d, a, b, GET(6), 0xa3014314, 15) STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21) STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6) STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10) STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15) STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21) a += saved_a; b += saved_b; c += saved_c; d += saved_d; ptr += 64; } while (size -= 64); ctx->a = a; ctx->b = b; ctx->c = c; ctx->d = d; return ptr; } void MD5_Init(MD5_CTX *ctx) { ctx->a = 0x67452301; ctx->b = 0xefcdab89; ctx->c = 0x98badcfe; ctx->d = 0x10325476; ctx->lo = 0; ctx->hi = 0; } void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) { MD5_u32plus saved_lo; unsigned long used, available; saved_lo = ctx->lo; if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) ctx->hi++; ctx->hi += size >> 29; used = saved_lo & 0x3f; if (used) { available = 64 - used; if (size < available) { memcpy(&ctx->buffer[used], data, size); return; } memcpy(&ctx->buffer[used], data, available); data = (const unsigned char *)data + available; size -= available; body(ctx, ctx->buffer, 64); } if (size >= 64) { data = body(ctx, data, size & ~(unsigned long)0x3f); size &= 0x3f; } memcpy(ctx->buffer, data, size); } void MD5_Final(unsigned char *result, MD5_CTX *ctx) { unsigned long used, available; used = ctx->lo & 0x3f; ctx->buffer[used++] = 0x80; available = 64 - used; if (available < 8) { memset(&ctx->buffer[used], 0, available); body(ctx, ctx->buffer, 64); used = 0; available = 64; } memset(&ctx->buffer[used], 0, available - 8); ctx->lo <<= 3; ctx->buffer[56] = ctx->lo; ctx->buffer[57] = ctx->lo >> 8; ctx->buffer[58] = ctx->lo >> 16; ctx->buffer[59] = ctx->lo >> 24; ctx->buffer[60] = ctx->hi; ctx->buffer[61] = ctx->hi >> 8; ctx->buffer[62] = ctx->hi >> 16; ctx->buffer[63] = ctx->hi >> 24; body(ctx, ctx->buffer, 64); result[0] = ctx->a; result[1] = ctx->a >> 8; result[2] = ctx->a >> 16; result[3] = ctx->a >> 24; result[4] = ctx->b; result[5] = ctx->b >> 8; result[6] = ctx->b >> 16; result[7] = ctx->b >> 24; result[8] = ctx->c; result[9] = ctx->c >> 8; result[10] = ctx->c >> 16; result[11] = ctx->c >> 24; result[12] = ctx->d; result[13] = ctx->d >> 8; result[14] = ctx->d >> 16; result[15] = ctx->d >> 24; memset(ctx, 0, sizeof(*ctx)); } #endif LRDF-0.6.1/src/md5.h000066400000000000000000000026021303474052200136720ustar00rootroot00000000000000/* * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. * MD5 Message-Digest Algorithm (RFC 1321). * * Homepage: * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 * * Author: * Alexander Peslyak, better known as Solar Designer * * This software was written by Alexander Peslyak in 2001. No copyright is * claimed, and the software is hereby placed in the public domain. * In case this attempt to disclaim copyright and place the software in the * public domain is deemed null and void, then the software is * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the * general public under the following terms: * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. * * See md5.c for more information. */ #ifdef HAVE_OPENSSL #include #elif !defined(_MD5_H) #define _MD5_H /* Any 32-bit or wider unsigned integer data type will do */ typedef unsigned int MD5_u32plus; typedef struct { MD5_u32plus lo, hi; MD5_u32plus a, b, c, d; unsigned char buffer[64]; MD5_u32plus block[16]; } MD5_CTX; extern void MD5_Init(MD5_CTX *ctx); extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); #endif