Imported Upstream version 1.10.2
[platform/upstream/krb5.git] / src / ccapi / lib / mac / ccapi_vector.c
1 /* ccapi/lib/mac/ccapi_vector.c */
2 /*
3  * Copyright 2006 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 "ccapi_vector.h"
27
28 #include "ccapi_context.h"
29 #include "ccapi_string.h"
30 #include "ccapi_ccache.h"
31 #include "ccapi_credentials.h"
32 #include "ccapi_ccache_iterator.h"
33 #include "ccapi_credentials_iterator.h"
34
35 /* ------------------------------------------------------------------------ */
36
37 static void cci_swap_string_functions (cc_string_t io_string)
38 {
39     cc_string_f temp = *(io_string->functions);
40     *((cc_string_f *)io_string->functions) = *(io_string->vector_functions);
41     *((cc_string_f *)io_string->vector_functions) = temp;
42 }
43
44 /* ------------------------------------------------------------------------ */
45
46 static void cci_swap_context_functions (cc_context_t io_context)
47 {
48     cc_context_f temp = *(io_context->functions);
49     *((cc_context_f *)io_context->functions) = *(io_context->vector_functions);
50     *((cc_context_f *)io_context->vector_functions) = temp;
51 }
52
53 /* ------------------------------------------------------------------------ */
54
55 static void cci_swap_ccache_functions (cc_ccache_t io_ccache)
56 {
57     cc_ccache_f temp = *(io_ccache->functions);
58     *((cc_ccache_f *)io_ccache->functions) = *(io_ccache->vector_functions);
59     *((cc_ccache_f *)io_ccache->vector_functions) = temp;
60 }
61
62 /* ------------------------------------------------------------------------ */
63
64 static void cci_swap_credentials_functions (cc_credentials_t io_credentials)
65 {
66     cc_credentials_f temp = *(io_credentials->functions);
67     *((cc_credentials_f *)io_credentials->functions) = *(io_credentials->otherFunctions);
68     *((cc_credentials_f *)io_credentials->otherFunctions) = temp;
69 }
70
71 /* ------------------------------------------------------------------------ */
72
73 static void cci_swap_ccache_iterator_functions (cc_ccache_iterator_t io_ccache_iterator)
74 {
75     cc_ccache_iterator_f temp = *(io_ccache_iterator->functions);
76     *((cc_ccache_iterator_f *)io_ccache_iterator->functions) = *(io_ccache_iterator->vector_functions);
77     *((cc_ccache_iterator_f *)io_ccache_iterator->vector_functions) = temp;
78 }
79
80 /* ------------------------------------------------------------------------ */
81
82 static void cci_swap_credentials_iterator_functions (cc_credentials_iterator_t io_credentials_iterator)
83 {
84     cc_credentials_iterator_f temp = *(io_credentials_iterator->functions);
85     *((cc_credentials_iterator_f *)io_credentials_iterator->functions) = *(io_credentials_iterator->vector_functions);
86     *((cc_credentials_iterator_f *)io_credentials_iterator->vector_functions) = temp;
87 }
88
89 #pragma mark -
90
91 /* ------------------------------------------------------------------------ */
92
93 cc_int32 __cc_initialize_vector (cc_context_t  *out_context,
94                                  cc_int32       in_version,
95                                  cc_int32      *out_supported_version,
96                                  char const   **out_vendor)
97 {
98     return cc_initialize (out_context, in_version, out_supported_version, out_vendor);
99 }
100
101 #pragma mark -
102
103 /* ------------------------------------------------------------------------ */
104
105 cc_int32 __cc_string_release_vector (cc_string_t in_string)
106 {
107     cci_swap_string_functions (in_string);
108     return ccapi_string_release (in_string);
109 }
110
111 #pragma mark -
112
113 /* ------------------------------------------------------------------------ */
114
115 cc_int32 __cc_context_release_vector (cc_context_t io_context)
116 {
117     cci_swap_context_functions (io_context);
118     return ccapi_context_release (io_context);
119 }
120
121 /* ------------------------------------------------------------------------ */
122
123 cc_int32 __cc_context_get_change_time_vector (cc_context_t  in_context,
124                                               cc_time_t    *out_change_time)
125 {
126     cc_int32 err = ccNoError;
127     cci_swap_context_functions (in_context);
128     err = ccapi_context_get_change_time (in_context, out_change_time);
129     cci_swap_context_functions (in_context);
130     return err;
131 }
132
133 /* ------------------------------------------------------------------------ */
134
135 cc_int32 __cc_context_get_default_ccache_name_vector (cc_context_t  in_context,
136                                                       cc_string_t  *out_name)
137 {
138     cc_int32 err = ccNoError;
139     cci_swap_context_functions (in_context);
140     err = ccapi_context_get_default_ccache_name (in_context, out_name);
141     cci_swap_context_functions (in_context);
142     return err;
143 }
144
145 /* ------------------------------------------------------------------------ */
146
147 cc_int32 __cc_context_open_ccache_vector (cc_context_t  in_context,
148                                           const char   *in_name,
149                                           cc_ccache_t  *out_ccache)
150 {
151     cc_int32 err = ccNoError;
152     cci_swap_context_functions (in_context);
153     err = ccapi_context_open_ccache (in_context, in_name, out_ccache);
154     cci_swap_context_functions (in_context);
155     return err;
156 }
157
158 /* ------------------------------------------------------------------------ */
159
160 cc_int32 __cc_context_open_default_ccache_vector (cc_context_t  in_context,
161                                                   cc_ccache_t  *out_ccache)
162 {
163     cc_int32 err = ccNoError;
164     cci_swap_context_functions (in_context);
165     err = ccapi_context_open_default_ccache (in_context, out_ccache);
166     cci_swap_context_functions (in_context);
167     return err;
168 }
169
170 /* ------------------------------------------------------------------------ */
171
172 cc_int32 __cc_context_create_ccache_vector (cc_context_t  in_context,
173                                             const char   *in_name,
174                                             cc_uint32     in_cred_vers,
175                                             const char   *in_principal,
176                                             cc_ccache_t  *out_ccache)
177 {
178     cc_int32 err = ccNoError;
179     cci_swap_context_functions (in_context);
180     err = ccapi_context_create_ccache (in_context, in_name, in_cred_vers, in_principal, out_ccache);
181     cci_swap_context_functions (in_context);
182     return err;
183 }
184
185
186 /* ------------------------------------------------------------------------ */
187
188 cc_int32 __cc_context_create_default_ccache_vector (cc_context_t  in_context,
189                                                     cc_uint32     in_cred_vers,
190                                                     const char   *in_principal,
191                                                     cc_ccache_t  *out_ccache)
192 {
193     cc_int32 err = ccNoError;
194     cci_swap_context_functions (in_context);
195     err = ccapi_context_create_default_ccache (in_context, in_cred_vers, in_principal, out_ccache);
196     cci_swap_context_functions (in_context);
197     return err;
198 }
199
200 /* ------------------------------------------------------------------------ */
201
202 cc_int32 __cc_context_create_new_ccache_vector (cc_context_t in_context,
203                                                 cc_uint32    in_cred_vers,
204                                                 const char  *in_principal,
205                                                 cc_ccache_t *out_ccache)
206 {
207     cc_int32 err = ccNoError;
208     cci_swap_context_functions (in_context);
209     err = ccapi_context_create_new_ccache (in_context, in_cred_vers, in_principal, out_ccache);
210     cci_swap_context_functions (in_context);
211     return err;
212 }
213
214 /* ------------------------------------------------------------------------ */
215
216 cc_int32 __cc_context_new_ccache_iterator_vector (cc_context_t          in_context,
217                                                   cc_ccache_iterator_t *out_iterator)
218 {
219     cc_int32 err = ccNoError;
220     cci_swap_context_functions (in_context);
221     err = ccapi_context_new_ccache_iterator (in_context, out_iterator);
222     cci_swap_context_functions (in_context);
223     return err;
224 }
225
226 /* ------------------------------------------------------------------------ */
227
228 cc_int32 __cc_context_lock_vector (cc_context_t in_context,
229                                    cc_uint32    in_lock_type,
230                                    cc_uint32    in_block)
231 {
232     cc_int32 err = ccNoError;
233     cci_swap_context_functions (in_context);
234     err = ccapi_context_lock (in_context, in_lock_type, in_block);
235     cci_swap_context_functions (in_context);
236     return err;
237 }
238
239 /* ------------------------------------------------------------------------ */
240
241 cc_int32 __cc_context_unlock_vector (cc_context_t in_context)
242 {
243     cc_int32 err = ccNoError;
244     cci_swap_context_functions (in_context);
245     err = ccapi_context_unlock (in_context);
246     cci_swap_context_functions (in_context);
247     return err;
248 }
249
250 /* ------------------------------------------------------------------------ */
251
252 cc_int32 __cc_context_compare_vector (cc_context_t  in_context,
253                                       cc_context_t  in_compare_to_context,
254                                       cc_uint32    *out_equal)
255 {
256     cc_int32 err = ccNoError;
257     cci_swap_context_functions (in_context);
258     err = ccapi_context_compare (in_context, in_compare_to_context, out_equal);
259     cci_swap_context_functions (in_context);
260     return err;
261 }
262
263 #pragma mark -
264
265 /* ------------------------------------------------------------------------ */
266
267 cc_int32 __cc_ccache_release_vector (cc_ccache_t io_ccache)
268 {
269     cci_swap_ccache_functions (io_ccache);
270     return ccapi_ccache_release (io_ccache);
271 }
272
273 /* ------------------------------------------------------------------------ */
274
275 cc_int32 __cc_ccache_destroy_vector (cc_ccache_t io_ccache)
276 {
277     cci_swap_ccache_functions (io_ccache);
278     return ccapi_ccache_destroy (io_ccache);
279 }
280
281 /* ------------------------------------------------------------------------ */
282
283 cc_int32 __cc_ccache_set_default_vector (cc_ccache_t io_ccache)
284 {
285     cc_int32 err = ccNoError;
286     cci_swap_ccache_functions (io_ccache);
287     err = ccapi_ccache_set_default (io_ccache);
288     cci_swap_ccache_functions (io_ccache);
289     return err;
290 }
291
292 /* ------------------------------------------------------------------------ */
293
294 cc_uint32 __cc_ccache_get_credentials_version_vector (cc_ccache_t  in_ccache,
295                                                       cc_uint32   *out_credentials_version)
296 {
297     cc_int32 err = ccNoError;
298     cci_swap_ccache_functions (in_ccache);
299     err = ccapi_ccache_get_credentials_version (in_ccache, out_credentials_version);
300     cci_swap_ccache_functions (in_ccache);
301     return err;
302 }
303
304 /* ------------------------------------------------------------------------ */
305
306 cc_int32 __cc_ccache_get_name_vector (cc_ccache_t  in_ccache,
307                                       cc_string_t *out_name)
308 {
309     cc_int32 err = ccNoError;
310     cci_swap_ccache_functions (in_ccache);
311     err = ccapi_ccache_get_name (in_ccache, out_name);
312     cci_swap_ccache_functions (in_ccache);
313     return err;
314 }
315
316 /* ------------------------------------------------------------------------ */
317
318 cc_int32 __cc_ccache_get_principal_vector (cc_ccache_t  in_ccache,
319                                            cc_uint32    in_credentials_version,
320                                            cc_string_t *out_principal)
321 {
322     cc_int32 err = ccNoError;
323     cci_swap_ccache_functions (in_ccache);
324     err = ccapi_ccache_get_principal (in_ccache, in_credentials_version, out_principal);
325     cci_swap_ccache_functions (in_ccache);
326     return err;
327 }
328
329 /* ------------------------------------------------------------------------ */
330
331 cc_int32 __cc_ccache_set_principal_vector (cc_ccache_t  io_ccache,
332                                            cc_uint32    in_credentials_version,
333                                            const char  *in_principal)
334 {
335     cc_int32 err = ccNoError;
336     cci_swap_ccache_functions (io_ccache);
337     err = ccapi_ccache_set_principal (io_ccache, in_credentials_version, in_principal);
338     cci_swap_ccache_functions (io_ccache);
339     return err;
340 }
341
342 /* ------------------------------------------------------------------------ */
343
344 cc_int32 __cc_ccache_store_credentials_vector (cc_ccache_t                 io_ccache,
345                                                const cc_credentials_union *in_credentials_union)
346 {
347     cc_int32 err = ccNoError;
348     cci_swap_ccache_functions (io_ccache);
349     err = ccapi_ccache_store_credentials (io_ccache, in_credentials_union);
350     cci_swap_ccache_functions (io_ccache);
351     return err;
352 }
353
354 /* ------------------------------------------------------------------------ */
355
356 cc_int32 __cc_ccache_remove_credentials_vector (cc_ccache_t      io_ccache,
357                                                 cc_credentials_t in_credentials)
358 {
359     cc_int32 err = ccNoError;
360     cci_swap_ccache_functions (io_ccache);
361     cci_swap_credentials_functions (in_credentials);
362     err = ccapi_ccache_remove_credentials (io_ccache, in_credentials);
363     cci_swap_ccache_functions (io_ccache);
364     cci_swap_credentials_functions (in_credentials);
365     return err;
366 }
367
368 /* ------------------------------------------------------------------------ */
369
370 cc_int32 __cc_ccache_new_credentials_iterator_vector (cc_ccache_t                in_ccache,
371                                                       cc_credentials_iterator_t *out_credentials_iterator)
372 {
373     cc_int32 err = ccNoError;
374     cci_swap_ccache_functions (in_ccache);
375     err = ccapi_ccache_new_credentials_iterator (in_ccache, out_credentials_iterator);
376     cci_swap_ccache_functions (in_ccache);
377     return err;
378 }
379
380 /* ------------------------------------------------------------------------ */
381
382 cc_int32 __cc_ccache_move_vector (cc_ccache_t io_source_ccache,
383                                   cc_ccache_t io_destination_ccache)
384 {
385     cc_int32 err = ccNoError;
386     cci_swap_ccache_functions (io_source_ccache);
387     cci_swap_ccache_functions (io_destination_ccache);
388     err = ccapi_ccache_move (io_source_ccache, io_destination_ccache);
389     cci_swap_ccache_functions (io_source_ccache);
390     cci_swap_ccache_functions (io_destination_ccache);
391     return err;
392 }
393
394 /* ------------------------------------------------------------------------ */
395
396 cc_int32 __cc_ccache_lock_vector (cc_ccache_t io_ccache,
397                                   cc_uint32   in_lock_type,
398                                   cc_uint32   in_block)
399 {
400     cc_int32 err = ccNoError;
401     cci_swap_ccache_functions (io_ccache);
402     err = ccapi_ccache_lock (io_ccache, in_lock_type, in_block);
403     cci_swap_ccache_functions (io_ccache);
404     return err;
405 }
406
407 /* ------------------------------------------------------------------------ */
408
409 cc_int32 __cc_ccache_unlock_vector (cc_ccache_t io_ccache)
410 {
411     cc_int32 err = ccNoError;
412     cci_swap_ccache_functions (io_ccache);
413     err = ccapi_ccache_unlock (io_ccache);
414     cci_swap_ccache_functions (io_ccache);
415     return err;
416 }
417
418 /* ------------------------------------------------------------------------ */
419
420 cc_int32 __cc_ccache_get_last_default_time_vector (cc_ccache_t  in_ccache,
421                                                    cc_time_t   *out_last_default_time)
422 {
423     cc_int32 err = ccNoError;
424     cci_swap_ccache_functions (in_ccache);
425     err = ccapi_ccache_get_last_default_time (in_ccache, out_last_default_time);
426     cci_swap_ccache_functions (in_ccache);
427     return err;
428 }
429
430 /* ------------------------------------------------------------------------ */
431
432 cc_int32 __cc_ccache_get_change_time_vector (cc_ccache_t  in_ccache,
433                                              cc_time_t   *out_change_time)
434 {
435     cc_int32 err = ccNoError;
436     cci_swap_ccache_functions (in_ccache);
437     err = ccapi_ccache_get_change_time (in_ccache, out_change_time);
438     cci_swap_ccache_functions (in_ccache);
439     return err;
440 }
441
442 /* ------------------------------------------------------------------------ */
443
444 cc_int32 __cc_ccache_compare_vector (cc_ccache_t  in_ccache,
445                                      cc_ccache_t  in_compare_to_ccache,
446                                      cc_uint32   *out_equal)
447 {
448     cc_int32 err = ccNoError;
449     cci_swap_ccache_functions (in_ccache);
450     cci_swap_ccache_functions (in_compare_to_ccache);
451     err = ccapi_ccache_compare (in_ccache, in_compare_to_ccache, out_equal);
452     cci_swap_ccache_functions (in_ccache);
453     cci_swap_ccache_functions (in_compare_to_ccache);
454     return err;
455 }
456
457 #pragma mark -
458
459 /* ------------------------------------------------------------------------ */
460
461 cc_int32 __cc_credentials_release_vector (cc_credentials_t io_credentials)
462 {
463     cci_swap_credentials_functions (io_credentials);
464     return ccapi_credentials_release (io_credentials);
465 }
466
467 /* ------------------------------------------------------------------------ */
468
469 cc_int32 __cc_credentials_compare_vector (cc_credentials_t  in_credentials,
470                                           cc_credentials_t  in_compare_to_credentials,
471                                           cc_uint32        *out_equal)
472 {
473     cc_int32 err = ccNoError;
474     cci_swap_credentials_functions (in_credentials);
475     cci_swap_credentials_functions (in_compare_to_credentials);
476     err = ccapi_credentials_compare (in_credentials, in_compare_to_credentials, out_equal);
477     cci_swap_credentials_functions (in_credentials);
478     cci_swap_credentials_functions (in_compare_to_credentials);
479     return err;
480 }
481
482 #pragma mark -
483
484 /* ------------------------------------------------------------------------ */
485
486 cc_int32 __cc_ccache_iterator_release_vector (cc_ccache_iterator_t io_ccache_iterator)
487 {
488     cci_swap_ccache_iterator_functions (io_ccache_iterator);
489     return ccapi_ccache_iterator_release (io_ccache_iterator);
490 }
491
492 /* ------------------------------------------------------------------------ */
493
494 cc_int32 __cc_ccache_iterator_next_vector (cc_ccache_iterator_t  in_ccache_iterator,
495                                            cc_ccache_t          *out_ccache)
496 {
497     cc_int32 err = ccNoError;
498     cci_swap_ccache_iterator_functions (in_ccache_iterator);
499     err = ccapi_ccache_iterator_next (in_ccache_iterator, out_ccache);
500     cci_swap_ccache_iterator_functions (in_ccache_iterator);
501     return err;
502 }
503
504 #pragma mark -
505
506 /* ------------------------------------------------------------------------ */
507
508 cc_int32 __cc_credentials_iterator_release_vector (cc_credentials_iterator_t io_credentials_iterator)
509 {
510     cci_swap_credentials_iterator_functions (io_credentials_iterator);
511     return ccapi_credentials_iterator_release (io_credentials_iterator);
512 }
513
514 /* ------------------------------------------------------------------------ */
515
516 cc_int32 __cc_credentials_iterator_next_vector (cc_credentials_iterator_t  in_credentials_iterator,
517                                                 cc_credentials_t          *out_credentials)
518 {
519     cc_int32 err = ccNoError;
520     cci_swap_credentials_iterator_functions (in_credentials_iterator);
521     err = ccapi_credentials_iterator_next (in_credentials_iterator, out_credentials);
522     cci_swap_credentials_iterator_functions (in_credentials_iterator);
523     return err;
524 }
525
526 #pragma mark -
527
528 /* ------------------------------------------------------------------------ */
529
530 cc_int32 __cc_shutdown_vector (apiCB **io_context)
531 {
532     cci_swap_context_functions (*io_context);
533     return cc_shutdown (io_context);
534 }
535
536 /* ------------------------------------------------------------------------ */
537
538 cc_int32 __cc_get_NC_info_vector (apiCB    *in_context,
539                                   infoNC ***out_info)
540 {
541     cc_int32 err = ccNoError;
542     cci_swap_context_functions (in_context);
543     err = cc_get_NC_info (in_context, out_info);
544     cci_swap_context_functions (in_context);
545     return err;
546 }
547
548 /* ------------------------------------------------------------------------ */
549
550 cc_int32 __cc_get_change_time_vector (apiCB     *in_context,
551                                       cc_time_t *out_change_time)
552 {
553     cc_int32 err = ccNoError;
554     cci_swap_context_functions (in_context);
555     err = cc_get_change_time (in_context, out_change_time);
556     cci_swap_context_functions (in_context);
557     return err;
558 }
559
560 /* ------------------------------------------------------------------------ */
561
562 cc_int32 __cc_open_vector (apiCB       *in_context,
563                            const char  *in_name,
564                            cc_int32     in_version,
565                            cc_uint32    in_flags,
566                            ccache_p   **out_ccache)
567 {
568     cc_int32 err = ccNoError;
569     cci_swap_context_functions (in_context);
570     err = cc_open (in_context, in_name, in_version, in_flags, out_ccache);
571     cci_swap_context_functions (in_context);
572     return err;
573 }
574
575 /* ------------------------------------------------------------------------ */
576
577 cc_int32 __cc_create_vector (apiCB       *in_context,
578                              const char  *in_name,
579                              const char  *in_principal,
580                              cc_int32     in_version,
581                              cc_uint32    in_flags,
582                              ccache_p   **out_ccache)
583 {
584     cc_int32 err = ccNoError;
585     cci_swap_context_functions (in_context);
586     err = cc_create (in_context, in_name, in_principal, in_version, in_flags, out_ccache);
587     cci_swap_context_functions (in_context);
588     return err;
589 }
590
591 /* ------------------------------------------------------------------------ */
592
593 cc_int32 __cc_close_vector (apiCB     *in_context,
594                             ccache_p **io_ccache)
595 {
596     cc_int32 err = ccNoError;
597     cci_swap_context_functions (in_context);
598     cci_swap_ccache_functions (*io_ccache);
599     err = cc_close (in_context, io_ccache);
600     cci_swap_context_functions (in_context);
601     return err;
602 }
603
604 /* ------------------------------------------------------------------------ */
605
606 cc_int32 __cc_destroy_vector (apiCB     *in_context,
607                               ccache_p **io_ccache)
608 {
609     cc_int32 err = ccNoError;
610     cci_swap_context_functions (in_context);
611     cci_swap_ccache_functions (*io_ccache);
612     err = cc_destroy (in_context, io_ccache);
613     cci_swap_context_functions (in_context);
614     return err;
615 }
616
617 /* ------------------------------------------------------------------------ */
618
619 cc_int32 __cc_seq_fetch_NCs_begin_vector (apiCB       *in_context,
620                                           ccache_cit **out_iterator)
621 {
622     cc_int32 err = ccNoError;
623     cci_swap_context_functions (in_context);
624     err = cc_seq_fetch_NCs_begin (in_context, out_iterator);
625     cci_swap_context_functions (in_context);
626     return err;
627 }
628
629
630 /* ------------------------------------------------------------------------ */
631
632 cc_int32 __cc_seq_fetch_NCs_next_vector (apiCB       *in_context,
633                                          ccache_p   **out_ccache,
634                                          ccache_cit  *in_iterator)
635 {
636     cc_int32 err = ccNoError;
637     cci_swap_context_functions (in_context);
638     cci_swap_ccache_iterator_functions ((ccache_cit_ccache *)in_iterator);
639     err = cc_seq_fetch_NCs_next (in_context, out_ccache, in_iterator);
640     cci_swap_context_functions (in_context);
641     cci_swap_ccache_iterator_functions ((ccache_cit_ccache *)in_iterator);
642     return err;
643 }
644
645 /* ------------------------------------------------------------------------ */
646
647 cc_int32 __cc_seq_fetch_NCs_end_vector (apiCB       *in_context,
648                                         ccache_cit **io_iterator)
649 {
650     cc_int32 err = ccNoError;
651     cci_swap_context_functions (in_context);
652     cci_swap_ccache_iterator_functions ((ccache_cit_ccache *) *io_iterator);
653     err = cc_seq_fetch_NCs_end (in_context, io_iterator);
654     cci_swap_context_functions (in_context);
655     return err;
656 }
657
658 /* ------------------------------------------------------------------------ */
659
660 cc_int32 __cc_get_name_vector (apiCB     *in_context,
661                                ccache_p  *in_ccache,
662                                char     **out_name)
663 {
664     cc_int32 err = ccNoError;
665     cci_swap_context_functions (in_context);
666     cci_swap_ccache_functions (in_ccache);
667     err = cc_get_name (in_context, in_ccache, out_name);
668     cci_swap_context_functions (in_context);
669     cci_swap_ccache_functions (in_ccache);
670     return err;
671 }
672
673 /* ------------------------------------------------------------------------ */
674
675 cc_int32 __cc_get_cred_version_vector (apiCB    *in_context,
676                                        ccache_p *in_ccache,
677                                        cc_int32 *out_version)
678 {
679     cc_int32 err = ccNoError;
680     cci_swap_context_functions (in_context);
681     cci_swap_ccache_functions (in_ccache);
682     err = cc_get_cred_version (in_context, in_ccache, out_version);
683     cci_swap_context_functions (in_context);
684     cci_swap_ccache_functions (in_ccache);
685     return err;
686 }
687
688 /* ------------------------------------------------------------------------ */
689
690 cc_int32 __cc_set_principal_vector (apiCB    *in_context,
691                                     ccache_p *io_ccache,
692                                     cc_int32  in_version,
693                                     char     *in_principal)
694 {
695     cc_int32 err = ccNoError;
696     cci_swap_context_functions (in_context);
697     cci_swap_ccache_functions (io_ccache);
698     err = cc_set_principal (in_context, io_ccache, in_version, in_principal);
699     cci_swap_context_functions (in_context);
700     cci_swap_ccache_functions (io_ccache);
701     return err;
702 }
703
704 /* ------------------------------------------------------------------------ */
705
706 cc_int32 __cc_get_principal_vector (apiCB      *in_context,
707                                     ccache_p   *in_ccache,
708                                     char      **out_principal)
709 {
710     cc_int32 err = ccNoError;
711     cci_swap_context_functions (in_context);
712     cci_swap_ccache_functions (in_ccache);
713     err = cc_get_principal (in_context, in_ccache, out_principal);
714     cci_swap_context_functions (in_context);
715     cci_swap_ccache_functions (in_ccache);
716     return err;
717 }
718
719 /* ------------------------------------------------------------------------ */
720
721 cc_int32 __cc_store_vector (apiCB      *in_context,
722                             ccache_p   *io_ccache,
723                             cred_union  in_credentials)
724 {
725     cc_int32 err = ccNoError;
726     cci_swap_context_functions (in_context);
727     cci_swap_ccache_functions (io_ccache);
728     err = cc_store (in_context, io_ccache, in_credentials);
729     cci_swap_context_functions (in_context);
730     cci_swap_ccache_functions (io_ccache);
731     return err;
732 }
733
734 /* ------------------------------------------------------------------------ */
735
736 cc_int32 __cc_remove_cred_vector (apiCB      *in_context,
737                                   ccache_p   *in_ccache,
738                                   cred_union  in_credentials)
739 {
740     cc_int32 err = ccNoError;
741     cci_swap_context_functions (in_context);
742     cci_swap_ccache_functions (in_ccache);
743     err = cc_remove_cred (in_context, in_ccache, in_credentials);
744     cci_swap_context_functions (in_context);
745     cci_swap_ccache_functions (in_ccache);
746     return err;
747 }
748
749 /* ------------------------------------------------------------------------ */
750
751 cc_int32 __cc_seq_fetch_creds_begin_vector (apiCB           *in_context,
752                                             const ccache_p  *in_ccache,
753                                             ccache_cit     **out_iterator)
754 {
755     cc_int32 err = ccNoError;
756     cci_swap_context_functions (in_context);
757     cci_swap_ccache_functions ((ccache_p *)in_ccache);
758     err = cc_seq_fetch_creds_begin (in_context, in_ccache, out_iterator);
759     cci_swap_context_functions (in_context);
760     cci_swap_ccache_functions ((ccache_p *)in_ccache);
761     return err;
762 }
763
764 /* ------------------------------------------------------------------------ */
765
766 cc_int32 __cc_seq_fetch_creds_next_vector (apiCB       *in_context,
767                                            cred_union **out_creds,
768                                            ccache_cit  *in_iterator)
769 {
770     cc_int32 err = ccNoError;
771     cci_swap_context_functions (in_context);
772     cci_swap_credentials_iterator_functions ((ccache_cit_creds *)in_iterator);
773     err = cc_seq_fetch_creds_next (in_context, out_creds, in_iterator);
774     cci_swap_context_functions (in_context);
775     cci_swap_credentials_iterator_functions ((ccache_cit_creds *)in_iterator);
776     return err;
777 }
778
779 /* ------------------------------------------------------------------------ */
780
781 cc_int32 __cc_seq_fetch_creds_end_vector (apiCB       *in_context,
782                                           ccache_cit **io_iterator)
783 {
784     cc_int32 err = ccNoError;
785     cci_swap_context_functions (in_context);
786     cci_swap_credentials_iterator_functions ((ccache_cit_creds *) *io_iterator);
787     err = cc_seq_fetch_creds_end (in_context, io_iterator);
788     cci_swap_context_functions (in_context);
789     return err;
790 }
791
792 /* ------------------------------------------------------------------------ */
793
794 cc_int32 __cc_free_principal_vector (apiCB  *in_context,
795                                      char  **io_principal)
796 {
797     cc_int32 err = ccNoError;
798     cci_swap_context_functions (in_context);
799     err = cc_free_principal (in_context, io_principal);
800     cci_swap_context_functions (in_context);
801     return err;
802 }
803
804 /* ------------------------------------------------------------------------ */
805
806 cc_int32 __cc_free_name_vector (apiCB  *in_context,
807                                 char  **io_name)
808 {
809     cc_int32 err = ccNoError;
810     cci_swap_context_functions (in_context);
811     err = cc_free_name (in_context, io_name);
812     cci_swap_context_functions (in_context);
813     return err;
814 }
815
816 /* ------------------------------------------------------------------------ */
817
818 cc_int32 __cc_free_creds_vector (apiCB       *in_context,
819                                  cred_union **io_credentials)
820 {
821     cc_int32 err = ccNoError;
822     cci_swap_context_functions (in_context);
823     err = cc_free_creds (in_context, io_credentials);
824     cci_swap_context_functions (in_context);
825     return err;
826 }
827
828 /* ------------------------------------------------------------------------ */
829
830 cc_int32 __cc_free_NC_info_vector (apiCB    *in_context,
831                                    infoNC ***io_info)
832 {
833     cc_int32 err = ccNoError;
834     cci_swap_context_functions (in_context);
835     err = cc_free_NC_info (in_context, io_info);
836     cci_swap_context_functions (in_context);
837     return err;
838 }