home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / util / pplib-1.6.lha / PPlib / Glue / Oberon / PowerPacker.mod < prev   
Text File  |  1993-12-21  |  5KB  |  131 lines

  1. (* ------------------------------------------------------------------------
  2.   :Program.       PowerPacker
  3.   :Contents.      Interface to Nico François' powerpacker.library
  4.   :Author.        Kai Bolay [kai] (C-Version by Nico François)
  5.   :Address.       Hoffmannstraße 168
  6.   :Address.       D-7250 Leonberg 1 (Germany)
  7.   :Address.       UUCP: ...!cbmvax!cbmehq!cbmger!depot1!amokle!kai
  8.   :Address.       FIDO: 2:247/706.3
  9.   :History.       v1.0 [kai] long ago  (translated from C)
  10.   :History.       v1.3 Nico  some time (updated)
  11.   :History.       v1.3 [kai] 22-Nov-91 (bug fixes)
  12.   :History.       v1.3a [kai] 24-Nov-91 (fixed missing exports)
  13.   :History.       v1.3b [kai] 07-Dec-91 (little bugfixes)
  14.   :History.       v1.4 Nico 28-Sep-93 (added ppCrunchBufferDest())
  15.   :Copyright.     Freeware
  16.   :Language.      Oberon
  17.   :Translator.    AMIGA OBERON v2.12e, A+L AG
  18.   :Remark.        Thanks to Nico for his great library
  19. ------------------------------------------------------------------------ *)
  20.  
  21. MODULE PowerPacker;
  22.  
  23. (*
  24. **      Filename: libraries/PowerPacker.mod
  25. **      Release: 1.3
  26. **
  27. **      (C) Copyright 1991 Nico François
  28. **          All Rights Reserved
  29. **
  30. *)
  31.  
  32. IMPORT
  33.    e: Exec, I: Intuition, d: Dos;
  34. CONST
  35.    PPName* = "powerpacker.library";
  36.    PPVersion* = 35;
  37.    (* decrunch colors for LoadData and DecrunchBuffer *)
  38.    DecrCol0*  = 0;
  39.    DecrCol1*  = 1;
  40.    DecrPoint* = 2;
  41.    DecrScrol* = 3;
  42.    DecrNone*  = 4;
  43.    (* error codes returned by LoadData *)
  44.    LoadOk*    =  0;
  45.    OpenErr*   = -1;
  46.    ReadErr*   = -2;
  47.    NoMemory*  = -3;
  48.    Crypted*   = -4;
  49.    PassErr*   = -5;
  50.    UnknownPP* = -6;
  51.    (* size of speedup buffer *)
  52.    SpeedupBuffLarge*  = 0;
  53.    SpeedupBuffMedium* = 1;
  54.    SpeedupBuffSmall*  = 2;
  55.    (* crunching efficiency *)
  56.    CrunFast*     = 0;
  57.    CrunMediocre* = 1;
  58.    CrunGood*     = 2;
  59.    CrunVeryGood* = 3;
  60.    CrunBest*     = 4;
  61.    (* possible return values from ppCrunchBuffer() and ppCrunchBufferDest() *)
  62.    CrunchAborted*  =  0;
  63.    BufferOverflow* = -1;
  64. TYPE
  65.    PPBase* = STRUCT (libNode* : e.Library);
  66.                 flags* : SHORTSET;
  67.                 pad* : SHORTINT;
  68.                 segList* : e.BPTR;
  69.              END; (* STRUCT *)
  70.    PPBasePtr* = UNTRACED POINTER TO PPBase;
  71.    (** These two function must preserve all Registers an may not deallocate
  72.        their parameters. Stack checking is not allowed! This means:
  73.        "DeallocPars-" and "SaveAllRegs+" and "StackChk-!! **)
  74.    PassFunc* = PROCEDURE (checksum: LONGINT; password: e.ADDRESS): BOOLEAN;
  75.    PercFunc* = PROCEDURE (userdata: e.ADDRESS; totlen: LONGINT;
  76.                           crunlen: LONGINT; lensofar: LONGINT): BOOLEAN;
  77. VAR
  78.    pp* : PPBasePtr;
  79.  
  80. PROCEDURE LoadData* {pp, -30} (    filename{8}: ARRAY OF CHAR;
  81.                                    col{0}: LONGINT;
  82.                                    memtype{1}: LONGSET;
  83.                                VAR buffer{9}: e.ADDRESS;
  84.                                VAR len{10}: LONGINT;
  85.                                    func{11}: PassFunc): LONGINT;
  86. PROCEDURE DecrunchBuffer* {pp, -36} (endcrun{8},
  87.                                      decrbuf{9},
  88.                                      effptr{10}: e.ADDRESS;
  89.                                      col{0}: LONGINT);
  90. PROCEDURE CalcCheckSum* {pp, -42} (string{8}: ARRAY OF CHAR): INTEGER;
  91. PROCEDURE CalcPasskey* {pp, -48} (password{8}: ARRAY OF CHAR): LONGINT;
  92. PROCEDURE Decrypt* {pp, -54} (buffer{8}: e.ADDRESS;
  93.                               len{0}, key{1}: LONGINT);
  94. PROCEDURE GetPassword* {pp, -60} (screen{8}: I.ScreenPtr;
  95.                                   buffer{9}: e.ADDRESS;
  96.                                   maxchars{0}: LONGINT;
  97.                                   checksum{1}: INTEGER): BOOLEAN;
  98. PROCEDURE AllocCrunchInfo* {pp, -96} (eff{0}: LONGINT;
  99.                                       speedup{1}: LONGINT;
  100.                                       func{8}: PercFunc;
  101.                                       userdata{9}: e.ADDRESS): e.ADDRESS;
  102. PROCEDURE FreeCrunchInfo* {pp, -102} (crunchinfo{8}: e.ADDRESS);
  103. PROCEDURE CrunchBuffer* {pp, -108} (crunchinfo{8}: e.ADDRESS;
  104.                                     buffer{9}: e.ADDRESS;
  105.                                     len{0}: LONGINT): LONGINT;
  106. PROCEDURE WriteDataHeader* {pp, -114} (handle{0}: d.FileHandlePtr;
  107.                                        eff{1}: LONGINT;
  108.                                        crypt{2}: BOOLEAN;
  109.                                        checksum{3}: LONGINT): BOOLEAN;
  110. PROCEDURE EnterPassword* {pp, -120} (screen{8}: I.ScreenPtr;
  111.                                      buffer{9}: e.ADDRESS): BOOLEAN;
  112. PROCEDURE ErrorMessage* {pp, -132} (error{0}: LONGINT): e.STRPTR;
  113. PROCEDURE CrunchBufferDest* {pp, -138} (crunchinfo{8}: e.ADDRESS;
  114.                                         buffer{9}: e.ADDRESS;
  115.                                         dest{10}: e.ADDRESS;
  116.                                         len{0}: LONGINT): LONGINT;
  117.  
  118. BEGIN
  119.    pp := e.OpenLibrary (PPName, PPVersion);
  120.    IF pp = NIL THEN
  121.       IF I.DisplayAlert (I.recoveryAlert,
  122.            "\x00\x64\x14missing powerpacker.library V35\o\o", 50) THEN END;
  123.       HALT (20)
  124.    END; (* IF *)
  125. CLOSE
  126.    IF pp # NIL THEN
  127.       e.CloseLibrary (pp);
  128.       pp := NIL;
  129.    END; (* IF *)
  130. END PowerPacker.
  131.