gd_endianness(3)

✨ gd_endianness ✨

okay so bestie, welcome to gd_endianness(3) β€” a lil GetData manual page that answers the eternal question: which way do your bytes face πŸ’… this one lives in section 3 of the manual, and it's giving "short but iconic." no cap.


🌸 NAME 🌸

gd_endianness β€” report the byte sex of fields in a Dirfile 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <getdata.h>

unsigned long gd_endianness(DIRFILE *dirfile, int fragment_index);

πŸ’– DESCRIPTION πŸ’–

so gd_endianness() goes and queries a dirfile(5) database β€” that's the one you pass in as dirfile β€” and it fetches the byte sex of the fragment at index fragment_index. yes we're really calling it that, that's the actual terminology, i don't make the rules πŸŽ€

and what does byte sex even mean here? it's the endianness of the data files tied to the RAW fields defined in that specified fragment. that's the whole vibe.

tiny lil caveat bestie: if a fragment has no RAW fields in it, its endianness is literally not meaningful. there's nothing to be endian about. so don't come for it πŸ’€

also, the dirfile argument has to point to a valid DIRFILE object β€” and it has to be one that was already created by a call to gd_open(3). no hand-rolled ones, no guessing, we need the real thing ✨


πŸ‘‘ RETURN VALUE πŸ‘‘

when it works? slay. gd_endianness() hands you back the byte sex of that fragment, which is either GD_BIG_ENDIAN or GD_LITTLE_ENDIAN.

and then β€” plot twist β€” that value gets bitwise-or'd with either GD_ARM_ENDIAN or GD_NOT_ARM_ENDIAN. and why, you ask? because it tells you whether the double-precision floating point data in this fragment is stored in the old ARM middle-endian format. yes, middle-endian. a whole third option. history is wild fr fr 🧚

but when it goes wrong 😭 this function returns zero and stashes a negative-valued error code inside the DIRFILE object. you can grab that later with a subsequent call to gd_error(3). the possible error codes are:

  • GD_E_BAD_DIRFILE β€” the supplied dirfile was invalid. not it. πŸ™ˆ
  • GD_E_BAD_INDEX β€” the supplied index was out of range. bestie that fragment does not exist πŸ’€

and if you want the actual words, not just the number, you can get a descriptive error string by calling gd_error_string(3) 🌈


⭐ HISTORY ⭐

so the get_endianness() function first appeared in GetData-0.5.0. iconic debut, no notes.

then in GetData-0.7.0 it got a glow-up and was renamed to gd_endianness(). and that same version also added the GD_ARM_ENDIAN and GD_NOT_ARM_ENDIAN flags. character development πŸŽ€


πŸ”₯ SEE ALSO πŸ”₯


that's the whole page bestie, go read your bytes πŸ’…

this was Version 0.10.0, dated 25 December 2016 β€” a lil Christmas gift from the GETDATA girlies 🎁✨ mwah, bye!!