~yerinalexey/hare-openssl

11cf19ae68bee932a222a14e6924e7f26bb4b0fc — Alexey Yerin 1 year, 6 months ago 494c879
Update per stdlib changes
5 files changed, 13 insertions(+), 12 deletions(-)

M examples/get.ha
M examples/poll.ha
M openssl/bio.ha
M openssl/error.ha
M openssl/ssl_ctx.ha
M examples/get.ha => examples/get.ha +1 -1
@@ 4,7 4,7 @@ use fmt;
use io;
use openssl;
use os;
use strings;
use types::c;

fn ssl_main(host: str, path: str) (void | openssl::error) = {
	const ctx = openssl::ctx_new_tls()?;

M examples/poll.ha => examples/poll.ha +3 -2
@@ 18,6 18,7 @@ use openssl;
use os;
use strconv;
use strings;
use types::c;
use unix::poll;

fn send(out: io::handle, fmt: str, params: fmt::field...) void = {


@@ 32,7 33,7 @@ fn printlines(buf: *[]u8) void = {
	for (true) {
		match (bytes::index(*buf, '\n': u8)) {
		case let index: size =>
			fmt::println(">", strings::fromutf8(buf[..index]))!;
			fmt::println(">", strings::fromutf8(buf[..index])!)!;
			delete(buf[..index + 1]);
		case void =>
			break;


@@ 90,7 91,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)!) {
			case let b: []u8 =>
				yield strings::fromutf8(b);
				yield strings::fromutf8(b)!;
			case io::EOF =>
				break;
			};

M openssl/bio.ha => openssl/bio.ha +1 -1
@@ 1,6 1,6 @@
use fmt;
use io;
use strings;
use types::c;

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

M openssl/error.ha => openssl/error.ha +4 -4
@@ 1,4 1,4 @@
use strings;
use types::c;

// OpenSSL error.
export type error = !u64;


@@ 7,8 7,8 @@ export type error = !u64;
export fn strerror(err: error) const str = {
	// TODO: can we get away without this call?
	match (c_ERR_reason_error_string(err)) {
	case let s: *const char =>
		return strings::fromc(s);
	case let s: *const c::char =>
		return c::tostr(s)!;
	case null =>
		return "No error";
	};


@@ 33,4 33,4 @@ fn wrapctrl(i: i64) (i64 | error) = {

@symbol("ERR_get_error") fn c_ERR_get_error() u64;
@symbol("ERR_reason_error_string") fn c_ERR_reason_error_string(
	err: u64) nullable *const char;
	err: u64) nullable *const c::char;

M openssl/ssl_ctx.ha => openssl/ssl_ctx.ha +4 -4
@@ 1,4 1,4 @@
use strings;
use types::c;

// An SSL context (opaque).
export type SSL_CTX = void;


@@ 33,9 33,9 @@ export fn load_verify_locations(
	ca_path: const str,
) (void | error) = {
	// TODO: error handling
	const ca_file = strings::to_c(ca_file);
	const ca_file = c::fromstr(ca_file);
	defer free(ca_file);
	const ca_path = if (len(ca_path) > 0) strings::to_c(ca_path) else null;
	const ca_path = if (len(ca_path) > 0) c::fromstr(ca_path) else null;
	defer free(ca_path);

	wrapint(c_SSL_CTX_load_verify_locations(ctx, ca_file, ca_path))?;


@@ 54,6 54,6 @@ export fn bio_new_ssl_connect(ctx: *SSL_CTX) (*BIO | error) = {
@symbol("SSL_CTX_new") fn c_SSL_CTX_new(meth: *const SSL_METHOD) nullable *SSL_CTX;
@symbol("TLS_method") fn c_TLS_method() *const SSL_METHOD;
@symbol("SSL_CTX_load_verify_locations") fn c_SSL_CTX_load_verify_locations(
	ctx: *SSL_CTX, CAfile: *const char, CApath: nullable *const char) int;
	ctx: *SSL_CTX, CAfile: *const c::char, CApath: nullable *const c::char) int;
@symbol("SSL_CTX_free") fn c_SSL_CTX_free(ctx: *SSL_CTX) void;
@symbol("BIO_new_ssl_connect") fn c_BIO_new_ssl_connect(ctx: *SSL_CTX) nullable *BIO;