	IFND	LIBRARIES_XFDMASTER_I
LIBRARIES_XFDMASTER_I	SET	1

**
**	$VER: xfdmaster.i 34.1 (17.9.94)
**
**	Copyright © 1994 by Georg Hörmann
**	All Rights Reserved
**

	IFND EXEC_LIBRARIES_I
	include "exec/libraries.i"
	ENDC

;======================================================================
; Library Base
;======================================================================

    STRUCTURE	xfdMasterBase,LIB_SIZE
	ULONG	xfdm_SegList		; PRIVATE
	APTR	xfdm_DosBase
	APTR	xfdm_FirstSlave
	APTR	xfdm_FirstForeman	; PRIVATE
	LABEL	xfdMasterBase_SIZE

XFDM_VERSION	EQU	34	;for OpenLibrary()

XFDM_NAME	MACRO
		dc.b	"xfdmaster.library",0
		ENDM

;======================================================================
; Buffer Info
;======================================================================

    STRUCTURE	xfdBufferInfo,0
	APTR	xfdbi_SourceBuffer	; pointer to source buffer
	ULONG	xfdbi_SourceBufLen	; length of source buffer
	APTR	xfdbi_Slave		; PRIVATE
	APTR	xfdbi_PackerName	; name of recognized packer
	UWORD	xfdbi_PackerFlags	; flags for recognized packer
	LABEL	xfdbi_MaxSpecialLen	; max. length of special info (eg. password)
	UWORD	xfdbi_Error		; error return code
	APTR	xfdbi_TargetBuffer	; pointer to target buffer
	ULONG	xfdbi_TargetBufMemType	; memtype of target buffer
	ULONG	xfdbi_TargetBufLen	; full length of buffer
	ULONG	xfdbi_TargetBufSaveLen	; used length of buffer
	ULONG	xfdbi_DecrAddress	; address to load decrunched file
	ULONG	xfdbi_JmpAddress	; address to jump in file
	APTR	xfdbi_Special		; special decrunch info (eg. password)
	LABEL	xfdBufferInfo_SIZE

;======================================================================
; Segment Info
;======================================================================

    STRUCTURE	xfdSegmentInfo,0
	ULONG	xfdsi_SegList		; value received by LoadSeg()
	APTR	xfdsi_Slave		; PRIVATE
	APTR	xfdsi_PackerName	; name of recognized packer
	UWORD	xfdsi_PackerFlags	; flags for recognized packer
	LABEL	xfdsi_MaxSpecialLen	; max. length of special info (eg. password)
	UWORD	xfdsi_Error		; error return code
	APTR	xfdsi_Special		; special decrunch info (eg. password)
	UWORD	xfdsi_RelMode		; (V34) relocation mode
	UWORD	xfdsi_Reserved0		; (V34) reserved
	LABEL	xfdSegmentInfo_SIZE

;======================================================================
; Error Codes
;======================================================================

XFDERR_OK		EQU	$0000	; no error

XFDERR_NOMEMORY		EQU	$0001	; error allocating memory
XFDERR_NOSLAVE		EQU	$0002	; no slave entry in info structure
XFDERR_NOTSUPPORTED	EQU	$0003	; slave doesn't support called function
XFDERR_UNKNOWN		EQU	$0004	; unknown file
XFDERR_NOSOURCE		EQU	$0005	; no sourcebuffer/seglist specified
XFDERR_WRONGPASSWORD	EQU	$0006	; wrong password for decrunching
XFDERR_BADHUNK		EQU	$0007	; bad hunk structure
XFDERR_CORRUPTEDDATA	EQU	$0008	; crunched data is corrupted
XFDERR_MISSINGRESOURCE	EQU	$0009	; (V34) missing external resource (eg. libs)

XFDERR_UNDEFINEDHUNK	EQU	$1000	; (V34) undefined hunk type
XFDERR_NOHUNKHEADER	EQU	$1001	; (V34) file is not executable
XFDERR_BADEXTTYPE	EQU	$1002	; (V34) bad hunk_ext type
XFDERR_BUFFERTRUNCATED	EQU	$1003	; (V34) unexpected end of file
XFDERR_WRONGHUNKAMOUNT	EQU	$1004	; (V34) wrong amount of hunks

XFDERR_UNSUPPORTEDHUNK	EQU	$2000	; (V34) hunk type not supported
XFDERR_BADRELMODE	EQU	$2001	; (V34) unknown XFDREL_#? mode

;======================================================================
; Relocation modes (V34)
;======================================================================

XFDREL_DEFAULT		EQU	$0000	; use memory types given by hunk_header
XFDREL_FORCECHIP	EQU	$0001	; force all hunks to chip ram
XFDREL_FORCEFAST	EQU	$0002	; force all hunks to fast ram

;======================================================================
; Values for xfd??_PackerFlags
;======================================================================

	BITDEF	XFDPF,RELOC,0		; relocatible file packer
	BITDEF	XFDPF,ADDR,1		; absolute address file packer
	BITDEF	XFDPF,DATA,2		; data file packer

	BITDEF	XFDPF,PASSWORD,4	; packer requires password
	BITDEF	XFDPF,RELMODE,5		; (V34) decruncher supports xfdsi_RelMode

;======================================================================
; Foreman
;======================================================================

    STRUCTURE	xfdForeman,0
	STRUCT	xfdf_Security,4		; moveq #-1,d0 : rts
	STRUCT	xfdf_ID,4		; set to XFDF_ID
	UWORD	xfdf_Version		; set to XFDF_VERSION
	UWORD	xfdf_Reserved		; not used by now, set to NULL
	ULONG	xfdf_Next		; PRIVATE
	ULONG	xfdf_SegList		; PRIVATE
	APTR	xfdf_FirstSlave		; first slave (see below)
	LABEL	xfdForeman_SIZE

XFDF_ID		EQU	(("X"<<24)!("F"<<16)!("D"<<8)!("F"))
XFDF_VERSION	EQU	1

;======================================================================
; Slave
;======================================================================

    STRUCTURE	xfdSlave,0
	APTR	xfds_Next		; next slave (or NULL)
	UWORD	xfds_Version		; set to XFDS_VERSION
	UWORD	xfds_MasterVersion	; minimum XFDM_VERSION required
	APTR	xfds_PackerName		; NULL-terminated name of packer
	UWORD	xfds_PackerFlags	; flags for packer
	UWORD	xfds_MaxSpecialLen	; max. length of special info (eg. password)
	FPTR	xfds_RecogBuffer	; buffer recognition code (or NULL)
	FPTR	xfds_DecrunchBuffer	; buffer decrunch code (or NULL)
	FPTR	xfds_RecogSegment	; segment recognition code (or NULL)
	FPTR	xfds_DecrunchSegment	; segment decrunch code (or NULL)
	LABEL	xfdSlave_SIZE

XFDS_VERSION	EQU	1


	ENDC	; LIBRARIES_XFDMASTER_I
