---
name: "gd_fragment_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_fragment_affixes"
---

# gd\_fragment\_affixes(3)

report the field affixes of a fragment of a Dirfile database

## NAME

gd\_fragment\_affixes — report the field affixes of a fragment of a Dirfile database

## SYNOPSIS

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

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

## DESCRIPTION

The **gd\_fragment\_affixes**() function queries a [dirfile(5)](/dirfile/5.md) database specified by *dirfile* and returns the field affixes for the fragment indexed by *fragment\_index*. The field prefix and suffix are appended to all field codes found in the specified fragment.

The *prefix* and *suffix* parameters point to memory locations in which store the addresses of the returned strings.  The returned *prefix* does NOT contain the root namespace of the fragment.  To retreive that, use [**gd\_fragment\_namespace**(3)](/gd_fragment_namespace/3.md).

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\_fragment\_affixes**() returns zero.  If non-empty, the prefix and suffix are reported in heap-allocated buffers whose addresses are returned in **\****prefix* and **\****suffix.* By default [**malloc**(3)](/malloc/3.md) is used to allocate these buffers, but a different allocator may be specified by calling [**gd\_alloc\_funcs**(3)](/gd_alloc_funcs/3.md) before calling this function.  The caller is responsible for deallocating the buffers.  If the fragment prefix or suffix is the empty string, NULL is returned in the corresponding pointer.

On error, a negative-valued error code is returned.  In this case, the values of **\****prefix* and **\****suffix* are unspecified, but will NOT be pointers to valid allocated memory.  Possible returned error codes are:\
  .TP 8 **GD\_E\_ALLOC** A memory allocation error occurred.\
  .TP 8 **GD\_E\_BAD\_DIRFILE** The supplied dirfile was invalid.\
  .TP 8 **GD\_E\_BAD\_INDEX** The supplied index was out of range.

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).

## HISTORY

The **gd\_fragment\_affixes**() function 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\_alloc\_funcs**(3)](/gd_alloc_funcs/3.md), [**gd\_alter\_affixes**(3)](/gd_alter_affixes/3.md), [**gd\_fragment\_namespace**(3)](/gd_fragment_namespace/3.md), **gd\_include\_affixes**(3), [**gd\_open**(3)](/gd_open/3.md), [dirfile(5)](/dirfile/5.md), [dirfile-format(5)](/dirfile-format/5.md)
