LIBXO(3)
β¨ LIBXO(3) β the manual, but make it cute β¨
okay so bestie, we're in the Library Functions Manual today and we're talking about LIBXO(3) β the marker functions. yes, the ones that gatekeep your closing calls. let's get into it π
πΈ NAME πΈ
xo_open_marker, xo_open_marker_h, xo_close_marker, xo_close_marker_h β the little icons that prevent (and allow) closing of open constructs. like, they literally decide what's allowed to close and what isn't. no cap.
π LIBRARY π
library βlibxoβ β that's the one, that's the girl π«Ά
π SYNOPSIS π
#include <libxo/xo.h>
xo_ssize_t
xo_open_marker(const char *name);
xo_ssize_t
xo_open_marker_h(xo_handle_t *handle, const char *name);
xo_ssize_t
xo_close_marker(const char *name);
xo_ssize_t
xo_close_marker_h(xo_handle_t *handle, const char *name);
π DESCRIPTION π
so here's the tea, bestie. libxo represents hierarchy using exactly two constructs: βcontainersβ and βlistsβ. that's it, that's the whole architecture, iconic.
A marker can be used to affect how open constructs get closed β either by preventing their closure (implicit or explicit) or by forcing their closure. While a marker is open, no other open constructs can be closed. and when a marker is closed? every construct that opened since that marker was opened gets closed too. it's giving "you came in with me, you leave with me" energy π€
A marker basically βfreezesβ any open constructs. Calls to xo_close_*() functions that would normally close them just get ignored β effectively blocking their closure. like, blocked. blocked blocked. π
However! when xo_close_marker() is called, any containers, lists, or leaf-lists opened since the matching xo_open_marker() call will be closed and the marker discarded. periodt.
Markers use names which are not user-visible, which means the caller gets to pick whatever internal names they want. the marker itself has no value and is not emitted in any form. it's a silent icon, a behind-the-scenes queen, we love that for her π
To open a marker, call xo_open_marker() or xo_open_marker_h(). the former uses the default handle, and the latter accepts a specific handle. choose your fighter π
To close a marker, use the xo_close_marker() or xo_close_marker_h() functions.
Each open call must have a matching close call. every single one. no skipping. i'm watching π
π the example where the marker blocks a close π
In this example, the xo_close_container() call on line [1] will be ignored, since the open marker "outer" will prevent close of any open constructs that precede it. The xo_close_marker() call on line [2] will close the "system" container, since it was opened after the "outer" marker.
Example:
xo_open_container("top");
xo_open_marker("outer");
xo_open_container("system");
xo_emit("{:host-name/%s%s%s", hostname,
domainname ? "." : "", domainname ?: "");
xo_close_container("top"); /* [1] */
xo_close_marker("outer"); /* [2] */
xo_close_container("top");
π§ the example where we whiffle through fish π§
In this example, the code whiffles through a list of fish, calling a function to emit details about each fish. The marker "fish-guts" is used to ensure that any constructs opened by the function are closed properly. clean-up on aisle fish π β¨
for (i = 0; fish[i]; i++) {
xo_open_instance("fish");
xo_open_marker("fish-guts");
dump_fish_details(i);
xo_close_marker("fish-guts");
}
π SEE ALSO π
go read your sisters, they're slay too π
π HISTORY π
The libxo library first appeared in FreeBSD 11.0. a debut, a moment, a cultural reset π
π AUTHORS π
libxo was written by Phil Shafer <phil@freebsd.org>. thank you king π«‘
π¦ 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
β HISTORY (the second one, yes there are two, and yes we're doing both) β
The libxo library was added in FreeBSD 11.0. same era, different sentence. she said it twice because it's that important π
π AUTHOR π
Phil Shafer
and that's the whole page bestie!! this one shipped on Debian, dated January 22, 2015, tagged LIBXO(3) β mwah, go open a marker and freeze something, ily πβ¨
π¦ where this page comes from
- epel 9: libxo-devel 1.7.5-1.el9 Β· LicenseRef-Callaway-BSD
- fedora 43: libxo-devel 1.7.5-2.fc43 Β· LicenseRef-Callaway-BSD
- fedora 43: libxo-devel 1.7.5-2.fc43 Β· LicenseRef-Callaway-BSD
- fedora 44: libxo-devel 1.7.5-3.fc44 Β· LicenseRef-Callaway-BSD
- fedora 44: libxo-devel 1.7.5-3.fc44 Β· LicenseRef-Callaway-BSD
- nixpkgs unstable: libxo 1.7.5
- Copyright (c) 2015, Juniper Networks, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms