LIBXO(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… LIBXO(3) β€” Library Functions Manual

Okay bestie, listen up, because this one is lowkey the origin story. This is the libxo page β€” from the Library Functions Manual β€” and it's all about how you create and destroy libxo output handles. Birth and death of a handle, the whole arc, main character energy from start to finish. πŸ¦‹


✨ NAME ✨

xo_create, xo_create_to_file, xo_destroy β€” create and destroy libxo output handles

πŸ“š LIBRARY πŸ“š

library β€œlibxo”

🧚 SYNOPSIS 🧚

#include <libxo/xo.h>

xo_handle_t *
xo_create(unsigned style, unsigned flags);

xo_handle_t *
xo_create_to_file(FILE *fp, unsigned style, unsigned flags);

void
xo_destroy(xo_handle_t *handle);

🌸 DESCRIPTION 🌸

So a libxo handle? You allocate that thing with the xo_create() function. That's it. That's the whole vibe. πŸ’«

Example, because we love a visual:

xo_handle_t *xop = xo_create(XO_STYLE_JSON, XOF_WARN);
....
xo_emit_h(xop, "testing\n");

Now, by default, libxo writes output to standard output. That's the default, that's the moment. But the devs knew sometimes you wanna write somewhere else, so they handed us a convenience function for exactly those situations where output should go to a different file. Besties who plan ahead. 🫢

Heads up, and this matters: use the XOF_CLOSE_FP flag to trigger a call to fclose(3) for the FILE pointer when the handle is destroyed. No flag, no fclose. πŸ‘‘

And then there's xo_destroy(), the closer. It releases a handle and any resources it is using. So thorough. So clean. ✨

Little plot twist tho: calling xo_destroy() with a NULL handle will release any resources associated with the default handle. Yes, even NULL has a job here. Not me being obsessed with the default handle's whole deal 😭

πŸ” SEE ALSO πŸ”

⭐ HISTORY ⭐

The libxo library first appeared in FreeBSD 11.0. Iconic debut, ngl. πŸ”₯

πŸ‘‘ AUTHORS πŸ‘‘

libxo was written by Phil Shafer <phil@freebsd.org>. Thank you Phil, we stan. πŸ’–


k bye bestie, that's the whole page πŸ’…

Feel free to go off and xo_create() your little heart out β€” and remember this lovely little artifact comes to you from Debian, dated December 4, 2014. Vintage. Iconic. Periodt. πŸŽ€πŸ’œ

πŸ“¦ where this page comes from