gd_alter_protection(3)
π gd_alter_protection β bestie, let's talk protection levels π
okay so this one is from the GETDATA manual, section 3, and it's literally about changing how protected a Dirfile fragment is. slay. let's get into it π
β¨ NAME β¨
gd_alter_protection β modify the protection level of a Dirfile fragment π
β¨ SYNOPSIS β¨
#include <getdata.h>
int gd_alter_protection(DIRFILE *dirfile, int protection_level, int
fragment_index);
β¨ DESCRIPTION β¨
so the way this works is: gd_alter_protection() sets the advisory protection level of the format specification fragment given by fragment_index to protection_level, inside the dirfile(5) database that dirfile points at. that's the whole vibe. π¦
and the protection_level argument? it should be one of these four, no cap:
GD_PROTECT_NONEβ says the fragment should not be protected at all. zero protection. free range. πGD_PROTECT_FORMATβ says the fragment's metadata should be protected. β¨GD_PROTECT_DATAβ says the fragment's binary data should be protected. πGD_PROTECT_ALLβ says both the fragment's metadata AND its binary data should be protected. lowkey important: this symbol is equivalent to the bitwise or ofGD_PROTECT_FORMATandGD_PROTECT_DATA. iykyk π
now, fragment_index can just be a normal valid fragment index, sure β but it can also be the special value GD_ALL_FRAGMENTS, which means change the protection level of every single fragment in the database. all of them. the whole squad. π
β¨ RETURN VALUE β¨
when it works? gd_alter_protection() returns zero. periodt. π
when it doesn't work? it returns a negative-valued error code. here's the menu of possible error codes, bestie:
GD_E_ACCMODEβ the specified dirfile was opened read-only. πGD_E_ARGUMENTβ theprotection_levelyou supplied was invalid. πGD_E_BAD_DIRFILEβ thedirfileyou supplied was invalid. πGD_E_BAD_INDEXβ theindexyou supplied was out of range. π¬GD_E_BAD_PROTECTIONβ theprotection levelyou supplied was invalid. π«
also!! the error code gets stored in theDIRFILEobject too, so you can grab it after this function returns by callinggd_error(3). and if you want an actual descriptive error string? callgd_error_string(3). two icons. π«Ά
β¨ NOTES β¨
not to be dramatic but: this is the only GetData function which ignores the (existing) protection level of a format specification fragment. the only one. main character energy fr fr π
β¨ HISTORY β¨
- the function
dirfile_protect()appeared in GetData-0.5.0. throwback. β - in GetData-0.7.0, this function was renamed to
gd_alter_protection(). glow up. π¦ - in GetData-0.10.0, the error return from this function changed from
-1to a negative-valued error code. growth. πΈ
β¨ SEE ALSO β¨
gd_error(3), gd_error_string(3), gd_protection(3), gd_open(3)
go read those too bestie, they're all part of the same friend group π
okay that's the whole page!! this was Version 0.10.0, dated 25 December 2016, and honestly? iconic for it. bye bestie, go protect your fragments π β¨π
π¦ 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, 2010, 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