Files
Viper_VRTE/openssl/err.vp
T

52 lines
1.9 KiB
Plaintext

import t, c
from openssl.types import *
# ============================================================
# openssl/err.vp — OpenSSL 错误队列
# 对应头文件: err.h
# ============================================================
# unsigned long ERR_get_error(void) — 弹出队列头并返回错误码
extern def ERR_get_error() -> t.CUInt32T
# unsigned long ERR_peek_error(void)
extern def ERR_peek_error() -> t.CUInt32T
# unsigned long ERR_peek_last_error(void)
extern def ERR_peek_last_error() -> t.CUInt32T
# void ERR_clear_error(void)
extern def ERR_clear_error()
# char *ERR_error_string(unsigned long e, char *buf) — buf 可为 NULL(用内部静态缓冲)
extern def ERR_error_string(e: t.CUInt32T, buf: bytes) -> str
# void ERR_error_string_n(unsigned long e, char *buf, size_t len)
extern def ERR_error_string_n(e: t.CUInt32T, buf: bytes, len: t.CSizeT)
# const char *ERR_lib_error_string(unsigned long e)
extern def ERR_lib_error_string(e: t.CUInt32T) -> str
# const char *ERR_func_error_string(unsigned long e)
extern def ERR_func_error_string(e: t.CUInt32T) -> str
# const char *ERR_reason_error_string(unsigned long e)
extern def ERR_reason_error_string(e: t.CUInt32T) -> str
# 栈标记(用于部分失败回滚)
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) — 把整个队列打到 BIO(见 bio.vp)
extern def ERR_print_errors(bp: BioPtr)
# void ERR_print_errors_fp(FILE *fp) — FILE* 暂不暴露
# ---- 错误码拆包(内联宏等价物)----
# OpenSSL 错误码布局:系统位 0x80000000,库 24-31,原因 0-15
ErrLibMask: t.CDefine = 0xff000000
ErrReasonMask: t.CDefine = 0x0000ffff
ErrSystemFlag: t.CDefine = 0x80000000
def err_get_lib(code: t.CUInt32T) -> int:
if (code & ErrSystemFlag) != 0:
return 0
return (code >> 24) & 0xff
def err_get_reason(code: t.CUInt32T) -> int:
return code & ErrReasonMask