gd_fragment_namespace(3)
π gd_fragment_namespace β getdata manual, section 3 π
okay bestie, pull up a chair π«Ά because today we're talking about gd_fragment_namespace(3), a little function from the getdata library, and honestly? it's giving "quietly powerful". it reports or changes the root namespace of a fragment in a dirfile database. yes. that's the whole vibe. let's get into it π
β¨ NAME β¨
gd_fragment_namespace β report or change the root namespace of a fragment of a dirfile database π
πΈ SYNOPSIS πΈ
#include <getdata.h>
const char *gd_fragment_namespace(DIRFILE *dirfile, int fragment_index,
char *new_namespace);
π¦ DESCRIPTION π¦
so, gd_fragment_namespace() does two jobs at once and it does them flawlessly: it can update and/or query the root namespace of a fragment inside the dirfile(5) database you hand it in dirfile. iconic behaviour, no cap β¨
here's the tea on how it decides what to do:
- if
new_namespaceisNULL, it just returns the current root namespace of the fragment indexed byfragment_index. simple. clean. we love her. - if
new_namespaceis non-NULL, the root namespace gets changed first to the string you gave it, and then reported back to you. like, it does the thing and tells you about the thing. multitasking queen π - the new namespace may optionally contain a single, trailing dot (
.). just one. don't be greedy. - wanna remove an existing root namespace? pass a pointer to the empty string (
"") asnew_namespace. boom, gone. periodt π
π¨ important, bestie: the root namespace of the root format file β that's the one indexed by fragment_index=0 β may not be changed. it is always the empty string. that's just the rules. don't fight it.
and dirfile must point to a valid DIRFILE object that was previously created by a call to gd_open(3). no random pointers, we're not doing chaos today π
π RETURN VALUE π
on a good day (which is every day, when you use this function correctly), gd_fragment_namespace() returns a non-NULL pointer to a read-only string containing the current root namespace of the fragment you specified. yay π
- if
new_namespacewas non-NULL, that returned string is a copy ofnew_namespace. - if the fragment's root namespace is empty, you get back a pointer to the empty string (
""). still valid, still cute.
on error, this function returns NULL and sets the dirfile error to a non-zero error value. here's the full lineup of possible dirfile error values, and yes, we're listing every single one because we don't skip:
GD_E_ACCMODEβ the dirfile was opened read-only. can't write, won't write πGD_E_ALLOCβ a memory allocation error occurred. tragic.GD_E_BAD_CODEβ the suppliednew_fragmentwas not a valid namespace. (yes, that's what it says. we report, we don't editorialise.)GD_E_BAD_DIRFILEβ the supplied dirfile was invalid. not a real dirfile, sorry bestie.GD_E_BAD_INDEXβ the supplied index was out of range. this error will also be returned if you attempt to change the root namespace of the root format file (fragment_indexzero). we told you. πGD_E_DUPLICATEβ attempting to change the root namespace resulted in a duplicated field definition. oops.GD_E_PROTECTEDβ the protection level of the specified fragment prohibits metadata changes. she's protected. respect the boundary π
you can grab the dirfile error by calling gd_error(3), and if you want a descriptive error string for the last error encountered, hit up gd_error_string(3). they've got you π«Ά
β HISTORY β
gd_fragment_namespace() appeared in GetData-0.10.0. a legend was born π
π SEE ALSO π
okay that's the whole page, you ate that reading session fr fr π₯ this was Version 0.10.0, dated 25 December 2016, and it's gd_fragment_namespace(3) from the getdata manual β go forth and namespace responsibly, bestie ππ§
π¦ 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
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms