explain_strtol_or_die(3)

πŸ“¦
version 1.4.D001 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

πŸ’– explain_strtol_or_die β€” like, the manual page, but make it make sense πŸ’–

okay bestie, welcome to explain_strtol_or_die(3) from the Library Functions Manual ✨ this one lives in libexplain and it's literally here to turn a string into a long and then tell you exactly what went wrong if it can't. no cap. 🫢


✨ NAME ✨

explain_strtol_or_die β€” convert a string to a long integer and report errors πŸ¦‹


🌸 SYNOPSIS 🌸

#include <libexplain/strtol.h>
long explain_strtol_or_die(const char *nptr, char **endptr, int base);
long explain_strtol_on_error(const char *nptr, char **endptr, int base))
yes the second one has a spare ) at the end. that's how it's printed. i am not touching it, that's canon πŸ’…

πŸ’œ DESCRIPTION πŸ’œ

So there's two functions here and they're basically siblings, okay? One is the dramatic one and one is the chill one. 🌈

The explain_strtol_or_die function is used to call the strtol(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_strtol(3) function, and then the process terminates by calling exit(EXIT_FAILURE). like. it's over. it said what it said. πŸ’€

The explain_strtol_on_error function is used to call the strtol(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_strtol(3) function, but still returns to the caller. so it also tells you everything, but it lets you keep living your life. main character energy but polite. πŸ‘‘

πŸŽ€ the arguments, bestie

  • nptr β€” the nptr, exactly as to be passed to the strtol(3) system call. exact same one, no edits, no remix.
  • endptr β€” the endptr, exactly as to be passed to the strtol(3) system call. again: verbatim, untouched, iconic.
  • base β€” the base, exactly as to be passed to the strtol(3) system call. yes queen, pass it straight through. ✨

⭐ RETURN VALUE ⭐

The explain_strtol_or_die function only returns on success, see strtol(3) for more information. On failure, prints an explanation and exits, it does not return. like, does not. don't sit there waiting for it, it already left the group chat. 😭

The explain_strtol_on_error function always returns the value return by the wrapped strtol(3) system call. always. every single time. 🫢


🌟 EXAMPLE 🌟

The explain_strtol_or_die function is intended to be used in a fashion similar to the following example:

long result = explain_strtol_or_die(nptr, endptr, base);

that's it. that's the whole vibe. one line, does the thing, explains itself if it can't. obsessed. πŸ’–


πŸ¦‹ SEE ALSO πŸ¦‹


libexplain version 1.4 Copyright (C) 2009 Peter Miller


and that's the whole page, bestie πŸŽ€ this was explain_strtol_or_die(3), page number 3, straight out of the Library Functions Manual β€” libexplain version 1.4, copyright 2009 Peter Miller, and the footer says the exact same title again because symmetry is slay πŸ’…βœ¨ go forth and convert strings responsibly, mwah πŸ«ΆπŸ’–

πŸ“¦ where this page comes from