explain_telldir(3)

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

πŸ’– explain_telldir(3) β€” Library Functions Manual πŸ’–

okay bestie, sit down, hydrate, and let me tell you about explain_telldir β€” it's the glow-up for telldir(3) error messages, and it lives in the libexplain library. ✨


✨ NAME ✨

explain_telldir β€” no cap, this is literally just here to explain telldir(3) errors for you. πŸ’…


🌸 SYNOPSIS 🌸

#include <libexplain/telldir.h>
const char *explain_telldir(DIR *dir);
const char *explain_errno_telldir(int errnum, DIR *dir);
void explain_message_telldir(char *message, int message_size, DIR *dir);
void explain_message_errno_telldir(char *message, int message_size, int
errnum, DIR *dir);

πŸ¦‹ DESCRIPTION πŸ¦‹

So the vibe here is: these functions are your little group chat that explains errors returned by the telldir(3) system call. That's the whole job. That's the mission. 🫢

πŸŽ€ explain_telldir

const char *explain_telldir(DIR *dir);

The explain_telldir function is how you get an explanation of an error returned by the telldir(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's giving detective energy honestly πŸ”

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

  • dir β€” the original dir, exactly as passed to the telldir(3) system call. don't get cute with it, pass it as-is bestie.

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 a communal snack bowl, not your personal lunchbox πŸ“
Note: This function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. sharing is caring until it's a buffer, then it's chaos 😭

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

off_t result = telldir(dir);
if (result < 0)
{
    fprintf(stderr, "%s\n", explain_telldir(dir));
    exit(EXIT_FAILURE);
}

The above code example is available pre‐packaged as the explain_telldir_or_die(3) function. it's the same thing but with ✨main character energy✨

🌈 explain_errno_telldir

const char *explain_errno_telldir(int errnum, DIR *dir);

The explain_errno_telldir function is used to obtain an explanation of an error returned by the telldir(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. yeah, errno is fickle like that, it changes its whole personality mid-conversation πŸ’€
  • dir β€” the original dir, exactly as passed to the telldir(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 = telldir(dir);
if (result < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_telldir(err, dir));
    exit(EXIT_FAILURE);
}

The above code example is available pre‐packaged as the explain_telldir_or_die(3) function.

πŸ’œ explain_message_telldir

void explain_message_telldir(char *message, int message_size, DIR *dir);

The explain_message_telldir function is used to obtain an explanation of an error returned by the telldir(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. look at you, being all responsible with your own buffer, we love growth πŸŽ€
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • dir β€” the original dir, exactly as passed to the telldir(3) system call.

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

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

The above code example is available pre‐packaged as the explain_telldir_or_die(3) function.

🧚 explain_message_errno_telldir

void explain_message_errno_telldir(char *message, int message_size, int
errnum, DIR *dir);

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

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

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

The above code example is available pre‐packaged as the explain_telldir_or_die(3) function.


πŸ‘‘ SEE ALSO πŸ‘‘


libexplain version 1.4 Copyright (C) 2009 Peter Miller


okay that's the whole page bestie, you ate that fr fr πŸ’…βœ¨ if you ever forget a flag or a param just come back here, I got you 🫢 mwah! πŸŒΈπŸ¦‹β­

β€” libexplain version 1.4, Copyright (C) 2009 Peter Miller β€” that's the source + version + date energy, periodt πŸ’œ

πŸ“¦ where this page comes from