explain_ftell(3)
π¦ explain_ftell(3) β Library Functions Manual π¦
okay so bestie, welcome to the explain_ftell(3) page π this is the manual page for explain_ftell from the Library Functions Manual, and it's about turning those cryptic ftell(3) errors into something a human can actually read. no cap, it's lowkey iconic.
β¨ NAME β¨
explain_ftell β explain ftell(3) errors
π SYNOPSIS π
#include <libexplain/ftell.h>
const char *explain_ftell(FILE *fp);
const char *explain_errno_ftell(int errnum, FILE *fp);
void explain_message_ftell(char *message, int message_size, FILE *fp);
void explain_message_errno_ftell(char *message, int message_size, int
errnum, FILE *fp);
π DESCRIPTION π
so these functions are your little translators, fr fr π«Ά you use them to get explanations for errors that come back from the ftell(3) system call. like, instead of just staring at an errno number like it's a cryptic text from a guy, you get actual words.
π explain_ftell π
const char *explain_ftell(FILE *fp);
the explain_ftell function is how you get an explanation of an error returned by the ftell(3) system call. the least the message will contain is the value of strerror(errno), but usually it does so much better than that and tells you the underlying cause in way more detail. it's giving overachiever, and we love that β¨
the errno global variable is what gets used to grab the error value that needs decoding.
fpβ the originalfp, exactly</>, as passed to theftell(3)system call. don't get creative with it.
Returns:
- the message explaining the error π this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function that shares this buffer, including other threads. so like, screenshot it, don't frame it.
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library do too. bestie, please be careful π
Example: this function is intended to be used in a fashion similar to the following example:
long result = ftell(fp);
if (result < 0)
{
fprintf(stderr, "%s\n", explain_ftell(fp));
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_ftell_or_die(3) function. slay, no boilerplate for you π
πΈ explain_errno_ftell πΈ
const char *explain_errno_ftell(int errnum, FILE *fp);
the explain_errno_ftell function is used to obtain an explanation of an error returned by the ftell(3) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. she's thorough π
errnumβ the error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. so grab it early, okay? πfpβ the originalfp, exactly as passed to theftell(3)system call.
Returns:
- the message explaining the error π this message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. this will be overwritten by the next call to any libexplain function which shares this buffer, including other threads.
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library.
Example: this function is intended to be used in a fashion similar to the following example:
long result = ftell(fp);
if (result < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_ftell(err, fp));
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_ftell_or_die(3) function.
π explain_message_ftell π
void explain_message_ftell(char *message, int message_size, FILE *fp);
the explain_message_ftell function is used to obtain an explanation of an error returned by the ftell(3) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail.
the errno global variable will be used to obtain the error value to be decoded.
messageβ the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe. periodt πmessage_sizeβ the size in bytes of the location in which to store the returned message.fpβ the originalfp, exactly as passed to theftell(3)system call.
Example: this function is intended to be used in a fashion similar to the following example:
long result = ftell(fp);
if (result < 0)
{
char message[3000];
explain_message_ftell(message, sizeof(message), fp);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_ftell_or_die(3) function.
π§ explain_message_errno_ftell π§
void explain_message_errno_ftell(char *message, int message_size, int
errnum, FILE *fp);
the explain_message_errno_ftell function is used to obtain an explanation of an error returned by the ftell(3) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail.
messageβ the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe. πmessage_sizeβ the size in bytes of the location in which to store the returned message.errnumβ the error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. do not sleep on this one πfpβ the originalfp, exactly as passed to theftell(3)system call.
Example: this function is intended to be used in a fashion similar to the following example:
long result = ftell(fp);
if (result < 0)
{
int err = errno;
char message[3000];
explain_message_errno_ftell(message, sizeof(message), err,
fp);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
the above code example is available preβpackaged as the explain_ftell_or_die(3) function.
π SEE ALSO π
ftell(3)β reposition a streamexplain_ftell_or_die(3)β reposition a stream and report errors
π COPYRIGHT π
libexplainversion1.4- Copyright (C) 2010 Peter Miller
and that's the whole page, bestie β¨ this was the explain_ftell(3) manual page from the Library Functions Manual, and the whole thing is libexplain version 1.4, Copyright (C) 2010 Peter Miller. go forth and explain your errors, main character π«Άππ
π¦ 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