LIBXO(3)
π LIBXO(3) β okay bestie, itβs giving Library Functions Manual energy π
Hiiii so this is LIBXO(3) from the Library Functions Manual, and itβs lowkey a tiny page with one very specific job: adding attribute name/value pairs to formatted output. Slay. β¨
π NAME π
xo_attr, xo_attr_h, xo_attr_hv β Add attribute name/value pairs to formatted output. π
π LIBRARY π
library βlibxoβ β thatβs the library, bestie. π¦
β¨ SYNOPSIS β¨
#include <libxo/xo.h>
xo_ssize_t
xo_attr(const char *name, const char *fmt, ...);
xo_ssize_t
xo_attr_h(xo_handle_t *handle, const char *name, const char *fmt, ...);
xo_ssize_t
xo_attr_hv(xo_handle_t *handle, const char *name, const char *fmt,
va_list vap);
π DESCRIPTION π
Okay so xo_attr() emits attributes for the XML output style β yes, XML specifically, no cap. The attribute value gets recorded in the handle and is attached to the next field that is emitted via a xo_emit(3) call. Thatβs the whole vibe. π«Ά
The name parameter gives the name of the attribute to be encoded. The fmt parameter gives a printf-style format string used to format the value of the attribute using any remaining arguments, or the vap parameter as passed to xo_attr_hv(). Cute, right? π
Hereβs the example, preserved exactly because we do not play with code:
xo_attr("seconds", "%ld", (unsigned long) login_time);
struct tm *tmp = localtime(login_time);
strftime(buf, sizeof(buf), "%R", tmp);
xo_emit("Logged in at {:login-time}\n", buf);
XML:
<login-time seconds="1408336270">00:14</login-time>
And remember: since attributes are only emitted in XML, their use should be limited to meta-data and additional or redundant representations of data already emitted in other form. Thatβs the caveat, bestie β donβt make it weird. π
π SEE ALSO π
xo_emit(3)β the emit call your attribute is waiting to attach to. πlibxo(3)β the library page itself. π
π°οΈ HISTORY π°οΈ
The libxo library first appeared in FreeBSD 11.0. Vintage-ish. β¨
π AUTHORS π
libxo was written by Phil Shafer <phil@freebsd.org>. Iconic. π
Source/version: Debian. Date: July, 2014. Page: LIBXO(3). π
π¦ 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