gd_protection(3)

✨ gd_protection β€” bestie edition ✨

okay so this is gd_protection(3), part of the GETDATA manual, and it's genuinely so useful. sit down, hydrate, let's go πŸ’–


🌸 NAME 🌸

gd_protection β€” the function that reports the protection level of a Dirfile fragment. yes. that's the whole job. and it does it flawlessly. periodt. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <getdata.h>

int gd_protection(DIRFILE *dirfile, int fragment_index);

that's it. two arguments. one int back. iconic behavior honestly.


πŸŽ€ DESCRIPTION πŸŽ€

so gd_protection() queries a dirfile(5) database β€” the one you hand it as dirfile β€” and figures out the advisory protection level for the fragment indexed by fragment_index.

like, it's not a bodyguard. it's the advisor. it tells you what the vibe check says about that fragment's protection. no cap. 🫢


πŸ’œ RETURN VALUE πŸ’œ

when it slays (i.e. succeeds), gd_protection() returns a non-negative integer β€” the advisory protection level of the fragment you asked about. and that integer is gonna be one of these symbols, fr fr:

GD_PROTECT_NONE, GD_PROTECT_FORMAT, GD_PROTECT_DATA,
GD_PROTECT_ALL.

what do they mean though? bestie, the meanings are explained over in the gd_alter_protection(3) man page. go look, i'll wait. πŸ‘‘

but on error? 😭 it returns a negative-valued error code. the possible error codes are:

  • GD_E_BAD_DIRFILE β€” the dirfile you supplied was invalid. not it. πŸ™ˆ
  • GD_E_BAD_INDEX β€” the index you supplied was out of range. literally out of bounds, bestie. πŸ’€

and listen β€” that error code also gets stored in the DIRFILE object, so you can go grab it after the function returns by calling gd_error(3). want a whole descriptive error string instead of a number? that's gd_error_string(3). two icons, both serving. ✨


🌈 HISTORY 🌈

  • get_protection() first appeared in GetData-0.5.0. baby's first era. 🍼
  • in GetData-0.7.0 it got renamed to gd_protection(). glow-up. πŸ’…
  • in GetData-0.10.0, the error return changed from -1 to a negative-valued error code. character development. πŸ”₯

⭐ SEE ALSO ⭐

go read them. all of them. for me. πŸ₯Ί


Version 0.10.0 Β· 25 December 2016 β€” and that's the whole page bestie, mwah, go forth and check your protection levels responsibly πŸ’–πŸ¦‹βœ¨