mirror of
https://git.tukaani.org/xz.git
synced 2026-08-16 09:02:50 +00:00
Imported to git.
This commit is contained in:
commit
5d018dc035
18
AUTHORS
Normal file
18
AUTHORS
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
Authors of LZMA Utils
|
||||
---------------------
|
||||
|
||||
Igor Pavlov
|
||||
* designed LZMA as an algorithm;
|
||||
* wrote an implementation known as LZMA SDK, which is part of
|
||||
the bigger 7-Zip project.
|
||||
|
||||
Ville Koskinen
|
||||
* wrote the first version of the gzip-like lzma command line
|
||||
utility (C++)
|
||||
* helped a lot with the documentation.
|
||||
|
||||
Lasse Collin
|
||||
* ported LZMA SDK to C and zlib-like API (liblzma);
|
||||
* rewrote the command line tool again to use liblzma and pthreads.
|
||||
|
||||
24
COPYING
Normal file
24
COPYING
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
LZMA Utils Licenses
|
||||
-------------------
|
||||
|
||||
Different licenses apply to different files in this package. Here
|
||||
is a rough summary of which license apply to which parts of this
|
||||
package (but check the individual files to be sure!):
|
||||
- Everything under src/liblzma/check is public domain.
|
||||
- Everything else under the src directory is under the GNU LGPL
|
||||
2.1 or (at your opinion) any later version.
|
||||
- Outside the src directory, there are some files that are under
|
||||
the GNU GPL 2 or (at your opinion) any later version, or under
|
||||
the GNU GPL 3 or (at your opinion) any later version.
|
||||
- Most documentation files are under an all-permissive license.
|
||||
|
||||
The following license texts are included in the following files
|
||||
in this package:
|
||||
- COPYING.LGPLv2.1: GNU Lesser General Public License version 2.1
|
||||
- COPYING.GPLv2: GNU General Public License version 2
|
||||
- COPYING.GPLv3: GNU General Public License version 3
|
||||
|
||||
If you have questions, don't hesitate to ask the copyright holder(s)
|
||||
for more information.
|
||||
|
||||
339
COPYING.GPLv2
Normal file
339
COPYING.GPLv2
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
674
COPYING.GPLv3
Normal file
674
COPYING.GPLv3
Normal file
@ -0,0 +1,674 @@
|
||||
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>.
|
||||
504
COPYING.LGPLv2.1
Normal file
504
COPYING.LGPLv2.1
Normal file
@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
2
ChangeLog
Normal file
2
ChangeLog
Normal file
@ -0,0 +1,2 @@
|
||||
See the commit log in the git repository:
|
||||
git://ctrl.tukaani.org/lzma-utils.git
|
||||
1229
Doxyfile.in
Normal file
1229
Doxyfile.in
Normal file
File diff suppressed because it is too large
Load Diff
38
Makefile.am
Normal file
38
Makefile.am
Normal file
@ -0,0 +1,38 @@
|
||||
##
|
||||
## Copyright (C) 2007 Lasse Collin
|
||||
##
|
||||
## This library is free software; you can redistribute it and/or
|
||||
## modify it under the terms of the GNU Lesser General Public
|
||||
## License as published by the Free Software Foundation; either
|
||||
## version 2.1 of the License, or (at your option) any later version.
|
||||
##
|
||||
## This library is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## Lesser General Public License for more details.
|
||||
##
|
||||
|
||||
SUBDIRS =
|
||||
|
||||
if COND_GNULIB
|
||||
SUBDIRS += lib
|
||||
endif
|
||||
|
||||
SUBDIRS += src po tests
|
||||
|
||||
|
||||
EXTRA_DIST = \
|
||||
m4 \
|
||||
extra \
|
||||
config.rpath \
|
||||
Doxyfile.in \
|
||||
FAQ \
|
||||
INSTALL.generic \
|
||||
COPYING.GPLv2 \
|
||||
COPYING.GPLv3 \
|
||||
COPYING.LGPLv2.1 \
|
||||
README-liblzma \
|
||||
README-lzma
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
151
README
Normal file
151
README
Normal file
@ -0,0 +1,151 @@
|
||||
|
||||
LZMA Utils
|
||||
----------
|
||||
|
||||
Warning
|
||||
|
||||
This is an early alpha version. Don't trust the files produced by
|
||||
this version of the software - not even if the software can
|
||||
uncompress the files properly! This is because the file format
|
||||
isn't completely frozen yet.
|
||||
|
||||
So please test a lot, but don't use for anything serious yet.
|
||||
|
||||
|
||||
Overview
|
||||
|
||||
LZMA is a general purporse compression algorithm designed by
|
||||
Igor Pavlov as part of 7-Zip. It provides high compression ratio
|
||||
while keeping the decompression speed fast.
|
||||
|
||||
LZMA Utils are an attempt to make LZMA compression easy to use
|
||||
on free (as in freedom) operating systems. This is achieved by
|
||||
providing tools and libraries which are similar to use than the
|
||||
equivalents of the most popular existing compression algorithms.
|
||||
|
||||
LZMA Utils consist of a few relatively separate parts:
|
||||
* liblzma is an encoder/decoder library with support for several
|
||||
filters (algorithm implementations). The primary filter is LZMA.
|
||||
* libzfile enables reading from and writing to gzip, bzip2 and
|
||||
LZMA compressed and uncompressed files with an API similar to
|
||||
the standard ANSI-C file I/O.
|
||||
[ NOTE: libzfile is not implemented yet. ]
|
||||
* lzma command line tool has almost identical syntax than gzip
|
||||
and bzip2. It makes LZMA easy for average users, but also
|
||||
provides advanced options to finetune the compression settings.
|
||||
* A few shell scripts make diffing and grepping LZMA compressed
|
||||
files easy. The scripts were adapted from gzip and bzip2.
|
||||
|
||||
|
||||
Supported platforms
|
||||
|
||||
LZMA Utils are developed on GNU+Linux, but they should work at
|
||||
least on *BSDs and Solaris. They probably work on some other
|
||||
POSIX-like operating systems too.
|
||||
|
||||
If you use GCC to compile LZMA Utils, you need at least version
|
||||
3.x.x. GCC version 2.xx.x doesn't support some C99 features used
|
||||
in LZMA Utils source code, thus GCC 2 won't compile LZMA Utils.
|
||||
|
||||
If you have written patches to make LZMA Utils to work on previously
|
||||
unsupported platform, please send the patches to me! I will consider
|
||||
including them to the official version. It's nice to minimize the
|
||||
need of third-party patching.
|
||||
|
||||
One exception: Don't request or send patches to change the whole
|
||||
source package to C89. I find C99 substantially nicer to write and
|
||||
maintain. However, the public library headers must be in C89 to
|
||||
avoid frustrating those who maintain programs, which are strictly
|
||||
in C89 or C++.
|
||||
|
||||
|
||||
configure options
|
||||
|
||||
If you are not familiar with `configure' scripts, read the file
|
||||
INSTALL first.
|
||||
|
||||
In most cases, the default --enable/--disable/--with/--without options
|
||||
are what you want. Don't touch them if you are unsure.
|
||||
|
||||
--disable-encoder
|
||||
Do not compile the encoder component of liblzma. This
|
||||
implies --disable-match-finders. If you need only
|
||||
the decoder, you can decrease the library size
|
||||
dramatically with this option.
|
||||
|
||||
The default is to build the encoder.
|
||||
|
||||
--disable-decoder
|
||||
Do not compile the decoder component of liblzma.
|
||||
|
||||
The default is to build the decoder.
|
||||
|
||||
--enable-filters=
|
||||
liblzma supports several filters. See liblzma-intro.txt
|
||||
for a little more information about these.
|
||||
|
||||
The default is to build all the filters.
|
||||
|
||||
--enable-match-finders=
|
||||
liblzma includes two categories of match finders:
|
||||
hash chains and binary trees. Hash chains (hc3 and hc4)
|
||||
are quite fast but they don't provide the best compression
|
||||
ratio. Binary trees (bt2, bt3 and bt4) give excellent
|
||||
compression ratio, but they are slower and need more
|
||||
memory than hash chains.
|
||||
|
||||
You need to enable at least one match finder to build the
|
||||
LZMA filter encoder. Usually hash chains are used only in
|
||||
the fast mode, while binary trees are used to when the best
|
||||
compression ratio is wanted.
|
||||
|
||||
The default is to build all the match finders.
|
||||
|
||||
--enable-checks=
|
||||
liblzma support multiple integrity checks. CRC32 is
|
||||
mandatory, and cannot be omitted. See liblzma-intro.txt
|
||||
for more information about usage of the integrity checks.
|
||||
|
||||
--disable-assembler
|
||||
liblzma includes some assembler optimizations. Currently
|
||||
there is only assembler code for CRC32 and CRC64 for
|
||||
32-bit x86.
|
||||
|
||||
All the assembler code in liblzma is position-independent
|
||||
code, which is suitable for use in shared libraries and
|
||||
position-independent executables.
|
||||
|
||||
--enable-small
|
||||
Omits precomputed tables. This makes liblzma a few KiB
|
||||
smaller. Startup time increases, because the tables need
|
||||
to be computed first.
|
||||
|
||||
--enable-debug
|
||||
This enables the assert() macro and possibly some other
|
||||
run-time consistency checks. It slows down things somewhat,
|
||||
so you normally don't want to have this enabled.
|
||||
|
||||
--enable-werror
|
||||
Makes all compiler warnings an error, that abort the
|
||||
compilation. This may help catching bugs, and should work
|
||||
on most systems. This has no effect on the resulting
|
||||
binaries.
|
||||
|
||||
|
||||
Static vs. dynamic linking of the command line tools
|
||||
|
||||
By default, the command line tools are linked statically against
|
||||
liblzma. There a are a few reasons:
|
||||
|
||||
- The executable(s) can be in /bin while the shared liblzma can still
|
||||
be in /usr/lib (if the distro uses such file system hierachy).
|
||||
|
||||
- It's easier to copy the executables to other systems, since they
|
||||
depend only on libc.
|
||||
|
||||
- It's slightly faster on some architectures like x86.
|
||||
|
||||
If you don't like this, you can get the command line tools linked
|
||||
against the shared liblzma by specifying --disable-static to configure.
|
||||
This disables building static liblzma completely.
|
||||
|
||||
23
THANKS
Normal file
23
THANKS
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
Thanks
|
||||
------
|
||||
|
||||
Some people have helped more, some less, some don't even know they have
|
||||
been helpful, but nevertheless everyone's help has been important. :-)
|
||||
In alphabetical order:
|
||||
- Mark Adler
|
||||
- Anders F. Björklund
|
||||
- İsmail Dönmez
|
||||
- Jean-loup Gailly
|
||||
- Per Øyvind Karlsen
|
||||
- Ville Koskinen
|
||||
- Jim Meyering
|
||||
- Igor Pavlov
|
||||
- Mikko Pouru
|
||||
- Alexandre Sauvé
|
||||
- Julian Seward
|
||||
- Mohammed Adnène Trojette
|
||||
|
||||
Also thanks to all the people who have participated the Tukaani project
|
||||
and others who I have forgot.
|
||||
|
||||
109
TODO
Normal file
109
TODO
Normal file
@ -0,0 +1,109 @@
|
||||
|
||||
LZMA Utils TODO List
|
||||
--------------------
|
||||
|
||||
Major missing features
|
||||
|
||||
Memory limits in the command line tool apply only to compression.
|
||||
|
||||
Threading support in the lzma command line tool is still primitive.
|
||||
It cannot split a file in pieces yet.
|
||||
|
||||
The --list mode isn't implemented in the command line tool.
|
||||
|
||||
Handling of Multi-Block Stream information should be separated
|
||||
from Stream encoder and decoder. Those would be useful to implement
|
||||
multi-threaded coding in applications.
|
||||
|
||||
Buffer to buffer coding is not implemented in liblzma. Probably
|
||||
a naive version should be written first, which would simply wrap
|
||||
things around lzma_stream. Later, there should be separate buffer
|
||||
coding functions, that are slightly faster (less memcpy()) and
|
||||
have smaller memory usage than the functions using lzma_stream.
|
||||
|
||||
libzfile is not implemented.
|
||||
|
||||
LZMA filter doesn't support predefined history buffer.
|
||||
|
||||
|
||||
Security
|
||||
|
||||
Search for bugs, especially security related issues. Security is
|
||||
important in every piece of code in LZMA Utils, but it is extremely
|
||||
important in the decoder part of liblzma.
|
||||
|
||||
Subblock: If there is LZMA as a Subfilter but without EOPM, can it
|
||||
trigger infinite loop when Subblock's "Unset Subfilter" flag is hit?
|
||||
|
||||
Similarly, can LZ decoder get stuck in infinite loop if the next
|
||||
filter in the chain returns LZMA_STREAM_END but the decoded data
|
||||
doesn't allow finishing the LZ decoding?
|
||||
|
||||
|
||||
Reliability
|
||||
|
||||
Create a test suite to be run with "make check".
|
||||
|
||||
Should we use strlimit() and getrlimit() for memory usage limitting?
|
||||
|
||||
|
||||
Performance
|
||||
|
||||
Benchmark the CRC code on non-x86 CPUs. Won't have huge effect on
|
||||
overall speed, but it would still be nice to know what algorithm
|
||||
variant is the best on different CPUs.
|
||||
|
||||
|
||||
Third party support
|
||||
|
||||
Add support for LZMA to various applications. This naturally requires
|
||||
cooperating with the authors of the specific applications.
|
||||
* GNU grep and GNU diffutils: BSD grep already uses zlib directly
|
||||
instead of ugly shell scripts. It would be nice to get similar
|
||||
feature into relevant GNU tools. With libzfile, multiple
|
||||
compression formats would be easy to support.
|
||||
* kioslave for KDE
|
||||
* Magic for the `file' command
|
||||
* GNU Midnight Commander
|
||||
* GNU Texinfo
|
||||
* The `man' command
|
||||
* Package managers
|
||||
|
||||
Test the patches already written. The patches should be sent to
|
||||
upstream developers _once_ LZMA Utils APIs are stable enough (so
|
||||
people don't need to fix those patches all the time).
|
||||
|
||||
Mandriva has quite a few patches. Some of them are OK, some need
|
||||
adapting for new LZMA Utils.
|
||||
|
||||
|
||||
Documentation
|
||||
|
||||
Revise the man page of lzma command line tool.
|
||||
|
||||
If the Doxygen docs aren't enough, write good Texinfo manual for
|
||||
liblzma. It's been a long time I've even tried to build the Doxygen
|
||||
docs, so they may look quite bad at the moment.
|
||||
|
||||
Document LZMA as an algorithm. It would be great to have detailed
|
||||
description of the algorithm in English. Many people think, that
|
||||
reading the source code is not the optimal way to learn how LZMA
|
||||
works.
|
||||
|
||||
|
||||
Other
|
||||
|
||||
Some things return LZMA_PROG_ERROR with invalid options, some
|
||||
LZMA_HEADER_ERROR. These must be checked carefully and made so
|
||||
that LZMA_HEADER_ERROR is used only when the given option could
|
||||
make sense in future version of libzma.
|
||||
|
||||
lzma_restrict vs. restrict
|
||||
|
||||
Usage of LZMA_RUN vs. LZMA_FINISH with Metadata coders.
|
||||
|
||||
Port the Deflate implementation from 7-Zip into liblzma. 7-Zip's
|
||||
Deflate compresses better than zlib, gzip or Info-ZIP. I don't
|
||||
know if Deflate will be included in .lzma format (probably not),
|
||||
but it's still useful once we also add support for .gz file format.
|
||||
|
||||
38
autogen.sh
Executable file
38
autogen.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e -x
|
||||
|
||||
# autooint copies all kinds of crap even though we have told in
|
||||
# configure.ac that we don't want the intl directory. It is able
|
||||
# to omit the intl directory but still copies the m4 files needed
|
||||
# only by the stuff in the non-existing intl directory.
|
||||
autopoint -f
|
||||
rm -f \
|
||||
codeset.m4 \
|
||||
glibc2.m4 \
|
||||
glibc21.m4 \
|
||||
intdiv0.m4 \
|
||||
intl.m4 \
|
||||
intldir.m4 \
|
||||
intmax.m4 \
|
||||
inttypes-pri.m4 \
|
||||
inttypes_h.m4 \
|
||||
lcmessage.m4 \
|
||||
lock.m4 \
|
||||
longdouble.m4 \
|
||||
longlong.m4 \
|
||||
printf-posix.m4 \
|
||||
size_max.m4 \
|
||||
stdint_h.m4 \
|
||||
uintmax_t.m4 \
|
||||
ulonglong.m4 \
|
||||
visibility.m4 \
|
||||
wchar_t.m4 \
|
||||
wint_t.m4 \
|
||||
xsize.m4
|
||||
|
||||
aclocal -I m4
|
||||
libtoolize -c -f || glibtoolize -c -f
|
||||
autoconf
|
||||
autoheader
|
||||
automake -acf --foreign
|
||||
611
configure.ac
Normal file
611
configure.ac
Normal file
@ -0,0 +1,611 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Copyright (C) 2007 Lasse Collin
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# NOTE: Don't add useless checks. autoscan detects this and that, but don't
|
||||
# let it confuse you. For example, we don't care about checking for behavior
|
||||
# of malloc(), stat(), or lstat(), since we don't use those functions in
|
||||
# a way that would cause the problems the autoconf macros check.
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
|
||||
# [LZMA] instead of [LZMA utils] since I prefer to have lzma-version.tar.gz
|
||||
# instead of lzma-utils-version.tar.gz.
|
||||
AC_INIT([LZMA], [4.42.2alpha], [lasse.collin@tukaani.org])
|
||||
|
||||
AC_CONFIG_SRCDIR([src/liblzma/common/common.h])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
|
||||
echo
|
||||
echo "LZMA Utils $PACKAGE_VERSION"
|
||||
|
||||
echo
|
||||
echo "System type:"
|
||||
# This is needed to know if assembler optimizations can be used.
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
echo
|
||||
echo "Configure options:"
|
||||
|
||||
# Enable/disable debugging code:
|
||||
AC_MSG_CHECKING([if debugging code should be compiled])
|
||||
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging code.]),
|
||||
[], enable_debug=no)
|
||||
if test "x$enable_debug" = xyes; then
|
||||
CFLAGS="-g $CFLAGS"
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_DEFINE(NDEBUG, 1, [Define to disable debugging code.])
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
# Enable/disable the encoder components:
|
||||
AC_MSG_CHECKING([if encoder components should be built])
|
||||
AC_ARG_ENABLE(encoder, AC_HELP_STRING([--disable-encoder],
|
||||
[Do not build the encoder components.]),
|
||||
[], enable_encoder=yes)
|
||||
if test "x$enable_encoder" = xyes; then
|
||||
AC_DEFINE([HAVE_ENCODER], 1,
|
||||
[Define to 1 if encoder components are enabled.])
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
AM_CONDITIONAL(COND_MAIN_ENCODER, test "x$enable_encoder" = xyes)
|
||||
|
||||
# Enable/disable the decoder components:
|
||||
AC_MSG_CHECKING([if decoder components should be built])
|
||||
AC_ARG_ENABLE(decoder, AC_HELP_STRING([--disable-decoder],
|
||||
[Do not build the decoder components.]),
|
||||
[], enable_decoder=yes)
|
||||
if test "x$enable_decoder" = xyes; then
|
||||
AC_DEFINE([HAVE_DECODER], 1,
|
||||
[Define to 1 if decoder components are enabled.])
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
if test "x$enable_encoder" = xno; then
|
||||
AC_MSG_ERROR([Do not disable both encoder and decoder.])
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL(COND_MAIN_DECODER, test "x$enable_decoder" = xyes)
|
||||
|
||||
# Filters
|
||||
AC_MSG_CHECKING([which filters to build])
|
||||
AC_ARG_ENABLE(filters, AC_HELP_STRING([--enable-filters=],
|
||||
[Comma-separated list of filters to build. Default=all.
|
||||
Filters used in encoding are needed also in decoding.
|
||||
Available filters: copy subblock x86 powerpc ia64
|
||||
arm armthumb sparc delta lzma]),
|
||||
[], [enable_filters=copy,subblock,x86,powerpc,ia64,arm,armthumb,sparc,delta,lzma])
|
||||
enable_filters=`echo "$enable_filters" | sed 's/,/ /g'`
|
||||
enable_filters_copy=no
|
||||
enable_filters_subblock=no
|
||||
enable_filters_x86=no
|
||||
enable_filters_powerpc=no
|
||||
enable_filters_ia64=no
|
||||
enable_filters_arm=no
|
||||
enable_filters_armthumb=no
|
||||
enable_filters_sparc=no
|
||||
enable_filters_delta=no
|
||||
enable_filters_lzma=no
|
||||
enable_simple_filters=no
|
||||
if test "x$enable_filters" = xno || test "x$enable_filters" = x; then
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([Please enable at least one filter.])
|
||||
else
|
||||
for arg in $enable_filters
|
||||
do
|
||||
case $arg in
|
||||
copy)
|
||||
enable_filters_copy=yes
|
||||
AC_DEFINE([HAVE_FILTER_COPY], 1,
|
||||
[Define to 1 if support for the
|
||||
Copy filter is enabled.])
|
||||
;;
|
||||
subblock)
|
||||
enable_filters_subblock=yes
|
||||
AC_DEFINE([HAVE_FILTER_SUBBLOCK], 1,
|
||||
[Define to 1 if support for the
|
||||
Subblock filter is enabled.])
|
||||
;;
|
||||
x86)
|
||||
enable_filters_x86=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_X86], 1,
|
||||
[Define to 1 if support for the
|
||||
x86 (BCJ) filter is enabled.])
|
||||
;;
|
||||
powerpc)
|
||||
enable_filters_powerpc=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_POWERPC], 1,
|
||||
[Define to 1 if support for the
|
||||
PowerPC filter is enabled.])
|
||||
;;
|
||||
ia64)
|
||||
enable_filters_ia64=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_IA64], 1,
|
||||
[Define to 1 if support for the
|
||||
IA64 filter is enabled.])
|
||||
;;
|
||||
arm)
|
||||
enable_filters_arm=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_ARM], 1,
|
||||
[Define to 1 if support for the
|
||||
ARM filter is enabled.])
|
||||
;;
|
||||
armthumb)
|
||||
enable_filters_armthumb=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_ARMTHUMB], 1,
|
||||
[Define to 1 if support for the
|
||||
ARMThumb filter is enabled.])
|
||||
;;
|
||||
sparc)
|
||||
enable_filters_sparc=yes
|
||||
enable_simple_filters=yes
|
||||
AC_DEFINE([HAVE_FILTER_SPARC], 1,
|
||||
[Define to 1 if support for the
|
||||
SPARC filter is enabled.])
|
||||
;;
|
||||
delta)
|
||||
enable_filters_delta=yes
|
||||
AC_DEFINE([HAVE_FILTER_DELTA], 1,
|
||||
[Define to 1 if support for the
|
||||
Delta filter is enabled.])
|
||||
;;
|
||||
lzma)
|
||||
enable_filters_lzma=yes
|
||||
AC_DEFINE([HAVE_FILTER_LZMA], 1,
|
||||
[Define to 1 if support for the
|
||||
LZMA filter is enabled.])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([unknown filter: $arg])
|
||||
;;
|
||||
esac
|
||||
done
|
||||
AC_MSG_RESULT([$enable_filters])
|
||||
fi
|
||||
if test "x$enable_simple_filters" = xyes ; then
|
||||
AC_DEFINE([HAVE_FILTER_SIMPLE], 1, [Define to 1 if support for any
|
||||
of the so called simple filters is enabled.])
|
||||
fi
|
||||
AM_CONDITIONAL(COND_FILTER_COPY, test "x$enable_filters_copy" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_SUBBLOCK, test "x$enable_filters_subblock" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_X86, test "x$enable_filters_x86" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_POWERPC, test "x$enable_filters_powerpc" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_IA64, test "x$enable_filters_ia64" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_ARM, test "x$enable_filters_arm" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_ARMTHUMB, test "x$enable_filters_armthumb" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_SPARC, test "x$enable_filters_sparc" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_DELTA, test "x$enable_filters_delta" = xyes)
|
||||
AM_CONDITIONAL(COND_FILTER_LZMA, test "x$enable_filters_lzma" = xyes)
|
||||
AM_CONDITIONAL(COND_MAIN_SIMPLE, test "x$enable_simple_filters" = xyes)
|
||||
|
||||
# Which match finders should be enabled:
|
||||
AC_MSG_CHECKING([which match finders to build])
|
||||
AC_ARG_ENABLE(match-finders, AC_HELP_STRING([--enable-match-finders=],
|
||||
[Comma-separated list of match finders to build. Default=all.
|
||||
At least one match finder is required for encoding with
|
||||
the LZMA filter.
|
||||
Available match finders: hc3 hc4 bt2 bt3 bt4]), [],
|
||||
[enable_match_finders=hc3,hc4,bt2,bt3,bt4])
|
||||
enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`
|
||||
enable_match_finders_hc3=no
|
||||
enable_match_finders_hc4=no
|
||||
enable_match_finders_bt2=no
|
||||
enable_match_finders_bt3=no
|
||||
enable_match_finders_bt4=no
|
||||
if test "x$enable_encoder" = xyes && test "x$enable_filters_lzma" = xyes ; then
|
||||
for arg in $enable_match_finders
|
||||
do
|
||||
case $arg in
|
||||
hc3) enable_match_finders_hc3=yes ;;
|
||||
hc4) enable_match_finders_hc4=yes ;;
|
||||
bt2) enable_match_finders_bt2=yes ;;
|
||||
bt3) enable_match_finders_bt3=yes ;;
|
||||
bt4) enable_match_finders_bt4=yes ;;
|
||||
*)
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([unknown match finder: $arg])
|
||||
;;
|
||||
esac
|
||||
done
|
||||
AC_MSG_RESULT([$enable_match_finders])
|
||||
else
|
||||
AC_MSG_RESULT([(none because not building the LZMA encoder)])
|
||||
fi
|
||||
AM_CONDITIONAL(COND_MF_HC3, test "x$enable_match_finders_hc3" = xyes)
|
||||
AM_CONDITIONAL(COND_MF_HC4, test "x$enable_match_finders_hc4" = xyes)
|
||||
AM_CONDITIONAL(COND_MF_BT2, test "x$enable_match_finders_bt2" = xyes)
|
||||
AM_CONDITIONAL(COND_MF_BT3, test "x$enable_match_finders_bt3" = xyes)
|
||||
AM_CONDITIONAL(COND_MF_BT4, test "x$enable_match_finders_bt4" = xyes)
|
||||
|
||||
# Which integrity checks to build
|
||||
AC_MSG_CHECKING([which integrity checks to build])
|
||||
AC_ARG_ENABLE(checks, AC_HELP_STRING([--enable-checks=],
|
||||
[Comma-separated list of integrity checks to build.
|
||||
Default=all. Available integrity checks: crc32 crc64 sha256]),
|
||||
[], [enable_checks=crc32,crc64,sha256])
|
||||
enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`
|
||||
enable_checks_crc32=no
|
||||
enable_checks_crc64=no
|
||||
enable_checks_sha256=no
|
||||
if test "x$enable_checks" = xno || test "x$enable_checks" = x; then
|
||||
AC_MSG_RESULT([(none)])
|
||||
else
|
||||
for arg in $enable_checks
|
||||
do
|
||||
case $arg in
|
||||
crc32)
|
||||
enable_checks_crc32=yes
|
||||
AC_DEFINE([HAVE_CHECK_CRC32], 1,
|
||||
[Define to 1 if CRC32 support
|
||||
is enabled.])
|
||||
;;
|
||||
crc64)
|
||||
enable_checks_crc64=yes
|
||||
AC_DEFINE([HAVE_CHECK_CRC64], 1,
|
||||
[Define to 1 if CRC64 support
|
||||
is enabled.])
|
||||
;;
|
||||
sha256)
|
||||
enable_checks_sha256=yes
|
||||
AC_DEFINE([HAVE_CHECK_SHA256], 1,
|
||||
[Define to 1 if SHA256 support
|
||||
is enabled.])
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([unknown integrity check: $arg])
|
||||
;;
|
||||
esac
|
||||
done
|
||||
AC_MSG_RESULT([$enable_checks])
|
||||
fi
|
||||
if test "x$enable_checks_crc32" = xno ; then
|
||||
AC_MSG_ERROR([For now, the CRC32 check must always be enabled.])
|
||||
fi
|
||||
AM_CONDITIONAL(COND_CHECK_CRC32, test "x$enable_checks_crc32" = xyes)
|
||||
AM_CONDITIONAL(COND_CHECK_CRC64, test "x$enable_checks_crc64" = xyes)
|
||||
AM_CONDITIONAL(COND_CHECK_SHA256, test "x$enable_checks_sha256" = xyes)
|
||||
|
||||
# Assembler optimizations
|
||||
AC_MSG_CHECKING([if assembler optimizations should be used])
|
||||
AC_ARG_ENABLE(assembler, AC_HELP_STRING([--disable-assembler],
|
||||
[Do not use assembler optimizations even if such exist
|
||||
for the architecture.]),
|
||||
[], [enable_assembler=yes])
|
||||
if test "x$enable_assembler" = xyes; then
|
||||
case $host_cpu in
|
||||
i?86) enable_assembler=x86 ;;
|
||||
*) enable_assembler=no ;;
|
||||
esac
|
||||
fi
|
||||
case $enable_assembler in
|
||||
x86|no) ;;
|
||||
*)
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([--enable-assembler accepts only \`yes', \`no', or \`x86'.])
|
||||
;;
|
||||
esac
|
||||
AC_MSG_RESULT([$enable_assembler])
|
||||
AM_CONDITIONAL(COND_ASM_X86, test "x$enable_assembler" = xx86)
|
||||
|
||||
# Size optimization
|
||||
AC_MSG_CHECKING([if small size is preferred over speed])
|
||||
AC_ARG_ENABLE(small, AC_HELP_STRING([--enable-small],
|
||||
[Omit precomputed tables to make liblzma a few kilobytes
|
||||
smaller. This will increase startup time of applications
|
||||
slightly, because the tables need to be computed first.]),
|
||||
[], [enable_small=no])
|
||||
if test "x$enable_small" = xyes; then
|
||||
AC_DEFINE([HAVE_SMALL], 1, [Define to 1 if optimizing for size.])
|
||||
elif test "x$enable_small" != xno; then
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_ERROR([--enable-small accepts only \`yes' or \`no'])
|
||||
fi
|
||||
AC_MSG_RESULT([$enable_small])
|
||||
AM_CONDITIONAL(COND_SMALL, test "x$enable_small" = xyes)
|
||||
|
||||
echo
|
||||
echo "Initializing Automake:"
|
||||
|
||||
# There's no C++ or Fortran in LZMA Utils:
|
||||
CXX=no
|
||||
F77=no
|
||||
|
||||
AM_INIT_AUTOMAKE
|
||||
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
|
||||
###############################################################################
|
||||
# Checks for programs.
|
||||
###############################################################################
|
||||
|
||||
AM_PROG_CC_C_O
|
||||
AM_PROG_AS
|
||||
AC_PROG_LN_S
|
||||
|
||||
echo
|
||||
echo "Threading support:"
|
||||
ACX_PTHREAD
|
||||
CC="$PTHREAD_CC"
|
||||
|
||||
echo
|
||||
echo "Initializing Libtool:"
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Checks for libraries.
|
||||
###############################################################################
|
||||
|
||||
echo
|
||||
echo "Initializing gettext:"
|
||||
AM_GNU_GETTEXT_VERSION([0.16.1])
|
||||
AM_GNU_GETTEXT([external])
|
||||
|
||||
###############################################################################
|
||||
# Checks for header files.
|
||||
###############################################################################
|
||||
|
||||
echo
|
||||
echo "System headers and functions:"
|
||||
|
||||
# There is currently no workarounds in this package if some of
|
||||
# these headers are missing.
|
||||
AC_CHECK_HEADERS([fcntl.h limits.h sys/time.h],
|
||||
[],
|
||||
[AC_MSG_ERROR([Required header file(s) are missing.])])
|
||||
|
||||
# If any of these headers are missing, things should still work correctly:
|
||||
AC_CHECK_HEADERS([assert.h errno.h byteswap.h sys/param.h sys/sysctl.h],
|
||||
[], [], [
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
])
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
###############################################################################
|
||||
|
||||
AC_HEADER_STDBOOL
|
||||
AC_C_INLINE
|
||||
AC_C_RESTRICT
|
||||
|
||||
# The command line tool can copy high resolution timestamps if such
|
||||
# information is availabe in struct stat. Otherwise one second accuracy
|
||||
# is used. Most systems seem to have st_xtim but BSDs have st_xtimespec.
|
||||
AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec, struct stat.st_mtim.tv_nsec,
|
||||
struct stat.st_atimespec.tv_nsec, struct stat.st_mtimespec.tv_nsec])
|
||||
|
||||
# It is very unlikely that you want to build liblzma without
|
||||
# large file support.
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
# At the moment, the only endian-dependent part should be the integrity checks.
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Checks for library functions.
|
||||
###############################################################################
|
||||
|
||||
# Gnulib replacements as needed
|
||||
gl_GETOPT
|
||||
|
||||
# Functions that are not mandatory i.e. we have alternatives for them
|
||||
# or we can just drop some functionality:
|
||||
AC_CHECK_FUNCS([memcpy memmove memset futimes futimesat])
|
||||
|
||||
# Check how to find out the amount of physical memory in the system. The
|
||||
# lzma command line tool uses this to automatically limits its memory usage.
|
||||
# - sysconf() gives all the needed info on GNU+Linux and Solaris.
|
||||
# - BSDs use sysctl().
|
||||
AC_MSG_CHECKING([how to detect the amount of physical memory])
|
||||
AC_COMPILE_IFELSE([
|
||||
#include <unistd.h>
|
||||
int
|
||||
main()
|
||||
{
|
||||
long i;
|
||||
i = sysconf(_SC_PAGESIZE);
|
||||
i = sysconf(_SC_PHYS_PAGES);
|
||||
return 0;
|
||||
}
|
||||
], [
|
||||
AC_DEFINE([HAVE_PHYSMEM_SYSCONF], 1,
|
||||
[Define to 1 if the amount of physical memory can be detected
|
||||
with sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES).])
|
||||
AC_MSG_RESULT([sysconf])
|
||||
], [
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
#include <sys/sysctl.h>
|
||||
int
|
||||
main()
|
||||
{
|
||||
int name[2] = { CTL_HW, HW_PHYSMEM };
|
||||
unsigned long mem;
|
||||
size_t mem_ptr_size = sizeof(mem);
|
||||
sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
]])], [
|
||||
AC_DEFINE([HAVE_PHYSMEM_SYSCTL], 1,
|
||||
[Define to 1 if the amount of physical memory can be detected
|
||||
with sysctl().])
|
||||
AC_MSG_RESULT([sysctl])
|
||||
], [
|
||||
AC_MSG_RESULT([unknown])
|
||||
])])
|
||||
|
||||
# Check how to find out the number of available CPU cores in the system.
|
||||
# sysconf(_SC_NPROCESSORS_ONLN) works on most systems, except that BSDs
|
||||
# use sysctl().
|
||||
AC_MSG_CHECKING([how to detect the number of available CPU cores])
|
||||
AC_COMPILE_IFELSE([
|
||||
#include <unistd.h>
|
||||
int
|
||||
main()
|
||||
{
|
||||
long i;
|
||||
i = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
return 0;
|
||||
}
|
||||
], [
|
||||
AC_DEFINE([HAVE_NCPU_SYSCONF], 1,
|
||||
[Define to 1 if the number of available CPU cores can be
|
||||
detected with sysconf(_SC_NPROCESSORS_ONLN).])
|
||||
AC_MSG_RESULT([sysconf])
|
||||
], [
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
#include <sys/sysctl.h>
|
||||
int
|
||||
main()
|
||||
{
|
||||
int name[2] = { CTL_HW, HW_NCPU };
|
||||
int cpus;
|
||||
size_t cpus_size = sizeof(cpus);
|
||||
sysctl(name, 2, &cpus, &cpus_size, NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
]])], [
|
||||
AC_DEFINE([HAVE_NCPU_SYSCTL], 1,
|
||||
[Define to 1 if the number of available CPU cores can be
|
||||
detected with sysctl().])
|
||||
AC_MSG_RESULT([sysctl])
|
||||
], [
|
||||
AC_MSG_RESULT([unknown])
|
||||
])])
|
||||
|
||||
|
||||
###############################################################################
|
||||
# If using GCC, set some additional CFLAGS:
|
||||
###############################################################################
|
||||
|
||||
Wno_uninitialized=no
|
||||
|
||||
if test -n "$GCC" ; then
|
||||
echo
|
||||
echo "GCC extensions:"
|
||||
gl_VISIBILITY
|
||||
if test -n "$CFLAG_VISIBILITY" ; then
|
||||
CFLAGS="$CFLAG_VISIBILITY $CFLAGS"
|
||||
fi
|
||||
|
||||
# -Wno-uninitialized is needed with -Werror with SHA256 code
|
||||
# to omit a bogus warning.
|
||||
AC_MSG_CHECKING([if $CC accepts -Wno-uninitialized])
|
||||
OLD_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Wno-uninitialized"
|
||||
AC_COMPILE_IFELSE([void foo(void) { }], [Wno_uninitialized=yes])
|
||||
CFLAGS="$OLD_CFLAGS"
|
||||
AC_MSG_RESULT([$Wno_uninitialized])
|
||||
|
||||
# Enable as much warnings as possible. These commented warnings won't
|
||||
# work for LZMA Utils though:
|
||||
# * -Wunreachable-code breaks several assert(0) cases, which are
|
||||
# backed up with "return LZMA_PROG_ERROR".
|
||||
# * -Wcast-qual would break various things where we need a non-const
|
||||
# pointer although we don't modify anything through it.
|
||||
# * -Wcast-align breaks optimized CRC32 and CRC64 implementation
|
||||
# on some architectures (not on x86), where this warning is bogus,
|
||||
# because we take care of correct alignment.
|
||||
for NEW_FLAG in -Wextra -Wformat=2 -Winit-self -Wstrict-aliasing=2 \
|
||||
-Wfloat-equal -Wshadow -Wunsafe-loop-optimizations \
|
||||
-Wpointer-arith -Wbad-function-cast -Wwrite-strings \
|
||||
-Waggregate-return -Wstrict-prototypes \
|
||||
-Wold-style-definition -Wmissing-prototypes \
|
||||
-Wmissing-declarations -Wmissing-noreturn \
|
||||
-Wredundant-decls -Winline -Wdisabled-optimization
|
||||
do
|
||||
AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
|
||||
OLD_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$NEW_FLAG $CFLAGS"
|
||||
AC_COMPILE_IFELSE([void foo(void) { }], [
|
||||
AC_MSG_RESULT([yes])
|
||||
], [
|
||||
CFLAGS="$OLD_CFLAGS"
|
||||
AC_MSG_RESULT([no])
|
||||
])
|
||||
done
|
||||
|
||||
AC_ARG_ENABLE([werror],
|
||||
AC_HELP_STRING([--enable-werror], [Enable -Werror to abort
|
||||
compilation on all compiler warnings.]),
|
||||
[], [enable_werror=no])
|
||||
if test "x$enable_werror" = "xyes"; then
|
||||
CFLAGS="-Werror $CFLAGS"
|
||||
fi
|
||||
|
||||
# IIRC these work with all GCC versions that support -std=c99:
|
||||
CFLAGS="-std=c99 -pedantic -Wall $CFLAGS"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([COND_WNO_UNINITIALIZED], test "x$Wno_uninitialized" = "xyes")
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Create the makefiles and config.h
|
||||
###############################################################################
|
||||
|
||||
echo
|
||||
|
||||
# Don't build the lib directory at all if we don't need any replacement
|
||||
# functions.
|
||||
AM_CONDITIONAL([COND_GNULIB], test -n "$LIBOBJS")
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Doxyfile
|
||||
Makefile
|
||||
po/Makefile.in
|
||||
lib/Makefile
|
||||
src/Makefile
|
||||
src/liblzma/lzma.pc
|
||||
src/liblzma/Makefile
|
||||
src/liblzma/api/Makefile
|
||||
src/liblzma/common/Makefile
|
||||
src/liblzma/check/Makefile
|
||||
src/liblzma/lz/Makefile
|
||||
src/liblzma/lzma/Makefile
|
||||
src/liblzma/simple/Makefile
|
||||
src/liblzma/subblock/Makefile
|
||||
src/liblzma/rangecoder/Makefile
|
||||
src/lzma/Makefile
|
||||
src/lzmadec/Makefile
|
||||
src/scripts/Makefile
|
||||
tests/Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
46
doc/bugs.txt
Normal file
46
doc/bugs.txt
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
Reporting bugs
|
||||
--------------
|
||||
|
||||
Naturally it is easiest for me if you already know what causes the
|
||||
unexpected behavior. Even better if you have a patch to propose.
|
||||
However, quite often the reason for unexpected behavior is unknown,
|
||||
so below are a few things what to do before sending a bug report.
|
||||
|
||||
In case of a crash (usually segmentation violation):
|
||||
|
||||
1. Try to create a small example how to reprocude the issue.
|
||||
|
||||
2. If you are writing an application using liblzma or libzfile,
|
||||
double check that you are using the libraries correctly (for
|
||||
example, that you didn't forget to call lzma_init()). If it is
|
||||
the command line tool included in LZMA Utils that is crashing,
|
||||
ignore this step.
|
||||
|
||||
3. Compile LZMA Utils with debugging code using configure switch
|
||||
`--enable-debug'. If you are using GCC as the compiler, use
|
||||
CFLAGS='-O0 -ggdb'. Don't strip the resulting binaries.
|
||||
|
||||
4. Turn on core dumps. The exact command depends on your shell;
|
||||
for example in GNU bash it is done with `ulimit -c unlimited',
|
||||
and in tcsh with `limit coredumpsize unlimited'.
|
||||
|
||||
5. Try to reproduce the suspected bug. If you get `assertion failed'
|
||||
message, be sure to include the complete message in your bug
|
||||
report. If the application leaves a coredump, get a backtrace
|
||||
using gdb:
|
||||
$ gdb /path/to/app-binary # Loads the app to the debugger.
|
||||
(gdb) core core # Opens the coredump.
|
||||
(gdb) bt # Prints the backtrace. Copy & paste to bug report.
|
||||
(gdb) quit # Quits gdb.
|
||||
|
||||
Send your bug report to Lasse Collin <lasse.collin@tukaani.org>. Don't
|
||||
send the core dump file or the actual executables. If you have a small
|
||||
example file(s) (total size less than 100 KiB), please include it/them
|
||||
as an attachment.
|
||||
|
||||
Do NOT complain about problems with LZMA Utils to Igor Pavlov.
|
||||
Although the code of LZMA Utils is derived from his code, there are
|
||||
a lot of changes, which may have introduced bugs not present in
|
||||
the original version.
|
||||
|
||||
247
doc/faq.txt
Normal file
247
doc/faq.txt
Normal file
@ -0,0 +1,247 @@
|
||||
|
||||
LZMA Utils FAQ
|
||||
--------------
|
||||
|
||||
Copyright (C) 2007 Lasse Collin
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved.
|
||||
|
||||
|
||||
Q: What are LZMA, LZMA Utils, lzma, .lzma, liblzma, LZMA SDK, LZMA_Alone,
|
||||
7-Zip and p7zip?
|
||||
|
||||
A: LZMA stands for Lempel-Ziv-Markov chain-Algorithm. LZMA is the name
|
||||
of the compression algorithm designed by Igor Pavlov. He is the author
|
||||
of 7-Zip, which is a great LGPL'd compression tool for Microsoft
|
||||
Windows operating systems. In addition to 7-Zip itself, also LZMA SDK
|
||||
is available on the website of 7-Zip. LZMA SDK contains LZMA
|
||||
implementations in C++, Java and C#. The C++ version is the original
|
||||
implementation which is used also in 7-Zip itself.
|
||||
|
||||
Excluding the unrar plugin, 7-Zip is free software (free as in
|
||||
freedom). Thanks to this, it was possible to port it to POSIX
|
||||
platforms. The port was done and is maintained by myspace (TODO:
|
||||
myspace's real name?). p7zip is a port of 7-Zip's command line version;
|
||||
p7zip doesn't include the 7-Zip's GUI.
|
||||
|
||||
In POSIX world, users are used to gzip and bzip2 command line tools.
|
||||
Developers know APIs of zlib and libbzip2. LZMA Utils try to ease
|
||||
adoption of LZMA on free operating systems by providing a compression
|
||||
library and a set of command line tools. The library is called liblzma.
|
||||
It provides a zlib-like API making it easy to adapt LZMA compression in
|
||||
existing applications. The main command line tool is known as lzma,
|
||||
whose command line syntax is very similar to that of gzip and bzip2.
|
||||
|
||||
The original command line tool from LZMA SDK (lzma.exe) was found from
|
||||
a directory called LZMA_Alone in the LZMA SDK. It used a simple header
|
||||
format in .lzma files. This format was also used by LZMA Utils up to
|
||||
and including 4.32.x. In LZMA Utils documentation, LZMA_Alone refers
|
||||
to both the file format and the command line tool from LZMA SDK.
|
||||
|
||||
Because of various limitations of the LZMA_Alone file format, a new
|
||||
file format was developed. Extending some existing format such as .gz
|
||||
used by gzip was considered, but these formats were found to be too
|
||||
limited. The filename suffix for the new .lzma format is `.lzma'. The
|
||||
same suffix is also used for files in the LZMA_Alone format. To make
|
||||
the transition to the new format as transparent as possible, LZMA Utils
|
||||
support both the new and old formats transparently.
|
||||
|
||||
7-Zip and LZMA SDK: <http://7-zip.org/>
|
||||
p7zip: <http://p7zip.sourceforge.net/>
|
||||
LZMA Utils: <http://tukaani.org/lzma/>
|
||||
|
||||
|
||||
Q: What LZMA implementations there are available?
|
||||
|
||||
A: LZMA SDK contains implementations in C++, Java and C#. The C++ version
|
||||
is the original implementation which is part of 7-Zip. LZMA SDK
|
||||
contains also a small LZMA decoder in C.
|
||||
|
||||
A port of LZMA SDK to Pascal was made by Alan Birtles
|
||||
<http://www.birtles.org.uk/programming/>. It should work with
|
||||
multiple Pascal programming language implementations.
|
||||
|
||||
LZMA Utils includes liblzma, which is directly based on LZMA SDK.
|
||||
liblzma is written in C (C99, not C89). In contrast to C++ callback
|
||||
API used by LZMA SDK, liblzma uses zlib-like stateful C API. I do not
|
||||
want to comment whether both/former/latter/neither API(s) are good or
|
||||
bad. The only reason to implement a zlib-like API was, that many
|
||||
developers are already familiar with zlib, and very many applications
|
||||
already use zlib. Having a similar API makes it easier to include LZMA
|
||||
support in existing applications.
|
||||
|
||||
See also <http://en.wikipedia.org/wiki/LZMA#External_links>.
|
||||
|
||||
|
||||
Q: Which file formats are supported by LZMA Utils?
|
||||
|
||||
A: Even when the raw LZMA stream is always the same, it can be wrapped
|
||||
in different container formats. The preferred format is the new .lzma
|
||||
format. It has magic bytes (the first six bytes: 0xFF 'L' 'Z' 'M'
|
||||
'A' 0x00). The format supports chaining up to seven filters filters,
|
||||
splitting data to multiple blocks for easier multi-threading and rough
|
||||
random-access reading. The file integrity is verified using CRC32,
|
||||
CRC64, or SHA256, and by verifying the uncompressed size of the file.
|
||||
|
||||
LZMA SDK includes a tool called LZMA_Alone. It supports uses a
|
||||
primitive header which includes only the mandatory stream information
|
||||
required by the LZMA decoder. This format can be both read and
|
||||
written by liblzma and the command line tool (use --format=alone to
|
||||
create such files).
|
||||
|
||||
.7z is the native archive format used by 7-Zip. This format is not
|
||||
supported by liblzma, and probably will never be supported. You
|
||||
should use e.g. p7zip to extract .7z files.
|
||||
|
||||
It is possible to implement custom file formats by using raw filter
|
||||
mode in liblzma. In this mode the application needs to store the filter
|
||||
properties and provide them to liblzma before starting to uncompress
|
||||
the data.
|
||||
|
||||
|
||||
Q: How can I identify files containing LZMA compressed data?
|
||||
|
||||
A: The preferred filename suffix for .lzma files is `.lzma'. `.tar.lzma'
|
||||
may be abbreviated to `.tlz'. The same suffixes are used for files in
|
||||
LZMA_Alone format. In practice this should be no problem since tools
|
||||
included in LZMA Utils support both formats transparently.
|
||||
|
||||
Checking the magic bytes is easy way to detect files in the new .lzma
|
||||
format (the first six bytes: 0xFF 'L' 'Z' 'M' 'A' 0x00). The "file"
|
||||
command version FIXME contains magic strings for this format.
|
||||
|
||||
The old LZMA_Alone format has no magic bytes. Its header cannot contain
|
||||
arbitrary bytes, thus it is possible to make a guess. Unfortunately the
|
||||
guessing is usually too hard to be reliable, so don't try it unless you
|
||||
are desperate.
|
||||
|
||||
|
||||
Q: Does the lzma command line tool support sparse files?
|
||||
|
||||
A: Sparse files can (of course) be compressed like normal files, but
|
||||
uncompression will not restore sparseness of the file. Use an archiver
|
||||
tool to take care of sparseness before compressing the data with lzma.
|
||||
|
||||
The reason for this is that archiver tools handle files, while
|
||||
compression tools handle streams or buffers. Being a sparse file is
|
||||
a property of the file on the disk, not a property of the stream or
|
||||
buffer.
|
||||
|
||||
|
||||
Q: Can I recover parts of a broken LZMA file (e.g. corrupted CD-R)?
|
||||
|
||||
A: With LZMA_Alone and single-block .lzma files, you can uncompress the
|
||||
file until you hit the first broken byte. The data after the broken
|
||||
position is lost. LZMA relies on the uncompression history, and if
|
||||
bytes are missing in the middle of the file, it is impossible to
|
||||
reliably continue after the broken section.
|
||||
|
||||
With multi-block .lzma files it may be possible to locale the next
|
||||
block in the file and continue decoding there. A limited recovery
|
||||
tool for this kind of situations is planned.
|
||||
|
||||
|
||||
Q: Is LZMA patented?
|
||||
|
||||
A: No, the authors are not aware of any patents that could affect LZMA.
|
||||
However, due to nature of software patents, the authors cannot
|
||||
guarantee, that LZMA isn't affected by any third party patent.
|
||||
|
||||
|
||||
Q: Where can I find documentation about how LZMA works as an algorithm?
|
||||
|
||||
A: Read the source code, Luke. There is no documentation about LZMA
|
||||
internals. It is possible that Igor Pavlov is the only person on
|
||||
the Earth that completely knows and understands the algorithm.
|
||||
|
||||
You could begin by downloading LZMA SDK, and start reading from
|
||||
the LZMA decoder to get some idea about the bitstream format.
|
||||
Before you begin, you should know the basics of LZ77 and
|
||||
range coding algorithms. LZMA is based on LZ77, but LZMA is
|
||||
*a lot* more complex. Range coding is used to compress the
|
||||
final bitstream like Huffman coding is used in Deflate.
|
||||
|
||||
|
||||
Q: What are filters?
|
||||
|
||||
A: In context of .lzma files, a filter means an implementation of a
|
||||
compression algorithm. The primary filter is LZMA, which is why
|
||||
the names of the tools contain the letters LZMA.
|
||||
|
||||
liblzma and the new .lzma format support also other filters than LZMA.
|
||||
There are different types of filters, which are suitable for different
|
||||
types of data. Thus, to select the optimal filter and settings, the
|
||||
type of the input data being compressed needs to be known.
|
||||
|
||||
Some filters are most useful when combined with another filter like
|
||||
LZMA. These filters increase redundancy in the data, without changing
|
||||
the size of the data, by taking advantage of properties specific to
|
||||
the data being compressed.
|
||||
|
||||
So far, all the filters are always reversible. That is, no matter what
|
||||
data you pass to a filter encoder, it can be always defiltered back to
|
||||
the original form. Because of this, it is safe to compress for example
|
||||
a software package that contains other file types than executables
|
||||
using a filter specific to the architechture of the package being
|
||||
compressed.
|
||||
|
||||
The old LZMA_Alone format supports only the LZMA filter.
|
||||
|
||||
|
||||
Q: I cannot find BCJ and BCJ2 filters. Don't they exist in liblzma?
|
||||
|
||||
A: BCJ filter is called "x86" in liblzma. BCJ2 is not included,
|
||||
because it requires using more than one encoded output stream.
|
||||
|
||||
|
||||
Q: Can I use LZMA in proprietary, non-free applications?
|
||||
|
||||
A: liblzma is under the GNU LGPL version 2.1 or (at your opinion) any
|
||||
later version. To summarise (*NOTE* This summary is not legally
|
||||
binding, that is, it doesn't give you any extra permissions compared
|
||||
to the LGPL. Read the GNU LGPL carefully for the exact license
|
||||
conditions.):
|
||||
* All the changes made into the library itself must be published
|
||||
under the same license.
|
||||
* End users must be able to replace the used liblzma. Easiest way
|
||||
to assure this is to link dynamically against liblzma so users
|
||||
can replace the shared library file if they want.
|
||||
* You must make it clear to your users, that your application uses
|
||||
liblzma, and that liblzma is free software under the GNU LGPL.
|
||||
A copy of GNU LGPL must be included.
|
||||
|
||||
LZMA SDK contains a special exception which allows linking *unmodified*
|
||||
code statically with a non-free application. This exception does *not*
|
||||
apply to liblzma.
|
||||
|
||||
As an alternative, you can support the development of LZMA and 7-Zip
|
||||
by buying a proprietary license from Igor Pavlov. See homepage of
|
||||
LZMA SDK <http://7-zip.org/sdk.html> for more information. Note that
|
||||
having a proprietary license from Igor Pavlov doesn't allow you to use
|
||||
liblzma in a way that contradicts with the GNU LGPL, because liblzma
|
||||
contains code that is not copyrighted by Igor Pavlov. Please contact
|
||||
both Lasse Collin and Igor Pavlov if the license conditions of liblzma
|
||||
are not suitable for you.
|
||||
|
||||
|
||||
Q: I would like to help. What can I do?
|
||||
|
||||
A: See the TODO file. Please contact Lasse Collin before starting to do
|
||||
anything, because it is possible that someone else is already working
|
||||
on the same thing.
|
||||
|
||||
|
||||
Q: How can I contact the authors?
|
||||
|
||||
A: Lasse Collin is the maintainer of LZMA Utils. You can contact him
|
||||
either via IRC (Larhzu on #tukaani at Freenode or IRCnet). Email
|
||||
should work too, <lasse.collin@tukaani.org>.
|
||||
|
||||
Igor Pavlov is the father of LZMA. He is the author of 7-Zip
|
||||
and LZMA SDK. <http://7-zip.org/>
|
||||
|
||||
NOTE: Please don't bother Igor Pavlov with questions specific
|
||||
to LZMA Utils.
|
||||
|
||||
1861
doc/file-format.txt
Normal file
1861
doc/file-format.txt
Normal file
File diff suppressed because it is too large
Load Diff
140
doc/history.txt
Normal file
140
doc/history.txt
Normal file
@ -0,0 +1,140 @@
|
||||
|
||||
LZMA Utils history
|
||||
------------------
|
||||
|
||||
Tukaani distribution
|
||||
|
||||
In 2005, there was a small group working on Tukaani distribution, which
|
||||
was a Slackware fork. One of the project goals was to fit the distro on
|
||||
a single 700 MiB ISO-9660 image. Using LZMA instead of gzip helped a
|
||||
lot. Roughly speaking, one could fit data that took 1000 MiB in gzipped
|
||||
form into 700 MiB with LZMA. Naturally compression ratio varied across
|
||||
packages, but this was what we got on average.
|
||||
|
||||
Slackware packages have traditionally had .tgz as the filename suffix,
|
||||
which is an abbreviation of .tar.gz. A logical naming for LZMA
|
||||
compressed packages was .tlz, being an abbreviation of .tar.lzma.
|
||||
|
||||
At the end of the year 2007, there's no distribution under the Tukaani
|
||||
project anymore. Development of LZMA Utils still continues. Still,
|
||||
there are .tlz packages around, because at least Vector Linux (a
|
||||
Slackware based distribution) uses LZMA for its packages.
|
||||
|
||||
First versions of the modified pkgtools used the LZMA_Alone tool from
|
||||
Igor Pavlov's LZMA SDK as is. It was fine, because users wouldn't need
|
||||
to interact with LZMA_Alone directly. But people soon wanted to use
|
||||
LZMA for other files too, and the interface of LZMA_Alone wasn't
|
||||
comfortable for those used to gzip and bzip2.
|
||||
|
||||
|
||||
First steps of LZMA Utils
|
||||
|
||||
The first version of LZMA Utils (4.22.0) included a shell script called
|
||||
lzmash. It was wrapper that had gzip-like command line interface. It
|
||||
used the LZMA_Alone tool from LZMA SDK to do all the real work. zgrep,
|
||||
zdiff, and related scripts from gzip were adapted work with LZMA and
|
||||
were part of the first LZMA Utils release too.
|
||||
|
||||
LZMA Utils 4.22.0 included also lzmadec, which was a small (less than
|
||||
10 KiB) decoder-only command line tool. It was written on top of the
|
||||
decoder-only C code found from the LZMA SDK. lzmadec was convenient in
|
||||
situations where LZMA_Alone (a few hundred KiB) would be too big.
|
||||
|
||||
lzmash and lzmadec were written by Lasse Collin.
|
||||
|
||||
|
||||
Second generation
|
||||
|
||||
The lzmash script was an ugly and not very secure hack. The last
|
||||
version of LZMA Utils to use lzmash was 4.27.1.
|
||||
|
||||
LZMA Utils 4.32.0beta1 introduced a new lzma command line tool written
|
||||
by Ville Koskinen. It was written in C++, and used the encoder and
|
||||
decoder from C++ LZMA SDK with little modifications. This tool replaced
|
||||
both the lzmash script and the LZMA_Alone command line tool in LZMA
|
||||
Utils.
|
||||
|
||||
Introducing this new tool caused some temporary incompatibilities,
|
||||
because LZMA_Alone executable was simply named lzma like the new
|
||||
command line tool, but they had completely different command line
|
||||
interface. The file format was still the same.
|
||||
|
||||
Lasse wrote liblzmadec, which was a small decoder-only library based on
|
||||
the C code found from LZMA SDK. liblzmadec had API similar to zlib,
|
||||
although there were some significant differences, which made it
|
||||
non-trivial to use it in some applications designed for zlib and
|
||||
libbzip2.
|
||||
|
||||
The lzmadec command line tool was converted to use liblzmadec.
|
||||
|
||||
Alexandre Sauvé helped converting build system to use GNU Autotools.
|
||||
This made is easier to test for certain less portable features needed
|
||||
by the new command line tool.
|
||||
|
||||
Since the new command line tool never got completely finished (for
|
||||
example, it didn't support LZMA_OPT environment variable), the intent
|
||||
was to not call 4.32.x stable. Similarly, liblzmadec wasn't polished,
|
||||
but appeared to work well enough, so some people started using it too.
|
||||
|
||||
Because the development of the third generation of LZMA Utils was
|
||||
delayed considerably (roughly two years), the 4.32.x branch had to be
|
||||
kept maintained. It got some bug fixes now and then, and finally it was
|
||||
decided to call it stable, although most of the missing features were
|
||||
never added.
|
||||
|
||||
|
||||
File format problems
|
||||
|
||||
The file format used by LZMA_Alone was primitive. It was designed for
|
||||
embedded systems in mind, and thus provided only minimal set of
|
||||
features. The two biggest problems for non-embedded use were lack of
|
||||
magic bytes and integrity check.
|
||||
|
||||
Igor and Lasse started developing a new file format with some help from
|
||||
Ville Koskinen, Mark Adler and Mikko Pouru. Designing the new format
|
||||
took quite a long time. It was mostly because Lasse was quite slow at
|
||||
getting things done due to personal reasons.
|
||||
|
||||
Near the end of the year 2007 the new format was practically finished.
|
||||
Compared to LZMA_Alone format and the .gz format used by gzip, the new
|
||||
.lzma format is quite complex as a whole. This means that tools having
|
||||
*full* support for the new format would be larger and more complex than
|
||||
the tools supporting only the old LZMA_Alone format.
|
||||
|
||||
For the situations where the full support for the .lzma format wouldn't
|
||||
be required (embedded systems, operating system kernels), the new
|
||||
format has a well-defined subset, which is easy to support with small
|
||||
amount of code. It wouldn't be as small as an implementation using the
|
||||
LZMA_Alone format, but the difference shouldn't be significant.
|
||||
|
||||
The new .lzma format allows dividing the data in multiple independent
|
||||
blocks, which can be compressed and uncompressed independenly. This
|
||||
makes multi-threading possible with algorithms that aren't inherently
|
||||
parallel (such as LZMA). There's also a central index of the sizes of
|
||||
the blocks, which makes it possible to do limited random-access reading
|
||||
with granularity of the block size.
|
||||
|
||||
The new .lzma format uses the same filename suffix that was used for
|
||||
LZMA_Alone files. The advantage is that users using the new tools won't
|
||||
notice the change to the new format. The disadvantage is that the old
|
||||
tools won't work with the new files.
|
||||
|
||||
|
||||
Third generation
|
||||
|
||||
LZMA Utils 4.42.0alphas drop the rest of the C++ LZMA SDK. The LZMA and
|
||||
other included filters (algorithm implementations) are still directly
|
||||
based on LZMA SDK, but ported to C.
|
||||
|
||||
liblzma is now the core of LZMA Utils. It has zlib-like API, which
|
||||
doesn't suffer from the problems of the API of liblzmadec. liblzma
|
||||
supports not only LZMA, but several other filters, which together
|
||||
can improve compression ratio even further with certain file types.
|
||||
|
||||
The lzma and lzmadec command line tools have been rewritten. They uses
|
||||
liblzma to do the actual compressing or uncompressing.
|
||||
|
||||
The development of LZMA Utils 4.42.x is still in alpha stage. Several
|
||||
features are still missing or don't fully work yet. Documentation is
|
||||
also very minimal.
|
||||
|
||||
324
doc/liblzma-advanced.txt
Normal file
324
doc/liblzma-advanced.txt
Normal file
@ -0,0 +1,324 @@
|
||||
|
||||
Advanced features of liblzma
|
||||
----------------------------
|
||||
|
||||
0. Introduction
|
||||
|
||||
Most developers need only the basic features of liblzma. These
|
||||
features allow single-threaded encoding and decoding of .lzma files
|
||||
in streamed mode.
|
||||
|
||||
In some cases developers want more. The .lzma file format is
|
||||
designed to allow multi-threaded encoding and decoding and limited
|
||||
random-access reading. These features are possible in non-streamed
|
||||
mode and limitedly also in streamed mode.
|
||||
|
||||
To take advange of these features, the application needs a custom
|
||||
.lzma file format handler. liblzma provides a set of tools to ease
|
||||
this task, but it's still quite a bit of work to get a good custom
|
||||
.lzma handler done.
|
||||
|
||||
|
||||
1. Where to begin
|
||||
|
||||
Start by reading the .lzma file format specification. Understanding
|
||||
the basics of the .lzma file structure is required to implement a
|
||||
custom .lzma file handler and to understand the rest of this document.
|
||||
|
||||
|
||||
2. The basic components
|
||||
|
||||
2.1. Stream Header and tail
|
||||
|
||||
Stream Header begins the .lzma Stream and Stream tail ends it. Stream
|
||||
Header is defined in the file format specification, but Stream tail
|
||||
isn't (thus I write "tail" with a lower-case letter). Stream tail is
|
||||
simply the Stream Flags and the Footer Magic Bytes fields together.
|
||||
It was done this way in liblzma, because the Block coders take care
|
||||
of the rest of the stuff in the Stream Footer.
|
||||
|
||||
For now, the size of Stream Header is fixed to 11 bytes. The header
|
||||
<lzma/stream_flags.h> defines LZMA_STREAM_HEADER_SIZE, which you
|
||||
should use instead of a hardcoded number. Similarly, Stream tail
|
||||
is fixed to 3 bytes, and there is a constant LZMA_STREAM_TAIL_SIZE.
|
||||
|
||||
It is possible, that a future version of the .lzma format will have
|
||||
variable-sized Stream Header and tail. As of writing, this seems so
|
||||
unlikely though, that it was considered simplest to just use a
|
||||
constant instead of providing a functions to get and store the sizes
|
||||
of the Stream Header and tail.
|
||||
|
||||
|
||||
2.x. Stream tail
|
||||
|
||||
For now, the size of Stream tail is fixed to 3 bytes. The header
|
||||
<lzma/stream_flags.h> defines LZMA_STREAM_TAIL_SIZE, which you
|
||||
should use instead of a hardcoded number.
|
||||
|
||||
|
||||
3. Keeping track of size information
|
||||
|
||||
The lzma_info_* functions found from <lzma/info.h> should ease the
|
||||
task of keeping track of sizes of the Blocks and also the Stream
|
||||
as a whole. Using these functions is strongly recommended, because
|
||||
there are surprisingly many situations where an error can occur,
|
||||
and these functions check for possible errors every time some new
|
||||
information becomes available.
|
||||
|
||||
If you find lzma_info_* functions lacking something that you would
|
||||
find useful, please contact the author.
|
||||
|
||||
|
||||
3.1. Start offset of the Stream
|
||||
|
||||
If you are storing the .lzma Stream inside anothe file format, or
|
||||
for some other reason are placing the .lzma Stream to somewhere
|
||||
else than to the beginning of the file, you should tell the starting
|
||||
offset of the Stream using lzma_info_start_offset_set().
|
||||
|
||||
The start offset of the Stream is used for two distinct purporses.
|
||||
First, knowing the start offset of the Stream allows
|
||||
lzma_info_alignment_get() to correctly calculate the alignment of
|
||||
every Block. This information is given to the Block encoder, which
|
||||
will calculate the size of Header Padding so that Compressed Data
|
||||
is alignment at an optimal offset.
|
||||
|
||||
Another use for start offset of the Stream is in random-access
|
||||
reading. If you set the start offset of the Stream, lzma_info_locate()
|
||||
will be able to calculate the offset relative to the beginning of the
|
||||
file containing the Stream (instead of offset relative to the
|
||||
beginning of the Stream).
|
||||
|
||||
|
||||
3.2. Size of Stream Header
|
||||
|
||||
While the size of Stream Header is constant (11 bytes) in the current
|
||||
version of the .lzma file format, this may change in future.
|
||||
|
||||
|
||||
3.3. Size of Header Metadata Block
|
||||
|
||||
This information is needed when doing random-access reading, and
|
||||
to verify the value of this field stored in Footer Metadata Block.
|
||||
|
||||
|
||||
3.4. Total Size of the Data Blocks
|
||||
|
||||
|
||||
3.5. Uncompressed Size of Data Blocks
|
||||
|
||||
|
||||
3.6. Index
|
||||
|
||||
|
||||
|
||||
|
||||
x. Alignment
|
||||
|
||||
There are a few slightly different types of alignment issues when
|
||||
working with .lzma files.
|
||||
|
||||
The .lzma format doesn't strictly require any kind of alignment.
|
||||
However, if the encoder carefully optimizes the alignment in all
|
||||
situations, it can improve compression ratio, speed of the encoder
|
||||
and decoder, and slightly help if the files get damaged and need
|
||||
recovery.
|
||||
|
||||
Alignment has the most significant effect compression ratio FIXME
|
||||
|
||||
|
||||
x.1. Compression ratio
|
||||
|
||||
Some filters take advantage of the alignment of the input data.
|
||||
To get the best compression ratio, make sure that you feed these
|
||||
filters correctly aligned data.
|
||||
|
||||
Some filters (e.g. LZMA) don't necessarily mind too much if the
|
||||
input doesn't match the preferred alignment. With these filters
|
||||
the penalty in compression ratio depends on the specific type of
|
||||
data being compressed.
|
||||
|
||||
Other filters (e.g. PowerPC executable filter) won't work at all
|
||||
with data that is improperly aligned. While the data can still
|
||||
be de-filtered back to its original form, the benefit of the
|
||||
filtering (better compression ratio) is completely lost, because
|
||||
these filters expect certain patterns at properly aligned offsets.
|
||||
The compression ratio may even worse with incorrectly aligned input
|
||||
than without the filter.
|
||||
|
||||
|
||||
x.1.1. Inter-filter alignment
|
||||
|
||||
When there are multiple filters chained, checking the alignment can
|
||||
be useful not only with the input of the first filter and output of
|
||||
the last filter, but also between the filters.
|
||||
|
||||
Inter-filter alignment important especially with the Subblock filter.
|
||||
|
||||
|
||||
x.1.2. Further compression with external tools
|
||||
|
||||
This is relatively rare situation in practice, but still worth
|
||||
understanding.
|
||||
|
||||
Let's say that there are several SPARC executables, which are each
|
||||
filtered to separate .lzma files using only the SPARC filter. If
|
||||
Uncompressed Size is written to the Block Header, the size of Block
|
||||
Header may vary between the .lzma files. If no Padding is used in
|
||||
the Block Header to correct the alignment, the starting offset of
|
||||
the Compressed Data field will be differently aligned in different
|
||||
.lzma files.
|
||||
|
||||
All these .lzma files are archived into a single .tar archive. Due
|
||||
to nature of the .tar format, every file is aligned inside the
|
||||
archive to an offset that is a multiple of 512 bytes.
|
||||
|
||||
The .tar archive is compressed into a new .lzma file using the LZMA
|
||||
filter with options, that prefer input alignment of four bytes. Now
|
||||
if the independent .lzma files don't have the same alignment of
|
||||
the Compressed Data fields, the LZMA filter will be unable to take
|
||||
advantage of the input alignment between the files in the .tar
|
||||
archive, which reduces compression ratio.
|
||||
|
||||
Thus, even if you have only single Block per file, it can be good for
|
||||
compression ratio to align the Compressed Data to optimal offset.
|
||||
|
||||
|
||||
x.2. Speed
|
||||
|
||||
Most modern computers are faster when multi-byte data is located
|
||||
at aligned offsets in RAM. Proper alignment of the Compressed Data
|
||||
fields can slightly increase the speed of some filters.
|
||||
|
||||
|
||||
x.3. Recovery
|
||||
|
||||
Aligning every Block Header to start at an offset with big enough
|
||||
alignment may ease or at least speed up recovery of broken files.
|
||||
|
||||
|
||||
y. Typical usage cases
|
||||
|
||||
y.x. Parsing the Stream backwards
|
||||
|
||||
You may need to parse the Stream backwards if you need to get
|
||||
information such as the sizes of the Stream, Index, or Extra.
|
||||
The basic procedure to do this follows.
|
||||
|
||||
Locate the end of the Stream. If the Stream is stored as is in a
|
||||
standalone .lzma file, simply seek to the end of the file and start
|
||||
reading backwards using appropriate buffer size. The file format
|
||||
specification allows arbitrary amount of Footer Padding (zero or more
|
||||
NUL bytes), which you skip before trying to decode the Stream tail.
|
||||
|
||||
Once you have located the end of the Stream (a non-NULL byte), make
|
||||
sure you have at least the last LZMA_STREAM_TAIL_SIZE bytes of the
|
||||
Stream in a buffer. If there isn't enough bytes left from the file,
|
||||
the file is too small to contain a valid Stream. Decode the Stream
|
||||
tail using lzma_stream_tail_decoder(). Store the offset of the first
|
||||
byte of the Stream tail; you will need it later.
|
||||
|
||||
You may now want to do some internal verifications e.g. if the Check
|
||||
type is supported by the liblzma build you are using.
|
||||
|
||||
Decode the Backward Size field with lzma_vli_reverse_decode(). The
|
||||
field is at maximum of LZMA_VLI_BYTES_MAX bytes long. Check that
|
||||
Backward Size is not zero. Store the offset of the first byte of
|
||||
the Backward Size; you will need it later.
|
||||
|
||||
Now you know the Total Size of the last Block of the Stream. It's the
|
||||
value of Backward Size plus the size of the Backward Size field. Note
|
||||
that you cannot use lzma_vli_size() to calculate the size since there
|
||||
might be padding; you need to use the real observed size of the
|
||||
Backward Size field.
|
||||
|
||||
At this point, the operation continues differently for Single-Block
|
||||
and Multi-Block Streams.
|
||||
|
||||
|
||||
y.x.1. Single-Block Stream
|
||||
|
||||
There might be Uncompressed Size field present in the Stream Footer.
|
||||
You cannot know it for sure unless you have already parsed the Block
|
||||
Header earlier. For security reasons, you probably want to try to
|
||||
decode the Uncompressed Size field, but you must not indicate any
|
||||
error if decoding fails. Later you can give the decoded Uncompressed
|
||||
Size to Block decoder if Uncopmressed Size isn't otherwise known;
|
||||
this prevents it from producing too much output in case of (possibly
|
||||
intentionally) corrupt file.
|
||||
|
||||
Calculate the the start offset of the Stream:
|
||||
|
||||
backward_offset - backward_size - LZMA_STREAM_HEADER_SIZE
|
||||
|
||||
backward_offset is the offset of the first byte of the Backward Size
|
||||
field. Remember to check for integer overflows, which can occur with
|
||||
invalid input files.
|
||||
|
||||
Seek to the beginning of the Stream. Decode the Stream Header using
|
||||
lzma_stream_header_decoder(). Verify that the decoded Stream Flags
|
||||
match the values found from Stream tail. You can use the
|
||||
lzma_stream_flags_is_equal() macro for this.
|
||||
|
||||
Decode the Block Header. Verify that it isn't a Metadata Block, since
|
||||
Single-Block Streams cannot have Metadata. If Uncompressed Size is
|
||||
present in the Block Header, the value you tried to decode from the
|
||||
Stream Footer must be ignored, since Uncompressed Size wasn't actually
|
||||
present there. If Block Header doesn't have Uncompressed Size, and
|
||||
decoding the Uncompressed Size field from the Stream Footer failed,
|
||||
the file is corrupt.
|
||||
|
||||
If you were only looking for the Uncompressed Size of the Stream,
|
||||
you now got that information, and you can stop processing the Stream.
|
||||
|
||||
To decode the Block, the same instructions apply as described in
|
||||
FIXME. However, because you have some extra known information decoded
|
||||
from the Stream Footer, you should give this information to the Block
|
||||
decoder so that it can verify it while decoding:
|
||||
- If Uncompressed Size is not present in the Block Header, set
|
||||
lzma_options_block.uncompressed_size to the value you decoded
|
||||
from the Stream Footer.
|
||||
- Always set lzma_options_block.total_size to backward_size +
|
||||
size_of_backward_size (you calculated this sum earlier already).
|
||||
|
||||
|
||||
y.x.2. Multi-Block Stream
|
||||
|
||||
Calculate the start offset of the Footer Metadata Block:
|
||||
|
||||
backward_offset - backward_size
|
||||
|
||||
backward_offset is the offset of the first byte of the Backward Size
|
||||
field. Remember to check for integer overflows, which can occur with
|
||||
broken input files.
|
||||
|
||||
Decode the Block Header. Verify that it is a Metadata Block. Set
|
||||
lzma_options_block.total_size to backward_size + size_of_backward_size
|
||||
(you calculated this sum earlier already). Then decode the Footer
|
||||
Metadata Block.
|
||||
|
||||
Store the decoded Footer Metadata to lzma_info structure using
|
||||
lzma_info_set_metadata(). Set also the offset of the Backward Size
|
||||
field using lzma_info_size_set(). Then you can get the start offset
|
||||
of the Stream using lzma_info_size_get(). Note that any of these steps
|
||||
may fail so don't omit error checking.
|
||||
|
||||
Seek to the beginning of the Stream. Decode the Stream Header using
|
||||
lzma_stream_header_decoder(). Verify that the decoded Stream Flags
|
||||
match the values found from Stream tail. You can use the
|
||||
lzma_stream_flags_is_equal() macro for this.
|
||||
|
||||
If you were only looking for the Uncompressed Size of the Stream,
|
||||
it's possible that you already have it now. If Uncompressed Size (or
|
||||
whatever information you were looking for) isn't available yet,
|
||||
continue by decoding also the Header Metadata Block. (If some
|
||||
information is missing, the Header Metadata Block has to be present.)
|
||||
|
||||
Decoding the Data Blocks goes the same way as described in FIXME.
|
||||
|
||||
|
||||
y.x.3. Variations
|
||||
|
||||
If you know the offset of the beginning of the Stream, you may want
|
||||
to parse the Stream Header before parsing the Stream tail.
|
||||
|
||||
112
doc/liblzma-hacking.txt
Normal file
112
doc/liblzma-hacking.txt
Normal file
@ -0,0 +1,112 @@
|
||||
|
||||
Hacking liblzma
|
||||
---------------
|
||||
|
||||
0. Preface
|
||||
|
||||
This document gives some overall information about the internals of
|
||||
liblzma, which should make it easier to start reading and modifying
|
||||
the code.
|
||||
|
||||
|
||||
1. Programming language
|
||||
|
||||
liblzma was written in C99. If you use GCC, this means that you need
|
||||
at least GCC 3.x.x. GCC 2 isn't and won't be supported.
|
||||
|
||||
Some GCC-specific extensions are used *conditionally*. They aren't
|
||||
required to build a full-featured library. Don't make the code rely
|
||||
on any non-standard compiler extensions or even C99 features that
|
||||
aren't portable between almost-C99 compatible compilers (for example
|
||||
non-static inlines).
|
||||
|
||||
The public API headers are in C89. This is to avoid frustrating those
|
||||
who maintain programs, which are strictly in C89 or C++.
|
||||
|
||||
An assumption about sizeof(size_t) is made. If this assumption is
|
||||
wrong, some porting is probably needed:
|
||||
|
||||
sizeof(uint32_t) <= sizeof(size_t) <= sizeof(uint64_t)
|
||||
|
||||
|
||||
2. Internal vs. external API
|
||||
|
||||
|
||||
|
||||
Input Output
|
||||
v Application ^
|
||||
| liblzma public API |
|
||||
| Stream coder |
|
||||
| Block coder |
|
||||
| Filter coder |
|
||||
| ... |
|
||||
v Filter coder ^
|
||||
|
||||
|
||||
Application
|
||||
`-- liblzma public API
|
||||
`-- Stream coder
|
||||
|-- Stream info handler
|
||||
|-- Stream Header coder
|
||||
|-- Block Header coder
|
||||
| `-- Filter Flags coder
|
||||
|-- Metadata coder
|
||||
| `-- Block coder
|
||||
| `-- Filter 0
|
||||
| `-- Filter 1
|
||||
| ...
|
||||
|-- Data Block coder
|
||||
| `-- Filter 0
|
||||
| `-- Filter 1
|
||||
| ...
|
||||
`-- Stream tail coder
|
||||
|
||||
|
||||
|
||||
x. Designing new filters
|
||||
|
||||
All filters must be designed so that the decoder cannot consume
|
||||
arbitrary amount input without producing any decoded output. Failing
|
||||
to follow this rule makes liblzma vulnerable to DoS attacks if
|
||||
untrusted files are decoded (usually they are untrusted).
|
||||
|
||||
An example should clarify the reason behind this requirement: There
|
||||
are two filters in the chain. The decoder of the first filter produces
|
||||
huge amount of output (many gigabytes or more) with a few bytes of
|
||||
input, which gets passed to the decoder of the second filter. If the
|
||||
data passed to the second filter is interpreted as something that
|
||||
produces no output (e.g. padding), the filter chain as a whole
|
||||
produces no output and consumes no input for a long period of time.
|
||||
|
||||
The above problem was present in the first versions of the Subblock
|
||||
filter. A tiny .lzma file could have taken several years to decode
|
||||
while it wouldn't produce any output at all. The problem was fixed
|
||||
by adding limits for number of consecutive Padding bytes, and requiring
|
||||
that some decoded output must be produced between Set Subfilter and
|
||||
Unset Subfilter.
|
||||
|
||||
|
||||
x. Implementing new filters
|
||||
|
||||
If the filter supports embedding End of Payload Marker, make sure that
|
||||
when your filter detects End of Payload Marker,
|
||||
- the usage of End of Payload Marker is actually allowed (i.e. End
|
||||
of Input isn't used); and
|
||||
- it also checks that there is no more input coming from the next
|
||||
filter in the chain.
|
||||
|
||||
The second requirement is slightly tricky. It's possible that the next
|
||||
filter hasn't returned LZMA_STREAM_END yet. It may even need a few
|
||||
bytes more input before it will do so. You need to give it as much
|
||||
input as it needs, and verify that it doesn't produce any output.
|
||||
|
||||
Don't call the next filter in the chain after it has returned
|
||||
LZMA_STREAM_END (except in encoder if action == LZMA_SYNC_FLUSH).
|
||||
It will result undefined behavior.
|
||||
|
||||
Be pedantic. If the input data isn't exactly valid, reject it.
|
||||
|
||||
At the moment, liblzma isn't modular. You will need to edit several
|
||||
files in src/liblzma/common to include support for a new filter. grep
|
||||
for LZMA_FILTER_LZMA to locate the files needing changes.
|
||||
|
||||
188
doc/liblzma-intro.txt
Normal file
188
doc/liblzma-intro.txt
Normal file
@ -0,0 +1,188 @@
|
||||
|
||||
Introduction to liblzma
|
||||
-----------------------
|
||||
|
||||
Writing applications to work with liblzma
|
||||
|
||||
liblzma API is split in several subheaders to improve readability and
|
||||
maintainance. The subheaders must not be #included directly; simply
|
||||
use `#include <lzma.h>' instead.
|
||||
|
||||
Those who have used zlib should find liblzma's API easy to use.
|
||||
To developers who haven't used zlib before, I recommend learning
|
||||
zlib first, because zlib has excellent documentation.
|
||||
|
||||
While the API is similar to that of zlib, there are some major
|
||||
differences, which are summarized below.
|
||||
|
||||
For basic stream encoding, zlib has three functions (deflateInit(),
|
||||
deflate(), and deflateEnd()). Similarly, there are three functions
|
||||
for stream decoding (inflateInit(), inflate(), and inflateEnd()).
|
||||
liblzma has only single coding and ending function. Thus, to
|
||||
encode one may use, for example, lzma_stream_encoder_single(),
|
||||
lzma_code(), and lzma_end(). Simlarly for decoding, one may
|
||||
use lzma_auto_decoder(), lzma_code(), and lzma_end().
|
||||
|
||||
zlib has deflateReset() and inflateReset() to reset the stream
|
||||
structure without reallocating all the memory. In liblzma, all
|
||||
coder initialization functions are like zlib's reset functions:
|
||||
the first-time initializations are done with the same functions
|
||||
as the reinitializations (resetting).
|
||||
|
||||
To make all this work, liblzma needs to know when lzma_stream
|
||||
doesn't already point to an allocated and initialized coder.
|
||||
This is achieved by initializing lzma_stream structure with
|
||||
LZMA_STREAM_INIT (static initialization) or LZMA_STREAM_INIT_VAR
|
||||
(for exampple when new lzma_stream has been allocated with malloc()).
|
||||
This initialization should be done exactly once per lzma_stream
|
||||
structure to avoid leaking memory. Calling lzma_end() will leave
|
||||
lzma_stream into a state comparable to the state achieved with
|
||||
LZMA_STREAM_INIT and LZMA_STREAM_INIT_VAR.
|
||||
|
||||
Example probably clarifies a lot. With zlib, compression goes
|
||||
roughly like this:
|
||||
|
||||
z_stream strm;
|
||||
deflateInit(&strm, level);
|
||||
deflate(&strm, Z_RUN);
|
||||
deflate(&strm, Z_RUN);
|
||||
...
|
||||
deflate(&strm, Z_FINISH);
|
||||
deflateEnd(&strm) or deflateReset(&strm)
|
||||
|
||||
With liblzma, it's slightly different:
|
||||
|
||||
lzma_stream strm = LZMA_STREAM_INIT;
|
||||
lzma_stream_encoder_single(&strm, &options);
|
||||
lzma_code(&strm, LZMA_RUN);
|
||||
lzma_code(&strm, LZMA_RUN);
|
||||
...
|
||||
lzma_code(&strm, LZMA_FINISH);
|
||||
lzma_end(&strm) or reinitialize for new coding work
|
||||
|
||||
Reinitialization in the last step can be any function that can
|
||||
initialize lzma_stream; it doesn't need to be the same function
|
||||
that was used for the previous initialization. If it is the same
|
||||
function, liblzma will usually be able to re-use most of the
|
||||
existing memory allocations (depends on how much the initialization
|
||||
options change). If you reinitialize with different function,
|
||||
liblzma will automatically free the memory of the previous coder.
|
||||
|
||||
|
||||
File formats
|
||||
|
||||
liblzma supports multiple container formats for the compressed data.
|
||||
Different initialization functions initialize the lzma_stream to
|
||||
process different container formats. See the details from the public
|
||||
header files.
|
||||
|
||||
The following functions are the most commonly used:
|
||||
|
||||
- lzma_stream_encoder_single(): Encodes Single-Block Stream; this
|
||||
the recommended format for most purporses.
|
||||
|
||||
- lzma_alone_encoder(): Useful if you need to encode into the
|
||||
legacy LZMA_Alone format.
|
||||
|
||||
- lzma_auto_decoder(): Decoder that automatically detects the
|
||||
file format; recommended when you decode compressed files on
|
||||
disk, because this way compatibility with the legacy LZMA_Alone
|
||||
format is transparent.
|
||||
|
||||
- lzma_stream_decoder(): Decoder for Single- and Multi-Block
|
||||
Streams; this is good if you want to accept only .lzma Streams.
|
||||
|
||||
|
||||
Filters
|
||||
|
||||
liblzma supports multiple filters (algorithm implementations). The new
|
||||
.lzma format supports filter-chain having up to seven filters. In the
|
||||
filter chain, the output of one filter is input of the next filter in
|
||||
the chain. The legacy LZMA_Alone format supports only one filter, and
|
||||
that must always be LZMA.
|
||||
|
||||
General-purporse compression:
|
||||
|
||||
LZMA The main algorithm of liblzma (surprise!)
|
||||
|
||||
Branch/Call/Jump filters for executables:
|
||||
|
||||
x86 This filter is known as BCJ in 7-Zip
|
||||
IA64 IA-64 (Itanium)
|
||||
PowerPC Big endian PowerPC
|
||||
ARM
|
||||
ARM-Thumb
|
||||
SPARC
|
||||
|
||||
Other filters:
|
||||
|
||||
Copy Dummy filter that simply copies all the data
|
||||
from input to output.
|
||||
|
||||
Subblock Multi-purporse filter, that can
|
||||
- embed End of Payload Marker if the previous
|
||||
filter in the chain doesn't support it; and
|
||||
- apply Subfilters, which filter only part
|
||||
of the same compressed Block in the Stream.
|
||||
|
||||
Branch/Call/Jump filters never change the size of the data. They
|
||||
should usually be used as a pre-filter for some compression filter
|
||||
like LZMA.
|
||||
|
||||
|
||||
Integrity checks
|
||||
|
||||
The .lzma Stream format uses CRC32 as the integrity check for
|
||||
different file format headers. It is possible to omit CRC32 from
|
||||
the Block Headers, but not from Stream Header. This is the reason
|
||||
why CRC32 code cannot be disabled when building liblzma (in addition,
|
||||
the LZMA encoder uses CRC32 for hashing, so that's another reason).
|
||||
|
||||
The integrity check of the actual data is calculated from the
|
||||
uncompressed data. This check can be CRC32, CRC64, or SHA256.
|
||||
It can also be omitted completely, although that usually is not
|
||||
a good thing to do. There are free IDs left, so support for new
|
||||
checks algorithms can be added later.
|
||||
|
||||
|
||||
API and ABI stability
|
||||
|
||||
The API and ABI of liblzma isn't stable yet, although no huge
|
||||
changes should happen. One potential place for change is the
|
||||
lzma_options_subblock structure.
|
||||
|
||||
In the 4.42.0alpha phase, the shared library version number won't
|
||||
be updated even if ABI breaks. I don't want to track the ABI changes
|
||||
yet. Just rebuild everything when you upgrade liblzma until we get
|
||||
to the beta stage.
|
||||
|
||||
|
||||
Size of the library
|
||||
|
||||
While liblzma isn't huge, it is quite far from the smallest possible
|
||||
LZMA implementation: full liblzma binary (with support for all
|
||||
filters and other features) is way over 100 KiB, but the plain raw
|
||||
LZMA decoder is only 5-10 KiB.
|
||||
|
||||
To decrease the size of the library, you can omit parts of the library
|
||||
by passing certain options to the `configure' script. Disabling
|
||||
everything but the decoders of the require filters will usually give
|
||||
you a small enough library, but if you need a decoder for example
|
||||
embedded in the operating system kernel, the code from liblzma probably
|
||||
isn't suitable as is.
|
||||
|
||||
If you need a minimal implementation supporting .lzma Streams, you
|
||||
may need to do partial rewrite. liblzma uses stateful API like zlib.
|
||||
That increases the size of the library. Using callback API or even
|
||||
simpler buffer-to-buffer API would allow smaller implementation.
|
||||
|
||||
LZMA SDK contains smaller LZMA decoder written in ANSI-C than
|
||||
liblzma, so you may want to take a look at that code. However,
|
||||
it doesn't (at least not yet) support the new .lzma Stream format.
|
||||
|
||||
|
||||
Documentation
|
||||
|
||||
There's no other documentation than the public headers and this
|
||||
text yet. Real docs will be written some day, I hope.
|
||||
|
||||
219
doc/liblzma-security.txt
Normal file
219
doc/liblzma-security.txt
Normal file
@ -0,0 +1,219 @@
|
||||
|
||||
Using liblzma securely
|
||||
----------------------
|
||||
|
||||
0. Introduction
|
||||
|
||||
This document discusses how to use liblzma securely. There are issues
|
||||
that don't apply to zlib or libbzip2, so reading this document is
|
||||
strongly recommended even for those who are very familiar with zlib
|
||||
or libbzip2.
|
||||
|
||||
While making liblzma itself as secure as possible is essential, it's
|
||||
out of scope of this document.
|
||||
|
||||
|
||||
1. Memory usage
|
||||
|
||||
The memory usage of liblzma varies a lot.
|
||||
|
||||
|
||||
1.1. Problem sources
|
||||
|
||||
1.1.1. Block coder
|
||||
|
||||
The memory requirements of Block encoder depend on the used filters
|
||||
and their settings. The memory requirements of the Block decoder
|
||||
depend on the which filters and with which filter settings the Block
|
||||
was encoded. Usually the memory requirements of a decoder are equal
|
||||
or less than the requirements of the encoder with the same settings.
|
||||
|
||||
While the typical memory requirements to decode a Block is from a few
|
||||
hundred kilobytes to tens of megabytes, a maliciously constructed
|
||||
files can require a lot more RAM to decode. With the current filters,
|
||||
the maximum amount is about 7 GiB. If you use multi-threaded decoding,
|
||||
every Block can require this amount of RAM, thus a four-threaded
|
||||
decoder could suddenly try to allocate 28 GiB of RAM.
|
||||
|
||||
If you don't limit the maximum memory usage in any way, and there are
|
||||
no resource limits set on the operating system side, one malicious
|
||||
input file can run the system out of memory, or at least make it swap
|
||||
badly for a long time. This is exceptionally bad on servers e.g.
|
||||
email server doing virus scanning on incoming messages.
|
||||
|
||||
|
||||
1.1.2. Metadata decoder
|
||||
|
||||
Multi-Block .lzma files contain at least one Metadata Block.
|
||||
Externally the Metadata Blocks are similar to Data Blocks, so all
|
||||
the issues mentioned about memory usage of Data Blocks applies to
|
||||
Metadata Blocks too.
|
||||
|
||||
The uncompressed content of Metadata Blocks contain information about
|
||||
the Stream as a whole, and optionally some Extra Records. The
|
||||
information about the Stream is kept in liblzma's internal data
|
||||
structures in RAM. Extra Records can contain arbitrary data. They are
|
||||
not interpreted by liblzma, but liblzma will provide them to the
|
||||
application in uninterpreted form if the application wishes so.
|
||||
|
||||
Usually the Uncompressed Size of a Metadata Block is small. Even on
|
||||
extreme cases, it shouldn't be much bigger than a few megabytes. Once
|
||||
the Metadata has been parsed into native data structures in liblzma,
|
||||
it usually takes a little more memory than in the encoded form. For
|
||||
all normal files, this is no problem, since the resulting memory usage
|
||||
won't be too much.
|
||||
|
||||
The problem is that a maliciously constructed Metadata Block can
|
||||
contain huge amount of "information", which liblzma will try to store
|
||||
in its internal data structures. This may cause liblzma to allocate
|
||||
all the available RAM unless some kind of resource usage limits are
|
||||
applied.
|
||||
|
||||
Note that the Extra Records in Metadata are always parsed but, but
|
||||
memory is allocated for them only if the application has requested
|
||||
liblzma to provide the Extra Records to the application.
|
||||
|
||||
|
||||
1.2. Solutions
|
||||
|
||||
If you need to decode files from untrusted sources (most people do),
|
||||
you must limit the memory usage to avoid denial of service (DoS)
|
||||
conditions caused by malicious input files.
|
||||
|
||||
The first step is to find out how much memory you are allowed consume
|
||||
at maximum. This may be a hardcoded constant or derived from the
|
||||
available RAM; whatever is appropriate in the application.
|
||||
|
||||
The simplest solution is to use setrlimit() if the kernel supports
|
||||
RLIMIT_AS, which limits the memory usage of the whole process.
|
||||
For more portable and fine-grained limitting, you can use
|
||||
memory limitter functions found from <lzma/memlimit.h>.
|
||||
|
||||
|
||||
1.2.1. Encoder
|
||||
|
||||
lzma_memory_usage() will give you a rough estimate about the memory
|
||||
usage of the given filter chain. To dramatically simplify the internal
|
||||
implementation, this function doesn't take into account all the small
|
||||
helper data structures needed in various places; only the structures
|
||||
with significant memory usage are taken into account. Still, the
|
||||
accuracy of this function should be well within a mebibyte.
|
||||
|
||||
The Subblock filter is a special case. If a Subfilter has been
|
||||
specified, it isn't taken into account when lzma_memory_usage()
|
||||
calculates the memory usage. You need to calculate the memory usage
|
||||
of the Subfilter separately.
|
||||
|
||||
Keeping track of Blocks in a Multi-Block Stream takes a few dozen
|
||||
bytes of RAM per Block (size of the lzma_index structure plus overhead
|
||||
of malloc()). It isn't a good idea to put tens of thousands of Blocks
|
||||
into a Stream unless you have a very good reason to do so (compressed
|
||||
dictionary could be an example of such situation).
|
||||
|
||||
Also keep the number and sizes of Extra Records sane. If you produce
|
||||
the list of Extra Records automatically from some untrusted source,
|
||||
you should not only validate the content of these Records, but also
|
||||
their memory usage.
|
||||
|
||||
|
||||
1.2.2. Decoder
|
||||
|
||||
A single-threaded decoder should simply use a memory limitter and
|
||||
indicate an error if it runs out of memory.
|
||||
|
||||
Memory-limitting with multi-threaded decoding is tricky. The simple
|
||||
solution is to divide the maximum allowed memory usage with the
|
||||
maximum allowed threads, and give each Block decoder their own
|
||||
independent lzma_memory_limitter. The drawback is that if one Block
|
||||
needs notably more RAM than any other Block, the decoder will run out
|
||||
of memory when in reality there would be plenty of free RAM.
|
||||
|
||||
An attractive alternative would be using shared lzma_memory_limitter.
|
||||
Depending on the application and the expected type of input, this may
|
||||
either be the best solution or a source of hard-to-repeat problems.
|
||||
Consider the following requirements:
|
||||
- You use at maximum of n threads.
|
||||
- x(i) is the decoder memory requirements of the Block number i
|
||||
in an expected input Stream.
|
||||
- The memory limitter is set to higher value than the sum of n
|
||||
highest values x(i).
|
||||
|
||||
(If you are better at explaining the above conditions, please
|
||||
contribute your improved version.)
|
||||
|
||||
If the above conditions aren't met, it is possible that the decoding
|
||||
will fail unpredictably. That is, on the same machine using the same
|
||||
settings, the decoding may sometimes succeed and sometimes fail. This
|
||||
is because sometimes threads may run so that the Blocks with highest
|
||||
memory usage are tried to be decoded at the same time.
|
||||
|
||||
Most .lzma files have all the Blocks encoded with identical settings,
|
||||
or at least the memory usage won't vary dramatically. That's why most
|
||||
multi-threaded decoders probably want to use the simple "separate
|
||||
lzma_memory_limitter for each thread" solution, possibly fallbacking
|
||||
to single-threaded mode in case the per-thread memory limits aren't
|
||||
enough in multi-threaded mode.
|
||||
|
||||
FIXME: Memory usage of Stream info.
|
||||
|
||||
[
|
||||
|
||||
]
|
||||
|
||||
|
||||
2. Huge uncompressed output
|
||||
|
||||
2.1. Data Blocks
|
||||
|
||||
Decoding a tiny .lzma file can produce huge amount of uncompressed
|
||||
output. There is an example file of 45 bytes, which decodes to 64 PiB
|
||||
(that's 2^56 bytes). Uncompressing such a file to disk is likely to
|
||||
fill even a bigger disk array. If the data is written to a pipe, it
|
||||
may not fill the disk, but would still take very long time to finish.
|
||||
|
||||
To avoid denial of service conditions caused by huge amount of
|
||||
uncompressed output, applications using liblzma should use some method
|
||||
to limit the amount of output produced. The exact method depends on
|
||||
the application.
|
||||
|
||||
All valid .lzma Streams make it possible to find out the uncompressed
|
||||
size of the Stream without actually uncompressing the data. This
|
||||
information is available in at least one of the Metadata Blocks.
|
||||
Once the uncompressed size is parsed, the decoder can verify that
|
||||
it doesn't exceed certain limits (e.g. available disk space).
|
||||
|
||||
When the uncompressed size is known, the decoder can actively keep
|
||||
track of the amount of output produced so far, and that it doesn't
|
||||
exceed the known uncompressed size. If it does exceed, the file is
|
||||
known to be corrupt and an error should be indicated without
|
||||
continuing to decode the rest of the file.
|
||||
|
||||
Unfortunately, finding the uncompressed size beforehand is often
|
||||
possible only in non-streamed mode, because the needed information
|
||||
could be in the Footer Metdata Block, which (obviously) is at the
|
||||
end of the Stream. In purely streamed mode decoding, one may need to
|
||||
use some rough arbitrary limits to prevent the problems described in
|
||||
the beginning of this section.
|
||||
|
||||
|
||||
2.2. Metadata
|
||||
|
||||
Metadata is stored in Metadata Blocks, which are very similar to
|
||||
Data Blocks. Thus, the uncompressed size can be huge just like with
|
||||
Data Blocks. The difference is, that the contents of Metadata Blocks
|
||||
aren't given to the application as is, but parsed by liblzma. Still,
|
||||
reading through a huge Metadata can take very long time, effectively
|
||||
creating a denial of service like piping decoded a Data Block to
|
||||
another process would do.
|
||||
|
||||
At first it would seem that using a memory limitter would prevent
|
||||
this issue as a side effect. But it does so only if the application
|
||||
requests liblzma to allocate the Extra Records and provide them to
|
||||
the application. If Extra Records aren't requested, they aren't
|
||||
allocated either. Still, the Extra Records are being read through
|
||||
to validate that the Metadata is in proper format.
|
||||
|
||||
The solution is to limit the Uncompressed Size of a Metadata Block
|
||||
to some relatively large value. This will make liblzma to give an
|
||||
error when the given limit is reached.
|
||||
|
||||
107
doc/lzma-intro.txt
Normal file
107
doc/lzma-intro.txt
Normal file
@ -0,0 +1,107 @@
|
||||
|
||||
Introduction to the lzma command line tool
|
||||
------------------------------------------
|
||||
|
||||
Overview
|
||||
|
||||
The lzma command line tool is similar to gzip and bzip2, but for
|
||||
compressing and uncompressing .lzma files.
|
||||
|
||||
|
||||
Supported file formats
|
||||
|
||||
By default, the tool creates files in the new .lzma format. This can
|
||||
be overriden with --format=FMT command line option. Use --format=alone
|
||||
to create files in the old LZMA_Alone format.
|
||||
|
||||
By default, the tool uncompresses both the new .lzma format and
|
||||
LZMA_Alone format. This is to make it transparent to switch from
|
||||
the old LZMA_Alone format to the new .lzma format. Since both
|
||||
formats use the same filename suffix, average user should never
|
||||
notice which format was used.
|
||||
|
||||
|
||||
Differences to gzip and bzip2
|
||||
|
||||
Standard input and output
|
||||
|
||||
Both gzip and bzip2 refuse to write compressed data to a terminal and
|
||||
read compressed data from a terminal. With gzip (but not with bzip2),
|
||||
this can be overriden with the `--force' option. lzma follows the
|
||||
behavior of gzip here.
|
||||
|
||||
Usage of LZMA_OPT environment variable
|
||||
|
||||
gzip and bzip2 read GZIP and BZIP2 environment variables at startup.
|
||||
These variables may contain extra command line options.
|
||||
|
||||
gzip and bzip2 allow passing not only options, but also end-of-options
|
||||
indicator (`--') and filenames via the environment variable. No quoting
|
||||
is supported with the filenames.
|
||||
|
||||
Here are examples with gzip. bzip2 behaves identically.
|
||||
|
||||
bash$ echo asdf > 'foo bar'
|
||||
bash$ GZIP='"foo bar"' gzip
|
||||
gzip: "foo: No such file or directory
|
||||
gzip: bar": No such file or directory
|
||||
|
||||
bash$ GZIP=-- gzip --help
|
||||
gzip: --help: No such file or directory
|
||||
|
||||
lzma silently ignores all non-option arguments given via the
|
||||
environment variable LZMA_OPT. Like on the command line, everything
|
||||
after `--' is taken as non-options, and thus ignored in LZMA_OPT.
|
||||
|
||||
bash$ LZMA_OPT='--help' lzma --version # Displays help
|
||||
bash$ LZMA_OPT='-- --help' lzma --version # Displays version
|
||||
|
||||
|
||||
Filter chain presets
|
||||
|
||||
Like in gzip and bzip2, lzma supports numbered presets from 1 to 9
|
||||
where 1 is the fastest and 9 the best compression. 1 and 2 are for
|
||||
fast compressing with small memory usage, 3 to 6 for good compression
|
||||
ratio with medium memory usage, and 7 to 9 for excellent compression
|
||||
ratio with higher memory requirements. The default is 7 if memory
|
||||
usage limit allows.
|
||||
|
||||
In future, there will probably be an option like --preset=NAME, which
|
||||
will contain more special presets for specific file types.
|
||||
|
||||
It's also possible that there will be some heuristics to select good
|
||||
filters. For example, the tool could detect when a .tar archive is
|
||||
being compressed, and enable x86 filter only for those files in the
|
||||
.tar archive that are ELF or PE executables for x86.
|
||||
|
||||
|
||||
Specifying custom filter chains
|
||||
|
||||
Custom filter chains are specified by using long options with the name
|
||||
of the filters in correct order. For example, to pass the input data to
|
||||
the x86 filter and the output of that to the LZMA filter, the following
|
||||
command will do:
|
||||
|
||||
lzma --x86 --lzma filename
|
||||
|
||||
Some filters accept options, which are specified as a comma-separated
|
||||
list of key=value pairs:
|
||||
|
||||
lzma --delta=distance=4 --lzma=dict=4Mi,lc=8,lp=2 filename
|
||||
|
||||
|
||||
Memory usage control
|
||||
|
||||
By default, the command line tool limits memory usage to 1/3 of the
|
||||
available physical RAM. If no preset or custom filter chain has been
|
||||
given, the default preset will be used. If the memory limit is too
|
||||
low for the default preset, the tool will silently switch to lower
|
||||
preset.
|
||||
|
||||
When a preset or a custom filter chain has been specified and the
|
||||
memory limit is too low, an error message is displayed and no files
|
||||
are processed.
|
||||
|
||||
If the decoder hits the memory usage limit, an error is displayed and
|
||||
no more files are processed.
|
||||
|
||||
85
extra/scanlzma/scanlzma.c
Normal file
85
extra/scanlzma/scanlzma.c
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
scanlzma, scan for lzma compressed data in stdin and echo it to stdout.
|
||||
Copyright (C) 2006 Timo Lindfors
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/* Usage example:
|
||||
|
||||
$ wget http://www.wifi-shop.cz/Files/produkty/wa2204/wa2204av1.4.1.zip
|
||||
$ unzip wa2204av1.4.1.zip
|
||||
$ gcc scanlzma.c -o scanlzma -Wall
|
||||
$ ./scanlzma 0 < WA2204-FW1.4.1/linux-1.4.bin | lzma -c -d | strings | grep -i "copyright"
|
||||
UpdateDD version 2.5, Copyright (C) 2005 Philipp Benner.
|
||||
Copyright (C) 2005 Philipp Benner.
|
||||
Copyright (C) 2005 Philipp Benner.
|
||||
mawk 1.3%s%s %s, Copyright (C) Michael D. Brennan
|
||||
# Copyright (C) 1998, 1999, 2001 Henry Spencer.
|
||||
...
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* LZMA compressed file format */
|
||||
/* --------------------------- */
|
||||
/* Offset Size Description */
|
||||
/* 0 1 Special LZMA properties for compressed data */
|
||||
/* 1 4 Dictionary size (little endian) */
|
||||
/* 5 8 Uncompressed size (little endian). -1 means unknown size */
|
||||
/* 13 Compressed data */
|
||||
|
||||
#define BUFSIZE 4096
|
||||
|
||||
int find_lzma_header(unsigned char *buf) {
|
||||
return (buf[0] < 0xE1
|
||||
&& buf[0] == 0x5d
|
||||
&& buf[4] < 0x20
|
||||
&& (memcmp (buf + 10 , "\x00\x00\x00", 3) == 0
|
||||
|| (memcmp (buf + 5, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 8) == 0)));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char buf[BUFSIZE];
|
||||
int ret, i, numlzma, blocks=0;
|
||||
|
||||
if (argc != 2) {
|
||||
printf("usage: %s numlzma < infile | lzma -c -d > outfile\n"
|
||||
"where numlzma is index of lzma file to extract, starting from zero.\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
numlzma = atoi(argv[1]);
|
||||
|
||||
for (;;) {
|
||||
/* Read data. */
|
||||
ret = fread(buf, BUFSIZE, 1, stdin);
|
||||
if (ret != 1)
|
||||
break;
|
||||
|
||||
/* Scan for signature. */
|
||||
for (i = 0; i<BUFSIZE-23; i++) {
|
||||
if (find_lzma_header(buf+i) && numlzma-- <= 0) {
|
||||
fwrite(buf+i, (BUFSIZE-i), 1, stdout);
|
||||
for (;;) {
|
||||
int ch;
|
||||
ch = getchar();
|
||||
if (ch == EOF)
|
||||
exit(0);
|
||||
putchar(ch);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
blocks++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
40
lib/Makefile.am
Normal file
40
lib/Makefile.am
Normal file
@ -0,0 +1,40 @@
|
||||
##
|
||||
## Copyright (C) 2004-2007 Free Software Foundation, Inc.
|
||||
## Copyright (C) 2007 Lasse Collin
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
|
||||
## Not using gnulib-tool, at least for now. Less mess this way.
|
||||
|
||||
## We need two builds of libgnu: one with NLS and one without.
|
||||
## This is because lzma uses NLS but lzmadec doesn't, while
|
||||
## both need GNU getopt_long().
|
||||
noinst_LIBRARIES = libgnu.a libgnu_nls.a
|
||||
|
||||
libgnu_a_SOURCES =
|
||||
libgnu_a_DEPENDENCIES = $(LIBOBJS)
|
||||
libgnu_a_LIBADD = $(LIBOBJS)
|
||||
libgnu_a_CPPFLAGS = -DDISABLE_NLS=1
|
||||
|
||||
libgnu_nls_a_SOURCES =
|
||||
libgnu_nls_a_DEPENDENCIES = $(LIBOBJS)
|
||||
libgnu_nls_a_LIBADD = $(LIBOBJS)
|
||||
|
||||
EXTRA_DIST = gettext.h getopt_.h getopt.c getopt1.c getopt_int.h
|
||||
BUILT_SOURCES = $(GETOPT_H)
|
||||
MOSTLYCLEANFILES = getopt.h getopt.h-t
|
||||
|
||||
getopt.h: getopt_.h
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
cat $(srcdir)/getopt_.h; \
|
||||
} > $@-t
|
||||
mv -f $@-t $@
|
||||
1191
lib/getopt.c
Normal file
1191
lib/getopt.c
Normal file
File diff suppressed because it is too large
Load Diff
171
lib/getopt1.c
Normal file
171
lib/getopt1.c
Normal file
@ -0,0 +1,171 @@
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <getopt.h>
|
||||
#else
|
||||
# include <config.h>
|
||||
# include "getopt.h"
|
||||
#endif
|
||||
#include "getopt_int.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
|
||||
const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, (char **) argv, options, long_options,
|
||||
opt_index, 0, 0);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_long_r (int argc, char **argv, const char *options,
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
{
|
||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
||||
0, 0, d);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
If an option that starts with '-' (not '--') doesn't match a long option,
|
||||
but does match a short option, it is parsed as a short option
|
||||
instead. */
|
||||
|
||||
int
|
||||
getopt_long_only (int argc, char *__getopt_argv_const *argv,
|
||||
const char *options,
|
||||
const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, (char **) argv, options, long_options,
|
||||
opt_index, 1, 0);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_long_only_r (int argc, char **argv, const char *options,
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
{
|
||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
||||
1, 0, d);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
226
lib/getopt_.h
Normal file
226
lib/getopt_.h
Normal file
@ -0,0 +1,226 @@
|
||||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
|
||||
#ifndef __need_getopt
|
||||
# define _GETOPT_H 1
|
||||
#endif
|
||||
|
||||
/* Standalone applications should #define __GETOPT_PREFIX to an
|
||||
identifier that prefixes the external functions and variables
|
||||
defined in this header. When this happens, include the
|
||||
headers that might declare getopt so that they will not cause
|
||||
confusion if included after this file. Then systematically rename
|
||||
identifiers so that they do not collide with the system functions
|
||||
and variables. Renaming avoids problems with some compilers and
|
||||
linkers. */
|
||||
#if defined __GETOPT_PREFIX && !defined __need_getopt
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
# undef __need_getopt
|
||||
# undef getopt
|
||||
# undef getopt_long
|
||||
# undef getopt_long_only
|
||||
# undef optarg
|
||||
# undef opterr
|
||||
# undef optind
|
||||
# undef optopt
|
||||
# define __GETOPT_CONCAT(x, y) x ## y
|
||||
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
|
||||
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
|
||||
# define getopt __GETOPT_ID (getopt)
|
||||
# define getopt_long __GETOPT_ID (getopt_long)
|
||||
# define getopt_long_only __GETOPT_ID (getopt_long_only)
|
||||
# define optarg __GETOPT_ID (optarg)
|
||||
# define opterr __GETOPT_ID (opterr)
|
||||
# define optind __GETOPT_ID (optind)
|
||||
# define optopt __GETOPT_ID (optopt)
|
||||
#endif
|
||||
|
||||
/* Standalone applications get correct prototypes for getopt_long and
|
||||
getopt_long_only; they declare "char **argv". libc uses prototypes
|
||||
with "char *const *argv" that are incorrect because getopt_long and
|
||||
getopt_long_only can permute argv; this is required for backward
|
||||
compatibility (e.g., for LSB 2.0.1).
|
||||
|
||||
This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
|
||||
but it caused redefinition warnings if both unistd.h and getopt.h were
|
||||
included, since unistd.h includes getopt.h having previously defined
|
||||
__need_getopt.
|
||||
|
||||
The only place where __getopt_argv_const is used is in definitions
|
||||
of getopt_long and getopt_long_only below, but these are visible
|
||||
only if __need_getopt is not defined, so it is quite safe to rewrite
|
||||
the conditional as follows:
|
||||
*/
|
||||
#if !defined __need_getopt
|
||||
# if defined __GETOPT_PREFIX
|
||||
# define __getopt_argv_const /* empty */
|
||||
# else
|
||||
# define __getopt_argv_const const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If __GNU_LIBRARY__ is not already defined, either we are being used
|
||||
standalone, or this is the first header included in the source file.
|
||||
If we are being used with glibc, we need to include <features.h>, but
|
||||
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
|
||||
not defined, include <ctype.h>, which will pull in <features.h> for us
|
||||
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
|
||||
doesn't flood the namespace with stuff the way some other headers do.) */
|
||||
#if !defined __GNU_LIBRARY__
|
||||
# include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifndef __THROW
|
||||
# ifndef __GNUC_PREREQ
|
||||
# define __GNUC_PREREQ(maj, min) (0)
|
||||
# endif
|
||||
# if defined __cplusplus && __GNUC_PREREQ (2,8)
|
||||
# define __THROW throw ()
|
||||
# else
|
||||
# define __THROW
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
#ifndef __need_getopt
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
const char *name;
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
# define no_argument 0
|
||||
# define required_argument 1
|
||||
# define optional_argument 2
|
||||
#endif /* need getopt */
|
||||
|
||||
|
||||
/* Get definitions and prototypes for functions to process the
|
||||
arguments in ARGV (ARGC of them, minus the program name) for
|
||||
options given in OPTS.
|
||||
|
||||
Return the option character from OPTS just read. Return -1 when
|
||||
there are no more options. For unrecognized options, or options
|
||||
missing arguments, `optopt' is set to the option letter, and '?' is
|
||||
returned.
|
||||
|
||||
The OPTS string is a list of characters which are recognized option
|
||||
letters, optionally followed by colons, specifying that that letter
|
||||
takes an argument, to be placed in `optarg'.
|
||||
|
||||
If a letter in OPTS is followed by two colons, its argument is
|
||||
optional. This behavior is specific to the GNU `getopt'.
|
||||
|
||||
The argument `--' causes premature termination of argument
|
||||
scanning, explicitly telling `getopt' that there are no more
|
||||
options.
|
||||
|
||||
If OPTS begins with `-', then non-option arguments are treated as
|
||||
arguments to the option '\1'. This behavior is specific to the GNU
|
||||
`getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in
|
||||
the environment, then do not permute arguments. */
|
||||
|
||||
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
|
||||
__THROW;
|
||||
|
||||
#ifndef __need_getopt
|
||||
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW;
|
||||
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure we later can get all the definitions and declarations. */
|
||||
#undef __need_getopt
|
||||
|
||||
#endif /* getopt.h */
|
||||
131
lib/getopt_int.h
Normal file
131
lib/getopt_int.h
Normal file
@ -0,0 +1,131 @@
|
||||
/* Internal declarations for getopt.
|
||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _GETOPT_INT_H
|
||||
#define _GETOPT_INT_H 1
|
||||
|
||||
extern int _getopt_internal (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, int __posixly_correct);
|
||||
|
||||
|
||||
/* Reentrant versions which can handle parsing multiple argument
|
||||
vectors at the same time. */
|
||||
|
||||
/* Data type for reentrant functions. */
|
||||
struct _getopt_data
|
||||
{
|
||||
/* These have exactly the same meaning as the corresponding global
|
||||
variables, except that they are used for the reentrant
|
||||
versions of getopt. */
|
||||
int optind;
|
||||
int opterr;
|
||||
int optopt;
|
||||
char *optarg;
|
||||
|
||||
/* Internal members. */
|
||||
|
||||
/* True if the internal members have been initialized. */
|
||||
int __initialized;
|
||||
|
||||
/* The next char to be scanned in the option-element
|
||||
in which the last option character we returned was found.
|
||||
This allows us to pick up the scan where we left off.
|
||||
|
||||
If this is zero, or a null string, it means resume the scan
|
||||
by advancing to the next ARGV-element. */
|
||||
char *__nextchar;
|
||||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything,
|
||||
the default is REQUIRE_ORDER if the environment variable
|
||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
||||
|
||||
REQUIRE_ORDER means don't recognize them as options;
|
||||
stop option processing when the first non-option is seen.
|
||||
This is what Unix does.
|
||||
This mode of operation is selected by either setting the environment
|
||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
||||
of the list of option characters, or by calling getopt.
|
||||
|
||||
PERMUTE is the default. We permute the contents of ARGV as we
|
||||
scan, so that eventually all the non-options are at the end.
|
||||
This allows options to be given in any order, even with programs
|
||||
that were not written to expect this.
|
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were
|
||||
written to expect options and other ARGV-elements in any order
|
||||
and that care about the ordering of the two. We describe each
|
||||
non-option ARGV-element as if it were the argument of an option
|
||||
with character code 1. Using `-' as the first character of the
|
||||
list of option characters selects this mode of operation.
|
||||
|
||||
The special argument `--' forces an end of option-scanning regardless
|
||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
||||
|
||||
enum
|
||||
{
|
||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
||||
} __ordering;
|
||||
|
||||
/* If the POSIXLY_CORRECT environment variable is set
|
||||
or getopt was called. */
|
||||
int __posixly_correct;
|
||||
|
||||
|
||||
/* Handle permutation of arguments. */
|
||||
|
||||
/* Describe the part of ARGV that contains non-options that have
|
||||
been skipped. `first_nonopt' is the index in ARGV of the first
|
||||
of them; `last_nonopt' is the index after the last of them. */
|
||||
|
||||
int __first_nonopt;
|
||||
int __last_nonopt;
|
||||
|
||||
#if defined _LIBC && defined USE_NONOPTION_FLAGS
|
||||
int __nonoption_flags_max_len;
|
||||
int __nonoption_flags_len;
|
||||
# endif
|
||||
};
|
||||
|
||||
/* The initializer is necessary to set OPTIND and OPTERR to their
|
||||
default values and to clear the initialization flag. */
|
||||
#define _GETOPT_DATA_INITIALIZER { 1, 1 }
|
||||
|
||||
extern int _getopt_internal_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, int __posixly_correct,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
extern int _getopt_long_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
extern int _getopt_long_only_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts,
|
||||
int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
#endif /* getopt_int.h */
|
||||
240
lib/gettext.h
Normal file
240
lib/gettext.h
Normal file
@ -0,0 +1,240 @@
|
||||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 2000-2002, 2004-2006 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published
|
||||
by the Free Software Foundation; either version 2, 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
#ifndef _LIBGETTEXT_H
|
||||
#define _LIBGETTEXT_H 1
|
||||
|
||||
/* NLS can be disabled through the configure --disable-nls option.
|
||||
*
|
||||
* Extra hack in LZMA Utils: if DISABLE_NLS is defined, NLS is disabled
|
||||
* even if ENABLE_NLS is true. See Makefile.am for more information.
|
||||
*/
|
||||
#if ENABLE_NLS && !defined(DISABLE_NLS)
|
||||
|
||||
/* Get declarations of GNU message catalog functions. */
|
||||
# include <libintl.h>
|
||||
|
||||
/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
|
||||
the gettext() and ngettext() macros. This is an alternative to calling
|
||||
textdomain(), and is useful for libraries. */
|
||||
# ifdef DEFAULT_TEXT_DOMAIN
|
||||
# undef gettext
|
||||
# define gettext(Msgid) \
|
||||
dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
|
||||
# undef ngettext
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
|
||||
chokes if dcgettext is defined as a macro. So include it now, to make
|
||||
later inclusions of <locale.h> a NOP. We don't include <libintl.h>
|
||||
as well because people using "gettext.h" will not include <libintl.h>,
|
||||
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
|
||||
is OK. */
|
||||
#if defined(__sun)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
|
||||
<libintl.h>, which chokes if dcgettext is defined as a macro. So include
|
||||
it now, to make later inclusions of <libintl.h> a NOP. */
|
||||
#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
|
||||
# include <cstdlib>
|
||||
# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Disabled NLS.
|
||||
The casts to 'const char *' serve the purpose of producing warnings
|
||||
for invalid uses of the value returned from these functions.
|
||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||
contain "#define const". */
|
||||
# define gettext(Msgid) ((const char *) (Msgid))
|
||||
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
|
||||
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
|
||||
# define ngettext(Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
|
||||
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||
# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
|
||||
# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
|
||||
|
||||
#endif
|
||||
|
||||
/* A pseudo function call that serves as a marker for the automated
|
||||
extraction of messages, but does not call gettext(). The run-time
|
||||
translation is done at a different place in the code.
|
||||
The argument, String, should be a literal string. Concatenated strings
|
||||
and other string expressions won't work.
|
||||
The macro's expansion is not parenthesized, so that it is suitable as
|
||||
initializer for static 'char[]' or 'const char[]' variables. */
|
||||
#define gettext_noop(String) String
|
||||
|
||||
/* The separator between msgctxt and msgid in a .mo file. */
|
||||
#define GETTEXT_CONTEXT_GLUE "\004"
|
||||
|
||||
/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
|
||||
MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
|
||||
short and rarely need to change.
|
||||
The letter 'p' stands for 'particular' or 'special'. */
|
||||
#ifdef DEFAULT_TEXT_DOMAIN
|
||||
# define pgettext(Msgctxt, Msgid) \
|
||||
pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
|
||||
#else
|
||||
# define pgettext(Msgctxt, Msgid) \
|
||||
pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
|
||||
#endif
|
||||
#define dpgettext(Domainname, Msgctxt, Msgid) \
|
||||
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
|
||||
#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
|
||||
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
|
||||
#ifdef DEFAULT_TEXT_DOMAIN
|
||||
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
|
||||
npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
|
||||
#else
|
||||
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
|
||||
npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
|
||||
#endif
|
||||
#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
|
||||
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
|
||||
#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
|
||||
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
|
||||
|
||||
static inline const char *
|
||||
pgettext_aux (const char *domain,
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
int category)
|
||||
{
|
||||
const char *translation = dcgettext (domain, msg_ctxt_id, category);
|
||||
if (translation == msg_ctxt_id)
|
||||
return msgid;
|
||||
else
|
||||
return translation;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
npgettext_aux (const char *domain,
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
{
|
||||
const char *translation =
|
||||
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
||||
if (translation == msg_ctxt_id || translation == msgid_plural)
|
||||
return (n == 1 ? msgid : msgid_plural);
|
||||
else
|
||||
return translation;
|
||||
}
|
||||
|
||||
/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
|
||||
can be arbitrary expressions. But for string literals these macros are
|
||||
less efficient than those above. */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
|
||||
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#define pgettext_expr(Msgctxt, Msgid) \
|
||||
dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
|
||||
#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
|
||||
dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
|
||||
|
||||
static inline const char *
|
||||
dcpgettext_expr (const char *domain,
|
||||
const char *msgctxt, const char *msgid,
|
||||
int category)
|
||||
{
|
||||
size_t msgctxt_len = strlen (msgctxt) + 1;
|
||||
size_t msgid_len = strlen (msgid) + 1;
|
||||
const char *translation;
|
||||
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
char msg_ctxt_id[msgctxt_len + msgid_len];
|
||||
#else
|
||||
char buf[1024];
|
||||
char *msg_ctxt_id =
|
||||
(msgctxt_len + msgid_len <= sizeof (buf)
|
||||
? buf
|
||||
: (char *) malloc (msgctxt_len + msgid_len));
|
||||
if (msg_ctxt_id != NULL)
|
||||
#endif
|
||||
{
|
||||
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
|
||||
msg_ctxt_id[msgctxt_len - 1] = '\004';
|
||||
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
|
||||
translation = dcgettext (domain, msg_ctxt_id, category);
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
if (msg_ctxt_id != buf)
|
||||
free (msg_ctxt_id);
|
||||
#endif
|
||||
if (translation != msg_ctxt_id)
|
||||
return translation;
|
||||
}
|
||||
return msgid;
|
||||
}
|
||||
|
||||
#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
|
||||
dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
|
||||
#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
|
||||
dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
|
||||
|
||||
static inline const char *
|
||||
dcnpgettext_expr (const char *domain,
|
||||
const char *msgctxt, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
{
|
||||
size_t msgctxt_len = strlen (msgctxt) + 1;
|
||||
size_t msgid_len = strlen (msgid) + 1;
|
||||
const char *translation;
|
||||
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
char msg_ctxt_id[msgctxt_len + msgid_len];
|
||||
#else
|
||||
char buf[1024];
|
||||
char *msg_ctxt_id =
|
||||
(msgctxt_len + msgid_len <= sizeof (buf)
|
||||
? buf
|
||||
: (char *) malloc (msgctxt_len + msgid_len));
|
||||
if (msg_ctxt_id != NULL)
|
||||
#endif
|
||||
{
|
||||
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
|
||||
msg_ctxt_id[msgctxt_len - 1] = '\004';
|
||||
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
|
||||
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
if (msg_ctxt_id != buf)
|
||||
free (msg_ctxt_id);
|
||||
#endif
|
||||
if (!(translation == msg_ctxt_id || translation == msgid_plural))
|
||||
return translation;
|
||||
}
|
||||
return (n == 1 ? msgid : msgid_plural);
|
||||
}
|
||||
|
||||
#endif /* _LIBGETTEXT_H */
|
||||
279
m4/acx_pthread.m4
Normal file
279
m4/acx_pthread.m4
Normal file
@ -0,0 +1,279 @@
|
||||
##### http://autoconf-archive.cryp.to/acx_pthread.html
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro figures out how to build C programs using POSIX threads.
|
||||
# It sets the PTHREAD_LIBS output variable to the threads library and
|
||||
# linker flags, and the PTHREAD_CFLAGS output variable to any special
|
||||
# C compiler flags that are needed. (The user can also force certain
|
||||
# compiler flags/libs to be tested by setting these environment
|
||||
# variables.)
|
||||
#
|
||||
# Also sets PTHREAD_CC to any special C compiler that is needed for
|
||||
# multi-threaded programs (defaults to the value of CC otherwise).
|
||||
# (This is necessary on AIX to use the special cc_r compiler alias.)
|
||||
#
|
||||
# NOTE: You are assumed to not only compile your program with these
|
||||
# flags, but also link it with them as well. e.g. you should link
|
||||
# with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
|
||||
# $LIBS
|
||||
#
|
||||
# If you are only building threads programs, you may wish to use
|
||||
# these variables in your default LIBS, CFLAGS, and CC:
|
||||
#
|
||||
# LIBS="$PTHREAD_LIBS $LIBS"
|
||||
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
# CC="$PTHREAD_CC"
|
||||
#
|
||||
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
|
||||
# constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
|
||||
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||
#
|
||||
# ACTION-IF-FOUND is a list of shell commands to run if a threads
|
||||
# library is found, and ACTION-IF-NOT-FOUND is a list of commands to
|
||||
# run it if it is not found. If ACTION-IF-FOUND is not specified, the
|
||||
# default action will define HAVE_PTHREAD.
|
||||
#
|
||||
# Please let the authors know if this macro fails on any platform, or
|
||||
# if you have any other suggestions or comments. This macro was based
|
||||
# on work by SGJ on autoconf scripts for FFTW (http://www.fftw.org/)
|
||||
# (with help from M. Frigo), as well as ac_pthread and hb_pthread
|
||||
# macros posted by Alejandro Forero Cuervo to the autoconf macro
|
||||
# repository. We are also grateful for the helpful feedback of
|
||||
# numerous users.
|
||||
#
|
||||
# LAST MODIFICATION
|
||||
#
|
||||
# 2007-07-29
|
||||
#
|
||||
# COPYLEFT
|
||||
#
|
||||
# Copyright (c) 2007 Steven G. Johnson <stevenj@alum.mit.edu>
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright
|
||||
# owner gives unlimited permission to copy, distribute and modify the
|
||||
# configure scripts that are the output of Autoconf when processing
|
||||
# the Macro. You need not follow the terms of the GNU General Public
|
||||
# License when using or distributing such scripts, even though
|
||||
# portions of the text of the Macro appear in them. The GNU General
|
||||
# Public License (GPL) does govern all other use of the material that
|
||||
# constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the
|
||||
# Autoconf Macro released by the Autoconf Macro Archive. When you
|
||||
# make and distribute a modified version of the Autoconf Macro, you
|
||||
# may extend this special exception to the GPL to apply to your
|
||||
# modified version as well.
|
||||
|
||||
AC_DEFUN([ACX_PTHREAD], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
acx_pthread_ok=no
|
||||
|
||||
# We used to check for pthread.h first, but this fails if pthread.h
|
||||
# requires special compiler flags (e.g. on True64 or Sequent).
|
||||
# It gets checked for in the link test anyway.
|
||||
|
||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||
# etcetera environment variables, and if threads linking works using
|
||||
# them:
|
||||
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
|
||||
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
fi
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
fi
|
||||
|
||||
# We must check for the threads library under a number of different
|
||||
# names; the ordering is very important because some systems
|
||||
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
||||
# libraries is broken (non-POSIX).
|
||||
|
||||
# Create a list of thread flags to try. Items starting with a "-" are
|
||||
# C compiler flags, and other items are library names, except for "none"
|
||||
# which indicates that we try without any flags at all, and "pthread-config"
|
||||
# which is a program returning the flags for the Pth emulation library.
|
||||
|
||||
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
||||
|
||||
# The ordering *is* (sometimes) important. Some notes on the
|
||||
# individual items follow:
|
||||
|
||||
# pthreads: AIX (must check this before -lpthread)
|
||||
# none: in case threads are in libc; should be tried before -Kthread and
|
||||
# other compiler flags to prevent continual compiler warnings
|
||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
|
||||
# -pthreads: Solaris/gcc
|
||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||
# doesn't hurt to check since this sometimes defines pthreads too;
|
||||
# also defines -D_REENTRANT)
|
||||
# ... -mt is also the pthreads flag for HP/aCC
|
||||
# pthread: Linux, etcetera
|
||||
# --thread-safe: KAI C++
|
||||
# pthread-config: use pthread-config program (for GNU Pth library)
|
||||
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*solaris*)
|
||||
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
|
||||
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
||||
# a function called by this macro, so we could check for that, but
|
||||
# who knows whether they'll stub that too in a future libc.) So,
|
||||
# we'll just look for -pthreads and -lpthread first:
|
||||
|
||||
acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
for flag in $acx_pthread_flags; do
|
||||
|
||||
case $flag in
|
||||
none)
|
||||
AC_MSG_CHECKING([whether pthreads work without any flags])
|
||||
;;
|
||||
|
||||
-*)
|
||||
AC_MSG_CHECKING([whether pthreads work with $flag])
|
||||
PTHREAD_CFLAGS="$flag"
|
||||
;;
|
||||
|
||||
pthread-config)
|
||||
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
|
||||
if test x"$acx_pthread_config" = xno; then continue; fi
|
||||
PTHREAD_CFLAGS="`pthread-config --cflags`"
|
||||
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_CHECKING([for the pthreads library -l$flag])
|
||||
PTHREAD_LIBS="-l$flag"
|
||||
;;
|
||||
esac
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Check for various functions. We must include pthread.h,
|
||||
# since some functions may be macros. (On the Sequent, we
|
||||
# need a special flag -Kthread to make this header compile.)
|
||||
# We check for pthread_join because it is in -lpthread on IRIX
|
||||
# while pthread_create is in libc. We check for pthread_attr_init
|
||||
# due to DEC craziness with -lpthreads. We check for
|
||||
# pthread_cleanup_push because it is one of the few pthread
|
||||
# functions on Solaris that doesn't have a non-functional libc stub.
|
||||
# We try pthread_create on general principles.
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[pthread_t th; pthread_join(th, 0);
|
||||
pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
||||
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
|
||||
[acx_pthread_ok=yes])
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
break;
|
||||
fi
|
||||
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
done
|
||||
fi
|
||||
|
||||
# Various other checks:
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
||||
AC_MSG_CHECKING([for joinable pthread attribute])
|
||||
attr_name=unknown
|
||||
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||
AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
|
||||
[attr_name=$attr; break])
|
||||
done
|
||||
AC_MSG_RESULT($attr_name)
|
||||
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
|
||||
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
|
||||
[Define to necessary symbol if this constant
|
||||
uses a non-standard name on your system.])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
||||
flag=no
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
|
||||
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
|
||||
esac
|
||||
AC_MSG_RESULT(${flag})
|
||||
if test "x$flag" != xno; then
|
||||
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
||||
fi
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
# More AIX lossage: must compile with xlc_r or cc_r
|
||||
if test x"$GCC" != xyes; then
|
||||
AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
|
||||
else
|
||||
PTHREAD_CC=$CC
|
||||
fi
|
||||
else
|
||||
PTHREAD_CC="$CC"
|
||||
fi
|
||||
|
||||
AC_SUBST(PTHREAD_LIBS)
|
||||
AC_SUBST(PTHREAD_CFLAGS)
|
||||
AC_SUBST(PTHREAD_CC)
|
||||
|
||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||
if test x"$acx_pthread_ok" = xyes; then
|
||||
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
|
||||
:
|
||||
else
|
||||
acx_pthread_ok=no
|
||||
$2
|
||||
fi
|
||||
AC_LANG_RESTORE
|
||||
])dnl ACX_PTHREAD
|
||||
83
m4/getopt.m4
Normal file
83
m4/getopt.m4
Normal file
@ -0,0 +1,83 @@
|
||||
# getopt.m4 serial 13
|
||||
dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# The getopt module assume you want GNU getopt, with getopt_long etc,
|
||||
# rather than vanilla POSIX getopt. This means your code should
|
||||
# always include <getopt.h> for the getopt prototypes.
|
||||
|
||||
AC_DEFUN([gl_GETOPT_SUBSTITUTE],
|
||||
[
|
||||
AC_LIBOBJ([getopt])
|
||||
AC_LIBOBJ([getopt1])
|
||||
gl_GETOPT_SUBSTITUTE_HEADER
|
||||
gl_PREREQ_GETOPT
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
|
||||
[
|
||||
GETOPT_H=getopt.h
|
||||
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
|
||||
[Define to rpl_ if the getopt replacement functions and variables
|
||||
should be used.])
|
||||
AC_SUBST([GETOPT_H])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
|
||||
[
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
|
||||
fi
|
||||
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
|
||||
fi
|
||||
|
||||
dnl BSD getopt_long uses an incompatible method to reset option processing,
|
||||
dnl and (as of 2004-10-15) mishandles optional option-arguments.
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>])
|
||||
fi
|
||||
|
||||
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
|
||||
dnl option string (as of 2005-05-05).
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([#include <getopt.h>],
|
||||
[[
|
||||
char *myargv[3];
|
||||
myargv[0] = "conftest";
|
||||
myargv[1] = "-+";
|
||||
myargv[2] = 0;
|
||||
return getopt (2, myargv, "+a") != '?';
|
||||
]])],
|
||||
[gl_cv_func_gnu_getopt=yes],
|
||||
[gl_cv_func_gnu_getopt=no],
|
||||
[dnl cross compiling - pessimistically guess based on decls
|
||||
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
|
||||
dnl option string (as of 2005-05-05).
|
||||
AC_CHECK_DECL([getopt_clip],
|
||||
[gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes],
|
||||
[#include <getopt.h>])])])
|
||||
if test "$gl_cv_func_gnu_getopt" = "no"; then
|
||||
GETOPT_H=getopt.h
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT_IFELSE],
|
||||
[
|
||||
AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
|
||||
AS_IF([test -n "$GETOPT_H"], [$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT], [gl_GETOPT_IFELSE([gl_GETOPT_SUBSTITUTE])])
|
||||
|
||||
# Prerequisites of lib/getopt*.
|
||||
AC_DEFUN([gl_PREREQ_GETOPT],
|
||||
[
|
||||
AC_CHECK_DECLS_ONCE([getenv])
|
||||
])
|
||||
1
po/LINGUAS
Normal file
1
po/LINGUAS
Normal file
@ -0,0 +1 @@
|
||||
fi
|
||||
46
po/Makevars
Normal file
46
po/Makevars
Normal file
@ -0,0 +1,46 @@
|
||||
# Makefile variables for PO directory in any package using GNU gettext.
|
||||
|
||||
# Usually the message domain is the same as the package name.
|
||||
DOMAIN = $(PACKAGE)
|
||||
|
||||
# These two variables depend on the location of this directory.
|
||||
subdir = po
|
||||
top_builddir = ..
|
||||
|
||||
# These options get passed to xgettext.
|
||||
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
|
||||
|
||||
# This is the copyright holder that gets inserted into the header of the
|
||||
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
|
||||
# package. (Note that the msgstr strings, extracted from the package's
|
||||
# sources, belong to the copyright holder of the package.) Translators are
|
||||
# expected to transfer the copyright for their translations to this person
|
||||
# or entity, or to disclaim their copyright. The empty string stands for
|
||||
# the public domain; in this case the translators are expected to disclaim
|
||||
# their copyright.
|
||||
COPYRIGHT_HOLDER =
|
||||
|
||||
# This is the email address or URL to which the translators shall report
|
||||
# bugs in the untranslated strings:
|
||||
# - Strings which are not entire sentences, see the maintainer guidelines
|
||||
# in the GNU gettext documentation, section 'Preparing Strings'.
|
||||
# - Strings which use unclear terms or require additional context to be
|
||||
# understood.
|
||||
# - Strings which make invalid assumptions about notation of date, time or
|
||||
# money.
|
||||
# - Pluralisation problems.
|
||||
# - Incorrect English spelling.
|
||||
# - Incorrect formatting.
|
||||
# It can be your email address, or a mailing list address where translators
|
||||
# can write to without being subscribed, or the URL of a web page through
|
||||
# which the translators can contact you.
|
||||
MSGID_BUGS_ADDRESS =
|
||||
|
||||
# This is the list of locale categories, beyond LC_MESSAGES, for which the
|
||||
# message catalogs shall be used. It is usually empty.
|
||||
EXTRA_LOCALE_CATEGORIES =
|
||||
|
||||
# Although you may need slightly wider terminal than 80 chars, it is
|
||||
# much nicer to edit the output of --help when this is set.
|
||||
XGETTEXT_OPTIONS += --no-wrap
|
||||
MSGMERGE += --no-wrap
|
||||
13
po/POTFILES.in
Normal file
13
po/POTFILES.in
Normal file
@ -0,0 +1,13 @@
|
||||
# List of source files which contain translatable strings.
|
||||
src/lzma/help.c
|
||||
src/lzma/alloc.c
|
||||
src/lzma/args.c
|
||||
src/lzma/error.c
|
||||
src/lzma/io.c
|
||||
src/lzma/list.c
|
||||
src/lzma/main.c
|
||||
src/lzma/options.c
|
||||
src/lzma/process.c
|
||||
src/lzma/suffix.c
|
||||
src/lzma/util.c
|
||||
lib/getopt.c
|
||||
445
po/fi.po
Normal file
445
po/fi.po
Normal file
@ -0,0 +1,445 @@
|
||||
# translation of fi.po to Finnish
|
||||
# This file is put in the public domain.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: fi\n"
|
||||
"Report-Msgid-Bugs-To: lasse.collin@tukaani.org\n"
|
||||
"POT-Creation-Date: 2007-12-01 18:36+0200\n"
|
||||
"PO-Revision-Date: 2007-08-09 22:14+0300\n"
|
||||
"Last-Translator: Lasse Collin <lasse.collin@tukaani.org>\n"
|
||||
"Language-Team: Finnish\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: src/lzma/help.c:28
|
||||
#, c-format
|
||||
msgid "Try `%s --help' for more information."
|
||||
msgstr "Lisätietoja saa komennolla \"%s --help\"."
|
||||
|
||||
#: src/lzma/help.c:36
|
||||
#, c-format
|
||||
msgid ""
|
||||
"Usage: %s [OPTION]... [FILE]...\n"
|
||||
"Compress or decompress FILEs in the .lzma format.\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
"Käyttö: %s [VALITSIN]... [TIEDOSTO]...\n"
|
||||
"Pakkaa tai purkaa .lzma-muotoiset TIEDOSTOt\n"
|
||||
"\n"
|
||||
|
||||
#: src/lzma/help.c:40
|
||||
msgid "Mandatory arguments to long options are mandatory for short options too.\n"
|
||||
msgstr "Pitkien valitsinten pakolliset argumentit ovat pakollisia myös lyhyille.\n"
|
||||
|
||||
#: src/lzma/help.c:44
|
||||
msgid ""
|
||||
" Operation mode:\n"
|
||||
"\n"
|
||||
" -z, --compress force compression\n"
|
||||
" -d, --decompress force decompression\n"
|
||||
" -t, --test test compressed file integrity\n"
|
||||
" -l, --list list block sizes, total sizes, and possible metadata\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/help.c:53
|
||||
msgid ""
|
||||
" Operation modifiers:\n"
|
||||
"\n"
|
||||
" -k, --keep keep (don't delete) input files\n"
|
||||
" -f, --force force overwrite of output file and (de)compress links\n"
|
||||
" -c, --stdout write to standard output and don't delete input files\n"
|
||||
" -S, --suffix=.SUF use suffix `.SUF' on compressed files instead of `.lzma'\n"
|
||||
" -F, --format=FMT file format to encode or decode; possible values are\n"
|
||||
" `auto', `native', `single', `multi', and `alone'\n"
|
||||
" --files=[FILE] read filenames to process from FILE; if FILE is\n"
|
||||
" omitted, filenames are read from the standard input;\n"
|
||||
" filenames must be terminated with the newline character\n"
|
||||
" --files0=[FILE] like --files but use the nul byte as terminator\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/help.c:68
|
||||
msgid ""
|
||||
" Compression presets and basic compression options:\n"
|
||||
"\n"
|
||||
" -1 .. -2 fast compression\n"
|
||||
" -3 .. -6 good compression; default is -6 if memory limit allows\n"
|
||||
" -7 .. -9 excellent compression, but needs a lot of memory\n"
|
||||
"\n"
|
||||
" -C, --check=CHECK integrity check type: `crc32', `crc64' (default),\n"
|
||||
" or `sha256'\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/help.c:79
|
||||
msgid ""
|
||||
" Custom filter chain for compression (alternative for using presets):\n"
|
||||
"\n"
|
||||
" --lzma=[OPTS] LZMA filter; OPTS is a comma-separated list of zero or\n"
|
||||
" more of the following options (valid values; default):\n"
|
||||
" dict=NUM dictionary size in bytes (1 - 1Gi; 8Mi)\n"
|
||||
" lc=NUM number of literal context bits (0-8; 3)\n"
|
||||
" lp=NUM number of literal position bits (0-4; 0)\n"
|
||||
" pb=NUM number of position bits (0-4; 2)\n"
|
||||
" mode=MODE compression mode (`fast' or `best'; `best')\n"
|
||||
" fb=NUM number of fast bytes (5-273; 128)\n"
|
||||
" mf=NAME match finder (hc3, hc4, bt2, bt3, bt4; bt4)\n"
|
||||
" mfc=NUM match finder cycles; 0=automatic (default)\n"
|
||||
"\n"
|
||||
" --x86 x86 filter (sometimes called BCJ filter)\n"
|
||||
" --powerpc PowerPC (big endian) filter\n"
|
||||
" --ia64 IA64 (Itanium) filter\n"
|
||||
" --arm ARM filter\n"
|
||||
" --armthumb ARM-Thumb filter\n"
|
||||
" --sparc SPARC filter\n"
|
||||
"\n"
|
||||
" --copy No filtering (useful only when specified alone)\n"
|
||||
" --subblock=[OPTS] Subblock filter; valid OPTS (valid values; default):\n"
|
||||
" size=NUM number of bytes of data per subblock\n"
|
||||
" (1 - 256Mi; 4Ki)\n"
|
||||
" rle=NUM run-length encoder chunk size (0-256; 0)\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/help.c:119
|
||||
msgid ""
|
||||
" Resource usage options:\n"
|
||||
"\n"
|
||||
" -M, --memory=NUM use roughly NUM bytes of memory at maximum\n"
|
||||
" -T, --threads=NUM use at maximum of NUM (de)compression threads\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/help.c:128
|
||||
msgid ""
|
||||
" Other options:\n"
|
||||
"\n"
|
||||
" -q, --quiet suppress warnings; specify twice to suppress errors too\n"
|
||||
" -v, --verbose be verbose; specify twice for even more verbose\n"
|
||||
"\n"
|
||||
" -h, --help display this help and exit\n"
|
||||
" -V, --version display version and license information and exit\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/help.c:136
|
||||
msgid "With no FILE, or when FILE is -, read standard input.\n"
|
||||
msgstr "Jos TIEDOSTOa ei ole annettu, tai se on \"-\", luetaan vakiosyötettä.\n"
|
||||
|
||||
#: src/lzma/help.c:142
|
||||
msgid "On this system and configuration, the tool will use"
|
||||
msgstr "Tässä järjestelmässä näillä asetuksilla, tämä työkalu käyttää"
|
||||
|
||||
#: src/lzma/help.c:143
|
||||
#, c-format
|
||||
msgid " * roughly %zu MiB of memory at maximum; and\n"
|
||||
msgstr " * korkeintaan %zu MiB keskusmuistia (suurpiirteinen rajoitus); ja\n"
|
||||
|
||||
#: src/lzma/help.c:146
|
||||
msgid ""
|
||||
" * at maximum of one thread for (de)compression.\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
" * korkeintaan yhtä säiettä pakkaukseen tai purkuun.\n"
|
||||
"\n"
|
||||
|
||||
#: src/lzma/help.c:150
|
||||
#, c-format
|
||||
msgid "Report bugs to <%s> (in English or Finnish).\n"
|
||||
msgstr ""
|
||||
"Lähetä raportit ohjelmistovioista (englanniksi tai suomeksi)\n"
|
||||
"osoitteeseen <%s>.\n"
|
||||
|
||||
#: src/lzma/args.c:126
|
||||
msgid "Maximum number of filters is seven"
|
||||
msgstr "Suotimia voi olla korkeintaan seitsemän"
|
||||
|
||||
#: src/lzma/args.c:189
|
||||
#, c-format
|
||||
msgid "%s: Invalid filename suffix"
|
||||
msgstr "%s: Virheellinen tiedostonimen pääte"
|
||||
|
||||
#: src/lzma/args.c:323
|
||||
#, c-format
|
||||
msgid "%s: Unknown file format type"
|
||||
msgstr "%s: Tuntematon tiedostomuodon tyyppi"
|
||||
|
||||
#: src/lzma/args.c:349
|
||||
#, c-format
|
||||
msgid "%s: Unknown integrity check type"
|
||||
msgstr "%s: Tuntematon eheystarkisteen tyyppi"
|
||||
|
||||
#: src/lzma/args.c:367
|
||||
msgid "Only one file can be specified with `--files'or `--files0'."
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/args.c:417
|
||||
msgid "The environment variable LZMA_OPT contains too many arguments"
|
||||
msgstr "Ympäristömuuttuja LZMA_OPT sisältää liian monta argumenttia"
|
||||
|
||||
#: src/lzma/args.c:483
|
||||
msgid "Memory usage limit is too small for any internal filter preset"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/args.c:498
|
||||
msgid "Memory usage limit is too small for the given filter setup"
|
||||
msgstr "Muistinkäyttörajoitus on liian pieni annetuille suodinasetusille"
|
||||
|
||||
#: src/lzma/error.c:35
|
||||
msgid "Operation successful"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/error.c:38
|
||||
msgid "Operation finished successfully"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/error.c:41 src/lzma/error.c:153
|
||||
msgid "Internal error (bug)"
|
||||
msgstr "Sisäinen virhe (bugi)"
|
||||
|
||||
#: src/lzma/error.c:44
|
||||
msgid "Compressed data is corrupt"
|
||||
msgstr "Pakattu data on korruptoitunut"
|
||||
|
||||
#: src/lzma/error.c:50
|
||||
msgid "Unexpected end of input"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/error.c:53
|
||||
msgid "Unsupported options"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/error.c:56
|
||||
msgid "Unsupported integrity check type"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/error.c:87 src/lzma/error.c:93
|
||||
#, c-format
|
||||
msgid "Writing to standard output failed: %s"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/io.c:81
|
||||
#, c-format
|
||||
msgid "Cannot get file descriptor of the current directory: %s"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/io.c:123 src/lzma/util.c:127
|
||||
#, c-format
|
||||
msgid "%s: Invalid filename"
|
||||
msgstr "%s: Virheellinen tiedostonimi"
|
||||
|
||||
#: src/lzma/io.c:130 src/lzma/io.c:233
|
||||
#, c-format
|
||||
msgid "Cannot change directory: %s"
|
||||
msgstr "Hakemiston vaihtaminen epäonnistui: %s"
|
||||
|
||||
#: src/lzma/io.c:135
|
||||
#, c-format
|
||||
msgid "%s: File seems to be moved, not removing"
|
||||
msgstr "%s: Tiedosto näyttää olevan siirretty, ei poisteta"
|
||||
|
||||
#: src/lzma/io.c:141
|
||||
#, c-format
|
||||
msgid "%s: Cannot remove: %s"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/io.c:164
|
||||
#, c-format
|
||||
msgid "%s: Cannot set the file owner: %s"
|
||||
msgstr "%s: Tiedoston omistajuuden asetus epäonnistui: %s"
|
||||
|
||||
#: src/lzma/io.c:170
|
||||
#, c-format
|
||||
msgid "%s: Cannot set the file group: %s"
|
||||
msgstr "%s: Tiedoston ryhmän asetus epäonnistui: %s"
|
||||
|
||||
#: src/lzma/io.c:189
|
||||
#, c-format
|
||||
msgid "%s: Cannot set the file permissions: %s"
|
||||
msgstr "%s: Tiedoston oikeuksien asetus epäonnistui: %s"
|
||||
|
||||
#: src/lzma/io.c:252
|
||||
#, c-format
|
||||
msgid "%s: Cannot open the directory containing the file: %s"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/io.c:313
|
||||
#, c-format
|
||||
msgid "%s: Is a symbolic link, skipping"
|
||||
msgstr "%s: Symbolinen linkki, ohitetaan"
|
||||
|
||||
#: src/lzma/io.c:330
|
||||
#, c-format
|
||||
msgid "%s: Is a directory, skipping"
|
||||
msgstr "%s: Hakemisto, ohitetaan"
|
||||
|
||||
#: src/lzma/io.c:337 src/lzma/list.c:445
|
||||
#, c-format
|
||||
msgid "%s: Not a regular file, skipping"
|
||||
msgstr "%s: Ei ole tavallinen tiedosto, ohitetaan"
|
||||
|
||||
#: src/lzma/io.c:348
|
||||
#, c-format
|
||||
msgid "%s: File has setuid or setgid bit set, skipping"
|
||||
msgstr "%s: Tiedostolla on setuid- tai setgid-bitti asetettuna, ohitetaan"
|
||||
|
||||
#: src/lzma/io.c:355
|
||||
#, c-format
|
||||
msgid "%s: File has sticky bit set, skipping"
|
||||
msgstr "%s: Tiedostolla on sticky-bitti asetettuna, ohitetaan"
|
||||
|
||||
#: src/lzma/io.c:362
|
||||
#, c-format
|
||||
msgid "%s: Input file has more than one hard link, skipping"
|
||||
msgstr "%s: Tiedostoon viittaa useampi kuin yksi linkki, ohitetaan"
|
||||
|
||||
#: src/lzma/io.c:390 src/lzma/io.c:467
|
||||
#, c-format
|
||||
msgid "%s: Closing the file failed: %s"
|
||||
msgstr "%s: Tiedoston sulkeminen epäonnistui: %s"
|
||||
|
||||
#: src/lzma/io.c:610
|
||||
#, c-format
|
||||
msgid "%s: Read error: %s"
|
||||
msgstr "%s: Lukeminen epäonnistui: %s"
|
||||
|
||||
#: src/lzma/io.c:653
|
||||
#, c-format
|
||||
msgid "%s: Write error: %s"
|
||||
msgstr "%s: Kirjoitus epäonnistui: %s"
|
||||
|
||||
#: src/lzma/list.c:451
|
||||
#, c-format
|
||||
msgid "%s: File is empty"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/main.c:57
|
||||
msgid "Cannot establish signal handlers"
|
||||
msgstr "Signaalikäsittelijöiden asetus epäonnistui"
|
||||
|
||||
#: src/lzma/main.c:75
|
||||
msgid "Compressed data not read from a terminal."
|
||||
msgstr "Pakattua dataa ei lueta päätteeltä."
|
||||
|
||||
#: src/lzma/main.c:77 src/lzma/main.c:92
|
||||
msgid "Use `--force' to force decompression."
|
||||
msgstr "Käytä valitsinta \"--force\" pakottaaksesi purun."
|
||||
|
||||
#: src/lzma/main.c:90
|
||||
msgid "Compressed data not written to a terminal."
|
||||
msgstr "Pakattua dataa ei kirjoiteta päätteelle."
|
||||
|
||||
#: src/lzma/main.c:117
|
||||
#, fuzzy, c-format
|
||||
msgid "%s: Error reading filenames: %s"
|
||||
msgstr "%s: Tiedoston sulkeminen epäonnistui: %s"
|
||||
|
||||
#: src/lzma/main.c:122
|
||||
#, c-format
|
||||
msgid "%s: Unexpected end of input when reading filenames"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/main.c:212
|
||||
msgid "Cannot read data from standard input when reading filenames from standard input"
|
||||
msgstr "Dataa ei voida lukea oletussyötteestä, kun tiedostonimiä luetaan oletussyötteestä"
|
||||
|
||||
#: src/lzma/options.c:83
|
||||
#, c-format
|
||||
msgid "%s: Options must be `name=value' pairs separated with commas"
|
||||
msgstr "%s: Asetusten tulee olla \"nimi=arvo\"-pareja, jotka on eroteltu pilkuilla"
|
||||
|
||||
#: src/lzma/options.c:111
|
||||
#, c-format
|
||||
msgid "%s: Invalid option value"
|
||||
msgstr "%s: Virheellinen asetuksen arvo"
|
||||
|
||||
#: src/lzma/options.c:124
|
||||
#, c-format
|
||||
msgid "%s: Invalid option name"
|
||||
msgstr "%s: Virheellinen asetuksen nimi"
|
||||
|
||||
#: src/lzma/process.c:142
|
||||
#, c-format
|
||||
msgid "Cannot create a thread: %s"
|
||||
msgstr "Säikeen luonti epäonnistui: %s"
|
||||
|
||||
#: src/lzma/suffix.c:85
|
||||
#, c-format
|
||||
msgid "%s: Filename has an unknown suffix, skipping"
|
||||
msgstr "%s: Tiedostonimellä on tuntematon pääte, ohitetaan"
|
||||
|
||||
#: src/lzma/suffix.c:114
|
||||
#, c-format
|
||||
msgid "%s: File already has `%s' suffix, skipping"
|
||||
msgstr "%s: Tiedostolla on jo \"%s\"-pääte, ohitetaan"
|
||||
|
||||
#: src/lzma/util.c:44
|
||||
#, c-format
|
||||
msgid "%s: Value is not a non-negative decimal integer"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/util.c:84
|
||||
#, c-format
|
||||
msgid "%s: Invalid multiplier suffix. Valid suffixes:"
|
||||
msgstr ""
|
||||
|
||||
#: src/lzma/util.c:105
|
||||
#, c-format
|
||||
msgid "Value of the option `%s' must be in the range [%llu, %llu]"
|
||||
msgstr "Asetuksen \"%s\" arvon tulee olla välillä [%llu, %llu]"
|
||||
|
||||
#: src/lzma/util.c:175
|
||||
msgid "Empty filename, skipping"
|
||||
msgstr "Tyhjä tiedostonimi, ohitetaan"
|
||||
|
||||
#: lib/getopt.c:531 lib/getopt.c:547
|
||||
#, c-format
|
||||
msgid "%s: option `%s' is ambiguous\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/getopt.c:580 lib/getopt.c:584
|
||||
#, c-format
|
||||
msgid "%s: option `--%s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/getopt.c:593 lib/getopt.c:598
|
||||
#, c-format
|
||||
msgid "%s: option `%c%s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/getopt.c:641 lib/getopt.c:660 lib/getopt.c:976 lib/getopt.c:995
|
||||
#, c-format
|
||||
msgid "%s: option `%s' requires an argument\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/getopt.c:698 lib/getopt.c:701
|
||||
#, c-format
|
||||
msgid "%s: unrecognized option `--%s'\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/getopt.c:709 lib/getopt.c:712
|
||||
#, c-format
|
||||
msgid "%s: unrecognized option `%c%s'\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/getopt.c:764 lib/getopt.c:767
|
||||
#, c-format
|
||||
msgid "%s: illegal option -- %c\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/getopt.c:773 lib/getopt.c:776
|
||||
#, c-format
|
||||
msgid "%s: invalid option -- %c\n"
|
||||
msgstr "%s: virheellinen valitsin -- %c\n"
|
||||
|
||||
#: lib/getopt.c:828 lib/getopt.c:844 lib/getopt.c:1048 lib/getopt.c:1066
|
||||
#, c-format
|
||||
msgid "%s: option requires an argument -- %c\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/getopt.c:897 lib/getopt.c:913
|
||||
#, c-format
|
||||
msgid "%s: option `-W %s' is ambiguous\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/getopt.c:937 lib/getopt.c:955
|
||||
#, c-format
|
||||
msgid "%s: option `-W %s' doesn't allow an argument\n"
|
||||
msgstr ""
|
||||
16
src/Makefile.am
Normal file
16
src/Makefile.am
Normal file
@ -0,0 +1,16 @@
|
||||
##
|
||||
## Copyright (C) 2007 Lasse Collin
|
||||
##
|
||||
## This library is free software; you can redistribute it and/or
|
||||
## modify it under the terms of the GNU Lesser General Public
|
||||
## License as published by the Free Software Foundation; either
|
||||
## version 2.1 of the License, or (at your option) any later version.
|
||||
##
|
||||
## This library is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## Lesser General Public License for more details.
|
||||
##
|
||||
|
||||
SUBDIRS = liblzma lzma lzmadec scripts
|
||||
EXTRA_DIST = common
|
||||
50
src/common/open_stdxxx.h
Normal file
50
src/common/open_stdxxx.h
Normal file
@ -0,0 +1,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file open_stdxxx.h
|
||||
/// \brief Make sure that file descriptors 0, 1, and 2 are open
|
||||
//
|
||||
// This code has been put into the public domain.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef OPEN_STDXXX_H
|
||||
#define OPEN_STDXXX_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static void
|
||||
open_stdxxx(int status)
|
||||
{
|
||||
for (int i = 0; i <= 2; ++i) {
|
||||
// We use fcntl() to check if the file descriptor is open.
|
||||
if (fcntl(i, F_GETFD) == -1 && errno == EBADF) {
|
||||
// With stdin, we could use /dev/full so that
|
||||
// writing to stdin would fail. However, /dev/full
|
||||
// is Linux specific, and if the program tries to
|
||||
// write to stdin, there's already a problem anyway.
|
||||
const int fd = open("/dev/null", O_NOCTTY
|
||||
| (i == 0 ? O_WRONLY : O_RDONLY));
|
||||
|
||||
if (fd != i) {
|
||||
// Something went wrong. Exit with the
|
||||
// exit status we were given. Don't try
|
||||
// to print an error message, since stderr
|
||||
// may very well be non-existent. This
|
||||
// error should be extremely rare.
|
||||
(void)close(fd);
|
||||
exit(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
77
src/common/physmem.h
Normal file
77
src/common/physmem.h
Normal file
@ -0,0 +1,77 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file physmem.h
|
||||
/// \brief Get the amount of physical memory
|
||||
//
|
||||
// This code has been put into the public domain.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PHYSMEM_H
|
||||
#define PHYSMEM_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PHYSMEM_SYSCTL) || defined(HAVE_NCPU_SYSCTL)
|
||||
# ifdef HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
# endif
|
||||
# ifdef HAVE_SYS_SYSCTL_H
|
||||
# include <sys/sysctl.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/// \brief Get the amount of physical memory in bytes
|
||||
///
|
||||
/// \return Amount of physical memory in bytes. On error, zero is
|
||||
/// returned.
|
||||
static inline uint64_t
|
||||
physmem(void)
|
||||
{
|
||||
uint64_t ret = 0;
|
||||
|
||||
#if defined(HAVE_PHYSMEM_SYSCONF)
|
||||
const long pagesize = sysconf(_SC_PAGESIZE);
|
||||
const long pages = sysconf(_SC_PHYS_PAGES);
|
||||
if (pagesize != -1 || pages != -1)
|
||||
// According to docs, pagesize * pages can overflow.
|
||||
// Simple case is 32-bit box with 4 GiB or more RAM,
|
||||
// which may report exactly 4 GiB of RAM, and "long"
|
||||
// being 32-bit will overflow. Casting to uint64_t
|
||||
// hopefully avoids overflows in the near future.
|
||||
ret = (uint64_t)(pagesize) * (uint64_t)(pages);
|
||||
|
||||
#elif defined(HAVE_PHYSMEM_SYSCTL)
|
||||
int name[2] = { CTL_HW, HW_PHYSMEM };
|
||||
unsigned long mem;
|
||||
size_t mem_ptr_size = sizeof(mem);
|
||||
if (!sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL)) {
|
||||
// Some systems use unsigned int as the "return value".
|
||||
// This makes a difference on 64-bit boxes.
|
||||
if (mem_ptr_size != sizeof(mem)) {
|
||||
if (mem_ptr_size == sizeof(unsigned int))
|
||||
ret = *(unsigned int *)(&mem);
|
||||
} else {
|
||||
ret = mem;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
100
src/common/sysdefs.h
Normal file
100
src/common/sysdefs.h
Normal file
@ -0,0 +1,100 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/// \file sysdefs.h
|
||||
/// \brief Common includes, definitions, system-specific things etc.
|
||||
///
|
||||
/// This file is used also by the lzma command line tool, that's why this
|
||||
/// file is separate from common.h.
|
||||
//
|
||||
// Copyright (C) 2007 Lasse Collin
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LZMA_SYSDEFS_H
|
||||
#define LZMA_SYSDEFS_H
|
||||
|
||||
//////////////
|
||||
// Includes //
|
||||
//////////////
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "lzma.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# if ! HAVE__BOOL
|
||||
typedef unsigned char _Bool;
|
||||
# endif
|
||||
# define bool _Bool
|
||||
# define false 0
|
||||
# define true 1
|
||||
# define __bool_true_false_are_defined 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ASSERT_H
|
||||
# include <assert.h>
|
||||
#else
|
||||
# ifdef NDEBUG
|
||||
# define assert(x)
|
||||
# else
|
||||
// TODO: Pretty bad assert() macro.
|
||||
# define assert(x) (!(x) && abort())
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMORY_H
|
||||
# include <memory.h>
|
||||
#endif
|
||||
|
||||
|
||||
////////////
|
||||
// Macros //
|
||||
////////////
|
||||
|
||||
#ifndef HAVE_MEMCPY
|
||||
# define memcpy(dest, src, n) bcopy(src, dest, n)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
# define memmove(dest, src, n) bcopy(src, dest, n)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMSET
|
||||
# define memzero(s, n) memset(s, 0, n)
|
||||
#else
|
||||
# define memzero(s, n) bzero(s, n)
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
# define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
47
src/liblzma/Makefile.am
Normal file
47
src/liblzma/Makefile.am
Normal file
@ -0,0 +1,47 @@
|
||||
##
|
||||
## Copyright (C) 2007 Lasse Collin
|
||||
##
|
||||
## This library is free software; you can redistribute it and/or
|
||||
## modify it under the terms of the GNU Lesser General Public
|
||||
## License as published by the Free Software Foundation; either
|
||||
## version 2.1 of the License, or (at your option) any later version.
|
||||
##
|
||||
## This library is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## Lesser General Public License for more details.
|
||||
##
|
||||
|
||||
SUBDIRS = api common check
|
||||
|
||||
lib_LTLIBRARIES = liblzma.la
|
||||
liblzma_la_SOURCES =
|
||||
liblzma_la_LDFLAGS = -version-info 0:0:0
|
||||
|
||||
liblzma_la_LIBADD = \
|
||||
common/libcommon.la \
|
||||
check/libcheck.la
|
||||
|
||||
if COND_FILTER_LZMA
|
||||
SUBDIRS += lz lzma rangecoder
|
||||
liblzma_la_LIBADD += \
|
||||
lz/liblz.la \
|
||||
lzma/liblzma4.la \
|
||||
rangecoder/librangecoder.la
|
||||
endif
|
||||
|
||||
if COND_FILTER_SUBBLOCK
|
||||
SUBDIRS += subblock
|
||||
liblzma_la_LIBADD += subblock/libsubblock.la
|
||||
endif
|
||||
|
||||
if COND_MAIN_SIMPLE
|
||||
SUBDIRS += simple
|
||||
liblzma_la_LIBADD += simple/libsimple.la
|
||||
endif
|
||||
|
||||
|
||||
## pkg-config
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = lzma.pc
|
||||
EXTRA_DIST = lzma.pc.in
|
||||
39
src/liblzma/api/Makefile.am
Normal file
39
src/liblzma/api/Makefile.am
Normal file
@ -0,0 +1,39 @@
|
||||
##
|
||||
## Copyright (C) 2007 Lasse Collin
|
||||
##
|
||||
## This library is free software; you can redistribute it and/or
|
||||
## modify it under the terms of the GNU Lesser General Public
|
||||
## License as published by the Free Software Foundation; either
|
||||
## version 2.1 of the License, or (at your option) any later version.
|
||||
##
|
||||
## This library is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## Lesser General Public License for more details.
|
||||
##
|
||||
|
||||
nobase_include_HEADERS = \
|
||||
lzma.h \
|
||||
lzma/alignment.h \
|
||||
lzma/alone.h \
|
||||
lzma/auto.h \
|
||||
lzma/base.h \
|
||||
lzma/block.h \
|
||||
lzma/check.h \
|
||||
lzma/copy.h \
|
||||
lzma/delta.h \
|
||||
lzma/extra.h \
|
||||
lzma/filter.h \
|
||||
lzma/index.h \
|
||||
lzma/info.h \
|
||||
lzma/init.h \
|
||||
lzma/lzma.h \
|
||||
lzma/memlimit.h \
|
||||
lzma/metadata.h \
|
||||
lzma/raw.h \
|
||||
lzma/simple.h \
|
||||
lzma/stream.h \
|
||||
lzma/stream_flags.h \
|
||||
lzma/subblock.h \
|
||||
lzma/version.h \
|
||||
lzma/vli.h
|
||||
122
src/liblzma/api/lzma.h
Normal file
122
src/liblzma/api/lzma.h
Normal file
@ -0,0 +1,122 @@
|
||||
/**
|
||||
* \file lzma.h
|
||||
* \brief The public API of liblzma
|
||||
*
|
||||
* liblzma is a LZMA compression library with a zlib-like API.
|
||||
* liblzma is based on LZMA SDK found from http://7-zip.org/sdk.html.
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H
|
||||
#define LZMA_H
|
||||
|
||||
/********************
|
||||
* External headers *
|
||||
********************/
|
||||
|
||||
/* size_t */
|
||||
#include <sys/types.h>
|
||||
|
||||
/* NULL */
|
||||
#include <stddef.h>
|
||||
|
||||
/* uint8_t, uint32_t, uint64_t, UINT32_C, UINT64_C, UINT64_MAX. */
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
/******************
|
||||
* GCC extensions *
|
||||
******************/
|
||||
|
||||
/*
|
||||
* GCC extensions are used conditionally in the public API. It doesn't
|
||||
* break anything if these are sometimes enabled and sometimes not, only
|
||||
* affects warnings and optimizations.
|
||||
*/
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
# ifndef lzma_attribute
|
||||
# define lzma_attribute(attr) __attribute__(attr)
|
||||
# endif
|
||||
# ifndef lzma_restrict
|
||||
# define lzma_restrict __restrict__
|
||||
# endif
|
||||
#else
|
||||
# ifndef lzma_attribute
|
||||
# define lzma_attribute(attr)
|
||||
# endif
|
||||
# ifndef lzma_restrict
|
||||
# define lzma_restrict
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/**************
|
||||
* Subheaders *
|
||||
**************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Subheaders check that this is defined. It is to prevent including
|
||||
* them directly from applications.
|
||||
*/
|
||||
#define LZMA_H_INTERNAL 1
|
||||
|
||||
/* Basic features */
|
||||
#include "lzma/init.h"
|
||||
#include "lzma/base.h"
|
||||
#include "lzma/vli.h"
|
||||
#include "lzma/filter.h"
|
||||
#include "lzma/check.h"
|
||||
|
||||
/* Filters */
|
||||
#include "lzma/copy.h"
|
||||
#include "lzma/subblock.h"
|
||||
#include "lzma/simple.h"
|
||||
#include "lzma/delta.h"
|
||||
#include "lzma/lzma.h"
|
||||
|
||||
/* Container formats and Metadata */
|
||||
#include "lzma/block.h"
|
||||
#include "lzma/index.h"
|
||||
#include "lzma/extra.h"
|
||||
#include "lzma/metadata.h"
|
||||
#include "lzma/stream.h"
|
||||
#include "lzma/alone.h"
|
||||
#include "lzma/raw.h"
|
||||
#include "lzma/auto.h"
|
||||
|
||||
/* Advanced features */
|
||||
#include "lzma/info.h"
|
||||
#include "lzma/alignment.h"
|
||||
#include "lzma/stream_flags.h"
|
||||
#include "lzma/memlimit.h"
|
||||
|
||||
/* Version number */
|
||||
#include "lzma/version.h"
|
||||
|
||||
/*
|
||||
* All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications
|
||||
* re-including the subheaders.
|
||||
*/
|
||||
#undef LZMA_H_INTERNAL
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ifndef LZMA_H */
|
||||
60
src/liblzma/api/lzma/alignment.h
Normal file
60
src/liblzma/api/lzma/alignment.h
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
* \file lzma/alignment.h
|
||||
* \brief Calculating input and output alignment of filter chains
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculates the preferred alignment of the input data
|
||||
*
|
||||
* FIXME desc
|
||||
*/
|
||||
extern uint32_t lzma_alignment_input(
|
||||
const lzma_options_filter *filters, uint32_t guess);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculates the alignment of the encoded output
|
||||
*
|
||||
* Knowing the alignment of the output data is useful e.g. in the Block
|
||||
* encoder which tries to align the Compressed Data field optimally.
|
||||
*
|
||||
* \param filters Pointer to lzma_options_filter array, whose last
|
||||
* member must have .id = LZMA_VLI_VALUE_UNKNOWN.
|
||||
* \param guess The value to return if the alignment of the output
|
||||
* is the same as the alignment of the input data.
|
||||
* If you want to always detect this special case,
|
||||
* this guess to zero; this function never returns
|
||||
* zero unless guess is zero.
|
||||
*
|
||||
* \return In most cases, a small positive integer is returned;
|
||||
* for optimal use, the encoded output of this filter
|
||||
* chain should start at on offset that is a multiple of
|
||||
* the returned integer value.
|
||||
*
|
||||
* If the alignment of the output is the same as the input
|
||||
* data (which this function cannot know), \a guess is
|
||||
* returned.
|
||||
*
|
||||
* If an error occurs (that is, unknown Filter IDs or filter
|
||||
* options), UINT32_MAX is returned.
|
||||
*/
|
||||
extern uint32_t lzma_alignment_output(
|
||||
const lzma_options_filter *filters, uint32_t guess);
|
||||
82
src/liblzma/api/lzma/alone.h
Normal file
82
src/liblzma/api/lzma/alone.h
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* \file lzma/alone.h
|
||||
* \brief Handling of the legacy LZMA_Alone format
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for files in the LZMA_Alone format
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Uncompressed Size and usage of End of Payload Marker
|
||||
*
|
||||
* In contrast to .lzma Blocks, LZMA_Alone format cannot have both
|
||||
* uncompressed size field in the header and end of payload marker.
|
||||
* If you don't know the uncompressed size beforehand, set it to
|
||||
* LZMA_VLI_VALUE_UNKNOWN and liblzma will embed end of payload
|
||||
* marker.
|
||||
*/
|
||||
lzma_vli uncompressed_size;
|
||||
|
||||
/**
|
||||
* \brief LZMA options
|
||||
*
|
||||
* The LZMA_Alone format supports only one filter: the LZMA filter.
|
||||
*
|
||||
* \note There exists also an undocumented variant of the
|
||||
* LZMA_Alone format, which uses the x86 filter in
|
||||
* addition to LZMA. This format was never supported
|
||||
* by LZMA Utils and is not supported by liblzma either.
|
||||
*/
|
||||
lzma_options_lzma lzma;
|
||||
|
||||
} lzma_options_alone;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initializes LZMA_Alone encoder
|
||||
*
|
||||
* LZMA_Alone files have the suffix .lzma like the .lzma Stream files.
|
||||
* LZMA_Alone format supports only one filter, the LZMA filter. There is
|
||||
* no support for integrity checks like CRC32.
|
||||
*
|
||||
* Use this format if and only if you need to create files readable by
|
||||
* legacy LZMA tools.
|
||||
*
|
||||
* LZMA_Alone encoder doesn't support LZMA_SYNC_FLUSH or LZMA_FULL_FLUSH.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern lzma_ret lzma_alone_encoder(
|
||||
lzma_stream *strm, const lzma_options_alone *options);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initializes decoder for LZMA_Alone file
|
||||
*
|
||||
* The LZMA_Alone decoder supports LZMA_SYNC_FLUSH.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
*/
|
||||
extern lzma_ret lzma_alone_decoder(lzma_stream *strm);
|
||||
41
src/liblzma/api/lzma/auto.h
Normal file
41
src/liblzma/api/lzma/auto.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* \file lzma/auto.h
|
||||
* \brief Decoder with automatic file format detection
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode .lzma Streams and LZMA_Alone files with autodetection
|
||||
*
|
||||
* Autodetects between the .lzma Stream and LZMA_Alone formats, and
|
||||
* calls lzma_stream_decoder_init() or lzma_alone_decoder_init() once
|
||||
* the type of the file has been detected.
|
||||
*
|
||||
* \param strm Pointer to propertily prepared lzma_stream
|
||||
* \param header Pointer to hold a pointer to Extra Records read
|
||||
* from the Header Metadata Block. Use NULL if
|
||||
* you don't care about Extra Records.
|
||||
* \param footer Same as header, but for Footer Metadata Block.
|
||||
*
|
||||
* \return - LZMA_OK: Initialization was successful.
|
||||
* - LZMA_MEM_ERROR: Cannot allocate memory.
|
||||
*/
|
||||
extern lzma_ret lzma_auto_decoder(lzma_stream *strm,
|
||||
lzma_extra **header, lzma_extra **footer);
|
||||
410
src/liblzma/api/lzma/base.h
Normal file
410
src/liblzma/api/lzma/base.h
Normal file
@ -0,0 +1,410 @@
|
||||
/**
|
||||
* \file lzma/base.h
|
||||
* \brief Data types and functions used in many places of the public API
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Boolean
|
||||
*
|
||||
* This is here because C89 doesn't have stdbool.h. To set a value for
|
||||
* variables having type lzma_bool, you can use
|
||||
* - C99's `true' and `false' from stdbool.h;
|
||||
* - C++'s internal `true' and `false'; or
|
||||
* - integers one (true) and zero (false).
|
||||
*/
|
||||
typedef unsigned char lzma_bool;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return values used by several functions in liblzma
|
||||
*
|
||||
* Check the descriptions of specific functions to find out which return
|
||||
* values they can return and the exact meanings of the values in every
|
||||
* situation. The descriptions given here are only suggestive.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_OK = 0,
|
||||
/**<
|
||||
* \brief Operation completed successfully
|
||||
*/
|
||||
|
||||
LZMA_STREAM_END = 1,
|
||||
/**<
|
||||
* \brief End of stream was reached
|
||||
*
|
||||
* The application should pick the last remaining output
|
||||
* bytes from strm->next_out.
|
||||
*/
|
||||
|
||||
LZMA_PROG_ERROR = -2,
|
||||
/**<
|
||||
* \brief Programming error
|
||||
*
|
||||
* This indicates that the arguments given to the function are
|
||||
* invalid or the internal state of the decoder is corrupt.
|
||||
* - Function arguments are invalid or the structures
|
||||
* pointed by the argument pointers are invalid
|
||||
* e.g. if strm->next_out has been set to NULL and
|
||||
* strm->avail_out > 0 when calling lzma_code().
|
||||
* - lzma_* functions have been called in wrong order
|
||||
* e.g. lzma_code() was called right after lzma_end().
|
||||
* - If errors occur randomly, the reason might be flaky
|
||||
* hardware.
|
||||
*
|
||||
* If you think that your code is correct, this error code
|
||||
* can be a sign of a bug in liblzma. See the documentation
|
||||
* how to report bugs.
|
||||
*/
|
||||
|
||||
LZMA_DATA_ERROR = -3,
|
||||
/**<
|
||||
* \brief Data is corrupt
|
||||
*
|
||||
* - Encoder: The input size doesn't match the uncompressed
|
||||
* size given to lzma_*_encoder_init().
|
||||
* - Decoder: The input is corrupt. This includes corrupted
|
||||
* header, corrupted compressed data, and unmatching
|
||||
* integrity Check.
|
||||
*
|
||||
* \todo What can be done if encoder returns this?
|
||||
* Probably can continue by fixing the input
|
||||
* amount, but make sure.
|
||||
*/
|
||||
|
||||
LZMA_MEM_ERROR = -4,
|
||||
/**<
|
||||
* \brief Cannot allocate memory
|
||||
*
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
|
||||
LZMA_BUF_ERROR = -5,
|
||||
/**<
|
||||
* \brief No progress is possible
|
||||
*
|
||||
* This may happen when avail_in or avail_out is zero.
|
||||
*
|
||||
* \note This error is not fatal. Coding can continue
|
||||
* normally once the reason for this error has
|
||||
* been fixed.
|
||||
*/
|
||||
|
||||
LZMA_HEADER_ERROR = -6,
|
||||
/**<
|
||||
* \brief Invalid or unsupported header
|
||||
*
|
||||
* Invalid or unsupported options, for example
|
||||
* - unsupported filter(s) or filter options; or
|
||||
* - reserved bits set in headers (decoder only).
|
||||
*
|
||||
* Rebuilding liblzma with more features enabled, or
|
||||
* upgrading to a newer version of liblzma may help.
|
||||
*/
|
||||
|
||||
LZMA_UNSUPPORTED_CHECK = -7,
|
||||
/**<
|
||||
* \brief Check type is unknown
|
||||
*
|
||||
* The type of Check is not supported, and thus the Check
|
||||
* cannot be calculated. In the encoder, this is an error.
|
||||
* In the decoder, this is only a warning and decoding can
|
||||
* still proceed normally (but the Check is ignored).
|
||||
*/
|
||||
} lzma_ret;
|
||||
|
||||
|
||||
/**
|
||||
* \brief The `action' argument for lzma_code()
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_RUN = 0,
|
||||
/**<
|
||||
* Encoder: Encode as much input as possible. Some internal
|
||||
* buffering will probably be done (depends on the filter
|
||||
* chain in use), which causes latency: the input used won't
|
||||
* usually be decodeable from the output of the same
|
||||
* lzma_code() call.
|
||||
*
|
||||
* Decoder: Decode as much input as possible and produce as
|
||||
* much output as possible. This action provides best
|
||||
* throughput, but may introduce latency, because the
|
||||
* decoder may decode more data into its internal buffers
|
||||
* than that fits into next_out.
|
||||
*/
|
||||
|
||||
LZMA_SYNC_FLUSH = 1,
|
||||
/**<
|
||||
* Encoder: Makes all the data given to liblzma via next_in
|
||||
* available in next_out without resetting the filters. Call
|
||||
* lzma_code() with LZMA_SYNC_FLUSH until it returns
|
||||
* LZMA_STREAM_END. Then continue encoding normally.
|
||||
*
|
||||
* \note Synchronous flushing is supported only by
|
||||
* some filters. Some filters support it only
|
||||
* partially.
|
||||
*
|
||||
* Decoder: Asks the decoder to decode only as much as is
|
||||
* needed to fill next_out. This decreases latency with some
|
||||
* filters, but is likely to decrease also throughput. It is
|
||||
* a good idea to use this flag only when it is likely that
|
||||
* you don't need more output soon.
|
||||
*
|
||||
* \note With decoder, this is not comparable to
|
||||
* zlib's Z_SYNC_FLUSH.
|
||||
*/
|
||||
|
||||
LZMA_FULL_FLUSH = 2,
|
||||
/**<
|
||||
* Finishes encoding of the current Data Block. All the input
|
||||
* data going to the current Data Block must have been given
|
||||
* to the encoder (the last bytes can still be pending in
|
||||
* next_in). Call lzma_code() with LZMA_FULL_FLUSH until
|
||||
* it returns LZMA_STREAM_END. Then continue normally with
|
||||
* LZMA_RUN or finish the Stream with LZMA_FINISH.
|
||||
*
|
||||
* This action is supported only by Multi-Block Stream
|
||||
* encoder. If there is no unfinished Data Block, no empty
|
||||
* Data Block is created.
|
||||
*/
|
||||
|
||||
LZMA_FINISH = 3
|
||||
/**<
|
||||
* Finishes the encoding operation. All the input data must
|
||||
* have been given to the encoder (the last bytes can still
|
||||
* be pending in next_in). Call lzma_code() with LZMA_FINISH
|
||||
* until it returns LZMA_STREAM_END.
|
||||
*
|
||||
* This action is not supported by decoders.
|
||||
*/
|
||||
} lzma_action;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Custom functions for memory handling
|
||||
*
|
||||
* A pointer to lzma_allocator may be passed via lzma_stream structure
|
||||
* to liblzma. The library will use these functions for memory handling
|
||||
* instead of the default malloc() and free().
|
||||
*
|
||||
* liblzma doesn't make an internal copy of lzma_allocator. Thus, it is
|
||||
* OK to change these function pointers in the middle of the coding
|
||||
* process, but obviously it must be done carefully to make sure that the
|
||||
* replacement `free' can deallocate memory allocated by the earlier
|
||||
* `alloc' function(s).
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Pointer to custom memory allocation function
|
||||
*
|
||||
* Set this to point to your custom memory allocation function.
|
||||
* It can be useful for example if you want to limit how much
|
||||
* memory liblzma is allowed to use: for this, you may use
|
||||
* a pointer to lzma_memory_alloc().
|
||||
*
|
||||
* If you don't want a custom allocator, but still want
|
||||
* custom free(), set this to NULL and liblzma will use
|
||||
* the standard malloc().
|
||||
*
|
||||
* \param opaque lzma_allocator.opaque (see below)
|
||||
* \param nmemb Number of elements like in calloc().
|
||||
* liblzma will always set nmemb to 1.
|
||||
* This argument exists only for
|
||||
* compatibility with zlib and libbzip2.
|
||||
* \param size Size of an element in bytes.
|
||||
* liblzma never sets this to zero.
|
||||
*
|
||||
* \return Pointer to the beginning of a memory block of
|
||||
* size nmemb * size, or NULL if allocation fails
|
||||
* for some reason. When allocation fails, functions
|
||||
* of liblzma return LZMA_MEM_ERROR.
|
||||
*/
|
||||
void *(*alloc)(void *opaque, size_t nmemb, size_t size);
|
||||
|
||||
/**
|
||||
* \brief Pointer to custom memory freeing function
|
||||
*
|
||||
* Set this to point to your custom memory freeing function.
|
||||
* If lzma_memory_alloc() is used as allocator, this should
|
||||
* be set to lzma_memory_free().
|
||||
*
|
||||
* If you don't want a custom freeing function, but still
|
||||
* want a custom allocator, set this to NULL and liblzma
|
||||
* will use the standard free().
|
||||
*
|
||||
* \param opaque lzma_allocator.opaque (see below)
|
||||
* \param ptr Pointer returned by
|
||||
* lzma_allocator.alloc(), or when it
|
||||
* is set to NULL, a pointer returned
|
||||
* by the standard malloc().
|
||||
*/
|
||||
void (*free)(void *opaque, void *ptr);
|
||||
|
||||
/**
|
||||
* \brief Pointer passed to .alloc() and .free()
|
||||
*
|
||||
* opaque is passed as the first argument to lzma_allocator.alloc()
|
||||
* and lzma_allocator.free(). This intended to ease implementing
|
||||
* custom memory allocation functions for use with liblzma.
|
||||
*
|
||||
* When using lzma_memory_alloc() and lzma_memory_free(), opaque
|
||||
* must point to lzma_memory_limitter structure allocated and
|
||||
* initialized with lzma_memory_limitter_create().
|
||||
*
|
||||
* If you don't need this, you should set it to NULL.
|
||||
*/
|
||||
void *opaque;
|
||||
|
||||
} lzma_allocator;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Internal data structure
|
||||
*
|
||||
* The contents of this structure is not visible outside the library.
|
||||
*/
|
||||
typedef struct lzma_internal_s lzma_internal;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Passing data to and from liblzma
|
||||
*
|
||||
* The lzma_stream structure is used for
|
||||
* - passing pointers to input and output buffers to liblzma;
|
||||
* - defining custom memory hander functions; and
|
||||
* - holding a pointer to coder-specific internal data structures.
|
||||
*
|
||||
* Before calling any of the lzma_*_init() functions the first time,
|
||||
* the application must reset lzma_stream to LZMA_STREAM_INIT. The
|
||||
* lzma_*_init() function will verify the options, allocate internal
|
||||
* data structures and store pointer to them into `internal'. Finally
|
||||
* total_in and total_out are reset to zero. In contrast to zlib,
|
||||
* next_in and avail_in are ignored by the initialization functions.
|
||||
*
|
||||
* The actual coding is done with the lzma_code() function. Application
|
||||
* must update next_in, avail_in, next_out, and avail_out between
|
||||
* calls to lzma_decode() just like with zlib.
|
||||
*
|
||||
* In contrast to zlib, even the decoder requires that there always
|
||||
* is at least one byte space in next_out; if avail_out == 0,
|
||||
* LZMA_BUF_ERROR is returned immediatelly. This shouldn't be a problem
|
||||
* for most applications that already use zlib, but it's still worth
|
||||
* checking your application.
|
||||
*
|
||||
* Application may modify values of total_in and total_out as it wants.
|
||||
* They are updated by liblzma to match the amount of data read and
|
||||
* written, but liblzma doesn't use the values internally.
|
||||
*
|
||||
* Application must not touch the `internal' pointer.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t *next_in; /**< Pointer to the next input byte. */
|
||||
size_t avail_in; /**< Number of available input bytes in next_in. */
|
||||
uint64_t total_in; /**< Total number of bytes read by liblzma. */
|
||||
|
||||
uint8_t *next_out; /**< Pointer to the next output position. */
|
||||
size_t avail_out; /**< Amount of free space in next_out. */
|
||||
uint64_t total_out; /**< Total number of bytes written by liblzma. */
|
||||
|
||||
/**
|
||||
* Custom memory allocation functions. Set to NULL to use
|
||||
* the standard malloc() and free().
|
||||
*/
|
||||
lzma_allocator *allocator;
|
||||
|
||||
/** Internal state is not visible to outsiders. */
|
||||
lzma_internal *internal;
|
||||
|
||||
} lzma_stream;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialization for lzma_stream
|
||||
*
|
||||
* When you declare an instance of lzma_stream, you can immediatelly
|
||||
* initialize it so that initialization functions know that no memory
|
||||
* has been allocated yet:
|
||||
*
|
||||
* lzma_stream strm = LZMA_STREAM_INIT;
|
||||
*/
|
||||
#define LZMA_STREAM_INIT { NULL, 0, 0, NULL, 0, 0, NULL, NULL }
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialization for lzma_stream
|
||||
*
|
||||
* This is like LZMA_STREAM_INIT, but this can be used when the lzma_stream
|
||||
* has already been allocated:
|
||||
*
|
||||
* lzma_stream *strm = malloc(sizeof(lzma_stream));
|
||||
* if (strm == NULL)
|
||||
* return LZMA_MEM_ERROR;
|
||||
* *strm = LZMA_STREAM_INIT_VAR;
|
||||
*/
|
||||
extern const lzma_stream LZMA_STREAM_INIT_VAR;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encodes or decodes data
|
||||
*
|
||||
* Once the lzma_stream has been successfully initialized (e.g. with
|
||||
* lzma_stream_encoder_single()), the actual encoding or decoding is
|
||||
* done using this function.
|
||||
*
|
||||
* \return Some coders may have more exact meaning for different return
|
||||
* values, which are mentioned separately in the description of
|
||||
* the initialization functions. Here are the typical meanings:
|
||||
* - LZMA_OK: So far all good.
|
||||
* - LZMA_STREAM_END:
|
||||
* - Encoder: LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or
|
||||
* LZMA_FINISH completed.
|
||||
* - Decoder: End of uncompressed data was reached.
|
||||
* - LZMA_BUF_ERROR: Unable to progress. Provide more input or
|
||||
* output space, and call this function again. This cannot
|
||||
* occur if both avail_in and avail_out were non-zero (or
|
||||
* there's a bug in liblzma).
|
||||
* - LZMA_MEM_ERROR: Unable to allocate memory. Due to lazy
|
||||
* programming, the coding cannot continue even if the
|
||||
* application could free more memory. The next call must
|
||||
* be lzma_end() or some initialization function.
|
||||
* - LZMA_DATA_ERROR:
|
||||
* - Encoder: Filter(s) cannot process the given data.
|
||||
* - Decoder: Compressed data is corrupt.
|
||||
* - LZMA_HEADER_ERROR: Unsupported options. Rebuilding liblzma
|
||||
* with more features enabled or upgrading to a newer version
|
||||
* may help, although usually this is a sign of invalid options
|
||||
* (encoder) or corrupted input data (decoder).
|
||||
* - LZMA_PROG_ERROR: Invalid arguments or the internal state
|
||||
* of the coder is corrupt.
|
||||
*/
|
||||
extern lzma_ret lzma_code(lzma_stream *strm, lzma_action action);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Frees memory allocated for the coder data structures
|
||||
*
|
||||
* \param strm Pointer to lzma_stream that is at least initialized
|
||||
* with LZMA_STREAM_INIT.
|
||||
*
|
||||
* \note zlib indicates an error if application end()s unfinished
|
||||
* stream. liblzma doesn't do this, and assumes that
|
||||
* application knows what it is doing.
|
||||
*/
|
||||
extern void lzma_end(lzma_stream *strm);
|
||||
409
src/liblzma/api/lzma/block.h
Normal file
409
src/liblzma/api/lzma/block.h
Normal file
@ -0,0 +1,409 @@
|
||||
/**
|
||||
* \file lzma/block.h
|
||||
* \brief .lzma Block handling
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for the Block Header encoder and decoder
|
||||
*
|
||||
* Different things use different parts of this structure. Some read
|
||||
* some members, other functions write, and some do both. Only the
|
||||
* members listed for reading need to be initialized when the specified
|
||||
* functions are called. The members marked for writing will be assigned
|
||||
* new values at some point either by calling the given function or by
|
||||
* later calls to lzma_code().
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Type of integrity Check
|
||||
*
|
||||
* The type of the integrity Check is not stored into the Block
|
||||
* Header, thus its value must be provided also when decoding.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*/
|
||||
lzma_check_type check;
|
||||
|
||||
/**
|
||||
* \brief Precense of CRC32 of the Block Header
|
||||
*
|
||||
* Set this to true if CRC32 of the Block Header should be
|
||||
* calculated and stored in the Block Header.
|
||||
*
|
||||
* There is no way to autodetect if CRC32 is present in the Block
|
||||
* Header, thus this information must be provided also when decoding.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encoder()
|
||||
* - lzma_block_header_decoder()
|
||||
*/
|
||||
lzma_bool has_crc32;
|
||||
|
||||
/**
|
||||
* \brief Usage of End of Payload Marker
|
||||
*
|
||||
* If this is true, End of Payload Marker is used even if
|
||||
* Uncompressed Size is known.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_encoder()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decoder()
|
||||
*/
|
||||
lzma_bool has_eopm;
|
||||
|
||||
/**
|
||||
* \brief True if the Block is a Metadata Block
|
||||
*
|
||||
* If this is true, the Metadata bit will be set in the Block Header.
|
||||
* It is up to the application to store correctly formatted data
|
||||
* into Metadata Block.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_encoder()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decoder()
|
||||
*/
|
||||
lzma_bool is_metadata;
|
||||
|
||||
/**
|
||||
* \brief True if Uncompressed Size is in Block Footer
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*/
|
||||
lzma_bool has_uncompressed_size_in_footer;
|
||||
|
||||
/**
|
||||
* \brief True if Backward Size is in Block Footer
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*/
|
||||
lzma_bool has_backward_size;
|
||||
|
||||
/**
|
||||
* \brief True if Block coder should take care of Padding
|
||||
*
|
||||
* In liblzma, Stream decoder sets this to true when decoding
|
||||
* Header Metadata Block or Data Blocks from Multi-Block Stream,
|
||||
* and to false when decoding Single-Block Stream or Footer
|
||||
* Metadata Block from a Multi-Block Stream.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*/
|
||||
lzma_bool handle_padding;
|
||||
|
||||
/**
|
||||
* \brief Size of the Compressed Data in bytes
|
||||
*
|
||||
* Usually you don't know this value when encoding in streamed mode.
|
||||
* In non-streamed mode you can reserve space for this field when
|
||||
* encoding the Block Header the first time, and then re-encode the
|
||||
* Block Header and copy it over the original one after the encoding
|
||||
* of the Block has been finished.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encoder()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decoder()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*/
|
||||
lzma_vli compressed_size;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed Size in bytes
|
||||
*
|
||||
* Encoder: If this value is not LZMA_VLI_VALUE_UNKNOWN, it is stored
|
||||
* to the Uncompressed Size field in the Block Header. The real
|
||||
* uncompressed size of the data being compressed must match
|
||||
* the Uncompressed Size or LZMA_HEADER_ERROR is returned.
|
||||
*
|
||||
* If Uncompressed Size is unknown, End of Payload Marker must
|
||||
* be used. If uncompressed_size == LZMA_VLI_VALUE_UNKNOWN and
|
||||
* has_eopm == 0, LZMA_HEADER_ERROR will be returned.
|
||||
*
|
||||
* Decoder: If this value is not LZMA_VLI_VALUE_UNKNOWN, it is
|
||||
* compared to the real Uncompressed Size. If they do not match,
|
||||
* LZMA_HEADER_ERROR is returned.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encoder()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decoder()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*/
|
||||
lzma_vli uncompressed_size;
|
||||
|
||||
/**
|
||||
* \brief Number of bytes to reserve for Compressed Size
|
||||
*
|
||||
* This is useful if you want to be able to store the Compressed Size
|
||||
* to the Block Header, but you don't know it when starting to encode.
|
||||
* Setting this to non-zero value at maximum of LZMA_VLI_BYTES_MAX,
|
||||
* the Block Header encoder will force the Compressed Size field to
|
||||
* occupy specified number of bytes. You can later rewrite the Block
|
||||
* Header to contain correct information by using otherwise identical
|
||||
* lzma_options_block structure except the correct compressed_size.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encoder()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decoder()
|
||||
*/
|
||||
uint32_t compressed_reserve;
|
||||
|
||||
/**
|
||||
* \brief Number of bytes to reserve for Uncompressed Size
|
||||
*
|
||||
* See the description of compressed_size above.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encoder()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decoder()
|
||||
*/
|
||||
uint32_t uncompressed_reserve;
|
||||
|
||||
/**
|
||||
* \brief Total Size of the Block in bytes
|
||||
*
|
||||
* This is useful in the decoder, which can verify the Total Size
|
||||
* if it is known from Index.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*/
|
||||
lzma_vli total_size;
|
||||
|
||||
/**
|
||||
* \brief Upper limit of Total Size
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*/
|
||||
lzma_vli total_limit;
|
||||
|
||||
/**
|
||||
* \brief Upper limit of Uncompressed Size
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*/
|
||||
lzma_vli uncompressed_limit;
|
||||
|
||||
/**
|
||||
* \brief Array of filters
|
||||
*
|
||||
* There can be at maximum of seven filters. The end of the array
|
||||
* is marked with .id = LZMA_VLI_VALUE_UNKNOWN. Minimum number of
|
||||
* filters is zero; in that case, an implicit Copy filter is used.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encoder()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decoder(): Note that this does NOT free()
|
||||
* the old filter options structures. If decoding fails, the
|
||||
* caller must take care of freeing the options structures
|
||||
* that may have been allocated and decoded before the error
|
||||
* occurred.
|
||||
*/
|
||||
lzma_options_filter filters[8];
|
||||
|
||||
/**
|
||||
* \brief Size of the Padding field
|
||||
*
|
||||
* The Padding field exist to allow aligning the Compressed Data field
|
||||
* optimally in the Block. See lzma_options_stream.alignment in
|
||||
* stream.h for more information.
|
||||
*
|
||||
* If you want the Block Header encoder to automatically calculate
|
||||
* optimal size for the Padding field by looking at the information
|
||||
* in filters[], set this to LZMA_BLOCK_HEADER_PADDING_AUTO. In that
|
||||
* case, you must also set the aligmnet variable to tell the the
|
||||
* encoder the aligmnet of the beginning of the Block Header.
|
||||
*
|
||||
* The decoder never sets this to LZMA_BLOCK_HEADER_PADDING_AUTO.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encoder(): Note that this doesn't
|
||||
* accept LZMA_BLOCK_HEADER_PADDING_AUTO.
|
||||
*
|
||||
* Written by (these never set padding to
|
||||
* LZMA_BLOCK_HEADER_PADDING_AUTO):
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_decoder()
|
||||
*/
|
||||
int32_t padding;
|
||||
# define LZMA_BLOCK_HEADER_PADDING_AUTO (-1)
|
||||
# define LZMA_BLOCK_HEADER_PADDING_MIN 0
|
||||
# define LZMA_BLOCK_HEADER_PADDING_MAX 31
|
||||
|
||||
/**
|
||||
* \brief Alignment of the beginning of the Block Header
|
||||
*
|
||||
* This variable is read only if padding has been set to
|
||||
* LZMA_BLOCK_HEADER_PADDING_AUTO.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encoder()
|
||||
*/
|
||||
uint32_t alignment;
|
||||
|
||||
/**
|
||||
* \brief Size of the Block Header
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_decoder()
|
||||
*/
|
||||
uint32_t header_size;
|
||||
|
||||
} lzma_options_block;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculates the size of Header Padding and Block Header
|
||||
*
|
||||
* \return - LZMA_OK: Size calculated successfully and stored to
|
||||
* options->header_size.
|
||||
* - LZMA_HEADER_ERROR: Unsupported filters or filter options.
|
||||
* - LZMA_PROG_ERROR: Invalid options
|
||||
*
|
||||
* \note This doesn't check that all the options are valid i.e. this
|
||||
* may return LZMA_OK even if lzma_block_header_encode() or
|
||||
* lzma_block_encoder() would fail.
|
||||
*/
|
||||
extern lzma_ret lzma_block_header_size(lzma_options_block *options);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encodes Block Header
|
||||
*
|
||||
* Encoding of the Block options is done with a single call instead of
|
||||
* first initializing and then doing the actual work with lzma_code().
|
||||
*
|
||||
* \param out Beginning of the output buffer. This must be
|
||||
* at least options->header_size bytes.
|
||||
* \param options Block options to be encoded.
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful. options->header_size
|
||||
* bytes were written to output buffer.
|
||||
* - LZMA_HEADER_ERROR: Invalid or unsupported options.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern lzma_ret lzma_block_header_encode(
|
||||
uint8_t *out, const lzma_options_block *options);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initializes Block Header decoder
|
||||
*
|
||||
* Because the results of this decoder are placed into *options,
|
||||
* strm->next_in, strm->avail_in, and strm->total_in are not used.
|
||||
*
|
||||
* The only valid `action' with lzma_code() is LZMA_RUN.
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful. options->header_size
|
||||
* bytes were written to output buffer.
|
||||
* - LZMA_HEADER_ERROR: Invalid or unsupported options.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern lzma_ret lzma_block_header_decoder(
|
||||
lzma_stream *strm, lzma_options_block *options);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initializes .lzma Block encoder
|
||||
*
|
||||
* This function is required for multi-thread encoding. It may also be
|
||||
* useful when implementing custom file formats.
|
||||
*
|
||||
* \return - LZMA_OK: All good, continue with lzma_code().
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_HEADER_ERROR
|
||||
* - LZMA_DATA_ERROR: Limits (total_limit and uncompressed_limit)
|
||||
* have been reached already.
|
||||
* - LZMA_UNSUPPORTED_CHECK: options->check specfies a Check
|
||||
* that is not supported by this buid of liblzma. Initializing
|
||||
* the encoder failed.
|
||||
* - LZMA_PROG_ERROR
|
||||
*
|
||||
* lzma_code() can return FIXME
|
||||
*/
|
||||
extern lzma_ret lzma_block_encoder(
|
||||
lzma_stream *strm, lzma_options_block *options);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initializes decoder for .lzma Block
|
||||
*
|
||||
* \return - LZMA_OK: All good, continue with lzma_code().
|
||||
* - LZMA_UNSUPPORTED_CHECK: Initialization was successful, but
|
||||
* the given Check type is not supported, thus Check will be
|
||||
* ignored.
|
||||
* - LZMA_PROG_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
*/
|
||||
extern lzma_ret lzma_block_decoder(
|
||||
lzma_stream *strm, lzma_options_block *options);
|
||||
128
src/liblzma/api/lzma/check.h
Normal file
128
src/liblzma/api/lzma/check.h
Normal file
@ -0,0 +1,128 @@
|
||||
/**
|
||||
* \file lzma/check.h
|
||||
* \brief Integrity checks
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Type of the Check
|
||||
*
|
||||
* The .lzma format supports multiple types of Checks that are calculated
|
||||
* from the uncompressed data (unless it is empty; then it's calculated
|
||||
* from Block Header).
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_CHECK_NONE = 0,
|
||||
/**<
|
||||
* No Check is calculated.
|
||||
*
|
||||
* Size of the Check field: 0 bytes
|
||||
*/
|
||||
|
||||
LZMA_CHECK_CRC32 = 1,
|
||||
/**<
|
||||
* CRC32 using the polynomial from the IEEE 802.3 standard
|
||||
*
|
||||
* Size of the Check field: 4 bytes
|
||||
*/
|
||||
|
||||
LZMA_CHECK_CRC64 = 3,
|
||||
/**<
|
||||
* CRC64 using the polynomial from the ECMA-182 standard
|
||||
*
|
||||
* Size of the Check field: 8 bytes
|
||||
*/
|
||||
|
||||
LZMA_CHECK_SHA256 = 5
|
||||
/**<
|
||||
* SHA-256
|
||||
*
|
||||
* Size of the Check field: 32 bytes
|
||||
*/
|
||||
} lzma_check_type;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Maximum valid Check ID
|
||||
*
|
||||
* The .lzma file format specification specifies eight Check IDs (0-7). Some
|
||||
* of them are only reserved i.e. no actual Check algorithm has been assigned.
|
||||
* Still liblzma accepts any of these eight IDs for future compatibility
|
||||
* when decoding files. If a valid but unsupported Check ID is detected,
|
||||
* liblzma indicates a warning with LZMA_UNSUPPORTED_CHECK.
|
||||
*
|
||||
* FIXME bad desc
|
||||
*/
|
||||
#define LZMA_CHECK_ID_MAX 7
|
||||
|
||||
|
||||
/**
|
||||
* \brief Check IDs supported by this liblzma build
|
||||
*
|
||||
* If lzma_available_checks[n] is true, the Check ID n is supported by this
|
||||
* liblzma build. You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32
|
||||
* are always available.
|
||||
*/
|
||||
extern const lzma_bool lzma_available_checks[LZMA_CHECK_ID_MAX + 1];
|
||||
|
||||
|
||||
/**
|
||||
* \brief Size of the Check field with different Check IDs
|
||||
*
|
||||
* Although not all Check IDs have a check algorithm associated, the size of
|
||||
* every Check is already frozen. This array contains the size (in bytes) of
|
||||
* the Check field with specified Check ID. The values are taken from the
|
||||
* section 2.2.2 of the .lzma file format specification:
|
||||
* { 0, 4, 4, 8, 16, 32, 32, 64 }
|
||||
*/
|
||||
extern const uint32_t lzma_check_sizes[LZMA_CHECK_ID_MAX + 1];
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate CRC32
|
||||
*
|
||||
* Calculates CRC32 using the polynomial from the IEEE 802.3 standard.
|
||||
*
|
||||
* \param buf Pointer to the input buffer
|
||||
* \param size Size of the input buffer
|
||||
* \param crc Previously returned CRC value. This is used to
|
||||
* calculate the CRC of a big buffer in smaller chunks.
|
||||
* Set to zero when there is no previous value.
|
||||
*
|
||||
* \return Updated CRC value, which can be passed to this function
|
||||
* again to continue CRC calculation.
|
||||
*/
|
||||
extern uint32_t lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate CRC64
|
||||
*
|
||||
* Calculates CRC64 using the polynomial from the ECMA-182 standard.
|
||||
*
|
||||
* This function is used similarly to lzma_crc32(). See its documentation.
|
||||
*/
|
||||
extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc);
|
||||
|
||||
|
||||
/*
|
||||
* SHA256 functions are currently not exported to public API.
|
||||
* Contact the author if you think it should be.
|
||||
*/
|
||||
29
src/liblzma/api/lzma/copy.h
Normal file
29
src/liblzma/api/lzma/copy.h
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* \file lzma/copy.h
|
||||
* \brief Copy filter
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Filter ID
|
||||
*
|
||||
* Filter ID of the Copy filter. This is used as lzma_options_filter.id.
|
||||
*/
|
||||
#define LZMA_FILTER_COPY LZMA_VLI_C(0x00)
|
||||
49
src/liblzma/api/lzma/delta.h
Normal file
49
src/liblzma/api/lzma/delta.h
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* \file lzma/delta.h
|
||||
* \brief Delta filter
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Filter ID
|
||||
*
|
||||
* Filter ID of the Delta filter. This is used as lzma_options_filter.id.
|
||||
*/
|
||||
#define LZMA_FILTER_DELTA LZMA_VLI_C(0x20)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for the Delta filter
|
||||
*
|
||||
* These options are needed by both encoder and decoder.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Delta distance as bytes
|
||||
*
|
||||
* Examples:
|
||||
* - 16-bit stereo audio: distance = 4 bytes
|
||||
* - 24-bit RGB image data: distance = 3 bytes
|
||||
*/
|
||||
uint32_t distance;
|
||||
# define LZMA_DELTA_DISTANCE_MIN 1
|
||||
# define LZMA_DELTA_DISTANCE_MAX 256
|
||||
|
||||
} lzma_options_delta;
|
||||
114
src/liblzma/api/lzma/extra.h
Normal file
114
src/liblzma/api/lzma/extra.h
Normal file
@ -0,0 +1,114 @@
|
||||
/**
|
||||
* \file lzma/extra.h
|
||||
* \brief Handling of Extra Records in Metadata
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Extra Record IDs
|
||||
*
|
||||
* See the .lzma file format specification for description what each
|
||||
* Extra Record type exactly means.
|
||||
*
|
||||
* If you ever need to update .lzma files with Extra Records, note that
|
||||
* the Record IDs are divided in two categories:
|
||||
* - Safe-to-Copy Records may be preserved as is when the
|
||||
* Stream is modified in ways that don't change the actual
|
||||
* uncompressed data. Examples of such operatings include
|
||||
* recompressing and adding, modifying, or deleting unrelated
|
||||
* Extra Records.
|
||||
* - Unsafe-to-Copy Records should be removed (and possibly
|
||||
* recreated) when any kind of changes are made to the Stream.
|
||||
*/
|
||||
|
||||
#define LZMA_EXTRA_PADDING 0x00
|
||||
#define LZMA_EXTRA_OPENPGP 0x01
|
||||
#define LZMA_EXTRA_FILTERS 0x02
|
||||
#define LZMA_EXTRA_COMMENT 0x03
|
||||
#define LZMA_EXTRA_CHECKS 0x04
|
||||
#define LZMA_EXTRA_FILENAME 0x05
|
||||
#define LZMA_EXTRA_MTIME 0x07
|
||||
#define LZMA_EXTRA_MTIME_HR 0x09
|
||||
#define LZMA_EXTRA_MIME_TYPE 0x0B
|
||||
#define LZMA_EXTRA_HOMEPAGE 0x0D
|
||||
|
||||
|
||||
/**
|
||||
* \brief Extra Records
|
||||
*
|
||||
* The .lzma format provides a way to store custom information along
|
||||
* the actual compressed content. Information about these Records
|
||||
* are passed to and from liblzma via this linked list.
|
||||
*/
|
||||
typedef struct lzma_extra_s lzma_extra;
|
||||
struct lzma_extra_s {
|
||||
/**
|
||||
* \brief Pointer to the next Extra Record
|
||||
*
|
||||
* This is NULL on the last Extra Record.
|
||||
*/
|
||||
lzma_extra *next;
|
||||
|
||||
/**
|
||||
* \brief Record ID
|
||||
*
|
||||
* Extra Record IDs are divided in three categories:
|
||||
* - Zero is a special case used for padding. It doesn't have
|
||||
* Size of Data fields.
|
||||
* - Odd IDs (1, 3, 5, ...) are Safe-to-Copy IDs.
|
||||
* These can be preserved as is if the Stream is
|
||||
* modified in a way that doesn't alter the actual
|
||||
* uncompressed content.
|
||||
* - Even IDs (2, 4, 6, ...) are Unsafe-to-Copy IDs.
|
||||
* If the .lzma Stream is modified in any way,
|
||||
* the Extra Records having a sensitive ID should
|
||||
* be removed or updated accordingly.
|
||||
*
|
||||
* Refer to the .lzma file format specification for
|
||||
* the up to date list of Extra Record IDs.
|
||||
*/
|
||||
lzma_vli id;
|
||||
|
||||
/**
|
||||
* \brief Size of the Record data
|
||||
*
|
||||
* In case of strings, this should not include the
|
||||
* trailing '\0'.
|
||||
*/
|
||||
size_t size;
|
||||
|
||||
/**
|
||||
* \brief Record data
|
||||
*
|
||||
* Record data is often a string in UTF-8 encoding,
|
||||
* but it can be arbitrary binary data. In case of
|
||||
* strings, the trailing '\0' is usually not stored
|
||||
* in the .lzma file.
|
||||
*
|
||||
* To ease working with Extra Records containing strings,
|
||||
* liblzma always adds '\0' to the end of data even when
|
||||
* it wasn't present in the .lzma file. This '\0' is not
|
||||
* counted in the size of the data.
|
||||
*/
|
||||
uint8_t *data;
|
||||
};
|
||||
|
||||
|
||||
extern void lzma_extra_free(lzma_extra *extra, lzma_allocator *allocator);
|
||||
166
src/liblzma/api/lzma/filter.h
Normal file
166
src/liblzma/api/lzma/filter.h
Normal file
@ -0,0 +1,166 @@
|
||||
/**
|
||||
* \file lzma/filter.h
|
||||
* \brief Common filter related types
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Filter options
|
||||
*
|
||||
* This structure is used to pass Filter ID and a pointer filter's options
|
||||
* to liblzma.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Filter ID
|
||||
*
|
||||
* Use constants whose name begin with `LZMA_FILTER_' to specify
|
||||
* different filters. In an array of lzma_option_filter structures,
|
||||
* use LZMA_VLI_VALUE_UNKNOWN to indicate end of filters.
|
||||
*/
|
||||
lzma_vli id;
|
||||
|
||||
/**
|
||||
* \brief Pointer to filter-specific options structure
|
||||
*
|
||||
* If the filter doesn't need options, set this to NULL. If id is
|
||||
* set to LZMA_VLI_VALUE_UNKNOWN, options is ignored, and thus
|
||||
* doesn't need be initialized.
|
||||
*
|
||||
* Some filters support changing the options in the middle of
|
||||
* the encoding process. These filters store the pointer of the
|
||||
* options structure and communicate with the application via
|
||||
* modifications of the options structure.
|
||||
*/
|
||||
void *options;
|
||||
|
||||
} lzma_options_filter;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Filters available for encoding
|
||||
*
|
||||
* Pointer to an array containing the list of available Filter IDs that
|
||||
* can be used for encoding. The last element is LZMA_VLI_VALUE_UNKNOWN.
|
||||
*
|
||||
* If lzma_available_filter_encoders[0] == LZMA_VLI_VALUE_UNKNOWN, the
|
||||
* encoder components haven't been built at all. This means that the
|
||||
* encoding-specific functions are probably missing from the library
|
||||
* API/ABI completely.
|
||||
*/
|
||||
extern const lzma_vli *const lzma_available_filter_encoders;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Filters available for decoding
|
||||
*
|
||||
* Pointer to an array containing the list of available Filter IDs that
|
||||
* can be used for decoding. The last element is LZMA_VLI_VALUE_UNKNOWN.
|
||||
*
|
||||
* If lzma_available_filter_decoders[0] == LZMA_VLI_VALUE_UNKNOWN, the
|
||||
* decoder components haven't been built at all. This means that the
|
||||
* decoding-specific functions are probably missing from the library
|
||||
* API/ABI completely.
|
||||
*/
|
||||
extern const lzma_vli *const lzma_available_filter_decoders;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate rough memory requirements for given filter chain
|
||||
*
|
||||
* \param filters Array of filters terminated with
|
||||
* .id == LZMA_VLI_VALUE_UNKNOWN.
|
||||
* \param is_encoder Set to true when calculating memory requirements
|
||||
* of an encoder; false for decoder.
|
||||
*
|
||||
* \return Number of mebibytes (MiB i.e. 2^20) required for the given
|
||||
* encoder or decoder filter chain.
|
||||
*
|
||||
* \note If calculating memory requirements of encoder, lzma_init() or
|
||||
* lzma_init_encoder() must have been called earlier. Similarly,
|
||||
* if calculating memory requirements of decoder, lzma_init() or
|
||||
* lzma_init_decoder() must have been called earlier.
|
||||
*/
|
||||
extern uint32_t lzma_memory_usage(
|
||||
const lzma_options_filter *filters, lzma_bool is_encoder);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculates encoded size of a Filter Flags field
|
||||
*
|
||||
* Knowing the size of Filter Flags is useful to know when allocating
|
||||
* memory to hold the encoded Filter Flags.
|
||||
*
|
||||
* \param size Pointer to integer to hold the calculated size
|
||||
* \param options Filter ID and associated options whose encoded
|
||||
* size is to be calculted
|
||||
*
|
||||
* \return - LZMA_OK: *size set successfully. Note that this doesn't
|
||||
* guarantee that options->options is valid, thus
|
||||
* lzma_filter_flags_encode() may still fail.
|
||||
* - LZMA_HEADER_ERROR: Unknown Filter ID or unsupported options.
|
||||
* - LZMA_PROG_ERROR: Invalid options
|
||||
*
|
||||
* \note If you need to calculate size of List of Filter Flags,
|
||||
* you need to loop over every lzma_options_filter entry.
|
||||
*/
|
||||
extern lzma_ret lzma_filter_flags_size(
|
||||
uint32_t *size, const lzma_options_filter *options);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encodes Filter Flags into given buffer
|
||||
*
|
||||
* In contrast to some functions, this doesn't allocate the needed buffer.
|
||||
* This is due to how this function is used internally by liblzma.
|
||||
*
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos out[*out_pos] is the next write position. This
|
||||
* is updated by the encoder.
|
||||
* \param out_size out[out_size] is the first byte to not write.
|
||||
* \param options Filter options to be encoded
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_HEADER_ERROR: Invalid or unsupported options.
|
||||
* - LZMA_PROG_ERROR: Invalid options or not enough output
|
||||
* buffer space (you should have checked it with
|
||||
* lzma_filter_flags_size()).
|
||||
*/
|
||||
extern lzma_ret lzma_filter_flags_encode(uint8_t *out, size_t *out_pos,
|
||||
size_t out_size, const lzma_options_filter *options);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initializes Filter Flags decoder
|
||||
*
|
||||
* The decoded result is stored into *options. options->options is
|
||||
* initialized but the old value is NOT free()d.
|
||||
*
|
||||
* Because the results of this decoder are placed into *options,
|
||||
* strm->next_in, strm->avail_in, and strm->total_in are not used
|
||||
* when calling lzma_code(). The only valid action for lzma_code()
|
||||
* is LZMA_RUN
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern lzma_ret lzma_filter_flags_decoder(
|
||||
lzma_stream *strm, lzma_options_filter *options);
|
||||
84
src/liblzma/api/lzma/index.h
Normal file
84
src/liblzma/api/lzma/index.h
Normal file
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* \file lzma/index.h
|
||||
* \brief Handling of Index lists
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief
|
||||
*
|
||||
* FIXME desc
|
||||
*/
|
||||
typedef struct lzma_index_s lzma_index;
|
||||
struct lzma_index_s {
|
||||
/**
|
||||
* \brief Total Size of the Block
|
||||
*
|
||||
* This includes Block Header, Compressed Data, and Block Footer.
|
||||
*/
|
||||
lzma_vli total_size;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed Size of the Block
|
||||
*/
|
||||
lzma_vli uncompressed_size;
|
||||
|
||||
/**
|
||||
* \brief Pointer to the next Index Record
|
||||
*
|
||||
* This is NULL on the last Index Record.
|
||||
*/
|
||||
lzma_index *next;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Duplicates an Index list
|
||||
*
|
||||
* \return A copy of the Index list, or NULL if memory allocation
|
||||
* failed or the original Index was empty.
|
||||
*/
|
||||
extern lzma_index *lzma_index_dup(
|
||||
const lzma_index *index, lzma_allocator *allocator);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Frees an Index list
|
||||
*
|
||||
* All Index Recors in the list are freed. This function is convenient when
|
||||
* getting rid of lzma_metadata structures containing an Index.
|
||||
*/
|
||||
extern void lzma_index_free(lzma_index *index, lzma_allocator *allocator);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculates information about the Index
|
||||
*
|
||||
* \return LZMA_OK on success, LZMA_PROG_ERROR on error. FIXME
|
||||
*/
|
||||
extern lzma_ret lzma_index_count(const lzma_index *index, size_t *count,
|
||||
lzma_vli *lzma_restrict total_size,
|
||||
lzma_vli *lzma_restrict uncompressed_size);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Compares if two Index lists are identical
|
||||
*/
|
||||
extern lzma_bool lzma_index_is_equal(const lzma_index *a, const lzma_index *b);
|
||||
315
src/liblzma/api/lzma/info.h
Normal file
315
src/liblzma/api/lzma/info.h
Normal file
@ -0,0 +1,315 @@
|
||||
/**
|
||||
* \file lzma/info.h
|
||||
* \brief Handling of Stream size information
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**********
|
||||
* Basics *
|
||||
**********/
|
||||
|
||||
/**
|
||||
* \brief Opaque data type to hold the size information
|
||||
*/
|
||||
typedef struct lzma_info_s lzma_info;
|
||||
|
||||
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Total Size of this Block
|
||||
*
|
||||
* This can be LZMA_VLI_VALUE_UNKNOWN.
|
||||
*/
|
||||
lzma_vli total_size;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed Size of this Block
|
||||
*
|
||||
* This can be LZMA_VLI_VALUE_UNKNOWN.
|
||||
*/
|
||||
lzma_vli uncompressed_size;
|
||||
|
||||
/**
|
||||
* \brief Offset of the first byte of the Block
|
||||
*
|
||||
* In encoder, this is useful to find out the alignment of the Block.
|
||||
*
|
||||
* In decoder, this is useful when doing random-access reading
|
||||
* with help from lzma_info_data_locate().
|
||||
*/
|
||||
lzma_vli stream_offset;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed offset of the Block
|
||||
*
|
||||
* Offset of the first uncompressed byte of the Block relative to
|
||||
* all uncompressed data in the Block.
|
||||
* FIXME desc
|
||||
*/
|
||||
lzma_vli uncompressed_offset;
|
||||
|
||||
/**
|
||||
* \brief Pointers to internal data structures
|
||||
*
|
||||
* Applications must not touch these.
|
||||
*/
|
||||
void *internal[4];
|
||||
|
||||
} lzma_info_iter;
|
||||
|
||||
|
||||
typedef enum {
|
||||
LZMA_INFO_STREAM_START,
|
||||
LZMA_INFO_HEADER_METADATA,
|
||||
LZMA_INFO_TOTAL,
|
||||
LZMA_INFO_UNCOMPRESSED,
|
||||
LZMA_INFO_FOOTER_METADATA
|
||||
} lzma_info_size;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Allocates and initializes a new lzma_info structure
|
||||
*
|
||||
* If info is NULL, a new lzma_info structure is allocated, initialized, and
|
||||
* a pointer to it returned. If allocation fails, NULL is returned.
|
||||
*
|
||||
* If info is non-NULL, it is reinitialized and the same pointer returned.
|
||||
* (In this case, return value cannot be NULL or a different pointer than
|
||||
* the info given as argument.)
|
||||
*/
|
||||
extern lzma_info *lzma_info_init(lzma_info *info, lzma_allocator *allocator);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Resets lzma_info
|
||||
*
|
||||
* This is like calling lzma_info_end() and lzma_info_create(), but
|
||||
* re-uses the existing base structure.
|
||||
*/
|
||||
extern void lzma_info_reset(
|
||||
lzma_info *info, lzma_allocator *allocator);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Frees memory allocated for a lzma_info structure
|
||||
*/
|
||||
extern void lzma_info_free(lzma_info *info, lzma_allocator *allocator);
|
||||
|
||||
|
||||
/************************
|
||||
* Setting known values *
|
||||
************************/
|
||||
|
||||
/**
|
||||
* \brief Set a known size value
|
||||
*
|
||||
* \param info Pointer returned by lzma_info_create()
|
||||
* \param type Any value from lzma_info_size
|
||||
* \param size Value to set or verify
|
||||
*
|
||||
* \return LZMA_OK on success, LZMA_DATA_ERROR if the size doesn't
|
||||
* match the existing information, or LZMA_PROG_ERROR
|
||||
* if type is invalid or size is not a valid VLI.
|
||||
*/
|
||||
extern lzma_ret lzma_info_size_set(
|
||||
lzma_info *info, lzma_info_size type, lzma_vli size);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Sets the Index
|
||||
*
|
||||
* The given lzma_index list is "absorbed" by this function. The application
|
||||
* must not access it after this function call, even if this function returns
|
||||
* an error.
|
||||
*
|
||||
* \note The given lzma_index will at some point get freed by the
|
||||
* lzma_info_* functions. If you use a custom lzma_allocator,
|
||||
* make sure that it can free the lzma_index.
|
||||
*/
|
||||
extern lzma_ret lzma_info_index_set(
|
||||
lzma_info *info, lzma_allocator *allocator,
|
||||
lzma_index *index, lzma_bool eat_index);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Sets information from a known Metadata Block
|
||||
*
|
||||
* This is a shortcut for calling lzma_info_size_set() with different type
|
||||
* arguments, lzma_info_index_set() with metadata->index.
|
||||
*/
|
||||
extern lzma_ret lzma_info_metadata_set(lzma_info *info,
|
||||
lzma_allocator *allocator, lzma_metadata *metadata,
|
||||
lzma_bool is_header_metadata, lzma_bool eat_index);
|
||||
|
||||
|
||||
/***************
|
||||
* Incremental *
|
||||
***************/
|
||||
|
||||
/**
|
||||
* \brief Prepares an iterator to be used with given lzma_info structure
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern void lzma_info_iter_begin(lzma_info *info, lzma_info_iter *iter);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Moves to the next Index Record
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern lzma_ret lzma_info_iter_next(
|
||||
lzma_info_iter *iter, lzma_allocator *allocator);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Sets or verifies the sizes in the Index Record
|
||||
*
|
||||
* \param iter Pointer to iterator to be set or verified
|
||||
* \param total_size
|
||||
* Total Size in bytes or LZMA_VLI_VALUE_UNKNOWN
|
||||
* \param uncompressed_size
|
||||
* Uncompressed Size or LZMA_VLI_VALUE_UNKNOWN
|
||||
*
|
||||
* \return - LZMA_OK: All OK.
|
||||
* - LZMA_DATA_ERROR: Given sizes don't match with the already
|
||||
* known sizes.
|
||||
* - LZMA_PROG_ERROR: Internal error, possibly integer
|
||||
* overflow (e.g. the sum of all the known sizes is too big)
|
||||
*/
|
||||
extern lzma_ret lzma_info_iter_set(lzma_info_iter *iter,
|
||||
lzma_vli total_size, lzma_vli uncompressed_size);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Locates a Data Block
|
||||
*
|
||||
* \param iter Properly initialized iterator
|
||||
* \param allocator Pointer to lzma_allocator or NULL
|
||||
* \param uncompressed_offset
|
||||
* Target offset to locate. The final offset
|
||||
* will be equal or smaller than this.
|
||||
* \param allow_alloc True if this function is allowed to call
|
||||
* lzma_info_iter_next() to allocate a new Record
|
||||
* if the requested offset reached end of Index
|
||||
* Record list. Note that if Index has been marked
|
||||
* final, lzma_info_iter_next() is never called.
|
||||
*
|
||||
* \return - LZMA_OK: All OK, *iter updated accordingly.
|
||||
* - LZMA_DATA_ERROR: Trying to search past the end of the Index
|
||||
* Record list, and allocating a new Record was not allowed
|
||||
* either because allow_alloc was false or Index was final.
|
||||
* - LZMA_PROG_ERROR: Internal error (probably integer
|
||||
* overflow causing some lzma_vli getting too big).
|
||||
*/
|
||||
extern lzma_ret lzma_info_iter_locate(lzma_info_iter *iter,
|
||||
lzma_allocator *allocator, lzma_vli uncompressed_offset,
|
||||
lzma_bool allow_alloc);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Finishes incrementally constructed Index
|
||||
*
|
||||
* This sets the known Total Size and Uncompressed of the Data Blocks
|
||||
* based on the information collected from the Index Records, and marks
|
||||
* the Index as final.
|
||||
*/
|
||||
extern lzma_ret lzma_info_index_finish(lzma_info *info);
|
||||
|
||||
|
||||
/***************************
|
||||
* Reading the information *
|
||||
***************************/
|
||||
|
||||
/**
|
||||
* \brief Gets a known size
|
||||
*
|
||||
*
|
||||
*/
|
||||
extern lzma_vli lzma_info_size_get(
|
||||
const lzma_info *info, lzma_info_size type);
|
||||
|
||||
extern lzma_vli lzma_info_metadata_locate(
|
||||
const lzma_info *info, lzma_bool is_header_metadata);
|
||||
|
||||
/**
|
||||
* \brief Gets a pointer to the beginning of the Index list
|
||||
*
|
||||
* If detach is true, the Index will be detached from the lzma_info
|
||||
* structure, and thus not be modified or freed by lzma_info_end().
|
||||
*
|
||||
* If detach is false, the application must not modify the Index in any way.
|
||||
* Also, the Index list is guaranteed to be valid only till the next call
|
||||
* to any lzma_info_* function.
|
||||
*/
|
||||
extern lzma_index *lzma_info_index_get(lzma_info *info, lzma_bool detach);
|
||||
|
||||
|
||||
extern size_t lzma_info_index_count_get(const lzma_info *info);
|
||||
|
||||
|
||||
extern uint32_t lzma_info_metadata_alignment_get(
|
||||
const lzma_info *info, lzma_bool is_header_metadata);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Locate a Block containing the given uncompressed offset
|
||||
*
|
||||
* This function is useful when you need to do random-access reading in
|
||||
* a Multi-Block Stream.
|
||||
*
|
||||
* \param info Pointer to lzma_info that has at least one
|
||||
* Index Record. The Index doesn't need to be finished.
|
||||
* \param uncompressed_target
|
||||
* Uncompressed target offset which the caller would
|
||||
* like to locate from the Stream.
|
||||
* \param stream_offset
|
||||
* Starting offset (relative to the beginning the Stream)
|
||||
* of the Block containing the requested location.
|
||||
* \param uncompressed_offset
|
||||
* The actual uncompressed offset of the beginning of
|
||||
* the Block. uncompressed_offset <= uncompressed_target
|
||||
* is always true; the application needs to uncompress
|
||||
* uncompressed_target - uncompressed_offset bytes to
|
||||
* reach the requested target offset.
|
||||
* \param total_size
|
||||
* Total Size of the Block. If the Index is incomplete,
|
||||
* this may be LZMA_VLI_VALUE_UNKNOWN indicating unknown
|
||||
* size.
|
||||
* \param uncompressed_size
|
||||
* Uncompressed Size of the Block. If the Index is
|
||||
* incomplete, this may be LZMA_VLI_VALUE_UNKNOWN
|
||||
* indicating unknown size. The application must pass
|
||||
* this value to the Block decoder to verify FIXME
|
||||
*
|
||||
* \return
|
||||
*
|
||||
* \note This function is currently implemented as a linear search.
|
||||
* If there are many Index Records, this can be really slow.
|
||||
* This can be improved in newer liblzma versions if needed.
|
||||
*/
|
||||
extern lzma_bool lzma_info_data_locate(const lzma_info *info,
|
||||
lzma_vli uncompressed_target,
|
||||
lzma_vli *lzma_restrict stream_offset,
|
||||
lzma_vli *lzma_restrict uncompressed_offset,
|
||||
lzma_vli *lzma_restrict total_size,
|
||||
lzma_vli *lzma_restrict uncompressed_size);
|
||||
85
src/liblzma/api/lzma/init.h
Normal file
85
src/liblzma/api/lzma/init.h
Normal file
@ -0,0 +1,85 @@
|
||||
/**
|
||||
* \file lzma/init.h
|
||||
* \brief Initializations
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize all internal static variables
|
||||
*
|
||||
* Depending on the build options, liblzma may have some internal static
|
||||
* variables, that must be initialized before using any other part of
|
||||
* the library (*). It is recommended to do these initializations in the very
|
||||
* beginning of the application by calling appropriate initialization function.
|
||||
*
|
||||
* (*) There are some exceptions to this rule. FIXME
|
||||
*
|
||||
* The initialization functions are not necessarily thread-safe, thus the
|
||||
* required initializations must be done before creating any threads. (The
|
||||
* rest of the functions of liblzma are thread-safe.) Calling the
|
||||
* initialization functions multiple times does no harm, although it
|
||||
* still shouldn't be done when there are multiple threads running.
|
||||
*
|
||||
* lzma_init() initializes all internal static variables by calling
|
||||
* lzma_lzma_init_encoder() and lzma_init_decoder().
|
||||
*
|
||||
* If you need only encoder, decoder, or neither-encoder-nor-decoder
|
||||
* functions, you may use other initialization functions, which initialize
|
||||
* only a subset of liblzma's internal static variables. Using those
|
||||
* functions have the following advantages:
|
||||
* - When linking statically against liblzma, less useless functions will
|
||||
* get linked into the binary. E.g. if you need only the decoder functions,
|
||||
* using lzma_init_decoder() avoids linking bunch of encoder related code.
|
||||
* - There is less things to initialize, making the initialization
|
||||
* process slightly faster.
|
||||
*/
|
||||
extern void lzma_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize internal static variables needed by encoders
|
||||
*
|
||||
* If you need only the encoder functions, you may use this function to
|
||||
* initialize only the things required by encoders.
|
||||
*
|
||||
* This function also calls lzma_init_check().
|
||||
*/
|
||||
extern void lzma_init_encoder(void);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize internal static variables needed by decoders
|
||||
*
|
||||
* If you need only the decoder functions, you may use this function to
|
||||
* initialize only the things required by decoders.
|
||||
*
|
||||
* This function also calls lzma_init_check().
|
||||
*/
|
||||
extern void lzma_init_decoder(void);
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize internal static variables needed by integrity checks
|
||||
*
|
||||
* Currently this initializes CRC32 and CRC64 lookup tables if precalculated
|
||||
* tables haven't been built into the library. This function can be useful
|
||||
* if the only thing you need from liblzma is the integrity check functions.
|
||||
*/
|
||||
extern void lzma_init_check(void);
|
||||
312
src/liblzma/api/lzma/lzma.h
Normal file
312
src/liblzma/api/lzma/lzma.h
Normal file
@ -0,0 +1,312 @@
|
||||
/**
|
||||
* \file lzma/lzma.h
|
||||
* \brief LZMA filter
|
||||
*
|
||||
* \author Copyright (C) 1999-2006 Igor Pavlov
|
||||
* \author Copyright (C) 2007 Lasse Collin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Filter ID
|
||||
*
|
||||
* Filter ID of the LZMA filter. This is used as lzma_options_filter.id.
|
||||
*/
|
||||
#define LZMA_FILTER_LZMA LZMA_VLI_C(0x40)
|
||||
|
||||
|
||||
/**
|
||||
* \brief LZMA compression modes
|
||||
*
|
||||
* Currently there are only two modes. Earlier LZMA SDKs had also third
|
||||
* mode between fast and best.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_MODE_INVALID = -1,
|
||||
/**<
|
||||
* \brief Invalid mode
|
||||
*
|
||||
* Used as array terminator in lzma_available_modes.
|
||||
*/
|
||||
|
||||
|
||||
LZMA_MODE_FAST = 0,
|
||||
/**<
|
||||
* \brief Fast compression
|
||||
*
|
||||
* Fast mode is usually at its best when combined with
|
||||
* a hash chain match finder.
|
||||
*/
|
||||
|
||||
LZMA_MODE_BEST = 2
|
||||
/**<
|
||||
* \brief Best compression ratio
|
||||
*
|
||||
* This is usually notably slower than fast mode. Use this
|
||||
* together with binary tree match finders to expose the
|
||||
* full potential of the LZMA encoder.
|
||||
*/
|
||||
} lzma_mode;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Match finders
|
||||
*
|
||||
* Match finder has major effect on both speed and compression ratio.
|
||||
* Usually hash chains are faster than binary trees.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_MF_INVALID = -1,
|
||||
/**<
|
||||
* \brief Invalid match finder ID
|
||||
*
|
||||
* Used as array terminator in lzma_available_match_finders.
|
||||
*/
|
||||
|
||||
LZMA_MF_HC3 = 0x03,
|
||||
/**<
|
||||
* \brief Hash Chain with 3 bytes hashing
|
||||
*
|
||||
* \todo Memory requirements
|
||||
*
|
||||
* \note It's possible that this match finder gets
|
||||
* removed in future. The definition will stay
|
||||
* in this header, but liblzma may return
|
||||
* LZMA_HEADER_ERROR if it is specified (just
|
||||
* like it would if the match finder had been
|
||||
* disabled at compile time).
|
||||
*/
|
||||
|
||||
LZMA_MF_HC4 = 0x04,
|
||||
/**<
|
||||
* \brief Hash Chain with 4 bytes hashing
|
||||
*
|
||||
* Memory requirements: 7.5 * dictionary_size + 4 MiB
|
||||
*
|
||||
* \note It's possible that this match finder gets
|
||||
* removed in future. The definition will stay
|
||||
* in this header, but liblzma may return
|
||||
* LZMA_HEADER_ERROR if it is specified (just
|
||||
* like it would if the match finder had been
|
||||
* disabled at compile time).
|
||||
*/
|
||||
|
||||
LZMA_MF_BT2 = 0x12,
|
||||
/**<
|
||||
* \brief Binary Tree with 2 bytes hashing
|
||||
*
|
||||
* Memory requirements: 9.5 * dictionary_size + 4 MiB
|
||||
*/
|
||||
|
||||
LZMA_MF_BT3 = 0x13,
|
||||
/**<
|
||||
* \brief Binary Tree with 3 bytes hashing
|
||||
*
|
||||
* Memory requirements: 11.5 * dictionary_size + 4 MiB
|
||||
*/
|
||||
|
||||
LZMA_MF_BT4 = 0x14
|
||||
/**<
|
||||
* \brief Binary Tree with 4 bytes hashing
|
||||
*
|
||||
* Memory requirements: 11.5 * dictionary_size + 4 MiB
|
||||
*/
|
||||
} lzma_match_finder;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options specific to the LZMA method handler
|
||||
*/
|
||||
typedef struct {
|
||||
/**********************************
|
||||
* LZMA encoding/decoding options *
|
||||
**********************************/
|
||||
|
||||
/* These options are required in encoder and also with raw decoding. */
|
||||
|
||||
/**
|
||||
* \brief Dictionary size in bytes
|
||||
*
|
||||
* Dictionary size indicates how many bytes of the recently processed
|
||||
* uncompressed data is kept in memory. One method to reduce size of
|
||||
* the uncompressed data is to store distance-length pairs, which
|
||||
* indicate what data to repeat from the dictionary buffer. Thus,
|
||||
* the bigger the dictionary, the better compression ratio usually is.
|
||||
*
|
||||
* Raw decoding: Too big dictionary does no other harm than
|
||||
* wasting memory. This value is ignored by lzma_raw_decode_buffer(),
|
||||
* because it uses the target buffer as the dictionary.
|
||||
*/
|
||||
uint32_t dictionary_size;
|
||||
# define LZMA_DICTIONARY_SIZE_MIN 1
|
||||
# define LZMA_DICTIONARY_SIZE_MAX (UINT32_C(1) << 30)
|
||||
# define LZMA_DICTIONARY_SIZE_DEFAULT (UINT32_C(1) << 23)
|
||||
|
||||
/**
|
||||
* \brief Number of literal context bits
|
||||
*
|
||||
* How many of the highest bits of the previous uncompressed
|
||||
* eight-bit byte (also known as `literal') are taken into
|
||||
* account when predicting the bits of the next literal.
|
||||
*
|
||||
* \todo Example
|
||||
*/
|
||||
uint32_t literal_context_bits;
|
||||
# define LZMA_LITERAL_CONTEXT_BITS_MIN 0
|
||||
# define LZMA_LITERAL_CONTEXT_BITS_MAX 8
|
||||
# define LZMA_LITERAL_CONTEXT_BITS_DEFAULT 3
|
||||
|
||||
/**
|
||||
* \brief Number of literal position bits
|
||||
*
|
||||
* How many of the lowest bits of the current position (number
|
||||
* of bytes from the beginning of the uncompressed data) in the
|
||||
* uncompressed data is taken into account when predicting the
|
||||
* bits of the next literal (a single eight-bit byte).
|
||||
*
|
||||
* \todo Example
|
||||
*/
|
||||
uint32_t literal_pos_bits;
|
||||
| ||||