BIO_set_fp function

  1. @RecordUse.new()
  2. @Native<Int Function(Pointer<BIO>, Pointer<FILE>, Int)>(ffi.Pointer<BIO>, ffi.Pointer<FILE>, ffi.Int)>(symbol: 'bssl_dart_BIO_set_fp')
int BIO_set_fp(
  1. Pointer<BIO> bio,
  2. Pointer<FILE> file,
  3. int flags
)

BIO_set_fp sets the |FILE| for |bio|. If |flags| contains |BIO_CLOSE| then |fclose| will be called on |file| when |bio| is closed. It returns one on success and zero otherwise.

On Windows, if |flags| contains |BIO_FP_TEXT|, this function will additionally switch |file| to text mode. This is not recommended, but may be required for OpenSSL compatibility. If |file| was not already in text mode, mode changes can cause unflushed data in |file| to be written in unexpected ways. See |_setmode| in Windows documentation for details.

Unlike OpenSSL, if |flags| does not contain |BIO_FP_TEXT|, the translation mode of |file| is left as-is. In OpenSSL, |file| will be set to binary, with the same pitfalls as above. BoringSSL does not do this so that wrapping a |FILE| in a |BIO| will not inadvertently change its state.

To avoid these pitfalls, callers should set the desired translation mode when opening the file. If targeting just BoringSSL, this is sufficient. If targeting both OpenSSL and BoringSSL, callers should set |BIO_FP_TEXT| to match the desired state of the file.

Implementation

@meta.RecordUse()
@ffi.Native<ffi.Int Function(ffi.Pointer<BIO>, ffi.Pointer<FILE>, ffi.Int)>(
  symbol: 'bssl_dart_BIO_set_fp',
)
external int BIO_set_fp(
  ffi.Pointer<BIO> bio,
  ffi.Pointer<FILE> file,
  int flags,
);