	IFND LIBRARIES_PATCH_I
LIBRARIES_PATCH_I SET 1
**
**	Filename:	libraries/patch.i
**	Release:	3.0
**	Date:		04.05.94
**
**	(C) Copyright 1993/94 Stefan Fuchs
**	All rights reserved
**
**      definition of patch.library public structures, returncodes and macros


	IFND EXEC_TYPES_I
	include "exec/types.i"
	ENDC

	IFND EXEC_LISTS_I
	include "exec/lists.i"
	ENDC

	IFND EXEC_LIBRARIES_I
	include "exec/libraries.i"
	ENDC

	IFND EXEC_SEMAPHORES_I
	include "exec/semaphores.i"
	ENDC

;-------------------------------------------------------------------------
;Structure required to install new patches via patch.library/InstallPatch()

 STRUCTURE NewPatch,0			;this structure is OBSOLETE from V2 on
	APTR	NPAT_NewCode		;pointer to the patch code to be installed
	ULONG	NPAT_NewCodeSize	;optional length of NPAT_NewCode in bytes
	APTR	NPAT_LibraryName	;pointer to the LibraryName
	UWORD	NPAT_LibVersion		;version of Library to open
	WORD	NPAT_LVO		;LVO of function to patch
	WORD	NPAT_Priority		;Priority (-127...+126) of the patch
	UWORD	NPAT_Flags		;currently none defined (keep zero)
	APTR	NPAT_PatchName		;optional pointer to an IDString
	LONG	NPAT_Result2		;optional pointer to longword for Result2

 LABEL NPAT_SIZEOF

;-------------------------------------------------------------------------
;ErrorCodes:
PATERR_Ok		equ	0	;Everything Ok
PATERR_PatchInUse	equ	1	;Patch Usecount <> 0
PATERR_InvalidHandle	equ	2	;Pointer to patch is not (no longer) valid
PATERR_OutOfMem		equ	3	;Out of memory
PATERR_OpenLib		equ	4	;Failed to open requested library
PATERR_FuncNotStd	equ	5	;Function to patch is not in the standard format
PATERR_PatchInstalled	equ	6	;Can't remove patch because another program has
					;installed a non-patch.library patch later
PATERR_InvalidTags	equ	7	;There was an error in the combination of the specified Tags
PATERR_OpenDev		equ	8	;Failed to open requested device
PATERR_NoTaskList	equ	9	;PATT_AddTask... or PATT_RemTask... was specified for a patch,
					;which had no PATT_CreateTaskList set
PATERR_TaskListExists	equ    10	;PATT_CreateTaskList was specified, but there already exists a TaskList
PATERR_InvalidTaskList	equ    11	;PATT_CreateTaskList was specified with a wrong parameter

;-------------------------------------------------------------------------
PATCHNAME	MACRO
	dc.b "patch.library",0
	ENDM

;---------------------------------------------------------------
;--- FALLBACK - Call this macro instead of a 'rts' instruction
;--- in your patchcode, if you want to return to the original
;--- library code
;---------------------------------------------------------------
FALLBACK	MACRO
	move.l (sp),-(sp)
	clr.l 4(sp)
	rts

	ENDM

;----------------------------------------------------------------------------
;----------------------------------------------------------------------------
;The following structures are not needed by normal patch.library applications
;----------------------------------------------------------------------------
;----------------------------------------------------------------------------
	STRUCTURE PatchBase,LIB_SIZE
	UBYTE PB_Flags				;no public flags defined
	UBYTE PB_reserved1
	ULONG PB_private1

	STRUCT	PB_Semaphore,SS_SIZE		;Semaphore to protect MasterPatchList
	STRUCT	PB_MasterPatchHeader,LH_SIZE	;Listheader structure for MasterPatch structures

	;...

;-------------------------------------------------------------------------
; Before accessing this structure, make sure MPS_TYPE is PS_TYPE_MASTER

 STRUCTURE MasterPatch,0	;This structure is READONLY
	APTR	MPS_SUCC	;Pointer to next (successor)
	APTR	MPS_PRED	;Pointer to previous (predecessor)
	UBYTE	MPS_TYPE	;MUST be PS_TYPE_MASTER
	BYTE	MPS_PRI		;Priority, for sorting
	APTR	MPS_NAME	;may contain a pointer to the name of the patched library
	UWORD	MPS_Flags			;no public flags defined
	STRUCT	MPS_PatchHeader,MLH_SIZE	;Listheader Structure for Patch structures
	APTR	MPS_PatchedLibraryBase		;Pointer to patched Library
	UWORD	MPS_PatchedLVO			;Library Vektor Offset in patched Library

	;...

;--------------------------------------------------------------------------
; Before accessing this structure, make sure PS_TYPE is either PS_TYPE_USER or PS_TYPE_SYSTEM
; Make sure your program can handle lists, that do not contain any nodes of
; PS_TYPE_USER or PS_TYPE_SYSTEM

 STRUCTURE Patch,0		;This structure is READONLY
	APTR	PS_SUCC		;Pointer to next (successor)
	APTR	PS_PRED		;Pointer to previous (predecessor)
	UBYTE	PS_TYPE		;MUST be PS_TYPE_USER or PS_TYPE_SYSTEM
	BYTE	PS_PRI		;Priority, for sorting
	APTR	PS_NAME		;may contain a pointer to the name of the patch
	UWORD	PS_Flags	;no public flags defined

	;...

;-------------------------------------------------------------------------
;Public types for patch and masterpatch structures:
PS_TYPE_MASTER	= 1	;node is MasterPatch structure
PS_TYPE_USER	= 2	;node was installed by an Application using the library interface
PS_TYPE_SYSTEM	= 3	;node was installed by a special patch.library Systemsoftware (not yet implemented)


	ENDC	;LIBRARIES_PATCH_I
