From 0cc81ff04f7364183f97ce2ca573a56fbfe3d156 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Tue, 15 Jul 2014 16:26:34 -0700 Subject: [PATCH] Add functions for setting a BIO callback and arg. These were omitted, but are needed by Chromium now. Change-Id: I17e1672674311c8dc2ede21539c82b8e2e50f376 Reviewed-on: https://boringssl-review.googlesource.com/1201 Reviewed-by: Adam Langley --- crypto/bio/bio.c | 12 ++++++++++++ include/openssl/bio.h | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/crypto/bio/bio.c b/crypto/bio/bio.c index d9f7f40db..11e4f65fb 100644 --- a/crypto/bio/bio.c +++ b/crypto/bio/bio.c @@ -359,6 +359,18 @@ int BIO_set_close(BIO *bio, int close_flag) { return BIO_ctrl(bio, BIO_CTRL_SET_CLOSE, close_flag, NULL); } +void BIO_set_callback(BIO *bio, bio_info_cb callback_func) { + bio->callback = callback_func; +} + +void BIO_set_callback_arg(BIO *bio, char *arg) { + bio->cb_arg = arg; +} + +char *BIO_get_callback_arg(const BIO *bio) { + return bio->cb_arg; +} + BIO *BIO_push(BIO *bio, BIO *appended_bio) { BIO *last_bio; diff --git a/include/openssl/bio.h b/include/openssl/bio.h index 83607e1bc..af3789efa 100644 --- a/include/openssl/bio.h +++ b/include/openssl/bio.h @@ -244,6 +244,18 @@ size_t BIO_wpending(const BIO *bio); * otherwise. */ int BIO_set_close(BIO *bio, int close_flag); +/* BIO_set_callback sets a callback function that will be called before and + * after most operations. See the comment above |bio_info_cb|. */ +void BIO_set_callback(BIO *bio, bio_info_cb callback_func); + +/* BIO_set_callback_arg sets the opaque pointer value that can be read within a + * callback with |BIO_get_callback_arg|. */ +void BIO_set_callback_arg(BIO *bio, char *arg); + +/* BIO_get_callback_arg returns the last value of the opaque callback pointer + * set by |BIO_set_callback_arg|. */ +char *BIO_get_callback_arg(const BIO *bio); + /* Managing chains of BIOs. *