(************************************************************************* :Program. XpkMasterD.def :Contents. Interface-Module for xpkmaster.library :Author. Oliver Knorr :Remark. Derived from Hartmut Goebel's Oberon Interface :Copyright. Copyright © 1992 by Oliver Knorr :Copyright. May be freely distributed with the Xpk-Package :Copyright. permission is given to be included with M2Amiga :Language. Modula-2 :Translator. M2Amiga V4.0 :History. V1.0, 29 Jul 1992 Oliver Knorr :History V2.0, 30 Jul 1992 Oliver Knorr :Date. 29 Jul 1992 01:41:25 *************************************************************************) DEFINITION MODULE XpkMasterD; (*$ Implementation:=FALSE *) FROM UtilityD IMPORT tagUser ; FROM SYSTEM IMPORT ADDRESS, BYTE, LONGSET ; CONST xpkName = "xpkmaster.library"; TYPE StrPtr = POINTER TO ARRAY [0..255] OF CHAR; (***************************************************************************** * * * The packing/unpacking tags * *) (* Tags we support *) TYPE XpkTags=(xpkTagBase:=tagUser + ORD("X")*256 + ORD("P"), (* Caller must supply ONE of these to tell Xpk#?ackFile where to get data from *) xpkInName, (* an entire named file *) xpkInFH, (* File handle - start from current position *) (* If packing partial file, must also supply InLen *) xpkInBuf, (* Single unblocked memory buffer *) (* Must also supply InLen *) xpkInHook, (* Call custom Hook to read data *) (* If packing, must also supply InLen *) (* If unpacking, InLen required only for PPDecrunch *) (* TagBase+5 through TagBase+15 are reserved *) xpk05, xpk06, xpk07, xpk08, xpk09, xpk10, xpk11, xpk12, xpk13, xpk14, xpk15, (* Caller must supply ONE of these to tell Xpk#?ackFile where to send data to *) xpkOutName, (* Write (or overwrite) this data file *) xpkOutFH, (* File handle - write from current position on *) xpkOutBuf, (* Unblocked buffer - must also supply OutBufLen *) xpkGetOutBuf, (* Master allocates OutBuf - ti_Data points to buf ptr *) xpkOutHook, (* Callback Hook to get output buffers *) (* TagBase+21 through TagBase+31 are reserved *) xpk21, xpk22, xpk23, xpk24, xpk25, xpk26, xpk27, xpk28, xpk29, xpk30, xpk31, (* Other tags for Pack/Unpack *) xpkInLen, (* Length of data in input buffer *) xpkOutBufLen, (* Length of output buffer *) xpkGetOutLen, (* ti_Data points to long to receive OutLen *) xpkGetOutBufLen, (* ti_Data points to long to receive OutBufLen *) xpkPassword, (* Password for de/encoding *) xpkGetError, (* ti_Data points to buffer for error message *) xpkOutMemType, (* Memory type for output buffer *) xpkPassThru, (* Bool: Pass through unrecognized formats on unpack *) xpkStepDown, (* Bool: Step down pack method if necessary *) xpkChunkHook, (* Call this Hook between chunks *) xpkPackMethod, (* Do a FindMethod before packing *) xpkChunkSize, (* Chunk size to try to pack with *) xpkPackMode, (* Packing mode for sublib to use *) xpkNoClobber, (* Don't overwrite existing files *) xpkIgnore, (* Skip this tag *) xpkTaskPri, (* Change priority for (un)packing *) xpkFileName, (* File name for progress report *) xpkShortError, (* Output short error messages *) xpkPackerQuery, (* Query properties of a packer *) xpkModeQuery (* Query properties of packmode *) ); CONST xpkFindMethod=xpkPackMethod; (* Compatibility *) (***************************************************************************** * * * The hook function interface * *) TYPE (* The values for XpkIOMsg.type *) XpkIOMsgType = (xiomt0, ioRead, ioWrite, ioFree, ioAbort, ioGetBuf, ioSeek, ioTotSize) ; (* Message passed to InHook and OutHook as the ParamPacket *) XpkIOMsgPtr = POINTER TO XpkIOMsg; XpkIOMsg = RECORD type : LONGINT; (* Read/Write/Alloc/Free/Abort *) ptr : ADDRESS; (* The mem area to read from/write to *) size : LONGINT; (* The size of the read/write *) ioError : LONGINT; (* The IoErr() that occurred *) reserved : ADDRESS; (* Reserved for future use *) private1 : ADDRESS; (* Hook specific, will be set to 0 by *) private2 : ADDRESS; (* master library before first use *) private3 : ADDRESS; private4 : ADDRESS; END; (***************************************************************************** * * * The progress report interface * *) TYPE (* The values for XpkProgress.type *) XpkProgressType = (xpt0, progStart, progMid, progEnd) ; (* Passed to ChunkHook as the ParamPacket *) XpkProgressPtr = POINTER TO XpkProgress; XpkProgress = RECORD type : LONGINT; (* Type of report: start/cont/end/abort *) packerName : StrPtr; (* Brief name of packer being used *) packerLongName : StrPtr; (* Descriptive name of packer being used *) activity : StrPtr; (* Packing/unpacking message *) fileName : StrPtr; (* Name of file being processed, if available *) cCur : LONGINT; (* Amount of packed data already processed *) uCur : LONGINT; (* Amount of unpacked data already processed *) uLen : LONGINT; (* Amount of unpacked data already processed *) cf : LONGINT; (* Compression factor so far *) done : LONGINT; (* Percentage done already *) speed : LONGINT; (* Bytes per second, from beginning of stream *) reserved : ARRAY [0..7] OF ADDRESS; (* For future use *) END; (***************************************************************************** * * * The file info block * *) TYPE (* Defines for XpkFib.type *) XpkFibType = (unpacked, packed, archive) ; (* Defines for XpkFib.flags *) XpkFibFlags = (password, seek, nonStd, xff3, xff4, xff5, xff6, xff7, xff8, xff9, xff10, xff11, xff12, xff13, xff14, xff15, xff16, xff17, xff18, xff19, xff20, xff21, xff22, xff23, xff24, xff25, xff26, xff27, xff28, xff29, xff30, xff31) ; XpkFibFlagSet = SET OF XpkFibFlags ; XpkFibPtr = POINTER TO XpkFib; XpkFib = RECORD type : LONGINT ; (* Unpacked, packed, archive? *) uLen : LONGINT ; (* Uncompressed length *) cLen : LONGINT ; (* Compressed length *) nLen : LONGINT ; (* Next chunk len *) uCur : LONGINT ; (* Uncompressed bytes so far *) cCur : LONGINT ; (* Compressed bytes so far *) id : ARRAY [0..3] OF BYTE ; (* 4 letter ID of packer *) packer : ARRAY [0..5] OF BYTE ; (* 4 letter name of packer *) subVersion : INTEGER ; (* Required sublib version   *) masVersion : INTEGER ; (* Required masterlib version *) flags : XpkFibFlagSet ; (* Password? *) head : ARRAY [0..15] OF BYTE ; (* First 16 bytes of orig. file *) ratio : LONGINT ; (* Compression ratio *) reserved : ARRAY [0..7] OF ADDRESS; (* For future use *) END; XpkFH = POINTER TO RECORD fib: XpkFib (* private data follows *) END; (***************************************************************************** * * * The error messages * *) CONST errOk = 0; errNoFunc = -1; (* This function not implemented *) errNoFiles = -2; (* No files allowed for this function *) errIOErrIn = -3; (* Input error happened, look at Result2 *) errIOErrOut = -4; (* Output error happened,look at Result2 *) errCheckSum = -5; (* Check sum test failed *) errVersion = -6; (* Packed file's version newer than lib *) errNoMem = -7; (* Out of memory *) errLibInUse = -8; (* For not-reentrant libraries *) errWrongForm = -9; (* Was not packed with this library *) errSmallBuf = -10; (* Output buffer too small *) errLargeBuf = -11; (* Input buffer too large *) errWrongMode = -12; (* This packing mode not supported *) errNeedPasswd = -13; (* Password needed for decoding *) errCorruptPkd = -14; (* Packed file is corrupt *) errMissingLib = -15; (* Required library is missing *) errBadParams = -16; (* Caller's TagList was screwed up *) errExpansion = -17; (* Would have caused data expansion *) errNoMethod = -18; (* Can't find requested method *) errAborted = -19; (* Operation aborted by user *) errTruncated = -20; (* Input file is truncated *) errWrongCPU = -21; (* Better CPU required for this library *) errPacked = -22; (* Data are already XPacked *) errNotPacked = -23; (* Data not packed *) errFileExists = -24; (* File already exists *) errOldMastLib = -25; (* Master library too old *) errOldSubLib = -26; (* Sub library too old *) errNoCrypt = -27; (* Cannot encrypt *) errNoInfo = -28; (* Can't get info in that packer *) errMsgSize = 80; (* Maximum size of an error message *) (***************************************************************************** * * * The XpkQuery() call * *) TYPE XpkInfoFlags = (pkChunk, (* Library supplies chunk packing *) pkStream, (* Library supplies stream packing *) pkArchive, (* Library supplies archive packing *) upChunk, (* Library supplies chunk unpacking *) upStream, (* Library supplies stream unpacking *) upArchive, (* Library supplies archive unpacking *) xpif6, hookio, (* Uses full Hook I/O *) xpif8, xpif9, checking, (* Does its own data checking *) prereadhdr, (* Unpacker pre-reads the next chunkhdr *) xpif12, encryption, (* Sub library supports encryption *) needPasswd, (* Sub library requires encryption *) modes, (* Sub library has different modes *) lossy, (* Sub library does lossy compression *) xpif17, xpif18, xpif19, xpif20, xpif21, xpif22, xpif23, xpif24, xpif25, xpif26, xpif27, xpif28, xpif29, xpif30, xpif31) ; XpkInfoFlagSet = SET OF XpkInfoFlags ; XpkPackerInfoPtr = POINTER TO XpkPackerInfo; XpkPackerInfo = RECORD name : ARRAY [0..23] OF CHAR; (* Brief name of the packer *) longName : ARRAY [0..31] OF CHAR; (* Full name of the packer *) description : ARRAY [0..79] OF CHAR; (* One line description of packer *) flags : XpkInfoFlagSet; (* Defined above *) maxChunk : LONGINT; (* Max input chunk size for packing *) defChunk : LONGINT; (* Default packing chunk size *) defMode : INTEGER; (* Default mode on 0..100 scale *) END; XpkModeFlags = (a3000Speed, (* Timings on A3000/25 *) pkNoCPU, (* Packing not heavily CPU dependent *) upNoCPU, (* Unpacking... (i.e. hardware modes) *) xmf3, xmf4, xmf5, xmf6, xmf7, xmf8, xmf9, xmf10, xmf11, xmf12, xmf13, xmf14, xmf15, xmf16, xmf17, xmf18, xmf19, xmf20, xmf21, xmf22, xmf23, xmf24, xmf25, xmf26, xmf27, xmf28, xmf29, xmf30, xmf31) ; XpkModeFlagSet = SET OF XpkModeFlags ; XpkModePtr = POINTER TO XpkMode; XpkMode = RECORD next : XpkModePtr; (* Chain to next descriptor for ModeDesc list*) upto : LONGINT; (* Maximum efficiency handled by this mode *) flags : XpkModeFlagSet; (* Defined above *) packMemory : LONGINT; (* Extra memory required during packing *) unpackMemory : LONGINT; (* Extra memory during unpacking *) packSpeed : LONGINT; (* Approx packing speed in K per second *) unpackSpeed : LONGINT; (* Approx unpacking speed in K per second *) ratio : INTEGER; (* CF in 0.1% for AmigaVision executable *) reserved : INTEGER; description : ARRAY [0..7] OF CHAR; (* 8 character mode description *) END; (***************************************************************************** * * * The XpkOpen() type calls * *) CONST lenOneChunk = 7FFFFFFFH; END XpkMasterD.noimp