BIO_PRINTF(3SSL)

✨ BIO_PRINTF(3SSL) ✨

okay bestie, welcome to the OpenSSL manual page for BIO_printf and its little squad πŸ’– we're doing formatted output, but make it BIO. stay with me, this one's short and honestly kinda iconic.


🌸 NAME 🌸

BIO_printf, BIO_vprintf, BIO_snprintf, BIO_vsnprintf β€” formatted output to a BIO. yes. all four. they're a package deal 🫢


πŸŽ€ 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);

like, look at them. so clean. so demure πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so BIO_printf() is giving regular C printf() energy, except the output doesn't go to standard output β€” it goes to the BIO you hand it, aka bio. and yes bestie, all the common format specifiers are supported ✨

then there's BIO_vprintf(), which is the vprintf()-coded cousin you'll find on lots of platforms. same deal: the output goes to the BIO you named, bio, not standard output. all common format specifiers work here too. the args argument is a stdarg argument list, so it's the one you'd reach for when you're passing varargs along 🌈

BIO_snprintf() exists for the platforms that are out here not having the common snprintf() function 😭 it's like sprintf(), except the size parameter n tells it how big the output buffer is. protect the buffer. periodt.

and BIO_vsnprintf() is to BIO_snprintf() what BIO_vprintf() is to BIO_printf(). matching set fr fr πŸ’–


⭐ RETURN VALUES ⭐

all of these functions return the number of bytes written, or -1 on error. and for BIO_snprintf() and BIO_vsnprintf() specifically, that -1 situation includes when the output buffer is too small πŸ‘€ like, not enough room = error, bestie.


πŸ’œ NOTES πŸ’œ

here's the detail that matters, no cap:

unless n is 0, both BIO_snprintf() and BIO_vsnprintf() always terminate their output with '\0'. yes, even in the cases where -1 is returned β€” including when there's not enough space to output the whole string. so the null's still showing up to the party even when the string couldn't fit πŸŽ€


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>.


and that's the whole page, bestie 🫢 this was OpenSSL BIO_PRINTF(3SSL), version 4.0.3, dated 2026-09-29 β€” go format something cute, and remember to size your buffers πŸ’–βœ¨

πŸ“¦ where this page comes from