43 lines
1.4 KiB
Julia
43 lines
1.4 KiB
Julia
# BIO_METHOD * BIO_s_mem(void);
|
|
|
|
# BIO_set_mem_eof_return(BIO *b,int v)
|
|
# long BIO_get_mem_data(BIO *b, char **pp)
|
|
# BIO_set_mem_buf(BIO *b,BUF_MEM *bm,int c)
|
|
# BIO_get_mem_ptr(BIO *b,BUF_MEM **pp)
|
|
|
|
# BIO * BIO_new(const BIO_METHOD *type);
|
|
# int BIO_set(BIO *a, const BIO_METHOD *type);
|
|
# # int BIO_up_ref(BIO *a); # Don't see a use case
|
|
# int BIO_free(BIO *a);
|
|
# # void BIO_vfree(BIO *a); # Same as BIO_free
|
|
# void BIO_free_all(BIO *a);
|
|
|
|
s_mem() = ccall((:BIO_s_mem, libssl), Ptr{BIO_Method}, ())
|
|
|
|
bio_new(mem::Ptr{BIO_Method}) =
|
|
ccall((:BIO_new, libssl), Ptr{Cvoid}, (Ptr{BIO_Method},), mem)
|
|
bio_new() = bio_new(s_mem())
|
|
|
|
function set_bio!(client::SSLClient, rbio, wbio)
|
|
client.rbio = rbio
|
|
client.wbio = wbio
|
|
ccall((:SSL_set_bio, libssl), Ptr{Cvoid}, (Ptr{Cvoid},Ptr{Cvoid},Ptr{Cvoid}),
|
|
client.ssl, rbio, wbio)
|
|
end
|
|
|
|
function bio_write!(client::SSLClient, data)
|
|
ccall((:BIO_write, libssl), Cint, (Ptr{Cvoid},Ptr{Cvoid},Cint),
|
|
client.rbio, data, length(data))
|
|
end
|
|
|
|
function bio_read(client::SSLClient)
|
|
buff = Vector{UInt8}(undef, 64)
|
|
n = ccall((:BIO_read, libssl), Cint, (Ptr{Cvoid},Ptr{Cvoid},Cint),
|
|
client.wbio, buff, length(buff))
|
|
n, n > 0 ? buff[1:n] : buff
|
|
end
|
|
|
|
bio_test_flags(bio, flags) =
|
|
ccall((:BIO_test_flags, libssl), Cint, (Ptr{Cvoid},Cint), bio, flags) != 0
|
|
bio_should_retry(bio) = bio_test_flags(bio, BIO_FLAGS_SHOULD_RETRY)
|