class OpenSSL::GETS_BIO
- OpenSSL::GETS_BIO
- Reference
- Object
Defined in:
openssl_ext/bio/bio.crConstant Summary
-
BIO_C_FILE_SEEK =
128
-
BIO_C_FILE_TELL =
133
-
GETS_BIO =
begin crystal_bio = OpenSSL::BIO::CRYSTAL_BIO ctrl = LibCrypto::BioMethodCtrl.new do |bio, cmd, _num, _ptr| val = case cmd when LibCrypto::CTRL_FLUSH io = Box(IO).unbox(BIO.get_data(bio)) io.flush 1 when LibCrypto::CTRL_PUSH, LibCrypto::CTRL_POP, LibCrypto::CTRL_EOF 0 when BIO_C_FILE_TELL, BIO_C_FILE_SEEK 0 when LibCrypto::CTRL_SET_KTLS_SEND 0 when LibCrypto::CTRL_GET_KTLS_SEND, LibCrypto::CTRL_GET_KTLS_RECV 0 else STDERR.puts("WARNING: Unsupported BIO ctrl call (#{cmd})") 0 end LibCrypto::Long.new(val) end bgets = LibCrypto::BioMethodGets.new do |bio, buffer, len| io = Box(IO).unbox(BIO.get_data(bio)) io.flush position = io.pos line = io.gets(len, false) if line.nil? 0 else io.seek(position) bytes = (io.read(Slice.new(buffer, line.bytesize))).to_i if bytes == 1 else bytes = bytes - 1 end bytes end end {% if (compare_versions(LibCrypto::OPENSSL_VERSION, "1.1.0")) >= 0 %} LibCrypto.BIO_meth_set_ctrl(crystal_bio, ctrl) LibCrypto.BIO_meth_set_gets(crystal_bio, bgets) {% else %} crystal_bio.value.ctrl = ctrl crystal_bio.value.bgets = bgets {% end %} crystal_bio end