explain_ftell_or_die(3)
β¨ 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 theftell(3)system call for you. and if it fails? bestie, it prints an explanation tostderr(which it gets from theexplain_ftell(3)function, iconic) and then the process terminates by callingexit(EXIT_FAILURE). that's the "or die" part. she's dramatic and she means it. πexplain_ftell_on_errorβ same deal, calls theftell(3)system call, and on failure it also prints an explanation tostderr, also obtained from theexplain_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 π₯
ftell(3)β get stream positionexplain_ftell(3)β explainftell(3)errorsexit(2)β terminate the calling process
π COPYRIGHT π
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
- debian bookworm: libexplain-dev 1.4.D001-12+b1 Β· LGPL-3.0-or-later
- debian trixie: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- ubuntu jammy: libexplain-dev 1.4.D001-12 Β· LGPL-3.0-or-later
- ubuntu noble: libexplain-dev 1.4.D001-13 Β· LGPL-3.0-or-later
- ubuntu resolute: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- Copyright (C) 2010, 2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms