Imported Upstream version 1.17
[platform/upstream/krb5.git] / src / include / k5-plugin.h
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  * Copyright (C) 2006 Massachusetts Institute of Technology.
4  * All Rights Reserved.
5  *
6  * This software is being provided to you, the LICENSEE, by the
7  * Massachusetts Institute of Technology (M.I.T.) under the following
8  * license.  By obtaining, using and/or copying this software, you agree
9  * that you have read, understood, and will comply with these terms and
10  * conditions:
11  *
12  * Export of this software from the United States of America may
13  * require a specific license from the United States Government.
14  * It is the responsibility of any person or organization contemplating
15  * export to obtain such a license before exporting.
16  *
17  * WITHIN THAT CONSTRAINT, permission to use, copy, modify and distribute
18  * this software and its documentation for any purpose and without fee or
19  * royalty is hereby granted, provided that you agree to comply with the
20  * following copyright notice and statements, including the disclaimer, and
21  * that the same appear on ALL copies of the software and documentation,
22  * including modifications that you make for internal use or for
23  * distribution:
24  *
25  * THIS SOFTWARE IS PROVIDED "AS IS", AND M.I.T. MAKES NO REPRESENTATIONS
26  * OR WARRANTIES, EXPRESS OR IMPLIED.  By way of example, but not
27  * limitation, M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES OF
28  * MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF
29  * THE LICENSED SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
30  * PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
31  *
32  * The name of the Massachusetts Institute of Technology or M.I.T. may NOT
33  * be used in advertising or publicity pertaining to distribution of the
34  * software.  Title to copyright in this software and any associated
35  * documentation shall at all times remain with M.I.T., and USER agrees to
36  * preserve same.
37  *
38  * Furthermore if you modify this software you must label
39  * your software as modified software and not distribute it in such a
40  * fashion that it might be confused with the original M.I.T. software.
41  */
42
43 /* Just those definitions which are needed by util/support/plugins.c,
44    which gets compiled before util/et is built, which happens before
45    we can construct krb5.h, which is included by k5-int.h.
46
47    So, no krb5 types.  */
48
49 #ifndef K5_PLUGIN_H
50 #define K5_PLUGIN_H
51
52 #if defined(_MSDOS) || defined(_WIN32)
53 #include "win-mac.h"
54 #endif
55 #include "autoconf.h"
56 #ifndef KRB5_CALLCONV
57 #define KRB5_CALLCONV
58 #define KRB5_CALLCONV_C
59 #endif
60
61 #include "k5-err.h"
62
63 /*
64  * Plugins normally export fixed symbol names, but when statically
65  * linking plugins, we need a different symbol name for each plugin.
66  * The first argument to PLUGIN_SYMBOL_NAME acts as the
67  * differentiator, and is only used for static plugin linking.
68  *
69  * Although this macro (and thus this header file) are used in plugins
70  * whose code lies inside the krb5 tree, plugins maintained separately
71  * from the krb5 tree do not need it; they can just use the fixed
72  * symbol name unconditionally.
73  */
74 #ifdef STATIC_PLUGINS
75 #define PLUGIN_SYMBOL_NAME(prefix, symbol) prefix ## _ ## symbol
76 #else
77 #define PLUGIN_SYMBOL_NAME(prefix, symbol) symbol
78 #endif
79
80 struct plugin_file_handle;      /* opaque */
81
82 struct plugin_dir_handle {
83     /* This points to a NULL-terminated list of pointers to plugin_file_handle structs */
84     struct plugin_file_handle **files;
85 };
86 #define PLUGIN_DIR_INIT(P) ((P)->files = NULL)
87 #define PLUGIN_DIR_OPEN(P) ((P)->files != NULL)
88
89 long KRB5_CALLCONV
90 krb5int_open_plugin (const char *, struct plugin_file_handle **, struct errinfo *);
91 void KRB5_CALLCONV
92 krb5int_close_plugin (struct plugin_file_handle *);
93
94 long KRB5_CALLCONV
95 krb5int_get_plugin_data (struct plugin_file_handle *, const char *, void **,
96                          struct errinfo *);
97
98 long KRB5_CALLCONV
99 krb5int_get_plugin_func (struct plugin_file_handle *, const char *,
100                          void (**)(), struct errinfo *);
101
102
103 long KRB5_CALLCONV
104 krb5int_open_plugin_dirs (const char * const *, const char * const *,
105                           struct plugin_dir_handle *, struct errinfo *);
106 void KRB5_CALLCONV
107 krb5int_close_plugin_dirs (struct plugin_dir_handle *);
108
109 long KRB5_CALLCONV
110 krb5int_get_plugin_dir_data (struct plugin_dir_handle *, const char *,
111                              void ***, struct errinfo *);
112 void KRB5_CALLCONV
113 krb5int_free_plugin_dir_data (void **);
114
115 long KRB5_CALLCONV
116 krb5int_get_plugin_dir_func (struct plugin_dir_handle *, const char *,
117                              void (***)(void), struct errinfo *);
118 void KRB5_CALLCONV
119 krb5int_free_plugin_dir_func (void (**)(void));
120
121 #endif /* K5_PLUGIN_H */