gd_put_string(3)
π gd_put_string(3) β GETDATA π
okay bestie, sit down, we're learning gd_put_string(3) today and honestly? it's giving simple but powerful. no cap.
β¨ NAME β¨
gd_put_string β write a STRING or SARRAY element to a Dirfile database π¦
πΈ SYNOPSIS πΈ
#include <getdata.h>
int gd_put_string(DIRFILE *dirfile, const char *field_code, const char
*data_in);
π DESCRIPTION π
so the way this works is: gd_put_string() goes and queries a dirfile(5) database β that's the one you named in dirfile β and then it takes the character string data_in and stores it in the STRING or SARRAY scalar field that you picked with field_code. very demure, very mindful.
and listen, tiny plot twist: if field_code points at a SARRAY field, your string gets stored as the first element. that's just how it is. π
the dirfile argument? it must point to a valid DIRFILE object that you already made by calling gd_open(3). no shortcuts, no vibes-based dirfile objects, sorry babe. π
π¨ IMPORTANT, FR FR: because string values live in the dirfile metadata, the new value offield_codewon't be written to disk until you flush the dirfile metadata withgd_metaflush(3), or until you close the dirfile withgd_close(3). so if you're out here wondering why your string ghosted the disk β that's why. periodt.
also, quick heads up: gd_put_sarray(3) gives you another way of storing STRING and SARRAY data to a Dirfile. options, we love to see it. π
β RETURN VALUE β
on success, gd_put_string() returns zero. slay. β¨
on error, it returns a negative-valued error code. and here's the whole roster of possible error codes, no gatekeeping:
GD_E_ACCMODEβ the dirfile you specified was opened read-only. can't write to something that said "no thank you." πGD_E_BAD_CODEβ the field you named infield_codewasn't found in the database. it's not there, bestie. πGD_E_BAD_DIRFILEβ an invalid dirfile was supplied. πGD_E_BAD_FIELD_TYPEβ thefield_codeyou handed over referred to a field of some type other than SARRAY or STRING. wrong field, wrong vibe. πGD_E_INTERNAL_ERRORβ an internal error happened in the library while it was trying to do the thing. this one means there's a bug in the library, and you should please report the incident to the maintainer. not your fault, queen. π«ΆGD_E_PROTECTEDβ the fragment containing the string was protected from change. hands off. π
and pssst β the error code also gets stored in the DIRFILE object itself, so you can go grab it after this function returns by calling gd_error(3). want a descriptive error string instead of a number? call gd_error_string(3). you're welcome. π
π¦ HISTORY π¦
okay story time, and it's a whole glow-up arc:
- the
put_string()function appeared in GetData-0.4.0. back then it returned asize_tcontaining the length of the string written, or zero on error. different era, different energy. - in GetData-0.7.0, this function was renamed to
gd_put_strint(). - in GetData-0.10.0, this function's return value changed to zero on success, or else a negative-valued error code. main character evolution. π
π SEE ALSO π
dirfile(5), gd_close(3), gd_get_string(3), gd_error(3), gd_error_string(3), gd_metaflush(3), gd_open(3), gd_put_sarray(3).
go read them, they're iconic too. π
and that's the whole page, bestie!! this was Version 0.10.0, dated 25 December 2016, and honestly a little Christmas gift from the GetData girlies. mwah, bye!! ππβ¨π§π
π¦ 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, 2016 D. V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms