diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 13:37:52 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 13:37:52 +0000 |
commit | 172d848086d785c0844a4d803702f6c5e0d2bb27 (patch) | |
tree | d7ef4cadde83c426e04aee0a9666ae29d9fa3cde | |
parent | Adding debian version 0.7-1. (diff) | |
download | lzlib-172d848086d785c0844a4d803702f6c5e0d2bb27.tar.xz lzlib-172d848086d785c0844a4d803702f6c5e0d2bb27.zip |
Merging upstream version 0.8.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
-rw-r--r-- | COPYING | 1352 | ||||
-rw-r--r-- | ChangeLog | 24 | ||||
-rw-r--r-- | INSTALL | 2 | ||||
-rw-r--r-- | Makefile.in | 54 | ||||
-rw-r--r-- | NEWS | 29 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | arg_parser.cc | 20 | ||||
-rw-r--r-- | arg_parser.h | 20 | ||||
-rwxr-xr-x | configure | 49 | ||||
-rw-r--r-- | decoder.cc | 58 | ||||
-rw-r--r-- | decoder.h | 10 | ||||
-rw-r--r-- | doc/lzlib.info | 341 | ||||
-rw-r--r-- | doc/lzlib.texinfo | 284 | ||||
-rw-r--r-- | encoder.cc | 9 | ||||
-rw-r--r-- | encoder.h | 11 | ||||
-rw-r--r-- | lzcheck.cc | 98 | ||||
-rw-r--r-- | lzip.h | 20 | ||||
-rw-r--r-- | lzlib.cc | 345 | ||||
-rw-r--r-- | lzlib.h | 117 | ||||
-rw-r--r-- | main.cc | 219 | ||||
-rwxr-xr-x | testsuite/check.sh | 10 | ||||
-rw-r--r-- | testsuite/test1 | 676 | ||||
-rw-r--r-- | testsuite/test1.lz (renamed from testsuite/COPYING.lz) | bin | 11540 -> 11540 bytes |
23 files changed, 2512 insertions, 1238 deletions
@@ -1,676 +1,676 @@ -
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. 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
-them 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 prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. 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.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey 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;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If 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 convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU 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 that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- 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.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-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.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- 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
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program 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, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU 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 Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
-
+ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. 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 +them 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 prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. 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. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey 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; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If 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 convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + 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. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +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. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + 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 +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program 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, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU 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 Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. + @@ -1,3 +1,23 @@ +2010-01-17 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 0.8 released. + * Added new function LZ_decompress_reset. + * Added new function LZ_decompress_sync_to_member. + * Added new function LZ_decompress_write_size. + * Added new function LZ_strerror. + * lzlib.h: API change. Replaced "enum" with functions for values + of dictionary size limits to make interface names consistent. + * lzlib.h: API change. "LZ_errno" replaced with "LZ_Errno". + * lzlib.h: API change. Replaced "void *" with "struct LZ_Encoder *" + and "struct LZ_Decoder *" to make interface type safe. + * decoder.cc: Truncated member trailer is now correctly detected. + * encoder.cc: Matchfinder::reset now also clears at_stream_end_, + allowing LZ_compress_restart_member to restart a finished stream. + * lzlib.cc: Accept only query or close operations after a fatal + error has occurred. + * Shared version of lzlib is no more built by default. + * testsuite/check.sh: Use "test1" instead of "COPYING" for testing. + 2009-10-20 Antonio Diaz Diaz <ant_diaz@teleline.es> * Version 0.7 released. @@ -27,7 +47,7 @@ 2009-05-03 Antonio Diaz Diaz <ant_diaz@teleline.es> * Version 0.3 released. - * Lzilib is now built as a shared library (in addition to static). + * Lzlib is now built as a shared library (in addition to static). 2009-04-26 Antonio Diaz Diaz <ant_diaz@teleline.es> @@ -40,7 +60,7 @@ * Version 0.1 released. -Copyright (C) 2009 Antonio Diaz Diaz. +Copyright (C) 2009, 2010 Antonio Diaz Diaz. This file is a collection of facts, and thus it is not copyrightable, but just in case, I give you unlimited permission to copy, distribute @@ -51,7 +51,7 @@ After running `configure', you can run `make' and `make install' as explained above. -Copyright (C) 2009 Antonio Diaz Diaz. +Copyright (C) 2009, 2010 Antonio Diaz Diaz. This file is free documentation: you have unlimited permission to copy, distribute and modify it. diff --git a/Makefile.in b/Makefile.in index 3d51c30..c06404d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -19,23 +19,23 @@ objs = arg_parser.o main.o all : $(progname) $(progname_shared) -$(libname).a: $(lib_objs) - $(AR) -rcs $(libname).a $(lib_objs) +lib$(libname).a: $(lib_objs) + $(AR) -rcs lib$(libname).a $(lib_objs) -$(libname).so.$(pkgversion) : $(sh_lib_objs) - $(CXX) -shared -Wl,--soname=$(libname).so.$(soversion) -o $(libname).so.$(pkgversion) $(sh_lib_objs) +lib$(libname).so.$(pkgversion) : $(sh_lib_objs) + $(CXX) -shared -Wl,--soname=lib$(libname).so.$(soversion) -o lib$(libname).so.$(pkgversion) $(sh_lib_objs) -$(progname) : $(objs) $(libname).a - $(CXX) $(LDFLAGS) -o $(progname) $(objs) $(libname).a +$(progname) : $(objs) lib$(libname).a + $(CXX) $(LDFLAGS) -o $(progname) $(objs) lib$(libname).a -$(progname)_shared : $(objs) $(libname).so.$(pkgversion) - $(CXX) $(LDFLAGS) -o $(progname)_shared $(objs) $(libname).so.$(pkgversion) +$(progname)_shared : $(objs) lib$(libname).so.$(pkgversion) + $(CXX) $(LDFLAGS) -o $(progname)_shared $(objs) lib$(libname).so.$(pkgversion) -$(progname)_profiled : $(objs) $(libname).a - $(CXX) $(LDFLAGS) -pg -o $(progname)_profiled $(objs) $(libname).a +$(progname)_profiled : $(objs) lib$(libname).a + $(CXX) $(LDFLAGS) -pg -o $(progname)_profiled $(objs) lib$(libname).a -lzcheck : lzcheck.o $(libname).a - $(CXX) $(LDFLAGS) -o lzcheck lzcheck.o $(libname).a +lzcheck : lzcheck.o lib$(libname).a + $(CXX) $(LDFLAGS) -o lzcheck lzcheck.o lib$(libname).a main.o : main.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $< @@ -61,7 +61,8 @@ sh_decoder.o : decoder.h sh_encoder.o : encoder.h sh_lzlib.o : decoder.h encoder.h arg_parser.o : Makefile arg_parser.h -main.o : Makefile arg_parser.h lzlib.h $(libname).a +main.o : Makefile arg_parser.h lzlib.h +lzcheck.o : Makefile lzlib.h doc : info man @@ -80,21 +81,21 @@ $(VPATH)/doc/$(progname).1 : $(progname) Makefile : $(VPATH)/configure $(VPATH)/Makefile.in ./config.status -check : all $(VPATH)/testsuite/check.sh lzcheck +check : all lzcheck @$(VPATH)/testsuite/check.sh $(VPATH)/testsuite install : all install-info if [ ! -d $(DESTDIR)$(includedir) ] ; then $(INSTALL_DIR) $(DESTDIR)$(includedir) ; fi if [ ! -d $(DESTDIR)$(libdir) ] ; then $(INSTALL_DIR) $(DESTDIR)$(libdir) ; fi - $(INSTALL_DATA) $(VPATH)/$(pkgname).h $(DESTDIR)$(includedir)/$(pkgname).h - $(INSTALL_DATA) ./$(libname).a $(DESTDIR)$(libdir)/$(libname).a + $(INSTALL_DATA) $(VPATH)/$(libname)lib.h $(DESTDIR)$(includedir)/$(libname)lib.h + $(INSTALL_DATA) ./lib$(libname).a $(DESTDIR)$(libdir)/lib$(libname).a if [ -n "$(progname_shared)" ] ; then \ - $(INSTALL_PROGRAM) ./$(libname).so.$(pkgversion) $(DESTDIR)$(libdir)/$(libname).so.$(pkgversion) ; \ - if [ -e $(DESTDIR)$(libdir)/$(libname).so.$(soversion) ] ; then \ - run_ldconfig=no ; rm -f $(DESTDIR)$(libdir)/$(libname).so.$(soversion) ; \ + $(INSTALL_PROGRAM) ./lib$(libname).so.$(pkgversion) $(DESTDIR)$(libdir)/lib$(libname).so.$(pkgversion) ; \ + if [ -e $(DESTDIR)$(libdir)/lib$(libname).so.$(soversion) ] ; then \ + run_ldconfig=no ; rm -f $(DESTDIR)$(libdir)/lib$(libname).so.$(soversion) ; \ else run_ldconfig=yes ; \ fi ; \ - cd $(DESTDIR)$(libdir) && ln -s $(libname).so.$(pkgversion) $(libname).so.$(soversion) ; \ + cd $(DESTDIR)$(libdir) && ln -s lib$(libname).so.$(pkgversion) lib$(libname).so.$(soversion) ; \ if [ $${run_ldconfig} = yes ] ; then $(LDCONFIG) $(DESTDIR)$(libdir) ; fi ; \ fi @@ -111,10 +112,10 @@ install-strip : all $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install uninstall : uninstall-info - -rm -f $(DESTDIR)$(includedir)/$(pkgname).h - -rm -f $(DESTDIR)$(libdir)/$(libname).a - -rm -f $(DESTDIR)$(libdir)/$(libname).so.$(soversion) - -rm -f $(DESTDIR)$(libdir)/$(libname).so.$(pkgversion) + -rm -f $(DESTDIR)$(includedir)/$(libname)lib.h + -rm -f $(DESTDIR)$(libdir)/lib$(libname).a + -rm -f $(DESTDIR)$(libdir)/lib$(libname).so.$(soversion) + -rm -f $(DESTDIR)$(libdir)/lib$(libname).so.$(pkgversion) uninstall-info : -install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$(pkgname).info @@ -123,7 +124,7 @@ uninstall-info : uninstall-man : -rm -f $(DESTDIR)$(mandir)/man1/$(progname).1 -dist : +dist : doc ln -sf $(VPATH) $(DISTNAME) tar -cvf $(DISTNAME).tar \ $(DISTNAME)/AUTHORS \ @@ -136,8 +137,9 @@ dist : $(DISTNAME)/configure \ $(DISTNAME)/doc/$(pkgname).info \ $(DISTNAME)/doc/$(pkgname).texinfo \ - $(DISTNAME)/testsuite/COPYING.lz \ $(DISTNAME)/testsuite/check.sh \ + $(DISTNAME)/testsuite/test1 \ + $(DISTNAME)/testsuite/test1.lz \ $(DISTNAME)/*.h \ $(DISTNAME)/*.cc rm -f $(DISTNAME) @@ -1,3 +1,28 @@ -Changes in version 0.7: +Changes in version 0.8: -Compression time has been reduced by 4%. +API changes: + New functions: + LZ_decompress_reset + LZ_decompress_sync_to_member + LZ_decompress_write_size + LZ_strerror + + Names and types for values of dictionary size limits have been changed + to make interface names consistent. + + "LZ_errno" has been replaced with "LZ_Errno". + + "void *" has been replaced with "struct LZ_Encoder *" and + "struct LZ_Decoder *" to make interface type safe. + +A truncated member trailer is now correctly detected. + +LZ_compress_restart_member is now able to restart a finished stream. + +Lzlib now only accepts query or close operations after a fatal error has +occurred. + +Shared version of lzlib is no more built by default. Use +"configure --enable-shared" to build it. + +The "COPYING" file is no more used for testing decompression. @@ -29,7 +29,7 @@ Igor Pavlov. For a description of the LZMA algorithm, see the Lzip manual. -Copyright (C) 2009 Antonio Diaz Diaz. +Copyright (C) 2009, 2010 Antonio Diaz Diaz. This file is free documentation: you have unlimited permission to copy, distribute and modify it. diff --git a/arg_parser.cc b/arg_parser.cc index b889e1a..cc9f87d 100644 --- a/arg_parser.cc +++ b/arg_parser.cc @@ -1,18 +1,28 @@ -/* Arg_parser - A POSIX/GNU command line argument parser. - Copyright (C) 2006, 2007, 2008, 2009 Antonio Diaz Diaz. +/* Arg_parser - A POSIX/GNU command line argument parser. (C++ version) + Copyright (C) 2006, 2007, 2008, 2009, 2010 Antonio Diaz Diaz. - This program is free software: you can redistribute it and/or modify + This library 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 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + 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 General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. + along with this library. If not, see <http://www.gnu.org/licenses/>. + + As a special exception, you may use this file as part of a free + software library without restriction. Specifically, if other files + instantiate templates or use macros or inline functions from this + file, or you compile this file and link it with other files to + produce an executable, this file does not by itself cause the + resulting executable to be covered by the GNU General Public + License. This exception does not however invalidate any other + reasons why the executable file might be covered by the GNU General + Public License. */ #include <cstring> diff --git a/arg_parser.h b/arg_parser.h index fa6161b..da1cc94 100644 --- a/arg_parser.h +++ b/arg_parser.h @@ -1,18 +1,28 @@ -/* Arg_parser - A POSIX/GNU command line argument parser. - Copyright (C) 2006, 2007, 2008, 2009 Antonio Diaz Diaz. +/* Arg_parser - A POSIX/GNU command line argument parser. (C++ version) + Copyright (C) 2006, 2007, 2008, 2009, 2010 Antonio Diaz Diaz. - This program is free software: you can redistribute it and/or modify + This library 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 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + 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 General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. + along with this library. If not, see <http://www.gnu.org/licenses/>. + + As a special exception, you may use this file as part of a free + software library without restriction. Specifically, if other files + instantiate templates or use macros or inline functions from this + file, or you compile this file and link it with other files to + produce an executable, this file does not by itself cause the + resulting executable to be covered by the GNU General Public + License. This exception does not however invalidate any other + reasons why the executable file might be covered by the GNU General + Public License. */ /* Arg_parser reads the arguments in `argv' and creates a number of @@ -1,21 +1,21 @@ #! /bin/sh # configure script for Lzlib - A compression library for lzip files -# Copyright (C) 2009 Antonio Diaz Diaz. +# Copyright (C) 2009, 2010 Antonio Diaz Diaz. # # This configure script is free software: you have unlimited permission # to copy, distribute and modify it. # -# Date of this version: 2009-10-20 +# Date of this version: 2010-01-17 args= no_create= pkgname=lzlib -pkgversion=0.7 +pkgversion=0.8 soversion=0 progname=minilzip -progname_shared=${progname}_shared -libname=liblz -srctrigger=${pkgname}.h +progname_shared= +libname=lz +srctrigger=${libname}lib.h # clear some things potentially inherited from environment. LC_ALL=C @@ -30,15 +30,13 @@ infodir='$(datadir)/info' libdir='${exec_prefix}/lib' mandir='$(datadir)/man' sysconfdir='$(prefix)/etc' -CC= CXX= CPPFLAGS= -CFLAGS='-Wall -W -O2' CXXFLAGS='-Wall -W -O2' LDFLAGS= # Loop over all args -while [ x"$1" != x ] ; do +while [ -n "$1" ] ; do # Get the first arg, and shuffle option=$1 @@ -70,11 +68,9 @@ while [ x"$1" != x ] ; do echo " --libdir=DIR object code libraries [${libdir}]" echo " --mandir=DIR man pages directory [${mandir}]" echo " --sysconfdir=DIR read-only single-machine data directory [${sysconfdir}]" - echo " --disable-shared do not build a shared library [enable]" - echo " CC=COMPILER C compiler to use [gcc]" + echo " --enable-shared build also a shared library [disable]" echo " CXX=COMPILER C++ compiler to use [g++]" echo " CPPFLAGS=OPTIONS command line options for the preprocessor [${CPPFLAGS}]" - echo " CFLAGS=OPTIONS command line options for the C compiler [${CFLAGS}]" echo " CXXFLAGS=OPTIONS command line options for the C++ compiler [${CXXFLAGS}]" echo " LDFLAGS=OPTIONS command line options for the linker [${LDFLAGS}]" echo @@ -104,13 +100,11 @@ while [ x"$1" != x ] ; do sysconfdir=`echo ${optarg} | sed -e 's,/$,,'` ;; --no-create | --no-c*) no_create=yes ;; - --disable-shared | --disable-s*) - progname_shared= ;; + --enable-shared | --enable-s*) + progname_shared=${progname}_shared ;; - CC=*) CC=${optarg} ;; CXX=*) CXX=${optarg} ;; CPPFLAGS=*) CPPFLAGS=${optarg} ;; - CFLAGS=*) CFLAGS=${optarg} ;; CXXFLAGS=*) CXXFLAGS=${optarg} ;; LDFLAGS=*) LDFLAGS=${optarg} ;; @@ -123,7 +117,7 @@ done # Find the source files, if location was not specified. srcdirtext= -if [ x"${srcdir}" = x ] ; then +if [ -z "${srcdir}" ] ; then srcdirtext="or . or .." ; srcdir=. if [ ! -r ${srcdir}/${srctrigger} ] ; then srcdir=.. ; fi if [ ! -r ${srcdir}/${srctrigger} ] ; then @@ -143,19 +137,8 @@ fi # Set srcdir to . if that's what it is. if [ "`pwd`" = "`cd ${srcdir} ; pwd`" ] ; then srcdir=. ; fi -# checking whether we are using GNU C. -if [ x"${CC}" = x ] ; then # Let the user override the test. - if [ -x /bin/gcc ] || - [ -x /usr/bin/gcc ] || - [ -x /usr/local/bin/gcc ] ; then - CC="gcc" - else - CC="cc" - fi -fi - # checking whether we are using GNU C++. -if [ x"${CXX}" = x ] ; then # Let the user override the test. +if [ -z "${CXX}" ] ; then # Let the user override the test. if [ -x /bin/g++ ] || [ -x /usr/bin/g++ ] || [ -x /usr/local/bin/g++ ] ; then @@ -166,7 +149,7 @@ if [ x"${CXX}" = x ] ; then # Let the user override the test. fi echo -if [ x${no_create} = x ] ; then +if [ -z ${no_create} ] ; then echo "creating config.status" rm -f config.status cat > config.status << EOF @@ -193,16 +176,14 @@ echo "infodir = ${infodir}" echo "libdir = ${libdir}" echo "mandir = ${mandir}" echo "sysconfdir = ${sysconfdir}" -echo "CC = ${CC}" echo "CXX = ${CXX}" echo "CPPFLAGS = ${CPPFLAGS}" -echo "CFLAGS = ${CFLAGS}" echo "CXXFLAGS = ${CXXFLAGS}" echo "LDFLAGS = ${LDFLAGS}" rm -f Makefile cat > Makefile << EOF # Makefile for Lzlib - A compression library for lzip files -# Copyright (C) 2009 Antonio Diaz Diaz. +# Copyright (C) 2009, 2010 Antonio Diaz Diaz. # This file was generated automatically by configure. Do not edit. # # This Makefile is free software: you have unlimited permission @@ -224,10 +205,8 @@ infodir = ${infodir} libdir = ${libdir} mandir = ${mandir} sysconfdir = ${sysconfdir} -CC = ${CC} CXX = ${CXX} CPPFLAGS = ${CPPFLAGS} -CFLAGS = ${CFLAGS} CXXFLAGS = ${CXXFLAGS} LDFLAGS = ${LDFLAGS} EOF @@ -1,5 +1,5 @@ /* Lzlib - A compression library for lzip files - Copyright (C) 2009 Antonio Diaz Diaz. + Copyright (C) 2009, 2010 Antonio Diaz Diaz. This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ 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, see <http://www.gnu.org/licenses/>. + along with this library. If not, see <http://www.gnu.org/licenses/>. As a special exception, you may use this file as part of a free software library without restriction. Specifically, if other files @@ -31,8 +31,6 @@ #include <cerrno> #include <cstdlib> #include <cstring> -#include <string> -#include <vector> #include <stdint.h> #include "lzlib.h" @@ -42,7 +40,8 @@ const CRC32 crc32; - +// Copies up to `out_size' bytes to `out_buffer' and updates `get'. +// Returns the number of bytes copied. int Circular_buffer::read_data( uint8_t * const out_buffer, const int out_size ) throw() { int size = 0; @@ -70,6 +69,8 @@ int Circular_buffer::read_data( uint8_t * const out_buffer, const int out_size ) } +// Copies up to `in_size' bytes from `in_buffer' and updates `put'. +// Returns the number of bytes copied. int Circular_buffer::write_data( const uint8_t * const in_buffer, const int in_size ) throw() { int size = 0; @@ -97,6 +98,47 @@ int Circular_buffer::write_data( const uint8_t * const in_buffer, const int in_s } +// Seeks a member header and updates `get'. +// Returns true if it finds a valid header. +bool Input_buffer::find_header() throw() + { + while( get != put ) + { + if( buffer[get] == magic_string[0] ) + { + int g = get; + File_header header; + for( unsigned int i = 0; i < sizeof header; ++i ) + { + if( g == put ) return false; // not enough data + ((uint8_t *)&header)[i] = buffer[g]; + if( ++g >= buffer_size ) g = 0; + } + if( header.verify() ) return true; + } + if( ++get >= buffer_size ) get = 0; + } + return false; + } + + +// Returns true, fills `header', and updates `get' if `get' points to a +// valid header. +// Else returns false and leaves `get' unmodified. +bool Input_buffer::read_header( File_header & header ) throw() + { + int g = get; + for( unsigned int i = 0; i < sizeof header; ++i ) + { + if( g == put ) return false; // not enough data + ((uint8_t *)&header)[i] = buffer[g]; + if( ++g >= buffer_size ) g = 0; + } + if( header.verify() ) { get = g; return true; } + return false; + } + + bool LZ_decoder::verify_trailer() { bool error = false; @@ -125,7 +167,8 @@ int LZ_decoder::decode_member() if( !range_decoder.try_reload() ) return 0; if( verify_trailer_pending ) { - if( range_decoder.available_bytes() < File_trailer::size( format_version ) ) + if( range_decoder.available_bytes() < File_trailer::size( format_version ) && + !range_decoder.at_stream_end() ) return 0; verify_trailer_pending = false; member_finished_ = true; @@ -201,7 +244,8 @@ int LZ_decoder::decode_member() range_decoder.normalize(); if( len == min_match_len ) // End Of Stream marker { - if( range_decoder.available_bytes() < File_trailer::size( format_version ) ) + if( range_decoder.available_bytes() < File_trailer::size( format_version ) && + !range_decoder.at_stream_end() ) { verify_trailer_pending = true; return 0; } member_finished_ = true; if( verify_trailer() ) return 0; else return 3; @@ -1,5 +1,5 @@ /* Lzlib - A compression library for lzip files - Copyright (C) 2009 Antonio Diaz Diaz. + Copyright (C) 2009, 2010 Antonio Diaz Diaz. This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ 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, see <http://www.gnu.org/licenses/>. + along with this library. If not, see <http://www.gnu.org/licenses/>. As a special exception, you may use this file as part of a free software library without restriction. Specifically, if other files @@ -39,7 +39,13 @@ public: bool at_stream_end() const throw() { return at_stream_end_; } void finish() throw() { at_stream_end_ = true; } bool finished() const throw() { return at_stream_end_ && !used_bytes(); } + int free_bytes() const throw() + { if( at_stream_end_ ) return 0; return Circular_buffer::free_bytes(); } void purge() throw() { at_stream_end_ = true; Circular_buffer::reset(); } + void reset() throw() { at_stream_end_ = false; Circular_buffer::reset(); } + + bool find_header() throw(); + bool read_header( File_header & header ) throw(); bool enough_available_bytes() const throw() { diff --git a/doc/lzlib.info b/doc/lzlib.info index 40862bd..9437d8c 100644 --- a/doc/lzlib.info +++ b/doc/lzlib.info @@ -12,23 +12,25 @@ File: lzlib.info, Node: Top, Next: Introduction, Up: (dir) Lzlib Manual ************ -This manual is for Lzlib (version 0.7, 20 October 2009). +This manual is for Lzlib (version 0.8, 17 January 2010). * Menu: * Introduction:: Purpose and features of Lzlib * Library Version:: Checking library version * Buffering:: Sizes of Lzlib's buffers +* Parameter Limits:: Min / max values for some parameters * Compression Functions:: Descriptions of the compression functions * Decompression Functions:: Descriptions of the decompression functions * Error Codes:: Meaning of codes returned by functions +* Error Messages:: Error messages corresponding to error codes * Data Format:: Detailed format of the compressed data * Examples:: A small tutorial with examples * Problems:: Reporting bugs * Concept Index:: Index of concepts - Copyright (C) 2009 Antonio Diaz Diaz. + Copyright (C) 2009, 2010 Antonio Diaz Diaz. This manual is free documentation: you have unlimited permission to copy, distribute and modify it. @@ -95,7 +97,7 @@ application. error( "bad library version" ); -File: lzlib.info, Node: Buffering, Next: Compression Functions, Prev: Library Version, Up: Top +File: lzlib.info, Node: Buffering, Next: Parameter Limits, Prev: Library Version, Up: Top 3 Buffering *********** @@ -119,24 +121,55 @@ minimum sizes: `LZ_decompress_write' function. Its size is 64KiB. * Output decompression buffer. Read from by the `LZ_decompress_read' - function. Its size is the dictionary size set with the - `LZ_decompress_open' function or 64KiB, whichever is larger. + function. Its size is the dictionary size set in the header of the + member currently being decompressed or 64KiB, whichever is larger. -File: lzlib.info, Node: Compression Functions, Next: Decompression Functions, Prev: Buffering, Up: Top +File: lzlib.info, Node: Parameter Limits, Next: Compression Functions, Prev: Buffering, Up: Top -4 Compression Functions +4 Parameter Limits +****************** + +These functions provide minimum and maximum values for some parameters. +Current values are shown in square brackets. + + -- Function: int LZ_min_dictionary_bits ( void ) + Returns the base 2 logarithm of the smallest valid dictionary size + [12]. + + -- Function: int LZ_min_dictionary_size ( void ) + Returns the smallest valid dictionary size [4KiB]. + + -- Function: int LZ_max_dictionary_bits ( void ) + Returns the base 2 logarithm of the largest valid dictionary size + [29]. + + -- Function: int LZ_max_dictionary_size ( void ) + Returns the largest valid dictionary size [512MiB]. + + -- Function: int LZ_min_match_len_limit ( void ) + Returns the smallest valid match length limit [5]. + + -- Function: int LZ_max_match_len_limit ( void ) + Returns the largest valid match length limit [273]. + + +File: lzlib.info, Node: Compression Functions, Next: Decompression Functions, Prev: Parameter Limits, Up: Top + +5 Compression Functions *********************** These are the functions used to compress data. In case of error, all of them return -1, except `LZ_compress_open' whose return value must be verified by calling `LZ_compress_errno' before using it. - -- Function: void * LZ_compress_open ( const int DICTIONARY_SIZE, - const int MATCH_LEN_LIMIT, const long long MEMBER_SIZE ) + -- Function: struct LZ_Encoder * LZ_compress_open ( const int + DICTIONARY_SIZE, const int MATCH_LEN_LIMIT, const long long + MEMBER_SIZE ) Initializes the internal stream state for compression and returns a pointer that can only be used as the ENCODER argument for the - other LZ_compress functions. + other LZ_compress functions, or a null pointer if the encoder + could not be allocated. The returned pointer must be verified by calling `LZ_compress_errno' before using it. If `LZ_compress_errno' does @@ -158,31 +191,37 @@ verified by calling `LZ_compress_errno' before using it. stream, give MEMBER_SIZE a value larger than the amount of data to be produced, for example LLONG_MAX. - -- Function: int LZ_compress_restart_member ( void * const ENCODER, - const long long MEMBER_SIZE ) - Use this function to start a new member, in a multimember data - stream. Call this function only after - `LZ_compress_member_finished' indicates that the current member - has been fully read (with the `LZ_compress_read' function). - - -- Function: int LZ_compress_close ( void * const ENCODER ) + -- Function: int LZ_compress_close ( struct LZ_Encoder * const ENCODER + ) Frees all dynamically allocated data structures for this stream. This function discards any unprocessed input and does not flush any pending output. After a call to `LZ_compress_close', ENCODER can no more be used as an argument to any LZ_compress function. - -- Function: int LZ_compress_finish ( void * const ENCODER ) - Use this function to tell `lzlib' that all the data for this stream + -- Function: int LZ_compress_finish ( struct LZ_Encoder * const + ENCODER ) + Use this function to tell `lzlib' that all the data for this member has already been written (with the `LZ_compress_write' function). + After all the produced compressed data has been read with + `LZ_compress_read' and `LZ_compress_member_finished' returns 1, a + new member can be started with `LZ_compress_restart_member'. + + -- Function: int LZ_compress_restart_member ( struct LZ_Encoder * + const ENCODER, const long long MEMBER_SIZE ) + Use this function to start a new member, in a multimember data + stream. Call this function only after + `LZ_compress_member_finished' indicates that the current member + has been fully read (with the `LZ_compress_read' function). - -- Function: int LZ_compress_sync_flush ( void * const ENCODER ) + -- Function: int LZ_compress_sync_flush ( struct LZ_Encoder * const + ENCODER ) Use this function to make available to `LZ_compress_read' all the data already written with the `LZ_compress_write' function. Repeated use of `LZ_compress_sync_flush' may degrade compression ratio, so use it only when needed. - -- Function: int LZ_compress_read ( void * const ENCODER, uint8_t * - const BUFFER, const int SIZE ) + -- Function: int LZ_compress_read ( struct LZ_Encoder * const ENCODER, + uint8_t * const BUFFER, const int SIZE ) The `LZ_compress_read' function reads up to SIZE bytes from the stream pointed to by ENCODER, storing the results in BUFFER. @@ -192,8 +231,8 @@ verified by calling `LZ_compress_errno' before using it. `LZ_compress_write' function. Note that reading less than SIZE bytes is not an error. - -- Function: int LZ_compress_write ( void * const ENCODER, uint8_t * - const BUFFER, const int SIZE ) + -- Function: int LZ_compress_write ( struct LZ_Encoder * const + ENCODER, uint8_t * const BUFFER, const int SIZE ) The `LZ_compress_write' function writes up to SIZE bytes from BUFFER to the stream pointed to by ENCODER. @@ -201,7 +240,8 @@ verified by calling `LZ_compress_errno' before using it. might be less than SIZE. Note that writing less than SIZE bytes is not an error. - -- Function: int LZ_compress_write_size ( void * const ENCODER ) + -- Function: int LZ_compress_write_size ( struct LZ_Encoder * const + ENCODER ) The `LZ_compress_write_size' function returns the maximum number of bytes that can be inmediately written through the `LZ_compress_write' function. @@ -209,69 +249,94 @@ verified by calling `LZ_compress_errno' before using it. It is guaranteed that an inmediate call to `LZ_compress_write' will accept a SIZE up to the returned number of bytes. - -- Function: enum LZ_errno LZ_compress_errno ( void * const ENCODER ) + -- Function: enum LZ_Errno LZ_compress_errno ( struct LZ_Encoder * + const ENCODER ) Returns the current error code for ENCODER (*note Error Codes::) - -- Function: int LZ_compress_finished ( void * const ENCODER ) + -- Function: int LZ_compress_finished ( struct LZ_Encoder * const + ENCODER ) Returns 1 if all the data has been read and `LZ_compress_close' can be safely called. Otherwise it returns 0. - -- Function: int LZ_compress_member_finished ( void * const ENCODER ) + -- Function: int LZ_compress_member_finished ( struct LZ_Encoder * + const ENCODER ) Returns 1 if the current member, in a multimember data stream, has been fully read and `LZ_compress_restart_member' can be safely called. Otherwise it returns 0. - -- Function: long long LZ_compress_data_position ( void * const - ENCODER ) + -- Function: long long LZ_compress_data_position ( struct LZ_Encoder * + const ENCODER ) Returns the number of input bytes already compressed in the current member. - -- Function: long long LZ_compress_member_position ( void * const - ENCODER ) + -- Function: long long LZ_compress_member_position ( struct LZ_Encoder + * const ENCODER ) Returns the number of compressed bytes already produced, but perhaps not yet read, in the current member. - -- Function: long long LZ_compress_total_in_size ( void * const - ENCODER ) + -- Function: long long LZ_compress_total_in_size ( struct LZ_Encoder * + const ENCODER ) Returns the total number of input bytes already compressed. - -- Function: long long LZ_compress_total_out_size ( void * const - ENCODER ) + -- Function: long long LZ_compress_total_out_size ( struct LZ_Encoder + * const ENCODER ) Returns the total number of compressed bytes already produced, but perhaps not yet read. File: lzlib.info, Node: Decompression Functions, Next: Error Codes, Prev: Compression Functions, Up: Top -5 Decompression Functions +6 Decompression Functions ************************* These are the functions used to decompress data. In case of error, all of them return -1, except `LZ_decompress_open' whose return value must be verified by calling `LZ_decompress_errno' before using it. - -- Function: void * LZ_decompress_open ( void ) + -- Function: struct LZ_Decoder * LZ_decompress_open ( void ) Initializes the internal stream state for decompression and returns a pointer that can only be used as the DECODER argument - for the other LZ_decompress functions. + for the other LZ_decompress functions, or a null pointer if the + decoder could not be allocated. The returned pointer must be verified by calling `LZ_decompress_errno' before using it. If `LZ_decompress_errno' does not return `LZ_ok', the returned pointer must not be used and should be freed with `LZ_decompress_close' to avoid memory leaks. - -- Function: int LZ_decompress_close ( void * const DECODER ) + -- Function: int LZ_decompress_close ( struct LZ_Decoder * const + DECODER ) Frees all dynamically allocated data structures for this stream. This function discards any unprocessed input and does not flush any pending output. After a call to `LZ_decompress_close', DECODER can no more be used as an argument to any LZ_decompress function. - -- Function: int LZ_decompress_finish ( void * const DECODER ) + -- Function: int LZ_decompress_finish ( struct LZ_Decoder * const + DECODER ) Use this function to tell `lzlib' that all the data for this stream has already been written (with the `LZ_decompress_write' function). - -- Function: int LZ_decompress_read ( void * const DECODER, uint8_t * - const BUFFER, const int SIZE ) + -- Function: int LZ_decompress_reset ( struct LZ_Decoder * const + DECODER ) + Resets the internal state of DECODER as it was just after opening + it with the `LZ_decompress_open' function. Data stored in the + internal buffers is discarded. Position counters are set to 0. + + -- Function: int LZ_decompress_sync_to_member ( struct LZ_Decoder * + const DECODER ) + Resets the error state of DECODER and enters a search state that + lasts until a new member header (or the end of the stream) is + found. After a successful call to `LZ_decompress_sync_to_member', + data written with `LZ_decompress_write' will be consumed and + `LZ_decompress_read' will return 0 until a header is found. + + This function is useful to discard any data preceding the first + member, or to discard the rest of the current member, for example + in case of a data error. If the decoder is already at the + beginning of a member, this function does nothing. + + -- Function: int LZ_decompress_read ( struct LZ_Decoder * const + DECODER, uint8_t * const BUFFER, const int SIZE ) The `LZ_decompress_read' function reads up to SIZE bytes from the stream pointed to by DECODER, storing the results in BUFFER. @@ -281,8 +346,8 @@ be verified by calling `LZ_decompress_errno' before using it. `LZ_decompress_write' function. Note that reading less than SIZE bytes is not an error. - -- Function: int LZ_decompress_write ( void * const DECODER, uint8_t * - const BUFFER, const int SIZE ) + -- Function: int LZ_decompress_write ( struct LZ_Decoder * const + DECODER, uint8_t * const BUFFER, const int SIZE ) The `LZ_decompress_write' function writes up to SIZE bytes from BUFFER to the stream pointed to by DECODER. @@ -290,36 +355,47 @@ be verified by calling `LZ_decompress_errno' before using it. might be less than SIZE. Note that writing less than SIZE bytes is not an error. - -- Function: enum LZ_errno LZ_decompress_errno ( void * const DECODER ) + -- Function: int LZ_decompress_write_size ( struct LZ_Decoder * const + DECODER ) + The `LZ_decompress_write_size' function returns the maximum number + of bytes that can be inmediately written through the + `LZ_decompress_write' function. + + It is guaranteed that an inmediate call to `LZ_decompress_write' + will accept a SIZE up to the returned number of bytes. + + -- Function: enum LZ_Errno LZ_decompress_errno ( struct LZ_Decoder * + const DECODER ) Returns the current error code for DECODER (*note Error Codes::) - -- Function: int LZ_decompress_finished ( void * const DECODER ) + -- Function: int LZ_decompress_finished ( struct LZ_Decoder * const + DECODER ) Returns 1 if all the data has been read and `LZ_decompress_close' can be safely called. Otherwise it returns 0. - -- Function: long long LZ_decompress_data_position ( void * const - DECODER ) + -- Function: long long LZ_decompress_data_position ( struct LZ_Decoder + * const DECODER ) Returns the number of decompressed bytes already produced, but perhaps not yet read, in the current member. - -- Function: long long LZ_decompress_member_position ( void * const - DECODER ) + -- Function: long long LZ_decompress_member_position ( struct + LZ_Decoder * const DECODER ) Returns the number of input bytes already decompressed in the current member. - -- Function: long long LZ_decompress_total_in_size ( void * const - DECODER ) + -- Function: long long LZ_decompress_total_in_size ( struct LZ_Decoder + * const DECODER ) Returns the total number of input bytes already decompressed. - -- Function: long long LZ_decompress_total_out_size ( void * const - DECODER ) + -- Function: long long LZ_decompress_total_out_size ( struct + LZ_Decoder * const DECODER ) Returns the total number of decompressed bytes already produced, but perhaps not yet read. -File: lzlib.info, Node: Error Codes, Next: Data Format, Prev: Decompression Functions, Up: Top +File: lzlib.info, Node: Error Codes, Next: Error Messages, Prev: Decompression Functions, Up: Top -6 Error Codes +7 Error Codes ************* Most library functions return -1 to indicate that they have failed. But @@ -336,42 +412,58 @@ whether a call failed. If the call failed, then you can examine The error codes are defined in the header file `lzlib.h'. - -- Constant: enum LZ_errno LZ_ok + -- Constant: enum LZ_Errno LZ_ok The value of this constant is 0 and is used to indicate that there is no error. - -- Constant: enum LZ_errno LZ_bad_argument + -- Constant: enum LZ_Errno LZ_bad_argument At least one of the arguments passed to the library function was invalid. - -- Constant: enum LZ_errno LZ_mem_error + -- Constant: enum LZ_Errno LZ_mem_error No memory available. The system cannot allocate more virtual memory because its capacity is full. - -- Constant: enum LZ_errno LZ_sequence_error + -- Constant: enum LZ_Errno LZ_sequence_error A library function was called in the wrong order. For example `LZ_compress_restart_member' was called before `LZ_compress_member_finished' indicates that the current member is finished. - -- Constant: enum LZ_errno LZ_header_error + -- Constant: enum LZ_Errno LZ_header_error Reading of member header failed. If this happens at the end of the data stream it may indicate trailing garbage. - -- Constant: enum LZ_errno LZ_unexpected_eof + -- Constant: enum LZ_Errno LZ_unexpected_eof The end of the data stream was reached in the middle of a member. - -- Constant: enum LZ_errno LZ_data_error + -- Constant: enum LZ_Errno LZ_data_error The data stream is corrupt. - -- Constant: enum LZ_errno LZ_library_error + -- Constant: enum LZ_Errno LZ_library_error A bug was detected in the library. Please, report it (*note Problems::). -File: lzlib.info, Node: Data Format, Next: Examples, Prev: Error Codes, Up: Top +File: lzlib.info, Node: Error Messages, Next: Data Format, Prev: Error Codes, Up: Top + +8 Error Messages +**************** + + -- Function: const char * LZ_strerror ( const enum LZ_Errno LZ_ERRNO ) + Returns the standard error message for a given error code. The + messages are fairly short; there are no multi-line messages or + embedded newlines. This function makes it easy for your program + to report informative error messages about the failure of a + library call. + + The value of LZ_ERRNO normally comes from a call to + `LZ_(de)compress_errno'. + + +File: lzlib.info, Node: Data Format, Next: Examples, Prev: Error Messages, Up: Top -7 Data Format +9 Data Format ************* In the diagram below, a box like this: @@ -433,8 +525,8 @@ with no additional information before, between, or after them. File: lzlib.info, Node: Examples, Next: Problems, Prev: Data Format, Up: Top -8 A small tutorial with examples -******************************** +10 A small tutorial with examples +********************************* This chaper shows the order in which the library functions should be called depending on what kind of data stream you want to compress or @@ -453,7 +545,18 @@ Example 1: Normal compression (MEMBER_SIZE > total output). 8) LZ_compress_close -Example 2: Decompression. +Example 2: Normal compression using LZ_compress_write_size. + + 1) LZ_compress_open + 2) go to step 5 if LZ_compress_write_size returns 0 + 3) LZ_compress_write + 4) if no more data to write, call LZ_compress_finish + 5) LZ_compress_read + 6) go back to step 2 until LZ_compress_finished returns 1 + 7) LZ_compress_close + + +Example 3: Decompression. 1) LZ_decompress_open 2) LZ_decompress_write @@ -465,24 +568,76 @@ Example 2: Decompression. 8) LZ_decompress_close -Example 3: Multimember compression (MEMBER_SIZE < total output). +Example 4: Decompression using LZ_decompress_write_size. + + 1) LZ_decompress_open + 2) go to step 5 if LZ_decompress_write_size returns 0 + 3) LZ_decompress_write + 4) if no more data to write, call LZ_decompress_finish + 5) LZ_decompress_read + 6) go back to step 2 until LZ_decompress_finished returns 1 + 7) LZ_decompress_close + + +Example 5: Multimember compression (MEMBER_SIZE < total output). + + 1) LZ_compress_open + 2) go to step 5 if LZ_compress_write_size returns 0 + 3) LZ_compress_write + 4) if no more data to write, call LZ_compress_finish + 5) LZ_compress_read + 6) go back to step 2 until LZ_compress_member_finished returns 1 + 7) go to step 10 if LZ_compress_finished() returns 1 + 8) LZ_compress_restart_member + 9) go back to step 2 + 10) LZ_compress_close + + +Example 6: Multimember compression (user-restarted members). 1) LZ_compress_open 2) LZ_compress_write 3) LZ_compress_read - 4) go back to step 2 until LZ_compress_member_finished returns 1 - 5) LZ_compress_restart_member - 6) go back to step 2 until all input data has been written - 7) LZ_compress_finish - 8) LZ_compress_read - 9) go back to step 8 until LZ_compress_finished returns 1 - 10) LZ_compress_close + 4) go back to step 2 until member termination is desired + 5) LZ_compress_finish + 6) LZ_compress_read + 7) go back to step 6 until LZ_compress_member_finished returns 1 + 8) verify that LZ_compress_finished returns 1 + 9) go to step 12 if all input data has been written + 10) LZ_compress_restart_member + 11) go back to step 2 + 12) LZ_compress_close + + +Example 7: Decompression with automatic removal of leading garbage. + + 1) LZ_decompress_open + 2) LZ_decompress_sync_to_member + 3) go to step 6 if LZ_decompress_write_size returns 0 + 4) LZ_decompress_write + 5) if no more data to write, call LZ_decompress_finish + 6) LZ_decompress_read + 7) go back to step 3 until LZ_decompress_finished returns 1 + 8) LZ_decompress_close + + +Example 8: Streamed decompression with automatic resynchronization to +next member in case of data error. + + 1) LZ_decompress_open + 2) go to step 5 if LZ_decompress_write_size returns 0 + 3) LZ_decompress_write + 4) if no more data to write, call LZ_decompress_finish + 5) if LZ_decompress_read produces LZ_header_error or LZ_data_error, + call LZ_decompress_sync_to_member + 6) go back to step 2 until LZ_decompress_finished returns 1 + 7) LZ_decompress_close File: lzlib.info, Node: Problems, Next: Concept Index, Prev: Examples, Up: Top -9 Reporting Bugs -**************** +11 Reporting Bugs +***************** There are probably bugs in Lzlib. There are certainly errors and omissions in this manual. If you report them, they will get fixed. If @@ -510,24 +665,28 @@ Concept Index * decompression functions: Decompression Functions. (line 6) * error codes: Error Codes. (line 6) +* error messages: Error Messages. (line 6) * examples: Examples. (line 6) * getting help: Problems. (line 6) * introduction: Introduction. (line 6) * library version: Library Version. (line 6) +* parameter limits: Parameter Limits. (line 6) Tag Table: Node: Top219 -Node: Introduction1028 -Node: Library Version2803 -Node: Buffering3448 -Node: Compression Functions4555 -Node: Decompression Functions10057 -Node: Error Codes13495 -Node: Data Format15431 -Node: Examples17398 -Node: Problems18832 -Node: Concept Index19402 +Node: Introduction1157 +Node: Library Version2932 +Node: Buffering3577 +Node: Parameter Limits4697 +Node: Compression Functions5654 +Node: Decompression Functions11700 +Node: Error Codes16762 +Node: Error Messages18701 +Node: Data Format19280 +Node: Examples21250 +Node: Problems24826 +Node: Concept Index25398 End Tag Table diff --git a/doc/lzlib.texinfo b/doc/lzlib.texinfo index a824739..ae22e44 100644 --- a/doc/lzlib.texinfo +++ b/doc/lzlib.texinfo @@ -5,8 +5,8 @@ @finalout @c %**end of header -@set UPDATED 20 October 2009 -@set VERSION 0.7 +@set UPDATED 17 January 2010 +@set VERSION 0.8 @dircategory Data Compression @direntry @@ -35,9 +35,11 @@ This manual is for Lzlib (version @value{VERSION}, @value{UPDATED}). * Introduction:: Purpose and features of Lzlib * Library Version:: Checking library version * Buffering:: Sizes of Lzlib's buffers +* Parameter Limits:: Min / max values for some parameters * Compression Functions:: Descriptions of the compression functions * Decompression Functions:: Descriptions of the decompression functions * Error Codes:: Meaning of codes returned by functions +* Error Messages:: Error messages corresponding to error codes * Data Format:: Detailed format of the compressed data * Examples:: A small tutorial with examples * Problems:: Reporting bugs @@ -45,7 +47,7 @@ This manual is for Lzlib (version @value{VERSION}, @value{UPDATED}). @end menu @sp 1 -Copyright @copyright{} 2009 Antonio Diaz Diaz. +Copyright @copyright{} 2009, 2010 Antonio Diaz Diaz. This manual is free documentation: you have unlimited permission to copy, distribute and modify it. @@ -139,11 +141,43 @@ is larger. @item Output decompression buffer. Read from by the @samp{LZ_decompress_read} function. Its size is the dictionary size set -with the @samp{LZ_decompress_open} function or 64KiB, whichever is -larger. +in the header of the member currently being decompressed or 64KiB, +whichever is larger. @end itemize +@node Parameter Limits +@chapter Parameter Limits +@cindex parameter limits + +These functions provide minimum and maximum values for some parameters. +Current values are shown in square brackets. + +@deftypefun int LZ_min_dictionary_bits ( void ) +Returns the base 2 logarithm of the smallest valid dictionary size [12]. +@end deftypefun + +@deftypefun int LZ_min_dictionary_size ( void ) +Returns the smallest valid dictionary size [4KiB]. +@end deftypefun + +@deftypefun int LZ_max_dictionary_bits ( void ) +Returns the base 2 logarithm of the largest valid dictionary size [29]. +@end deftypefun + +@deftypefun int LZ_max_dictionary_size ( void ) +Returns the largest valid dictionary size [512MiB]. +@end deftypefun + +@deftypefun int LZ_min_match_len_limit ( void ) +Returns the smallest valid match length limit [5]. +@end deftypefun + +@deftypefun int LZ_max_match_len_limit ( void ) +Returns the largest valid match length limit [273]. +@end deftypefun + + @node Compression Functions @chapter Compression Functions @cindex compression functions @@ -153,10 +187,11 @@ them return -1, except @samp{LZ_compress_open} whose return value must be verified by calling @samp{LZ_compress_errno} before using it. -@deftypefun {void *} LZ_compress_open ( const int @var{dictionary_size}, const int @var{match_len_limit}, const long long @var{member_size} ) +@deftypefun {struct LZ_Encoder *} LZ_compress_open ( const int @var{dictionary_size}, const int @var{match_len_limit}, const long long @var{member_size} ) Initializes the internal stream state for compression and returns a pointer that can only be used as the @var{encoder} argument for the -other LZ_compress functions. +other LZ_compress functions, or a null pointer if the encoder could not +be allocated. The returned pointer must be verified by calling @samp{LZ_compress_errno} before using it. If @samp{LZ_compress_errno} @@ -180,15 +215,7 @@ for example LLONG_MAX. @end deftypefun -@deftypefun int LZ_compress_restart_member ( void * const @var{encoder}, const long long @var{member_size} ) -Use this function to start a new member, in a multimember data stream. -Call this function only after @samp{LZ_compress_member_finished} -indicates that the current member has been fully read (with the -@samp{LZ_compress_read} function). -@end deftypefun - - -@deftypefun int LZ_compress_close ( void * const @var{encoder} ) +@deftypefun int LZ_compress_close ( struct LZ_Encoder * const @var{encoder} ) Frees all dynamically allocated data structures for this stream. This function discards any unprocessed input and does not flush any pending output. After a call to @samp{LZ_compress_close}, @var{encoder} can no @@ -196,13 +223,24 @@ more be used as an argument to any LZ_compress function. @end deftypefun -@deftypefun int LZ_compress_finish ( void * const @var{encoder} ) -Use this function to tell @samp{lzlib} that all the data for this stream +@deftypefun int LZ_compress_finish ( struct LZ_Encoder * const @var{encoder} ) +Use this function to tell @samp{lzlib} that all the data for this member has already been written (with the @samp{LZ_compress_write} function). +After all the produced compressed data has been read with +@samp{LZ_compress_read} and @samp{LZ_compress_member_finished} returns +1, a new member can be started with @samp{LZ_compress_restart_member}. @end deftypefun -@deftypefun int LZ_compress_sync_flush ( void * const @var{encoder} ) +@deftypefun int LZ_compress_restart_member ( struct LZ_Encoder * const @var{encoder}, const long long @var{member_size} ) +Use this function to start a new member, in a multimember data stream. +Call this function only after @samp{LZ_compress_member_finished} +indicates that the current member has been fully read (with the +@samp{LZ_compress_read} function). +@end deftypefun + + +@deftypefun int LZ_compress_sync_flush ( struct LZ_Encoder * const @var{encoder} ) Use this function to make available to @samp{LZ_compress_read} all the data already written with the @samp{LZ_compress_write} function. Repeated use of @samp{LZ_compress_sync_flush} may degrade compression @@ -210,7 +248,7 @@ ratio, so use it only when needed. @end deftypefun -@deftypefun int LZ_compress_read ( void * const @var{encoder}, uint8_t * const @var{buffer}, const int @var{size} ) +@deftypefun int LZ_compress_read ( struct LZ_Encoder * const @var{encoder}, uint8_t * const @var{buffer}, const int @var{size} ) The @samp{LZ_compress_read} function reads up to @var{size} bytes from the stream pointed to by @var{encoder}, storing the results in @var{buffer}. @@ -223,7 +261,7 @@ in the stream or if more bytes have to be yet written with the @end deftypefun -@deftypefun int LZ_compress_write ( void * const @var{encoder}, uint8_t * const @var{buffer}, const int @var{size} ) +@deftypefun int LZ_compress_write ( struct LZ_Encoder * const @var{encoder}, uint8_t * const @var{buffer}, const int @var{size} ) The @samp{LZ_compress_write} function writes up to @var{size} bytes from @var{buffer} to the stream pointed to by @var{encoder}. @@ -233,7 +271,7 @@ not an error. @end deftypefun -@deftypefun int LZ_compress_write_size ( void * const @var{encoder} ) +@deftypefun int LZ_compress_write_size ( struct LZ_Encoder * const @var{encoder} ) The @samp{LZ_compress_write_size} function returns the maximum number of bytes that can be inmediately written through the @samp{LZ_compress_write} function. @@ -243,42 +281,42 @@ accept a @var{size} up to the returned number of bytes. @end deftypefun -@deftypefun {enum LZ_errno} LZ_compress_errno ( void * const @var{encoder} ) +@deftypefun {enum LZ_Errno} LZ_compress_errno ( struct LZ_Encoder * const @var{encoder} ) Returns the current error code for @var{encoder} (@pxref{Error Codes}) @end deftypefun -@deftypefun int LZ_compress_finished ( void * const @var{encoder} ) +@deftypefun int LZ_compress_finished ( struct LZ_Encoder * const @var{encoder} ) Returns 1 if all the data has been read and @samp{LZ_compress_close} can be safely called. Otherwise it returns 0. @end deftypefun -@deftypefun int LZ_compress_member_finished ( void * const @var{encoder} ) +@deftypefun int LZ_compress_member_finished ( struct LZ_Encoder * const @var{encoder} ) Returns 1 if the current member, in a multimember data stream, has been fully read and @samp{LZ_compress_restart_member} can be safely called. Otherwise it returns 0. @end deftypefun -@deftypefun {long long} LZ_compress_data_position ( void * const @var{encoder} ) +@deftypefun {long long} LZ_compress_data_position ( struct LZ_Encoder * const @var{encoder} ) Returns the number of input bytes already compressed in the current member. @end deftypefun -@deftypefun {long long} LZ_compress_member_position ( void * const @var{encoder} ) +@deftypefun {long long} LZ_compress_member_position ( struct LZ_Encoder * const @var{encoder} ) Returns the number of compressed bytes already produced, but perhaps not yet read, in the current member. @end deftypefun -@deftypefun {long long} LZ_compress_total_in_size ( void * const @var{encoder} ) +@deftypefun {long long} LZ_compress_total_in_size ( struct LZ_Encoder * const @var{encoder} ) Returns the total number of input bytes already compressed. @end deftypefun -@deftypefun {long long} LZ_compress_total_out_size ( void * const @var{encoder} ) +@deftypefun {long long} LZ_compress_total_out_size ( struct LZ_Encoder * const @var{encoder} ) Returns the total number of compressed bytes already produced, but perhaps not yet read. @end deftypefun @@ -293,10 +331,11 @@ of them return -1, except @samp{LZ_decompress_open} whose return value must be verified by calling @samp{LZ_decompress_errno} before using it. -@deftypefun {void *} LZ_decompress_open ( void ) +@deftypefun {struct LZ_Decoder *} LZ_decompress_open ( void ) Initializes the internal stream state for decompression and returns a pointer that can only be used as the @var{decoder} argument for the -other LZ_decompress functions. +other LZ_decompress functions, or a null pointer if the decoder could +not be allocated. The returned pointer must be verified by calling @samp{LZ_decompress_errno} before using it. If @@ -306,7 +345,7 @@ pointer must not be used and should be freed with @end deftypefun -@deftypefun int LZ_decompress_close ( void * const @var{decoder} ) +@deftypefun int LZ_decompress_close ( struct LZ_Decoder * const @var{decoder} ) Frees all dynamically allocated data structures for this stream. This function discards any unprocessed input and does not flush any pending output. After a call to @samp{LZ_decompress_close}, @var{decoder} can no @@ -314,13 +353,34 @@ more be used as an argument to any LZ_decompress function. @end deftypefun -@deftypefun int LZ_decompress_finish ( void * const @var{decoder} ) +@deftypefun int LZ_decompress_finish ( struct LZ_Decoder * const @var{decoder} ) Use this function to tell @samp{lzlib} that all the data for this stream has already been written (with the @samp{LZ_decompress_write} function). @end deftypefun -@deftypefun int LZ_decompress_read ( void * const @var{decoder}, uint8_t * const @var{buffer}, const int @var{size} ) +@deftypefun int LZ_decompress_reset ( struct LZ_Decoder * const @var{decoder} ) +Resets the internal state of @var{decoder} as it was just after opening +it with the @samp{LZ_decompress_open} function. Data stored in the +internal buffers is discarded. Position counters are set to 0. +@end deftypefun + + +@deftypefun int LZ_decompress_sync_to_member ( struct LZ_Decoder * const @var{decoder} ) +Resets the error state of @var{decoder} and enters a search state that +lasts until a new member header (or the end of the stream) is found. +After a successful call to @samp{LZ_decompress_sync_to_member}, data +written with @samp{LZ_decompress_write} will be consumed and +@samp{LZ_decompress_read} will return 0 until a header is found. + +This function is useful to discard any data preceding the first member, +or to discard the rest of the current member, for example in case of a +data error. If the decoder is already at the beginning of a member, this +function does nothing. +@end deftypefun + + +@deftypefun int LZ_decompress_read ( struct LZ_Decoder * const @var{decoder}, uint8_t * const @var{buffer}, const int @var{size} ) The @samp{LZ_decompress_read} function reads up to @var{size} bytes from the stream pointed to by @var{decoder}, storing the results in @var{buffer}. @@ -333,7 +393,7 @@ in the stream or if more bytes have to be yet written with the @end deftypefun -@deftypefun int LZ_decompress_write ( void * const @var{decoder}, uint8_t * const @var{buffer}, const int @var{size} ) +@deftypefun int LZ_decompress_write ( struct LZ_Decoder * const @var{decoder}, uint8_t * const @var{buffer}, const int @var{size} ) The @samp{LZ_decompress_write} function writes up to @var{size} bytes from @var{buffer} to the stream pointed to by @var{decoder}. @@ -343,35 +403,45 @@ not an error. @end deftypefun -@deftypefun {enum LZ_errno} LZ_decompress_errno ( void * const @var{decoder} ) +@deftypefun int LZ_decompress_write_size ( struct LZ_Decoder * const @var{decoder} ) +The @samp{LZ_decompress_write_size} function returns the maximum number +of bytes that can be inmediately written through the +@samp{LZ_decompress_write} function. + +It is guaranteed that an inmediate call to @samp{LZ_decompress_write} +will accept a @var{size} up to the returned number of bytes. +@end deftypefun + + +@deftypefun {enum LZ_Errno} LZ_decompress_errno ( struct LZ_Decoder * const @var{decoder} ) Returns the current error code for @var{decoder} (@pxref{Error Codes}) @end deftypefun -@deftypefun int LZ_decompress_finished ( void * const @var{decoder} ) +@deftypefun int LZ_decompress_finished ( struct LZ_Decoder * const @var{decoder} ) Returns 1 if all the data has been read and @samp{LZ_decompress_close} can be safely called. Otherwise it returns 0. @end deftypefun -@deftypefun {long long} LZ_decompress_data_position ( void * const @var{decoder} ) +@deftypefun {long long} LZ_decompress_data_position ( struct LZ_Decoder * const @var{decoder} ) Returns the number of decompressed bytes already produced, but perhaps not yet read, in the current member. @end deftypefun -@deftypefun {long long} LZ_decompress_member_position ( void * const @var{decoder} ) +@deftypefun {long long} LZ_decompress_member_position ( struct LZ_Decoder * const @var{decoder} ) Returns the number of input bytes already decompressed in the current member. @end deftypefun -@deftypefun {long long} LZ_decompress_total_in_size ( void * const @var{decoder} ) +@deftypefun {long long} LZ_decompress_total_in_size ( struct LZ_Decoder * const @var{decoder} ) Returns the total number of input bytes already decompressed. @end deftypefun -@deftypefun {long long} LZ_decompress_total_out_size ( void * const @var{decoder} ) +@deftypefun {long long} LZ_decompress_total_out_size ( struct LZ_Decoder * const @var{decoder} ) Returns the total number of decompressed bytes already produced, but perhaps not yet read. @end deftypefun @@ -395,46 +465,61 @@ examine @samp{LZ_(de)compress_errno}. The error codes are defined in the header file @samp{lzlib.h}. -@deftypevr Constant {enum LZ_errno} LZ_ok +@deftypevr Constant {enum LZ_Errno} LZ_ok The value of this constant is 0 and is used to indicate that there is no error. @end deftypevr -@deftypevr Constant {enum LZ_errno} LZ_bad_argument +@deftypevr Constant {enum LZ_Errno} LZ_bad_argument At least one of the arguments passed to the library function was invalid. @end deftypevr -@deftypevr Constant {enum LZ_errno} LZ_mem_error +@deftypevr Constant {enum LZ_Errno} LZ_mem_error No memory available. The system cannot allocate more virtual memory because its capacity is full. @end deftypevr -@deftypevr Constant {enum LZ_errno} LZ_sequence_error +@deftypevr Constant {enum LZ_Errno} LZ_sequence_error A library function was called in the wrong order. For example @samp{LZ_compress_restart_member} was called before @samp{LZ_compress_member_finished} indicates that the current member is finished. @end deftypevr -@deftypevr Constant {enum LZ_errno} LZ_header_error +@deftypevr Constant {enum LZ_Errno} LZ_header_error Reading of member header failed. If this happens at the end of the data stream it may indicate trailing garbage. @end deftypevr -@deftypevr Constant {enum LZ_errno} LZ_unexpected_eof +@deftypevr Constant {enum LZ_Errno} LZ_unexpected_eof The end of the data stream was reached in the middle of a member. @end deftypevr -@deftypevr Constant {enum LZ_errno} LZ_data_error +@deftypevr Constant {enum LZ_Errno} LZ_data_error The data stream is corrupt. @end deftypevr -@deftypevr Constant {enum LZ_errno} LZ_library_error +@deftypevr Constant {enum LZ_Errno} LZ_library_error A bug was detected in the library. Please, report it (@pxref{Problems}). @end deftypevr +@node Error Messages +@chapter Error Messages +@cindex error messages + +@deftypefun {const char *} LZ_strerror ( const enum LZ_Errno @var{lz_errno} ) +Returns the standard error message for a given error code. The messages +are fairly short; there are no multi-line messages or embedded newlines. +This function makes it easy for your program to report informative error +messages about the failure of a library call. + +The value of @var{lz_errno} normally comes from a call to +@samp{LZ_(de)compress_errno}. +@end deftypefun + + @node Data Format @chapter Data Format @cindex data format @@ -528,7 +613,22 @@ Example 1: Normal compression (@var{member_size} > total output). @sp 1 @noindent -Example 2: Decompression. +Example 2: Normal compression using LZ_compress_write_size. + +@example +1) LZ_compress_open +2) go to step 5 if LZ_compress_write_size returns 0 +3) LZ_compress_write +4) if no more data to write, call LZ_compress_finish +5) LZ_compress_read +6) go back to step 2 until LZ_compress_finished returns 1 +7) LZ_compress_close +@end example + + +@sp 1 +@noindent +Example 3: Decompression. @example 1) LZ_decompress_open @@ -544,19 +644,87 @@ Example 2: Decompression. @sp 1 @noindent -Example 3: Multimember compression (@var{member_size} < total output). +Example 4: Decompression using LZ_decompress_write_size. + +@example +1) LZ_decompress_open +2) go to step 5 if LZ_decompress_write_size returns 0 +3) LZ_decompress_write +4) if no more data to write, call LZ_decompress_finish +5) LZ_decompress_read +6) go back to step 2 until LZ_decompress_finished returns 1 +7) LZ_decompress_close +@end example + + +@sp 1 +@noindent +Example 5: Multimember compression (@var{member_size} < total output). + +@example + 1) LZ_compress_open + 2) go to step 5 if LZ_compress_write_size returns 0 + 3) LZ_compress_write + 4) if no more data to write, call LZ_compress_finish + 5) LZ_compress_read + 6) go back to step 2 until LZ_compress_member_finished returns 1 + 7) go to step 10 if LZ_compress_finished() returns 1 + 8) LZ_compress_restart_member + 9) go back to step 2 +10) LZ_compress_close +@end example + + +@sp 1 +@noindent +Example 6: Multimember compression (user-restarted members). @example 1) LZ_compress_open 2) LZ_compress_write 3) LZ_compress_read - 4) go back to step 2 until LZ_compress_member_finished returns 1 - 5) LZ_compress_restart_member - 6) go back to step 2 until all input data has been written - 7) LZ_compress_finish - 8) LZ_compress_read - 9) go back to step 8 until LZ_compress_finished returns 1 -10) LZ_compress_close + 4) go back to step 2 until member termination is desired + 5) LZ_compress_finish + 6) LZ_compress_read + 7) go back to step 6 until LZ_compress_member_finished returns 1 + 8) verify that LZ_compress_finished returns 1 + 9) go to step 12 if all input data has been written +10) LZ_compress_restart_member +11) go back to step 2 +12) LZ_compress_close +@end example + + +@sp 1 +@noindent +Example 7: Decompression with automatic removal of leading garbage. + +@example +1) LZ_decompress_open +2) LZ_decompress_sync_to_member +3) go to step 6 if LZ_decompress_write_size returns 0 +4) LZ_decompress_write +5) if no more data to write, call LZ_decompress_finish +6) LZ_decompress_read +7) go back to step 3 until LZ_decompress_finished returns 1 +8) LZ_decompress_close +@end example + + +@sp 1 +@noindent +Example 8: Streamed decompression with automatic resynchronization to +next member in case of data error. + +@example +1) LZ_decompress_open +2) go to step 5 if LZ_decompress_write_size returns 0 +3) LZ_decompress_write +4) if no more data to write, call LZ_decompress_finish +5) if LZ_decompress_read produces LZ_header_error or LZ_data_error, + call LZ_decompress_sync_to_member +6) go back to step 2 until LZ_decompress_finished returns 1 +7) LZ_decompress_close @end example @@ -1,5 +1,5 @@ /* Lzlib - A compression library for lzip files - Copyright (C) 2009 Antonio Diaz Diaz. + Copyright (C) 2009, 2010 Antonio Diaz Diaz. This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ 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, see <http://www.gnu.org/licenses/>. + along with this library. If not, see <http://www.gnu.org/licenses/>. As a special exception, you may use this file as part of a free software library without restriction. Specifically, if other files @@ -31,8 +31,6 @@ #include <cerrno> #include <cstdlib> #include <cstring> -#include <string> -#include <vector> #include <stdint.h> #include "lzlib.h" @@ -87,11 +85,12 @@ Matchfinder::Matchfinder( const int dict_size, const int len_limit ) void Matchfinder::reset() throw() { const int size = stream_pos - pos; - std::memmove( buffer, buffer + pos, size ); + if( size > 0 ) std::memmove( buffer, buffer + pos, size ); partial_data_pos = 0; stream_pos -= pos; pos = 0; cyclic_pos = 0; + at_stream_end_ = false; for( int i = 0; i < num_prev_positions; ++i ) prev_positions[i] = -1; } @@ -1,5 +1,5 @@ /* Lzlib - A compression library for lzip files - Copyright (C) 2009 Antonio Diaz Diaz. + Copyright (C) 2009, 2010 Antonio Diaz Diaz. This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ 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, see <http://www.gnu.org/licenses/>. + along with this library. If not, see <http://www.gnu.org/licenses/>. As a special exception, you may use this file as part of a free software library without restriction. Specifically, if other files @@ -186,7 +186,8 @@ public: int dictionary_size() const throw() { return dictionary_size_; } void flushing( const bool b ) throw() { at_stream_end_ = b; } bool finished() const throw() { return at_stream_end_ && pos >= stream_pos; } - int free_bytes() const throw() { return buffer_size - stream_pos; } + int free_bytes() const throw() + { if( at_stream_end_ ) return 0; return buffer_size - stream_pos; } int match_len_limit() const throw() { return match_len_limit_; } const uint8_t * ptr_to_current_pos() const throw() { return buffer + pos; } @@ -234,14 +235,14 @@ class Range_encoder : public Circular_buffer void shift_low() { const uint32_t carry = low >> 32; - if( low < 0xFF000000 || carry == 1 ) + if( low < 0xFF000000LL || carry == 1 ) { put_byte( cache + carry ); for( ; ff_count > 0; --ff_count ) put_byte( 0xFF + carry ); cache = low >> 24; } else ++ff_count; - low = ( low & 0x00FFFFFF ) << 8; + low = ( low & 0x00FFFFFFLL ) << 8; } public: @@ -1,5 +1,5 @@ /* Lzcheck - A test program for the lzlib library - Copyright (C) 2009 Antonio Diaz Diaz. + Copyright (C) 2009, 2010 Antonio Diaz Diaz. This program is free software: you have unlimited permission to copy, distribute and modify it. @@ -8,9 +8,13 @@ lzcheck filename.txt This program reads the specified text file and then compresses it, - line by line, to test the flushing mechanism. + line by line, to test the flushing mechanism and the member + restart/reset/sync functions. */ +#define _FILE_OFFSET_BITS 64 + +#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> @@ -29,7 +33,7 @@ #define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL #endif -const int buffer_size = 65536; +const int buffer_size = 32768; uint8_t in_buffer[buffer_size]; uint8_t mid_buffer[buffer_size]; uint8_t out_buffer[buffer_size]; @@ -54,8 +58,8 @@ int main( const int argc, const char * argv[] ) const int dictionary_size = 1 << 20; const int match_len_limit = 80; const long long member_size = LLONG_MAX; - void * encoder = LZ_compress_open( dictionary_size, match_len_limit, - member_size ); + LZ_Encoder * encoder = LZ_compress_open( dictionary_size, match_len_limit, + member_size ); if( !encoder || LZ_compress_errno( encoder ) != LZ_ok ) { const bool mem_error = ( LZ_compress_errno( encoder ) == LZ_mem_error ); @@ -69,7 +73,7 @@ int main( const int argc, const char * argv[] ) return 3; } - void * decoder = LZ_decompress_open(); + LZ_Decoder * decoder = LZ_decompress_open(); if( !decoder || LZ_decompress_errno( decoder ) != LZ_ok ) { LZ_decompress_close( decoder ); @@ -77,35 +81,91 @@ int main( const int argc, const char * argv[] ) return 1; } - while( true ) + int retval = 0; + while( retval <= 2 ) { - const int read_size = std::fread( in_buffer, 1, buffer_size, file ); - if( read_size <= 0 ) break; + const int read_size = std::fread( in_buffer, 1, buffer_size / 2, file ); + if( read_size <= 0 ) break; // end of file for( int l = 0, r = 1; r <= read_size; l = r, ++r ) { while( r < read_size && in_buffer[r-1] != '\n' ) ++r; + const int leading_garbage = (l == 0) ? std::min( r, read_size / 2 ) : 0; const int in_size = LZ_compress_write( encoder, in_buffer + l, r - l ); if( in_size < r - l ) r = l + in_size; LZ_compress_sync_flush( encoder ); - const int mid_size = LZ_compress_read( encoder, mid_buffer, buffer_size ); - LZ_decompress_write( decoder, mid_buffer, mid_size ); - const int out_size = LZ_decompress_read( decoder, out_buffer, buffer_size ); + if( leading_garbage ) + std::memset( mid_buffer, in_buffer[0], leading_garbage ); + const int mid_size = LZ_compress_read( encoder, + mid_buffer + leading_garbage, + buffer_size - leading_garbage ); + if( mid_size < 0 ) + { + std::fprintf( stderr, "LZ_compress_read error: %s.\n", + LZ_strerror( LZ_compress_errno( encoder ) ) ); + retval = 3; break; + } + LZ_decompress_write( decoder, mid_buffer, mid_size + leading_garbage ); + int out_size = LZ_decompress_read( decoder, out_buffer, buffer_size ); + if( out_size < 0 ) + { + if( LZ_decompress_errno( decoder ) == LZ_header_error || + LZ_decompress_errno( decoder ) == LZ_data_error ) + { + LZ_decompress_sync_to_member( decoder ); // remove leading garbage + out_size = LZ_decompress_read( decoder, out_buffer, buffer_size ); + } + if( out_size < 0 ) + { + std::fprintf( stderr, "LZ_decompress_read error: %s.\n", + LZ_strerror( LZ_decompress_errno( decoder ) ) ); + retval = 3; break; + } + } if( out_size != in_size || std::memcmp( in_buffer + l, out_buffer, out_size ) ) { - std::printf( "sync error at pos %d. in_size = %d, out_size = %d\n", - l, in_size, out_size ); - for( int i = 0; i < in_size; ++i ) std::putchar( in_buffer[l+i] ); - if( in_buffer[l+in_size-1] != '\n' ) std::putchar( '\n' ); - for( int i = 0; i < out_size; ++i ) std::putchar( out_buffer[i] ); - std::putchar( '\n' ); + std::fprintf( stderr, "sync error at pos %d. in_size = %d, out_size = %d\n", + l, in_size, out_size ); + for( int i = 0; i < in_size; ++i ) + std::fputc( in_buffer[l+i], stderr ); + if( in_buffer[l+in_size-1] != '\n' ) + std::fputc( '\n', stderr ); + for( int i = 0; i < out_size; ++i ) + std::fputc( out_buffer[i], stderr ); + std::fputc( '\n', stderr ); + retval = 1; } } + if( retval >= 3 ) break; + + if( LZ_compress_finish( encoder ) < 0 || + LZ_decompress_write( decoder, mid_buffer, LZ_compress_read( encoder, mid_buffer, buffer_size ) ) < 0 || + LZ_decompress_read( decoder, out_buffer, buffer_size ) != 0 || + LZ_decompress_reset( decoder ) < 0 || + LZ_compress_restart_member( encoder, member_size ) < 0 ) + { + std::fprintf( stderr, "can't restart member: %s.\n", + LZ_strerror( LZ_decompress_errno( decoder ) ) ); + retval = 3; break; + } + + const int size = std::min( 100, read_size ); + if( LZ_compress_write( encoder, in_buffer, size ) != size || + LZ_compress_finish( encoder ) < 0 || + LZ_decompress_write( decoder, mid_buffer, LZ_compress_read( encoder, mid_buffer, buffer_size ) ) < 0 || + LZ_decompress_read( decoder, out_buffer, 0 ) != 0 || + LZ_decompress_sync_to_member( decoder ) < 0 || + LZ_compress_restart_member( encoder, member_size ) < 0 ) + { + std::fprintf( stderr, "can't seek to next member: %s.\n", + LZ_strerror( LZ_decompress_errno( decoder ) ) ); + retval = 3; break; + } } LZ_decompress_close( decoder ); LZ_compress_close( encoder ); std::fclose( file ); - return 0; + return retval; } @@ -1,5 +1,5 @@ /* Lzlib - A compression library for lzip files - Copyright (C) 2009 Antonio Diaz Diaz. + Copyright (C) 2009, 2010 Antonio Diaz Diaz. This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ 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, see <http://www.gnu.org/licenses/>. + along with this library. If not, see <http://www.gnu.org/licenses/>. As a special exception, you may use this file as part of a free software library without restriction. Specifically, if other files @@ -58,6 +58,10 @@ public: }; +const int min_dictionary_bits = 12; +const int min_dictionary_size = 1 << min_dictionary_bits; +const int max_dictionary_bits = 29; +const int max_dictionary_size = 1 << max_dictionary_bits; const int literal_context_bits = 3; const int pos_state_bits = 2; const int pos_states = 1 << pos_state_bits; @@ -80,6 +84,7 @@ const int max_len_symbols = len_low_symbols + len_mid_symbols + len_high_symbols const int min_match_len = 2; // must be 2 const int max_match_len = min_match_len + max_len_symbols - 1; // 273 +const int min_match_len_limit = 5; const int max_dis_states = 4; @@ -152,6 +157,13 @@ struct File_header return ( version <= 1 ); } + bool verify() const throw() + { + return ( verify_magic() && verify_version() && + dictionary_size() >= min_dictionary_size && + dictionary_size() <= max_dictionary_size ); + } + static int real_bits( const int value ) throw() { int bits = 0; @@ -241,9 +253,9 @@ struct File_trailer class Circular_buffer { protected: - const int buffer_size; + const int buffer_size; // capacity == buffer_size - 1 uint8_t * const buffer; - int get; + int get; // buffer is empty when get == put int put; void reset() throw() { get = 0; put = 0; } @@ -1,5 +1,5 @@ /* Lzlib - A compression library for lzip files - Copyright (C) 2009 Antonio Diaz Diaz. + Copyright (C) 2009, 2010 Antonio Diaz Diaz. This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ 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, see <http://www.gnu.org/licenses/>. + along with this library. If not, see <http://www.gnu.org/licenses/>. As a special exception, you may use this file as part of a free software library without restriction. Specifically, if other files @@ -27,7 +27,6 @@ #include <algorithm> #include <cstring> -#include <vector> #include <stdint.h> #include "lzlib.h" @@ -36,19 +35,18 @@ #include "encoder.h" -namespace { - -struct Encoder +struct LZ_Encoder { long long partial_in_size; long long partial_out_size; Matchfinder * matchfinder; LZ_encoder * lz_encoder; - LZ_errno lz_errno; + LZ_Errno lz_errno; int flush_pending; const File_header member_header; + bool fatal; - Encoder( const File_header & header ) throw() + LZ_Encoder( const File_header & header ) throw() : partial_in_size( 0 ), partial_out_size( 0 ), @@ -56,67 +54,96 @@ struct Encoder lz_encoder( 0 ), lz_errno( LZ_ok ), flush_pending( 0 ), - member_header( header ) + member_header( header ), + fatal( false ) {} }; -bool verify_encoder( void * const encoder ) +bool verify_encoder( LZ_Encoder * const encoder ) { if( !encoder ) return false; - Encoder & e = *(Encoder *)encoder; - if( !e.matchfinder || !e.lz_encoder ) - { e.lz_errno = LZ_bad_argument; return false; } + if( !encoder->matchfinder || !encoder->lz_encoder ) + { encoder->lz_errno = LZ_bad_argument; return false; } return true; } -struct Decoder +struct LZ_Decoder { long long partial_in_size; long long partial_out_size; Input_buffer * ibuf; LZ_decoder * lz_decoder; - LZ_errno lz_errno; + LZ_Errno lz_errno; + bool fatal; + bool seeking; - Decoder() throw() + LZ_Decoder() throw() : partial_in_size( 0 ), partial_out_size( 0 ), ibuf( 0 ), lz_decoder( 0 ), - lz_errno( LZ_ok ) + lz_errno( LZ_ok ), + fatal( false ), + seeking( false ) {} }; -bool verify_decoder( void * const decoder ) +bool verify_decoder( struct LZ_Decoder * const decoder ) { if( !decoder ) return false; - if( !((Decoder *)decoder)->ibuf ) - { ((Decoder *)decoder)->lz_errno = LZ_bad_argument; return false; } + if( !decoder->ibuf ) + { decoder->lz_errno = LZ_bad_argument; return false; } return true; } -} // end namespace +const char * LZ_version() { return LZ_version_string; } +const char * LZ_strerror( const LZ_Errno lz_errno ) + { + switch( lz_errno ) + { + case LZ_ok : return "ok"; + case LZ_bad_argument : return "bad argument"; + case LZ_mem_error : return "not enough memory"; + case LZ_sequence_error: return "sequence error"; + case LZ_header_error : return "header error"; + case LZ_unexpected_eof: return "unexpected eof"; + case LZ_data_error : return "data error"; + case LZ_library_error : return "library error"; + } + return "invalid error code"; + } -const char * LZ_version() { return LZ_version_string; } +int LZ_min_dictionary_bits() { return min_dictionary_bits; } +int LZ_min_dictionary_size() { return min_dictionary_size; } +int LZ_max_dictionary_bits() { return max_dictionary_bits; } +int LZ_max_dictionary_size() { return max_dictionary_size; } +int LZ_min_match_len_limit() { return min_match_len_limit; } +int LZ_max_match_len_limit() { return max_match_len; } -void * LZ_compress_open( const int dictionary_size, const int match_len_limit, - const long long member_size ) + +/*---------------------- Compression Functions ----------------------*/ + +LZ_Encoder * LZ_compress_open( const int dictionary_size, + const int match_len_limit, + const long long member_size ) { File_header header; header.set_magic(); const bool error = ( !header.dictionary_size( dictionary_size ) || - match_len_limit < 5 || match_len_limit > max_match_len ); + match_len_limit < min_match_len_limit || + match_len_limit > max_match_len ); - Encoder * encoder = new( std::nothrow ) Encoder( header ); + LZ_Encoder * encoder = new( std::nothrow ) LZ_Encoder( header ); if( !encoder ) return 0; - Encoder & e = *encoder; + LZ_Encoder & e = *encoder; if( error ) e.lz_errno = LZ_bad_argument; else { @@ -138,15 +165,35 @@ void * LZ_compress_open( const int dictionary_size, const int match_len_limit, } if( !e.lz_encoder ) e.lz_errno = LZ_mem_error; } + if( e.lz_errno != LZ_ok ) e.fatal = true; return encoder; } -int LZ_compress_restart_member( void * const encoder, +int LZ_compress_close( LZ_Encoder * const encoder ) + { + if( !encoder ) return -1; + if( encoder->lz_encoder ) delete encoder->lz_encoder; + if( encoder->matchfinder ) delete encoder->matchfinder; + delete encoder; + return 0; + } + + +int LZ_compress_finish( LZ_Encoder * const encoder ) + { + if( !verify_encoder( encoder ) || encoder->fatal ) return -1; + encoder->matchfinder->flushing( true ); + encoder->flush_pending = 0; + return 0; + } + + +int LZ_compress_restart_member( LZ_Encoder * const encoder, const long long member_size ) { - if( !verify_encoder( encoder ) ) return -1; - Encoder & e = *(Encoder *)encoder; + if( !verify_encoder( encoder ) || encoder->fatal ) return -1; + LZ_Encoder & e = *encoder; if( !e.lz_encoder->member_finished() ) { e.lz_errno = LZ_sequence_error; return -1; } @@ -159,42 +206,22 @@ int LZ_compress_restart_member( void * const encoder, e.lz_encoder = new LZ_encoder( *e.matchfinder, e.member_header, member_size ); } catch( std::bad_alloc ) - { e.lz_encoder = 0; e.lz_errno = LZ_mem_error; return -1; } - return 0; - } - - -int LZ_compress_close( void * const encoder ) - { - if( !encoder ) return -1; - Encoder & e = *(Encoder *)encoder; - if( e.lz_encoder ) delete e.lz_encoder; - if( e.matchfinder ) delete e.matchfinder; - delete (Encoder *)encoder; - return 0; - } - - -int LZ_compress_finish( void * const encoder ) - { - if( !verify_encoder( encoder ) ) return -1; - Encoder & e = *(Encoder *)encoder; - e.matchfinder->flushing( true ); - e.flush_pending = 0; + { e.lz_encoder = 0; e.lz_errno = LZ_mem_error; e.fatal = true; return -1; } + e.lz_errno = LZ_ok; return 0; } -int LZ_compress_sync_flush( void * const encoder ) +int LZ_compress_sync_flush( LZ_Encoder * const encoder ) { - if( !verify_encoder( encoder ) ) return -1; - Encoder & e = *(Encoder *)encoder; + if( !verify_encoder( encoder ) || encoder->fatal ) return -1; + LZ_Encoder & e = *encoder; if( !e.flush_pending && !e.matchfinder->at_stream_end() ) { e.flush_pending = 2; // 2 consecutive markers guarantee decoding e.matchfinder->flushing( true ); if( !e.lz_encoder->encode_member( false ) ) - { e.lz_errno = LZ_library_error; return -1; } + { e.lz_errno = LZ_library_error; e.fatal = true; return -1; } while( e.flush_pending > 0 && e.lz_encoder->sync_flush() ) { if( --e.flush_pending <= 0 ) e.matchfinder->flushing( false ); } } @@ -202,127 +229,159 @@ int LZ_compress_sync_flush( void * const encoder ) } -int LZ_compress_read( void * const encoder, uint8_t * const buffer, - const int size ) +int LZ_compress_read( LZ_Encoder * const encoder, + uint8_t * const buffer, const int size ) { - if( !verify_encoder( encoder ) ) return -1; - Encoder & e = *(Encoder *)encoder; + if( !verify_encoder( encoder ) || encoder->fatal ) return -1; + LZ_Encoder & e = *encoder; if( !e.lz_encoder->encode_member( !e.flush_pending ) ) - { e.lz_errno = LZ_library_error; return -1; } + { e.lz_errno = LZ_library_error; e.fatal = true; return -1; } while( e.flush_pending > 0 && e.lz_encoder->sync_flush() ) { if( --e.flush_pending <= 0 ) e.matchfinder->flushing( false ); } return e.lz_encoder->read_data( buffer, size ); } -int LZ_compress_write( void * const encoder, const uint8_t * const buffer, - const int size ) +int LZ_compress_write( LZ_Encoder * const encoder, + const uint8_t * const buffer, const int size ) { - if( !verify_encoder( encoder ) ) return -1; - Encoder & e = *(Encoder *)encoder; - if( e.flush_pending ) return 0; - return e.matchfinder->write_data( buffer, size ); + if( !verify_encoder( encoder ) || encoder->fatal ) return -1; + if( encoder->flush_pending ) return 0; + return encoder->matchfinder->write_data( buffer, size ); } -int LZ_compress_write_size( void * const encoder ) +int LZ_compress_write_size( LZ_Encoder * const encoder ) { - if( !verify_encoder( encoder ) ) return -1; - Encoder & e = *(Encoder *)encoder; - if( e.flush_pending ) return 0; - return e.matchfinder->free_bytes(); + if( !verify_encoder( encoder ) || encoder->fatal ) return -1; + if( encoder->flush_pending ) return 0; + return encoder->matchfinder->free_bytes(); } -enum LZ_errno LZ_compress_errno( void * const encoder ) +LZ_Errno LZ_compress_errno( LZ_Encoder * const encoder ) { if( !encoder ) return LZ_bad_argument; - return ((Encoder *)encoder)->lz_errno; + return encoder->lz_errno; } -int LZ_compress_finished( void * const encoder ) +int LZ_compress_finished( LZ_Encoder * const encoder ) { if( !verify_encoder( encoder ) ) return -1; - Encoder & e = *(Encoder *)encoder; - return ( !e.flush_pending && e.matchfinder->finished() && - e.lz_encoder->member_finished() ); + return ( !encoder->flush_pending && encoder->matchfinder->finished() && + encoder->lz_encoder->member_finished() ); } -int LZ_compress_member_finished( void * const encoder ) +int LZ_compress_member_finished( LZ_Encoder * const encoder ) { if( !verify_encoder( encoder ) ) return -1; - return ((Encoder *)encoder)->lz_encoder->member_finished(); + return encoder->lz_encoder->member_finished(); } -long long LZ_compress_data_position( void * const encoder ) +long long LZ_compress_data_position( LZ_Encoder * const encoder ) { if( !verify_encoder( encoder ) ) return -1; - return ((Encoder *)encoder)->matchfinder->data_position(); + return encoder->matchfinder->data_position(); } -long long LZ_compress_member_position( void * const encoder ) +long long LZ_compress_member_position( LZ_Encoder * const encoder ) { if( !verify_encoder( encoder ) ) return -1; - return ((Encoder *)encoder)->lz_encoder->member_position(); + return encoder->lz_encoder->member_position(); } -long long LZ_compress_total_in_size( void * const encoder ) +long long LZ_compress_total_in_size( LZ_Encoder * const encoder ) { if( !verify_encoder( encoder ) ) return -1; - Encoder & e = *(Encoder *)encoder; - return e.partial_in_size + e.matchfinder->data_position(); + return encoder->partial_in_size + encoder->matchfinder->data_position(); } -long long LZ_compress_total_out_size( void * const encoder ) +long long LZ_compress_total_out_size( LZ_Encoder * const encoder ) { if( !verify_encoder( encoder ) ) return -1; - Encoder & e = *(Encoder *)encoder; - return e.partial_out_size + e.lz_encoder->member_position(); + return encoder->partial_out_size + encoder->lz_encoder->member_position(); } -void * LZ_decompress_open() +/*--------------------- Decompression Functions ---------------------*/ + +struct LZ_Decoder * LZ_decompress_open() { - Decoder * decoder = new( std::nothrow ) Decoder(); + LZ_Decoder * decoder = new( std::nothrow ) LZ_Decoder; if( !decoder ) return 0; - try { decoder->ibuf = new Input_buffer(); } + LZ_Decoder & d = *decoder; + try { d.ibuf = new Input_buffer; } catch( std::bad_alloc ) - { decoder->ibuf = 0; decoder->lz_errno = LZ_mem_error; } + { d.ibuf = 0; d.lz_errno = LZ_mem_error; d.fatal = true; } return decoder; } -int LZ_decompress_close( void * const decoder ) +int LZ_decompress_close( struct LZ_Decoder * const decoder ) { if( !decoder ) return -1; - Decoder & d = *(Decoder *)decoder; - if( d.lz_decoder ) delete d.lz_decoder; - if( d.ibuf ) delete d.ibuf; - delete (Decoder *)decoder; + if( decoder->lz_decoder ) delete decoder->lz_decoder; + if( decoder->ibuf ) delete decoder->ibuf; + delete decoder; return 0; } -int LZ_decompress_finish( void * const decoder ) +int LZ_decompress_finish( struct LZ_Decoder * const decoder ) + { + if( !verify_decoder( decoder ) || decoder->fatal ) return -1; + LZ_Decoder & d = *decoder; + if( d.seeking ) { d.seeking = false; d.ibuf->purge(); } + else d.ibuf->finish(); + return 0; + } + + +int LZ_decompress_reset( struct LZ_Decoder * const decoder ) { if( !verify_decoder( decoder ) ) return -1; - ((Decoder *)decoder)->ibuf->finish(); + LZ_Decoder & d = *decoder; + if( d.lz_decoder ) { delete d.lz_decoder; d.lz_decoder = 0; } + d.partial_in_size = 0; + d.partial_out_size = 0; + d.ibuf->reset(); + d.lz_errno = LZ_ok; + d.fatal = false; + d.seeking = false; return 0; } -int LZ_decompress_read( void * const decoder, uint8_t * const buffer, - const int size ) +int LZ_decompress_sync_to_member( struct LZ_Decoder * const decoder ) { if( !verify_decoder( decoder ) ) return -1; - Decoder & d = *(Decoder *)decoder; + LZ_Decoder & d = *decoder; + if( d.lz_decoder ) { delete d.lz_decoder; d.lz_decoder = 0; } + if( d.ibuf->find_header() ) d.seeking = false; + else + { + if( !d.ibuf->at_stream_end() ) d.seeking = true; + else { d.seeking = false; d.ibuf->purge(); } + } + d.lz_errno = LZ_ok; + d.fatal = false; + return 0; + } + + +int LZ_decompress_read( struct LZ_Decoder * const decoder, + uint8_t * const buffer, const int size ) + { + if( !verify_decoder( decoder ) || decoder->fatal ) return -1; + LZ_Decoder & d = *decoder; + if( d.seeking ) return 0; if( d.lz_decoder && d.lz_decoder->member_finished() ) { d.partial_in_size += d.lz_decoder->member_position(); @@ -337,25 +396,22 @@ int LZ_decompress_read( void * const decoder, uint8_t * const buffer, if( !d.ibuf->at_stream_end() || d.ibuf->finished() ) return 0; d.ibuf->purge(); // remove trailing garbage d.lz_errno = LZ_header_error; + d.fatal = true; return -1; } File_header header; - for( unsigned int i = 0; i < sizeof header; ++i ) - ((uint8_t *)&header)[i] = d.ibuf->get_byte(); - if( !header.verify_magic() || !header.verify_version() || - header.dictionary_size() < min_dictionary_size || - header.dictionary_size() > max_dictionary_size ) + if( !d.ibuf->read_header( header ) ) { - d.ibuf->purge(); // remove trailing garbage d.lz_errno = LZ_header_error; + d.fatal = true; return -1; } try { d.lz_decoder = new LZ_decoder( header, *d.ibuf ); } catch( std::bad_alloc ) // not enough free memory { - d.ibuf->purge(); d.lz_decoder = 0; d.lz_errno = LZ_mem_error; + d.fatal = true; return -1; } } @@ -364,69 +420,84 @@ int LZ_decompress_read( void * const decoder, uint8_t * const buffer, { if( result == 2 ) d.lz_errno = LZ_unexpected_eof; else d.lz_errno = LZ_data_error; + d.fatal = true; return -1; } return d.lz_decoder->read_data( buffer, size ); } -int LZ_decompress_write( void * const decoder, const uint8_t * const buffer, - const int size ) +int LZ_decompress_write( struct LZ_Decoder * const decoder, + const uint8_t * const buffer, const int size ) { - if( !verify_decoder( decoder ) ) return -1; - return ((Decoder *)decoder)->ibuf->write_data( buffer, size ); + if( !verify_decoder( decoder ) || decoder->fatal ) return -1; + LZ_Decoder & d = *decoder; + int result = d.ibuf->write_data( buffer, size ); + while( d.seeking ) + { + if( d.ibuf->find_header() ) d.seeking = false; + if( result >= size ) break; + const int size2 = d.ibuf->write_data( buffer + result, size - result ); + if( size2 > 0 ) result += size2; + else break; + } + return result; + } + + +int LZ_decompress_write_size( struct LZ_Decoder * const decoder ) + { + if( !verify_decoder( decoder ) || decoder->fatal ) return -1; + return decoder->ibuf->free_bytes(); } -enum LZ_errno LZ_decompress_errno( void * const decoder ) +LZ_Errno LZ_decompress_errno( struct LZ_Decoder * const decoder ) { if( !decoder ) return LZ_bad_argument; - return ((Decoder *)decoder)->lz_errno; + return decoder->lz_errno; } -int LZ_decompress_finished( void * const decoder ) +int LZ_decompress_finished( struct LZ_Decoder * const decoder ) { if( !verify_decoder( decoder ) ) return -1; - Decoder & d = *(Decoder *)decoder; - return ( d.ibuf->finished() && - ( !d.lz_decoder || d.lz_decoder->member_finished() ) ); + return ( decoder->ibuf->finished() && + ( !decoder->lz_decoder || decoder->lz_decoder->member_finished() ) ); } -long long LZ_decompress_data_position( void * const decoder ) +long long LZ_decompress_data_position( struct LZ_Decoder * const decoder ) { if( !verify_decoder( decoder ) ) return -1; - if( ((Decoder *)decoder)->lz_decoder ) - return ((Decoder *)decoder)->lz_decoder->data_position(); + if( decoder->lz_decoder ) + return decoder->lz_decoder->data_position(); else return 0; } -long long LZ_decompress_member_position( void * const decoder ) +long long LZ_decompress_member_position( struct LZ_Decoder * const decoder ) { if( !verify_decoder( decoder ) ) return -1; - if( ((Decoder *)decoder)->lz_decoder ) - return ((Decoder *)decoder)->lz_decoder->member_position(); + if( decoder->lz_decoder ) + return decoder->lz_decoder->member_position(); else return 0; } -long long LZ_decompress_total_in_size( void * const decoder ) +long long LZ_decompress_total_in_size( struct LZ_Decoder * const decoder ) { if( !verify_decoder( decoder ) ) return -1; - Decoder & d = *(Decoder *)decoder; - if( d.lz_decoder ) - return d.partial_in_size + d.lz_decoder->member_position(); - return d.partial_in_size; + if( decoder->lz_decoder ) + return decoder->partial_in_size + decoder->lz_decoder->member_position(); + return decoder->partial_in_size; } -long long LZ_decompress_total_out_size( void * const decoder ) +long long LZ_decompress_total_out_size( struct LZ_Decoder * const decoder ) { if( !verify_decoder( decoder ) ) return -1; - Decoder & d = *(Decoder *)decoder; - if( d.lz_decoder ) - return d.partial_out_size + d.lz_decoder->data_position(); - return d.partial_out_size; + if( decoder->lz_decoder ) + return decoder->partial_out_size + decoder->lz_decoder->data_position(); + return decoder->partial_out_size; } @@ -1,5 +1,5 @@ /* Lzlib - A compression library for lzip files - Copyright (C) 2009 Antonio Diaz Diaz. + Copyright (C) 2009, 2010 Antonio Diaz Diaz. This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -12,7 +12,7 @@ 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, see <http://www.gnu.org/licenses/>. + along with this library. If not, see <http://www.gnu.org/licenses/>. As a special exception, you may use this file as part of a free software library without restriction. Specifically, if other files @@ -29,61 +29,78 @@ extern "C" { #endif -const char * const LZ_version_string = "0.7"; +const char * const LZ_version_string = "0.8"; -enum { min_dictionary_bits = 12, - min_dictionary_size = 1 << min_dictionary_bits, - max_dictionary_bits = 29, - max_dictionary_size = 1 << max_dictionary_bits }; - -enum LZ_errno { LZ_ok = 0, LZ_bad_argument, LZ_mem_error, LZ_sequence_error, - LZ_header_error, LZ_unexpected_eof, LZ_data_error, - LZ_library_error }; +enum LZ_Errno { LZ_ok = 0, LZ_bad_argument, LZ_mem_error, + LZ_sequence_error, LZ_header_error, LZ_unexpected_eof, + LZ_data_error, LZ_library_error }; const char * LZ_version( void ); +const char * LZ_strerror( const enum LZ_Errno lz_errno ); + +int LZ_min_dictionary_bits( void ); +int LZ_min_dictionary_size( void ); +int LZ_max_dictionary_bits( void ); +int LZ_max_dictionary_size( void ); +int LZ_min_match_len_limit( void ); +int LZ_max_match_len_limit( void ); + + +/*---------------------- Compression Functions ----------------------*/ +struct LZ_Encoder; -void * LZ_compress_open( const int dictionary_size, const int match_len_limit, - const long long member_size ); -int LZ_compress_restart_member( void * const encoder, +struct LZ_Encoder * LZ_compress_open( const int dictionary_size, + const int match_len_limit, + const long long member_size ); +int LZ_compress_close( struct LZ_Encoder * const encoder ); + +int LZ_compress_finish( struct LZ_Encoder * const encoder ); +int LZ_compress_restart_member( struct LZ_Encoder * const encoder, const long long member_size ); -int LZ_compress_close( void * const encoder ); -int LZ_compress_finish( void * const encoder ); -int LZ_compress_sync_flush( void * const encoder ); - -int LZ_compress_read( void * const encoder, uint8_t * const buffer, - const int size ); -int LZ_compress_write( void * const encoder, const uint8_t * const buffer, - const int size ); -int LZ_compress_write_size( void * const encoder ); - -enum LZ_errno LZ_compress_errno( void * const encoder ); -int LZ_compress_finished( void * const encoder ); -int LZ_compress_member_finished( void * const encoder ); - -long long LZ_compress_data_position( void * const encoder ); -long long LZ_compress_member_position( void * const encoder ); -long long LZ_compress_total_in_size( void * const encoder ); -long long LZ_compress_total_out_size( void * const encoder ); - - -void * LZ_decompress_open( void ); -int LZ_decompress_close( void * const decoder ); -int LZ_decompress_finish( void * const decoder ); - -int LZ_decompress_read( void * const decoder, uint8_t * const buffer, - const int size ); -int LZ_decompress_write( void * const decoder, const uint8_t * const buffer, - const int size ); - -enum LZ_errno LZ_decompress_errno( void * const decoder ); -int LZ_decompress_finished( void * const decoder ); - -long long LZ_decompress_data_position( void * const decoder ); -long long LZ_decompress_member_position( void * const decoder ); -long long LZ_decompress_total_in_size( void * const decoder ); -long long LZ_decompress_total_out_size( void * const decoder ); +int LZ_compress_sync_flush( struct LZ_Encoder * const encoder ); + +int LZ_compress_read( struct LZ_Encoder * const encoder, + uint8_t * const buffer, const int size ); +int LZ_compress_write( struct LZ_Encoder * const encoder, + const uint8_t * const buffer, const int size ); +int LZ_compress_write_size( struct LZ_Encoder * const encoder ); + +enum LZ_Errno LZ_compress_errno( struct LZ_Encoder * const encoder ); +int LZ_compress_finished( struct LZ_Encoder * const encoder ); +int LZ_compress_member_finished( struct LZ_Encoder * const encoder ); + +long long LZ_compress_data_position( struct LZ_Encoder * const encoder ); +long long LZ_compress_member_position( struct LZ_Encoder * const encoder ); +long long LZ_compress_total_in_size( struct LZ_Encoder * const encoder ); +long long LZ_compress_total_out_size( struct LZ_Encoder * const encoder ); + + +/*--------------------- Decompression Functions ---------------------*/ + +struct LZ_Decoder; + +struct LZ_Decoder * LZ_decompress_open( void ); +int LZ_decompress_close( struct LZ_Decoder * const decoder ); + +int LZ_decompress_finish( struct LZ_Decoder * const decoder ); +int LZ_decompress_reset( struct LZ_Decoder * const decoder ); +int LZ_decompress_sync_to_member( struct LZ_Decoder * const decoder ); + +int LZ_decompress_read( struct LZ_Decoder * const decoder, + uint8_t * const buffer, const int size ); +int LZ_decompress_write( struct LZ_Decoder * const decoder, + const uint8_t * const buffer, const int size ); +int LZ_decompress_write_size( struct LZ_Decoder * const decoder ); + +enum LZ_Errno LZ_decompress_errno( struct LZ_Decoder * const decoder ); +int LZ_decompress_finished( struct LZ_Decoder * const decoder ); + +long long LZ_decompress_data_position( struct LZ_Decoder * const decoder ); +long long LZ_decompress_member_position( struct LZ_Decoder * const decoder ); +long long LZ_decompress_total_in_size( struct LZ_Decoder * const decoder ); +long long LZ_decompress_total_out_size( struct LZ_Decoder * const decoder ); #ifdef __cplusplus } @@ -1,5 +1,5 @@ /* Minilzip - A test program for the lzlib library - Copyright (C) 2009 Antonio Diaz Diaz. + Copyright (C) 2009, 2010 Antonio Diaz Diaz. 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 @@ -63,7 +63,7 @@ namespace { const char * invocation_name = 0; const char * const Program_name = "Minilzip"; const char * const program_name = "minilzip"; -const char * const program_year = "2009"; +const char * const program_year = "2010"; struct { const char * from; const char * to; } const known_extensions[] = { { ".lz", "" }, @@ -145,7 +145,7 @@ void show_help() throw() std::printf( "Numbers may be followed by a multiplier: k = kB = 10^3 = 1000,\n" ); std::printf( "Ki = KiB = 2^10 = 1024, M = 10^6, Mi = 2^20, G = 10^9, Gi = 2^30, etc...\n" ); std::printf( "\nReport bugs to lzip-bug@nongnu.org\n" ); - std::printf( "Lzip home page: http://www.nongnu.org/lzip/lzip.html\n" ); + std::printf( "Lzlib home page: http://www.nongnu.org/lzip/lzlib.html\n" ); } @@ -159,30 +159,6 @@ void show_version() throw() } -const char * format_num( long long num, long long limit = 9999, - const int set_prefix = 0 ) throw() - { - const char * const si_prefix[8] = - { "k", "M", "G", "T", "P", "E", "Z", "Y" }; - const char * const binary_prefix[8] = - { "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi" }; - static bool si = false; - static char buf[16]; - - if( set_prefix ) si = ( set_prefix > 0 ); - const int factor = ( si ) ? 1000 : 1024; - const char * const *prefix = ( si ) ? si_prefix : binary_prefix; - const char *p = ""; - limit = std::max( 999LL, std::min( 999999LL, limit ) ); - - for( int i = 0; i < 8 && ( llabs( num ) > limit || - ( llabs( num ) >= factor && num % factor == 0 ) ); ++i ) - { num /= factor; p = prefix[i]; } - snprintf( buf, sizeof buf, "%lld %s", num, p ); - return buf; - } - - long long getnum( const char * ptr, const int bs = 0, const long long llimit = LLONG_MIN + 1, const long long ulimit = LLONG_MAX ) throw() @@ -218,7 +194,7 @@ long long getnum( const char * ptr, const int bs = 0, break; case 'k': if( factor == 1000 ) exponent = 1; else bad_multiplier = true; break; - default: bad_multiplier = true; + default : bad_multiplier = true; } if( bad_multiplier ) { @@ -245,9 +221,10 @@ int get_dict_size( const char * arg ) throw() { char *tail; int bits = std::strtol( arg, &tail, 0 ); - if( bits >= min_dictionary_bits && bits <= max_dictionary_bits && *tail == 0 ) + if( bits >= LZ_min_dictionary_bits() && + bits <= LZ_max_dictionary_bits() && *tail == 0 ) return ( 1 << bits ); - return getnum( arg, 0, min_dictionary_size, max_dictionary_size ); + return getnum( arg, 0, LZ_min_dictionary_size(), LZ_max_dictionary_size() ); } @@ -390,31 +367,30 @@ void cleanup_and_fail( const int retval ) throw() // Set permissions, owner and times. -void close_and_set_permissions( const struct stat * in_statsp, int * retvalp ) +void close_and_set_permissions( const struct stat * const in_statsp ) { - int tmp = 0; + bool error = false; if( in_statsp ) { - if( fchmod( outhandle, in_statsp->st_mode ) != 0 ) tmp = 1; - if( !tmp ) (void)fchown( outhandle, in_statsp->st_uid, in_statsp->st_gid ); + if( fchmod( outhandle, in_statsp->st_mode ) != 0 ) error = true; + else (void)fchown( outhandle, in_statsp->st_uid, in_statsp->st_gid ); // fchown will in many cases return with EPERM, which can be safely ignored. } if( close( outhandle ) == 0 ) outhandle = -1; else cleanup_and_fail( 1 ); delete_output_on_interrupt = false; if( !in_statsp ) return; - if( !tmp ) + if( !error ) { struct utimbuf t; t.actime = in_statsp->st_atime; t.modtime = in_statsp->st_mtime; - tmp = utime( output_filename.c_str(), &t ); + if( utime( output_filename.c_str(), &t ) != 0 ) error = true; } - if( tmp ) + if( error ) { - if( tmp > *retvalp ) *retvalp = tmp; show_error( "I can't change output file attributes." ); - cleanup_and_fail( *retvalp ); + cleanup_and_fail( 1 ); } } @@ -432,58 +408,55 @@ bool next_filename() } -int compress( const long long member_size, const long long volume_size, - lzma_options encoder_options, const int inhandle, - const Pretty_print & pp, const struct stat * in_statsp, - int * retvalp ) +int do_compress( LZ_Encoder * const encoder, const long long member_size, + const long long volume_size, const int inhandle, + const Pretty_print & pp, const struct stat * const in_statsp ) { - if( verbosity >= 1 ) pp(); - void * encoder = LZ_compress_open( encoder_options.dictionary_size, - encoder_options.match_len_limit, - std::min( member_size, volume_size ) ); - if( !encoder || LZ_compress_errno( encoder ) != LZ_ok ) - { - const bool mem_error = ( LZ_compress_errno( encoder ) == LZ_mem_error ); - LZ_compress_close( encoder ); - if( mem_error ) - { pp( "not enough memory. Try a smaller dictionary size" ); return 1; } - internal_error( "invalid argument to encoder" ); - } - long long partial_volume_size = 0; const int out_buffer_size = 65536, in_buffer_size = 8 * out_buffer_size; uint8_t in_buffer[in_buffer_size], out_buffer[out_buffer_size]; + + if( verbosity >= 1 ) pp(); while( true ) { int in_size = std::min( LZ_compress_write_size( encoder ), in_buffer_size ); if( in_size > 0 ) { - in_size = readblock( inhandle, (char *)in_buffer, in_size ); + const int max_in_size = in_size; + in_size = readblock( inhandle, (char *)in_buffer, max_in_size ); + if( in_size != max_in_size && errno ) + { pp(); show_error( "read error", errno ); return 1; } if( in_size == 0 ) LZ_compress_finish( encoder ); else if( in_size != LZ_compress_write( encoder, in_buffer, in_size ) ) - internal_error( "library error" ); + internal_error( "library error (LZ_compress_write)" ); } int out_size = LZ_compress_read( encoder, out_buffer, out_buffer_size ); // std::fprintf( stderr, "%6d in_size, %5d out_size.\n", in_size, out_size ); if( out_size < 0 ) - { pp(); show_error( "read error", errno ); return 1; } + { + pp(); + if( verbosity >= 0 ) + std::fprintf( stderr, "LZ_compress_read error: %s.\n", + LZ_strerror( LZ_compress_errno( encoder ) ) ); + return 1; + } else if( out_size > 0 ) { const int wr = writeblock( outhandle, (char *)out_buffer, out_size ); if( wr != out_size ) { pp(); show_error( "write error", errno ); return 1; } } - else if( in_size == 0 ) internal_error( "library error" ); + else if( in_size == 0 ) internal_error( "library error (LZ_compress_read)" ); if( LZ_compress_member_finished( encoder ) ) { if( LZ_compress_finished( encoder ) == 1 ) break; partial_volume_size += LZ_compress_member_position( encoder ); - if( partial_volume_size >= volume_size - min_dictionary_size ) + if( partial_volume_size >= volume_size - LZ_min_dictionary_size() ) { partial_volume_size = 0; if( delete_output_on_interrupt ) { - close_and_set_permissions( in_statsp, retvalp ); + close_and_set_permissions( in_statsp ); if( !next_filename() ) { pp(); show_error( "too many volume files" ); return 1; } if( !open_outstream( true ) ) return 1; @@ -493,7 +466,13 @@ int compress( const long long member_size, const long long volume_size, const long long size = std::min( member_size, volume_size - partial_volume_size ); if( LZ_compress_restart_member( encoder, size ) < 0 ) - { pp(); show_error( "read error", errno ); return 1; } + { + pp(); + if( verbosity >= 0 ) + std::fprintf( stderr, "LZ_compress_restart_member error: %s.\n", + LZ_strerror( LZ_compress_errno( encoder ) ) ); + return 1; + } } } @@ -511,51 +490,60 @@ int compress( const long long member_size, const long long volume_size, 100.0 * ( 1.0 - ( (double)out_size / in_size ) ), in_size, out_size ); } - LZ_compress_close( encoder ); return 0; } -int decompress( const int inhandle, const Pretty_print & pp, - const bool testing ) +int compress( const long long member_size, const long long volume_size, + const lzma_options & encoder_options, const int inhandle, + const Pretty_print & pp, const struct stat * const in_statsp ) { - void * decoder = LZ_decompress_open(); - if( !decoder || LZ_decompress_errno( decoder ) != LZ_ok ) + LZ_Encoder * const encoder = + LZ_compress_open( encoder_options.dictionary_size, + encoder_options.match_len_limit, + std::min( member_size, volume_size ) ); + int retval; + + if( !encoder || LZ_compress_errno( encoder ) != LZ_ok ) { - LZ_decompress_close( decoder ); - pp( "not enough memory. Find a machine with more memory" ); - return 1; + if( LZ_compress_errno( encoder ) == LZ_mem_error ) + pp( "not enough memory. Try a smaller dictionary size" ); + else + internal_error( "invalid argument to encoder" ); + retval = 1; } - if( verbosity >= 1 ) pp(); + else retval = do_compress( encoder, member_size, volume_size, + inhandle, pp, in_statsp ); + LZ_compress_close( encoder ); + return retval; + } + +int do_decompress( LZ_Decoder * const decoder, const int inhandle, + const Pretty_print & pp, const bool testing ) + { const int in_buffer_size = 65536, out_buffer_size = 8 * in_buffer_size; uint8_t in_buffer[in_buffer_size], out_buffer[out_buffer_size]; - int in_pos = 0, in_stream_pos = 0; - bool finished = false; + + if( verbosity >= 1 ) pp(); while( true ) { - int in_size = 0; - if( !finished ) + int in_size = std::min( LZ_decompress_write_size( decoder ), in_buffer_size ); + if( in_size > 0 ) { - if( in_stream_pos == 0 ) - in_stream_pos = readblock( inhandle, (char *)in_buffer, in_buffer_size ); - if( in_pos < in_stream_pos ) - { - in_size = LZ_decompress_write( decoder, in_buffer + in_pos, in_stream_pos - in_pos ); - in_pos += in_size; - } - if( in_pos >= in_stream_pos ) - { - if( in_stream_pos < in_buffer_size ) - { finished = true; LZ_decompress_finish( decoder ); } - in_stream_pos = 0; in_pos = 0; - } + const int max_in_size = in_size; + in_size = readblock( inhandle, (char *)in_buffer, max_in_size ); + if( in_size != max_in_size && errno ) + { pp(); show_error( "read error", errno ); return 1; } + if( in_size == 0 ) LZ_decompress_finish( decoder ); + else if( in_size != LZ_decompress_write( decoder, in_buffer, in_size ) ) + internal_error( "library error (LZ_decompress_write)" ); } int out_size = LZ_decompress_read( decoder, out_buffer, out_buffer_size ); // std::fprintf( stderr, "%5d in_size, %6d out_size.\n", in_size, out_size ); if( out_size < 0 ) { - const LZ_errno lz_errno = LZ_decompress_errno( decoder ); + const LZ_Errno lz_errno = LZ_decompress_errno( decoder ); if( lz_errno == LZ_header_error ) { if( LZ_decompress_total_out_size( decoder ) > 0 ) @@ -568,15 +556,18 @@ int decompress( const int inhandle, const Pretty_print & pp, pp( "not enough memory. Find a machine with more memory" ); return 1; } + pp(); if( lz_errno == LZ_unexpected_eof ) { if( verbosity >= 0 ) - { pp(); - std::fprintf( stderr, "file ends unexpectedly at pos %lld\n", - LZ_decompress_total_in_size( decoder ) ); } + std::fprintf( stderr, "file ends unexpectedly at pos %lld\n", + LZ_decompress_total_in_size( decoder ) ); return 2; } - pp(); show_error( "read error", errno ); return 1; + if( verbosity >= 0 ) + std::fprintf( stderr, "LZ_decompress_read error: %s.\n", + LZ_strerror( LZ_decompress_errno( decoder ) ) ); + return 1; } else if( out_size > 0 && outhandle >= 0 ) { @@ -585,17 +576,34 @@ int decompress( const int inhandle, const Pretty_print & pp, { pp(); show_error( "write error", errno ); return 1; } } if( LZ_decompress_finished( decoder ) == 1 ) break; - if( finished && in_size == 0 && out_size == 0 ) - internal_error( "library error" ); + if( in_size == 0 && out_size == 0 ) + internal_error( "library error (LZ_decompress_read)" ); } if( verbosity >= 1 ) { if( testing ) std::fprintf( stderr, "ok\n" ); else std::fprintf( stderr, "done\n" ); } - LZ_decompress_close( decoder ); return 0; } +int decompress( const int inhandle, const Pretty_print & pp, + const bool testing ) + { + LZ_Decoder * const decoder = LZ_decompress_open(); + int retval; + + if( !decoder || LZ_decompress_errno( decoder ) != LZ_ok ) + { + pp( "not enough memory. Find a machine with more memory" ); + retval = 1; + } + else retval = do_decompress( decoder, inhandle, pp, testing ); + + LZ_decompress_close( decoder ); + return retval; + } + + extern "C" void signal_handler( int ) throw() { show_error( "Control-C or similar caught, quitting." ); @@ -775,7 +783,8 @@ int main( const int argc, const char * argv[] ) case 'h': show_help(); return 0; case 'k': keep_input_files = true; break; case 'm': encoder_options.match_len_limit = - getnum( arg, 0, 5, 273 ); break; + getnum( arg, 0, LZ_min_match_len_limit(), + LZ_max_match_len_limit() ); break; case 'o': default_output_filename = arg; break; case 'q': verbosity = -1; break; case 's': encoder_options.dictionary_size = get_dict_size( arg ); @@ -859,19 +868,19 @@ int main( const int argc, const char * argv[] ) if( output_filename.size() && !to_stdout && program_mode != m_test ) delete_output_on_interrupt = true; - const struct stat * in_statsp = input_filename.size() ? &in_stats : 0; + const struct stat * const in_statsp = input_filename.size() ? &in_stats : 0; pp.set_name( input_filename ); int tmp = 0; if( program_mode == m_compress ) tmp = compress( member_size, volume_size, encoder_options, inhandle, - pp, in_statsp, &retval ); + pp, in_statsp ); else tmp = decompress( inhandle, pp, program_mode == m_test ); if( tmp > retval ) retval = tmp; if( tmp && program_mode != m_test ) cleanup_and_fail( retval ); if( delete_output_on_interrupt ) - close_and_set_permissions( in_statsp, &retval ); + close_and_set_permissions( in_statsp ); if( input_filename.size() ) { close( inhandle ); inhandle = -1; @@ -879,6 +888,12 @@ int main( const int argc, const char * argv[] ) std::remove( input_filename.c_str() ); } } - if( outhandle >= 0 ) close( outhandle ); + if( outhandle >= 0 && close( outhandle ) != 0 ) + { + if( verbosity >= 0 ) + std::fprintf( stderr, "%s: Can't close stdout: %s.\n", + program_name, std::strerror( errno ) ); + if( retval < 1 ) retval = 1; + } return retval; } diff --git a/testsuite/check.sh b/testsuite/check.sh index 62f9e49..e35876d 100755 --- a/testsuite/check.sh +++ b/testsuite/check.sh @@ -1,6 +1,6 @@ #! /bin/sh # check script for Lzlib - A compression library for lzip files -# Copyright (C) 2009 Antonio Diaz Diaz. +# Copyright (C) 2009, 2010 Antonio Diaz Diaz. # # This script is free software: you have unlimited permission # to copy, distribute and modify it. @@ -20,13 +20,13 @@ fi if [ -d tmp ] ; then rm -rf tmp ; fi mkdir tmp -echo -n "testing minilzip..." +echo -n "testing lzlib..." cd "${objdir}"/tmp -cat "${testdir}"/../COPYING > in || framework_failure +cat "${testdir}"/test1 > in || framework_failure fail=0 -"${LZIP}" -cd "${testdir}"/COPYING.lz > copy || fail=1 +"${LZIP}" -cd "${testdir}"/test1.lz > copy || fail=1 cmp in copy || fail=1 for i in s4096 1 2 3 4 5 6 7 8; do @@ -47,7 +47,7 @@ for i in s4096 1 2 3 4 5 6 7 8; do done for i in s4096 1 2 3 4 5 6 7 8; do - "${LZIP}" -c -$i < in > out || fail=1 + "${LZIP}" -$i < in > out || fail=1 "${LZIP}" -d < out > copy || fail=1 cmp in copy || fail=1 echo -n . diff --git a/testsuite/test1 b/testsuite/test1 new file mode 100644 index 0000000..5b244d5 --- /dev/null +++ b/testsuite/test1 @@ -0,0 +1,676 @@ +
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. 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
+them 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 prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. 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.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey 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;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU 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 that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ 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.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+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.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ 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
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program 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, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU 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 Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+
diff --git a/testsuite/COPYING.lz b/testsuite/test1.lz Binary files differindex a09b1e8..a09b1e8 100644 --- a/testsuite/COPYING.lz +++ b/testsuite/test1.lz |