Files

51 lines
1.9 KiB
Plaintext

from openssl.types import *
# ============================================================
# openssl/err.vp — OpenSSL error queue
# Corresponding header: err.h
# ============================================================
# unsigned long ERR_get_error(void) -- pop queue head and return error code
extern def ERR_get_error() -> uint32
# unsigned long ERR_peek_error(void)
extern def ERR_peek_error() -> uint32
# unsigned long ERR_peek_last_error(void)
extern def ERR_peek_last_error() -> uint32
# void ERR_clear_error(void)
extern def ERR_clear_error()
# char *ERR_error_string(unsigned long e, char *buf) -- buf may be NULL (uses internal static buffer)
extern def ERR_error_string(e: uint32, buf: bytes) -> str
# void ERR_error_string_n(unsigned long e, char *buf, size_t len)
extern def ERR_error_string_n(e: uint32, buf: bytes, len: sizet)
# const char *ERR_lib_error_string(unsigned long e)
extern def ERR_lib_error_string(e: uint32) -> str
# const char *ERR_func_error_string(unsigned long e)
extern def ERR_func_error_string(e: uint32) -> str
# const char *ERR_reason_error_string(unsigned long e)
extern def ERR_reason_error_string(e: uint32) -> str
# Stack marks (for partial-failure rollback)
extern def ERR_set_mark() -> int
extern def ERR_pop_to_mark() -> int
extern def ERR_clear_last_mark() -> int
# void ERR_print_errors(BIO *bp) -- dump the whole queue to BIO (see bio.vp)
extern def ERR_print_errors(bp: BioPtr)
# void ERR_print_errors_fp(FILE *fp) -- FILE* not exposed yet
# ---- Error code unpacking (inline-macro equivalents) ----
# OpenSSL error code layout: system bit 0x80000000, library 24-31, reason 0-15
define ErrLibMask = 0xff000000
define ErrReasonMask = 0x0000ffff
define ErrSystemFlag = 0x80000000
def err_get_lib(code: uint32) -> int:
if (code & ErrSystemFlag) != 0:
return 0
return (code >> 24) & 0xff
def err_get_reason(code: uint32) -> int:
return code & ErrReasonMask