explain_ftell_or_die(3)

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

✨ explain_ftell_or_die β€” the ftell(3) glow-up bestie πŸ’–

okay so this is explain_ftell_or_die(3), from the Library Functions Manual, and it's genuinely one of my faves because it does the exact thing you already wanted ftell(3) to do, but with ✨consequences✨. no cap.


🌸 SYNOPSIS 🌸

#include <libexplain/ftell.h>
long explain_ftell_or_die(FILE *fp);
long explain_ftell_on_error(FILE *fp);

πŸ’… DESCRIPTION πŸ’…

so there are two functions here and they're siblings, not twins. let's get into it 🫢

  • explain_ftell_or_die β€” this one calls the ftell(3) system call for you. and if it fails? bestie, it prints an explanation to stderr (which it gets from the explain_ftell(3) function, iconic) and then the process terminates by calling exit(EXIT_FAILURE). that's the "or die" part. she's dramatic and she means it. πŸ’€
  • explain_ftell_on_error β€” same deal, calls the ftell(3) system call, and on failure it also prints an explanation to stderr, also obtained from the explain_ftell(3) function. BUT. she still returns to the caller. no exit, no drama, just the tea and a return value. 🌈

fp β€” the fp, exactly as to be passed to the ftell(3) system call. like, literally, don't get creative with it, just hand it over as-is. πŸ’œ


⭐ RETURN VALUE ⭐

explain_ftell_or_die only returns on success β€” peep ftell(3) for more info on that. on failure it prints an explanation and exits, so it does not return. she said "I'm leaving" and she left. πŸŽ€

explain_ftell_on_error always returns the value return by the wrapped ftell(3) system call. always. every time. πŸ’«


πŸ¦‹ EXAMPLE πŸ¦‹

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

long result = explain_ftell_or_die(fp);

that's it. that's the whole vibe. πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯


libexplain version 1.4

Copyright (C) 2010 Peter Miller


okay that's the whole page, bestie, you're officially fluent in explain_ftell_or_die(3) πŸ’– go forth and never wonder why your ftell returned -1 ever again. mwah. πŸŽ€βœ¨πŸ¦‹

libexplain version 1.4 🌸 Copyright (C) 2010 Peter Miller β€” that's the source, the version and the date, all wrapped up with a bow, ty for coming to my ted talk πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from