1
2
3
4
5
6
7
8
9gd_get_carray_slice(3)              GETDATA             gd_get_carray_slice(3)
10
11
12

NAME

14       gd_get_carray, gd_get_carray_slice, gd_get_constant — retrieve CONST or
15       CARRAY data from a Dirfile database
16
17

SYNOPSIS

19       #include <getdata.h>
20
21       int gd_get_carray_slice(DIRFILE *dirfile, const char *field_code,
22              unsigned int start, size_t len, gd_type_t return_type, void
23              *data_out);
24
25       int gd_get_carray(DIRFILE *dirfile, const char *field_code, gd_type_t
26              return_type, void *data_out);
27
28       int gd_get_constant(DIRFILE *dirfile, const char *field_code, gd_type_t
29              return_type, void *data_out);
30
31

DESCRIPTION

33       The gd_get_carray_slice() function queries a dirfile(5) database speci‐
34       fied  by  dirfile  for the CONST or CARRAY scalar field_code, which may
35       contain a representation suffix.  The data in the field is converted to
36       the data type specified by return_type, and stored in the user-supplied
37       buffer data_out.  The first element of the field  stored  is  given  by
38       start, and the number of elements stored is given by len.
39
40       The  gd_get_carray()  function behaves similarly, except it returns the
41       entire field, as if gd_get_carray_slice() were called with start  equal
42       to  zero  and  len equal to the value returned by gd_array_len(3).  The
43       gd_get_constant()     function     is     equivalent     to     calling
44       gd_get_carray_slice() with start equal to zero and len equal to one.
45
46       The  dirfile  argument  must point to a valid DIRFILE object previously
47       created by a call to gd_open(3).  The argument data_out must point to a
48       valid memory location of sufficient size to hold all the requested data
49       of the return type specified.   The  number  of  elements  returned  by
50       gd_get_carray()  may  be  obtained  by calling gd_array_len(3).  Unlike
51       gd_getdata(3), calling gd_get_carray_slice() never results in  a  short
52       read;  attempting  to  read past the end of the field will result in an
53       error, and no data will be returned.
54
55       The return_type argument should be one of the following symbols,  which
56       indicates the desired return type of the data:
57
58              GD_UINT8
59                      unsigned 8-bit integer
60
61              GD_INT8 signed (two's complement) 8-bit integer
62
63              GD_UINT16
64                      unsigned 16-bit integer
65
66              GD_INT16
67                      signed (two's complement) 16-bit integer
68
69              GD_UINT32
70                      unsigned 32-bit integer
71
72              GD_INT32
73                      signed (two's complement) 32-bit integer
74
75              GD_UINT64
76                      unsigned 64-bit integer
77
78              GD_INT64
79                      signed (two's complement) 64-bit integer
80
81              GD_FLOAT32
82                      IEEE-754 standard 32-bit single precision floating point
83                      number
84
85              GD_FLOAT64
86                      IEEE-754 standard 64-bit double precision floating point
87                      number
88
89              GD_COMPLEX64
90                      C99-conformant 64-bit single precision complex number
91
92              GD_COMPLEX128
93                      C99-conformant 128-bit double precision complex number
94
95              GD_NULL the  null type: the database is queried as usual, but no
96                      data is returned.  In this case, data_out is ignored and
97                      may be NULL.
98
99       The  return  type  of the field need not be the same as the type of the
100       data stored in the database.  Type conversion will be performed as nec‐
101       essary  to return the requested type.  If the field_code does not indi‐
102       cate a representation, but conversion from a complex value to a  purely
103       real  one  is  required,  only the real portion of the requested vector
104       will be returned.
105
106

RETURN VALUE

108       On     success,     gd_get_carray(),     gd_get_carray_slice(),     and
109       gd_get_constant() return zero.  On error, they return a negative-valued
110       error code.  Possible error codes are:
111
112       GD_E_ALLOC
113               The library was unable to allocate memory.
114
115       GD_E_BAD_CODE
116               The field specified by field_code was not found  in  the  data‐
117               base.
118
119       GD_E_BAD_DIRFILE
120               An invalid dirfile was supplied.
121
122       GD_E_BAD_FIELD_TYPE
123               The supplied field_code was not a CONST nor CARRAY.
124
125       GD_E_BAD_TYPE
126               An invalid return_type was specified.
127
128       GD_E_BOUNDS
129               A request for data beyond the end of the field was made.
130
131       GD_E_INTERNAL_ERROR
132               An  internal error occurred in the library while trying to per‐
133               form the task.  This indicates a bug in  the  library.   Please
134               report the incident to the maintainer.
135
136       The  error  code  is  also  stored in the DIRFILE object and may be re‐
137       trieved after this function returns by calling gd_error(3).  A descrip‐
138       tive   error   string   for  the  error  may  be  obtained  by  calling
139       gd_error_string(3).
140
141

HISTORY

143       The get_constant() function appeared in GetData-0.4.0.
144
145       In GetData-0.7.0, this function was renamed to  gd_get_constant().   In
146       this  release,  the gd_get_carray() and gd_get_carray_slice() functions
147       also appeared.
148
149       In GetData-0.10.0, the error return from these functions  changed  from
150       -1 to a negative-valued error code.
151
152

SEE ALSO

154       gd_array_len(3),    gd_carrays(3),   gd_error(3),   gd_error_string(3),
155       gd_open(3), gd_put_carray_slice(3), dirfile(5)
156
157
158
159Version 0.10.0                 25 December 2016         gd_get_carray_slice(3)
Impressum