LIBXO(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… 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