/*
**	patch.library
**
**	Copyright © 1993-1997 by Stefan Fuchs
**		Freely distributable.
*/

#ifndef _PATCH_INCLUDES_H
#include "patch_includes.h"
#endif

/****** patch.library/AddPatchNotifyA ******************************************
*
*   NAME
*        AddPatchNotifyA -- Get messages, if a patch is changed. (V5)
*        AddPatchNotify -- varargs stub for AddPatchNotifyA(). (V5)
*
*   SYNOPSIS
*        Error = AddPatchNotifyA( msgport, taglist )
*        D0                       A0       A1
*
*        ULONG Error AddPatchNotifyA( struct MsgPort *, struct TagItem *);
*
*        Error = AddPatchNotify( msgport, ...)
*
*        ULONG Error AddPatchNotify( struct MsgPort *, ...);
*
*   FUNCTION
*        Patch.library will immediately start sending out PatchNotifyMessages
*        (see patch.h) of PATCHNOTIFY_CLASS to the given message port, if
*        a patch is added, removed or changed.
*
*        pnm_Code contains PATCOD_xxx values to indicate the kind of
*        change. For PATCOD_PatchInstalled and PATCOD_PatchChanged
*        pnm_Object will contain a pointer to the corresponding
*        patch structure.
*
*   INPUTS
*        msgport = pointer to msgport ready to receive messages or
*                  null for no action
*        taglist = pointer to array of tags
*
*   TAGS
*        PATT_Priority (BYTE) - Optional priority for the notification request
*                Normally only the priorities +5, 0, -5 should be used.
*
*   RESULT
*        Error = errorcode as defined in patch.h.
*                PATERR_Ok
*                        Indicates success of the operation.
*                PATERR_OutOfMem
*                        Indicates that there was not enough memory to
*                        complete the operation.
*
*   NOTES
*
*   BUGS
*
*   SEE ALSO
*        RemPatchNotify(), patch.h
*
******************************************************************************
*
*/
ULONG LIBFUNC AddPatchNotifyA( REGA0 struct MsgPort *msgport GNUC_REGA0, REGA1 struct TagItem *taglist GNUC_REGA1)
{
struct Node *pointer;
LONG pri;
	if( msgport == NULL) return(NULL);

	if( FindPatchNotify(msgport)) return(PATERR_Ok);

	pri = GetTagData(PATT_Priority, 0L, taglist);
	pointer = ACreateMyListNodePri( &(PatchBase->PB_NotifyListHeader), sizeof(struct Node), pri);

	if(pointer)
	{
		pointer->ln_Name = (char *)msgport;
		return(PATERR_Ok);
	}
	else
		return(PATERR_OutOfMem);
}