Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/include/openssl/ex_data.h

raw
1 // Copyright (C) 1995-1998 Eric Young ([email protected])
2 // Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
4
5 #ifndef OPENSSL_HEADER_EX_DATA_H
6 #define OPENSSL_HEADER_EX_DATA_H
7
8 #include <openssl/base.h>
9
10 #include <openssl/stack.h>
11
12 #if defined(__cplusplus)
13 extern "C" {
14 #endif
15
16
17 // ex_data is a mechanism for associating arbitrary extra data with objects.
18 // For each type of object that supports ex_data, different users can be
19 // assigned indexes in which to store their data. Each index has callback
20 // functions that are called when an object of that type is freed or
21 // duplicated.
22
23
24 typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
25
26
27 // Type-specific functions.
28
29 #if 0 // Sample
30
31 // Each type that supports ex_data provides three functions:
32
33 // TYPE_get_ex_new_index allocates a new index for |TYPE|. An optional
34 // |free_func| argument may be provided which is called when the owning object
35 // is destroyed. See |CRYPTO_EX_free| for details. The |argl| and |argp|
36 // arguments are opaque values that are passed to the callback. It returns the
37 // new index or a negative number on error.
38 OPENSSL_EXPORT int TYPE_get_ex_new_index(long argl, void *argp,
39 CRYPTO_EX_unused *unused,
40 CRYPTO_EX_dup *dup_unused,
41 CRYPTO_EX_free *free_func);
42
43 // TYPE_set_ex_data sets an extra data pointer on |t|. The |index| argument
44 // must have been returned from a previous call to |TYPE_get_ex_new_index|.
45 OPENSSL_EXPORT int TYPE_set_ex_data(TYPE *t, int index, void *arg);
46
47 // TYPE_get_ex_data returns an extra data pointer for |t|, or NULL if no such
48 // pointer exists. The |index| argument should have been returned from a
49 // previous call to |TYPE_get_ex_new_index|.
50 OPENSSL_EXPORT void *TYPE_get_ex_data(const TYPE *t, int index);
51
52 // Some types additionally preallocate index zero, with all callbacks set to
53 // NULL. Applications that do not need the general ex_data machinery may use
54 // this instead.
55
56 // TYPE_set_app_data sets |t|'s application data pointer to |arg|. It returns
57 // one on success and zero on error.
58 OPENSSL_EXPORT int TYPE_set_app_data(TYPE *t, void *arg);
59
60 // TYPE_get_app_data returns the application data pointer for |t|, or NULL if no
61 // such pointer exists.
62 OPENSSL_EXPORT void *TYPE_get_app_data(const TYPE *t);
63
64 #endif // Sample
65
66
67 // Callback types.
68
69 // CRYPTO_EX_free is a callback function that is called when an object of the
70 // class with extra data pointers is being destroyed. For example, if this
71 // callback has been passed to |SSL_get_ex_new_index| then it may be called each
72 // time an |SSL*| is destroyed.
73 //
74 // The callback is passed the to-be-destroyed object (i.e. the |SSL*|) in
75 // |parent|. As |parent| will shortly be destroyed, callers must not perform
76 // operations that would increment its reference count, pass ownership, or
77 // assume the object outlives the function call. The arguments |argl| and |argp|
78 // contain opaque values that were given to |CRYPTO_get_ex_new_index|.
79 //
80 // This callback may be called with a NULL value for |ptr| if |parent| has no
81 // value set for this index. However, the callbacks may also be skipped entirely
82 // if no extra data pointers are set on |parent| at all.
83 typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
84 int index, long argl, void *argp);
85
86
87 // General No-op Functions [Deprecated].
88
89 // CRYPTO_cleanup_all_ex_data does nothing.
90 OPENSSL_EXPORT OPENSSL_DEPRECATED void CRYPTO_cleanup_all_ex_data(void);
91
92 // CRYPTO_EX_dup is a legacy callback function type which is ignored.
93 typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from,
94 void **from_d, int index, long argl, void *argp);
95
96
97 // Private structures.
98
99 // CRYPTO_EX_unused is a placeholder for an unused callback. It is aliased to
100 // int to ensure non-NULL callers fail to compile rather than fail silently.
101 typedef int CRYPTO_EX_unused;
102
103 struct crypto_ex_data_st {
104 STACK_OF(void) *sk;
105 };
106
107
108 #if defined(__cplusplus)
109 } // extern C
110 #endif
111
112 #endif // OPENSSL_HEADER_EX_DATA_H