LIBXO(3)

πŸ“¦
version 1.7.5 Β· 2 versions
, in epel 9, fedora 43, fedora 44, nixpkgs unstable

πŸ’– LIBXO(3) πŸ’–

okay bestie, welcome to the libxo(3) manual page β€” yes that's the library manual, and no we are not skipping anything, we're doing the whole thing πŸ’…


✨ NAME ✨

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

like... literally what it says. you make a handle, you unmake a handle. that's the whole arc.


🌸 LIBRARY 🌸

library β€œlibxo” β€” that's the vibe, that's the whole vibe πŸ¦‹


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

look at those signatures. gorgeous. no notes. πŸ‘‘


πŸ’œ DESCRIPTION πŸ’œ

so a libxo handle can be allocated using the xo_create() function. that's the main character move, that's how you start everything.

Example:

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

see how we did that? XO_STYLE_JSON and XOF_WARN and then boom, xo_emit_h with your handle. iconic behavior fr fr ✨

by default, libxo writes output to standard output. very demure, very mindful. but a convenience function is provided for situations when output should be written to a different file β€” that's your xo_create_to_file() bestie, in case you were wondering 🫢

πŸ’€ heads up: use the XOF_CLOSE_FP flag to trigger a call to fclose(3) for the FILE pointer when the handle is destroyed. yes, for real, the FILE pointer gets closed. know that.

the xo_destroy() function releases a handle and any resources it is using. cleanup era 🧹

and here's the plot twist: calling xo_destroy() with a NULL handle will release any resources associated with the default handle. so even the NULL one does something. not me being shocked 😭


πŸ¦‹ SEE ALSO πŸ¦‹

go read those too, iykyk πŸ“š


🌈 HISTORY 🌈

the libxo library first appeared in FreeBSD 11.0. a classic. a legend. the origin story ⭐


πŸ‘‘ AUTHORS πŸ‘‘

libxo was written by Phil Shafer <phil@freebsd.org>. thank you for your service sir πŸ«‘πŸ’–


πŸŽ€ ADDITIONAL DOCUMENTATION πŸŽ€

FreeBSD uses libxo version 1.7.5. complete documentation can be found on github:

https://juniper.github.io/libxo/1.7.5/html/index.html

libxo lives on github as:

https://github.com/Juniper/libxo

the latest release of libxo is available at:

https://github.com/Juniper/libxo/releases

three links, all of them important, all of them slaying πŸ’…


🌸 HISTORY 🌸

(no because why are there two HISTORY sections, and yet β€” we keep them both, because the rules are the rules 😌)

the libxo library was added in FreeBSD 11.0. yeah. again. same energy. same fact. ✨


πŸ’– AUTHOR πŸ’–

Phil Shafer


and that's the whole page bestie!! this came to you from the Debian build, dated December 4, 2014, sitting pretty at LIBXO(3) β€” mwah, go create some handles πŸ’‹πŸ’–βœ¨

πŸ“¦ where this page comes from