pax_global_header00006660000000000000000000000064140013346350014511gustar00rootroot0000000000000052 comment=e5a008a9672f28d281ff9bc3e39838b1b90186f1 camlbz2-0.7.0/000077500000000000000000000000001400133463500130475ustar00rootroot00000000000000camlbz2-0.7.0/.gitignore000066400000000000000000000001301400133463500150310ustar00rootroot00000000000000.depend .pc Makefile aclocal.m4 autom4te.cache/ config.log config.status configure doc/ camlbz2-0.7.0/BUGS000066400000000000000000000002211400133463500135250ustar00rootroot00000000000000 BUGS ==== Please look for them and report them into the CamlBZ2 bug tracker, available at: http://forge.ocamlcore.org/tracker/?group_id=63 camlbz2-0.7.0/COPYING000066400000000000000000000654631400133463500141200ustar00rootroot00000000000000 As a special exception to the GNU Library General Public License (reported below), you may link, statically or dynamically, a "work that uses the Library" with a publicly distributed version of the Library to produce an executable file containing portions of the Library, and distribute that executable file under terms of your choice, without any of the additional requirements listed in clause 6 of the GNU Library General Public License. By "a publicly distributed version of the Library", we mean either the unmodified Library as distributed by INRIA, or a modified version of the Library that is distributed under the conditions defined in clause 3 of the GNU Library General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU Library General Public License. ---------------------------------------------------------------------- GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! camlbz2-0.7.0/ChangeLog000066400000000000000000000014031400133463500146170ustar00rootroot000000000000002021-01-18 Johannes Schauer Marin Rodrigues * Version 0.7.0 released * No changes to the last version but bumping the version number to indicate a breaking change compared to 0.6.0 2021-01-11 Johannes Schauer Marin Rodrigues * Version 0.6.1 released * Changes with respect to 0.6.0: - add examples/ dir, with a "bunzip2" replacement example - change interface to use bytes instead of string because the latter is immutable 2008-11-08 Stefano Zacchiroli * Version 0.6.0 released * Changes with respect to 0.5.99: - update copyright headers - get rid of bashisms in Makefile - add docs pointing to forge entry points - fix Findlib names: now consistently "bz2" camlbz2-0.7.0/INSTALL000066400000000000000000000005431400133463500141020ustar00rootroot00000000000000 INSTALLING ========== * `./configure` * `make all` builds the bytecode and native-code libraries (where available), and the stub code * `make install` (or `make install DESTDIR=/shome/where/else`) Options: * for configure : CPPFLAGS="-I " LIBS="-L " Requirements: - OCaml >= 3.10 - Findlib camlbz2-0.7.0/LICENSE000066400000000000000000000016451400133463500140620ustar00rootroot00000000000000CamlBZ2 - OCaml bindings for libbz2 (AKA, bzip2) Copyright © 2000-2005 Olivier Andrieu © 2008 Stefano Zacchiroli CamlBZ2 is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (with the special exception on linking described in file COPYING) 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA camlbz2-0.7.0/META000066400000000000000000000001311400133463500135130ustar00rootroot00000000000000version = "x.y.z" archive(byte) = "bz2.cma" archive(native) = "bz2.cmxa" camlbz2-0.7.0/Makefile.in000066400000000000000000000062031400133463500151150ustar00rootroot00000000000000OCAMLC := @OCAMLC@ OCAMLOPT := @OCAMLOPT@ OCAMLDEP := @OCAMLDEP@ OCAMLLIB := @OCAMLLIB@ OCAMLFIND := @OCAMLFIND@ OCAMLDOC := @OCAMLDOC@ OCAMLMKLIB := @OCAMLMKLIB@ INSTALL := @INSTALL@ INSTALL_DATA := @INSTALL_DATA@ INSTALLDIR := @INSTALLDIR@ CLIBS := $(filter -l%,@LIBS@) CLIBSDIR := $(filter -L%,@LIBS@) BZ_PREFIX := @BZ_PREFIX@ CPPFLAGS = $(if $(BZ_PREFIX),-D BZ_PREFIX) @CPPFLAGS@ NAME := camlbz2 SHORTNAME := bz2 VERSION := 0.6.0 INSTALLFILES := \ $(SHORTNAME).cmi $(SHORTNAME).mli $(SHORTNAME).cma \ dll$(NAME).so lib$(NAME).a DISTSRC := $(SHORTNAME).ml $(SHORTNAME).mli \ c_bz.c io.h \ aclocal.m4 install-sh \ Makefile.in configure configure.in \ META doc \ BUGS COPYING INSTALL LICENSE README ROADMAP ChangeLog DESTDIR = ifndef OCAMLOPT all : stub lib else INSTALLFILES += $(SHORTNAME).cmx $(SHORTNAME).cmxa $(SHORTNAME).a all : stub lib libopt endif ifdef OCAMLFIND install : findlib-install ifeq ($(DESTDIR),) DESTDIR_FLAGS = else DESTDIR_FLAGS = -destdir $(DESTDIR) findlib-install : install-mkdir install-mkdir : test -d $(DESTDIR) || mkdir -p $(DESTDIR) endif else install : normal-install endif stub : dll$(NAME).so lib$(NAME).a lib : $(SHORTNAME).cma libopt : $(SHORTNAME).cmxa lib$(NAME).a dll$(NAME).so : c_bz.o $(OCAMLMKLIB) -oc $(NAME) $^ $(CLIBS) $(CLIBSDIR) $(SHORTNAME).cma : $(SHORTNAME).cmo $(OCAMLMKLIB) -oc $(NAME) -o $(SHORTNAME) $^ $(CLIBS) $(CLIBSDIR) $(SHORTNAME).cmxa : bz2.cmx $(OCAMLMKLIB) -oc $(NAME) -o $(SHORTNAME) $^ $(CLIBS) $(CLIBSDIR) test : INCDIR= $(if $(OCAMLFIND),$(shell ocamlfind query $(SHORTNAME)),$(INSTALLDIR)) test : test.ml $(OCAMLC) -o $@ -dllpath $(INCDIR) -I $(INCDIR) $(SHORTNAME).cma $^ test.opt : INCDIR= $(if $(OCAMLFIND),$(shell ocamlfind query $(SHORTNAME)),$(INSTALLDIR)) test.opt : test.ml $(OCAMLOPT) -o $@ -I $(INCDIR) $(SHORTNAME).cmxa $^ normal-install: all mkdir -p $(INSTALLDIR) $(INSTALL_DATA) $(INSTALLFILES) $(INSTALLDIR) @echo "You need to put a link to the shared stub in $$($(OCAMLC) -where)/stublibs" findlib-install: all -$(OCAMLFIND) remove $(DESTDIR_FLAGS) $(SHORTNAME) $(OCAMLFIND) install $(DESTDIR_FLAGS) \ -patch-version $(VERSION) -ldconf ignore \ $(SHORTNAME) META $(INSTALLFILES) clean: rm -f *.cm* *.a *.so *.o *.opt test test.opt .depend distclean: clean rm -f config.log config.status Makefile maintainer-clean: distclean rm -rf aclocal.m4 doc/ rm -f aclocal.m4 configure ifdef OCAMLDOC doc : doc/index.html doc/index.html : bz2.mli mkdir -p doc/ $(OCAMLDOC) -html -d doc $^ else doc : ; $(error "you need ocamldoc to generate the documentation") endif dist: doc $(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION).tar.gz: dummy cd .. && mv $(NAME) $(NAME)-$(VERSION) && \ tar zcvf $@ $(addprefix $(NAME)-$(VERSION)/, $(DISTSRC)) && \ mv $(NAME)-$(VERSION) $(NAME) .PHONY: all lib libopt clean doc dist normal-install findlib-install dummy stub %.cmo : %.ml $(OCAMLC) -c $< %.cmx : %.ml $(OCAMLOPT) -c $< %.cmi : %.mli $(OCAMLC) -c $< %.o : %.c $(OCAMLC) -ccopt "$(CPPFLAGS) $(CFLAGS)" -c $< .depend : $(wildcard *.ml *.mli) -@$(OCAMLDEP) $^ > .depend -include .depend configure : configure.in aclocal.m4 autoconf aclocal.m4 : ocaml.m4 aclocal -I . camlbz2-0.7.0/README000066400000000000000000000017501400133463500137320ustar00rootroot00000000000000 CamlBZ2 ======= This is CamlBZ2, OCaml bindings for the libbz2 (AKA, bzip2) (de)compression library. DOWNLOAD -------- You can download the latest version of CamlBZ2 from the OCaml forge (http://forge.ocamlcore.org), where CamlBZ2 is hosted. Have a look at the CamlBZ2 homepage for more info: http://camlbz2.forge.ocamlcore.org or jump directly to the download section: http://forge.ocamlcore.org/frs/?group_id=63 LICENSING --------- GNU LGPL, version 2.1 or above, with the usual OCaml linking exception (see COPYING). The file io.h comes from the OCaml compiler source tree, hence it is GPL, with the same linking exception as above. AUTHORS ------- This library descends from "gz", a library which used to ship both gzip and bzip2 bindings. The authors of "gz" where: - Olivier Andrieu - Nicolas George CamlBZ2 is now copyright and maintained by: - Stefano Zacchiroli - Olivier Andrieu camlbz2-0.7.0/ROADMAP000066400000000000000000000010411400133463500140510ustar00rootroot00000000000000 ROADMAP ======= * 0.7.0 - bindings for the "low-level" bzip2 (de)compression API http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html#low-level That API would enable to (de)compress in memory, without forcibly having to (de)compress all the data at once (as currently supported by Bz2.{un,}compress). Low-level API bindings are a must for integration into Batteries (http://batteries.forge.ocamlcore.org). * 0.6.0 - feature complete wrt the latest "GZ" release (of course excluding zlib bindings, which have been removed) camlbz2-0.7.0/bz2.ml000066400000000000000000000031611400133463500140770ustar00rootroot00000000000000(* CamlBZ2 - OCaml bindings for libbz2 (AKA, bzip2) * * Copyright © 2000-2005 Olivier Andrieu * © 2008 Stefano Zacchiroli * * CamlBZ2 is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License (with the * special exception on linking described in file COPYING) as published * by the Free Software Foundation; either version 2.1 of the License, * or (at your option) any later version. *) type in_channel type out_channel exception IO_error of string exception Data_error exception Unexpected_EOF let _ = begin Callback.register_exception "mlbz_io_exn" (IO_error "") ; Callback.register_exception "mlbz_data_exn" Data_error ; Callback.register_exception "mlbz_eof_exn" Unexpected_EOF end external library_version : unit -> string = "mlbz_version" let version = library_version () external open_in : ?small:bool -> ?unused:bytes -> Pervasives.in_channel -> in_channel = "mlbz_readopen" external read : in_channel -> bytes -> int -> int -> int = "mlbz_read" external read_get_unused : in_channel -> bytes = "mlbz_readgetunused" external close_in : in_channel -> unit = "mlbz_readclose" external open_out : ?block:int -> Pervasives.out_channel -> out_channel = "mlbz_writeopen" external write : out_channel -> bytes -> int -> int -> unit = "mlbz_write" external close_out : out_channel -> unit = "mlbz_writeclose" external compress : ?block:int -> bytes -> int -> int -> bytes = "mlbz_compress" external uncompress : ?small:bool -> bytes -> int -> int -> bytes = "mlbz_uncompress" camlbz2-0.7.0/bz2.mli000066400000000000000000000072501400133463500142530ustar00rootroot00000000000000(* CamlBZ2 - OCaml bindings for libbz2 (AKA, bzip2) * * Copyright © 2000-2005 Olivier Andrieu * © 2008 Stefano Zacchiroli * * CamlBZ2 is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License (with the * special exception on linking described in file COPYING) as published * by the Free Software Foundation; either version 2.1 of the License, * or (at your option) any later version. *) (** {1 Bzip2 interface} *) (** The module [Bz] provides a basic interface to the [bzip2] compression library. *) (** {2 Datatypes & exceptions} *) type in_channel type out_channel exception IO_error of string (** Exception [IO_error] is raised when there is an error reading or writing on a compressed channel ; the string argument is the message reported by the OS. *) exception Data_error (** Exception [Data_error] is raised when a data integrity error is detected during decompression. *) exception Unexpected_EOF (** Exception [Unexpected_EOF] is raised when an [in_channel] finishes before the logical end of stream is detected. *) (** When any of these exception is raised, the channel is automatically closed (but you still have to close the Pervasives channel). *) val version : string (** Version of the underlying [bzip2] library. *) (** {2 File I/O} *) (** {3 File input} *) (** [open_in ic] opens a compressed stream reading from the [Pervasives] input channel [ic]. @param small when [true] requests usage of a different method for decompressing that is slower but uses less memory. Defaults: [false] *) val open_in : ?small:bool -> ?unused:bytes -> Pervasives.in_channel -> in_channel (** [read buf pos len] reads up to [len] characters and store them in the string buffer [buf], starting at position [pos]. @return number of bytes actually read, (a value strictly less than [len] means end of stream). @raise End_of_file if end of stream was already reached. *) val read : in_channel -> bytes -> int -> int -> int (** If there's some data after the compressed stream that you want to read from the same [Pervasives] [in_channel], use [read_get_unused]. *) val read_get_unused : in_channel -> bytes val close_in : in_channel -> unit (** {3 File output} *) (** [open_out oc] creates an [out_channel] writing to the [Pervasives] output channel [oc]. Once the write operations are finished and the compressed channel is closed, it is possible to continue writing on the [Pervasives] channel. However, reading back requires special care (cf. above). @param block block size to use for compresion. It is a value between 1 and 9 inclusive. 9 is the default and provides best compression but takes most memory. *) val open_out : ?block:int -> Pervasives.out_channel -> out_channel (** [write oc buf pos len] writes [len] characters, coming from [buf] and starting at position [pos], to [oc] *) val write : out_channel -> bytes -> int -> int -> unit val close_out : out_channel -> unit (** {2 In-memory compression} *) (** These functions compress to/decompress from string buffers. *) (** [compress buf pos len] compress a data chunk coming from [buf], [len] character long, and starting at [pos]. @return compressed data chunk as string *) val compress : ?block:int -> bytes -> int -> int -> bytes (** [uncompress buf pos len] uncompress a data chunk comfing from [buf], [len] character long, and starting at [pos]. @param small see [Bz2.open_in] above @return uncompressed data chunk as string *) val uncompress : ?small:bool -> bytes -> int -> int -> bytes camlbz2-0.7.0/c_bz.c000066400000000000000000000201701400133463500141300ustar00rootroot00000000000000/* CamlBZ2 - OCaml bindings for libbz2 (AKA, bzip2) * * Copyright © 2000-2005 Olivier Andrieu * © 2008 Stefano Zacchiroli * * CamlBZ2 is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License (with the * special exception on linking described in file COPYING) as published * by the Free Software Foundation; either version 2.1 of the License, * or (at your option) any later version. */ #include #include #include #include #include #include #include #include #include #include #include "io.h" #ifdef BZ_PREFIX #define BZ_P(a) BZ2_ ## a #else #define BZ_P(a) a #endif value mlbz_readclose(value chan) ; value mlbz_writeclose(value chan) ; /* ERROR REPORTING */ /* checks bzerror and raises the corresponding Caml exception */ /* then closes the channel */ static void mlbz_error(int bzerror, char *msg, value chan, int read_str) { if(bzerror<0){ if(read_str) mlbz_readclose(chan) ; else mlbz_writeclose(chan) ; switch(bzerror){ case BZ_PARAM_ERROR : invalid_argument(msg) ; break ; case BZ_MEM_ERROR : raise_out_of_memory() ; break ; case BZ_DATA_ERROR : case BZ_DATA_ERROR_MAGIC : raise_constant(*caml_named_value("mlbz_data_exn")) ; break ; case BZ_IO_ERROR : raise_with_string(*caml_named_value("mlbz_io_exn"), strerror(errno)) ; break ; case BZ_UNEXPECTED_EOF : raise_constant(*caml_named_value("mlbz_eof_exn")) ; break ; default : failwith(msg) ; } } } /* MEMORY HANDLING */ /* The Caml abstract_value contains 3 values : */ /* - BZFILE* pointer (compressed stream) */ /* - FILE* pointer (underlying C stream) */ /* - bool value (flag indicating an end of stream */ static value Val_twoptr(FILE * ptr1, BZFILE * ptr2) { value result; result= alloc_small(3, Abstract_tag); Field(result, 0) = (value) ptr1 ; Field(result, 1) = (value) ptr2 ; Field(result, 2) = Val_false ; /* flag for the eof state */ return result; } #define Cfile_val(v) ((FILE*)(Field((v), 0))) #define Bzfile_val(v) ((BZFILE*)(Field((v), 1))) #define Bz_eof(v) (Bool_val(Field((v), 2))) static void set_eof_flag(value chan) { Field(chan, 2) = Val_true ; } /* converts a Caml channel to a C FILE* stream */ static FILE * stream_of_channel(value chan, const char * mode) { int des ; FILE * res ; struct channel *c_chan = Channel(chan) ; if(c_chan==NULL) return NULL; des = dup(c_chan->fd) ; res = fdopen(des, mode) ; return res ; } value mlbz_version(value unit) { return copy_string(BZ_P(bzlibVersion())) ; } /* INPUT FUNCTIONS */ value mlbz_readopen(value small, value unused, value chan) { int bzerror ; int c_small = 0 ; char *c_unused = NULL ; int c_nunused = 0; FILE * c_chan ; BZFILE * bz_chan ; if(Is_block(small)) c_small = Bool_val(Field(small, 0)) ; if(Is_block(unused)){ c_unused = String_val(Field(unused, 0)) ; c_nunused = string_length(Field(unused, 0)); } c_chan = stream_of_channel(chan, "rb") ; bz_chan = BZ_P(bzReadOpen)(&bzerror, c_chan, c_small, 0, c_unused, c_nunused) ; mlbz_error(bzerror, "Bz.open_in", chan, 1) ; return Val_twoptr(c_chan, bz_chan) ; } value mlbz_read(value chan, value buf, value pos, value len) { int res ; int bzerror ; char *c_buf ; int c_pos = Int_val(pos); int c_len = Int_val(len); if(Bz_eof(chan)) raise_end_of_file() ; if((c_len + c_pos > string_length(buf)) || (c_len < 0) || (c_pos < 0)) invalid_argument("Bz.read") ; c_buf = String_val(buf) + c_pos ; res = BZ_P(bzRead)(&bzerror, Bzfile_val(chan), c_buf, c_len) ; if(bzerror == BZ_STREAM_END) set_eof_flag(chan) ; mlbz_error(bzerror, "Bz.read", chan, 1) ; return Val_int(res) ; } value mlbz_readclose(value chan) { int bzerror ; BZ_P(bzReadClose)(&bzerror, Bzfile_val(chan)) ; fclose(Cfile_val(chan)) ; { void **p = (void **) chan; p[0] = NULL; p[1] = NULL; } /* mlbz_error(bzerror, "Bz.close_in", chan, 1); */ return Val_unit ; } value mlbz_readgetunused(value chan) { value result; int bzerror ; void *unused ; int nunused ; BZ_P(bzReadGetUnused)(&bzerror, Bzfile_val(chan), &unused, &nunused) ; mlbz_error(bzerror, "Bz.read_get_unused: not at end of stream", chan, 1) ; result = alloc_string(nunused) ; memcpy(String_val(result), unused, nunused) ; return result; } /* OUTPUT FUNCTIONS */ value mlbz_writeopen(value block, value chan) { int bzerror ; int c_block = 9 ; FILE * c_chan ; BZFILE * bz_chan ; if(Is_block(block)) c_block = Int_val(Field(block, 0)) ; c_chan = stream_of_channel(chan, "wb"); bz_chan = BZ_P(bzWriteOpen)(&bzerror, c_chan, c_block, 0, 0) ; mlbz_error(bzerror, "Bz.open_out", chan, 0); return Val_twoptr(c_chan, bz_chan); } value mlbz_write(value chan, value buf, value pos, value len) { int bzerror ; char *c_buf ; int c_pos = Int_val(pos) ; int c_len = Int_val(len) ; if((c_len + c_pos > string_length(buf)) || (c_len < 0) || (c_pos < 0)) invalid_argument("Bz.write") ; c_buf = String_val(buf) + c_pos ; BZ_P(bzWrite)(&bzerror, Bzfile_val(chan), c_buf, c_len) ; mlbz_error(bzerror, "Bz.write", chan, 0) ; return Val_unit; } value mlbz_writeclose(value chan) { int bzerror ; BZ_P(bzWriteClose)(&bzerror, Bzfile_val(chan), 0, NULL, NULL) ; fclose(Cfile_val(chan)) ; { void **p = (void **) chan; p[0] = NULL; p[1] = NULL; } /* mlbz_error(bzerror, "Bz.close_out", chan, 0); */ return Val_unit ; } /* IN MEMORY COMPRESSION */ value mlbz_compress(value block, value src, value pos, value len) { value result ; int c_block=9 ; int c_pos = Int_val(pos) ; int c_len = Int_val(len) ; int r ; unsigned int dst_buf_len, dst_len ; char *src_buf, *dst_buf; if(Is_block(block)) c_block = Int_val(Field(block, 0)) ; if(c_block < 1 || c_block > 9 || c_pos < 0 || c_len < 0 || c_pos + c_len > string_length(src)) invalid_argument("Bz.compress") ; src_buf = String_val(src) + c_pos; dst_buf_len = c_len * 1.01 + 600 ; dst_buf = malloc(dst_buf_len) ; if(dst_buf == NULL) raise_out_of_memory(); while(1) { dst_len = dst_buf_len; r = BZ_P(bzBuffToBuffCompress)(dst_buf, &dst_len, src_buf, c_len, c_block, 0, 0) ; if(r == BZ_OK) { break; } else if(r == BZ_OUTBUFF_FULL){ char *new_buf; dst_buf_len *= 2; new_buf = realloc(dst_buf, dst_buf_len); if(new_buf == NULL) { free(dst_buf); raise_out_of_memory(); } dst_buf = new_buf; } else { free(dst_buf); raise_out_of_memory(); } } result = alloc_string(dst_len); memcpy(String_val(result), dst_buf, dst_len); free(dst_buf); return result ; } value mlbz_uncompress(value small, value src, value pos, value len) { value result ; int c_small = 0 ; int c_pos = Int_val(pos) ; int c_len = Int_val(len) ; int r ; unsigned int dst_buf_len, dst_len ; char *src_buf, *dst_buf; if(Is_block(small)) c_small = Bool_val(Field(small, 0)) ; if(c_pos < 0 || c_len < 0 || c_pos + c_len > string_length(src)) invalid_argument("Bz.uncompress") ; src_buf = String_val(src) + c_pos; dst_buf_len = c_len * 2 ; dst_buf = malloc(dst_buf_len) ; if(dst_buf == NULL) raise_out_of_memory(); while(1) { dst_len = dst_buf_len; r = BZ_P(bzBuffToBuffDecompress)(dst_buf, &dst_len, src_buf, c_len, c_small, 0) ; if(r == BZ_OK) break; else switch(r) { case BZ_OUTBUFF_FULL : { char *new_buf; dst_buf_len *= 2; new_buf = realloc(dst_buf, dst_buf_len); if(new_buf == NULL) { free(dst_buf); raise_out_of_memory(); } dst_buf = new_buf; } break ; case BZ_MEM_ERROR : free(dst_buf) ; raise_out_of_memory() ; case BZ_DATA_ERROR : case BZ_DATA_ERROR_MAGIC : raise_constant(*caml_named_value("mlbz_data_exn")) ; case BZ_UNEXPECTED_EOF : raise_constant(*caml_named_value("mlbz_eof_exn")) ; } } result = alloc_string(dst_len); memcpy(String_val(result), dst_buf, dst_len); free(dst_buf); return result ; } camlbz2-0.7.0/configure.in000066400000000000000000000013011400133463500153530ustar00rootroot00000000000000# autoconf input using ocaml.m4 AC_INIT(bz2.mli) use_findlib=yes # check for OCaml compiler AC_PROG_OCAML AC_PROG_FINDLIB AC_ARG_OCAML_INSTALLDIR AC_CACHE_SAVE # check the C compiler if test "$CFLAGS" = "" ; then CFLAGS="-O2" fi AC_PROG_CC AC_PROG_INSTALL # check for bzlib AC_CHECK_HEADER(bzlib.h,,AC_MSG_ERROR(not found)) BZ_PREFIX="BZ2_" not_ok="" AC_CHECK_LIB(bz2,${BZ_PREFIX}bzReadOpen,,not_ok=y) if test $not_ok then not_ok="" BZ_PREFIX="" AC_CHECK_LIB(bz2,${BZ_PREFIX}bzReadOpen,,not_ok=y) fi if test $not_ok then AC_MSG_ERROR(libbz2 not found) fi unset not_ok AC_SUBST(CFLAGS) AC_SUBST(LIBS) AC_SUBST(BZ_PREFIX) # Finally create the Makefile from Makefile.in AC_OUTPUT(Makefile) camlbz2-0.7.0/examples/000077500000000000000000000000001400133463500146655ustar00rootroot00000000000000camlbz2-0.7.0/examples/bunzip2.ml000066400000000000000000000023311400133463500166070ustar00rootroot00000000000000(* Sample replacement for "bunzip2": showcase for CamlBZ2 * * Copyright © 2009 Stefano Zacchiroli * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License (with the * special exception on linking described in file COPYING) as published * by the Free Software Foundation; either version 2.1 of the License, * or (at your option) any later version. *) (* Compile with: ocamlfind ocamlc -package bz2 -linkpkg -o bunzip2 bunzip2.ml *) open Printf let die_usage () = printf "Usage: bunzip2 FILE.bz2\n"; exit 2 let iname, ic = try Sys.argv.(1), open_in Sys.argv.(1) with Invalid_argument _ -> die_usage () let oc = if not (Filename.check_suffix iname ".bz2") then begin eprintf "Error: unrecognized compressed file extension"; die_usage () end; open_out (Filename.chop_suffix iname ".bz2") let buflen = 8192 let buf = String.create buflen let bzic = Bz2.open_in ic let _ = try while true do let bytes = Bz2.read bzic buf 0 buflen in output oc buf 0 bytes; if bytes < buflen then raise End_of_file done with End_of_file -> (); Bz2.close_in bzic; close_in ic; close_out oc camlbz2-0.7.0/install-sh000077500000000000000000000220211400133463500150500ustar00rootroot00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2005-05-14.22 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" chmodcmd="$chmodprog 0755" chowncmd= chgrpcmd= stripcmd= rmcmd="$rmprog -f" mvcmd="$mvprog" src= dst= dir_arg= dstarg= no_target_directory= usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: -c (ignored) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. --help display this help and exit. --version display version info and exit. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test -n "$1"; do case $1 in -c) shift continue;; -d) dir_arg=true shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; --help) echo "$usage"; exit $?;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -s) stripcmd=$stripprog shift continue;; -t) dstarg=$2 shift shift continue;; -T) no_target_directory=true shift continue;; --version) echo "$0 $scriptversion"; exit $?;; *) # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. test -n "$dir_arg$dstarg" && break # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dstarg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dstarg" shift # fnord fi shift # arg dstarg=$arg done break;; esac done if test -z "$1"; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi for src do # Protect names starting with `-'. case $src in -*) src=./$src ;; esac if test -n "$dir_arg"; then dst=$src src= if test -d "$dst"; then mkdircmd=: chmodcmd= else mkdircmd=$mkdirprog fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dstarg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dstarg # Protect names starting with `-'. case $dst in -*) dst=./$dst ;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dstarg: Is a directory" >&2 exit 1 fi dst=$dst/`basename "$src"` fi fi # This sed command emulates the dirname command. dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` # Make sure that the destination directory exists. # Skip lots of stat calls in the usual case. if test ! -d "$dstdir"; then defaultIFS=' ' IFS="${IFS-$defaultIFS}" oIFS=$IFS # Some sh's can't handle IFS=/ for some reason. IFS='%' set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` shift IFS=$oIFS pathcomp= while test $# -ne 0 ; do pathcomp=$pathcomp$1 shift if test ! -d "$pathcomp"; then $mkdirprog "$pathcomp" # mkdir can fail with a `File exist' error in case several # install-sh are creating the directory concurrently. This # is OK. test -d "$pathcomp" || exit fi pathcomp=$pathcomp/ done fi if test -n "$dir_arg"; then $doit $mkdircmd "$dst" \ && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } else dstfile=`basename "$dst"` # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 trap '(exit $?); exit' 1 2 13 15 # Copy the file name to the temp name. $doit $cpprog "$src" "$dsttmp" && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && # Now rename the file to the real destination. { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ || { # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { if test -f "$dstdir/$dstfile"; then $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ || { echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 (exit 1); exit 1 } else : fi } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" } } fi || { (exit 1); exit 1; } done # The final little trick to "correctly" pass the exit status to the exit trap. { (exit 0); exit 0 } # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-end: "$" # End: camlbz2-0.7.0/io.h000066400000000000000000000036211400133463500136310ustar00rootroot00000000000000/***********************************************************************/ /* */ /* Objective Caml */ /* */ /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ /* */ /* Copyright 1996 Institut National de Recherche en Informatique et */ /* en Automatique. All rights reserved. This file is distributed */ /* under the terms of the GNU Library General Public License, with */ /* the special exception on linking described in file LICENSE. */ /* */ /***********************************************************************/ /* Snippet taken from byterun/io.h of OCaml 3.11 */ #include #ifndef IO_BUFFER_SIZE #define IO_BUFFER_SIZE 4096 #endif #include typedef off_t file_offset; struct channel { int fd; /* Unix file descriptor */ file_offset offset; /* Absolute position of fd in the file */ char * end; /* Physical end of the buffer */ char * curr; /* Current position in the buffer */ char * max; /* Logical end of the buffer (for input) */ void * mutex; /* Placeholder for mutex (for systhreads) */ struct channel * next, * prev;/* Double chaining of channels (flush_all) */ int revealed; /* For Cash only */ int old_revealed; /* For Cash only */ int refcount; /* For flush_all and for Cash */ int flags; /* Bitfield */ char buff[IO_BUFFER_SIZE]; /* The buffer itself */ }; #define Channel(v) (*((struct channel **) (Data_custom_val(v)))) camlbz2-0.7.0/ocaml.m4000066400000000000000000000130111400133463500144000ustar00rootroot00000000000000dnl -*- autoconf -*- macros for OCaml dnl by Olivier Andrieu dnl from a configure.in by Jean-Christophe Filliâtre, dnl from a first script by Georges Mariano dnl dnl defines AC_PROG_OCAML that will check the OCaml compiler dnl and set the following variables : dnl OCAMLC "ocamlc" if present in the path, or a failure dnl or "ocamlc.opt" if present with same version number as ocamlc dnl OCAMLOPT "ocamlopt" (or "ocamlopt.opt" if present), or unset dnl OCAMLBEST either "byte" if no native compiler was found, dnl "opt" otherwise dnl OCAMLDEP "ocamldep" dnl OCAMLLIB the path to the ocaml standard library dnl OCAMLVERSION the ocaml version number dnl dnl OCAMLMKTOP dnl OCAMLMKLIB dnl OCAMLDOC AC_DEFUN(AC_PROG_OCAML, [dnl # checking for ocamlc AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,AC_MSG_ERROR(Cannot find ocamlc.)) OCAMLVERSION=$($OCAMLC -version) AC_MSG_RESULT(OCaml version is $OCAMLVERSION) OCAMLLIB=$($OCAMLC -where) AC_MSG_RESULT(OCaml library path is $OCAMLLIB) # checking for ocamlopt AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt) OCAMLBEST=byte if test -z "$OCAMLOPT"; then AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.) else TMPVERSION=$($OCAMLOPT -version) if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT(versions differs from ocamlc; ocamlopt discarded.) unset OCAMLOPT else OCAMLBEST=opt fi fi # checking for ocamlc.opt AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt) if test "$OCAMLCDOTOPT"; then TMPVERSION=$($OCAMLCDOTOPT -version) if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT(versions differs from ocamlc; ocamlc.opt discarded.) else OCAMLC=$OCAMLCDOTOPT fi fi # checking for ocamlopt.opt if test "$OCAMLOPT" ; then AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt) if test "$OCAMLOPTDOTOPT"; then TMPVERSION=$($OCAMLOPTDOTOPT -version) if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_RESULT(version differs from ocamlc; ocamlopt.opt discarded.) else OCAMLOPT=$OCAMLOPTDOTOPT fi fi fi # checking for ocamldep AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,AC_MSG_ERROR(Cannot find ocamldep.)) #checking for ocamlmktop AC_CHECK_PROG(OCAMLMKTOP,ocamlmktop,ocamlmktop, AC_MSG_WARN(Cannot find ocamlmktop.)) #checking for ocamlmklib AC_CHECK_PROG(OCAMLMKLIB,ocamlmklib,ocamlmklib, AC_MSG_WARN(Cannot find ocamlmklib.)) # checking for ocamldoc AC_CHECK_PROG(OCAMLDOC,ocamldoc,ocamldoc, AC_MSG_WARN(Cannot find ocamldoc.)) # get the C compiler used by ocamlc if test -z "$CC" ; then touch conftest.c CC=$($OCAMLC -verbose conftest.c 2>&1 | awk '/^+/ {print $[]2 ; exit}') echo OCaml uses $CC to compile C files fi AC_SUBST(OCAMLC) AC_SUBST(OCAMLOPT) AC_SUBST(OCAMLDEP) AC_SUBST(OCAMLBEST) AC_SUBST(OCAMLVERSION) AC_SUBST(OCAMLLIB) AC_SUBST(OCAMLMKLIB) AC_SUBST(OCAMLMKTOP) AC_SUBST(OCAMLDOC) ]) dnl dnl dnl dnl macro AC_PROG_OCAML_TOOLS will check OCamllex and OCamlyacc : dnl OCAMLLEX "ocamllex" or "ocamllex.opt" if present dnl OCAMLYACC "ocamlyac" AC_DEFUN(AC_PROG_OCAML_TOOLS, [dnl # checking for ocamllex and ocamlyacc AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex,AC_MSG_ERROR(Cannot find ocamllex.)) if test "$OCAMLLEX"; then AC_CHECK_PROG(OCAMLLEXDOTOPT,ocamllex.opt,ocamllex.opt) if test "$OCAMLLEXDOTOPT"; then OCAMLLEX=$OCAMLLEXDOTOPT fi fi AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,AC_MSG_ERROR(Cannot find ocamlyacc.)) AC_SUBST(OCAMLLEX) AC_SUBST(OCAMLYACC) ]) dnl dnl dnl dnl AC_PROG_CAMLP4 checks for Camlp4 AC_DEFUN(AC_PROG_CAMLP4, [dnl AC_REQUIRE([AC_PROG_OCAML]) # checking for camlp4 AC_CHECK_PROG(CAMLP4,camlp4,camlp4) if test "$CAMLP4"; then TMPVERSION=$($CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p') if test "$TMPVERSION" != "$OCAMLVERSION" ; then AC_MSG_ERROR(versions differs from ocamlc) else AC_CHECK_PROG(CAMLP4O,camlp4o,camlp4o) fi fi AC_SUBST(CAMLP4) AC_SUBST(CAMLP4O) ]) dnl dnl dnl dnl macro AC_PROG_FINDLIB will check for the presence of dnl ocamlfind if configure is called with --with-findlib AC_DEFUN(AC_PROG_FINDLIB, [dnl AC_ARG_WITH(findlib,[ --with-findlib use findlib package system], use_findlib="$withval") # checking for ocamlfind if test "$use_findlib" = yes ; then AC_CHECK_PROG(OCAMLFIND,ocamlfind,ocamlfind, AC_MSG_ERROR(ocamlfind not found)) else unset OCAMLFIND fi AC_SUBST(OCAMLFIND) ]) dnl dnl dnl dnl AC_CHECK_OCAML_PKG checks wether a findlib package is present dnl defines pkg_name to name AC_DEFUN(AC_CHECK_OCAML_PKG, [dnl AC_REQUIRE([AC_PROG_FINDLIB]) if test "$use_findlib" = yes ; then AC_MSG_CHECKING(findlib package $1) if $OCAMLFIND query $1 >/dev/null 2>/dev/null; then AC_MSG_RESULT(found) pkg_$1="$1" else AC_MSG_WARN(not found) unset pkg_$1 fi fi ]) dnl dnl dnl dnl AC_ARG_OCAML_INSTALLDIR adds a --with-installdir option AC_DEFUN(AC_ARG_OCAML_INSTALLDIR, [dnl AC_ARG_WITH(installdir,[ --with-installdir=DIR specify installation directory],INSTALLDIR="$withval") if ! test "$INSTALLDIR" -o "$use_findlib" ; then INSTALLDIR='$(OCAMLLIB)/$(NAME)' fi AC_SUBST(INSTALLDIR) ]) dnl dnl dnl dnl AC_CHECK_OCAML_MODULE looks for a module in a given path dnl 1 -> name (for printing) dnl 2 -> env var name dnl 3 -> module to check dnl 4 -> default dirs AC_DEFUN(AC_CHECK_OCAML_MODULE, [dnl AC_MSG_CHECKING($1 directory) cat > conftest.ml < /dev/null 2>&1 ; then found=yes break fi done if test "$found" ; then AC_MSG_RESULT($$2) else AC_MSG_RESULT(not found) unset $2 fi AC_SUBST($2)])