base: rename heim_base_atomic_{max,type} to ...integer_{max,type}
[heimdal.git] / lib / base / common_plugin.h
blob82c5895638308e11f1cea000fa41927f0b4af968
1 /*
2 * Copyright (c) 2006 - 2020 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
6 * Portions Copyright (c) 2018 AuriStor, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the Institute nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
36 #ifndef HEIMDAL_BASE_COMMON_PLUGIN_H
37 #define HEIMDAL_BASE_COMMON_PLUGIN_H
39 #ifdef _WIN32
40 # ifndef HEIM_CALLCONV
41 # define HEIM_CALLCONV __stdcall
42 # endif
43 # ifndef HEIM_LIB_CALL
44 # define HEIM_LIB_CALL __stdcall
45 # endif
46 #else
47 # ifndef HEIM_CALLCONV
48 # define HEIM_CALLCONV
49 # endif
50 # ifndef HEIM_LIB_CALL
51 # define HEIM_LIB_CALL
52 # endif
53 #endif
54 #ifndef KRB5_CALLCONV
55 # define KRB5_CALLCONV HEIM_CALLCONV
56 #endif
57 #ifndef KRB5_LIB_CALL
58 # define KRB5_LIB_CALL HEIM_LIB_CALL
59 #endif
61 /* For krb5 plugins, this is a krb5_context */
62 typedef struct heim_pcontext_s *heim_pcontext;
64 typedef uintptr_t
65 (HEIM_LIB_CALL *heim_get_instance_func_t)(const char *);
66 typedef heim_get_instance_func_t krb5_get_instance_t;
69 * All plugin function tables extend the following structure.
71 struct heim_plugin_common_ftable_desc {
72 int version;
73 int (HEIM_LIB_CALL *init)(heim_pcontext, void **);
74 void (HEIM_LIB_CALL *fini)(void *);
76 typedef struct heim_plugin_common_ftable_desc heim_plugin_common_ftable;
77 typedef struct heim_plugin_common_ftable_desc *heim_plugin_common_ftable_p;
78 typedef struct heim_plugin_common_ftable_desc * const heim_plugin_common_ftable_cp;
80 typedef int
81 (HEIM_CALLCONV heim_plugin_load_ft)(heim_pcontext context,
82 heim_get_instance_func_t *func,
83 size_t *n_ftables,
84 heim_plugin_common_ftable_cp **ftables);
86 typedef heim_plugin_load_ft *heim_plugin_load_t;
88 /* For source backwards-compatibility */
89 typedef struct heim_plugin_common_ftable_desc krb5_plugin_common_ftable;
90 typedef struct heim_plugin_common_ftable_desc *krb5_plugin_common_ftable_p;
91 typedef struct heim_plugin_common_ftable_desc * const krb5_plugin_common_ftable_cp;
92 typedef heim_plugin_load_ft krb5_plugin_load_ft;
93 typedef heim_plugin_load_ft *krb5_plugin_load_t;
96 * All plugins must export a function named "<type>_plugin_load" with
97 * a signature of:
99 * int HEIM_CALLCONV
100 * <type>_plugin_load(heim_pcontext context,
101 * heim_get_instance_func_t *func,
102 * size_t *n_ftables,
103 * const heim_plugin_common_ftable *const **ftables);
105 #endif /* HEIMDAL_BASE_COMMON_PLUGIN_H */