LIBXO(3)
π LIBXO(3) β ok so hear me out
bestie, we're in section 3 of the manual (that's library functions for the uninitiated π) and today's topic is libxo's marker functions. yes, the whole page is about markers. no, i'm not gonna make it boring. let's go π
β¨ NAME β¨
xo_open_marker, xo_open_marker_h, xo_close_marker, xo_close_marker_h β the girlies that prevent and allow closing of open constructs. literally the bouncers of your output tree π«Ά
π LIBRARY π
library βlibxoβ β she's the moment, she's the icon π
πΈ 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);
not me listing all four signatures exactly as they are π copy them character for character, i don't make the rules (i do, actually, and that's the rule).
π¦ DESCRIPTION π¦
okay so first, the lore π§: libxo represents hierarchy using two constructs β βcontainersβ and βlistsβ. that's the whole family tree.
a marker is what you use to affect how open constructs get closed. two ways, pick your fighter:
- by preventing their closure (implicit or explicit, both count)
- by forcing their closure
π while a marker is open, no other open constructs can be closed. like, none. zero. the door is LOCKED.
and when a marker is closed? all constructs open since the marker was opened will be closed. everything. all of it. periodt.
so think of a marker as a way to "freeze" any open constructs βοΈ. calls to xo_close_*() functions that would normally close them get ignored β effectively blocking their closure. no cap, they just get ghosted π.
but the second you call xo_close_marker(), any containers, lists, or leaf-lists opened since the matching xo_open_marker() call get closed, and the marker itself gets discarded. bye bestie π
markers use names which are not user-visible β so you get to pick whatever internal names feel right to you. no one's watching, go feral π. the marker has no value and is not emitted in any form. it's giving invisible main character energy.
π opening & closing, the basics
to open a marker, call xo_open_marker() or xo_open_marker_h().
- the former uses the default handle
- the latter accepts a specific handle
to close a marker, use the xo_close_marker() or xo_close_marker_h() functions.
β and fr fr: each open call must have a matching close call. that's the vibe check. don't leave her hanging π
π example one β the "outer" marker
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. lowkey rude of it but okay.
the xo_close_marker() call on line [2] will close the "system" container, since it was opened after the "outer" marker. slay, order matters π
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");
π§ββοΈ example two β the "fish-guts" agenda
in this example, the code whiffles through a list of fish (yes, whiffles, that's the technical term, i don't make the words i just deliver them π ), 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. iconic safety net behavior honestly π₯Ή
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 them, i'll wait π
π HISTORY π
the libxo library first appeared in FreeBSD 11.0. a legend was born β¨
π«Ά AUTHORS π«Ά
libxo was written by Phil Shafer <phil@freebsd.org>. thank you phil, king behavior ππ
and that's the page bestie!! this edition came to you from Debian, dated January 22, 2015, and it's filed under LIBXO(3) in case you need to find her again πΈ mwah π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2015, Juniper Networks, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms