mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: WCX plugin for extract *.bz2 archives
This commit is contained in:
parent
e93248b814
commit
a1c8fa34b9
10 changed files with 1689 additions and 7 deletions
340
plugins/unbz2/COPYING
Normal file
340
plugins/unbz2/COPYING
Normal file
|
|
@ -0,0 +1,340 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
180
plugins/unbz2/bz2func.pas
Normal file
180
plugins/unbz2/bz2func.pas
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
{
|
||||
Double commander
|
||||
-------------------------------------------------------------------------
|
||||
WCX plugin for extract *.bz2 archives
|
||||
|
||||
|
||||
Copyright (C) 2007 Koblov Alexander (Alexx2000@mail.ru)
|
||||
|
||||
based on:
|
||||
pasbzip.pas from FPC sources
|
||||
|
||||
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
|
||||
in a file called COPYING along with this program; if not, write to
|
||||
the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
|
||||
02139, USA.
|
||||
}
|
||||
|
||||
|
||||
unit bz2func;
|
||||
|
||||
interface
|
||||
uses uWCXhead;
|
||||
|
||||
{Mandatory functions}
|
||||
function OpenArchive (var ArchiveData : tOpenArchiveData) : THandle;{$IFNDEF WIN32}cdecl{$ELSE}stdcall{$ENDIF};
|
||||
function ReadHeader (hArcData : THandle; var HeaderData : THeaderData) : Integer;{$IFNDEF WIN32}cdecl{$ELSE}stdcall{$ENDIF};
|
||||
function ProcessFile (hArcData : THandle; Operation : Integer; DestPath, DestName : PChar) : Integer;{$IFNDEF WIN32}cdecl{$ELSE}stdcall{$ENDIF};
|
||||
function CloseArchive (hArcData : THandle) : Integer;{$IFNDEF WIN32}cdecl{$ELSE}stdcall{$ENDIF};
|
||||
procedure SetChangeVolProc (hArcData : THandle; pChangeVolProc1 : PChangeVolProc);{$IFNDEF WIN32}cdecl{$ELSE}stdcall{$ENDIF};
|
||||
procedure SetProcessDataProc (hArcData : THandle; pProcessDataProc1 : PProcessDataProc);{$IFNDEF WIN32}cdecl{$ELSE}stdcall{$ENDIF};
|
||||
{Optional functions}
|
||||
|
||||
|
||||
implementation
|
||||
uses bzip2, SysUtils, objects;
|
||||
|
||||
var
|
||||
sArcName : String;
|
||||
Count : Integer = 0;
|
||||
|
||||
|
||||
function ExtractOnlyFileName(const FileName: string): string;
|
||||
var
|
||||
iDotIndex,
|
||||
I: longint;
|
||||
begin
|
||||
(* Find a dot index *)
|
||||
I := Length(FileName);
|
||||
while (I > 0) and not (FileName[I] in ['.', '/', '\', ':']) do Dec(I);
|
||||
if (I > 0) and (FileName[I] = '.') then
|
||||
iDotIndex := I
|
||||
else
|
||||
iDotIndex := MaxInt;
|
||||
(* Find file name index *)
|
||||
I := Length(FileName);
|
||||
while (I > 0) and not (FileName[I] in ['/', '\', ':']) do Dec(I);
|
||||
Result := Copy(FileName, I + 1, iDotIndex - I - 1);
|
||||
end;
|
||||
|
||||
|
||||
function OpenArchive (var ArchiveData : tOpenArchiveData) : THandle;
|
||||
begin
|
||||
if FileExists(ArchiveData.ArcName) then
|
||||
begin
|
||||
sArcName := ArchiveData.ArcName;
|
||||
Count := 0;
|
||||
Result := 1985;
|
||||
end
|
||||
else
|
||||
Result := E_EOPEN;
|
||||
end;
|
||||
|
||||
function ReadHeader (hArcData : THandle; var HeaderData : THeaderData) : Integer;
|
||||
var
|
||||
sr : TSearchRec;
|
||||
begin
|
||||
if Count > 0 then
|
||||
begin
|
||||
Result := E_END_ARCHIVE;
|
||||
exit;
|
||||
end;
|
||||
|
||||
with HeaderData do
|
||||
begin
|
||||
FindFirst(sArcName, faAnyFile, sr);
|
||||
FileName := ExtractOnlyFileName(sArcName);
|
||||
PackSize := sr.Size;
|
||||
UnpSize := 0; // we don't now real file size
|
||||
FileTime := sr.Time;
|
||||
FileAttr := sr.Attr;
|
||||
|
||||
end;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function ProcessFile (hArcData : THandle; Operation : Integer; DestPath, DestName : PChar) : Integer;
|
||||
var
|
||||
infile,outfile:Tbufstream;
|
||||
decoder:Tbzip2_decode_stream;
|
||||
a:array[1..4096] of byte;
|
||||
i,readsize:cardinal;
|
||||
sOutputFileName : String;
|
||||
begin
|
||||
|
||||
case Operation of
|
||||
PK_TEST:
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
|
||||
PK_EXTRACT:
|
||||
begin
|
||||
|
||||
sOutputFileName := DestPath;
|
||||
if sOutputFileName <> '' then
|
||||
sOutputFileName := sOutputFileName + ExtractOnlyFileName(sArcName)
|
||||
else
|
||||
sOutputFileName := DestName;
|
||||
|
||||
assign(output, DestPath + 'unbz2.log');
|
||||
rewrite(output);
|
||||
begin
|
||||
infile.init(sArcName,stopenread,4096);
|
||||
outfile.init(sOutputFileName,stcreate,4096);
|
||||
decoder.init(@infile);
|
||||
if decoder.status<>stok then
|
||||
writeln(output, 'Fout: ',decoder.status,' ',decoder.errorinfo);
|
||||
repeat
|
||||
readsize:=4096;
|
||||
decoder.read(a,readsize);
|
||||
dec(readsize,decoder.short);
|
||||
outfile.write(a,readsize);
|
||||
until decoder.status<>0;
|
||||
if decoder.status<>stok then
|
||||
writeln(output, 'Fout: ',decoder.status,' ',decoder.errorinfo);
|
||||
decoder.done;
|
||||
infile.done;
|
||||
outfile.done;
|
||||
end;
|
||||
close(output);
|
||||
end;
|
||||
|
||||
PK_SKIP:
|
||||
begin
|
||||
|
||||
end;
|
||||
end; {case}
|
||||
|
||||
Count := Count + 1;
|
||||
Result :=0;
|
||||
|
||||
|
||||
end;
|
||||
|
||||
function CloseArchive (hArcData : THandle) : Integer;
|
||||
begin
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
procedure SetChangeVolProc (hArcData : THandle; pChangeVolProc1 : PChangeVolProc);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure SetProcessDataProc (hArcData : THandle; pProcessDataProc1 : PProcessDataProc);
|
||||
begin
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
40
plugins/unbz2/bzip2/LICENSE
Normal file
40
plugins/unbz2/bzip2/LICENSE
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
This Pascal unit "bzip2.pas" is
|
||||
copyright (C) 2002 by Daniel Mantione
|
||||
|
||||
It is inspired by "bzip2" and associated library "libbzip2",
|
||||
copyright (C) 1996-2002 by Julian R Seward.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Daniel Mantione, Delft, the Netherlans
|
||||
daniel.mantione@freepascal.org
|
||||
Pascal bzip2 unit, version 0.0.1 of 10 October 2002
|
||||
733
plugins/unbz2/bzip2/bzip2.pas
Normal file
733
plugins/unbz2/bzip2/bzip2.pas
Normal file
|
|
@ -0,0 +1,733 @@
|
|||
unit bzip2;
|
||||
{****************************************************************************
|
||||
|
||||
BZIP2 decompression unit
|
||||
|
||||
Copyright (C) 2002 by Daniel Mantione
|
||||
|
||||
This unit provides a decompression stream to decode .bz2 files. It is
|
||||
inpired by Julian R. Seward's libbzip2 library and therefore you should
|
||||
send credits to him and bug reports to me :)
|
||||
|
||||
This code is licensed under the same terms as the original libbz2 library,
|
||||
which is decsribed in the file LICENSE. If you don't have this file, look
|
||||
at http://www.freepascal.org for this bzip2 unit, the LICENSE file will
|
||||
be included. In case of problems, contact the author.
|
||||
|
||||
E-mail addresses:
|
||||
|
||||
Daniel Mantione <daniel.mantione@freepascal.org>
|
||||
Julian R. Seward <jseward@acm.org>
|
||||
|
||||
Please do not contact Julian about this Pascal library, he didn't wrote it.
|
||||
|
||||
****************************************************************************}
|
||||
interface
|
||||
|
||||
uses objects;
|
||||
|
||||
const max_groups=6;
|
||||
max_alpha_size=258;
|
||||
max_code_len=23;
|
||||
group_size=50;
|
||||
iter_count=4;
|
||||
max_selectors=2+(900000 div group_size);
|
||||
|
||||
const mtfa_size=4096;
|
||||
mtfl_size=16;
|
||||
|
||||
type Tcardinal_array=array [0..899999] of cardinal;
|
||||
Pcardinal_array=^Tcardinal_array;
|
||||
|
||||
Pcardinal=^cardinal;
|
||||
Thuffarray=array[0..max_alpha_size] of cardinal;
|
||||
Phuffarray=^Thuffarray;
|
||||
|
||||
Tbzip2_decode_stream=object(Tstream)
|
||||
short:cardinal;
|
||||
readstream:Pstream;
|
||||
block_randomized:boolean;
|
||||
blocksize:byte;
|
||||
tt:Pcardinal_array;
|
||||
tt_count:cardinal;
|
||||
rle_run_left,rle_run_data:byte;
|
||||
nextrle:Pbyte;
|
||||
decode_available:cardinal;
|
||||
block_origin:cardinal;
|
||||
current_block:cardinal;
|
||||
read_data,bits_available:byte;
|
||||
inuse16:set of 0..15;
|
||||
inuse:set of 0..255;
|
||||
inuse_count:cardinal;
|
||||
seq_to_unseq:array[0..255] of byte;
|
||||
alphasize:cardinal;
|
||||
group_count,group_pos,gsel,gminlen:byte;
|
||||
group_no:cardinal;
|
||||
glimit,gperm,gbase:Phuffarray;
|
||||
selector_count:cardinal;
|
||||
selector,selector_mtf:array[0..max_selectors] of byte;
|
||||
len:array[0..max_groups,0..max_alpha_size] of byte;
|
||||
limit:array[0..max_groups,0..max_alpha_size] of cardinal;
|
||||
base:array[0..max_groups,0..max_alpha_size] of cardinal;
|
||||
perm:array[0..max_groups,0..max_alpha_size] of cardinal;
|
||||
minlens:array[0..max_groups] of byte;
|
||||
cftab:array[0..257] of cardinal;
|
||||
mtfbase:array[0..256 div mtfl_size-1] of cardinal;
|
||||
mtfa:array[0..mtfa_size-1] of byte;
|
||||
constructor init(Areadstream:Pstream);
|
||||
function get_bits(n:byte):byte;
|
||||
function get_boolean:boolean;
|
||||
function get_byte:byte;
|
||||
function get_cardinal24:cardinal;
|
||||
function get_cardinal:cardinal;
|
||||
procedure receive_mapping_table;
|
||||
procedure receive_selectors;
|
||||
procedure undo_mtf_values;
|
||||
procedure receive_coding_tables;
|
||||
procedure make_hufftab;
|
||||
procedure init_mtf;
|
||||
function get_mtf_value:cardinal;
|
||||
procedure move_mtf_block;
|
||||
procedure receive_mtf_values;
|
||||
procedure detransform;
|
||||
function decode_block:boolean;
|
||||
procedure read(var buf;count:sw_word);virtual;
|
||||
procedure new_block;
|
||||
procedure consume_rle;inline;
|
||||
procedure rle_read(bufptr:Pbyte;var count:sw_word);
|
||||
destructor done;virtual;
|
||||
end;
|
||||
|
||||
{A bzip2 stream starts with this:}
|
||||
const bzip2_stream_magic='BZh';
|
||||
|
||||
{Error codes for stream errorinfo.}
|
||||
const bzip2_bad_header_magic =1;
|
||||
bzip2_bad_block_magic =2;
|
||||
bzip2_endoffile =3;
|
||||
bzip2_data_error =4;
|
||||
|
||||
implementation
|
||||
|
||||
{$ifdef i386}
|
||||
{$i bzip2i386.inc}
|
||||
{$endif}
|
||||
|
||||
procedure hb_create_decode_tables(var limit,base,perm:array of cardinal;
|
||||
var length:array of byte;
|
||||
minlen,maxlen:byte;alphasize:cardinal);
|
||||
|
||||
var pp,i,j,vec:cardinal;
|
||||
|
||||
begin
|
||||
pp:=0;
|
||||
for i:=minlen to maxlen do
|
||||
for j:=0 to alphasize-1 do
|
||||
if length[j]=i then
|
||||
begin
|
||||
perm[pp]:=j;
|
||||
inc(pp);
|
||||
end;
|
||||
for i:=0 to max_code_len-1 do
|
||||
begin
|
||||
base[i]:=0;
|
||||
limit[i]:=0;
|
||||
end;
|
||||
for i:=0 to alphasize-1 do
|
||||
inc(base[length[i]+1]);
|
||||
for i:=1 to max_code_len-1 do
|
||||
inc(base[i],base[i-1]);
|
||||
vec:=0;
|
||||
for i:=minlen to maxlen do
|
||||
begin
|
||||
inc(vec,base[i+1]-base[i]);
|
||||
limit[i]:=vec-1;
|
||||
vec:=vec shl 1;
|
||||
end;
|
||||
for i:=minlen+1 to maxlen do
|
||||
base[i]:=((limit[i-1]+1) shl 1)-base[i];
|
||||
end;
|
||||
|
||||
{*****************************************************************************
|
||||
Tbzip2_decode_stream
|
||||
*****************************************************************************}
|
||||
|
||||
constructor Tbzip2_decode_stream.init(Areadstream:Pstream);
|
||||
|
||||
var magic:array[1..3] of char;
|
||||
c:char;
|
||||
|
||||
begin
|
||||
readstream:=Areadstream;
|
||||
{Read the magic.}
|
||||
readstream^.read(magic,sizeof(magic));
|
||||
if magic<>bzip2_stream_magic then
|
||||
begin
|
||||
error(stiniterror,bzip2_bad_header_magic);
|
||||
exit;
|
||||
end;
|
||||
{Read the block size and allocate the working array.}
|
||||
readstream^.read(c,1);
|
||||
blocksize:=byte(c)-byte('0');
|
||||
getmem(tt,blocksize*100000*sizeof(cardinal));
|
||||
decode_available:=high(decode_available);
|
||||
end;
|
||||
|
||||
function Tbzip2_decode_stream.get_bits(n:byte):byte;
|
||||
|
||||
var data:byte;
|
||||
|
||||
begin
|
||||
if n>bits_available then
|
||||
begin
|
||||
readstream^.read(data,1);
|
||||
get_bits:=(read_data shr (8-n)) or data shr (8-(n-bits_available));
|
||||
read_data:=data shl (n-bits_available);
|
||||
inc(bits_available,8);
|
||||
end
|
||||
else
|
||||
begin
|
||||
get_bits:=read_data shr (8-n);
|
||||
read_data:=read_data shl n;
|
||||
end;
|
||||
dec(bits_available,n);
|
||||
end;
|
||||
|
||||
function Tbzip2_decode_stream.get_boolean:boolean;
|
||||
|
||||
begin
|
||||
get_boolean:=boolean(get_bits(1));
|
||||
end;
|
||||
|
||||
function Tbzip2_decode_stream.get_byte:byte;
|
||||
|
||||
begin
|
||||
get_byte:=get_bits(8);
|
||||
end;
|
||||
|
||||
function Tbzip2_decode_stream.get_cardinal24:cardinal;
|
||||
|
||||
begin
|
||||
get_cardinal24:=get_bits(8) shl 16 or get_bits(8) shl 8 or get_bits(8);
|
||||
end;
|
||||
|
||||
|
||||
function Tbzip2_decode_stream.get_cardinal:cardinal;
|
||||
|
||||
begin
|
||||
get_cardinal:=get_bits(8) shl 24 or get_bits(8) shl 16 or get_bits(8) shl 8 or
|
||||
get_bits(8);
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.receive_mapping_table;
|
||||
|
||||
{Receive the mapping table. To save space, the inuse set is stored in pieces
|
||||
of 16 bits. First 16 bits are stored which pieces of 16 bits are used, then
|
||||
the pieces follow.}
|
||||
|
||||
var i,j:byte;
|
||||
|
||||
begin
|
||||
inuse16:=[];
|
||||
{Receive the first 16 bits which tell which pieces are stored.}
|
||||
for i:=0 to 15 do
|
||||
if get_boolean then
|
||||
include(inuse16,i);
|
||||
|
||||
{Receive the used pieces.}
|
||||
inuse:=[];
|
||||
inuse_count:=0;
|
||||
for i:=0 to 15 do
|
||||
if i in inuse16 then
|
||||
for j:=0 to 15 do
|
||||
if get_boolean then
|
||||
begin
|
||||
include(inuse,16*i+j);
|
||||
seq_to_unseq[inuse_count]:=16*i+j;
|
||||
inc(inuse_count);
|
||||
end;
|
||||
{ system.write('Mapping table: ');
|
||||
for i:=0 to 255 do
|
||||
if i in inuse then
|
||||
system.write(i,' ');
|
||||
writeln;}
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.receive_selectors;
|
||||
|
||||
{Receives the selectors.}
|
||||
|
||||
var i:cardinal;
|
||||
j:byte;
|
||||
|
||||
begin
|
||||
group_count:=get_bits(3);
|
||||
selector_count:=get_bits(8) shl 7 or get_bits(7);
|
||||
for i:=0 to selector_count-1 do
|
||||
begin
|
||||
j:=0;
|
||||
while get_boolean do
|
||||
begin
|
||||
inc(j);
|
||||
if j>5 then
|
||||
error(streaderror,bzip2_data_error);
|
||||
end;
|
||||
selector_mtf[i]:=j;
|
||||
end;
|
||||
{ system.write('Selector_mtf: ');
|
||||
for i:=0 to selector_count-1 do
|
||||
system.write(selector_mtf[i],' ');
|
||||
writeln;}
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.undo_mtf_values;
|
||||
|
||||
{Undo the MTF values for the selectors.}
|
||||
|
||||
var pos:array[0..max_groups] of byte;
|
||||
i:cardinal;
|
||||
v,tmp:byte;
|
||||
|
||||
begin
|
||||
for v:=0 to group_count-1 do
|
||||
pos[v]:=v;
|
||||
for i:=0 to selector_count-1 do
|
||||
begin
|
||||
v:=selector_mtf[i];
|
||||
tmp:=pos[v];
|
||||
while v<>0 do
|
||||
begin
|
||||
pos[v]:=pos[v-1];
|
||||
dec(v);
|
||||
end;
|
||||
pos[0]:=tmp;
|
||||
selector[i]:=tmp;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.receive_coding_tables;
|
||||
|
||||
var t,curr:byte;
|
||||
i:cardinal;
|
||||
|
||||
begin
|
||||
for t:=0 to group_count-1 do
|
||||
begin
|
||||
curr:=get_bits(5);
|
||||
for i:=0 to alphasize-1 do
|
||||
begin
|
||||
repeat
|
||||
if not(curr in [1..20]) then
|
||||
begin
|
||||
error(streaderror,bzip2_data_error);
|
||||
exit;
|
||||
end;
|
||||
if not get_boolean then
|
||||
break;
|
||||
if get_boolean then
|
||||
dec(curr)
|
||||
else
|
||||
inc(curr);
|
||||
until false;
|
||||
len[t,i]:=curr;
|
||||
end;
|
||||
end;
|
||||
{ writeln('Coding tables:');
|
||||
for t:=0 to group_count-1 do
|
||||
begin
|
||||
for i:=0 to alphasize-1 do
|
||||
system.write(len[t,i],' ');
|
||||
writeln;
|
||||
end;}
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.make_hufftab;
|
||||
|
||||
{Builds the Huffman tables.}
|
||||
|
||||
var i:cardinal;
|
||||
t,minlen,maxlen:byte;
|
||||
|
||||
begin
|
||||
for t:=0 to group_count-1 do
|
||||
begin
|
||||
minlen:=32;
|
||||
maxlen:=0;
|
||||
for i:=0 to alphasize-1 do
|
||||
begin
|
||||
if len[t,i]>maxlen then
|
||||
maxlen:=len[t,i];
|
||||
if len[t,i]<minlen then
|
||||
minlen:=len[t,i];
|
||||
end;
|
||||
hb_create_decode_tables(limit[t],base[t],perm[t],len[t],
|
||||
minlen,maxlen,alphasize);
|
||||
minlens[t]:=minlen;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.init_mtf;
|
||||
|
||||
var i,j:byte;
|
||||
k:cardinal;
|
||||
|
||||
begin
|
||||
k:=mtfa_size-1;
|
||||
for i:=256 div mtfl_size-1 downto 0 do
|
||||
begin
|
||||
for j:=mtfl_size-1 downto 0 do
|
||||
begin
|
||||
mtfa[k]:=i*mtfl_size+j;
|
||||
dec(k);
|
||||
end;
|
||||
mtfbase[i]:=k+1;
|
||||
end;
|
||||
end;
|
||||
|
||||
function Tbzip2_decode_stream.get_mtf_value:cardinal;
|
||||
|
||||
var zn:byte;
|
||||
zvec:cardinal;
|
||||
|
||||
begin
|
||||
if group_pos=0 then
|
||||
begin
|
||||
inc(group_no);
|
||||
group_pos:=group_size;
|
||||
gsel:=selector[group_no];
|
||||
gminlen:=minlens[gsel];
|
||||
glimit:=@limit[gsel];
|
||||
gperm:=@perm[gsel];
|
||||
gbase:=@base[gsel];
|
||||
end;
|
||||
dec(group_pos);
|
||||
zn:=gminlen;
|
||||
zvec:=get_bits(zn);
|
||||
while zvec>glimit^[zn] do
|
||||
begin
|
||||
inc(zn);
|
||||
zvec:=zvec shl 1 or byte(get_boolean);
|
||||
end;
|
||||
get_mtf_value:=gperm^[zvec-gbase^[zn]];
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.move_mtf_block;
|
||||
|
||||
var i:byte;
|
||||
j,k:cardinal;
|
||||
|
||||
begin
|
||||
k:=MTFA_SIZE;
|
||||
for i:=256 div MTFL_SIZE-1 downto 0 do
|
||||
begin
|
||||
j:=mtfbase[i];
|
||||
Pcardinal(@mtfa[k- 4])^:=Pcardinal(@mtfa[j+12])^;
|
||||
Pcardinal(@mtfa[k- 8])^:=Pcardinal(@mtfa[j+ 8])^;
|
||||
Pcardinal(@mtfa[k-12])^:=Pcardinal(@mtfa[j+ 4])^;
|
||||
dec(k,16);
|
||||
Pcardinal(@mtfa[k ])^:=Pcardinal(@mtfa[j ])^;
|
||||
mtfbase[i]:=k;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.receive_mtf_values;
|
||||
|
||||
const run_a=0;
|
||||
run_b=1;
|
||||
|
||||
var t,next_sym:cardinal;
|
||||
es:cardinal;
|
||||
n:byte;
|
||||
nn,i:cardinal;
|
||||
p,q:Pbyte;
|
||||
u,v:Pcardinal;
|
||||
lno,off:cardinal;
|
||||
|
||||
begin
|
||||
group_no:=high(group_no);
|
||||
group_pos:=0;
|
||||
t:=0;
|
||||
for i:=0 to 257 do
|
||||
cftab[i]:=0;
|
||||
init_mtf;
|
||||
next_sym:=get_mtf_value;
|
||||
while next_sym<>inuse_count+1 do
|
||||
begin
|
||||
{ writeln(t,' ',next_sym);
|
||||
if t=22296 then
|
||||
t:=t; }
|
||||
if next_sym<=run_b then
|
||||
begin
|
||||
es:=0;
|
||||
n:=0;
|
||||
repeat
|
||||
inc(es,(next_sym+1) shl n);
|
||||
inc(n);
|
||||
next_sym:=get_mtf_value;
|
||||
until next_sym>run_b;
|
||||
n:=seq_to_unseq[mtfa[mtfbase[0]]];
|
||||
inc(cftab[n],es);
|
||||
if t+es>100000*blocksize then
|
||||
begin
|
||||
error(streaderror,bzip2_data_error);
|
||||
exit;
|
||||
end;
|
||||
while es>0 do
|
||||
begin
|
||||
tt^[t]:=n;
|
||||
dec(es);
|
||||
inc(t);
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
nn:=next_sym-1;
|
||||
if nn<mtfl_size then
|
||||
begin
|
||||
{Avoid the costs of the general case.}
|
||||
p:=@mtfa[mtfbase[0]];
|
||||
q:=p+nn;
|
||||
n:=q^;
|
||||
repeat
|
||||
q^:=(q-1)^;
|
||||
dec(q);
|
||||
until q=p;
|
||||
q^:=n;
|
||||
end
|
||||
else
|
||||
begin
|
||||
{General case.}
|
||||
lno:=nn div MTFL_SIZE;
|
||||
off:=nn and (MTFL_SIZE-1);
|
||||
p:=@mtfa[mtfbase[lno]];
|
||||
q:=p+off;
|
||||
n:=q^;
|
||||
while(q<>p) do
|
||||
begin
|
||||
q^:=(q-1)^;
|
||||
dec(q);
|
||||
end;
|
||||
u:=@mtfbase;
|
||||
v:=u+lno;
|
||||
repeat
|
||||
mtfa[v^]:=mtfa[(v-1)^+MTFL_SIZE-1];
|
||||
dec(v);
|
||||
dec(v^);
|
||||
until v=u;
|
||||
mtfa[v^]:=n;
|
||||
if v^=0 then
|
||||
move_mtf_block;
|
||||
end;
|
||||
inc(cftab[seq_to_unseq[n]]);
|
||||
tt^[t]:=cardinal(seq_to_unseq[n]);
|
||||
inc(t);
|
||||
if t>100000*blocksize then
|
||||
begin
|
||||
error(streaderror,bzip2_data_error);
|
||||
exit;
|
||||
end;
|
||||
next_sym:=get_mtf_value;
|
||||
end;
|
||||
end;
|
||||
tt_count:=t;
|
||||
{Setup cftab to facilitate generation of T^(-1).}
|
||||
t:=0;
|
||||
for i:=0 to 256 do
|
||||
begin
|
||||
nn:=cftab[i];
|
||||
cftab[i]:=t;
|
||||
{ writeln(i,' ',t);}
|
||||
inc(t,nn);
|
||||
end;
|
||||
end;
|
||||
|
||||
{$ifndef HAVE_DETRANSFORM}
|
||||
|
||||
procedure Tbzip2_decode_stream.detransform;
|
||||
|
||||
var a:cardinal;
|
||||
p,q,r:Pcardinal;
|
||||
|
||||
begin
|
||||
a:=0;
|
||||
p:=@tt^[0];
|
||||
q:=p+tt_count;
|
||||
while p<>q do
|
||||
begin
|
||||
r:=@tt^[cftab[p^ and $ff]];
|
||||
inc(cftab[p^ and $ff]);
|
||||
r^:=r^ or a;
|
||||
inc(a,256);
|
||||
inc(p);
|
||||
end;
|
||||
end;
|
||||
|
||||
{$endif}
|
||||
|
||||
function Tbzip2_decode_stream.decode_block:boolean;
|
||||
|
||||
{Decode a new compressed block.}
|
||||
|
||||
var magic:array[1..6] of char;
|
||||
stored_blockcrc:cardinal;
|
||||
i:byte;
|
||||
|
||||
begin
|
||||
for i:=1 to 6 do
|
||||
magic[i]:=char(get_byte);
|
||||
if magic='1AY&SY' then
|
||||
begin
|
||||
inc(current_block);
|
||||
{ writeln('Block ',current_block,': Header ok');}
|
||||
stored_blockcrc:=get_cardinal;
|
||||
block_randomized:=get_boolean;
|
||||
block_origin:=get_cardinal24;
|
||||
|
||||
{Receive the mapping table.}
|
||||
receive_mapping_table;
|
||||
alphasize:=cardinal(inuse_count)+2;
|
||||
{ writeln('Mapping table ok.');}
|
||||
|
||||
{Receive the selectors.}
|
||||
receive_selectors;
|
||||
if status<>0 then
|
||||
exit;
|
||||
{ writeln('Selectors ok.');}
|
||||
{Undo the MTF values for the selectors.}
|
||||
undo_mtf_values;
|
||||
{ writeln('Undo mtf ok.');}
|
||||
{Receive the coding tables.}
|
||||
receive_coding_tables;
|
||||
if status<>0 then
|
||||
exit;
|
||||
{ writeln('Coding tables ok');}
|
||||
{Build the Huffman tables.}
|
||||
make_hufftab;
|
||||
{ writeln('Huffman ok.');}
|
||||
{Receive the MTF values.}
|
||||
receive_mtf_values;
|
||||
{ writeln('MTF OK');}
|
||||
{Undo the Burrows Wheeler transformation.}
|
||||
detransform;
|
||||
{ writeln('Detransform OK');}
|
||||
decode_available:=tt_count;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if magic<>#$17'rE8P'#$90 then
|
||||
error(streaderror,bzip2_bad_block_magic);
|
||||
decode_block:=false;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.new_block;
|
||||
|
||||
begin
|
||||
if decode_block then
|
||||
nextrle:=@tt^[tt^[block_origin] shr 8]
|
||||
else
|
||||
begin
|
||||
error(streaderror,bzip2_endoffile);
|
||||
nextrle:=nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.consume_rle;inline;
|
||||
|
||||
{Make nextrle point to the next decoded byte. If nextrle did point to the last
|
||||
byte in the current block, decode the next block.}
|
||||
|
||||
begin
|
||||
{ Pcardinal(nextrle)^:=Pcardinal(nextrle)^ shr 8;}
|
||||
nextrle:=@tt^[Pcardinal(nextrle)^ shr 8];
|
||||
dec(decode_available);
|
||||
if decode_available=0 then
|
||||
new_block;
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.rle_read(bufptr:Pbyte;var count:sw_word);
|
||||
|
||||
var rle_len:cardinal;
|
||||
data:byte;
|
||||
|
||||
label rle_write;
|
||||
|
||||
begin
|
||||
rle_len:=rle_run_left;
|
||||
data:=rle_run_data;
|
||||
if block_randomized then
|
||||
{Not yet implemented.}
|
||||
runerror(212)
|
||||
else
|
||||
begin
|
||||
if rle_len<>0 then
|
||||
{Speed is important. Instead of an if statement within the
|
||||
repeat loop use a goto outside the loop.}
|
||||
goto rle_write;
|
||||
repeat
|
||||
if decode_available=0 then
|
||||
break;
|
||||
rle_len:=1;
|
||||
data:=nextrle^;
|
||||
consume_rle;
|
||||
if (decode_available>0) and (data=nextrle^) then
|
||||
begin
|
||||
inc(rle_len);
|
||||
consume_rle;
|
||||
if (decode_available>0) and (data=nextrle^) then
|
||||
begin
|
||||
inc(rle_len);
|
||||
consume_rle;
|
||||
if (decode_available>0) and (data=nextrle^) then
|
||||
begin
|
||||
consume_rle;
|
||||
inc(rle_len,nextrle^+1);
|
||||
consume_rle;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
rle_write:
|
||||
repeat
|
||||
bufptr^:=data;
|
||||
inc(bufptr);
|
||||
dec(count);
|
||||
dec(rle_len);
|
||||
until (rle_len=0) or (count=0);
|
||||
until count=0;
|
||||
short:=count;
|
||||
end;
|
||||
rle_run_data:=data;
|
||||
rle_run_left:=rle_len;
|
||||
end;
|
||||
|
||||
procedure Tbzip2_decode_stream.read(var buf;count:sw_word);
|
||||
|
||||
var bufptr:Pbyte;
|
||||
|
||||
begin
|
||||
short:=0;
|
||||
bufptr:=@buf;
|
||||
if decode_available=high(decode_available) then
|
||||
begin
|
||||
{Initialize the rle process:
|
||||
- Decode a block
|
||||
- Initialize pointer.}
|
||||
if not decode_block then
|
||||
begin
|
||||
error(streaderror,bzip2_endoffile);
|
||||
nextrle:=nil;
|
||||
end;
|
||||
nextrle:=@tt^[tt^[block_origin] shr 8];
|
||||
end;
|
||||
rle_read(bufptr,count);
|
||||
end;
|
||||
|
||||
destructor Tbzip2_decode_stream.done;
|
||||
|
||||
begin
|
||||
if tt<>nil then
|
||||
freemem(tt,blocksize*100000*sizeof(cardinal));
|
||||
inherited done;
|
||||
end;
|
||||
|
||||
end.
|
||||
56
plugins/unbz2/bzip2/bzip2i386.inc
Normal file
56
plugins/unbz2/bzip2/bzip2i386.inc
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
{$ASMMODE intel}
|
||||
|
||||
{$define HAVE_DETRANSFORM}
|
||||
{
|
||||
procedure Tbzip2_decode_stream.detransform;
|
||||
|
||||
var a:cardinal;
|
||||
p,q,r:Pcardinal;
|
||||
|
||||
begin
|
||||
a:=0;
|
||||
p:=@tt^[0];
|
||||
q:=p+tt_count;
|
||||
while p<>q do
|
||||
begin
|
||||
r:=@tt^[cftab[p^ and $ff]];
|
||||
inc(cftab[p^ and $ff]);
|
||||
r^:=r^ or a;
|
||||
inc(a,256);
|
||||
inc(p);
|
||||
end;
|
||||
end;
|
||||
}
|
||||
|
||||
{const c:cardinal=0;
|
||||
|
||||
procedure mcount;external name 'mcount';}
|
||||
|
||||
|
||||
procedure Tbzip2_decode_stream.detransform;assembler;
|
||||
|
||||
asm
|
||||
{ mov edx,offset c
|
||||
call mcount}
|
||||
xor edx,edx
|
||||
lea ebx,[esi+Tbzip2_decode_stream.cftab]
|
||||
mov ecx,[esi+Tbzip2_decode_stream.tt_count]
|
||||
push esi
|
||||
push ebp
|
||||
mov esi,[esi+Tbzip2_decode_stream.tt]
|
||||
mov edi,esi
|
||||
lea ebp,[4*ecx+esi]
|
||||
jmp @a2
|
||||
@a1:
|
||||
movzx eax,byte [esi]
|
||||
mov ecx,[ebx+4*eax]
|
||||
inc dword [ebx+4*eax]
|
||||
or [edi+4*ecx],edx
|
||||
add edx,$100
|
||||
add esi,4
|
||||
@a2:
|
||||
cmp esi,ebp
|
||||
jne @a1
|
||||
pop ebp
|
||||
pop esi
|
||||
end ['eax','ebx','ecx','edx','edi'];
|
||||
35
plugins/unbz2/bzip2/pasbzip.pas
Normal file
35
plugins/unbz2/bzip2/pasbzip.pas
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
program pasbzip;
|
||||
|
||||
uses objects,bzip2;
|
||||
|
||||
var infile,outfile:Tbufstream;
|
||||
decoder:Tbzip2_decode_stream;
|
||||
a:array[1..4096] of byte;
|
||||
i,readsize:cardinal;
|
||||
|
||||
begin
|
||||
assign(output,'pasbzip.out');
|
||||
rewrite(output);
|
||||
if paramcount<>1 then
|
||||
writeln('Usage: pasbunzip <file>')
|
||||
else
|
||||
begin
|
||||
infile.init(paramstr(1),stopenread,4096);
|
||||
outfile.init('OUTFILE',stcreate,4096);
|
||||
decoder.init(@infile);
|
||||
if decoder.status<>stok then
|
||||
writeln('Fout: ',decoder.status,' ',decoder.errorinfo);
|
||||
repeat
|
||||
readsize:=4096;
|
||||
decoder.read(a,readsize);
|
||||
dec(readsize,decoder.short);
|
||||
outfile.write(a,readsize);
|
||||
until decoder.status<>0;
|
||||
if decoder.status<>stok then
|
||||
writeln('Fout: ',decoder.status,' ',decoder.errorinfo);
|
||||
decoder.done;
|
||||
infile.done;
|
||||
outfile.done;
|
||||
end;
|
||||
close(output);
|
||||
end.
|
||||
26
plugins/unbz2/unbz2.dpr
Normal file
26
plugins/unbz2/unbz2.dpr
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
library unbz2;
|
||||
|
||||
|
||||
|
||||
uses
|
||||
bz2func in 'bz2func.pas';
|
||||
|
||||
{$E wcx}
|
||||
|
||||
{$R *.res}
|
||||
exports
|
||||
{mandatory}
|
||||
OpenArchive,
|
||||
ReadHeader,
|
||||
ProcessFile,
|
||||
CloseArchive,
|
||||
SetChangeVolProc,
|
||||
SetProcessDataProc;
|
||||
{optional}
|
||||
|
||||
|
||||
begin
|
||||
{$IFNDEF WIN32}
|
||||
WriteLN('unbz2 plugin is loaded');
|
||||
{$ENDIF}
|
||||
end.
|
||||
277
plugins/unbz2/unbz2.lpi
Normal file
277
plugins/unbz2/unbz2.lpi
Normal file
|
|
@ -0,0 +1,277 @@
|
|||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="5"/>
|
||||
<General>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<ActiveEditorIndexAtStart Value="1"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<Units Count="13">
|
||||
<Unit0>
|
||||
<Filename Value="unbz2.dpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<CursorPos X="44" Y="12"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<UnitName Value="bz2func"/>
|
||||
<CursorPos X="39" Y="122"/>
|
||||
<TopLine Value="105"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="wcxhead.pas"/>
|
||||
<UnitName Value="wcxhead"/>
|
||||
<CursorPos X="47" Y="71"/>
|
||||
<TopLine Value="60"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\..\..\..\..\Prog\lazarus\fpcsrc\rtl\inc\systemh.inc"/>
|
||||
<CursorPos X="3" Y="349"/>
|
||||
<TopLine Value="329"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\..\..\..\..\Prog\lazarus\fpcsrc\rtl\inc\objects.pp"/>
|
||||
<UnitName Value="Objects"/>
|
||||
<CursorPos X="10" Y="273"/>
|
||||
<TopLine Value="257"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="..\..\..\..\..\Prog\lazarus\fpcsrc\rtl\objpas\sysutils\finah.inc"/>
|
||||
<CursorPos X="1" Y="30"/>
|
||||
<TopLine Value="13"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="..\..\..\..\..\Prog\lazarus\fpcsrc\rtl\objpas\sysutils\fina.inc"/>
|
||||
<CursorPos X="1" Y="89"/>
|
||||
<TopLine Value="69"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="..\..\..\..\..\Prog\lazarus\fpcsrc\rtl\inc\fexpand.inc"/>
|
||||
<CursorPos X="10" Y="84"/>
|
||||
<TopLine Value="553"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="..\..\..\..\..\Prog\lazarus\fpcsrc\rtl\objpas\sysutils\syspchh.inc"/>
|
||||
<CursorPos X="10" Y="45"/>
|
||||
<TopLine Value="18"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="..\..\..\..\..\Prog\lazarus\fpcsrc\rtl\win32\wininc\func.inc"/>
|
||||
<CursorPos X="10" Y="184"/>
|
||||
<TopLine Value="168"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="..\..\..\..\..\Prog\lazarus\fpcsrc\rtl\win32\sysutils.pp"/>
|
||||
<UnitName Value="sysutils"/>
|
||||
<CursorPos X="17" Y="254"/>
|
||||
<TopLine Value="249"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="..\..\..\..\..\Prog\lazarus\fpcsrc\rtl\objpas\sysutils\filutilh.inc"/>
|
||||
<CursorPos X="19" Y="86"/>
|
||||
<TopLine Value="69"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="bzip2\bzip2.pas"/>
|
||||
<UnitName Value="bzip2"/>
|
||||
<CursorPos X="7" Y="46"/>
|
||||
<TopLine Value="30"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit12>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="102" Column="10" TopLine="86"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="114" Column="19" TopLine="98"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="115" Column="38" TopLine="99"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="117" Column="33" TopLine="101"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="118" Column="17" TopLine="102"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="unbz2.dpr"/>
|
||||
<Caret Line="20" Column="20" TopLine="1"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="122" Column="17" TopLine="106"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="119" Column="48" TopLine="105"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="147" Column="6" TopLine="131"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="unbz2.dpr"/>
|
||||
<Caret Line="28" Column="1" TopLine="1"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="57" Column="41" TopLine="35"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="117" Column="54" TopLine="101"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="unbz2.dpr"/>
|
||||
<Caret Line="19" Column="45" TopLine="1"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="103" Column="8" TopLine="94"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="106" Column="14" TopLine="86"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="102" Column="45" TopLine="86"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="141" Column="65" TopLine="122"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="107" Column="10" TopLine="91"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="47" Column="18" TopLine="27"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="107" Column="1" TopLine="95"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="114" Column="25" TopLine="94"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="110" Column="32" TopLine="94"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="unbz2.dpr"/>
|
||||
<Caret Line="15" Column="50" TopLine="1"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="147" Column="67" TopLine="122"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="135" Column="48" TopLine="121"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="109" Column="15" TopLine="105"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="unbz2.dpr"/>
|
||||
<Caret Line="7" Column="3" TopLine="1"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="unbz2.dpr"/>
|
||||
<Caret Line="6" Column="3" TopLine="1"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="unbz2.dpr"/>
|
||||
<Caret Line="18" Column="26" TopLine="1"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="bz2func.pas"/>
|
||||
<Caret Line="121" Column="49" TopLine="103"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<OtherUnitFiles Value="bzip2\;..\..\"/>
|
||||
<UnitOutputDirectory Value="bin"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<DelphiCompat Value="True"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Generate Value="Faster"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Options>
|
||||
<ExecutableType Value="Library"/>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<BreakPoints Count="2">
|
||||
<Item1>
|
||||
<Source Value="..\..\mnt\X\linux\lazarus\lcl\include\imglist.inc"/>
|
||||
<Line Value="435"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Source Value="..\..\ucopythread.pas"/>
|
||||
<Line Value="42"/>
|
||||
</Item2>
|
||||
</BreakPoints>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
BIN
plugins/unbz2/unbz2.res
Normal file
BIN
plugins/unbz2/unbz2.res
Normal file
Binary file not shown.
|
|
@ -36,7 +36,7 @@
|
|||
<Unit1>
|
||||
<Filename Value="wcxhead.pas"/>
|
||||
<UnitName Value="wcxhead"/>
|
||||
<CursorPos X="22" Y="5"/>
|
||||
<CursorPos X="21" Y="8"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="10"/>
|
||||
|
|
@ -59,12 +59,7 @@
|
|||
<UsageCount Value="10"/>
|
||||
</Unit3>
|
||||
</Units>
|
||||
<JumpHistory Count="1" HistoryIndex="0">
|
||||
<Position1>
|
||||
<Filename Value="Zip.dpr"/>
|
||||
<Caret Line="29" Column="8" TopLine="14"/>
|
||||
</Position1>
|
||||
</JumpHistory>
|
||||
<JumpHistory Count="0" HistoryIndex="-1"/>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue