---
name: "gd_alter_affixes"
section: "3"
platform: "linux"
package: "libgetdata-doc"
version: "0.11.0-15"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/gd_alter_affixes"
---

# gd\_alter\_affixes(3)

modify the field affixes of a fragments in a Dirfile

## NAME

gd\_alter\_affixes — modify the field affixes of a fragments in a Dirfile

## SYNOPSIS

**#include \<getdata.h\>**

**int gd\_alter\_affixes(DIRFILE \****dirfile***, int** *fragment\_index***,** **const char \****prefix***, const char \****suffix***);**

## DESCRIPTION

The **gd\_alter\_affixes**() function sets the root namespace, field prefix and suffix of fields defined in the format specification fragment given by *fragment\_index* to *prefix* and *suffix* in the [dirfile(5)](/dirfile/5.md) database specified by *dirfile*.

The *prefix* may contain a root namespace for the fragment, separated from the prefix by a dot (**.**). If it does not contain a namespace, the fragment's root namespace is not changed.  To remove a root namespace, explicitly specify the null namespace via a leading dot in *prefix*.

The field prefix and suffix are affixed to all field codes found in the specified fragment.  If the parent fragment to the modified fragment contains field affixes themselves, they should be included in the affixes passed to **gd\_alter\_affixes**(). If *prefix* or *suffix* is NULL, the corresponding affix will be unchanged.  To remove an affix, set it to the parent fragment's corresponding affix, which may be the empty string ("").

It is not possible to set affixes on the root format file (i.e. *fragment\_index* may not be zero).

The *dirfile* argument must point to a valid DIRFILE object previously created by a call to [**gd\_open**(3)](/gd_open/3.md).

## RETURN VALUE

Upon successful completion, **gd\_alter\_affixes**() returns zero.  On error, it returns a negative-valued error code.  Possible error codes are:\
  .TP 8 **GD\_E\_ACCMODE** The specified dirfile was opened read-only.\
  .TP 8 **GD\_E\_ALLOC** The library was unable to allocate memory.\
  .TP 8 **GD\_E\_BAD\_CODE** The supplied *prefix* or *suffix* contained invalid characters.\
  .TP 8 **GD\_E\_BAD\_DIRFILE** The supplied dirfile was invalid.\
  .TP 8 **GD\_E\_BAD\_INDEX** The supplied index was out of range.\
  .TP 8 **GD\_E\_DUPLICATE** The supplied affixes would result in one or more field codes duplicating an existing field code.\
  .TP 8 **GD\_E\_PROTECTED** The metadata of the given fragment's parent fragment was protected from change.

The error code is also stored in the **DIRFILE** object and may be retrieved after this function returns by calling [**gd\_error**(3)](/gd_error/3.md). A descriptive error string for the error may be obtained by calling [**gd\_error\_string**(3)](/gd_error_string/3.md).

## NOTES

The function [**gd\_fragment\_namespace**(3)](/gd_fragment_namespace/3.md) can also be used to modify the root namespace.

## HISTORY

The function **gd\_alter\_affixes**() appeared in GetData-0.8.0.

In GetData-0.10.0, the error return from this function changed from -1 to a negative-valued error code.

## SEE ALSO

[**gd\_error**(3)](/gd_error/3.md), [**gd\_error\_string**(3)](/gd_error_string/3.md), [**gd\_fragment\_affixes**(3)](/gd_fragment_affixes/3.md), [**gd\_include\_affix**(3)](/gd_include_affix/3.md), [**gd\_open**(3)](/gd_open/3.md), [dirfile(5)](/dirfile/5.md), [dirfile-format(5)](/dirfile-format/5.md)
