1
2
3
4
5
6
7
8
9gd_putdata(3) GETDATA gd_putdata(3)
10
11
12
14 gd_putdata — write data to a Dirfile database
15
16
18 #include <getdata.h>
19
20 size_t gd_putdata(DIRFILE *dirfile, const char *field_code, off_t
21 first_frame, off_t first_sample, size_t num_frames, size_t
22 num_samples, gd_type_t data_type, const void *data_in);
23
24
26 The gd_putdata() function writes data to a dirfile(5) database speci‐
27 fied by dirfile for the field field_code, which may not contain a rep‐
28 resentation suffix. It writes num_frames frames plus num_samples sam‐
29 ples to this field, starting first_sample samples past frame
30 first_frame. The data is read from the user-supplied buffer data_in,
31 which is has a data type specified by data_type. This interface cannot
32 write to field representations.
33
34 The dirfile argument must point to a valid DIRFILE object previously
35 created by a call to gd_open(3).
36
37 Unless using GD_HERE (see below), the first sample written will be
38 first_frame * samples_per_frame + first_sample
39 as measured from the start of the dirfile, where samples_per_frame is
40 the number of samples per frame as returned by gd_spf(3). The number
41 of samples which gd_putdata() attempts to write is, similarly,
42 num_frames * samples_per_frame + num_samples.
43 Although calling gd_putdata() using both samples and frames is possi‐
44 ble, the function is typically called with either num_samples and
45 first_sample, or num_frames and first_frames, equal to zero.
46
47 Instead of explicitly specifying the origin of the write, the caller
48 may pass the special symbol GD_HERE as first_frame. This will result
49 in the write occurring at the current position of the I/O pointer for
50 the field (see gd_getdata(3) for a discussion of I/O pointers). In
51 this case, the value of first_sample is ignored.
52
53 The data_type argument should be one of the following symbols, which
54 indicates the type of the input data:
55
56 GD_UINT8 unsigned 8-bit integer
57
58 GD_INT8 signed (two's complement) 8-bit integer
59
60 GD_UINT16
61 unsigned 16-bit integer
62
63 GD_INT16
64 signed (two's complement) 16-bit integer
65
66 GD_UINT32
67 unsigned 32-bit integer
68
69 GD_INT32
70 signed (two's complement) 32-bit integer
71
72 GD_UINT64
73 unsigned 64-bit integer
74
75 GD_INT64
76 signed (two's complement) 64-bit integer
77
78 GD_FLOAT32
79 IEEE-754 standard 32-bit single precision floating point
80 number
81
82 GD_FLOAT64
83 IEEE-754 standard 64-bit double precision floating point
84 number
85
86 GD_COMPLEX64
87 C99-conformant 64-bit single precision complex number
88
89 GD_COMPLEX128
90 C99-conformant 128-bit double precision complex number
91
92 The type of the input data need not be the same as the type of the data
93 stored in the database. Type conversion will be performed as necessary
94 to write the appropriate type. The argument data_in must point to a
95 valid memory location of containing all the data to be written.
96
97 Upon successful completion, the I/O pointer of the field will be on the
98 sample immediately following the last sample written, if possible. On
99 error, the position of the I/O pointer is not specified.
100
101
103 In all cases, gd_putdata() returns the number of samples (not bytes)
104 successfully written to the database, which may be zero if an error has
105 occurred.
106
107 On error, this function returns zero and stores a negative-valued error
108 code in the DIRFILE object which may be retrieved by a subsequent call
109 to gd_error(3). Possible error codes are:
110
111 GD_E_ACCMODE
112 The specified dirfile was opened read-only.
113
114 GD_E_ALLOC
115 The library was unable to allocate memory.
116
117 GD_E_BAD_CODE
118 The field specified by field_code, or one of the fields it uses
119 for input, was not found in the database.
120
121 GD_E_BAD_DIRFILE
122 An invalid dirfile was supplied.
123
124 GD_E_BAD_FIELD_TYPE
125 Either the field specified by field_code, or one of the fields
126 it uses for input, was of MULTIPLY, DIVIDE, WINDOW, INDIR, or
127 SINDIR type, or a LINCOM with more than one input field, or a
128 POLYNOM with quadratic or higer terms. Alternately, the caller
129 may have attempted to write to the implicit INDEX field, which
130 is not possible.
131
132 GD_E_BAD_TYPE
133 An invalid data_type was specified.
134
135 GD_E_DIMENSION
136 The field specified by field_code was not a vector field. The
137 caller should use gd_put_carray(3), gd_put_constant(3), or
138 gd_put_string(3) instead. Or, a scalar field was found where a
139 vector field was expected in the definition of field_code.
140
141 GD_E_DOMAIN
142 An attempt was made to write to a LINTERP field with a look-up
143 table which was not monotonic or not purely real.
144
145 GD_E_INTERNAL_ERROR
146 An internal error occurred in the library while trying to per‐
147 form the task. This indicates a bug in the library. Please
148 report the incident to the maintainer.
149
150 GD_E_IO An error occurred while trying to open, read from, or write to
151 a file on disk containing a raw field or a LINTERP table.
152
153 GD_E_LUT
154 A LINTERP table was malformed.
155
156 GD_E_PROTECTED
157 The data of the RAW field backing field_code was protected from
158 change by a /PROTECT directive.
159
160 GD_E_RANGE
161 An attempt was made to write data either before the beginning-
162 of-frame marker for field_code, or the raw field it depends on,
163 or else outside the addressable Dirfile range (more than 2**63
164 samples beyond the start of the Dirfile).
165
166 GD_E_RECURSE_LEVEL
167 Too many levels of recursion were encountered while trying to
168 resolve field_code. This usually indicates a circular depen‐
169 dency in field specification in the dirfile.
170
171 GD_E_UNSUPPORTED
172 Reading from dirfiles with the encoding scheme of the specified
173 dirfile is not supported by the library. See dirfile-encod‐
174 ing(5) for details on dirfile encoding schemes.
175
176 A descriptive error string for the error may be obtained by calling
177 gd_error_string(3).
178
179
181 When operating on a platform whose size_t is N-bytes wide, a single
182 call of gd_putdata() will never write more than (2**(N-M) - 1) samples,
183 where M is the size, in bytes, of the largest data type used to calcu‐
184 late the stored field. If a larger request is specified, less data
185 than requested will be written, without raising an error. This limit
186 is imposed even when data_type is GD_NULL (i.e., even when no actual
187 I/O or calculation occurs). In all cases, the actual amount of data is
188 returned.
189
190
192 The putdata() function appeared in GetData-0.3.0.
193
194 In GetData-0.7.0, this function was renamed to gd_getdata().
195
196 The GD_HERE symbol used for sequential writes appeared in GetDa‐
197 ta-0.8.0.
198
199
201 GD_SIZE(3), gd_error(3), gd_error_string(3), gd_getdata(3), gd_open(3),
202 gd_put_carray(3), gd_put_constant(3), gd_put_sarray(3),
203 gd_put_string(3), gd_seek(3), gd_spf(3), dirfile(5), dirfile-encod‐
204 ing(5)
205
206
207
208Version 0.10.0 25 January 2017 gd_putdata(3)