LIBXO(3)

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

πŸ’… LIBXO(3) β€” xo_parse_args, xo_set_program πŸ’…

okay so bestie, this is LIBXO(3) from the Library Functions Manual. we're about to get into the two functions that detect, parse, and remove arguments for libxo. it's giving utility, it's giving group-chat explainer. πŸŽ€

✨ NAME ✨

xo_parse_args, xo_set_program β€” detect, parse, and remove arguments for libxo. periodt. πŸ’…

πŸ“š LIBRARY πŸ“š

It's the library β€œlibxo” β€” yes, that one. πŸ¦‹

πŸ› οΈ SYNOPSIS πŸ› οΈ

#include <libxo/xo.h>

int
xo_parse_args(int argc, char **argv);

int
xo_set_program(const char *name);

πŸŒ€ DESCRIPTION πŸŒ€

okay so xo_parse_args() is the function that processes command-line arguments β€” the ones described in xo_options(7). it processes the libxo-specific options and removes them from the argument list, so the calling application does not need to process them. if it's successful, you get a new value for argc back. on failure, it emits a message and returns -1. 😭

like this, bestie:

argc = xo_parse_args(argc, argv);
if (argc < 0)
    exit(EXIT_FAILURE);

after the call to xo_parse_args(), the application can process the remaining arguments in a normal manner. no cap. πŸ’–

xo_set_program() sets the name of the program as reported by functions like xo_failure(), xo_warn(), xo_err(), etc. the program name is initialized by xo_parse_args(), but subsequent calls to xo_set_program() can override this value. 🌸

⚠️ important note: the value is not copied, so the memory passed to xo_set_program() (and xo_parse_args()) must be maintained by the caller. don't let it get freed, bestie β€” protect that memory. 🫢

πŸ‘€ SEE ALSO πŸ‘€

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

The libxo library first appeared in FreeBSD 11.0. iconic. ⭐

πŸ‘‘ AUTHORS πŸ‘‘

libxo was written by Phil Shafer <phil@freebsd.org>. periodt. πŸ’œ


Debian β€’ November 17, 2020 β€’ LIBXO(3) β€” that's the footer, bestie, and we are so done. πŸŽ€

πŸ“¦ where this page comes from