LIBXO(3)

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

🌸 LIBXO(3) 🌸

okay bestie, welcome to the libxo manual page β€” library functions manual, if we're being formal πŸ’…


✨ NAME ✨

xo_err, xo_errc, xo_errx xo_warn, xo_warnx, xo_warn_c, xo_warn_hc β€” these bad boys emit errors and warnings in multiple output styles πŸŽ€


πŸ“š LIBRARY πŸ“š

the library is literally called "libxo" β€” that's the whole vibe πŸ¦‹


⭐ SYNOPSIS ⭐

#include <libxo/xo.h>

void
xo_warn(const char *fmt, ...);

void
xo_warnx(const char *fmt, ...);

void
xo_warn_c(int code, const char *fmt, ...);

void
xo_warn_hc(xo_handle_t *xop, int code, const char *fmt, ...);

void
xo_err(int eval, const char *fmt, ...);

void
xo_errc(int eval, int code, const char *fmt, ...);

void
xo_errx(int eval, const char *fmt, ...);

πŸ’– DESCRIPTION πŸ’–

okay so picture this: so many programs out there are leaning on the standard library functions err(3) and warn(3) to spit out errors and warnings for the user. and libxo? it wants to pass all that info along via the current output style instead, so it gives you these compatible functions to make that happen. honestly, iconic behavior πŸ‘‘

so the fmt argument β€” heads up, it's compatible with printf(3), not with xo_emit(3). the whole point is to make simple conversion easy peasy. which means... yeah, these functions make unstructured data πŸ™ˆ. if you want structured data, you're gonna wanna use the xo_emit_err(3) functions instead, no cap.

here's what these functions actually display, in order:

  1. the program name
  2. a colon
  3. a formatted message based on the arguments
  4. and then optionally a colon plus an error message associated with either errno or the code parameter

and here's the EXAMPLE: they gave us, chef's kiss:

if (open(filename, O_RDONLY) < 0)
    xo_err(1, "cannot open file '%s'", filename);

πŸ¦‹ SEE ALSO πŸ¦‹


🌈 HISTORY 🌈

the libxo library first appeared in FreeBSD 11.0 β€” a whole era ⭐


πŸ‘‘ AUTHORS πŸ‘‘

libxo was written by Phil Shafer <phil@freebsd.org> β€” thank you for your service, king 🫢


aaaand that's the page, bestie!! this one's from Debian, dated December 4, 2014, version LIBXO(3) β€” mwah, go forth and emit responsibly πŸ’œπŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from