Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / datatypes / copydttriggermethods.c
blob20ec062d3155e8555ed5a1c8c3dbc7b6c6b7e121
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
8 #include <proto/exec.h>
9 #include <proto/datatypes.h>
10 #include "datatypes_intern.h"
12 /*****************************************************************************
14 NAME */
16 AROS_LH3(struct DTMethod *, CopyDTTriggerMethods,
18 /* SYNOPSIS */
19 AROS_LHA(struct DTMethod *, methods, A0),
20 AROS_LHA(struct DTMethod *, include, A1),
21 AROS_LHA(struct DTMethod *, exclude, A2),
23 /* LOCATION */
24 struct Library *, DataTypesBase, 46, DataTypes)
26 /* FUNCTION
28 Copy and modify an array of DTMethod:s. This is used by subclass
29 implementors who want to add supported methods to an existing class.
31 INPUTS
33 methods -- array of methods; may be NULL
34 include -- array of methods to include terminated with ~0UL; may be NULL
35 method -- array of methods to exclude terminated with ~0UL; may be NULL
36 the dtm_Command and dtm_Method fields may have the options
37 described in the FindTriggerMethod to filter out the given
38 entries
39 RESULT
41 The new array of methods or NULL if something went wrong (like out of
42 memory).
44 NOTES
46 dtm_Label and dtm_Command must be valid as long as the object exists as
47 they are not copied.
48 A subclass that implment DTM_TRIGGER must send unknown trigger
49 methods to its superclass.
51 EXAMPLE
53 BUGS
55 SEE ALSO
57 FindTriggerMethod(), CopyDTMethods(), FreeDTMethods()
59 INTERNALS
61 HISTORY
63 2.8.99 SDuvan implemented
65 *****************************************************************************/
67 AROS_LIBFUNC_INIT
69 struct DTMethod *inc = include;
70 struct DTMethod *exc = exclude;
71 struct DTMethod *met = methods;
72 ULONG nMethods = 0;
73 struct DTMethod *newM;
74 struct DTMethod *newmets;
76 if(methods == NULL)
77 return NULL;
79 if(inc != NULL)
81 while(inc->dtm_Method != STM_DONE)
83 nMethods++;
84 inc++;
88 if(exc != NULL)
90 while(exc->dtm_Method != STM_DONE)
92 if(FindTriggerMethod(methods, NULL, exc->dtm_Method) != NULL)
93 nMethods--;
95 exc++;
99 while(met->dtm_Method != STM_DONE)
101 nMethods++;
102 met++;
105 newM = AllocVec((nMethods + 1)*sizeof(struct DTMethod), MEMF_PUBLIC);
107 /* No memory available? */
108 if(newM == NULL)
109 return NULL;
111 newmets = newM;
112 met = methods;
114 /* Copy new methods */
115 if(include != NULL)
117 while(include->dtm_Method != STM_DONE)
118 *newmets++ = *include++;
121 /* Copy old methods except the excluded ones */
122 while(met->dtm_Method != STM_DONE)
124 if(FindTriggerMethod(exclude, NULL, met->dtm_Method) == NULL)
125 *newmets++ = *met;
127 met++;
130 newmets->dtm_Method = STM_DONE;
132 return newM;
134 AROS_LIBFUNC_EXIT
135 } /* CopyDTTriggerMethods */