fix function to take the hook param
[AROS.git] / workbench / libs / datatypes / copydtmethods.c
blob54dd80c4008ebc54e96235e5ca9cafc05ac59a14
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(ULONG *, CopyDTMethods,
18 /* SYNOPSIS */
19 AROS_LHA(ULONG *, methods, A0),
20 AROS_LHA(ULONG *, include, A1),
21 AROS_LHA(ULONG *, exclude, A2),
23 /* LOCATION */
24 struct Library *, DataTypesBase, 45, DataTypes)
26 /* FUNCTION
28 Copy and modify an array of methods. This is used by subclass implementors
29 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.
37 RESULT
39 The new array of methods or NULL if something went wrong (like out of
40 memory).
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 FindMethod(), CopyDTTriggerMethods(), FreeDTMethods()
52 INTERNALS
54 When a method is specified both in the 'include' and the 'exclude',
55 it will be included.
57 HISTORY
59 2.8.99 SDuvan implemented
61 *****************************************************************************/
63 AROS_LIBFUNC_INIT
65 ULONG *inc = include;
66 ULONG *exc = exclude;
67 ULONG *met = methods;
68 ULONG nMethods = 0;
69 ULONG *newM;
70 ULONG *newmets;
72 if(methods == NULL)
73 return NULL;
75 if(inc != NULL)
77 while(*inc++ != ~0)
78 nMethods++;
81 if(exc != NULL)
83 while(*exc != ~0)
85 if(FindMethod(methods, *exc) != NULL)
86 nMethods--;
88 exc++;
92 while(*met++ != ~0)
93 nMethods++;
95 newM = AllocVec((nMethods + 1)*sizeof(ULONG), MEMF_PUBLIC);
97 /* No memory available? */
98 if(newM == NULL)
99 return NULL;
101 newmets = newM;
102 met = methods;
104 /* Copy new methods */
105 if(include != NULL)
107 while(*include != ~0)
108 *newmets++ = *include++;
111 /* Copy old methods except the excluded ones */
112 while(*met != ~0)
114 if(FindMethod(exclude, *met) == NULL)
115 *newmets++ = *met;
117 met++;
120 *newmets = ~0;
122 return newM;
124 AROS_LIBFUNC_EXIT
125 } /* CopyDTMethods */