gd_error(3)
β¨ gd_error(3) β¨
okay so bestie, welcome to the GETDATA corner of the manual β this is gd_error, plus its ride-or-die gd_error_string, and together they're literally just here to tell you what went wrong π
πΈ NAME πΈ
gd_error, gd_error_string β report a GetData library error π«Ά
π SYNOPSIS π
#include <getdata.h>
int gd_error(const DIRFILE *dirfile);
char *gd_error_string(const DIRFILE *dirfile, char *buffer, size_t
buflen);
that's it. that's the whole vibe. two little functions and a whole lot of emotional support π
π¦ DESCRIPTION π¦
So like, the way that gd_error() works is: it looks at the most recent GetData library function call that operated on dirfile, and it's like "girl, did that work or not?"
- If that last call succeeded,
gd_error()returnsGD_E_OKβ which equals zero. slay β¨ - If that last call failed,
gd_error()returns a negative-valued error code telling you the cause of the failure π
and here's the tea: the possible codes vary from function to function. So go check the corresponding manual page of the function that failed to get the full list of possible codes. iykyk π§
gd_error_string() is basically the same girl but she's an overachiever β she behaves similarly, but she composes a string describing the error π
- If
bufferis not NULL, the string gets written to that memory location. At mostbuflencharacters will be written, including the terminating NUL byte. - If
bufferis not large enough to hold the entire string, the string will be truncated β but the truncated string will still be NUL-terminated, because she's polite like that π - If
bufferis NULL,gd_error_string()will allocate a string of sufficient length on the heap. In this case,buflenis ignored π- By default,
malloc(3)is used to allocate this buffer β but an alternate memory manager may be specified by callinggd_alloc_funcs(3)before calling this function. - The caller is responsible for deallocating this string when it is no longer needed. yes bestie, YOU. you free it. π«Ά
- By default,
Now, some functions get ignored by these two, because they always succeed and honestly? good for them:
gd_alloc_funcs(3)gd_error_count(3)gd_flags(3)gd_free_entry_strings(3)gd_mplex_lookback(3)gd_parser_callback(3)
Previous gd_error() and gd_error_string() calls are also ignored. no self-referential drama here, we're not doing that today π
π RETURN VALUE π
gd_error() always returns the integer error code of the last library call on the supplied DIRFILE object. always. no exceptions. main character behavior fr fr π₯
gd_error_string() is a little more complicated, so pay attention bestie:
- If
bufferis non-NULL, it returnsbufferβ unlessbuflenis less than one, in which case it returnsNULL. π - If
bufferis NULL, this function returns a newly allocated string of sufficient length which should be deallocated by the caller β orNULLif memory allocation failed π
π HISTORY π
storytime, gather round π§
- The
get_error_string()function appeared in GetData-0.3.0. vintage queen β - The
get_error()function appeared in GetData-0.4.0. Before this, the error code was directly accessible via thedirfile->errormember in theDIRFILEstructure. like, manually. wild times π - In GetData-0.7.0, these functions were renamed to
gd_error()andgd_error_string(). This is also the first release in whichgd_error_string()would allocate a buffer for the error string if passedNULL. glow-up era β¨
π SEE ALSO π
go read her too, she's iconic in her own right π«Ά
and that's the whole page bestie!! this was Version 0.10.0, dated 25 December 2016, from the GETDATA manual, section 3 β gd_error(3), periodt π
β¨ππ¦πΈ
π¦ where this page comes from
- debian bookworm: libgetdata-doc 0.11.0-6
- debian trixie: libgetdata-doc 0.11.0-15
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- nixos 26.05: getdata 0.11.0
- nixpkgs unstable: getdata 0.11.0
- ubuntu jammy: libgetdata-doc 0.11.0-3ubuntu1
- ubuntu noble: libgetdata-doc 0.11.0-13
- ubuntu questing: libgetdata-doc 0.11.0-15
- ubuntu resolute: libgetdata-doc 0.11.0-17build1
- ubuntu stonking: libgetdata-doc 0.11.0-17build2
- Copyright (C) 2016 D. V. Wiebe
- Copyright (C) 2008, 2009, 2010, 2011, 2014, 2016 D. V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms