summaryrefslogtreecommitdiffstats
path: root/fortran/src/H5Lf.c
blob: 5fb5a3425fb1bbf8b15651dcc14e6d499e15d517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
/****h* H5Lf/H5Lf
 * PURPOSE
 *  This file contains C stubs for H5L Fortran APIs
 *
 * COPYRIGHT
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the COPYING file, which can be found at the root of the source code       *
 * distribution tree, or in https://www.hdfgroup.org/licenses.               *
 * If you do not have access to either file, you may request a copy from     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 ******
 */

#include "H5f90.h"
#include "H5Eprivate.h"

/****if* H5Lf/h5lcopy_c
 * NAME
 *  h5lcopy_c
 * PURPOSE
 *  Call H5Lcopy
 * INPUTS
 *
 *  src_loc_id - Location identifier of the source link
 *  src_name - Name of the link to be copied
 *  src_namelen - length of the name
 *  dest_loc_id - Location identifier specifying the destination of the copy
 *  dest_name - Name to be assigned to the NEW copy
 *  dest_namelen - Length of the name
 *  loc_id - Identifier of the file or group containing the object
 *  name - Name of the link to delete
 *  lcpl_id - Link creation property list identifier
 *  lapl_id - Link access property list identifier
 *
 * RETURNS
 *  0 on success, -1 on failure
 * SOURCE
 */

int_f
h5lcopy_c(hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_namelen, hid_t_f *dest_loc_id, _fcd dest_name,
          size_t_f *dest_namelen, hid_t_f *lcpl_id, hid_t_f *lapl_id)
/******/
{
    char *c_src_name  = NULL;
    char *c_dest_name = NULL;
    int_f ret_value   = 0;

    /*
     * Convert FORTRAN name to C name
     */
    if (NULL == (c_src_name = HD5f2cstring(src_name, (size_t)*src_namelen)))
        HGOTO_DONE(FAIL);
    if (NULL == (c_dest_name = HD5f2cstring(dest_name, (size_t)*dest_namelen)))
        HGOTO_DONE(FAIL);

    /*
     * Call H5Lcopy function.
     */
    if (H5Lcopy((hid_t)*src_loc_id, c_src_name, (hid_t)*dest_loc_id, c_dest_name, (hid_t)*lcpl_id,
                (hid_t)*lapl_id) < 0)
        HGOTO_DONE(FAIL);

done:
    if (c_src_name)
        free(c_src_name);
    if (c_dest_name)
        free(c_dest_name);

    return ret_value;
}

/****if* H5Lf/h5lcreate_external_c
 * NAME
 *  h5lcreate_external_c
 * PURPOSE
 *  Call H5Lcreate_external_c
 * INPUTS
 *
 *  file_name - Name of the file containing the target object. Neither the file nor the target object is
 *  required to exist. May be the file the link is being created in.
 *  obj_name - Path within the target file to the target object.
 *  link_loc_id - The file or group identifier for the new link.
 *  link_name - The name of the new link.
 *  lcpl_id - Link creation property list identifier.
 *  lapl_id - Link access property list identifier.
 *
 * RETURNS
 *  0 on success, -1 on failure
 * SOURCE
 */

int_f
h5lcreate_external_c(_fcd file_name, size_t_f *file_namelen, _fcd obj_name, size_t_f *obj_namelen,
                     hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, hid_t_f *lcpl_id,
                     hid_t_f *lapl_id)
/******/
{
    char *c_file_name = NULL;
    char *c_obj_name  = NULL;
    char *c_link_name = NULL;
    int_f ret_value   = 0;

    /*
     * Convert FORTRAN name to C name
     */
    if ((c_file_name = HD5f2cstring(file_name, (size_t)*file_namelen)) == NULL)
        HGOTO_DONE(FAIL);
    if ((c_obj_name = HD5f2cstring(obj_name, (size_t)*obj_namelen)) == NULL)
        HGOTO_DONE(FAIL);
    if ((c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)) == NULL)
        HGOTO_DONE(FAIL);

    /*
     * Call H5Lcopy function.
     */
    if (H5Lcreate_external(c_file_name, c_obj_name, (hid_t)*link_loc_id, c_link_name, (hid_t)*lcpl_id,
                           (hid_t)*lapl_id) < 0)
        HGOTO_DONE(FAIL);

done:
    if (c_file_name)
        free(c_file_name);
    if (c_obj_name)
        free(c_obj_name);
    if (c_link_name)
        free(c_link_name);

    return ret_value;
}

/****if* H5Lf/h5lget_info_c
 * NAME
 *  h5lget_info_c
 * PURPOSE
 *  Call  H5Lget_info
 * INPUTS
 *
 *		link_loc_id - File or group identifier.
 *  link_name - Name of the link for which information is being sought
 *  link_namelen - Name length
 *  lapl_id - Link access property list
 * OUTPUTS
 *
 *
 *  cset - indicates the character set used for link's name.
 *  corder - specifies the link's creation order position.
 *  corder_valid - indicates whether the value in corder is valid.
 *  link_type -  specifies the link class:
 *     	                H5L_LINK_HARD_F      - Hard link
 *     	                H5L_LINK_SOFT_F      - Soft link
 *     	                H5L_LINK_EXTERNAL_F  - External link
 *     	                H5L_LINK_ERROR_F     - Error
 *  token - If the link is a hard link, token specifies the token for the object that the link points to
 *  val_size - If the link is a symbolic link, val_size will be the length of the link value
 *
 * RETURNS
 *  0 on success, -1 on failure
 * SOURCE
 */
int_f
h5lget_info_c(hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, int_f *cset, int_f *corder,
              int_f *corder_valid, int_f *link_type, H5O_token_t *token, size_t_f *val_size, hid_t_f *lapl_id)
/******/
{
    char       *c_link_name = NULL; /* Buffer to hold C string */
    int_f       ret_value   = 0;    /* Return value */
    H5L_info2_t link_buff;

    /*
     * Convert FORTRAN name to C name
     */
    if (NULL == (c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)))
        HGOTO_DONE(FAIL);

    /*
     * Call H5Linfo function.
     */
    if (H5Lget_info2((hid_t)*link_loc_id, c_link_name, &link_buff, (hid_t)*lapl_id) < 0)
        HGOTO_DONE(FAIL);

    /* Unpack the structure */
    *cset         = (int_f)link_buff.cset;
    *corder       = (int_f)link_buff.corder;
    *corder_valid = 0;
    if (link_buff.corder_valid > 0)
        *corder_valid = 1;
    *link_type = (int_f)link_buff.type;
    *token     = link_buff.u.token;
    *val_size  = (size_t_f)link_buff.u.val_size;

done:
    if (c_link_name)
        free(c_link_name);

    return ret_value;
}

/****if* H5Lf/h5lget_info_by_idx_c
 * NAME
 *  h5lget_info_by_idx_c
 * PURPOSE
 *  Call  H5Lget_info_by_idx
 * INPUTS
 *
 *	loc_id  - File or group identifier specifying location of subject group
 *  group_name - Name of subject group
 *  group_namelen - Name length
 *  index_field - Index or field which determines the order
 *  order - Order within field or index
 *  n - Link for which to retrieve information
 *  lapl_id - Link access property list
 * OUTPUTS
 *
 *  corder_valid - Indicates whether the creation order data is valid for this attribute
 *  corder - Is a positive integer containing the creation order of the attribute
 *  cset - Indicates the character set used for the attribute's name
 *  data_size - indicates the size, in the number of characters, of the attribute
 *
 * RETURNS
 *  0 on success, -1 on failure
 * SOURCE
 */
int_f
h5lget_info_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, int_f *index_field,
                     int_f *order, hsize_t_f *n, int_f *link_type, int_f *corder_valid, int_f *corder,
                     int_f *cset, H5O_token_t *token, size_t_f *val_size, hid_t_f *lapl_id)
/******/
{
    char           *c_group_name = NULL; /* Buffer to hold C string */
    H5_index_t      c_index_field;
    H5_iter_order_t c_order;
    int_f           ret_value = 0; /* Return value */
    H5L_info2_t     link_buff;

    /*
     * Convert FORTRAN name to C name
     */
    if ((c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)) == NULL)
        HGOTO_DONE(FAIL);

    c_index_field = (H5_index_t)*index_field;
    c_order       = (H5_iter_order_t)*order;
    /*
     * Call H5Linfo_by_idx function.
     */
    if (H5Lget_info_by_idx2((hid_t)*loc_id, c_group_name, c_index_field, c_order, (hsize_t)*n, &link_buff,
                            (hid_t)*lapl_id) < 0)
        HGOTO_DONE(FAIL);

    /* Unpack the structure */

    *corder_valid = 0;
    if (link_buff.corder_valid > 0)
        *corder_valid = 1;

    *corder    = (int_f)link_buff.corder;
    *cset      = (int_f)link_buff.cset;
    *link_type = (int_f)link_buff.type;
    *token     = link_buff.u.token;
    *val_size  = (size_t_f)link_buff.u.val_size;

done:
    return ret_value;
}

/****if* H5Lf/H5Lis_registered_c
 * NAME
 *        H5Lis_registered_c
 * PURPOSE
 *  Call H5Lis_registered
 * INPUTS
 *
 *  link_cls_id - User-defined link class identifier
 * OUTPUTS
 *     NONE
 *
 * RETURNS
 *  Returns a positive value if the link class has been registered
 *  and zero if it is unregistered. Otherwise returns a negative value
 * SOURCE
 */
int_f
h5lis_registered_c(int_f *link_cls_id)
/******/
{
    int_f ret_value; /* Return value */

    /*
     * Call H5Lis_registered
     */
    ret_value = (int_f)H5Lis_registered((H5L_type_t)*link_cls_id);

    return ret_value;
}

/* { not sure what this is fix -scot- */
/*   int_f ret_value = 0;      /\* Return value *\/ */
/*   H5L_type_t c_link_cls_id; /\* User-defined link class identifier *\/ */
/*   htri_t registered; /\* registration status *\/ */

/*   c_link_cls_id = (H5L_type_t)*link_cls_id; */
/*   /\* */
/*    * Call H5Lis_registered */
/*    *\/ */
/*   registered = H5Lis_registered(c_link_cls_id); */

/*   ret_value = (int_f)registered; */

/*   return ret_value; */
/* } */

/****if* H5Lf/h5lmove_c
 * NAME
 *  h5lmove_c
 * PURPOSE
 *  Call  H5Lmove
 * INPUTS
 *
 *  src_loc_id   - Original file or group identifier.
 *  src_name     - Original link name.
 *  src_namelen  - name length
 *  dest_loc_id  - Destination file or group identifier.
 *  dest_name    - NEW link name.
 *  dest_namelen - name length
 * OUTPUTS
 *
 *
 * RETURNS
 *  0 on success, -1 on failure
 * SOURCE
 */
int_f
h5lmove_c(hid_t_f *src_loc_id, _fcd src_name, size_t_f *src_namelen, hid_t_f *dest_loc_id, _fcd dest_name,
          size_t_f *dest_namelen, hid_t_f *lcpl_id, hid_t_f *lapl_id)
/******/
{
    char *c_src_name  = NULL; /* Buffer to hold C string */
    char *c_dest_name = NULL; /* Buffer to hold C string */
    int_f ret_value   = 0;    /* Return value */

    /*
     * Convert FORTRAN name to C name
     */
    if (NULL == (c_src_name = HD5f2cstring(src_name, (size_t)*src_namelen)))
        HGOTO_DONE(FAIL);
    if (NULL == (c_dest_name = HD5f2cstring(dest_name, (size_t)*dest_namelen)))
        HGOTO_DONE(FAIL);

    /*
     * Call H5Lmove function.
     */
    if (H5Lmove((hid_t)*src_loc_id, c_src_name, (hid_t)*dest_loc_id, c_dest_name, (hid_t)*lcpl_id,
                (hid_t)*lapl_id) < 0)
        HGOTO_DONE(FAIL);

done:
    if (c_src_name)
        free(c_src_name);
    if (c_dest_name)
        free(c_dest_name);

    return ret_value;
}

/****if* H5Lf/h5lget_name_by_idx_c
 * NAME
 *  h5lget_name_by_idx_c
 * PURPOSE
 *  Call  H5Lget_name_by_idx
 * INPUTS
 *
 *  loc_id      - File or group identifier specifying location of subject group
 *  group_name  - Name of subject group
 *  index_field - Index or field which determines the order
 *  order       - Order within field or index
 *  n           - Link for which to retrieve information
 *  size        - Maximum number of characters of link value to be returned.
 *  lapl_id     - Link access property list
 * OUTPUTS
 *
 *  name        - Buffer in which link value is returned
 *  size        - The size of the link name on success
 * RETURNS
 *  0 on success, -1 on failure
 * SOURCE
 */
int_f
h5lget_name_by_idx_c(hid_t_f *loc_id, _fcd group_name, size_t_f *group_namelen, int_f *index_field,
                     int_f *order, hsize_t_f *n, size_t_f *size, _fcd name, hid_t_f *lapl_id)
/******/
{
    char   *c_group_name = NULL; /* Buffer to hold C string */
    char   *c_name       = NULL; /* Buffer to hold C string */
    size_t  c_size;
    ssize_t c_size_link;
    int_f   ret_value = 0; /* Return value */

    /*
     * Convert FORTRAN name to C name
     */
    if (NULL == (c_group_name = HD5f2cstring(group_name, (size_t)*group_namelen)))
        HGOTO_DONE(FAIL);

    c_size = (size_t)*size + 1;

    /*
     * Allocate buffer to hold name of an attribute
     */
    if (NULL == (c_name = (char *)malloc(c_size)))
        HGOTO_DONE(FAIL);

    if ((c_size_link =
             H5Lget_name_by_idx((hid_t)*loc_id, c_group_name, (H5_index_t)*index_field,
                                (H5_iter_order_t)*order, (hsize_t)*n, c_name, c_size, (hid_t)*lapl_id)) < 0)
        HGOTO_DONE(FAIL);

    *size = (size_t_f)c_size_link;

    /*
     * Convert C name to FORTRAN and place it in the given buffer
     */
    if (c_name)
        HD5packFstring(c_name, _fcdtocp(name), c_size - 1);

done:
    if (c_group_name)
        free(c_group_name);
    if (c_name)
        free(c_name);

    return ret_value;
}

/* /\****if* H5Lf/h5lget_val_c */
/*  * NAME */
/*  *        h5lget_val_c */
/*  * PURPOSE */
/*  *     Call  H5Lget_val */
/*  * INPUTS */
/*  * */
/*  *		link_loc_id - File or group identifier. */
/*  *                link_name - Name of the link for which valrmation is being sought */
/*  *             link_namelen - Name length */
/*  *                     size - Maximum number of characters of link value to be returned. */
/*  *                  lapl_id - Link access property list */
/*  * OUTPUTS */
/*  * */
/*  *             linkval_buff - The buffer to hold the returned link value. */
/*  * */
/*  * RETURNS */
/*  *     0 on success, -1 on failure */
/*  * SOURCE */
/* *\/ */
/* int_f */
/* h5lget_val_c (hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, */
/* 	       size_t_f *size, _fcd linkval_buff, */
/* 	       hid_t_f *lapl_id) */
/* { */
/*     char *c_link_name = NULL;   /\* Buffer to hold C string *\/ */
/*     int_f ret_value = 0;        /\* Return value *\/ */
/*     void *c_linkval_buff = NULL; */

/*     /\* */
/*      * Convert FORTRAN name to C name */
/*      *\/ */
/*     if((c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)) == NULL) */
/*       HGOTO_DONE(FAIL); */
/*     /\* */
/*      * Call H5Lval function. */
/*      *\/ */
/*     if(H5Lget_val((hid_t)*link_loc_id, c_link_name, &linkval_buff, (size_t)*size, (hid_t)*lapl_id) < 0) */
/*       HGOTO_DONE(FAIL); */
/*   /\* */
/*    * Convert C name to FORTRAN  */
/*    *\/ */
/*     HD5packFstring(c_buf, _fcdtocp(buf), c_bufsize-1); */

/* done: */
/*     return ret_value; */
/* } */

/* /\****if* H5Lf/ */
/*  * NAME */
/*  *        H5Lregistered_c */
/*  * PURPOSE */
/*  *     Call H5Lregistered */
/*  * INPUTS */
/*  * */
/*  * */
/*  * INPUTS */
/*  * */
/*  *     version         - Version number of this struct */
/*  *     class_id        - Link class identifier */
/*  *     comment         - Comment for debugging */
/*  *     comment_len     - Comment for debugging */
/*  *     create_func     - Callback during link creation */
/*  *     create_func_len - length */
/*  *    move_func        - Callback after moving link */
/*  *    move_func_len    - length */
/*  *     copy_func       - Callback after copying link */
/*  *     copy_func_len   - length */
/*  *     trav_func       - The main traversal function */
/*  *     trav_func_len   - length */
/*  *     del_func        - Callback for link deletion */
/*  *     del_func_len    - length */
/*  *     query_func      - Callback for queries */
/*  *     query_func_len  - length */
/*  * */
/*  * RETURNS */
/*  *     0 on success, -1 on failure */
/*  * SOURCE */
/* *\/ */

/* int_f */

/* h5lregistered_c(int_f *version, int_f *class_id, */
/* 		 _fcd comment, size_t_f *comment_len, */
/* 		 _fcd create_func, size_t_f *create_func_len, */
/* 		 _fcd move_func, size_t_f *move_func_len, */
/* 		 _fcd copy_func, size_t_f *copy_func_len, */
/* 		 _fcd trav_func, size_t_f *trav_func_len, */
/* 		 _fcd del_func , size_t_f *del_func_len, */
/* 		 _fcd query_func, size_t_f *query_func_len) */
/* { */
/*   char *c_comment = NULL;         */
/*   char *c_create_func = NULL; */
/*   char *c_move_func = NULL;    */
/*   char *c_copy_func = NULL;   */
/*   char *c_trav_func = NULL;  */
/*   char *c_del_func = NULL;  */
/*   char *c_query_func = NULL; */

/*   H5L_class_t class_t; */

/*   int_f ret_value = 0; */

/*   /\* */
/*    * Convert FORTRAN name to C name */
/*    *\/ */
/*   if((c_comment = HD5f2cstring(c_comment, (size_t)*sc_comment_len)) == NULL) */
/*     HGOTO_DONE(FAIL); */
/*   if((c_create_func = HD5f2cstring(c_create_func, (size_t)*c_create_func_len)) == NULL) */
/*     HGOTO_DONE(FAIL); */
/*   if((c_move_func = HD5f2cstring(c_move_func, (size_t)*sc_move_func_len)) == NULL) */
/*     HGOTO_DONE(FAIL); */
/*   if((c_copy_func = HD5f2cstring(c_copy_func, (size_t)*c_copy_func_len)) == NULL) */
/*     HGOTO_DONE(FAIL); */
/*   if((c_trav_func = HD5f2cstring(c_trav_func, (size_t)*sc_trav_func_len)) == NULL) */
/*     HGOTO_DONE(FAIL); */
/*   if((c_del_func = HD5f2cstring(c_del_func, (size_t)*c_del_func_len)) == NULL) */
/*     HGOTO_DONE(FAIL); */
/*   if((c_query_func = HD5f2cstring(c_query_func, (size_t)*c_query_func_len)) == NULL) */
/*     HGOTO_DONE(FAIL); */
/*   /\* */
/*    * Pack into C struct H5L_class_t */
/*    *\/ */
/*       int version;                    /\* Version number of this struct  *\/ */
/*       H5L_type_t class_id;            /\* Link class identifier          *\/ */
/*       const char *comment;            /\* Comment for debugging          *\/ */
/*       H5L_create_func_t create_func;  /\* Callback during link creation  *\/ */
/*       H5L_move_func_t move_func;      /\* Callback after moving link     *\/ */
/*       H5L_copy_func_t copy_func;      /\* Callback after copying link    *\/ */
/*       H5L_traverse_func_t trav_func;  /\* The main traversal function    *\/ */
/*       H5L_delete_func_t del_func;     /\* Callback for link deletion     *\/ */
/*       H5L_query_func_t query_func;    /\* Callback for queries           *\/ */

/*       class_t.version = (int)*version; */
/*       class_t.class_id = (H5L_type_t)*class_id; */
/*       class_t.comment = c_comment; */
/*       class_t. */

/*   /\* */
/*    * Call H5Lcopy function. */
/*    *\/ */
/*   if( H5Lcopy( (hid_t)*src_loc_id, c_src_name, (hid_t) *dest_loc_id,  */
/* 	       c_dest_name, (hid_t)*lcpl_id, (hid_t)*lapl_id ) < 0) */
/*     HGOTO_DONE(FAIL); */

/* done: */
/*   if(c_src_name) */
/*     free(c_src_name); */
/*   if(c_dest_name) */
/*     free(c_dest_name); */

/*   return ret_value; */
/* } */

/****if* H5Lf/h5lget_val_c
 * NAME
 *  h5lget_val_c
 * PURPOSE
 *  Call H5Lget_val
 * INPUTS
 *
 *  link_loc_id - File or group identifier.
 *  link_name - Link whose value is to be returned.
 *  link_name_len - length of link_name
 *  size - Maximum number of characters of link value to be returned.
 *  lapl_id  - List access property list identifier
 * OUTPUTS
 *
 *  linkval_buff  - The buffer to hold the returned link value.
 *
 * RETURNS
 *  0 on success, -1 on failure
 * SOURCE
 */
int_f
h5lget_val_c(hid_t_f *link_loc_id, _fcd link_name, size_t_f *link_namelen, size_t_f *size, void *linkval_buff,
             hid_t_f *lapl_id)
/******/
{
    char *c_link_name = NULL; /* Buffer to hold C string */
    int_f ret_value   = 0;    /* Return value */

    /*
     * Convert FORTRAN name to C name
     */
    if (NULL == (c_link_name = HD5f2cstring(link_name, (size_t)*link_namelen)))
        HGOTO_DONE(FAIL);

    /*
     * Call H5Lget_val
     */
    if (H5Lget_val((hid_t)*link_loc_id, c_link_name, &linkval_buff, (size_t)*size, (hid_t)*lapl_id) < 0)
        HGOTO_DONE(FAIL);

done:
    if (c_link_name)
        free(c_link_name);

    return ret_value;
}

/****if* H5Lf/h5literate_by_name_c
 * NAME
 *  h5literate_by_name_c
 * PURPOSE
 *  Call H5Literate_by_name
 * INPUTS
 *
 *  loc_id - Identifier specifying subject group
 *  name - Name of subject group
 *  namelen - Name length
 *  index_type - Type of index which determines the order
 *  order - Order within index
 *  idx - Iteration position at which to start
 *  op - Callback function passing data regarding the link to the calling application
 *  op_data - User-defined pointer to data required by the application for its processing of the link
 *  lapl_id - List access property list identifier
 *
 * OUTPUTS
 *
 *  idx - Position at which an interrupted iteration may be restarted
 *
 * RETURNS
 *  >0 on success, 0< on failure
 * SOURCE
 */
int_f
h5literate_by_name_c(hid_t_f *loc_id, _fcd name, size_t_f *namelen, int_f *index_type, int_f *order,
                     hsize_t_f *idx, H5L_iterate2_t op, void *op_data, hid_t_f *lapl_id)
/******/
{
    int_f   ret_value = -1; /* Return value */
    herr_t  func_ret_value; /* H5Linterate return value */
    hsize_t idx_c  = 0;
    char   *c_name = NULL; /* Buffer to hold C string */

    /*
     * Convert FORTRAN name to C name
     */
    if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL)
        return ret_value = -1;

    idx_c = (hsize_t)*idx;

    /*
     * Call H5Linterate
     */

    func_ret_value = H5Literate_by_name2((hid_t)*loc_id, c_name, (H5_index_t)*index_type,
                                         (H5_iter_order_t)*order, &idx_c, op, op_data, (hid_t)*lapl_id);

    ret_value = (int_f)func_ret_value;
    *idx      = (hsize_t_f)idx_c;

    if (c_name)
        free(c_name);

    return ret_value;
}