#ifndef OPENSSL_HEADER_CRYPTO_ERR_INTERNAL_H
#define OPENSSL_HEADER_CRYPTO_ERR_INTERNAL_H
#include <openssl/err.h>
#if defined(__cplusplus)
extern "C" {
#endif
typedef struct err_save_state_st ERR_SAVE_STATE;
OPENSSL_EXPORT void ERR_SAVE_STATE_free(ERR_SAVE_STATE *state);
OPENSSL_EXPORT ERR_SAVE_STATE *ERR_save_state(void);
OPENSSL_EXPORT void ERR_restore_state(const ERR_SAVE_STATE *state);
OPENSSL_EXPORT int ERR_suppress_errors_begin(void);
OPENSSL_EXPORT void ERR_suppress_errors_end(void);
#if defined(__cplusplus)
}
extern "C++" {
BSSL_NAMESPACE_BEGIN
BORINGSSL_MAKE_DELETER(ERR_SAVE_STATE, ERR_SAVE_STATE_free)
class ScopedErrorSuppression {
public:
ScopedErrorSuppression() : active_(ERR_suppress_errors_begin() != 0) {}
~ScopedErrorSuppression() {
if (active_) {
ERR_suppress_errors_end();
}
}
ScopedErrorSuppression(const ScopedErrorSuppression &) = delete;
ScopedErrorSuppression &operator=(const ScopedErrorSuppression &) = delete;
explicit operator bool() const { return active_; }
private:
const bool active_;
};
BSSL_NAMESPACE_END
} #endif
#endif