libgta
1.2.1
Read and Write Generic Tagged Array (GTA) files
|
The libgta C interface. More...
Typedefs | |
typedef struct gta_internal_header_struct | gta_header_t |
The GTA header type. | |
typedef struct gta_internal_taglist_struct | gta_taglist_t |
The GTA tag list type. More... | |
typedef size_t(* | gta_read_t) (intptr_t userdata, void *buffer, size_t size, int *error) |
Custom input function. More... | |
typedef size_t(* | gta_write_t) (intptr_t userdata, const void *buffer, size_t size, int *error) |
Custom output function. More... | |
typedef void(* | gta_seek_t) (intptr_t userdata, intmax_t offset, int whence, int *error) |
Custom seek function. More... | |
typedef struct gta_internal_io_state_struct | gta_io_state_t |
State for element-based input/output. More... | |
Enumerations | |
enum | gta_result_t { GTA_OK = 0, GTA_OVERFLOW = 1, GTA_UNSUPPORTED_DATA = 2, GTA_UNEXPECTED_EOF = 3, GTA_INVALID_DATA = 4, GTA_SYSTEM_ERROR = 5 } |
GTA result type. More... | |
enum | gta_type_t { GTA_INT8 = 1, GTA_UINT8 = 2, GTA_INT16 = 3, GTA_UINT16 = 4, GTA_INT32 = 5, GTA_UINT32 = 6, GTA_INT64 = 7, GTA_UINT64 = 8, GTA_INT128 = 9, GTA_UINT128 = 10, GTA_FLOAT32 = 11, GTA_FLOAT64 = 12, GTA_FLOAT128 = 13, GTA_CFLOAT32 = 14, GTA_CFLOAT64 = 15, GTA_CFLOAT128 = 16, GTA_BLOB = 0 } |
GTA data types. More... | |
enum | gta_compression_t { GTA_NONE = 0, GTA_ZLIB = 1, GTA_ZLIB1 = 4, GTA_ZLIB2 = 5, GTA_ZLIB3 = 6, GTA_ZLIB4 = 7, GTA_ZLIB5 = 8, GTA_ZLIB6 = 9, GTA_ZLIB7 = 10, GTA_ZLIB8 = 11, GTA_ZLIB9 = 12, GTA_BZIP2 = 2, GTA_XZ = 3 } |
GTA compression algorithms. More... | |
Functions | |
Version information | |
const char * | gta_version (int *restrict major, int *restrict minor, int *restrict patch) |
Get the libgta version. More... | |
Create and destroy GTA Headers | |
gta_result_t | gta_create_header (gta_header_t *restrict *restrict header) |
Create a new GTA header structure and initialize it. More... | |
gta_result_t | gta_clone_header (gta_header_t *restrict dst_header, const gta_header_t *restrict src_header) |
Clone a GTA header structure. More... | |
void | gta_destroy_header (gta_header_t *restrict header) |
Destroy a GTA header structure and free its resources. More... | |
Read and Write GTA Headers | |
gta_result_t | gta_read_header (gta_header_t *restrict header, gta_read_t read_fn, intptr_t userdata) |
Read a GTA header. More... | |
gta_result_t | gta_read_header_from_stream (gta_header_t *restrict header, FILE *restrict f) |
Read a GTA header from a stream. More... | |
gta_result_t | gta_read_header_from_fd (gta_header_t *restrict header, int fd) |
Read a GTA header from a file descriptor. More... | |
gta_result_t | gta_write_header (const gta_header_t *restrict header, gta_write_t write_fn, intptr_t userdata) |
Write a GTA header. More... | |
gta_result_t | gta_write_header_to_stream (const gta_header_t *restrict header, FILE *restrict f) |
Write a GTA header to a stream. More... | |
gta_result_t | gta_write_header_to_fd (const gta_header_t *restrict header, int fd) |
Write a GTA header to a file descriptor. More... | |
Access GTA Headers | |
const gta_taglist_t * | gta_get_global_taglist_const (const gta_header_t *restrict header) |
Get the global tag list (non-modifiable). More... | |
gta_taglist_t * | gta_get_global_taglist (gta_header_t *restrict header) |
Get the global tag list (modifiable). More... | |
uintmax_t | gta_get_element_size (const gta_header_t *restrict header) |
Return the size of an array element. More... | |
uintmax_t | gta_get_components (const gta_header_t *restrict header) |
Get the number of components. More... | |
gta_type_t | gta_get_component_type (const gta_header_t *restrict header, uintmax_t i) |
Get the type of a component. More... | |
uintmax_t | gta_get_component_size (const gta_header_t *restrict header, uintmax_t i) |
Get the size of a component. More... | |
const gta_taglist_t * | gta_get_component_taglist_const (const gta_header_t *restrict header, uintmax_t i) |
Get the tag list of a component (non-modifiable). More... | |
gta_taglist_t * | gta_get_component_taglist (gta_header_t *restrict header, uintmax_t i) |
Get the tag list of a component (modifiable). More... | |
uintmax_t | gta_get_dimensions (const gta_header_t *restrict header) |
Get the number of dimensions. More... | |
uintmax_t | gta_get_dimension_size (const gta_header_t *restrict header, uintmax_t i) |
Get the size in a dimension. More... | |
const gta_taglist_t * | gta_get_dimension_taglist_const (const gta_header_t *restrict header, uintmax_t i) |
Get the tag list of a dimension (non-modifiable). More... | |
gta_taglist_t * | gta_get_dimension_taglist (gta_header_t *restrict header, uintmax_t i) |
Get the tag list of a dimension (modifiable). More... | |
uintmax_t | gta_get_elements (const gta_header_t *restrict header) |
Get the total number of elements in the array. More... | |
uintmax_t | gta_get_data_size (const gta_header_t *restrict header) |
Get the total size of the array data. More... | |
gta_compression_t | gta_get_compression (const gta_header_t *restrict header) |
Get the compression. More... | |
void | gta_set_compression (gta_header_t *restrict header, gta_compression_t compression) |
Set the compression. More... | |
Define an Array | |
gta_result_t | gta_set_components (gta_header_t *restrict header, uintmax_t n, const gta_type_t *restrict types, const uintmax_t *restrict sizes) |
Set the components of an array element. More... | |
gta_result_t | gta_set_dimensions (gta_header_t *restrict header, uintmax_t n, const uintmax_t *restrict sizes) |
Set the dimensions. More... | |
Access Tag Lists | |
uintmax_t | gta_get_tags (const gta_taglist_t *restrict taglist) |
Get the number of tags in a tag list. More... | |
const char * | gta_get_tag_name (const gta_taglist_t *restrict taglist, uintmax_t i) |
Get the tag name with the given index. More... | |
const char * | gta_get_tag_value (const gta_taglist_t *restrict taglist, uintmax_t i) |
Get the tag value with the given index. More... | |
const char * | gta_get_tag (const gta_taglist_t *restrict taglist, const char *restrict name) |
Get a tag value by its name. More... | |
gta_result_t | gta_set_tag (gta_taglist_t *restrict taglist, const char *restrict name, const char *restrict value) |
Set a tag. More... | |
gta_result_t | gta_unset_tag (gta_taglist_t *restrict taglist, const char *restrict name) |
Unset a tag. More... | |
void | gta_unset_all_tags (gta_taglist_t *restrict taglist) |
Unset all tags. More... | |
gta_result_t | gta_clone_taglist (gta_taglist_t *restrict dst_taglist, const gta_taglist_t *restrict src_taglist) |
Clone a tag list. More... | |
Read and Write Complete Arrays | |
These functions are intended to be used by applications that know that all the data will fit into memory. | |
gta_result_t | gta_read_data (const gta_header_t *restrict header, void *restrict data, gta_read_t read_fn, intptr_t userdata) |
Read the complete data. More... | |
gta_result_t | gta_read_data_from_stream (const gta_header_t *restrict header, void *restrict data, FILE *restrict f) |
Read the complete data from a stream. More... | |
gta_result_t | gta_read_data_from_fd (const gta_header_t *restrict header, void *restrict data, int fd) |
Read the complete data from a file descriptor. More... | |
gta_result_t | gta_skip_data (const gta_header_t *restrict header, gta_read_t read_fn, gta_seek_t seek_fn, intptr_t userdata) |
Skip the complete data. More... | |
gta_result_t | gta_skip_data_from_stream (const gta_header_t *restrict header, FILE *restrict f) |
Skip the complete data from a stream. More... | |
gta_result_t | gta_skip_data_from_fd (const gta_header_t *restrict header, int fd) |
Skip the complete data from a file descriptor. More... | |
gta_result_t | gta_write_data (const gta_header_t *restrict header, const void *restrict data, gta_write_t write_fn, intptr_t userdata) |
Write the complete data. More... | |
gta_result_t | gta_write_data_to_stream (const gta_header_t *restrict header, const void *restrict data, FILE *restrict f) |
Write the complete data to a stream. More... | |
gta_result_t | gta_write_data_to_fd (const gta_header_t *restrict header, const void *restrict data, int fd) |
Write the complete data to a file descriptor. More... | |
gta_result_t | gta_copy_data (const gta_header_t *restrict read_header, gta_read_t read_fn, intptr_t read_userdata, const gta_header_t *restrict write_header, gta_write_t write_fn, intptr_t write_userdata) |
Copy the complete data. More... | |
gta_result_t | gta_copy_data_stream (const gta_header_t *restrict read_header, FILE *restrict read_f, const gta_header_t *restrict write_header, FILE *restrict write_f) |
Copy the complete data between streams. More... | |
gta_result_t | gta_copy_data_fd (const gta_header_t *restrict read_header, int read_fd, const gta_header_t *restrict write_header, int write_fd) |
Copy the complete data between file descriptors. More... | |
In-Memory Data Access | |
void | gta_linear_index_to_indices (const gta_header_t *restrict header, uintmax_t index, uintmax_t *restrict indices) |
Transform a linear index to array indices. More... | |
uintmax_t | gta_indices_to_linear_index (const gta_header_t *restrict header, const uintmax_t *restrict indices) |
Transform array indices to a linear index. More... | |
const void * | gta_get_element_const (const gta_header_t *restrict header, const void *restrict data, const uintmax_t *restrict indices) |
Get the address of an array element (non-modifiable). More... | |
void * | gta_get_element (const gta_header_t *restrict header, void *restrict data, const uintmax_t *restrict indices) |
Get the address of an array element (modifiable). More... | |
const void * | gta_get_element_linear_const (const gta_header_t *restrict header, const void *restrict data, uintmax_t index) |
Get the address of an array element (non-modifiable). More... | |
void * | gta_get_element_linear (const gta_header_t *restrict header, void *restrict data, uintmax_t index) |
Get the address of an array element (modifiable). More... | |
const void * | gta_get_component_const (const gta_header_t *restrict header, const void *restrict element, uintmax_t i) |
Get the address of a component of an array element (non-modifiable). More... | |
void * | gta_get_component (const gta_header_t *restrict header, void *restrict element, uintmax_t i) |
Get the address of a component of an array element (modifiable). More... | |
Read and Write Array Elements | |
These functions are intended to be used for filtering a complete array on a per-element basis. They read or write a given number of elements, and it is expected that they are used repeatedly until all elements of an array have been read or written. Theses function work for all GTAs, an the input and output streams do not need to be seekable. Element-based input/output needs a state structure. This structure must be allocated with gta_create_io_state() before the first element is read or written, and freed with gta_destroy_io_state() after the last element was read or written, or after an error occured. | |
gta_result_t | gta_create_io_state (gta_io_state_t *restrict *restrict io_state) |
Create and initialize a new input/output state. More... | |
gta_result_t | gta_clone_io_state (gta_io_state_t *restrict dst_io_state, const gta_io_state_t *restrict src_io_state) |
Clone an input/output state. More... | |
void | gta_destroy_io_state (gta_io_state_t *restrict io_state) |
Destroy input/output state and free its resources. More... | |
gta_result_t | gta_read_elements (const gta_header_t *restrict header, gta_io_state_t *restrict io_state, uintmax_t n, void *restrict buf, gta_read_t read_fn, intptr_t userdata) |
Read array elements. More... | |
gta_result_t | gta_read_elements_from_stream (const gta_header_t *restrict header, gta_io_state_t *restrict io_state, uintmax_t n, void *restrict buf, FILE *restrict f) |
Read array elements. More... | |
gta_result_t | gta_read_elements_from_fd (const gta_header_t *restrict header, gta_io_state_t *restrict io_state, uintmax_t n, void *restrict buf, int fd) |
Read array elements. More... | |
gta_result_t | gta_write_elements (const gta_header_t *restrict header, gta_io_state_t *restrict io_state, uintmax_t n, const void *restrict buf, gta_write_t write_fn, intptr_t userdata) |
Write array elements. More... | |
gta_result_t | gta_write_elements_to_stream (const gta_header_t *restrict header, gta_io_state_t *restrict io_state, uintmax_t n, const void *restrict buf, FILE *restrict f) |
Write array elements. More... | |
gta_result_t | gta_write_elements_to_fd (const gta_header_t *restrict header, gta_io_state_t *restrict io_state, uintmax_t n, const void *restrict buf, int fd) |
Write array elements. More... | |
Read and Write Array Blocks | |
These functions can only be used if the input/output is seekable. | |
gta_result_t | gta_read_block (const gta_header_t *restrict header, intmax_t data_offset, const uintmax_t *restrict lower_coordinates, const uintmax_t *restrict higher_coordinates, void *restrict block, gta_read_t read_fn, gta_seek_t seek_fn, intptr_t userdata) |
Read an array block. More... | |
gta_result_t | gta_read_block_from_stream (const gta_header_t *restrict header, intmax_t data_offset, const uintmax_t *restrict lower_coordinates, const uintmax_t *restrict higher_coordinates, void *restrict block, FILE *restrict f) |
Read an array block from a stream. More... | |
gta_result_t | gta_read_block_from_fd (const gta_header_t *restrict header, intmax_t data_offset, const uintmax_t *restrict lower_coordinates, const uintmax_t *restrict higher_coordinates, void *restrict block, int fd) |
Read an array block from a file descriptor. More... | |
gta_result_t | gta_write_block (const gta_header_t *restrict header, intmax_t data_offset, const uintmax_t *restrict lower_coordinates, const uintmax_t *restrict higher_coordinates, const void *restrict block, gta_write_t write_fn, gta_seek_t seek_fn, intptr_t userdata) |
Write an array block. More... | |
gta_result_t | gta_write_block_to_stream (const gta_header_t *restrict header, intmax_t data_offset, const uintmax_t *restrict lower_coordinates, const uintmax_t *restrict higher_coordinates, const void *restrict block, FILE *restrict f) |
Write an array block to a stream. More... | |
gta_result_t | gta_write_block_to_fd (const gta_header_t *restrict header, intmax_t data_offset, const uintmax_t *restrict lower_coordinates, const uintmax_t *restrict higher_coordinates, const void *restrict block, int fd) |
Write an array block to a file descriptor. More... | |
The libgta C interface.
This document describes the C language interface of libgta.
typedef struct gta_internal_taglist_struct gta_taglist_t |
The GTA tag list type.
A tag consists of a name and a value. A tag list stores these name/value pairs.
Tag names are non-empty UTF-8 strings that must not contain '='.
Tag values are UTF-8 strings.
If you do not want to deal with conversions between the local character set and UTF-8, you must restrict names and values to ASCII.
typedef size_t(* gta_read_t) (intptr_t userdata, void *buffer, size_t size, int *error) |
Custom input function.
You can specify your own input function to read from your own custom sources.
It must read the given number of bytes into the given buffer.
Its return value must be the number of bytes successfully read.
If an error occured, the error flag must be set to true (1). The function must set errno to indicate the type of error. If the error type is unknown, errno should be set to EIO.
typedef size_t(* gta_write_t) (intptr_t userdata, const void *buffer, size_t size, int *error) |
Custom output function.
You can specify your own output function to write to your own custum destinations.
It must write the given number of bytes from the given buffer.
Its return value must be the number of bytes successfully written.
If an error occured, the error flag must be set to true (1). The function must set errno to indicate the type of error. If the error type is unknown, errno should be set to EIO.
typedef void(* gta_seek_t) (intptr_t userdata, intmax_t offset, int whence, int *error) |
Custom seek function.
You can specify your own seek function to seek in your own custum media.
It must change its file position indicator as indicated by the parameters offset and whence, just like fseeko() and lseek() do. The parameter whence can be SEEK_SET or SEEK_CUR (SEEK_END is never used).
If an error occured, the error flag must be set to true (1). The function must set errno to indicate the type of error. If the error type is unknown, errno should be set to EIO.
typedef struct gta_internal_io_state_struct gta_io_state_t |
State for element-based input/output.
See gta_read_elements() and gta_write_elements().
enum gta_result_t |
GTA result type.
The return value of most GTA functions is of this type, to indicate failures and their causes.
enum gta_type_t |
GTA data types.
Data types supported by GTA.
All integer types contain the exact number of bits indicated by their name and use the common two's complement representation.
All floating point types contain the exact number of bits indicated by their name and conform to the binary representation defined by IEEE 754.
The complex types (GTA_CFLOAT*) consist of two floating point values with the number of bits indicated by the name, as defined above. The first value is the real part, the second value is the imaginary part. For example, GTA_CFLOAT32 consists of two GTA_FLOAT32 values.
The name GTA_BLOB can be used for data types that are not defined in this list. In this case, the size of the data type must be given, and the data type must be independent of endianness.
enum gta_compression_t |
GTA compression algorithms.
These are deprecated. Do not use them anymore, they will be removed in a future version.
const char* gta_version | ( | int *restrict | major, |
int *restrict | minor, | ||
int *restrict | patch | ||
) |
Get the libgta version.
major | Buffer for the major version number, or NULL. |
minor | Buffer for the minor version number, or NULL. |
patch | Buffer for the patch version number, or NULL. |
This function returns the version string "MAJOR.MINOR.PATCH". If the pointers major, minor, patch are not NULL, the requested version number will be stored there.
gta_result_t gta_create_header | ( | gta_header_t *restrict *restrict | header | ) |
Create a new GTA header structure and initialize it.
header | The header. |
Creates a new GTA header and initializes it. The GTA will initially be empty (zero element components, zero dimensions) and contain no tags.
gta_result_t gta_clone_header | ( | gta_header_t *restrict | dst_header, |
const gta_header_t *restrict | src_header | ||
) |
Clone a GTA header structure.
dst_header | The destination header. |
src_header | The source header. |
Clones src_header into dst_header.
void gta_destroy_header | ( | gta_header_t *restrict | header | ) |
Destroy a GTA header structure and free its resources.
header | The header. |
Destroys a GTA header structure and fress all of its resources.
gta_result_t gta_read_header | ( | gta_header_t *restrict | header, |
gta_read_t | read_fn, | ||
intptr_t | userdata | ||
) |
Read a GTA header.
header | The header. |
read_fn | The custom input function. |
userdata | A parameter to the custom input function. |
gta_result_t gta_read_header_from_stream | ( | gta_header_t *restrict | header, |
FILE *restrict | f | ||
) |
Read a GTA header from a stream.
header | The header. |
f | The stream. |
Reads a GTA header from a stream.
The file position indicator will be positioned after the GTA header, on the first data byte.
gta_result_t gta_read_header_from_fd | ( | gta_header_t *restrict | header, |
int | fd | ||
) |
Read a GTA header from a file descriptor.
header | The header. |
fd | The file descriptor. |
Reads a GTA header from a file descriptor.
The file position indicator will be positioned after the GTA header, on the first data byte.
gta_result_t gta_write_header | ( | const gta_header_t *restrict | header, |
gta_write_t | write_fn, | ||
intptr_t | userdata | ||
) |
Write a GTA header.
header | The header. |
write_fn | The custom output function. |
userdata | A parameter to the custom output function. |
gta_result_t gta_write_header_to_stream | ( | const gta_header_t *restrict | header, |
FILE *restrict | f | ||
) |
Write a GTA header to a stream.
header | The header. |
f | The stream. |
gta_result_t gta_write_header_to_fd | ( | const gta_header_t *restrict | header, |
int | fd | ||
) |
Write a GTA header to a file descriptor.
header | The header. |
fd | The file descriptor. |
const gta_taglist_t* gta_get_global_taglist_const | ( | const gta_header_t *restrict | header | ) |
Get the global tag list (non-modifiable).
header | The header. |
gta_taglist_t* gta_get_global_taglist | ( | gta_header_t *restrict | header | ) |
Get the global tag list (modifiable).
header | The header. |
uintmax_t gta_get_element_size | ( | const gta_header_t *restrict | header | ) |
Return the size of an array element.
header | The header. |
uintmax_t gta_get_components | ( | const gta_header_t *restrict | header | ) |
Get the number of components.
header | The header. |
gta_type_t gta_get_component_type | ( | const gta_header_t *restrict | header, |
uintmax_t | i | ||
) |
Get the type of a component.
header | The header. |
i | The component index. |
uintmax_t gta_get_component_size | ( | const gta_header_t *restrict | header, |
uintmax_t | i | ||
) |
Get the size of a component.
header | The header. |
i | The component index. |
const gta_taglist_t* gta_get_component_taglist_const | ( | const gta_header_t *restrict | header, |
uintmax_t | i | ||
) |
Get the tag list of a component (non-modifiable).
header | The header. |
i | The component index. |
gta_taglist_t* gta_get_component_taglist | ( | gta_header_t *restrict | header, |
uintmax_t | i | ||
) |
Get the tag list of a component (modifiable).
header | The header. |
i | The component index. |
uintmax_t gta_get_dimensions | ( | const gta_header_t *restrict | header | ) |
Get the number of dimensions.
header | The header. |
uintmax_t gta_get_dimension_size | ( | const gta_header_t *restrict | header, |
uintmax_t | i | ||
) |
Get the size in a dimension.
header | The header. |
i | The dimension index. |
const gta_taglist_t* gta_get_dimension_taglist_const | ( | const gta_header_t *restrict | header, |
uintmax_t | i | ||
) |
Get the tag list of a dimension (non-modifiable).
header | The header. |
i | The dimension index. |
gta_taglist_t* gta_get_dimension_taglist | ( | gta_header_t *restrict | header, |
uintmax_t | i | ||
) |
Get the tag list of a dimension (modifiable).
header | The header. |
i | The dimension index. |
uintmax_t gta_get_elements | ( | const gta_header_t *restrict | header | ) |
Get the total number of elements in the array.
header | The header. |
uintmax_t gta_get_data_size | ( | const gta_header_t *restrict | header | ) |
Get the total size of the array data.
header | The header. |
gta_compression_t gta_get_compression | ( | const gta_header_t *restrict | header | ) |
Get the compression.
header | The header. |
Gets the compression type for the header and data. Compression is deprecated so the return value should always be GTA_NONE, unless you read legacy files. This function will be removed in a future version.
void gta_set_compression | ( | gta_header_t *restrict | header, |
gta_compression_t | compression | ||
) |
Set the compression.
header | The header. |
compression | The compression type. |
Sets the compression type for writing the header and data. Compression is deprecated and this function actually does nothing. This function will be removed in a future version.
gta_result_t gta_set_components | ( | gta_header_t *restrict | header, |
uintmax_t | n, | ||
const gta_type_t *restrict | types, | ||
const uintmax_t *restrict | sizes | ||
) |
Set the components of an array element.
header | The header. |
n | The number of components. |
types | The types of the n components. |
sizes | NULL, or the sizes of the components that have type GTA_BLOB. |
Set the components of the array elements.
The sizes parameter can be NULL if no components have the type GTA_BLOB. Otherwise, it must point to a list that contains the sizes of these components (and only these components). For example, if there are five components, but only two have the type GTA_BLOB, then the sizes list must contain two size values.
All components will initially have an empty tag list.
gta_result_t gta_set_dimensions | ( | gta_header_t *restrict | header, |
uintmax_t | n, | ||
const uintmax_t *restrict | sizes | ||
) |
Set the dimensions.
header | The header. |
n | The number of dimensions. |
sizes | The array sizes in each of the dimensions. |
Sets the array dimensions.
All dimensions will initially have an empty tag list.
uintmax_t gta_get_tags | ( | const gta_taglist_t *restrict | taglist | ) |
Get the number of tags in a tag list.
taglist | The tag list. |
const char* gta_get_tag_name | ( | const gta_taglist_t *restrict | taglist, |
uintmax_t | i | ||
) |
Get the tag name with the given index.
taglist | The tag list. |
i | The tag index. |
const char* gta_get_tag_value | ( | const gta_taglist_t *restrict | taglist, |
uintmax_t | i | ||
) |
Get the tag value with the given index.
taglist | The tag list. |
i | The tag index. |
const char* gta_get_tag | ( | const gta_taglist_t *restrict | taglist, |
const char *restrict | name | ||
) |
Get a tag value by its name.
taglist | The tag list. |
name | The tag name. |
gta_result_t gta_set_tag | ( | gta_taglist_t *restrict | taglist, |
const char *restrict | name, | ||
const char *restrict | value | ||
) |
Set a tag.
taglist | The tag list. |
name | The name. |
value | The value. |
Sets the given tag, possibly overwriting an existing tag with the same name. The name and value must be valid UTF-8 strings without control characters. Additionally, the name must not contain the equal sign and must not be empty.
gta_result_t gta_unset_tag | ( | gta_taglist_t *restrict | taglist, |
const char *restrict | name | ||
) |
Unset a tag.
taglist | The tag list. |
name | The tag name. |
Removes the tag with the given name, if it exists.
void gta_unset_all_tags | ( | gta_taglist_t *restrict | taglist | ) |
Unset all tags.
taglist | The tag list. |
Removes all tags from the tag list.
gta_result_t gta_clone_taglist | ( | gta_taglist_t *restrict | dst_taglist, |
const gta_taglist_t *restrict | src_taglist | ||
) |
Clone a tag list.
dst_taglist | The destination tag list. |
src_taglist | The source tag list. |
Copies src_taglist to dst_taglist.
gta_result_t gta_read_data | ( | const gta_header_t *restrict | header, |
void *restrict | data, | ||
gta_read_t | read_fn, | ||
intptr_t | userdata | ||
) |
Read the complete data.
header | The header. |
data | The data buffer. |
read_fn | The custom input function. |
userdata | A parameter to the custom input function. |
Reads the complete data into the given buffer. The buffer must be large enough.
gta_result_t gta_read_data_from_stream | ( | const gta_header_t *restrict | header, |
void *restrict | data, | ||
FILE *restrict | f | ||
) |
Read the complete data from a stream.
header | The header. |
data | The data buffer. |
f | The stream. |
Reads the complete data into the given buffer. The buffer must be large enough.
gta_result_t gta_read_data_from_fd | ( | const gta_header_t *restrict | header, |
void *restrict | data, | ||
int | fd | ||
) |
Read the complete data from a file descriptor.
header | The header. |
data | The data buffer. |
fd | The file descriptor. |
Reads the complete data into the given buffer. The buffer must be large enough.
gta_result_t gta_skip_data | ( | const gta_header_t *restrict | header, |
gta_read_t | read_fn, | ||
gta_seek_t | seek_fn, | ||
intptr_t | userdata | ||
) |
Skip the complete data.
header | The header. |
read_fn | The custom input function. |
seek_fn | The custom seek function, or NULL for non-seekable input. |
userdata | A parameter to the custom input and seek functions. |
Skips the complete data, so that the next GTA header can be read.
gta_result_t gta_skip_data_from_stream | ( | const gta_header_t *restrict | header, |
FILE *restrict | f | ||
) |
Skip the complete data from a stream.
header | The header. |
f | The stream. |
Skips the complete data, so that the next GTA header can be read.
gta_result_t gta_skip_data_from_fd | ( | const gta_header_t *restrict | header, |
int | fd | ||
) |
Skip the complete data from a file descriptor.
header | The header. |
fd | The file descriptor. |
Skips the complete data, so that the next GTA header can be read.
gta_result_t gta_write_data | ( | const gta_header_t *restrict | header, |
const void *restrict | data, | ||
gta_write_t | write_fn, | ||
intptr_t | userdata | ||
) |
Write the complete data.
header | The header. |
data | The data buffer. |
write_fn | The custom output function. |
userdata | A parameter to the custom output function. |
Writes the complete data.
gta_result_t gta_write_data_to_stream | ( | const gta_header_t *restrict | header, |
const void *restrict | data, | ||
FILE *restrict | f | ||
) |
Write the complete data to a stream.
header | The header. |
data | The data buffer. |
f | The stream. |
Writes the complete data.
gta_result_t gta_write_data_to_fd | ( | const gta_header_t *restrict | header, |
const void *restrict | data, | ||
int | fd | ||
) |
Write the complete data to a file descriptor.
header | The header. |
data | The data buffer. |
fd | The file descriptor. |
Writes the complete data.
gta_result_t gta_copy_data | ( | const gta_header_t *restrict | read_header, |
gta_read_t | read_fn, | ||
intptr_t | read_userdata, | ||
const gta_header_t *restrict | write_header, | ||
gta_write_t | write_fn, | ||
intptr_t | write_userdata | ||
) |
Copy the complete data.
read_header | The input header. |
read_fn | The custom input function. |
read_userdata | A parameter to the custom input function. |
write_header | The ourput header. |
write_fn | The custom output function. |
write_userdata | A parameter to the custom output function. |
Copies the complete data. The data encoding is altered as necessary (endianness correction). Note that the data encoding may change even if read_header and write_header point to the same header!
gta_result_t gta_copy_data_stream | ( | const gta_header_t *restrict | read_header, |
FILE *restrict | read_f, | ||
const gta_header_t *restrict | write_header, | ||
FILE *restrict | write_f | ||
) |
Copy the complete data between streams.
read_header | The input header. |
read_f | The input stream. |
write_header | The output header. |
write_f | The output stream. |
Copies the complete data. The data encoding is altered as necessary (endianness correction). Note that the data encoding may change even if read_header and write_header point to the same header!
gta_result_t gta_copy_data_fd | ( | const gta_header_t *restrict | read_header, |
int | read_fd, | ||
const gta_header_t *restrict | write_header, | ||
int | write_fd | ||
) |
Copy the complete data between file descriptors.
read_header | The input header. |
read_fd | The input file descriptor. |
write_header | The output header. |
write_fd | The output file descriptor. |
Copies the complete data. The data encoding is altered as necessary (endianness correction). Note that the data encoding may change even if read_header and write_header point to the same header!
void gta_linear_index_to_indices | ( | const gta_header_t *restrict | header, |
uintmax_t | index, | ||
uintmax_t *restrict | indices | ||
) |
Transform a linear index to array indices.
header | The header. |
index | The linear index. |
indices | The array indices. |
uintmax_t gta_indices_to_linear_index | ( | const gta_header_t *restrict | header, |
const uintmax_t *restrict | indices | ||
) |
Transform array indices to a linear index.
header | The header. |
indices | The array indices. |
const void* gta_get_element_const | ( | const gta_header_t *restrict | header, |
const void *restrict | data, | ||
const uintmax_t *restrict | indices | ||
) |
Get the address of an array element (non-modifiable).
header | The header. |
data | The data. |
indices | The indices for each dimension of the array. |
void* gta_get_element | ( | const gta_header_t *restrict | header, |
void *restrict | data, | ||
const uintmax_t *restrict | indices | ||
) |
Get the address of an array element (modifiable).
header | The header. |
data | The data. |
indices | The indices for each dimension of the array. |
const void* gta_get_element_linear_const | ( | const gta_header_t *restrict | header, |
const void *restrict | data, | ||
uintmax_t | index | ||
) |
Get the address of an array element (non-modifiable).
header | The header. |
data | The data. |
index | The linear index of the element. |
void* gta_get_element_linear | ( | const gta_header_t *restrict | header, |
void *restrict | data, | ||
uintmax_t | index | ||
) |
Get the address of an array element (modifiable).
header | The header. |
data | The data. |
index | The linear index of the element. |
const void* gta_get_component_const | ( | const gta_header_t *restrict | header, |
const void *restrict | element, | ||
uintmax_t | i | ||
) |
Get the address of a component of an array element (non-modifiable).
header | The header. |
element | The element. |
i | The component index. |
void* gta_get_component | ( | const gta_header_t *restrict | header, |
void *restrict | element, | ||
uintmax_t | i | ||
) |
Get the address of a component of an array element (modifiable).
header | The header. |
element | The element. |
i | The component index. |
gta_result_t gta_create_io_state | ( | gta_io_state_t *restrict *restrict | io_state | ) |
Create and initialize a new input/output state.
io_state | The input/output state. |
Creates and initializes a state structure for element-based input/output.
gta_result_t gta_clone_io_state | ( | gta_io_state_t *restrict | dst_io_state, |
const gta_io_state_t *restrict | src_io_state | ||
) |
Clone an input/output state.
dst_io_state | The destination state. |
src_io_state | The source state. |
Clones src_io_state into dst_io_state.
void gta_destroy_io_state | ( | gta_io_state_t *restrict | io_state | ) |
Destroy input/output state and free its resources.
io_state | The input/output state. |
Destroys a state structure for element-based input/output and frees its resources.
gta_result_t gta_read_elements | ( | const gta_header_t *restrict | header, |
gta_io_state_t *restrict | io_state, | ||
uintmax_t | n, | ||
void *restrict | buf, | ||
gta_read_t | read_fn, | ||
intptr_t | userdata | ||
) |
Read array elements.
header | The header. |
io_state | The input/output state. |
n | The number of elements to read. |
buf | The buffer for the elements. |
read_fn | The custom input function. |
userdata | A parameter to the custom input function. |
Reads the given number of elements into the given buffer, which must be large enough.
gta_result_t gta_read_elements_from_stream | ( | const gta_header_t *restrict | header, |
gta_io_state_t *restrict | io_state, | ||
uintmax_t | n, | ||
void *restrict | buf, | ||
FILE *restrict | f | ||
) |
Read array elements.
header | The header. |
io_state | The input/output state. |
n | The number of elements to read. |
buf | The buffer for the elements. |
f | The stream. |
Reads the given number of elements into the given buffer, which must be large enough.
gta_result_t gta_read_elements_from_fd | ( | const gta_header_t *restrict | header, |
gta_io_state_t *restrict | io_state, | ||
uintmax_t | n, | ||
void *restrict | buf, | ||
int | fd | ||
) |
Read array elements.
header | The header. |
io_state | The input/output state. |
n | The number of elements to read. |
buf | The buffer for the elements. |
fd | The file descriptor. |
Reads the given number of elements into the given buffer, which must be large enough.
gta_result_t gta_write_elements | ( | const gta_header_t *restrict | header, |
gta_io_state_t *restrict | io_state, | ||
uintmax_t | n, | ||
const void *restrict | buf, | ||
gta_write_t | write_fn, | ||
intptr_t | userdata | ||
) |
Write array elements.
header | The header. |
io_state | The input/output state. |
n | The number of elements to write. |
buf | The buffer for the elements. |
write_fn | The custom output function. |
userdata | A parameter to the custom output function. |
Writes the given number of elements from the given buffer.
gta_result_t gta_write_elements_to_stream | ( | const gta_header_t *restrict | header, |
gta_io_state_t *restrict | io_state, | ||
uintmax_t | n, | ||
const void *restrict | buf, | ||
FILE *restrict | f | ||
) |
Write array elements.
header | The header. |
io_state | The input/output state. |
n | The number of elements to write. |
buf | The buffer for the elements. |
f | The stream. |
Writes the given number of elements from the given buffer.
gta_result_t gta_write_elements_to_fd | ( | const gta_header_t *restrict | header, |
gta_io_state_t *restrict | io_state, | ||
uintmax_t | n, | ||
const void *restrict | buf, | ||
int | fd | ||
) |
Write array elements.
header | The header. |
io_state | The input/output state. |
n | The number of elements to write. |
buf | The buffer for the elements. |
fd | The file descriptor. |
Writes the given number of elements from the given buffer.
gta_result_t gta_read_block | ( | const gta_header_t *restrict | header, |
intmax_t | data_offset, | ||
const uintmax_t *restrict | lower_coordinates, | ||
const uintmax_t *restrict | higher_coordinates, | ||
void *restrict | block, | ||
gta_read_t | read_fn, | ||
gta_seek_t | seek_fn, | ||
intptr_t | userdata | ||
) |
Read an array block.
header | The header. |
data_offset | Offset of the first data byte. |
lower_coordinates | Coordinates of the lower corner element of the block. |
higher_coordinates | Coordinates of the higher corner element of the block. |
block | The block buffer. |
read_fn | The custom input function. |
seek_fn | The custom seek function. |
userdata | A parameter to the custom input function. |
Reads the given array block and copies it to the given block buffer, which must be large enough.
This function modifies the file position indicator of the input.
gta_result_t gta_read_block_from_stream | ( | const gta_header_t *restrict | header, |
intmax_t | data_offset, | ||
const uintmax_t *restrict | lower_coordinates, | ||
const uintmax_t *restrict | higher_coordinates, | ||
void *restrict | block, | ||
FILE *restrict | f | ||
) |
Read an array block from a stream.
header | The header. |
data_offset | Offset of the first data byte. |
lower_coordinates | Coordinates of the lower corner element of the block. |
higher_coordinates | Coordinates of the higher corner element of the block. |
block | The block buffer. |
f | The stream. |
Reads the given array block and copies it to the given block buffer, which must be large enough.
This function modifies the file position indicator of the input.
gta_result_t gta_read_block_from_fd | ( | const gta_header_t *restrict | header, |
intmax_t | data_offset, | ||
const uintmax_t *restrict | lower_coordinates, | ||
const uintmax_t *restrict | higher_coordinates, | ||
void *restrict | block, | ||
int | fd | ||
) |
Read an array block from a file descriptor.
header | The header. |
data_offset | Offset of the first data byte. |
lower_coordinates | Coordinates of the lower corner element of the block. |
higher_coordinates | Coordinates of the higher corner element of the block. |
block | The block buffer. |
fd | The file descriptor. |
Reads the given array block and copies it to the given block buffer, which must be large enough.
This function modifies the file position indicator of the input.
gta_result_t gta_write_block | ( | const gta_header_t *restrict | header, |
intmax_t | data_offset, | ||
const uintmax_t *restrict | lower_coordinates, | ||
const uintmax_t *restrict | higher_coordinates, | ||
const void *restrict | block, | ||
gta_write_t | write_fn, | ||
gta_seek_t | seek_fn, | ||
intptr_t | userdata | ||
) |
Write an array block.
header | The header. |
data_offset | Offset of the first data byte. |
lower_coordinates | Coordinates of the lower corner element of the block. |
higher_coordinates | Coordinates of the higher corner element of the block. |
block | The block buffer. |
write_fn | The custom output function. |
seek_fn | The custom seek function. |
userdata | A parameter to the custom output function. |
This function modifies the file position indicator of the output.
gta_result_t gta_write_block_to_stream | ( | const gta_header_t *restrict | header, |
intmax_t | data_offset, | ||
const uintmax_t *restrict | lower_coordinates, | ||
const uintmax_t *restrict | higher_coordinates, | ||
const void *restrict | block, | ||
FILE *restrict | f | ||
) |
Write an array block to a stream.
header | The header. |
data_offset | Offset of the first data byte. |
lower_coordinates | Coordinates of the lower corner element of the block. |
higher_coordinates | Coordinates of the higher corner element of the block. |
block | The block buffer. |
f | The stream. |
This function modifies the file position indicator of the output.
gta_result_t gta_write_block_to_fd | ( | const gta_header_t *restrict | header, |
intmax_t | data_offset, | ||
const uintmax_t *restrict | lower_coordinates, | ||
const uintmax_t *restrict | higher_coordinates, | ||
const void *restrict | block, | ||
int | fd | ||
) |
Write an array block to a file descriptor.
header | The header. |
data_offset | Offset of the first data byte. |
lower_coordinates | Coordinates of the lower corner element of the block. |
higher_coordinates | Coordinates of the higher corner element of the block. |
block | The block buffer. |
fd | The file descriptor. |
This function modifies the file position indicator of the output.