explain_ftime(3)

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

πŸ’– explain_ftime(3) β€” a lil guide from your fave Unix bestie πŸ’–

Library Functions Manual · part of libexplain ✨

okay so bestie, gather round 🫢 this one is all about making ftime(3) errors make sense instead of just yelling errno at you like a cryptic little gremlin. it's giving translator energy, and honestly? iconic.


✨ NAME ✨

explain_ftime β€” the function that explains your ftime(3) errors for you πŸ’… no cap, that's literally its whole job.


🌸 SYNOPSIS 🌸

#include <libexplain/ftime.h>
const char *explain_ftime(struct timeb *tp);
const char *explain_errno_ftime(int errnum, struct timeb *tp);
void explain_message_ftime(char *message, int message_size, struct timeb
*tp);
void explain_message_errno_ftime(char *message, int message_size, int
errnum, struct timeb *tp);

πŸ¦‹ DESCRIPTION πŸ¦‹

so these functions are your lil squad of error-explainers πŸ‘‘ you use them to get actual explanations for errors that the ftime(3) system call handed back to you. like, the vibe is: the system call said no, and now you wanna know why, in words, in English, fr fr.

πŸ’œ explain_ftime

const char *explain_ftime(struct timeb *tp);

the explain_ftime function gets you an explanation of an error returned by the ftime(3) system call. the least it'll give you is the value of strerror(errno), but usually it goes way harder than that and tells you the actual underlying cause in more detail. main character energy honestly.

the errno global variable is what gets used to grab the error value that's gonna be decoded. so like, it reads the vibes straight from errno πŸ’«

  • tp β€” the original tp, exactly as you passed it to the ftime(3) system call. no substitutions, no edits, the real one.

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. so the next call to any libexplain function that shares this buffer will overwrite it β€” including calls from other threads. it's a communal lil buffer, and it does not care about your feelings 😭

Note: this function is not thread safe, because it shares a return buffer across all threads, and lots of other functions in this library do too. so like, be careful out there 🫠

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

if (ftime(tp) < 0)
{
    fprintf(stderr, "%s\n", explain_ftime(tp));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_ftime_or_die(3) function πŸŽ€ (yes, it does the dying for you, slay)

🌈 explain_errno_ftime

const char *explain_errno_ftime(int errnum, struct timeb *tp);

the explain_errno_ftime function gets you an explanation of an error returned by the ftime(3) system call. again, the least the message will contain is the value of strerror(errno), but usually it does much better and points at the underlying cause in more detail. obsessed.

  • errnum β€” the error value to be decoded, usually grabbed from the errno global variable right before this function is called. this is necessary if you need to run any code between the system call you're explaining and this function, because a lot of libc functions will mess with the value of errno. so like, snapshot it first πŸ“Έ
  • tp β€” the original tp, exactly as passed to the ftime(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.

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:

if (ftime(tp) < 0)
{
    int err = errno;
    fprintf(stderr, "%s\n", explain_errno_ftime(err, tp));
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_ftime_or_die(3) function ✨

πŸŽ€ explain_message_ftime

void explain_message_ftime(char *message, int message_size, struct timeb
*tp);

the explain_message_ftime function gets you an explanation of an error returned by the ftime(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 thorough πŸ’…

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 you supply a suitable message return buffer, this function is thread safe. you did it bestie, you brought your own buffer 🫢
  • message_size β€” the size in bytes of the location in which to store the returned message. so like, how much room you're giving it.
  • tp β€” the original tp, exactly as passed to the ftime(3) system call.

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

if (ftime(tp) < 0)
{
    char message[3000];
    explain_message_ftime(message, sizeof(message), tp);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_ftime_or_die(3) function 🌟

🧚 explain_message_errno_ftime

void explain_message_errno_ftime(char *message, int message_size, int
errnum, struct timeb *tp);

the explain_message_errno_ftime function is used to obtain an explanation of an error returned by the ftime(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 full package, no cap.

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

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

if (ftime(tp) < 0)
{
    int err = errno;
    char message[3000];
    explain_message_errno_ftime(message, sizeof(message), err, tp);
    fprintf(stderr, "%s\n", message);
    exit(EXIT_FAILURE);
}

the above code example is available pre-packaged as the explain_ftime_or_die(3) function πŸ’–


πŸ‘€ SEE ALSO πŸ‘€


libexplain version 1.4 Copyright (C) 2009 Peter Miller


and that's the whole page bestie 🌸 go forth and explain those errors, you absolute legend πŸ’…πŸ‘‘

β€” explain_ftime(3), from libexplain version 1.4, copyright (C) 2009 Peter Miller. mwah πŸ’‹

πŸ“¦ where this page comes from