16int F5Cset (
F5Path* fpath,
const char* fieldname,
const char* content_type) {
18 const int len = strlen (content_type);
20 hid_t attr_space = -1;
23 hid_t FieldTable = -1;
30 if (
ok && ((attr_type = H5Tcopy (H5T_C_S1)) < 0)) {
36 if (
ok && (H5Tset_size (attr_type, (
size_t)attr_size) < 0 )) {
40 if (
ok && (H5Tset_strpad (attr_type, H5T_STR_NULLTERM) < 0 )) {
44 if (
ok && (attr_space = H5Screate (H5S_SCALAR)) < 0) {
54 if (
ok && (FieldInfo =
F5Gappend (FieldTable, fieldname)) < 0)
60 enum { attr_name_bufsize = 20 };
61 char attr_name[attr_name_bufsize];
62 const int attnum = H5Aget_num_attrs (FieldInfo);
67 if ((attr_id = H5Acreate2(FieldInfo, attr_name, attr_type, attr_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
72 if (
ok && H5Awrite (attr_id, attr_type, content_type) < 0) {
82 if (FieldTable >= 0) {
85 if (attr_space >= 0) {
86 H5Sclose (attr_space);
110 hid_t FieldTable = -1;
111 hsize_t num_objs = 0;
120 if (
ok && (H5Gget_num_objs (FieldTable, &num_objs)) < 0)
125 assert (
sizeof (
int) <=
sizeof (
void*));
127 bufsize = num_objs * (
sizeof (
void*) + 20);
128 nextidx = num_objs *
sizeof(
void*);
129 if (
ok && num_objs > 0 && (buffer = (
char*)malloc (bufsize)) == 0) {
132 for (i = 0; i < num_objs; i++) {
133 const int len = H5Gget_objname_by_idx (FieldTable, i, 0, 0);
135 while (nextidx + len + 1 >= bufsize) {
137 bufsize = (int)((
float)bufsize * 1.2);
138 newbuf = realloc (buffer, bufsize);
143 buffer = (
char*)newbuf;
146 if (H5Gget_objname_by_idx (FieldTable, i, buffer + nextidx, len + 1) <= 0) {
150 ((
int*)buffer)[i] = nextidx;
155 for (i = num_objs - 1; i >= 0; i--) {
156 const int index = ((
int*)buffer)[i];
157 ((
char**)buffer)[i] = buffer + index;
160 if (FieldTable >= 0) {
168 *names = (
char**)buffer;
182 hid_t FieldTable = -1;
183 hid_t FieldInfo = -1;
186 hsize_t num_attrs = 0;
195 if (
ok && (FieldInfo =
F5Gappend (FieldTable, fieldname)) < 0)
201 num_attrs = H5Aget_num_attrs (FieldInfo);
204 assert (
sizeof (
int) <=
sizeof (
void*));
206 bufsize = num_attrs * (
sizeof (
void*) + 50);
207 nextidx = num_attrs *
sizeof(
void*);
208 if (
ok && num_attrs > 0 && (buffer = (
char*)malloc (bufsize)) == 0) {
211 for (i = 0; i < num_attrs; i++) {
212 if ((attr_id = H5Aopen_idx (FieldInfo, i)) < 0) {
216 if ((type_id = H5Aget_type (attr_id)) < 0) {
221 size_t size = H5Tget_size (type_id);
224 while (nextidx + size >= bufsize) {
226 bufsize = (int)((
float)bufsize * 1.2);
227 newbuf = realloc (buffer, bufsize);
232 buffer = (
char*)newbuf;
234 if (H5Aread (attr_id, type_id, buffer + nextidx) < 0) {
238 ((
int*)buffer)[i] = nextidx;
248 for (i = num_attrs - 1; i >= 0; i--) {
249 const int index = ((
int*)buffer)[i];
250 ((
char**)buffer)[i] = buffer + index;
259 if (FieldTable >= 0) {
262 if (FieldInfo >= 0) {
270 *names = (
char**)buffer;
350int F5Cget_version (
const char* content_type,
int* major,
int* minor,
int* patch,
const char** remainder) {
351 const char** url_starts;
352 for (url_starts = valid_f5_urls; *url_starts; url_starts++) {
353 const char* start = *url_starts;
354 const int len = strlen (start);
356 if (strncmp (content_type, start, len) == 0) {
362 if (err > 0 && strcmp (
"F5", buf) == 0) {
377 ,
int* major,
int* minor,
int* patch
378 ,
const char** remainder) {
int F5Cget_subspec(const char *content_type, char *str, size_t size, int *major, int *minor, int *patch, const char **remainder)
int F5Cget_content_types(F5Path *fpath, const char *fieldname, size_t *count, char ***names)
int F5Cset(F5Path *fpath, const char *fieldname, const char *content_type)
int F5Cget_version(const char *content_type, int *major, int *minor, int *patch, const char **remainder)
int F5Cparse_version_string(const char *version_string, char *str, size_t size, int *major, int *minor, int *patch, const char **remainder)
int F5Cget_fields(F5Path *fpath, size_t *count, char ***names)