revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / datatypes / findtoolnodea.c
blob95f7116954e1670057dbfb0c98561c1371d5ea3c
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
8 #include "datatypes_intern.h"
9 #include <proto/utility.h>
11 /*****************************************************************************
13 NAME */
15 AROS_LH2(struct ToolNode *, FindToolNodeA,
17 /* SYNOPSIS */
18 AROS_LHA(struct List *, toollist, A0),
19 AROS_LHA(struct TagItem *, attrs , A1),
21 /* LOCATION */
22 struct Library *, DataTypesBase, 41, DataTypes)
24 /* FUNCTION
26 Search for a specific tool in a list of given tool nodes.
28 INPUTS
30 toollist -- a list or a struct ToolNode * (which will be skipped) to
31 search in; may be NULL.
33 attrs -- search tags; if NULL, the result of the function will
34 simply be the following node.
36 TAGS
38 TOOLA_Program -- name of the program to search for
40 TOOLA_Which -- one of the TW_#? types
42 TOOLA_LaunchType -- launch mode: TF_SHELL, TF_WORKBENCH or TF_RX
44 RESULT
46 A pointer to a ToolNode describing the search result (NULL for failure).
48 NOTES
50 The entries in dt->dtn_ToolList are valid as long as a lock is kept on
51 the data type 'dt' (ObtainDataTypeA() or LockDataType()).
53 EXAMPLE
55 BUGS
57 SEE ALSO
59 LaunchToolA()
61 INTERNALS
63 HISTORY
65 7.8.99 SDuvan implemented
67 *****************************************************************************/
69 AROS_LIBFUNC_INIT
71 STRPTR program;
72 WORD which;
73 WORD ltype;
75 struct ToolNode *tNode;
77 if(toollist == NULL)
78 return NULL;
80 program = (STRPTR)GetTagData(TOOLA_Program, (IPTR)NULL, attrs);
81 which = (WORD)GetTagData(TOOLA_Which, -1, attrs);
82 ltype = (WORD)GetTagData(TOOLA_LaunchType, -1, attrs);
84 ForeachNode(toollist, tNode)
86 /* Match program name */
87 if(program != NULL)
89 if(Stricmp(tNode->tn_Tool.tn_Program, program) != 0)
90 continue;
93 /* Check type */
94 if(which != -1)
96 if(which != tNode->tn_Tool.tn_Which)
97 continue;
100 /* Check launch type */
101 if(ltype != -1)
103 if(ltype != (tNode->tn_Tool.tn_Flags & TF_LAUNCH_MASK))
104 continue;
107 return tNode;
110 return NULL;
112 AROS_LIBFUNC_EXIT
113 } /* FindToolNodeA */