~yerinalexey/hare-openssl

a8ad311c9b8d2c473b857592c2118cda86242f8f — Alexey Yerin 1 year, 3 months ago cb3de86 master
Update per stdlib and language changes
3 files changed, 7 insertions(+), 8 deletions(-)

M examples/poll.ha
M openssl/bio.ha
M openssl/init.ha
M examples/poll.ha => examples/poll.ha +1 -1
@@ 89,7 89,7 @@ fn ssl_main(server: str, port: u16) (void | openssl::error | errors::error) = {
			};
		};
		if (pollfds[0].revents & poll::event::POLLIN != 0) {
			const line = match (bufio::scanline(os::stdin)!) {
			const line = match (bufio::read_line(os::stdin)!) {
			case let b: []u8 =>
				yield strings::fromutf8(b)!;
			case io::EOF =>

M openssl/bio.ha => openssl/bio.ha +5 -6
@@ 3,7 3,7 @@ use io;
use types::c;

// Buffered I/O handle (opaque).
export type BIO = void;
export type BIO = opaque;

// Frees a [[BIO]] with its data.
export fn bio_free_all(bio: *BIO) void = {


@@ 12,13 12,13 @@ export fn bio_free_all(bio: *BIO) void = {

// Writes a buffer to a [[BIO]].
export fn bio_write(bio: *BIO, buf: []u8) (size | error) = {
	return wrapint(c_BIO_write(bio, buf: *[*]u8: *const void,
	return wrapint(c_BIO_write(bio, buf: *[*]u8: *const opaque,
		len(buf): int))?: size;
};

// Reads a buffer from a [[BIO]].
export fn bio_read(bio: *BIO, buf: []u8) (size | io::EOF | error) = {
	const n = wrapint(c_BIO_read(bio, buf: *[*]u8: *void, len(buf): int))?;
	const n = wrapint(c_BIO_read(bio, buf: *[*]u8: *opaque, len(buf): int))?;
	if (n == 0) {
		return io::EOF;
	} else {


@@ 45,8 45,7 @@ export fn bio_set_conn_hostname(
	const n = len(fmt::bsprintf(buf, "{}:{}", hostname, port));
	buf[n] = '\0';

	wrapctrl(c_BIO_ctrl(bio, BIO_C_SET_CONNECT, 0,
		&buf: *void))?;
	wrapctrl(c_BIO_ctrl(bio, BIO_C_SET_CONNECT, 0, &buf: *opaque))?;
};

// Retrieves an SSL connection for the given [[BIO]].


@@ 57,7 56,7 @@ export fn bio_get_ssl(bio: *BIO) *SSL = {
};

@symbol("BIO_free_all") fn c_BIO_free_all(bio: *BIO) void;
@symbol("BIO_write") fn c_BIO_write(bio: *BIO, data: *const void, dlen: int) int;
@symbol("BIO_write") fn c_BIO_write(bio: *BIO, data: *const opaque, dlen: int) int;
@symbol("BIO_read") fn c_BIO_read(bio: *BIO, data: *opaque, dlen: int) int;
@symbol("BIO_ctrl") fn c_BIO_ctrl(bio: *BIO, cmd: int, larg: i64,
	parg: nullable *opaque) i64;

M openssl/init.ha => openssl/init.ha +1 -1
@@ 9,4 9,4 @@ def OPENSSL_INIT_LOAD_SSL_STRINGS: u64 = 0x00200000;
def OPENSSL_INIT_LOAD_CRYPTO_STRINGS: u64 = 0x00000002;

@symbol("OPENSSL_init_ssl") fn c_OPENSSL_init_ssl(opts: u64,
	settings: nullable *void) int;
	settings: nullable *opaque) int;