gd_alter_entry(3)
π gd_alter_entry β bestie edition π
okay so picture this: it's a getdata man page, it's a GETDATA manual page, and it's called gd_alter_entry. she's a 3 (library function, iykyk). and she's here to change up the metadata of a Dirfile field. no cap. π
β¨ NAME β¨
gd_alter_entry β modify the metadata of a Dirfile field π
πΈ SYNOPSIS πΈ
#include <getdata.h>
int gd_alter_entry(DIRFILE *dirfile, const char *field_code, const
gd_entry_t *entry, int recode);
π¦ DESCRIPTION π¦
okay so the tea is: gd_alter_entry() takes the field you name in field_code inside the dirfile you name in dirfile and glow-ups it to match the new parameters you're passing in entry. π
and listen β field_code isn't just regular fields. she can also point at a metafield, as long as you spell it out with its full (slashed) field code. BUT. and this is important bestie: field_code should never contain a representation suffix. never ever. π«
the shape of entry is explained in excruciating gorgeous detail over in the get_entry(3) man page. here's the thing though β entry->field and entry->fragment_index are ignored by this function, so you literally don't even have to initialise them, they're just vibing. every other member that's appropriate to the field type of field_code should be initialised, except for the special cases noted down below. π
want to change the fragment index of a field? that's a gd_move(3) situation. want to change the name of a field? take it to gd_rename(3). this girl doesn't do that. π
ββοΈ
π the flags situation π
the only flags in the entry->flags member that get honoured are:
GD_EN_HIDDENβ set it or clear it to set the hiddenness of the entry (peepgd_hidden(3)for that one)GD_EN_COMPSCALβ tells you whether scalar parameters are initialised from the complex valued member or the purely real member, and both of those are present forLINCOM,POLYNOM, andRECIP
π₯ the recode lore π₯
if field_code specifies a RAW field and recode is non-zero, the binary file hanging out with that field gets converted for changes in data type and samples-per-frame. and when that happens, the field's I/O pointer gets reset to the beginning-of-frame. (main character behaviour, honestly.) if recode is zero, no binary file conversion happens at all. zero. nada. π§
if field_code specifies a LINTERP field and recode is non-zero, the look-up table file gets moved if entry->table specifies a different path.
β οΈ if a file with the new pathname already exists, it will be overwritten. not a drill. π
if the field specified by field_code is any type other than RAW or LINTERP, then recode is just... ignored. it's giving background character. π
π the LINCOM / POLYNOM scalars π
if field_code specifies a LINCOM or POLYNOM field, the value of entry->comp_scal decides which list gets used:
- the purely real scalar lists β
entry->a, orentry->bandentry->m - the complex valued lists β
entry->ca, orentry->cbandentry->cm
and the unused counterparts? they don't need to be initialised at all. they can stay in bed. π
β field types are NOT up for negotiation β
entry->field_type must correspond to the field type of field_code. periodt. this interface cannot be used to change the type of a given field. nope.
if you really want a different type, the routine is:
- delete the old field first with
gd_delete(3) - then create a new field of the desired type with
gd_add(3)
π special "no change" values π
some entry members have special values that mean "don't touch this, leave it alone". they are:
NULLβ any of the string members0βspf,n_fields,numbits,cdividend,dividend, orarray_len-1βbitnumorperiodGD_NULLβdata_typeorconst_typeGD_WINDOP_UNKβwindop
π«Ά the scalar element rules π«Ά
every entry->scalar element that's relevant for the given field type must be initialised to one of these:
- a pointer to a field code indicating a new scalar field to be used for the corresponding field parameter. if the parameter was previously a literal number, it gets replaced by the specified field code. if the parameter was previously a field code, the new field code replaces the old one. and if the field code specifies a
CARRAYfield, the correspondingentry->scalar_indelement should also be set. β¨ - a pointer to the empty string (
""). in this case, no change is made to the field code for the corresponding field parameter: if one already existed, it's kept, otherwise the corresponding literal numerical parameter is used. and if the value of the corresponding numerical entry member is one of those special no-change values listed up there, then no change is made to the field parameter at all. NB: in this case, GetData also ignores the correspondingentry->scalar_indelement, even if it differs from the current value. so if you want to change ascalar_indelement without changing the corresponding scalar, set that scalar element to its current value β at which point GetData operates like the previous bullet. π - the
NULLpointer. if the corresponding field parameter was previously a field code, the field code gets deleted and a literal number is used instead. in the special case where a scalar element isNULLand the corresponding numerical entry member contains one of those special no-change values, GetData will de-reference the previous field code value and convert it into a literal number before removing the field code from the entry. iconic, honestly. π
π one last carray thing π
if you use this function to increase the length of a CARRAY field, the added elements will be uninitialised. they're just born like that. use gd_put_carray_slice(3) or an equivalent to initialise them. π§
π RETURN VALUE π
on success, gd_alter_entry() returns zero. π on error, a negative-valued error code is returned. the possible error codes are:
GD_E_ACCMODEβ the specified dirfile was opened read-only. rude.GD_E_ALLOCβ the library was unable to allocate memory. πGD_E_BAD_CODEβ the field specified byfield_codewas not found, or a supplied field code didn't contain the appropriate prefix or suffix. this error may also result from attempting to dereference a scalar field code which indicates a non-existent field.GD_E_BAD_DIRFILEβ the supplied dirfile was invalid.GD_E_BAD_ENTRYβ one or more of the parameters specified inentrywas invalid.GD_E_BAD_FIELD_TYPEβ theentry->field_typeparameter did not correspond to the type of the field specified byfield_code, or an attempt was made to modify the immutableINDEXfield. this error may also result from attempting to dereference a scalar field code which does not indicate aCONSTorCARRAYfield.GD_E_BAD_TYPEβ theentry->data_typeparameter provided with aRAWentry, or theentry->const_typeparameter provided with aCONSTorCARRAYentry, was invalid.GD_E_IOβ an I/O error occurred while translating the binary file associated with a modifiedRAWfield, or an I/O error occurred while attempting to rename aLINTERPtable file.GD_E_PROTECTEDβ the metadata of the fragment was protected from change. or, a request to translate the binary file associated with aRAWfield was attempted, but the data of the fragment was protected. π‘οΈGD_E_UNKNOWN_ENCODINGβ the encoding scheme of the indicated format specification fragment is not known to the library. as a result, the library was unable to translate the binary file be associated with a modifiedRAWfield. (yes, that sentence really does say "be associated", we're keeping it exactly as it is π)GD_E_UNSUPPORTEDβ the encoding scheme of the indicated format specification fragment does not support translating the binary file associated with a modifiedRAWfield.
the error code is also stored in the DIRFILE object, and you can retrieve it after this function returns by calling gd_error(3). want a descriptive error string instead? that's gd_error_string(3). π«Ά
πΈ HISTORY πΈ
the function dirfile_alter_entry() appeared in GetData-0.5.0.
in GetData-0.7.0, this function was renamed to gd_alter_entry().
in GetData-0.8.0 β the first version supporting fragment affixes β this function would apply the destination fragment's affixes to the supplied entry->field name. in GetData-0.8.1 that changed: gd_alter_entry() now assumes entry->field contains the full field name, including any necessary affixes. growth. π
in GetData-0.10.0, the error return changed from -1 to a negative-valued error code.
see gd_entry(3) for the history of the gd_entry_t structure. π
π SEE ALSO π
gd_alter_bit(3), gd_alter_carray(3), gd_alter_const(3), gd_alter_divide(3), gd_alter_lincom(3), gd_alter_linterp(3), gd_alter_multiply(3), gd_alter_phase(3), gd_alter_polynom(3), gd_alter_raw(3), gd_alter_recip(3), gd_alter_spec(3), gd_delete(3), gd_error(3), gd_error_string(3), gd_hidden(3), gd_malter_spec(3), gd_metaflush(3), gd_move(3), gd_open(3), gd_put_carray_slice(3), gd_rename(3), dirfile-format(5)
and that's the whole page bestie!! π this was Version 0.10.0, dated 25 December 2016, from the gd_alter_entry(3) page in the GetData manual. merry christmas to those who celebrate, and happy metadata-altering to those who don't. mwah πβ¨π
π¦ 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, 2009, 2010, 2012, 2013, 2014, 2016 D. V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms