explain_ftello(3)

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

πŸ’– explain_ftello β€” ok bestie, let's decode your ftello(3) errors πŸ’–

so this is the tea: the explain_ftello(3) page lives in the Library Functions Manual section of the libexplain docs, and it's basically a whole support group for when ftello(3) goes wrong and you're staring at errno like πŸ‘οΈπŸ‘„πŸ‘οΈ. Let's get into it. πŸ¦‹


✨ NAME ✨

explain_ftello β€” explain ftello(3) errors. no cap, that's the whole job. πŸ’…


🌸 SYNOPSIS 🌸

#include <libexplain/ftello.h>
const char *explain_ftello(FILE *fp);
const char *explain_errno_ftello(int errnum, FILE *fp);
void explain_message_ftello(char *message, int message_size, FILE *fp);
void explain_message_errno_ftello(char *message, int message_size, int
errnum, FILE *fp);

four lil functions, four lil vibes, all of them here to explain what went wrong. 🫢


πŸ‘‘ DESCRIPTION πŸ‘‘

These functions may be used to obtain explanations for errors returned by the ftello(3) system call. like, it's a whole translator between "errno said a number" and "here's what actually happened bestie". 🧚


🌈 explain_ftello

const char *explain_ftello(FILE *fp);

The explain_ftello function is used to obtain an explanation of an error returned by the ftello(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. it really said "let me cook." πŸ”₯

The errno global variable will be used to obtain the error value to be decoded.

  • fp β€” the original fp, exactly as passed to the ftello(3) system call. exactly. don't get cute with it.

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. so like… it's one communal water bottle. everyone's drinking from it. πŸ’€

Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. the way that one buffer is doing ALL that labor for everyone 😭

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

off_t result = ftello(fp);
if (result < 0)
{
    fprintf(stderr, "%s\n", explain_ftello(fp));
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_ftello_or_die(3) function. iconic, honestly β€” they already wrote the boring part for you. ✨


πŸ¦‹ explain_errno_ftello

const char *explain_errno_ftello(int errnum, FILE *fp);

The explain_errno_ftello function is used to obtain an explanation of an error returned by the ftello(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.

  • 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. fr fr, libc will snatch your errno mid-conversation, so grab it first. πŸ™ˆ
  • fp β€” the original fp, exactly as passed to the ftello(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:

off_t result = ftello(fp);
if (result < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_ftello(err, fp));
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_ftello_or_die(3) function.


πŸŽ€ explain_message_ftello

void explain_message_ftello(char *message, int message_size, FILE *fp);

The explain_message_ftello function is used to obtain an explanation of an error returned by the ftello(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. oh so NOW we're being responsible with our buffers, 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 ftello(3) system call.

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

off_t result = ftello(fp);
if (result < 0)
{
    char message[3000];
    explain_message_ftello(message, sizeof(message), fp);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_ftello_or_die(3) function.


πŸ’œ explain_message_errno_ftello

void explain_message_errno_ftello(char *message, int message_size, int
errnum, FILE *fp);

The explain_message_errno_ftello function is used to obtain an explanation of an error returned by the ftello(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.
  • fp β€” the original fp, exactly as passed to the ftello(3) system call.

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

off_t result = ftello(fp);
if (result < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_ftello(message, sizeof(message), err,
    fp);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

The above code example is available pre-packaged as the explain_ftello_or_die(3) function. bestie combo: errno captured AND a message buffer. she's doing it all. πŸ’…


🌟 SEE ALSO 🌟

  • ftello(3) β€” get stream position the og function, the one we're explaining
  • explain_ftello_or_die(3) β€” get stream position and report errors same energy but it will absolutely exit on you

libexplain version 1.4 Copyright (C) 2013 Peter Miller


ok that's the whole page bestie, you're officially fluent in explain_ftello 🫢✨

signing off from the Library Functions Manual section of the libexplain docs β€” libexplain version 1.4, Copyright (C) 2013 Peter Miller β€” go forth and debug, my main character. πŸŽ€πŸ¦‹πŸ‘‘

πŸ“¦ where this page comes from