LIBXO(3)

πŸ“¦
version 1.7.5 Β· 2 versions
, in epel 9, fedora 43, fedora 44, nixpkgs unstable

✨ LIBXO(3) ✨

okay bestie, this one's from the Library Functions Manual and it's literally about making your errors and warnings not be boring. we're talking πŸ’– xo_err, xo_errc, xo_errx, xo_warn, xo_warnx, xo_warn_c, and xo_warn_hc β€” the whole friend group πŸ’…

🌸 NAME 🌸

xo_err, xo_errc, xo_errx, xo_warn, xo_warnx, xo_warn_c, xo_warn_hc β€” emit errors and warnings in multiple output styles 🫢

πŸ“š LIBRARY πŸ“š

library β€œlibxo”

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

so like, so many programs out here are using the standard library besties err(3) and warn(3) to throw errors and warnings at the user. totally valid. but libxo said "not me ignoring the current output style" 😀 β€” it wants to pass all that info through the current output style, and it hands you compatible functions so you can do exactly that. iconic behavior, honestly.

the fmt argument is one that plays nice with printf(3) rather than xo_emit(3), and that's on purpose β€” it makes simple conversion ✨ effortless ✨. but lowkey important: this means these functions make unstructured data. if you want structured data, you gotta go use the xo_emit_err(3) functions instead. different vibe, different function, no cap.

so what do these do when you call them? they display:

  • the program name
  • a colon
  • a formatted message based on the arguments
  • and then optionally a colon and an error message associated with either errno or the code parameter πŸ¦‹

EXAMPLE:

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

πŸ‘€ SEE ALSO πŸ‘€

xo_emit(3), xo_emit_err(3), libxo(3)

πŸ•°οΈ HISTORY πŸ•°οΈ

the libxo library first appeared in FreeBSD 11.0. a whole era, fr fr 🌈

πŸ‘‘ AUTHORS πŸ‘‘

libxo was written by Phil Shafer <phil@freebsd.org>. we stan 🫢

πŸ“– ADDITIONAL DOCUMENTATION πŸ“–

FreeBSD uses libxo version 1.7.5. the complete documentation can be found on github, bestie:

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 libxo library was added in FreeBSD 11.0. yes it's listed twice, and yes, it's still true both times πŸ’€βœ¨

✍️ AUTHOR ✍️

Phil Shafer


and that's the whole page, bestie! this one came from Debian, dated December 4, 2014, and it's filed under LIBXO(3) in the manual. go forth and make your errors pretty πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from