explain_ftell(3)

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

πŸ¦‹ 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 original fp, exactly</>, as passed to the ftell(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 the errno global 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 of errno. so grab it early, okay? πŸ™ˆ
  • fp β€” the original fp, exactly as passed to the ftell(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 original fp, exactly as passed to the ftell(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 the errno global 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 of errno. do not sleep on this one 😭
  • fp β€” the original fp, exactly as passed to the ftell(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 πŸ‘€


  • libexplain version 1.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