LIBXO(3)
π 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 theXOF_CLOSE_FPflag to trigger a call tofclose(3)for theFILEpointer when the handle is destroyed. No flag, nofclose. π
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: callingxo_destroy()with aNULLhandle will release any resources associated with the default handle. Yes, evenNULLhas 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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2014, Juniper Networks, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms