/* $Header: Src/rcs/AssignNode.h,v 1.4 1995/06/21 17:24:04 cmh Exp cmh $
 *
 * BindNamesII: Handy assign/path maker.
 * Copyright (C) 1994-95  Magnus Holmgren <cmh@augs.se>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <exec/types.h>

/* This structure stores one target for an assign.
 * We use a struct Node so that names may prioritized.
 * That way it is easy to specify search order priorities.
 *
 */
struct PathNode
{
	struct Node		Node;           /* Node linking */
	STRPTR			Name;           /* Path for this target */
	struct AssignNode	*Parent;	/* Parent assign, if any */
};


/* This structure stores all information about an assign.
 *
 * We don't store any childrens here, since each part in a mulitassign can
 * refer to a different parent. This forces us to backtrace the parents, which
 * makes it a bit tricky to notice loops. But thanks to recursion it isn't
 * that bad really.. :)
 */
struct AssignNode
{
	struct MinNode	Node;		/* Node linking */
	struct MinList	Path;		/* The targets for this assign */
	STRPTR		Name;		/* Name of this assign, including a ':' char */
	STRPTR		Alias;		/* PathHandler alias for this assign */
	WORD		AssignType;	/* Type of assign. ASN_NORMAL, ASN_DEFER or ASN_PATH */
	WORD		Flags;		/* Various flags. See below */
	LONG		IoErr;		/* Only used if ANF_FAILED is set */
};

/* Type of assign */

#define ASN_NORMAL	0		/* Normal assign */
#define ASN_DEFER	1		/* Resolve at first reference */
#define ASN_PATH	2		/* Resolve at each reference */
#define ASN_CMDPATH	3		/* Not assign, add to command search path instead */

/* AssignNode flags */

#define ANF_ADD		0x0001	/* Don't replace any previous assign */
#define ANF_PATHADD	0x0002	/* Put all targets in a PathHandler assign, if there is at least one */
#define ANF_ASSIGNED	0x0004	/* This assign have been done. */
#define ANF_NODE	0x0008	/* This assign refers to a (not yet done) assign. I.e., it has at least one parent */
#define ANF_VOLUME	0x0010	/* This assign only refers to known volumes (i.e. it can be assigned right away) */
#define ANF_STRAY	0x0020	/* This assign refers (possibly indirect) to unknown volumes */
#define ANF_FAILED	0x0040	/* This assign couldn't be made for some reason. See IoErr field for more info */
#define ANF_LOOP	0x0080	/* This assign is in a loop that can't be resolved */
#define ANF_BAD		0x0100	/* This assign is bad somehow (probably multiple targets for ASN_DEFER or ASN_PATH) */
#define ANF_VISIT	0x0200	/* This node have already been visited by IsStray(). For loop detection */
#define ANF_BADPARENT	0x0400	/* This assign node couldn't be made becase a parent assign had failed */
