gd_putdata
write data to a Dirfile database
- Provided by: libgetdata-doc (Version: 0.11.0-13)
- Source: libgetdata
- Report a bug
write data to a Dirfile database
#include <getdata.h>
size_t gd_putdata(DIRFILE *dirfile, const char *field_code, off_t first_frame, off_t first_sample, size_t num_frames, size_t num_samples, gd_type_t data_type, const void *data_in);
The gd_putdata() function writes data to a dirfile(5) database specified by dirfile for the field field_code, which may not contain a representation suffix. It writes num_frames frames plus num_samples samples to this field, starting first_sample samples past frame first_frame. The data is read from the user-supplied buffer data_in, which is has a data type specified by data_type. This interface cannot write to field representations.
The dirfile argument must point to a valid DIRFILE object previously created by a call to gd_open(3).
Unless using GD_HERE (see below), the first sample written will be
Instead of explicitly specifying the origin of the write, the caller may pass the special symbol GD_HERE as first_frame. This will result in the write occurring at the current position of the I/O pointer for the field (see gd_getdata(3) for a discussion of I/O pointers). In this case, the value of first_sample is ignored.
The data_type argument should be one of the following symbols, which indicates the type of the input data:
The type of the input data need not be the same as the type of the data stored in the database. Type conversion will be performed as necessary to write the appropriate type. The argument data_in must point to a valid memory location of containing all the data to be written.
Upon successful completion, the I/O pointer of the field will be on the sample immediately following the last sample written, if possible. On error, the position of the I/O pointer is not specified.
In all cases, gd_putdata() returns the number of samples (not bytes) successfully written to the database, which may be zero if an error has occurred.
On error, this function returns zero and stores a negative-valued error code in the DIRFILE object which may be retrieved by a subsequent call to gd_error(3). Possible error codes are:
A descriptive error string for the error may be obtained by calling gd_error_string(3).
When operating on a platform whose size_t is N-bytes wide, a single call of gd_putdata() will never write more than (2**(N-M) - 1) samples, where M is the size, in bytes, of the largest data type used to calculate the stored field. If a larger request is specified, less data than requested will be written, without raising an error. This limit is imposed even when data_type is GD_NULL (i.e., even when no actual I/O or calculation occurs). In all cases, the actual amount of data is returned.
The putdata() function appeared in GetData-0.3.0.
In GetData-0.7.0, this function was renamed to gd_getdata().
The GD_HERE symbol used for sequential writes appeared in GetData-0.8.0.
GD_SIZE(3), gd_error(3), gd_error_string(3), gd_getdata(3), gd_open(3), gd_put_carray(3), gd_put_constant(3), gd_put_sarray(3), gd_put_string(3), gd_seek(3), gd_spf(3), dirfile(5), dirfile-encoding(5)