1 /****h* H5Af/H5Af
2  * PURPOSE
3  *  This file contains C stubs for H5A Fortran APIs
4  *
5  * COPYRIGHT
6  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7  * Copyright by The HDF Group.                                               *
8  * Copyright by the Board of Trustees of the University of Illinois.         *
9  * All rights reserved.                                                      *
10  *                                                                           *
11  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
12  * terms governing use, modification, and redistribution, is contained in    *
13  * the COPYING file, which can be found at the root of the source code       *
14  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
15  * If you do not have access to either file, you may request a copy from     *
16  * help@hdfgroup.org.                                                        *
17  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
18  *
19  ******
20 */
21 
22 #include "H5f90.h"
23 #include "H5Eprivate.h"
24 
25 /****if* H5Af/h5acreate_c
26  * NAME
27  *  h5acreate_c
28  * PURPOSE
29  *  Call H5Acreate2 to create an attribute
30  * INPUTS
31  *  obj_id - object identifier
32  *  name - name of the attribute
33  *  namelen - name length
34  *  type_id - datatype identifier
35  *  space_id - dataspace identifier
36  *  crt_pr  - identifier of creation property list
37  * OUTPUTS
38  *  attr_id - attribute identifier
39  * RETURNS
40  *  0 on success, -1 on failure
41  * AUTHOR
42  *  Elena Pourmal
43  *  Thursday, August 12, 1999
44  * HISTORY
45  *
46  * SOURCE
47 */
48 int_f
h5acreate_c(hid_t_f * obj_id,_fcd name,size_t_f * namelen,hid_t_f * type_id,hid_t_f * space_id,hid_t_f * crt_prp,hid_t_f * aapl,hid_t_f * attr_id)49 h5acreate_c(hid_t_f *obj_id, _fcd name, size_t_f *namelen, hid_t_f *type_id,
50     hid_t_f *space_id, hid_t_f *crt_prp, hid_t_f *aapl, hid_t_f *attr_id)
51 /*******/
52 {
53     char *c_name = NULL;        /* Buffer to hold C string */
54     int_f ret_value = 0;        /* Return value */
55 
56      /*
57       * Convert FORTRAN name to C name
58       */
59     if(NULL == (c_name = HD5f2cstring(name, (size_t)*namelen)))
60         HGOTO_DONE(FAIL);
61 
62      /*
63       * Call H5Acreate2 function.
64       */
65     if((*attr_id = (hid_t_f)H5Acreate2((hid_t)*obj_id, c_name, (hid_t)*type_id, (hid_t)*space_id, (hid_t)*crt_prp, (hid_t)*aapl)) < 0)
66         HGOTO_DONE(FAIL);
67 
68 done:
69     if(c_name)
70         HDfree(c_name);
71     return ret_value;
72 }
73 
74 /****if* H5Af/h5adelete_c
75  * NAME
76  *  h5adelete_c
77  * PURPOSE
78  *  Call H5Adelete to delete an attribute
79  * INPUTS
80  *  obj_id - object identifier
81  *  name - name of the attribute
82  *  namelen - name length
83  * RETURNS
84  *  0 on success, -1 on failure
85  * AUTHOR
86  *  Elena Pourmal
87  *  Thursday, August 12, 1999
88  * HISTORY
89  *
90  * SOURCE
91 */
92 int_f
h5adelete_c(hid_t_f * obj_id,_fcd name,size_t_f * namelen)93 h5adelete_c (hid_t_f *obj_id, _fcd name, size_t_f *namelen)
94 /******/
95 {
96     char *c_name = NULL;        /* Buffer to hold C string */
97     int_f ret_value = 0;        /* Return value */
98 
99      /*
100       * Convert FORTRAN name to C name
101       */
102      if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL)
103         HGOTO_DONE(FAIL);
104 
105      /*
106       * Call H5Adelete function.
107       */
108      if(H5Adelete((hid_t)*obj_id, c_name) < 0)
109          HGOTO_DONE(FAIL);
110 
111 done:
112     if(c_name)
113         HDfree(c_name);
114 
115     return ret_value;
116 }
117 
118 /****if* H5Af/h5aget_num_attrs_c
119  * NAME
120  *  h5aget_num_attrs_c
121  * PURPOSE
122  *  Call H5Oget_info to determine number of
123  *  attributes of an object
124  * INPUTS
125  *  obj_id - object identifier
126  *  attr_num - number of attributes
127  * RETURNS
128  *  0 on success, -1 on failure
129  * AUTHOR
130  *  Elena Pourmal
131  *  Thursday, August 12, 1999
132  * HISTORY
133  *
134  * SOURCE
135 */
136 int_f
h5aget_num_attrs_c(hid_t_f * obj_id,int_f * attr_num)137 h5aget_num_attrs_c (hid_t_f *obj_id, int_f *attr_num)
138 /******/
139 {
140     H5O_info_t oinfo;           /* Object info */
141     int_f ret_value = 0;        /* Return value */
142 
143     /*
144      * Call H5Oget_info function.
145      */
146     if(H5Oget_info2((hid_t)*obj_id, &oinfo, H5O_INFO_NUM_ATTRS) < 0)
147         HGOTO_DONE(FAIL);
148 
149     /* Set number of attributes */
150     *attr_num = (int_f)oinfo.num_attrs;
151 
152 done:
153      return ret_value;
154 }
155 
156 /****if* H5Af/h5aget_name_c
157  * NAME
158  *  h5aget_name_c
159  * PURPOSE
160  *  Call H5Aget_name to get attribute's name
161  * INPUTS
162  *  attr_id - attribute identifier
163  *  bufsize - size of the buffer
164  * OUTPUTS
165  *  buf - buffer to hold the name
166  * RETURNS
167  *  0 on success, -1 on failure
168  * AUTHOR
169  *  Elena Pourmal
170  *  Thursday, August 12, 1999
171  * HISTORY
172  *
173  * SOURCE
174 */
175 int_f
h5aget_name_c(hid_t_f * attr_id,size_t_f * bufsize,_fcd buf)176 h5aget_name_c(hid_t_f *attr_id, size_t_f *bufsize, _fcd buf)
177 /******/
178 {
179   size_t c_bufsize;
180   char *c_buf=NULL;           /* Buffer to hold C string */
181   int_f ret_value=0;          /* Return value */
182 
183   c_bufsize = (size_t)*bufsize+1;
184 
185   /*
186    * Allocate buffer to hold name of an attribute
187    */
188   if(NULL == (c_buf = (char *)HDmalloc(c_bufsize)))
189     HGOTO_DONE(FAIL);
190 
191   /*
192    * Call H5Aget_name function
193    */
194   if ((ret_value = (int_f)H5Aget_name((hid_t)*attr_id, c_bufsize, c_buf)) < 0)
195     HGOTO_DONE(FAIL);
196 
197   /*
198    * Convert C name to FORTRAN and place it in the given buffer
199    */
200   HD5packFstring(c_buf, _fcdtocp(buf), c_bufsize-1);
201 
202 done:
203   if(c_buf) HDfree(c_buf);
204   return ret_value;
205 }
206 
207 
208 /****if* H5Af/h5arename_by_name_c
209  * NAME
210  *  h5arename_by_name_c
211  * PURPOSE
212  *  Calls H5Arename_by_name
213  * INPUTS
214  *  loc_id        - Object identifier
215  *  obj_name      - Name of object, relative to location,
216  *  whose attribute is to be renamed
217  *  obj_name_len      - Object name length
218  *  old_attr_name     - Prior attribute name
219  *  old_attr_name_len - Prior attribute name length
220  *  new_attr_name     - New attribute name
221  *  new_attr_name_len - New attribute name length
222  *  lapl_id       - Link access property list identifier
223  * OUTPUTS
224  *     N/A
225  * RETURNS
226  *  0 on success, -1 on failure
227  * AUTHOR
228  *  M. Scot Breitenfeld
229  *  January, 2008
230  * HISTORY
231  * N/A
232  * SOURCE
233 */
234 
235 int_f
h5arename_by_name_c(hid_t_f * loc_id,_fcd obj_name,size_t_f * obj_namelen,_fcd old_attr_name,size_t_f * old_attr_namelen,_fcd new_attr_name,size_t_f * new_attr_namelen,hid_t_f * lapl_id)236 h5arename_by_name_c( hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
237 		      _fcd old_attr_name, size_t_f *old_attr_namelen,
238 		      _fcd new_attr_name, size_t_f *new_attr_namelen,
239 		      hid_t_f *lapl_id )
240 /******/
241 {
242     char *c_obj_name = NULL;          /* Buffer to hold C string */
243     char *c_old_attr_name = NULL;     /* Buffer to hold C string */
244     char *c_new_attr_name = NULL;     /* Buffer to hold C string */
245     int_f ret_value=0;          /* Return value */
246      /*
247       * Convert FORTRAN name to C name
248       */
249     if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
250       HGOTO_DONE(FAIL);
251     if((c_old_attr_name = HD5f2cstring(old_attr_name, (size_t)*old_attr_namelen)) == NULL)
252       HGOTO_DONE(FAIL);
253     if((c_new_attr_name = HD5f2cstring(new_attr_name, (size_t)*new_attr_namelen)) == NULL)
254       HGOTO_DONE(FAIL);
255 
256     if(H5Arename_by_name((hid_t)*loc_id,c_obj_name,c_old_attr_name,c_new_attr_name,(hid_t)*lapl_id) < 0)
257         HGOTO_DONE(FAIL);
258 
259 done:
260     if(c_obj_name)
261       HDfree(c_obj_name);
262     if(c_old_attr_name)
263       HDfree(c_old_attr_name);
264     if(c_new_attr_name)
265       HDfree(c_new_attr_name);
266     return ret_value;
267 }
268 
269 /****if* H5Af/h5aopen_c
270  * NAME
271  *  h5aopen_c
272  * PURPOSE
273  *  Call H5Aopen to open an attribute
274  * INPUTS
275  *  obj_id       - Identifer for object to which attribute is attached
276  *	        attr_name    - Attribute access property list
277  *  attr_namelen - size of attr_name
278  *  aapl_id      - Link access property list
279  * OUTPUTS
280  *  attr_id - dataset identifier
281  * RETURNS
282  *  0 on success, -1 on failure
283  * AUTHOR
284  *  M. Scot Breitenfeld
285  *  January, 2008
286  * HISTORY
287  *
288  * SOURCE
289 */
290 int_f
h5aopen_c(hid_t_f * obj_id,_fcd attr_name,size_t_f * attr_namelen,hid_t_f * aapl_id,hid_t_f * attr_id)291 h5aopen_c (hid_t_f *obj_id, _fcd attr_name, size_t_f *attr_namelen, hid_t_f *aapl_id, hid_t_f *attr_id)
292 /******/
293 {
294     char *c_attr_name = NULL;          /* Buffer to hold C string */
295     int_f ret_value = 0;          /* Return value */
296 
297      /*
298       * Convert FORTRAN name to C name
299       */
300      if((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL)
301         HGOTO_DONE(FAIL);
302      /*
303       * Call H5Aopen function.
304       */
305 
306       if((*attr_id = (hid_t_f)H5Aopen((hid_t)*obj_id, c_attr_name, (hid_t)*aapl_id)) < 0)
307 	HGOTO_DONE(FAIL);
308 
309 done:
310     if(c_attr_name)
311         HDfree(c_attr_name);
312     return ret_value;
313 }
314 /****if* H5Af/h5adelete_by_name_c
315  * NAME
316  *  h5adelete_by_name_c
317  * PURPOSE
318  *  Call h5adelete_by_name to remove an attribute from a specified location
319  * INPUTS
320  *  loc_id - identifer for object to which attribute is attached
321  *  obj_name - object identifier
322  *  obj_namelen - name length
323  *  attr_name - name of the attribute
324  *  attr_namelen - name length
325  *  lapl_id - link access property list
326  *
327  * OUTPUTS
328  *     N/A
329  * RETURNS
330  *  0 on success, -1 on failure
331  * AUTHOR
332  *  M. Scot Breitenfeld
333  *  January, 2008
334  * HISTORY
335  * N/A
336  * SOURCE
337 */
338 int_f
h5adelete_by_name_c(hid_t_f * loc_id,_fcd obj_name,size_t_f * obj_namelen,_fcd attr_name,size_t_f * attr_namelen,hid_t_f * lapl_id)339 h5adelete_by_name_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd attr_name, size_t_f *attr_namelen, hid_t_f *lapl_id)
340 /******/
341 {
342     char *c_obj_name = NULL;          /* Buffer to hold C string */
343     char *c_attr_name = NULL;         /* Buffer to hold C string */
344     int_f ret_value = 0;          /* Return value */
345 
346      /*
347       * Convert FORTRAN name to C name
348       */
349     if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
350       HGOTO_DONE(FAIL);
351     if((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL)
352       HGOTO_DONE(FAIL);
353 
354      /*
355       * Call H5Adelete_by_name function.
356       */
357     if(H5Adelete_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, (hid_t)*lapl_id) < 0)
358       HGOTO_DONE(FAIL);
359 
360 done:
361     if(c_attr_name)
362         HDfree(c_attr_name);
363     if(c_obj_name)
364         HDfree(c_obj_name);
365     return ret_value;
366 }
367 /****if* H5Af/h5adelete_by_idx_c
368  * NAME
369  *  h5adelete_by_idx_c
370  * PURPOSE
371  *  Call h5adelete_by_idx
372  * INPUTS
373  *  loc_id - Location or object identifier; may be dataset or group
374  *  obj_name - object identifier
375  *  obj_namelen - name length
376  *  attr_name - name of the attribute
377  *  attr_namelen - name length
378  *  lapl_id - link access property list
379  *
380  * OUTPUTS
381  *     N/A
382  * RETURNS
383  *  0 on success, -1 on failure
384  * AUTHOR
385  *  M. Scot Breitenfeld
386  *  January, 2008
387  * HISTORY
388  * N/A
389  * SOURCE
390 */
391 int_f
h5adelete_by_idx_c(hid_t_f * loc_id,_fcd obj_name,size_t_f * obj_namelen,int_f * idx_type,int_f * order,hsize_t_f * n,hid_t_f * lapl_id)392 h5adelete_by_idx_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
393 		     int_f *idx_type, int_f *order, hsize_t_f *n, hid_t_f *lapl_id)
394 /******/
395 {
396     char *c_obj_name = NULL;          /* Buffer to hold C string */
397     int_f ret_value = 0;          /* Return value */
398 
399      /*
400       * Convert FORTRAN name to C name
401       */
402     if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)))
403         HGOTO_DONE(FAIL)
404 
405      /*
406       * Call H5Adelete_by_name function.
407       */
408     if(H5Adelete_by_idx((hid_t)*loc_id, c_obj_name, (H5_index_t)*idx_type, (H5_iter_order_t)*order, (hsize_t)*n, (hid_t)*lapl_id) < 0)
409         HGOTO_DONE(FAIL)
410 
411 done:
412     if(c_obj_name)
413         HDfree(c_obj_name);
414 
415     return ret_value;
416 }
417 /****if* H5Af/h5aget_name_by_idx_c
418  * NAME
419  *  h5aget_name_by_idx_c
420  * PURPOSE
421  *  Call h5aget_name_by_idx
422  * INPUTS
423  *
424  *
425  *  loc_id - Identifer for object to which attribute is attached
426  *  obj_name - Name of object, relative to location,
427  *  from which attribute is to be removed *TEST* check NULL
428  *  idx_type - Type of index; Possible values are:
429  *                         H5_INDEX_UNKNOWN   - Unknown index type
430  *                         H5_INDEX_NAME      - Index on names
431  *                         H5_INDEX_CRT_ORDER - Index on creation order
432  *                         H5_INDEX_N	      - Number of indices defined
433  *
434  *  order    - Order in which to iterate over index; Possible values are:
435  *                          H5_ITER_UNKNOWN  - Unknown order
436  *                          H5_ITER_INC      - Increasing order
437  *                          H5_ITER_DEC      - Decreasing order
438  *                          H5_ITER_NATIVE   - No particular order, whatever is fastest
439  *                          H5_ITER_N	     - Number of iteration orders
440  *
441  *  n  - Attribute’s position in index
442  *  attr_id  - Attribute identifier
443  *  size  - Buffer size ! *TEST* check for 0 value *CHECK* should this return the correct value
444  *
445  *  lapl_id   - Link access property list
446  *  hdferr   - Error code:
447  *  Returns attribute name size, -1 if fail
448  *
449  * OUTPUTS
450  *  name - Attribute name
451  *
452  * RETURNS
453  *  Size of buffer on success, -1 on failure
454  * AUTHOR
455  *  M. Scot Breitenfeld
456  *  January, 2008
457  * HISTORY
458  * N/A
459  * SOURCE
460 */
461 int_f
h5aget_name_by_idx_c(hid_t_f * loc_id,_fcd obj_name,size_t_f * obj_namelen,int_f * idx_type,int_f * order,hsize_t_f * n,_fcd name,size_t_f * size,hid_t_f * lapl_id)462 h5aget_name_by_idx_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
463 		       int_f *idx_type, int_f *order, hsize_t_f *n, _fcd name,
464 		       size_t_f *size, hid_t_f *lapl_id)
465 /******/
466 {
467     char *c_obj_name = NULL;          /* Buffer to hold C string */
468     ssize_t c_size;
469     size_t c_buf_size;
470     char *c_buf = NULL;
471     int_f ret_value = 0;          /* Return value */
472 
473     /*
474      * Convert FORTRAN name to C name
475      */
476     if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)))
477         HGOTO_DONE(FAIL)
478 
479     /*
480      * Allocate buffer to hold name of an attribute
481      */
482     c_buf_size = (size_t)*size + 1;
483     if(NULL == (c_buf = (char *)HDmalloc(c_buf_size)))
484         HGOTO_DONE(FAIL)
485 
486      /*
487       * Call H5Aget_name_by_idx function.
488       */
489      c_size = H5Aget_name_by_idx((hid_t)*loc_id, c_obj_name, (H5_index_t)*idx_type, (H5_iter_order_t)*order, (hsize_t)*n, c_buf, c_buf_size,(hid_t)*lapl_id);
490      if(c_size < 0)
491         HGOTO_DONE(FAIL)
492 
493 
494      /*
495       * Convert C name to FORTRAN and place it in the given buffer
496       */
497      HD5packFstring(c_buf, _fcdtocp(name), c_buf_size - 1);
498      *size = (size_t_f)c_size;
499 
500 done:
501    if(c_obj_name)
502        HDfree(c_obj_name);
503    if(c_buf)
504        HDfree(c_buf);
505     return ret_value;
506 }
507 
508 /****if* H5Af/h5aopen_by_idx_c
509  * NAME
510  *  h5aopen_by_idx_c
511  * PURPOSE
512  *  Call H5Aopen_by_idx
513  * INPUTS
514  *  loc_id    - Object identifier
515  *  obj_name - Name of object to which attribute is attached
516  *  obj_namelen - name length
517  *  idx_type - Type of index; Possible values are:
518  *                         H5_INDEX_UNKNOWN   - Unknown index type
519  *                         H5_INDEX_NAME      - Index on names
520  *                         H5_INDEX_CRT_ORDER - Index on creation order
521  *                         H5_INDEX_N	      - Number of indices defined
522  *
523  *  order - Order in which to iterate over index; Possible values are:
524  *                          H5_ITER_UNKNOWN  - Unknown order
525  *                          H5_ITER_INC      - Increasing order
526  *                          H5_ITER_DEC      - Decreasing order
527  *                          H5_ITER_NATIVE   - No particular order, whatever is fastest
528  *                          H5_ITER_N	     - Number of iteration orders
529  *
530  *  n - Attribute’s position in index
531  *  aapl_id - Attribute access property list
532  *  lapl_id - Link access property list
533  * OUTPUTS
534  *  attr_id - attribute identifer
535  * RETURNS
536  *  0 on success, -1 on failure
537  * AUTHOR
538  *  M. Scot Breitenfeld
539  *  January, 2008
540  * HISTORY
541  * N/A
542  * SOURCE
543 */
544 int_f
h5aopen_by_idx_c(hid_t_f * loc_id,_fcd obj_name,size_t_f * obj_namelen,int_f * idx_type,int_f * order,hsize_t_f * n,hid_t_f * aapl_id,hid_t_f * lapl_id,hid_t_f * attr_id)545 h5aopen_by_idx_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
546 		   int_f *idx_type, int_f *order, hsize_t_f *n, hid_t_f *aapl_id, hid_t_f *lapl_id, hid_t_f *attr_id )
547 /******/
548 {
549     char *c_obj_name = NULL;          /* Buffer to hold C string */
550     int_f ret_value = 0;          /* Return value */
551 
552     /*
553      * Convert FORTRAN name to C name
554      */
555     if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)))
556         HGOTO_DONE(FAIL)
557 
558      /*
559       * Call H5Aopen_by_idx function.
560       */
561     if((*attr_id = (hid_t_f)H5Aopen_by_idx((hid_t)*loc_id, c_obj_name, (H5_index_t)*idx_type, (H5_iter_order_t)*order, (hsize_t)*n, (hid_t)*aapl_id, (hid_t)*lapl_id)) < 0)
562         HGOTO_DONE(FAIL)
563 
564 done:
565     if(c_obj_name)
566         HDfree(c_obj_name);
567 
568     return ret_value;
569 }
570 
571 /****if* H5Af/h5aget_info_c
572  * NAME
573  *  h5aget_info_c
574  * PURPOSE
575  *  Call H5Aget_info
576  * INPUTS
577  *  loc_id  - Object identifier
578  * OUTPUTS
579  *
580  *  corder_valid - Indicates whether the the creation order data is valid for this attribute
581  *  corder - Is a positive integer containing the creation order of the attribute
582  *  cset - Indicates the character set used for the attribute’s name
583  *  data_size - indicates the size, in the number of characters, of the attribute
584  *
585  * RETURNS
586  *  0 on success, -1 on failure
587  * AUTHOR
588  *  M. Scot Breitenfeld
589  *  January, 2008
590  * HISTORY
591  * N/A
592  * SOURCE
593 */
594 int_f
h5aget_info_c(hid_t_f * loc_id,int_f * corder_valid,int_f * corder,int_f * cset,hsize_t_f * data_size)595 h5aget_info_c (hid_t_f *loc_id, int_f *corder_valid, int_f *corder,
596 		int_f *cset, hsize_t_f *data_size )
597 /******/
598 {
599 
600     int_f ret_value = 0;          /* Return value */
601     H5A_info_t ainfo;
602 
603 
604      /*
605       * Call H5Aget_info function.
606       */
607     if(H5Aget_info((hid_t)*loc_id,&ainfo) < 0)
608       HGOTO_DONE(FAIL);
609 
610     /* Unpack the structure */
611 
612     *corder_valid = 0;
613     if(ainfo.corder_valid > 0) *corder_valid = 1;
614 
615     *corder = (int_f)ainfo.corder;
616     *cset = (int_f)ainfo.cset;
617     *data_size = (hsize_t_f)ainfo.data_size;
618 
619 done:
620     return ret_value;
621 }
622 
623 /****if* H5Af/h5aget_info_by_idx_c
624  * NAME
625  *  h5aget_info_by_idx_c
626  * PURPOSE
627  *  Call  H5Aget_info_by_idx
628  * INPUTS
629  *  loc_id  - Object identifier
630  *  obj_name - Name of object to which attribute is attached
631  *  obj_namelen - name length
632  *  idx_type - Type of index; Possible values are:
633  *                         H5_INDEX_UNKNOWN   - Unknown index type
634  *                         H5_INDEX_NAME      - Index on names
635  *                         H5_INDEX_CRT_ORDER - Index on creation order
636  *                         H5_INDEX_N	      - Number of indices defined
637  *
638  *  order - Order in which to iterate over index; Possible values are:
639  *                          H5_ITER_UNKNOWN  - Unknown order
640  *                          H5_ITER_INC      - Increasing order
641  *                          H5_ITER_DEC      - Decreasing order
642  *                          H5_ITER_NATIVE   - No particular order, whatever is fastest
643  *                          H5_ITER_N	     - Number of iteration orders
644  *
645  *  n - Attribute’s position in index
646  *  lapl_id - Link access property list
647  * OUTPUTS
648  *
649  *  corder_valid - Indicates whether the the creation order data is valid for this attribute
650  *  corder - Is a positive integer containing the creation order of the attribute
651  *  cset - Indicates the character set used for the attribute’s name
652  *  data_size - indicates the size, in the number of characters, of the attribute
653  *
654  * RETURNS
655  *  0 on success, -1 on failure
656  * AUTHOR
657  *  M. Scot Breitenfeld
658  *  January, 2008
659  * HISTORY
660  * N/A
661  * SOURCE
662 */
663 int_f
h5aget_info_by_idx_c(hid_t_f * loc_id,_fcd obj_name,size_t_f * obj_namelen,int_f * idx_type,int_f * order,hsize_t_f * n,hid_t_f * lapl_id,int_f * corder_valid,int_f * corder,int_f * cset,hsize_t_f * data_size)664 h5aget_info_by_idx_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
665 		int_f *idx_type, int_f *order, hsize_t_f *n, hid_t_f *lapl_id,
666 		int_f *corder_valid, int_f *corder,
667 		int_f *cset, hsize_t_f *data_size )
668 /******/
669 {
670     char *c_obj_name = NULL;          /* Buffer to hold C string */
671     H5A_info_t ainfo;
672     int_f ret_value = 0;          /* Return value */
673 
674     /*
675      * Convert FORTRAN name to C name
676      */
677     if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)))
678         HGOTO_DONE(FAIL)
679 
680      /*
681       * Call H5Ainfo_by_idx function.
682       */
683     if(H5Aget_info_by_idx((hid_t)*loc_id, c_obj_name, (H5_index_t)*idx_type, (H5_iter_order_t)*order, (hsize_t)*n,
684             &ainfo, (hid_t)*lapl_id) < 0)
685       HGOTO_DONE(FAIL)
686 
687     /* Unpack the structure */
688     *corder_valid = 0;
689     if(ainfo.corder_valid > 0)
690         *corder_valid = 1;
691     *corder = (int_f)ainfo.corder;
692     *cset = (int_f)ainfo.cset;
693     *data_size = (hsize_t_f)ainfo.data_size;
694 
695 done:
696     if(c_obj_name)
697         HDfree(c_obj_name);
698 
699     return ret_value;
700 }
701 
702 /****if* H5Af/h5aget_info_by_name_c
703  * NAME
704  *  h5aget_info_by_name_c
705  * PURPOSE
706  *  Call  H5Aget_info_by_name
707  * INPUTS
708  *  loc_id - Object identifier
709  *  obj_name - Name of object to which attribute is attached
710  *  obj_namelen - name length
711  *  attr_name - Attribute name
712  *  attr_namelen - attribute name length
713  *  lapl_id - Link access property list
714  * OUTPUTS
715  *
716  *  corder_valid - Indicates whether the the creation order data is valid for this attribute
717  *  corder - Is a positive integer containing the creation order of the attribute
718  *  cset - Indicates the character set used for the attribute’s name
719  *  data_size - indicates the size, in the number of characters, of the attribute
720  *
721  * RETURNS
722  *  0 on success, -1 on failure
723  * AUTHOR
724  *  M. Scot Breitenfeld
725  *  January, 2008
726  * HISTORY
727  * N/A
728  * SOURCE
729 */
730 int_f
h5aget_info_by_name_c(hid_t_f * loc_id,_fcd obj_name,size_t_f * obj_namelen,_fcd attr_name,size_t_f * attr_namelen,hid_t_f * lapl_id,int_f * corder_valid,int_f * corder,int_f * cset,hsize_t_f * data_size)731 h5aget_info_by_name_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
732 			_fcd attr_name, size_t_f *attr_namelen, hid_t_f *lapl_id,
733 			int_f *corder_valid, int_f *corder,
734 			int_f *cset, hsize_t_f *data_size )
735 /******/
736 {
737     char *c_obj_name = NULL;          /* Buffer to hold C string */
738     char *c_attr_name = NULL;          /* Buffer to hold C string */
739     H5A_info_t ainfo;
740     int_f ret_value = 0;          /* Return value */
741 
742     /*
743      * Convert FORTRAN name to C name
744      */
745     if(NULL == (c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)))
746         HGOTO_DONE(FAIL)
747     if(NULL == (c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)))
748         HGOTO_DONE(FAIL)
749 
750      /*
751       * Call H5Ainfo_by_name function.
752       */
753     if(H5Aget_info_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, &ainfo, (hid_t)*lapl_id) < 0)
754         HGOTO_DONE(FAIL)
755 
756     /* Unpack the structure */
757     *corder_valid = 0;
758     if(ainfo.corder_valid > 0)
759         *corder_valid = 1;
760     *corder = (int_f)ainfo.corder;
761     *cset = (int_f)ainfo.cset;
762     *data_size = (hsize_t_f)ainfo.data_size;
763 
764 done:
765     if(c_obj_name)
766         HDfree(c_obj_name);
767     if(c_attr_name)
768         HDfree(c_attr_name);
769 
770     return ret_value;
771 }
772 
773 /****if* H5Af/h5acreate_by_name_c
774  * NAME
775  *  h5acreate_by_name_c
776  * PURPOSE
777  *  Call h5acreate_by_name
778 
779  * INPUTS
780  *
781  *  loc_id  - Object identifier
782  *  obj_name - Name of object to which attribute is attached
783  *  obj_namelen - name length
784  *  attr_name - Attribute name
785  *  attr_namelen - attribute name length
786  *  type_id - Attribute datatype identifier
787  *  space_id  - Attribute dataspace identifier
788  *  acpl_id - Attribute creation property list identifier (Currently not used.)
789  *  aapl_id - Attribute access property list identifier (Currently not used.)
790  *  lapl_id - Link access property list
791  *
792  * OUTPUTS
793  *
794  *  attr - an attribute identifier
795  *
796  * RETURNS
797  *  0 on success, -1 on failure
798  * AUTHOR
799  *  M. Scot Breitenfeld
800  *  February, 2008
801  * HISTORY
802  * N/A
803  * SOURCE
804 */
805 int_f
h5acreate_by_name_c(hid_t_f * loc_id,_fcd obj_name,size_t_f * obj_namelen,_fcd attr_name,size_t_f * attr_namelen,hid_t_f * type_id,hid_t_f * space_id,hid_t_f * acpl_id,hid_t_f * aapl_id,hid_t_f * lapl_id,hid_t_f * attr_id)806 h5acreate_by_name_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen,
807 		     _fcd attr_name, size_t_f *attr_namelen,  hid_t_f *type_id,
808 		     hid_t_f *space_id, hid_t_f *acpl_id, hid_t_f *aapl_id,
809 		     hid_t_f *lapl_id, hid_t_f *attr_id )
810 /******/
811 {
812   char *c_obj_name = NULL;      /* Buffer to hold C string */
813   char *c_attr_name = NULL;     /* Buffer to hold C string */
814   int_f ret_value = 0;          /* Return value */
815 
816   /*
817    * Convert FORTRAN name to C name
818    */
819   if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
820     HGOTO_DONE(FAIL);
821   if((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL)
822     HGOTO_DONE(FAIL);
823 
824   /*
825    * Call H5Acreate_by_name function.
826    */
827   if((*attr_id = (hid_t_f)H5Acreate_by_name((hid_t)*loc_id, c_obj_name, c_attr_name,
828 					    (hid_t)*type_id, (hid_t)*space_id,(hid_t)*acpl_id,(hid_t)*aapl_id,(hid_t)*lapl_id )) < 0)
829     HGOTO_DONE(FAIL);
830 
831 done:
832   if(c_obj_name)
833     HDfree(c_obj_name);
834   if(c_attr_name)
835     HDfree(c_attr_name);
836   return ret_value;
837 }
838 
839 /****if* H5Af/h5aexists_c
840  * NAME
841  *  h5aexists_c
842  * PURPOSE
843  *     CAll h5aexists
844  * INPUTS
845  *
846  *  obj_id - Object identifier
847  *  attr_name - Attribute name
848  * OUTPUTS
849  *
850  *  attr_exists_c  - returns a positive value, for TRUE, or 0 (zero), for FALSE.
851  * RETURNS
852  *  0 on success, -1 on failure
853  * AUTHOR
854  *  M. Scot Breitenfeld
855  *  February, 2008
856  * HISTORY
857  *
858  * SOURCE
859 */
860 int_f
h5aexists_c(hid_t_f * obj_id,_fcd name,size_t_f * namelen,hid_t_f * attr_exists)861 h5aexists_c (hid_t_f *obj_id, _fcd name, size_t_f *namelen, hid_t_f *attr_exists)
862 /******/
863 {
864   char *c_name = NULL;          /* Buffer to hold C string */
865   int_f ret_value = 0;          /* Return value */
866 
867   /*
868    * Convert FORTRAN name to C name
869    */
870   if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL)
871     HGOTO_DONE(FAIL);
872 
873   /*
874    * Call H5Aexists function.
875    */
876   if((*attr_exists = (hid_t_f)H5Aexists((hid_t)*obj_id, c_name)) < 0)
877          HGOTO_DONE(FAIL);
878 
879 done:
880     if(c_name)
881         HDfree(c_name);
882     return ret_value;
883 }
884 
885 /****if* H5Af/h5aexists_by_name_c
886  * NAME
887  *  h5aexists_by_name_c
888  * PURPOSE
889  *     CAll H5Aexists_by_name
890  * INPUTS
891  *
892  *  loc_id - Location identifier
893  *  obj_name - Object name either relative to loc_id, absolute from the file’s root group, or '.' (a dot)
894  *  attr_name - Attribute name
895  *  lapl_id - Link access property list identifier
896  * OUTPUTS
897  *
898  *  attr_exists_c  - returns a positive value, for TRUE, or 0 (zero), for FALSE.
899  * RETURNS
900  *  0 on success, -1 on failure
901  * AUTHOR
902  *  M. Scot Breitenfeld
903  *  February, 2008
904  * HISTORY
905  *
906  * SOURCE
907 */
908 int_f
h5aexists_by_name_c(hid_t_f * loc_id,_fcd obj_name,size_t_f * obj_namelen,_fcd attr_name,size_t_f * attr_namelen,hid_t_f * lapl_id,int_f * attr_exists)909 h5aexists_by_name_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd attr_name, size_t_f *attr_namelen,
910 		      hid_t_f *lapl_id, int_f *attr_exists)
911 /******/
912 {
913   char *c_obj_name = NULL;          /* Buffer to hold object name C string */
914   char *c_attr_name = NULL;          /* Buffer to hold attribute name C string */
915   int_f ret_value = 0;          /* Return value */
916 
917   /*
918    * Convert FORTRAN name to C name
919    */
920   if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
921     HGOTO_DONE(FAIL);
922   if((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL)
923     HGOTO_DONE(FAIL);
924 
925   /*
926    * Call H5Aexists_by_name function.
927    */
928   if((*attr_exists = (int_f)H5Aexists_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, (hid_t)*lapl_id)) < 0)
929          HGOTO_DONE(FAIL);
930 
931 done:
932     if(c_obj_name)
933         HDfree(c_obj_name);
934     if(c_attr_name)
935         HDfree(c_attr_name);
936     return ret_value;
937 }
938 
939 /****if* H5Af/h5aopen_by_name_c
940  * NAME
941  *  h5aopen_by_name_c
942  * PURPOSE
943  *  Call H5Aopen_by_name
944  * INPUTS
945  *
946  *  loc_id - Location identifier
947  *  obj_name - Object name either relative to loc_id, absolute from the file’s root group, or '.' (a dot)
948  *  attr_name - Attribute name
949  *  aapl_id - Attribute access property list (Currently unused; should be passed in as H5P_DEFAULT.)
950  *  lapl_id - Link access property list identifier
951  * OUTPUTS
952  *
953  *  attr_id  - attribute identifier
954  * RETURNS
955  *  0 on success, -1 on failure
956  * AUTHOR
957  *  M. Scot Breitenfeld
958  *  February, 2008
959  * HISTORY
960  *
961  * SOURCE
962 */
963 int_f
h5aopen_by_name_c(hid_t_f * loc_id,_fcd obj_name,size_t_f * obj_namelen,_fcd attr_name,size_t_f * attr_namelen,hid_t_f * aapl_id,hid_t_f * lapl_id,hid_t_f * attr_id)964 h5aopen_by_name_c (hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd attr_name, size_t_f *attr_namelen,
965 		    hid_t_f *aapl_id, hid_t_f *lapl_id, hid_t_f *attr_id)
966 /******/
967 {
968   char *c_obj_name = NULL;          /* Buffer to hold object name C string */
969   char *c_attr_name = NULL;          /* Buffer to hold attribute name C string */
970   int_f ret_value = 0;          /* Return value */
971 
972   /*
973    * Convert FORTRAN name to C name
974    */
975   if((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
976     HGOTO_DONE(FAIL);
977   if((c_attr_name = HD5f2cstring(attr_name, (size_t)*attr_namelen)) == NULL)
978     HGOTO_DONE(FAIL);
979 
980   /*
981    * Call H5Aopen function.
982    */
983   if((*attr_id = (hid_t_f)H5Aopen_by_name((hid_t)*loc_id, c_obj_name, c_attr_name, (hid_t)*aapl_id, (hid_t)*lapl_id)) < 0)
984     HGOTO_DONE(FAIL);
985 
986  done:
987   if(c_obj_name)
988     HDfree(c_obj_name);
989   if(c_attr_name)
990     HDfree(c_attr_name);
991   return ret_value;
992 }
993 
994 /****if* H5Af/h5arename_c
995  * NAME
996  *  h5arename_c
997  * PURPOSE
998  *  Calls H5Arename
999  * INPUTS
1000  *  loc_id            - Object identifier
1001  *  old_attr_name     - Prior attribute name
1002  *  old_attr_name_len - Prior attribute name length
1003  *  new_attr_name     - New attribute name
1004  *  new_attr_name_len - New attribute name length
1005  * OUTPUTS
1006  *     N/A
1007  * RETURNS
1008  *  0 on success, -1 on failure
1009  * AUTHOR
1010  *  M. Scot Breitenfeld
1011  *  January, 2008
1012  * HISTORY
1013  * N/A
1014  * SOURCE
1015 */
1016 
1017 int_f
h5arename_c(hid_t_f * loc_id,_fcd old_attr_name,size_t_f * old_attr_namelen,_fcd new_attr_name,size_t_f * new_attr_namelen)1018 h5arename_c( hid_t_f *loc_id,
1019 		      _fcd old_attr_name, size_t_f *old_attr_namelen,
1020 		      _fcd new_attr_name, size_t_f *new_attr_namelen)
1021 /******/
1022 {
1023   char *c_old_attr_name = NULL;     /* Buffer to hold C string */
1024   char *c_new_attr_name = NULL;     /* Buffer to hold C string */
1025   int_f ret_value=0;          /* Return value */
1026   /*
1027    * Convert FORTRAN name to C name
1028    */
1029   if((c_old_attr_name = HD5f2cstring(old_attr_name, (size_t)*old_attr_namelen)) == NULL)
1030     HGOTO_DONE(FAIL);
1031   if((c_new_attr_name = HD5f2cstring(new_attr_name, (size_t)*new_attr_namelen)) == NULL)
1032     HGOTO_DONE(FAIL);
1033 
1034     if(H5Arename((hid_t)*loc_id,c_old_attr_name,c_new_attr_name) < 0)
1035         HGOTO_DONE(FAIL);
1036 
1037 done:
1038     if(c_old_attr_name)
1039       HDfree(c_old_attr_name);
1040     if(c_new_attr_name)
1041       HDfree(c_new_attr_name);
1042     return ret_value;
1043 }
1044 /****if* H5Af/h5awrite_f_c
1045  * NAME
1046  *  h5awrite_f_c
1047  * PURPOSE
1048  *  Call H5Awrite to write a dataset
1049  * INPUTS
1050  *  attr_id     - Identifier of an attribute to write.
1051  *  mem_type_id - Identifier of the attribute datatype (in memory).
1052  *  buf         - data pointer buffer
1053  * RETURNS
1054  *  0 on success, -1 on failure
1055  * AUTHOR
1056  *  M. Scot Breitenfeld
1057  *  June 11, 2008
1058  * HISTORY
1059  *
1060  *
1061  * SOURCE
1062 */
1063 int_f
h5awrite_f_c(hid_t_f * attr_id,hid_t_f * mem_type_id,void * buf)1064 h5awrite_f_c (hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf)
1065 /******/
1066 {
1067   int ret_value = -1;
1068   herr_t ret;
1069 
1070   ret = H5Awrite( (hid_t)*attr_id, (hid_t)*mem_type_id, buf);
1071 
1072   if (ret < 0) return ret_value;
1073   ret_value = 0;
1074   return ret_value;
1075 }
1076 
1077 /****if* H5Af/h5aread_f_c
1078  * NAME
1079  *  h5aread_f_c
1080  * PURPOSE
1081  *  Call H5Awrite to write a dataset
1082  * INPUTS
1083  *  attr_id     - Identifier of an attribute to write.
1084  *  mem_type_id - Identifier of the attribute datatype (in memory).
1085  *  buf         - data pointer buffer
1086  * RETURNS
1087  *  0 on success, -1 on failure
1088  * AUTHOR
1089  *  M. Scot Breitenfeld
1090  *  June 11, 2008
1091  * HISTORY
1092  *
1093  *
1094  * SOURCE
1095 */
1096 int_f
h5aread_f_c(hid_t_f * attr_id,hid_t_f * mem_type_id,void * buf)1097 h5aread_f_c (hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf)
1098 /******/
1099 {
1100   int ret_value = -1;
1101   herr_t ret;
1102 
1103   ret = H5Aread( (hid_t)*attr_id, (hid_t)*mem_type_id, buf);
1104 
1105   if (ret < 0) return ret_value;
1106   ret_value = 0;
1107   return ret_value;
1108 }
1109 
1110