BIO_printf, BIO_vprintf, BIO_snprintf, BIO_vsnprintf - formatted output to a BIO
#include <openssl/bio.h>
int BIO_printf(BIO *bio, const char *format, ...); int BIO_vprintf(BIO *bio, const char *format, va_list args);
Deprecated since OpenSSL 4.1, can be hidden entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):
int BIO_snprintf(char *buf, size_t n, const char *format, ...); int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args);
BIO_printf() is similar to the standard C printf() function, except that
the output is sent to the specified BIO, bio, rather than standard
output. All common format specifiers are supported.
BIO_vprintf() is similar to the vprintf() function found on many platforms,
the output is sent to the specified BIO, bio, rather than standard
output. All common format specifiers are supported. The argument
list args is a stdarg argument list.
BIO_snprintf() and BIO_vsnprintf() were provided when not every supported
platform shipped a C99 snprintf() implementation. That is no longer the
case: every supported build target provides C99 snprintf(), and new code
should use the standard library functions directly. BIO_snprintf() and
BIO_vsnprintf() are retained for source compatibility but are deprecated
as of OpenSSL 4.1.
BIO_snprintf() and BIO_vsnprintf() have the same signatures as snprintf()
and vsnprintf() but they do not have the same return value on truncation.
When the formatted output would exceed n bytes, snprintf() returns the
number of bytes that would have been written had the buffer been large
enough, while BIO_snprintf() and BIO_vsnprintf() return -1. Because the
functions look identical at the call site, callers reach for the standard
C99 idiom by reflex, and the divergence becomes a source of bugs. New
code should call snprintf() and vsnprintf() directly.
BIO_printf() and BIO_vprintf() return the number of bytes written, or
-1 on error.
BIO_snprintf() and BIO_vsnprintf() return the number of bytes written to
buf (excluding the terminating '\0') on success, or -1 if the
formatted output would not fit in n bytes or on other error.
When n is greater than 0, BIO_snprintf() and BIO_vsnprintf() always
terminate buf with '\0', including in the truncation case where -1
is returned.
BIO_snprintf() and BIO_vsnprintf() were deprecated in OpenSSL 4.1. Callers
should use the standard C library functions snprintf() and vsnprintf()
instead.
Copyright 2017-2026 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.