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