xref: /freebsd/crypto/krb5/src/ccapi/server/ccs_array.c (revision b670c9bafc0e31c7609969bf374b2e80bdc00211)
1 /* ccapi/server/ccs_array.c */
2 /*
3  * Copyright 2006, 2007 Massachusetts Institute of Technology.
4  * All Rights Reserved.
5  *
6  * Export of this software from the United States of America may
7  * require a specific license from the United States Government.
8  * It is the responsibility of any person or organization contemplating
9  * export to obtain such a license before exporting.
10  *
11  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
12  * distribute this software and its documentation for any purpose and
13  * without fee is hereby granted, provided that the above copyright
14  * notice appear in all copies and that both that copyright notice and
15  * this permission notice appear in supporting documentation, and that
16  * the name of M.I.T. not be used in advertising or publicity pertaining
17  * to distribution of the software without specific, written prior
18  * permission.  Furthermore if you modify this software you must label
19  * your software as modified software and not distribute it in such a
20  * fashion that it might be confused with the original M.I.T. software.
21  * M.I.T. makes no representations about the suitability of
22  * this software for any purpose.  It is provided "as is" without express
23  * or implied warranty.
24  */
25 
26 #include "ccs_common.h"
27 #include "cci_array_internal.h"
28 
29 /* ------------------------------------------------------------------------ */
30 
31 static cc_int32 ccs_client_object_release (cci_array_object_t io_client)
32 {
33     return cci_check_error (ccs_client_release ((ccs_client_t) io_client));
34 }
35 
36 /* ------------------------------------------------------------------------ */
37 
38 cc_int32 ccs_client_array_new (ccs_client_array_t *out_array)
39 {
40     return cci_array_new (out_array, ccs_client_object_release);
41 }
42 
43 /* ------------------------------------------------------------------------ */
44 
45 cc_int32 ccs_client_array_release (ccs_client_array_t io_array)
46 {
47     return cci_array_release (io_array);
48 }
49 
50 /* ------------------------------------------------------------------------ */
51 
52 cc_uint64 ccs_client_array_count (ccs_client_array_t in_array)
53 {
54     return cci_array_count (in_array);
55 }
56 
57 /* ------------------------------------------------------------------------ */
58 
59 ccs_client_t ccs_client_array_object_at_index (ccs_client_array_t io_array,
60                                                cc_uint64          in_position)
61 {
62     return (ccs_client_t) cci_array_object_at_index (io_array, in_position);
63 }
64 
65 /* ------------------------------------------------------------------------ */
66 
67 cc_int32 ccs_client_array_insert (ccs_client_array_t io_array,
68                                   ccs_client_t       in_client,
69                                   cc_uint64          in_position)
70 {
71     return cci_array_insert (io_array, (cci_array_object_t) in_client, in_position);
72 }
73 
74 /* ------------------------------------------------------------------------ */
75 
76 cc_int32 ccs_client_array_remove (ccs_client_array_t io_array,
77                                   cc_uint64          in_position)
78 {
79     return cci_array_remove (io_array, in_position);
80 }
81 
82 #ifdef TARGET_OS_MAC
83 #pragma mark -
84 #endif
85 
86 /* ------------------------------------------------------------------------ */
87 
88 static cc_int32 ccs_lock_object_release (cci_array_object_t io_lock)
89 {
90     return cci_check_error (ccs_lock_release ((ccs_lock_t) io_lock));
91 }
92 
93 /* ------------------------------------------------------------------------ */
94 
95 cc_int32 ccs_lock_array_new (ccs_lock_array_t *out_array)
96 {
97     return cci_array_new (out_array, ccs_lock_object_release);
98 }
99 
100 /* ------------------------------------------------------------------------ */
101 
102 cc_int32 ccs_lock_array_release (ccs_lock_array_t io_array)
103 {
104     return cci_array_release (io_array);
105 }
106 
107 /* ------------------------------------------------------------------------ */
108 
109 cc_uint64 ccs_lock_array_count (ccs_lock_array_t in_array)
110 {
111     return cci_array_count (in_array);
112 }
113 
114 /* ------------------------------------------------------------------------ */
115 
116 ccs_lock_t ccs_lock_array_object_at_index (ccs_lock_array_t io_array,
117                                            cc_uint64        in_position)
118 {
119     return (ccs_lock_t) cci_array_object_at_index (io_array, in_position);
120 }
121 
122 /* ------------------------------------------------------------------------ */
123 
124 cc_int32 ccs_lock_array_insert (ccs_lock_array_t io_array,
125                                 ccs_lock_t       in_lock,
126                                 cc_uint64        in_position)
127 {
128     return cci_array_insert (io_array, (cci_array_object_t) in_lock, in_position);
129 }
130 
131 /* ------------------------------------------------------------------------ */
132 
133 cc_int32 ccs_lock_array_remove (ccs_lock_array_t io_array,
134                                 cc_uint64        in_position)
135 {
136     return cci_array_remove (io_array, in_position);
137 }
138 
139 /* ------------------------------------------------------------------------ */
140 cc_int32 ccs_lock_array_move (ccs_lock_array_t  io_array,
141                               cc_uint64         in_position,
142                               cc_uint64         in_new_position,
143                               cc_uint64        *out_real_new_position)
144 {
145     return cci_array_move (io_array, in_position, in_new_position, out_real_new_position);
146 }
147 
148 #ifdef TARGET_OS_MAC
149 #pragma mark -
150 #endif
151 
152 /* ------------------------------------------------------------------------ */
153 
154 static cc_int32 ccs_callback_object_release (cci_array_object_t io_callback)
155 {
156     return cci_check_error (ccs_callback_release ((ccs_callback_t) io_callback));
157 }
158 
159 /* ------------------------------------------------------------------------ */
160 
161 cc_int32 ccs_callback_array_new (ccs_callback_array_t *out_array)
162 {
163     return cci_array_new (out_array, ccs_callback_object_release);
164 }
165 
166 /* ------------------------------------------------------------------------ */
167 
168 cc_int32 ccs_callback_array_release (ccs_callback_array_t io_array)
169 {
170     return cci_array_release (io_array);
171 }
172 
173 /* ------------------------------------------------------------------------ */
174 
175 cc_uint64 ccs_callback_array_count (ccs_callback_array_t in_array)
176 {
177     return cci_array_count (in_array);
178 }
179 
180 /* ------------------------------------------------------------------------ */
181 
182 ccs_callback_t ccs_callback_array_object_at_index (ccs_callback_array_t io_array,
183 						   cc_uint64            in_position)
184 {
185     return (ccs_callback_t) cci_array_object_at_index (io_array, in_position);
186 }
187 
188 /* ------------------------------------------------------------------------ */
189 
190 cc_int32 ccs_callback_array_insert (ccs_callback_array_t io_array,
191 				    ccs_callback_t       in_callback,
192 				    cc_uint64            in_position)
193 {
194     return cci_array_insert (io_array, (cci_array_object_t) in_callback, in_position);
195 }
196 
197 /* ------------------------------------------------------------------------ */
198 
199 cc_int32 ccs_callback_array_remove (ccs_callback_array_t io_array,
200 				    cc_uint64           in_position)
201 {
202     return cci_array_remove (io_array, in_position);
203 }
204 
205 #ifdef TARGET_OS_MAC
206 #pragma mark -
207 #endif
208 
209 
210 /* ------------------------------------------------------------------------ */
211 
212 cc_int32 ccs_callbackref_array_new (ccs_callbackref_array_t *out_array)
213 {
214     /* Ref arrays do not own their contents; pass NULL for release function */
215     return cci_array_new (out_array, NULL);
216 }
217 
218 /* ------------------------------------------------------------------------ */
219 
220 cc_int32 ccs_callbackref_array_release (ccs_callbackref_array_t io_array)
221 {
222     return cci_array_release (io_array);
223 }
224 
225 /* ------------------------------------------------------------------------ */
226 
227 cc_uint64 ccs_callbackref_array_count (ccs_callbackref_array_t in_array)
228 {
229     return cci_array_count (in_array);
230 }
231 
232 /* ------------------------------------------------------------------------ */
233 
234 ccs_callback_t ccs_callbackref_array_object_at_index (ccs_callbackref_array_t io_array,
235 						      cc_uint64               in_position)
236 {
237     return (ccs_callback_t) cci_array_object_at_index (io_array, in_position);
238 }
239 
240 /* ------------------------------------------------------------------------ */
241 
242 cc_int32 ccs_callbackref_array_insert (ccs_callbackref_array_t io_array,
243 				       ccs_callback_t          in_callback,
244 				       cc_uint64               in_position)
245 {
246     return cci_array_insert (io_array, (cci_array_object_t) in_callback, in_position);
247 }
248 
249 /* ------------------------------------------------------------------------ */
250 
251 cc_int32 ccs_callbackref_array_remove (ccs_callbackref_array_t io_array,
252 				       cc_uint64               in_position)
253 {
254     return cci_array_remove (io_array, in_position);
255 }
256 
257 #ifdef TARGET_OS_MAC
258 #pragma mark -
259 #endif
260 
261 /* ------------------------------------------------------------------------ */
262 
263 cc_int32 ccs_iteratorref_array_new (ccs_iteratorref_array_t *out_array)
264 {
265     /* Ref arrays do not own their contents; pass NULL for release function */
266     return cci_array_new (out_array, NULL);
267 }
268 
269 /* ------------------------------------------------------------------------ */
270 
271 cc_int32 ccs_iteratorref_array_release (ccs_iteratorref_array_t io_array)
272 {
273     return cci_array_release (io_array);
274 }
275 
276 /* ------------------------------------------------------------------------ */
277 
278 cc_uint64 ccs_iteratorref_array_count (ccs_iteratorref_array_t in_array)
279 {
280     return cci_array_count (in_array);
281 }
282 
283 /* ------------------------------------------------------------------------ */
284 
285 ccs_generic_list_iterator_t ccs_iteratorref_array_object_at_index (ccs_iteratorref_array_t io_array,
286                                                                    cc_uint64               in_position)
287 {
288     return (ccs_generic_list_iterator_t) cci_array_object_at_index (io_array,
289                                                                     in_position);
290 }
291 
292 /* ------------------------------------------------------------------------ */
293 
294 cc_int32 ccs_iteratorref_array_insert (ccs_iteratorref_array_t     io_array,
295 				       ccs_generic_list_iterator_t in_iterator,
296 				       cc_uint64                   in_position)
297 {
298     return cci_array_insert (io_array,
299                              (cci_array_object_t) in_iterator,
300                              in_position);
301 }
302 
303 /* ------------------------------------------------------------------------ */
304 
305 cc_int32 ccs_iteratorref_array_remove (ccs_iteratorref_array_t io_array,
306 				       cc_uint64               in_position)
307 {
308     return cci_array_remove (io_array, in_position);
309 }
310