9c24f20cc8f32490303860992999d7a4220842e4
[platform/upstream/krb5.git] / src / lib / krb5 / ccache / cc-int.h
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* lib/krb5/ccache/cc-int.h */
3 /*
4  * Copyright 1990,1991 by the Massachusetts Institute of Technology.
5  * All Rights Reserved.
6  *
7  * Export of this software from the United States of America may
8  *   require a specific license from the United States Government.
9  *   It is the responsibility of any person or organization contemplating
10  *   export to obtain such a license before exporting.
11  *
12  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13  * distribute this software and its documentation for any purpose and
14  * without fee is hereby granted, provided that the above copyright
15  * notice appear in all copies and that both that copyright notice and
16  * this permission notice appear in supporting documentation, and that
17  * the name of M.I.T. not be used in advertising or publicity pertaining
18  * to distribution of the software without specific, written prior
19  * permission.  Furthermore if you modify this software you must label
20  * your software as modified software and not distribute it in such a
21  * fashion that it might be confused with the original M.I.T. software.
22  * M.I.T. makes no representations about the suitability of
23  * this software for any purpose.  It is provided "as is" without express
24  * or implied warranty.
25  */
26
27 /* This file contains constant and function declarations used in the
28  * file-based credential cache routines. */
29
30 #ifndef __KRB5_CCACHE_H__
31 #define __KRB5_CCACHE_H__
32
33 #include "k5-int.h"
34
35 krb5_boolean
36 krb5int_cc_creds_match_request(krb5_context, krb5_flags whichfields, krb5_creds *mcreds, krb5_creds *creds);
37
38 int
39 krb5int_cc_initialize(void);
40
41 void
42 krb5int_cc_finalize(void);
43
44 krb5_error_code krb5int_random_string (krb5_context, char *, unsigned int);
45
46 /*
47  * Cursor for iterating over ccache types
48  */
49 struct krb5_cc_typecursor;
50 typedef struct krb5_cc_typecursor *krb5_cc_typecursor;
51
52 krb5_error_code
53 krb5int_cc_typecursor_new(krb5_context context, krb5_cc_typecursor *cursor);
54
55 krb5_error_code
56 krb5int_cc_typecursor_next(
57     krb5_context context,
58     krb5_cc_typecursor cursor,
59     const struct _krb5_cc_ops **ops);
60
61 krb5_error_code
62 krb5int_cc_typecursor_free(
63     krb5_context context,
64     krb5_cc_typecursor *cursor);
65
66 /* reentrant mutex used by krb5_cc_* functions */
67 typedef struct _k5_cc_mutex {
68     k5_mutex_t lock;
69     krb5_context owner;
70     krb5_int32 refcount;
71 } k5_cc_mutex;
72
73 #define K5_CC_MUTEX_PARTIAL_INITIALIZER         \
74     { K5_MUTEX_PARTIAL_INITIALIZER, NULL, 0 }
75
76 krb5_error_code
77 k5_cc_mutex_init(k5_cc_mutex *m);
78
79 krb5_error_code
80 k5_cc_mutex_finish_init(k5_cc_mutex *m);
81
82 #define k5_cc_mutex_destroy(M)                  \
83     k5_mutex_destroy(&(M)->lock);
84
85 void
86 k5_cc_mutex_assert_locked(krb5_context context, k5_cc_mutex *m);
87
88 void
89 k5_cc_mutex_assert_unlocked(krb5_context context, k5_cc_mutex *m);
90
91 krb5_error_code
92 k5_cc_mutex_lock(krb5_context context, k5_cc_mutex *m);
93
94 krb5_error_code
95 k5_cc_mutex_unlock(krb5_context context, k5_cc_mutex *m);
96
97 extern k5_cc_mutex krb5int_mcc_mutex;
98 extern k5_cc_mutex krb5int_krcc_mutex;
99 extern k5_cc_mutex krb5int_cc_file_mutex;
100
101 #ifdef USE_CCAPI_V3
102 extern krb5_error_code KRB5_CALLCONV krb5_stdccv3_context_lock
103 (krb5_context context);
104
105 extern krb5_error_code KRB5_CALLCONV krb5_stdccv3_context_unlock
106 (krb5_context context);
107 #endif
108
109 krb5_error_code
110 k5_cc_mutex_force_unlock(k5_cc_mutex *m);
111
112 krb5_error_code
113 k5_cccol_force_unlock(void);
114
115 krb5_error_code
116 krb5int_fcc_new_unique(krb5_context context, char *template, krb5_ccache *id);
117
118 krb5_error_code
119 ccselect_realm_initvt(krb5_context context, int maj_ver, int min_ver,
120                       krb5_plugin_vtable vtable);
121
122 krb5_error_code
123 ccselect_k5identity_initvt(krb5_context context, int maj_ver, int min_ver,
124                            krb5_plugin_vtable vtable);
125
126 #endif /* __KRB5_CCACHE_H__ */