home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 28
/
amigaformatcd28.iso
/
-seriously_amiga-
/
archivers
/
xpk
/
xpk_source
/
e
/
none
/
none.e
< prev
Wrap
Text File
|
1998-04-27
|
5KB
|
248 lines
/*
**
** xpkNONE.library
**
** This is just an exaple how to create an xpk-library, the library
** itself are useless.
**
*/
OPT PREPROCESS
MODULE '*none_xpkrev'
MODULE 'xpk/xpk', 'xpk/xpksub'
/***************************** CONSTANTS ********************************/
#define LIB_AUTHOR 'Torgil Svensson'
CONST MASTER_VERSION = 0 -> required xpkmaster version
/*------------------- xpk library setup --------------------*/
CONST LIB_FLAGS = XPKIF_PK_CHUNK OR -> chunk packing
XPKIF_UP_CHUNK -> chunk unpacking
CONST DEF_MODE = 100 -> default mode number
/*-------------------- memory / buffers --------------------*/
CONST MAX_IN_CHUNK = $7ffffff, -> max chunk size
MIN_IN_CHUNK = 1, -> min chunk size
DEF_IN_CHUNK = 100000 -> default packing chunk size
/*------------------- strings / messages -------------------*/
-> (max 20 chars)
#define LIB_SHORT_NAME LIB_NAME + ' V' + LIB_VERSION + '.' + LIB_REVISION
-> (max 30 chars)
#define LIB_LONG_NAME LIB_FULL_NAME + ' V' + LIB_VERSION + '.' + LIB_REVISION
-> (max 70 chars)
#define LIB_DESC 'This library really does no compression '+\
'by ' + LIB_AUTHOR
#define PACK_MSG 'compressing'
#define UNPACK_MSG 'decompressing'
#define PACKED_MSG 'compressed'
#define UNPACKED_MSG 'decompressed'
/********************** EC LIBRARY HEADER *****************************/
LIBRARY LIB_FULL_NAME,VERSION,REVISION,LIB_VERSTR IS
xpksPackerInfo, -> Get information about a packer sub-library for use
xpksPackChunk, -> Pack a chunk of data
xpksPackFree, -> Free buffers associated with packing process
xpksPackReset, -> Reset all internal tables
xpksUnpackChunk, -> Uncompress a chunk of data
xpksUnpackFree -> Free all private data the sublib has allocated
/*********************** GLOBAL VARIABLES *****************************/
DEF mode1:xpkMode
DEF info:xpkInfo
/**************************** main() **********************************/
PROC main()
/*-------------------- mode descriptors --------------------*/
-> user selectable through the 1-100 scale in xpk
-> This is a node in a linked list of modes
-> Packspeed tested with A500/000 on a 460Kb file
mode1.next := NIL -> next mode (NIL if last mode)
mode1.upto := 100 -> Maximum efficiency
mode1.flags := 0 -> Flags
mode1.packMemory := 0 -> Extra Memory, packing
mode1.unpackMemory := 0 -> Extra Memory, unpacking
mode1.packSpeed := 170 -> Pack speed * 1000 bytes
mode1.unpackSpeed := 170 -> Unpack speed * 1000 bytes
mode1.ratio := 0 -> Ratio * 0.1%
mode1.chunkSize := 100 -> Desired Cunk size in kb
AstrCopy(mode1.description,'useless',10)
/*-------------------- xpkInfo structure -------------------*/
info.xpkInfoVersion := INFO_VERSION
info.libVersion := VERSION
info.masterVersion := MASTER_VERSION
info.modesVersion := MODES_VERSION
info.name := LIB_SHORT_NAME
info.longName := LIB_LONG_NAME
info.description := LIB_DESC
info.id := LIB_ID
info.flags := LIB_FLAGS
info.maxPkInChunk := MAX_IN_CHUNK
info.minPkInChunk := MIN_IN_CHUNK
info.defPkInChunk := DEF_IN_CHUNK
info.packMsg := PACK_MSG
info.unpackMsg := UNPACK_MSG
info.packedMsg := PACKED_MSG
info.unpackedMsg := UNPACKED_MSG
info.defMode := DEF_MODE
info.pad := 0 -> future use
info.modeDesc := mode1 -> list of modes (first mode)
info.reserved[0] := 0
info.reserved[1] := 0
info.reserved[2] := 0
info.reserved[3] := 0
info.reserved[4] := 0
info.reserved[5] := 0
ENDPROC
/*********************** xpksPackerInfo() *****************************/
PROC xpksPackerInfo()
ENDPROC info
/*********************** xpksPackChunk() ******************************/
PROC xpksPackChunk(param:PTR TO xpkSubParams, dummy)
DEF length=0, -> number of bytes to copy
err=0 -> return value
length := param.inLen
-> enough space in outbuf?
IF param.outBufLen < length
err := XPKERR_SMALLBUF
param.outLen := 0
ELSE
CopyMem(param.inBuf,param.outBuf,length)
param.outLen := length
ENDIF
ENDPROC err
/************************ xpksPackFree() ******************************/
PROC xpksPackFree(param:PTR TO xpkSubParams, dummy)
ENDPROC 0
/*********************** xpksPackReset() ******************************/
PROC xpksPackReset(param:PTR TO xpkSubParams, dummy)
ENDPROC 0
/*********************** xpksUnpackChunk() ****************************/
PROC xpksUnpackChunk(param:PTR TO xpkSubParams, dummy)
DEF length=0, -> number of bytes to copy
err=0 -> return value
length := param.inLen
-> enough space in outbuf?
IF param.outBufLen < length
err := XPKERR_SMALLBUF
param.outLen := 0
ELSE
CopyMem(param.inBuf,param.outBuf,length)
param.outLen := length
ENDIF
ENDPROC err
/*********************** xpksUnpackFree() *****************************/
PROC xpksUnpackFree(param:PTR TO xpkSubParams, dummy)
ENDPROC 0