gd_putdata(3)
π NAME π
gd_putdata β ok so this is the one that writes data into a Dirfile database β¨ (it lives in the GETDATA manual section, bestie, section 3, the library-calls girlies π)
π¦ SYNOPSIS π¦
#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);
πΈ DESCRIPTION πΈ
The gd_putdata() function writes data to a dirfile(5) database specified by dirfile for the field field_code, and heads up: field_code may not contain a representation suffix. Like, at all. It writes num_frames frames plus num_samples samples to this field, starting first_sample samples past frame first_frame. The data gets read from the user-supplied buffer data_in, and that buffer has a data type specified by data_type. And lowkey important: this interface cannot write to field representations, periodt.
The dirfile argument must point to a valid DIRFILE object that was previously created by a call to gd_open(3).
Unless you're using GD_HERE (more on that below π), the first sample written will be
first_frame * samples_per_frame + first_sample
as measured from the start of the dirfile, where samples_per_frame is the number of samples per frame as returned by gd_spf(3). And the number of samples which gd_putdata() attempts to write is, similarly,
num_frames * samples_per_frame + num_samples.
Ik that mixing frames and samples is possible, but the function is typically called with either num_samples and first_sample, or num_frames and first_frames, equal to zero. Pick a lane bestie π
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 (go check gd_getdata(3) for a whole discussion of I/O pointers, it's giving lore). In this case, the value of first_sample is ignored. Bye βοΈ
The data_type argument should be one of the following symbols, which indicates the type of the input data:
GD_UINT8β unsigned 8-bit integerGD_INT8β signed (two's complement) 8-bit integerGD_UINT16β unsigned 16-bit integerGD_INT16β signed (two's complement) 16-bit integerGD_UINT32β unsigned 32-bit integerGD_INT32β signed (two's complement) 32-bit integerGD_UINT64β unsigned 64-bit integerGD_INT64β signed (two's complement) 64-bit integerGD_FLOAT32β IEEE-754 standard 32-bit single precision floating point numberGD_FLOAT64β IEEE-754 standard 64-bit double precision floating point numberGD_COMPLEX64β C99-conformant 64-bit single precision complex numberGD_COMPLEX128β C99-conformant 128-bit double precision complex number
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 library is doing the glow-up for you, no cap β¨) 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 β so don't come for it, it's just vibing somewhere π
π RETURN VALUE π
In all cases, gd_putdata() returns the number of samples (not bytes, bestie, samples) 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:
GD_E_ACCMODEβ The specified dirfile was opened read-only. πGD_E_ALLOCβ The library was unable to allocate memory.GD_E_BAD_CODEβ The field specified by field_code, or one of the fields it uses for input, was not found in the database.GD_E_BAD_DIRFILEβ An invalid dirfile was supplied.GD_E_BAD_FIELD_TYPEβ Either the field specified by field_code, or one of the fields it uses for input, was ofMULTIPLY,DIVIDE,WINDOW,INDIR, orSINDIRtype, or aLINCOMwith more than one input field, or aPOLYNOMwith quadratic or higer terms. Alternately, the caller may have attempted to write to the implicitINDEXfield, which is not possible.GD_E_BAD_TYPEβ An invalid data_type was specified.GD_E_DIMENSIONβ The field specified by field_code was not a vector field. The caller should usegd_put_carray(3),gd_put_constant(3), orgd_put_string(3)instead. Or, a scalar field was found where a vector field was expected in the definition of field_code.GD_E_DOMAINβ An attempt was made to write to aLINTERPfield with a look-up table which was not monotonic or not purely real.GD_E_INTERNAL_ERRORβ An internal error occurred in the library while trying to perform the task. This indicates a bug in the library. Please report the incident to the maintainer. πGD_E_IOβ An error occurred while trying to open, read from, or write to a file on disk containing a raw field or aLINTERPtable.GD_E_LUTβ ALINTERPtable was malformed.GD_E_PROTECTEDβ The data of theRAWfield backing field_code was protected from change by a/PROTECTdirective.GD_E_RANGEβ An attempt was made to write data either before the beginning-of-frame marker for field_code, or the raw field it depends on, or else outside the addressable Dirfile range (more than 2**63 samples beyond the start of the Dirfile).GD_E_RECURSE_LEVELβ Too many levels of recursion were encountered while trying to resolve field_code. This usually indicates a circular dependency in field specification in the dirfile. πGD_E_UNSUPPORTEDβ Reading from dirfiles with the encoding scheme of the specified dirfile is not supported by the library. Seedirfile-encoding(5)for details on dirfile encoding schemes.
A descriptive error string for the error may be obtained by calling gd_error_string(3).
β NOTES β
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 math said no and she meant it π
π HISTORY π
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.
π SEE ALSO π
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)
And that's the whole page bestie!! This is Version 0.10.0, dated 25 January 2017 β an icon, a legend, and she is the moment. Go write some data πβ¨π¦
π¦ 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-2017 D. V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms