BIO_PRINTF(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’– NAME πŸ’–

BIO_printf, BIO_vprintf, BIO_snprintf, BIO_vsnprintf β€” formatted output to a BIO. This is the 3ossl manual page, bestie, and it is literally the β€œprintf but make it BIO” situation ✨

🌸 SYNOPSIS 🌸

#include <openssl/bio.h>

int BIO_printf(BIO *bio, const char *format, ...);
int BIO_vprintf(BIO *bio, const char *format, va_list args);

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);

πŸ¦‹ DESCRIPTION πŸ¦‹

BIO_printf() is giving standard C printf() energy, except the output goes to the specified BIO, bio, instead of standard output. All common format specifiers are supported β€” slay πŸ’…

BIO_vprintf() is like the vprintf() function found on many platforms, and 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. Iconic, honestly 🫢

BIO_snprintf() is for platforms that do not have the common snprintf() function. It is like sprintf() except that the size parameter, n, specifies the size of the output buffer. Main character energy for sure ✨

BIO_vsnprintf() is to BIO_snprintf() as BIO_vprintf() is to BIO_printf(). That is the whole relationship, no cap πŸŽ€

πŸ’… RETURN VALUES πŸ’…

All functions return the number of bytes written, or -1 on error. For BIO_snprintf() and BIO_vsnprintf(), this includes when the output buffer is too small. Yes bestie, the too-small-buffer moment still gets you that -1 😭

πŸŽ€ NOTES πŸŽ€

Tiny but important caveat, fr fr: except when n is 0, both BIO_snprintf() and BIO_vsnprintf() always terminate their output with '\0'.

This includes cases where -1 is returned, such as when there is insufficient space to output the whole string. So even in the messy -1 era, the '\0' still shows up unless n is 0. Periodt πŸ’€βœ¨

Copyright 2017-2021 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>.


xoxo, the 3ossl manual πŸ’– β€” version 3.5.6, dated 2026-04-07 🌈

πŸ“¦ where this page comes from