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

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


/****** patch.library/SetPatchProjectA ***************************************
*
*   NAME
*        SetPatchProjectA -- Changes certain attributes of a project. (V5)
*        SetPatchProject -- varargs stub for SetPatchProjectA(). (V5)
*
*   SYNOPSIS
*        Error = SetPatchProjectA( project, taglist )
*        D0                        A0       A1
*
*        ULONG Error SetPatchProjectA( APTR, struct TagItem *);
*
*        Error = SetPatchProject( project, ...)
*
*        ULONG Error SetPatchProject( APTR, ...);
*
*   FUNCTION
*        Changes certain attributes of a group of patches belonging to one
*        project. For now (V5) it mainly calls SetPatch() recursive for
*        all patches belonging to the project.
*        Certain project specific tags may be implemented later.
*
*   INPUTS
*        project = pointer to a patch project obtained via
*                  CreatePatchProject() or NULL for no action
*        taglist = pointer to array of tags
*
*   TAGS
*        see SetPatch() for a list of valid tags.
*
*   RESULT
*        Error = errorcode as defined in patch.h.
*                see SetPatch() for a list of errorcodes
*
*   NOTES
*        Currently (V5) SetPatchProject() stops changing patches, when any of
*        the internal calls to SetPatch() return an error. Therefore when
*        SetPatchProject() returns an error, some patches may have been
*        changed and others not.
*
*   BUGS
*
*   SEE ALSO
*        SetPatch(), patch.h, patchtags.h, CreatePatchProject()
*
******************************************************************************
*
*/

ULONG LIBFUNC SetPatchProjectA( REGA0 struct PatchProject *project GNUC_REGA0, REGA1 struct TagItem *taglist GNUC_REGA1)
{
ULONG Error;
struct Patch *patch;
struct Node *pointer;

	if (project)
	{
		for (pointer = (struct Node *)project->PPR_PatchListHeader.lh_Head;
		     pointer->ln_Succ;
		     pointer = (struct Node *)pointer->ln_Succ)
		{
			patch = (struct Patch *) (((UBYTE *)pointer) -offsetof(struct Patch, PS_ProjectNode.mln_Succ));
			if( project->PPR_Flags & PPRF_InternalCall)
				patch->PS_Flags |= PSF_InternalCall;
			Error = SetPatchA(patch, taglist);
			if (Error) return(Error);
		}
		project->PPR_Flags &= ~PPRF_InternalCall;

	}
	return(NULL);

}
