gd_put_sarray_slice(3)
π gd_put_sarray_slice(3) β the GETDATA girlies' guide π
okay so bestie, welcome to the GETDATA section 3 club, where we write STRING and SARRAY data into your dirfile and it's giving iconic π
β¨ NAME β¨
gd_put_sarray, gd_put_sarray_slice β write STRING or SARRAY data to a Dirfile database π¦
πΈ SYNOPSIS πΈ
#include <getdata.h>
int gd_put_sarray_slice(DIRFILE *dirfile, const char *field_code,
unsigned int start, size_t len, const char **data_in);
int gd_put_sarray(DIRFILE *dirfile, const char *field_code, const char
**data_in);
π DESCRIPTION π
so gd_put_sarray_slice() literally writes string data to a dirfile(5) database β the one you handed it as dirfile β straight into the STRING or SARRAY scalar array field_code. the spot where the first element of the field lands is start, and how many elements we're stashing is len. no cap β¨
and if field_code is pointing at a STRING field? we just treat it like it was a SARRAY field of length one. simple as that π
gd_put_sarray() is the same vibe honestly, except it writes the whole scalar array, like you'd called gd_put_sarray_slice() with start equal to zero and len equal to whatever gd_array_len(3) gives back π
the data_in argument has to point to an array of pointers to character strings β those are the values we're storing. and if you wanna know how many elements gd_put_sarray() is gonna store, call gd_array_len(3) and it'll tell you π«
π¨ okay important bestie: unlike gd_putdata(3), writing data past the end of the field is not permitted. not allowed. we do not do that here. π
so if you wanna add data to a SARRAY, first make it longer by calling gd_alter_sarray(3), or some other equivalent function. grow first, then write. periodt π
oh and p.s. β gd_put_string(3) is another way to write data to a STRING field, if you want options π«Ά
π₯ RETURN VALUE π₯
on success, gd_put_sarray() and gd_put_sarray_slice() return zero. slay. π
on error, they return a negative-valued error code π and the possible ones are:
GD_E_ACCMODEβ the dirfile you specified was opened read-only. can't write to a locked door, babe πGD_E_ALLOCβ the library could not allocate memory. it's not you, it's the heap πGD_E_BAD_CODEβ the field specified byfield_codewas not found in the database. ghosted fr fr π»GD_E_BAD_DIRFILEβ an invalid dirfile was supplied. not a real one bestie πGD_E_BAD_FIELD_TYPEβ thefield_codeyou gave was not aSTRINGnor aSARRAY. wrong genre πGD_E_BOUNDSβ a request for data beyond the end of the field was made. we talked about this π¨GD_E_INTERNAL_ERRORβ an internal error happened inside the library while it was trying to do the thing. this means there's a bug in the library, so please report the incident to the maintainer! πGD_E_PROTECTEDβ the fragment containing the constant was protected from change. hands off, it's guarded π
the error code also gets stored in the DIRFILE object, and you can grab it after this function returns by calling gd_error(3) β¨ and if you want a descriptive error string for whatever went wrong, call gd_error_string(3) and it'll spill the tea π
π¦ HISTORY π¦
the gd_put_sarray() and gd_put_sarray_slice() functions appeared in GetData-0.10.0. they've been here, being iconic, since then π
π SEE ALSO π
dirfile(5), gd_array_len(3), gd_sarrays(3), gd_error(3), gd_error_string(3), gd_get_sarray_slice(3), gd_open(3), gd_put_string(3)
and that's the whole page, bestie π this was Version 0.10.0, dated 25 December 2016, and it lives in the gd_put_sarray_slice(3) corner of the manual β go forth and write those strings, you absolute main character πβ¨π«Ά
π¦ 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) 2010, 2011, 2012, 2016 D. V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms