(****************************************** |******************************************
 *      RAR, dekompresni komponenta       * |*      RAR, decompression component      *
 *                pro Delphi 3 (32b)      * |*                for Delphi 3 (32b)      *
 *                 (c) 1997 BEALsoft      * |*                 (c) 1997 BEALsoft      *
 *                       v1.0             * |*                       v1.0             *
 *________________________________________* |*________________________________________*
 *    !! TATO KOMPONENTA JE ZDARMA !!     * |*     !! THIS COMPONENT IS FREE !!       *
 ****************************************** |******************************************)
// Kontakt na autora // Contact to author :
// aberka@usa.net, ICQ UIN 2365308, http://jakub.naf.cz/~aberka
// BEALsoft BBS, +420-5-<MOMENTALNE NENI / NONE AT THE MOMENT>, 24h

// ** Nove telefonni cislo bude umisteno na me webovske stranky **
// ** New phone number will be placen on my web pages **

{Pro chod teto komponenty je treba UNRAR.DLL (WinRAR 2.0>). Umistete jej do
  aktualniho adresare nebo do WINDOWS\SYSTEM}
{To run this component you need UNRAR.DLL (WinRAR 2.0>) in actual or in WINDOWS\SYSTEM
  directory}

  Zname problemy s UNRAR.DLL - vytvoreni jiz existujiciho adresare zpusoby chybu erECreate
  Known UNRAR.DLL bugs - creating an existing directory will result erECreate

   Varovani : Kdyz nastane udalost OnReqPassword a vratite-li v PASSWORD
                prazdny retezec, pouzije se minule heslo.
   Warnings : When OnReqPassword occurs, blank PASSWORD string means old password
                will be used

// Diky Jorge Rojas Matovi ! To byl on, kdo napsal interface a ukazku k Cckovemu
    UNRAR.DLL. To bylo presne to co jsem potreboval k napsani teto komponenty
// Thanx to Jorge Rojas Mata ! He rewrote DLL interface from C to Pascal and
// wrote example. This was what I needed to understand UNRAR library.

P.S. RAR je nejlepsi ! RAR is the BEST !

Doporucuji stahnout si z internetu WinRAR 2.0>
I recommend you to download WinRAR 2.0> from the net.

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Nasledujici dokumentace je JEN v anglictine, protoze predpokladam u programatoru
znalost anglictiny.

It is recommended to read the source code, its comments and UNRARDLL.TXT.

METHODS:
=======

procedure ListArchive;
---------------------
  This method will list all files in archive. See On

function ExtractArchive : Boolean;
-----------------------
  This function will extract all files (FilesToExtract is empty) or files written in
  FilesToExtract

  Result - True  - Everything went OK
         - False - Some errors occured

function TestArchive : Boolean; {False - archive corrupted, True - archive is ok}
--------------------
  This function will test all files (FilesToTest is empty) or files written in
  FilesToTest

  Result - True  - Files are OK
         - False - Some files are corrupted

Function GetErrorString(Error : Integer) : String;
-----------------------
  Use this function to get text message for specific error
  It is recommended to use this function in OnError event :

    procedure TForm1.RARError(Sender: TObject; Error: Integer);
    begin
      MessageDlg(RAR.GetErrorString(Error),mtError,[mbOk],0);
    end;

Function GetErrorStringCZ(Error : Integer) : String;
-------------------------
  This function is equal to GetErrorString
  This is in Czech Language

PROPERTIES:
==========

ArchiveName (String)
-----------
  You should specify archive filename here


FilesToExtract (TStringList)
--------------
  You can choose which files are to be extracted

FilesToTest (TStringList)
-----------
  You can choose which files are to be tested

TargetDir (String)
---------
  This property contains the directory, which are the files extracted to.

Stop (Boolean)
----
  Choose true to stop current operation (it will turn automaticaly false after
  stopping)


EVENTS:
======

  TChangeVolProcN     = function (Sender: TObject; ArcName : PChar; Mode : Integer) : Integer of object;
  TProcessDataProcN   = function (Sender: TObject; Addr : PChar; BlockSize, Position : Integer) : Integer of object;

  TErrorProc          = procedure (Sender: TObject; Error : Integer) of object;
  TCommentProc        = procedure (Sender: TObject; Comment : TComment) of object;
  TListFileProc       = procedure (Sender: TObject; ListedFile : RARHeaderData) of object;
  TFileBeingExtracted = procedure (Sender: TObject; eFile : RARHeaderData) of object;
  TFileExtracted      = procedure (Sender: TObject; eFile : RARHeaderData; Result : Boolean) of object;
  TFileBeingTested    = procedure (Sender: TObject; eFile : RARHeaderData) of object;
  TFileTested         = procedure (Sender: TObject; eFile : RARHeaderData; Result : Boolean) of object;
  TReqPassword        = procedure (Sender: TObject; eFile : RARHeaderData; var Password : String) of object;

OnProcessData, function (Sender: TObject; Addr : PChar; BlockSize, Position : Integer) : Integer
-------------
  OnProcessData occurs when next data portion is unpacked.

  Addr - Pointer to Zero-char terminated array of unpacked data
  BlockSize - Size of unpacked data
  Position - Number of unpacked bytes in current file

  Result - 0        - Stop extraction
         - Non-Zero - Continue extraction


OnVolumeChange, function (Sender: TObject; ArcName : PChar; Mode : Integer) : Integer
--------------
  onVolumeChange occurs when next volume is going to be processed

  ArcName - Volume FileName
  Mode    - moVolNotify - Next volume found, notifying user
          - moVolAsk    - Next volume not found, asking user for inserting correct disk

  Soon, you will be able to change ArcName to change next Volume Name

OnError, procedure (Sender: TObject; Error : Integer)
-------
  OnError occurs when error is detected while opening, listing, extracting or
    testing archive.

  Error - Error code

  See GetErrorString and GetErrorStringCZ

OnComment, procedure (Sender: TObject; Comment : TComment)
---------
  OnError occurs when archive comment is present while opening archive

  Comment - structure of archive comment:

    TComment = record
                 Size : Integer; {Size of comment}
                 Data : Array[1..rMaxCommentSize] of Char; {Comment}
               end; {rMaxCommentSize is default set to 64kB}

OnListFile, procedure (Sender: TObject; ListedFile : RARHeaderData)
----------
  OnListFile occurs when file found in archive during ListArchive;

  ListedFile - structure of archive header:

      RARHeaderData = record
                    ArcName              : array[1..260] of char; {Archive filename}
                    FileName             : array[1..260] of char; {FileName}
                    Flags                : Cardinal; {Flags}
                    PackSize             : Cardinal; {Packed size}
                    UnpSize              : Cardinal; {UnPacked size}
                    HostOS               : Cardinal; {Operating system -
                                                                0 - MS DOS;
                                                                1 - OS/2.
                                                                2 - Win32
                                                                3 - Unix}
                    FileCRC              : Cardinal; {CRC of file}
                    FileTime             : Cardinal; {Date&Time}
                    UnpVer               : Cardinal; {RAR version req. to extract}
                    Method               : Cardinal; {Packing method}
                    FileAttr             : Cardinal; {File attributes}
                    CmtBuf               : PChar; {This should point to the comment buffer}
                    CmtBufSize,            {Size of comment buffer}
                    CmtSize,               {Size of read comment}
                    CmtState            : Cardinal; {State:

                                 0                     Absent comments
                                 1                     Comments read completely
                                 ERAR_NO_MEMORY        Not enough memory to extract comments
                                 ERAR_BAD_DATA         Broken comment
                                 ERAR_UNKNOWN_FORMAT   Unknown comment format
                                 ERAR_SMALL_BUF        Buffer too small, comments not completely read}

  ** FLAGS **
  ^^^^^^^^^^^
  01 - file continued from previous volume
    // if (ListedFile.Flags and 01)=01 then ....
  02 - file continued on next volume
  04 - file encrypted with password
  08 - file comment present
  16 - compression of previous files is used (solid flag)

  bits 7 6 5

       0 0 0    - dictionary size   64 Kb
       0 0 1    - dictionary size  128 Kb
       0 1 0    - dictionary size  256 Kb
       0 1 1    - dictionary size  512 Kb
       1 0 0    - dictionary size 1024 Kb
       1 0 1    - reserved
       1 1 0    - reserved
       1 1 1    - file is directory

  Other bits are reserved.

OnExtracting, procedure (Sender: TObject; eFile : RARHeaderData)
------------
  OnExtracting occurs when file eFile is going to be extracted

OnExtract, procedure (Sender: TObject; eFile : RARHeaderData; Result : Boolean)
---------
  OnExtracting occurs when file eFile was extracted

OnTesting, procedure (Sender: TObject; eFile : RARHeaderData)
---------
  OnTesting occurs when file eFile is going to be tested

OnTested, procedure (Sender: TObject; eFile : RARHeaderData; Result : Boolean)
--------
  OnTesting occurs when file eFile was tested

OnReqPassword, procedure (Sender: TObject; eFile : RARHeaderData; var Password : String) of object;
-------------
  OnReqPassword occurs when password-protected file is extracting. You should
  return password in Password string.
  Returning of empty Password string means use of last password.
