1 // Copyright 2017 The BoringSSL Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef OPENSSL_HEADER_CRYPTO_ERR_INTERNAL_H
16 #define OPENSSL_HEADER_CRYPTO_ERR_INTERNAL_H
17 
18 #include <openssl/err.h>
19 
20 #if defined(__cplusplus)
21 extern "C" {
22 #endif
23 
24 
25 // Private error queue functions.
26 
27 // ERR_SAVE_STATE contains a saved representation of the error queue. It is
28 // slightly more compact than |ERR_STATE| as the error queue will typically not
29 // contain |ERR_NUM_ERRORS| entries.
30 typedef struct err_save_state_st ERR_SAVE_STATE;
31 
32 // ERR_SAVE_STATE_free releases all memory associated with |state|.
33 OPENSSL_EXPORT void ERR_SAVE_STATE_free(ERR_SAVE_STATE *state);
34 
35 // ERR_save_state returns a newly-allocated |ERR_SAVE_STATE| structure
36 // containing the current state of the error queue or NULL on allocation
37 // error. It should be released with |ERR_SAVE_STATE_free|.
38 OPENSSL_EXPORT ERR_SAVE_STATE *ERR_save_state(void);
39 
40 // ERR_restore_state clears the error queue and replaces it with |state|.
41 OPENSSL_EXPORT void ERR_restore_state(const ERR_SAVE_STATE *state);
42 
43 
44 #if defined(__cplusplus)
45 }  // extern C
46 
47 extern "C++" {
48 
49 BSSL_NAMESPACE_BEGIN
50 
51 BORINGSSL_MAKE_DELETER(ERR_SAVE_STATE, ERR_SAVE_STATE_free)
52 
53 BSSL_NAMESPACE_END
54 
55 }  // extern C++
56 #endif
57 
58 #endif  // OPENSSL_HEADER_CRYPTO_ERR_INTERNAL_H
59