explain_strcoll(3)

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

πŸ’– explain_strcoll(3) πŸ’–

okay bestie, welcome to explain_strcoll(3) from the Library Functions Manual β€” yes she's a real one, she lives in section 3 and she's here to explain strcoll(3) errors to you like a supportive bestie who also happens to have read the whole source. πŸŽ€


✨ NAME ✨

explain_strcoll β€” the girl who explains strcoll(3) errors for you, no cap πŸ’…


🌸 SYNOPSIS 🌸

#include <libexplain/strcoll.h>
const char *explain_strcoll(const char *s1, const char *s2);
const char *explain_errno_strcoll(int errnum, const char *s1, const char *s2);
void explain_message_strcoll(char *message, int message_size, const char *s1, const char *s2);
void explain_message_errno_strcoll(char *message, int message_size, int errnum, const char *s1, const char *s2);

πŸ¦‹ DESCRIPTION πŸ¦‹

so. these functions? they're how you get explanations for errors that came back from the strcoll(3) system call. it's giving "let me translate this cryptic error into actual words for you" and honestly we love that for us. πŸ’–

🧚 explain_strcoll

const char *explain_strcoll(const char *s1, const char *s2);

the explain_strcoll function is used to obtain an explanation of an error returned by the strcoll(3) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better than that, and point at the underlying cause in more detail. lowkey overachiever behaviour and we're obsessed. ✨

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

  • s1 β€” the original s1, exactly as passed to the strcoll(3) system call.
  • s2 β€” the original s2, exactly as passed to the strcoll(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. it will be overwritten by the next call to any libexplain function which shares this buffer, including other threads. so don't get attached, bestie. 😭

Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library. it's giving "everyone sharing one communal lip gloss", iykyk. πŸ’€

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

errno = 0;
int result = strcoll(s1, s2);
if (result < 0 && errno != 0)
{
    fprintf(stderr, "%s\n", explain_strcoll(s1, s2));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_strcoll_or_die(3) function. 🫢


πŸŽ€ explain_errno_strcoll

const char *explain_errno_strcoll(int errnum, const char *s1, const char *s2);

the explain_errno_strcoll function is used to obtain an explanation of an error returned by the strcoll(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. iconic, truly. πŸ‘‘

  • 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. (she's sneaky like that, protect your errno at all costs πŸ”₯)
  • s1 β€” the original s1, exactly as passed to the strcoll(3) system call.
  • s2 β€” the original s2, exactly as passed to the strcoll(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:

errno = 0;
int result = strcoll(s1, s2);
if (result < 0 && errno != 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_strcoll(err, s1, s2));
    exit(EXIT_FAILURE);
}

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


🌈 explain_message_strcoll

void explain_message_strcoll(char *message, int message_size, const char *s1, const char *s2);

the explain_message_strcoll function is used to obtain an explanation of an error returned by the strcoll(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 understood the assignment. πŸ’…

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. (glow up moment πŸ¦‹)
  • message_size β€” the size in bytes of the location in which to store the returned message.
  • s1 β€” the original s1, exactly as passed to the strcoll(3) system call.
  • s2 β€” the original s2, exactly as passed to the strcoll(3) system call.

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

errno = 0;
int result = strcoll(s1, s2);
if (result < 0 && errno != 0)
{
    char message[3000];
    explain_message_strcoll(message, sizeof(message), s1, s2);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

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


⭐ explain_message_errno_strcoll

void explain_message_errno_strcoll(char *message, int message_size, int errnum, const char *s1, const char *s2);

the explain_message_errno_strcoll function is used to obtain an explanation of an error returned by the strcoll(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. main character energy fr fr. 🌟

  • 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.
  • s1 β€” the original s1, exactly as passed to the strcoll(3) system call.
  • s2 β€” the original s2, exactly as passed to the strcoll(3) system call.

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

errno = 0;
int result = strcoll(s1, s2);
if (result < 0 && errno != 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_strcoll(message, sizeof(message), err, s1, s2);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

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


πŸ‘‘ SEE ALSO πŸ‘‘


libexplain version 1.4 Copyright (C) 2013 Peter Miller


and that's the whole page, bestie, you ate it up πŸ“βœ¨ this was explain_strcoll(3) from the Library Functions Manual, brought to you by libexplain version 1.4 and the copyright of Peter Miller, 2013 β€” go forth and explain your errors, periodt. πŸ’–πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from