Coverage Report

Created: 2025-11-11 06:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hdf5/src/H5P.c
Line
Count
Source
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
 * Copyright by The HDF Group.                                               *
3
 * All rights reserved.                                                      *
4
 *                                                                           *
5
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
6
 * terms governing use, modification, and redistribution, is contained in    *
7
 * the LICENSE file, which can be found at the root of the source code       *
8
 * distribution tree, or in https://www.hdfgroup.org/licenses.               *
9
 * If you do not have access to either file, you may request a copy from     *
10
 * help@hdfgroup.org.                                                        *
11
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13
/*
14
 * Purpose: Generic Property Functions
15
 */
16
17
/****************/
18
/* Module Setup */
19
/****************/
20
21
#include "H5Pmodule.h" /* This source code file is part of the H5P module */
22
23
/***********/
24
/* Headers */
25
/***********/
26
#include "H5private.h"   /* Generic Functions     */
27
#include "H5CXprivate.h" /* API Contexts                         */
28
#include "H5Eprivate.h"  /* Error handling        */
29
#include "H5Iprivate.h"  /* IDs           */
30
#include "H5Ppkg.h"      /* Property lists        */
31
32
/****************/
33
/* Local Macros */
34
/****************/
35
36
/******************/
37
/* Local Typedefs */
38
/******************/
39
40
/* Typedef for property iterator callback */
41
typedef struct {
42
    H5P_iterate_t iter_func; /* Iterator callback */
43
    hid_t         id;        /* Property list or class ID */
44
    void         *iter_data; /* Iterator callback pointer */
45
} H5P_iter_ud_t;
46
47
/********************/
48
/* Local Prototypes */
49
/********************/
50
51
/*********************/
52
/* Package Variables */
53
/*********************/
54
55
/* Package initialization variable */
56
bool H5_PKG_INIT_VAR = false;
57
58
/*****************************/
59
/* Library Private Variables */
60
/*****************************/
61
62
/*******************/
63
/* Local Variables */
64
/*******************/
65
66
/*--------------------------------------------------------------------------
67
 NAME
68
    H5Pcopy
69
 PURPOSE
70
    Routine to copy a property list or class
71
 USAGE
72
    hid_t H5Pcopy(id)
73
        hid_t id;           IN: Property list or class ID to copy
74
 RETURNS
75
    Success: valid property list ID on success (non-negative)
76
    Failure: H5I_INVALID_HID (negative)
77
 DESCRIPTION
78
    Copy a property list or class and return the ID.  This routine calls the
79
    class 'copy' callback after any property 'copy' callbacks are called
80
    (assuming all property 'copy' callbacks return successfully).
81
82
 GLOBAL VARIABLES
83
 COMMENTS, BUGS, ASSUMPTIONS
84
 EXAMPLES
85
 REVISION LOG
86
--------------------------------------------------------------------------*/
87
hid_t
88
H5Pcopy(hid_t id)
89
0
{
90
0
    void *obj;                         /* Property object to copy */
91
0
    hid_t ret_value = H5I_INVALID_HID; /* return value */
92
93
0
    FUNC_ENTER_API(H5I_INVALID_HID)
94
95
0
    if (H5P_DEFAULT == id)
96
0
        HGOTO_DONE(H5P_DEFAULT);
97
98
    /* Check arguments. */
99
0
    if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id))
100
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not property object");
101
0
    if (NULL == (obj = H5I_object(id)))
102
0
        HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5I_INVALID_HID, "property object doesn't exist");
103
104
    /* Compare property lists */
105
0
    if (H5I_GENPROP_LST == H5I_get_type(id)) {
106
0
        if ((ret_value = H5P_copy_plist((H5P_genplist_t *)obj, true)) < 0)
107
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "can't copy property list");
108
0
    } /* end if */
109
    /* Must be property classes */
110
0
    else {
111
0
        H5P_genclass_t *copy_class; /* Copy of class */
112
113
        /* Copy the class */
114
0
        if ((copy_class = H5P__copy_pclass((H5P_genclass_t *)obj)) == NULL)
115
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "can't copy property class");
116
117
        /* Get an ID for the copied class */
118
0
        if ((ret_value = H5I_register(H5I_GENPROP_CLS, copy_class, true)) < 0) {
119
0
            H5P__close_class(copy_class);
120
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID,
121
0
                        "unable to register property list class");
122
0
        } /* end if */
123
0
    }     /* end else */
124
125
0
done:
126
0
    FUNC_LEAVE_API(ret_value)
127
0
} /* H5Pcopy() */
128
129
/*--------------------------------------------------------------------------
130
 NAME
131
    H5Pcreate_class
132
 PURPOSE
133
    Create a new property list class.
134
 USAGE
135
    hid_t H5Pcreate_class(parent, name, cls_create, create_data,
136
                cls_close, close_data)
137
        hid_t parent;       IN: Property list class ID of parent class
138
        const char *name;   IN: Name of class we are creating
139
        H5P_cls_create_func_t cls_create;   IN: The callback function to call
140
                                    when each property list in this class is
141
                                    created.
142
        void *create_data;  IN: Pointer to user data to pass along to class
143
                                    creation callback.
144
        H5P_cls_copy_func_t cls_copy;   IN: The callback function to call
145
                                    when each property list in this class is
146
                                    copied.
147
        void *copy_data;  IN: Pointer to user data to pass along to class
148
                                    copy callback.
149
        H5P_cls_close_func_t cls_close;     IN: The callback function to call
150
                                    when each property list in this class is
151
                                    closed.
152
        void *close_data;   IN: Pointer to user data to pass along to class
153
                                    close callback.
154
 RETURNS
155
    Returns a valid property list class ID on success, H5I_INVALID_HID on failure.
156
 DESCRIPTION
157
    Allocates memory and attaches a class to the property list class hierarchy.
158
 GLOBAL VARIABLES
159
 COMMENTS, BUGS, ASSUMPTIONS
160
 EXAMPLES
161
 REVISION LOG
162
--------------------------------------------------------------------------*/
163
hid_t
164
H5Pcreate_class(hid_t parent, const char *name, H5P_cls_create_func_t cls_create, void *create_data,
165
                H5P_cls_copy_func_t cls_copy, void *copy_data, H5P_cls_close_func_t cls_close,
166
                void *close_data)
167
0
{
168
0
    H5P_genclass_t *par_class = NULL;            /* Pointer to the parent class */
169
0
    H5P_genclass_t *pclass    = NULL;            /* Property list class created */
170
0
    hid_t           ret_value = H5I_INVALID_HID; /* Return value      */
171
172
0
    FUNC_ENTER_API(H5I_INVALID_HID)
173
174
    /* Check arguments. */
175
0
    if (H5P_DEFAULT != parent && (H5I_GENPROP_CLS != H5I_get_type(parent)))
176
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list class");
177
0
    if (!name || !*name)
178
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid class name");
179
0
    if ((create_data != NULL && cls_create == NULL) || (copy_data != NULL && cls_copy == NULL) ||
180
0
        (close_data != NULL && cls_close == NULL))
181
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "data specified, but no callback provided");
182
183
    /* Get the pointer to the parent class */
184
0
    if (parent == H5P_DEFAULT)
185
0
        par_class = NULL;
186
0
    else if (NULL == (par_class = (H5P_genclass_t *)H5I_object(parent)))
187
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't retrieve parent class");
188
189
    /* Create the new property list class */
190
0
    if (NULL == (pclass = H5P__create_class(par_class, name, H5P_TYPE_USER, cls_create, create_data, cls_copy,
191
0
                                            copy_data, cls_close, close_data)))
192
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create property list class");
193
194
    /* Get an ID for the class */
195
0
    if ((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, true)) < 0)
196
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register property list class");
197
198
0
done:
199
0
    if (H5I_INVALID_HID == ret_value && pclass)
200
0
        H5P__close_class(pclass);
201
202
0
    FUNC_LEAVE_API(ret_value)
203
0
} /* H5Pcreate_class() */
204
205
/*--------------------------------------------------------------------------
206
 NAME
207
    H5Pcreate
208
 PURPOSE
209
    Routine to create a new property list of a property list class.
210
 USAGE
211
    hid_t H5Pcreate(cls_id)
212
        hid_t cls_id;       IN: Property list class create list from
213
 RETURNS
214
    Returns a valid property list ID on success, H5I_INVALID_HID  on failure.
215
 DESCRIPTION
216
        Creates a property list of a given class.  If a 'create' callback
217
    exists for the property list class, it is called before the
218
    property list is passed back to the user.  If 'create' callbacks exist for
219
    any individual properties in the property list, they are called before the
220
    class 'create' callback.
221
222
 GLOBAL VARIABLES
223
 COMMENTS, BUGS, ASSUMPTIONS
224
 EXAMPLES
225
 REVISION LOG
226
--------------------------------------------------------------------------*/
227
hid_t
228
H5Pcreate(hid_t cls_id)
229
0
{
230
0
    H5P_genclass_t *pclass;                      /* Property list class to modify */
231
0
    hid_t           ret_value = H5I_INVALID_HID; /* return value */
232
233
0
    FUNC_ENTER_API(H5I_INVALID_HID)
234
235
    /* Check arguments. */
236
0
    if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS)))
237
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list class");
238
239
    /* Create the new property list */
240
0
    if ((ret_value = H5P_create_id(pclass, true)) < 0)
241
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create property list");
242
243
0
done:
244
0
    FUNC_LEAVE_API(ret_value)
245
0
} /* H5Pcreate() */
246
247
/*--------------------------------------------------------------------------
248
 NAME
249
    H5Pregister2
250
 PURPOSE
251
    Routine to register a new property in a property list class.
252
 USAGE
253
    herr_t H5Pregister2(class, name, size, default, prp_create, prp_set, prp_get, prp_close)
254
        hid_t class;            IN: Property list class to close
255
        const char *name;       IN: Name of property to register
256
        size_t size;            IN: Size of property in bytes
257
        void *def_value;        IN: Pointer to buffer containing default value
258
                                    for property in newly created property lists
259
        H5P_prp_create_func_t prp_create;   IN: Function pointer to property
260
                                    creation callback
261
        H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback
262
        H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback
263
        H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback
264
        H5P_prp_copy_func_t prp_copy; IN: Function pointer to property copy callback
265
        H5P_prp_compare_func_t prp_cmp; IN: Function pointer to property compare callback
266
        H5P_prp_close_func_t prp_close; IN: Function pointer to property close
267
                                    callback
268
 RETURNS
269
    Returns non-negative on success, negative on failure.
270
 DESCRIPTION
271
        Registers a new property with a property list class.  The property will
272
    exist in all property list objects of that class after this routine is
273
    finished.  The name of the property must not already exist.  The default
274
    property value must be provided and all new property lists created with this
275
    property will have the property value set to the default provided.  Any of
276
    the callback routines may be set to NULL if they are not needed.
277
278
        Zero-sized properties are allowed and do not store any data in the
279
    property list.  These may be used as flags to indicate the presence or
280
    absence of a particular piece of information.  The 'default' pointer for a
281
    zero-sized property may be set to NULL.  The property 'create' & 'close'
282
    callbacks are called for zero-sized properties, but the 'set' and 'get'
283
    callbacks are never called.
284
285
        The 'create' callback is called when a new property list with this
286
    property is being created.  H5P_prp_create_func_t is defined as:
287
        typedef herr_t (*H5P_prp_create_func_t)(hid_t prop_id, const char *name,
288
                size_t size, void *initial_value);
289
    where the parameters to the callback function are:
290
        hid_t prop_id;      IN: The ID of the property list being created.
291
        const char *name;   IN: The name of the property being modified.
292
        size_t size;        IN: The size of the property value
293
        void *initial_value; IN/OUT: The initial value for the property being created.
294
                                (The 'default' value passed to H5Pregister2)
295
    The 'create' routine may modify the value to be set and those changes will
296
    be stored as the initial value of the property.  If the 'create' routine
297
    returns a negative value, the new property value is not copied into the
298
    property and the property list creation routine returns an error value.
299
300
        The 'set' callback is called before a new value is copied into the
301
    property.  H5P_prp_set_func_t is defined as:
302
        typedef herr_t (*H5P_prp_set_func_t)(hid_t prop_id, const char *name,
303
            size_t size, void *value);
304
    where the parameters to the callback function are:
305
        hid_t prop_id;      IN: The ID of the property list being modified.
306
        const char *name;   IN: The name of the property being modified.
307
        size_t size;        IN: The size of the property value
308
        void *new_value;    IN/OUT: The value being set for the property.
309
    The 'set' routine may modify the value to be set and those changes will be
310
    stored as the value of the property.  If the 'set' routine returns a
311
    negative value, the new property value is not copied into the property and
312
    the property list set routine returns an error value.
313
314
        The 'get' callback is called before a value is retrieved from the
315
    property.  H5P_prp_get_func_t is defined as:
316
        typedef herr_t (*H5P_prp_get_func_t)(hid_t prop_id, const char *name,
317
            size_t size, void *value);
318
    where the parameters to the callback function are:
319
        hid_t prop_id;      IN: The ID of the property list being queried.
320
        const char *name;   IN: The name of the property being queried.
321
        size_t size;        IN: The size of the property value
322
        void *value;        IN/OUT: The value being retrieved for the property.
323
    The 'get' routine may modify the value to be retrieved and those changes
324
    will be returned to the calling function.  If the 'get' routine returns a
325
    negative value, the property value is returned and the property list get
326
    routine returns an error value.
327
328
        The 'delete' callback is called when a property is deleted from a
329
    property list.  H5P_prp_delete_func_t is defined as:
330
        typedef herr_t (*H5P_prp_delete_func_t)(hid_t prop_id, const char *name,
331
            size_t size, void *value);
332
    where the parameters to the callback function are:
333
        hid_t prop_id;      IN: The ID of the property list the property is deleted from.
334
        const char *name;   IN: The name of the property being deleted.
335
        size_t size;        IN: The size of the property value
336
        void *value;        IN/OUT: The value of the property being deleted.
337
    The 'delete' routine may modify the value passed in, but the value is not
338
    used by the library when the 'delete' routine returns.  If the
339
    'delete' routine returns a negative value, the property list deletion
340
    routine returns an error value but the property is still deleted.
341
342
        The 'copy' callback is called when a property list with this
343
    property is copied.  H5P_prp_copy_func_t is defined as:
344
        typedef herr_t (*H5P_prp_copy_func_t)(const char *name, size_t size,
345
            void *value);
346
    where the parameters to the callback function are:
347
        const char *name;   IN: The name of the property being copied.
348
        size_t size;        IN: The size of the property value
349
        void *value;        IN: The value of the property being copied.
350
    The 'copy' routine may modify the value to be copied and those changes will be
351
    stored as the value of the property.  If the 'copy' routine returns a
352
    negative value, the new property value is not copied into the property and
353
    the property list copy routine returns an error value.
354
355
        The 'compare' callback is called when a property list with this
356
    property is compared to another property list.  H5P_prp_compare_func_t is
357
    defined as:
358
        typedef int (*H5P_prp_compare_func_t)( void *value1, void *value2,
359
            size_t size);
360
    where the parameters to the callback function are:
361
        const void *value1; IN: The value of the first property being compared.
362
        const void *value2; IN: The value of the second property being compared.
363
        size_t size;        IN: The size of the property value
364
    The 'compare' routine may not modify the values to be compared.  The
365
    'compare' routine should return a positive value if VALUE1 is greater than
366
    VALUE2, a negative value if VALUE2 is greater than VALUE1 and zero if VALUE1
367
    and VALUE2 are equal.
368
369
        The 'close' callback is called when a property list with this
370
    property is being destroyed.  H5P_prp_close_func_t is defined as:
371
        typedef herr_t (*H5P_prp_close_func_t)(const char *name, size_t size,
372
            void *value);
373
    where the parameters to the callback function are:
374
        const char *name;   IN: The name of the property being closed.
375
        size_t size;        IN: The size of the property value
376
        void *value;        IN: The value of the property being closed.
377
    The 'close' routine may modify the value passed in, but the value is not
378
    used by the library when the 'close' routine returns.  If the
379
    'close' routine returns a negative value, the property list close
380
    routine returns an error value but the property list is still closed.
381
382
 GLOBAL VARIABLES
383
 COMMENTS, BUGS, ASSUMPTIONS
384
        The 'set' callback function may be useful to range check the value being
385
    set for the property or may perform some transformation/translation of the
386
    value set.  The 'get' callback would then [probably] reverse the
387
    transformation, etc.  A single 'get' or 'set' callback could handle
388
    multiple properties by performing different actions based on the property
389
    name or other properties in the property list.
390
391
        I would like to say "the property list is not closed" when a 'close'
392
    routine fails, but I don't think that's possible due to other properties in
393
    the list being successfully closed & removed from the property list.  I
394
    suppose that it would be possible to just remove the properties which have
395
    successful 'close' callbacks, but I'm not happy with the ramifications
396
    of a mangled, un-closable property list hanging around...  Any comments? -QAK
397
398
 EXAMPLES
399
 REVISION LOG
400
--------------------------------------------------------------------------*/
401
herr_t
402
H5Pregister2(hid_t cls_id, const char *name, size_t size, void *def_value, H5P_prp_create_func_t prp_create,
403
             H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete,
404
             H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close)
405
0
{
406
0
    H5P_genclass_t *pclass;      /* Property list class to modify */
407
0
    H5P_genclass_t *orig_pclass; /* Original property class */
408
0
    herr_t          ret_value;   /* Return value */
409
410
0
    FUNC_ENTER_API(FAIL)
411
412
    /* Check arguments. */
413
0
    if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(cls_id, H5I_GENPROP_CLS)))
414
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class");
415
0
    if (!name || !*name)
416
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid class name");
417
0
    if (size > 0 && def_value == NULL)
418
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default");
419
420
    /* Create the new property list class */
421
0
    orig_pclass = pclass;
422
0
    if ((ret_value = H5P__register(&pclass, name, size, def_value, prp_create, prp_set, prp_get, NULL, NULL,
423
0
                                   prp_delete, prp_copy, prp_cmp, prp_close)) < 0)
424
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in class");
425
426
    /* Check if the property class changed and needs to be substituted in the ID */
427
0
    if (pclass != orig_pclass) {
428
0
        H5P_genclass_t *old_pclass; /* Old property class */
429
430
        /* Substitute the new property class in the ID */
431
0
        if (NULL == (old_pclass = (H5P_genclass_t *)H5I_subst(cls_id, pclass)))
432
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to substitute property class in ID");
433
0
        assert(old_pclass == orig_pclass);
434
435
        /* Close the previous class */
436
0
        if (H5P__close_class(old_pclass) < 0)
437
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL,
438
0
                        "unable to close original property class after substitution");
439
0
    } /* end if */
440
441
0
done:
442
0
    FUNC_LEAVE_API(ret_value)
443
0
} /* H5Pregister2() */
444
445
/*--------------------------------------------------------------------------
446
 NAME
447
    H5Pinsert2
448
 PURPOSE
449
    Routine to insert a new property in a property list.
450
 USAGE
451
    herr_t H5Pinsert2(plist, name, size, value, prp_set, prp_get, prp_close)
452
        hid_t plist;            IN: Property list to add property to
453
        const char *name;       IN: Name of property to add
454
        size_t size;            IN: Size of property in bytes
455
        void *value;            IN: Pointer to the value for the property
456
        H5P_prp_set_func_t prp_set; IN: Function pointer to property set callback
457
        H5P_prp_get_func_t prp_get; IN: Function pointer to property get callback
458
        H5P_prp_delete_func_t prp_delete; IN: Function pointer to property delete callback
459
        H5P_prp_copy_func_t prp_copy; IN: Function pointer to property copy callback
460
        H5P_prp_compare_func_t prp_cmp; IN: Function pointer to property compare callback
461
        H5P_prp_close_func_t prp_close; IN: Function pointer to property close
462
                                    callback
463
 RETURNS
464
    Returns non-negative on success, negative on failure.
465
 DESCRIPTION
466
        Inserts a temporary property into a property list.  The property will
467
    exist only in this property list object.  The name of the property must not
468
    already exist.  The value must be provided unless the property is zero-
469
    sized.  Any of the callback routines may be set to NULL if they are not
470
    needed.
471
472
        Zero-sized properties are allowed and do not store any data in the
473
    property list.  These may be used as flags to indicate the presence or
474
    absence of a particular piece of information.  The 'value' pointer for a
475
    zero-sized property may be set to NULL.  The property 'close' callback is
476
    called for zero-sized properties, but the 'set' and 'get' callbacks are
477
    never called.
478
479
        The 'set' callback is called before a new value is copied into the
480
    property.  H5P_prp_set_func_t is defined as:
481
        typedef herr_t (*H5P_prp_set_func_t)(hid_t prop_id, const char *name,
482
            size_t size, void *value);
483
    where the parameters to the callback function are:
484
        hid_t prop_id;      IN: The ID of the property list being modified.
485
        const char *name;   IN: The name of the property being modified.
486
        size_t size;        IN: The size of the property value
487
        void *new_value;    IN/OUT: The value being set for the property.
488
    The 'set' routine may modify the value to be set and those changes will be
489
    stored as the value of the property.  If the 'set' routine returns a
490
    negative value, the new property value is not copied into the property and
491
    the property list set routine returns an error value.
492
493
        The 'get' callback is called before a value is retrieved from the
494
    property.  H5P_prp_get_func_t is defined as:
495
        typedef herr_t (*H5P_prp_get_func_t)(hid_t prop_id, const char *name,
496
            size_t size, void *value);
497
    where the parameters to the callback function are:
498
        hid_t prop_id;      IN: The ID of the property list being queried.
499
        const char *name;   IN: The name of the property being queried.
500
        size_t size;        IN: The size of the property value
501
        void *value;        IN/OUT: The value being retrieved for the property.
502
    The 'get' routine may modify the value to be retrieved and those changes
503
    will be returned to the calling function.  If the 'get' routine returns a
504
    negative value, the property value is returned and the property list get
505
    routine returns an error value.
506
507
        The 'delete' callback is called when a property is deleted from a
508
    property list.  H5P_prp_delete_func_t is defined as:
509
        typedef herr_t (*H5P_prp_delete_func_t)(hid_t prop_id, const char *name,
510
            size_t size, void *value);
511
    where the parameters to the callback function are:
512
        hid_t prop_id;      IN: The ID of the property list the property is deleted from.
513
        const char *name;   IN: The name of the property being deleted.
514
        size_t size;        IN: The size of the property value
515
        void *value;        IN/OUT: The value of the property being deleted.
516
    The 'delete' routine may modify the value passed in, but the value is not
517
    used by the library when the 'delete' routine returns.  If the
518
    'delete' routine returns a negative value, the property list deletion
519
    routine returns an error value but the property is still deleted.
520
521
        The 'copy' callback is called when a property list with this
522
    property is copied.  H5P_prp_copy_func_t is defined as:
523
        typedef herr_t (*H5P_prp_copy_func_t)(const char *name, size_t size,
524
            void *value);
525
    where the parameters to the callback function are:
526
        const char *name;   IN: The name of the property being copied.
527
        size_t size;        IN: The size of the property value
528
        void *value;        IN: The value of the property being copied.
529
    The 'copy' routine may modify the value to be copied and those changes will be
530
    stored as the value of the property.  If the 'copy' routine returns a
531
    negative value, the new property value is not copied into the property and
532
    the property list copy routine returns an error value.
533
534
        The 'compare' callback is called when a property list with this
535
    property is compared to another property list.  H5P_prp_compare_func_t is
536
    defined as:
537
        typedef int (*H5P_prp_compare_func_t)( void *value1, void *value2,
538
            size_t size);
539
    where the parameters to the callback function are:
540
        const void *value1; IN: The value of the first property being compared.
541
        const void *value2; IN: The value of the second property being compared.
542
        size_t size;        IN: The size of the property value
543
    The 'compare' routine may not modify the values to be compared.  The
544
    'compare' routine should return a positive value if VALUE1 is greater than
545
    VALUE2, a negative value if VALUE2 is greater than VALUE1 and zero if VALUE1
546
    and VALUE2 are equal.
547
548
        The 'close' callback is called when a property list with this
549
    property is being destroyed.  H5P_prp_close_func_t is defined as:
550
        typedef herr_t (*H5P_prp_close_func_t)(const char *name, size_t size,
551
            void *value);
552
    where the parameters to the callback function are:
553
        const char *name;   IN: The name of the property being closed.
554
        size_t size;        IN: The size of the property value
555
        void *value;        IN: The value of the property being closed.
556
    The 'close' routine may modify the value passed in, but the value is not
557
    used by the library when the 'close' routine returns.  If the
558
    'close' routine returns a negative value, the property list close
559
    routine returns an error value but the property list is still closed.
560
561
 GLOBAL VARIABLES
562
 COMMENTS, BUGS, ASSUMPTIONS
563
        The 'set' callback function may be useful to range check the value being
564
    set for the property or may perform some transformation/translation of the
565
    value set.  The 'get' callback would then [probably] reverse the
566
    transformation, etc.  A single 'get' or 'set' callback could handle
567
    multiple properties by performing different actions based on the property
568
    name or other properties in the property list.
569
570
        There is no 'create' callback routine for temporary property list
571
    objects, the initial value is assumed to have any necessary setup already
572
    performed on it.
573
574
        I would like to say "the property list is not closed" when a 'close'
575
    routine fails, but I don't think that's possible due to other properties in
576
    the list being successfully closed & removed from the property list.  I
577
    suppose that it would be possible to just remove the properties which have
578
    successful 'close' callbacks, but I'm not happy with the ramifications
579
    of a mangled, un-closable property list hanging around...  Any comments? -QAK
580
581
 EXAMPLES
582
 REVISION LOG
583
--------------------------------------------------------------------------*/
584
herr_t
585
H5Pinsert2(hid_t plist_id, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set,
586
           H5P_prp_get_func_t prp_get, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy,
587
           H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close)
588
0
{
589
0
    H5P_genplist_t *plist;     /* Property list to modify */
590
0
    herr_t          ret_value; /* return value */
591
592
0
    FUNC_ENTER_API(FAIL)
593
594
    /* Check arguments. */
595
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
596
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
597
0
    if (!name || !*name)
598
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name");
599
0
    if (size > 0 && value == NULL)
600
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "properties >0 size must have default");
601
602
    /* Create the new property list class */
603
0
    if ((ret_value = H5P_insert(plist, name, size, value, prp_set, prp_get, NULL, NULL, prp_delete, prp_copy,
604
0
                                prp_cmp, prp_close)) < 0)
605
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to register property in plist");
606
607
0
done:
608
0
    FUNC_LEAVE_API(ret_value)
609
0
} /* H5Pinsert2() */
610
611
/*--------------------------------------------------------------------------
612
 NAME
613
    H5Pset
614
 PURPOSE
615
    Routine to set a property's value in a property list.
616
 USAGE
617
    herr_t H5Pset(plist_id, name, value)
618
        hid_t plist_id;         IN: Property list to find property in
619
        const char *name;       IN: Name of property to set
620
        void *value;            IN: Pointer to the value for the property
621
 RETURNS
622
    Returns non-negative on success, negative on failure.
623
 DESCRIPTION
624
        Sets a new value for a property in a property list.  The property name
625
    must exist or this routine will fail.  If there is a 'set' callback routine
626
    registered for this property, the 'value' will be passed to that routine and
627
    any changes to the 'value' will be used when setting the property value.
628
    The information pointed at by the 'value' pointer (possibly modified by the
629
    'set' callback) is copied into the property list value and may be changed
630
    by the application making the H5Pset call without affecting the property
631
    value.
632
633
        If the 'set' callback routine returns an error, the property value will
634
    not be modified.  This routine may not be called for zero-sized properties
635
    and will return an error in that case.
636
637
 GLOBAL VARIABLES
638
 COMMENTS, BUGS, ASSUMPTIONS
639
 EXAMPLES
640
 REVISION LOG
641
--------------------------------------------------------------------------*/
642
herr_t
643
H5Pset(hid_t plist_id, const char *name, const void *value)
644
0
{
645
0
    H5P_genplist_t *plist;               /* Property list to modify */
646
0
    herr_t          ret_value = SUCCEED; /* return value */
647
648
0
    FUNC_ENTER_API(FAIL)
649
650
    /* Check arguments. */
651
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
652
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
653
0
    if (!name || !*name)
654
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name");
655
0
    if (value == NULL)
656
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property value");
657
658
    /* Go set the value */
659
0
    if (H5P_set(plist, name, value) < 0)
660
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to set value in plist");
661
662
0
done:
663
0
    FUNC_LEAVE_API(ret_value)
664
0
} /* H5Pset() */
665
666
/*--------------------------------------------------------------------------
667
 NAME
668
    H5Pexist
669
 PURPOSE
670
    Routine to query the existence of a property in a property object.
671
 USAGE
672
    htri_t H5P_exist(id, name)
673
        hid_t id;           IN: Property object ID to check
674
        const char *name;   IN: Name of property to check for
675
 RETURNS
676
    Success: Positive if the property exists in the property object, zero
677
            if the property does not exist.
678
    Failure: negative value
679
 DESCRIPTION
680
        This routine checks if a property exists within a property list or
681
    class.
682
683
 GLOBAL VARIABLES
684
 COMMENTS, BUGS, ASSUMPTIONS
685
 EXAMPLES
686
 REVISION LOG
687
--------------------------------------------------------------------------*/
688
htri_t
689
H5Pexist(hid_t id, const char *name)
690
0
{
691
0
    H5P_genplist_t *plist;     /* Property list to query */
692
0
    H5P_genclass_t *pclass;    /* Property class to query */
693
0
    htri_t          ret_value; /* return value */
694
695
0
    FUNC_ENTER_API(FAIL)
696
697
    /* Check arguments. */
698
0
    if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id))
699
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object");
700
0
    if (!name || !*name)
701
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name");
702
703
    /* Check for the existence of the property in the list or class */
704
0
    if (H5I_GENPROP_LST == H5I_get_type(id)) {
705
0
        if (NULL == (plist = (H5P_genplist_t *)H5I_object(id)))
706
0
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
707
0
        if ((ret_value = H5P_exist_plist(plist, name)) < 0)
708
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property does not exist in list");
709
0
    } /* end if */
710
0
    else if (H5I_GENPROP_CLS == H5I_get_type(id)) {
711
0
        if (NULL == (pclass = (H5P_genclass_t *)H5I_object(id)))
712
0
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class");
713
0
        if ((ret_value = H5P__exist_pclass(pclass, name)) < 0)
714
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "property does not exist in class");
715
0
    } /* end if */
716
0
    else
717
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object");
718
719
0
done:
720
0
    FUNC_LEAVE_API(ret_value)
721
0
} /* H5Pexist() */
722
723
/*--------------------------------------------------------------------------
724
 NAME
725
    H5Pget_size
726
 PURPOSE
727
    Routine to query the size of a property in a property list or class.
728
 USAGE
729
    herr_t H5Pget_size(id, name)
730
        hid_t id;               IN: ID of property list or class to check
731
        const char *name;       IN: Name of property to query
732
        size_t *size;           OUT: Size of property
733
 RETURNS
734
    Success: non-negative value
735
    Failure: negative value
736
 DESCRIPTION
737
        This routine retrieves the size of a property's value in bytes.  Zero-
738
    sized properties are allowed and return a value of 0.  This function works
739
    for both property lists and classes.
740
741
 GLOBAL VARIABLES
742
 COMMENTS, BUGS, ASSUMPTIONS
743
 EXAMPLES
744
 REVISION LOG
745
--------------------------------------------------------------------------*/
746
herr_t
747
H5Pget_size(hid_t id, const char *name, size_t *size /*out*/)
748
0
{
749
0
    H5P_genclass_t *pclass;    /* Property class to query */
750
0
    H5P_genplist_t *plist;     /* Property list to query */
751
0
    herr_t          ret_value; /* return value */
752
753
0
    FUNC_ENTER_API(FAIL)
754
755
    /* Check arguments. */
756
0
    if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id))
757
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object");
758
0
    if (!name || !*name)
759
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name");
760
0
    if (size == NULL)
761
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property size");
762
763
0
    if (H5I_GENPROP_LST == H5I_get_type(id)) {
764
0
        if (NULL == (plist = (H5P_genplist_t *)H5I_object(id)))
765
0
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
766
767
        /* Check the property size */
768
0
        if ((ret_value = H5P__get_size_plist(plist, name, size)) < 0)
769
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query size in plist");
770
0
    } /* end if */
771
0
    else if (H5I_GENPROP_CLS == H5I_get_type(id)) {
772
0
        if (NULL == (pclass = (H5P_genclass_t *)H5I_object(id)))
773
0
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
774
775
        /* Check the property size */
776
0
        if ((ret_value = H5P__get_size_pclass(pclass, name, size)) < 0)
777
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query size in plist");
778
0
    } /* end if */
779
0
    else
780
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object");
781
782
0
done:
783
0
    FUNC_LEAVE_API(ret_value)
784
0
} /* H5Pget_size() */
785
786
/*--------------------------------------------------------------------------
787
 NAME
788
    H5Pencode2
789
 PURPOSE
790
    Routine to convert the property values in a property list into a binary buffer.
791
    The encoding of property values will be done according to the file format
792
    setting in fapl_id.
793
 USAGE
794
    herr_t H5Pencode2(plist_id, buf, nalloc, fapl_id)
795
        hid_t plist_id;         IN: Identifier to property list to encode
796
        void *buf:              OUT: buffer to gold the encoded plist
797
        size_t *nalloc;         IN/OUT: size of buffer needed to encode plist
798
        hid_t fapl_id;          IN: File access property list ID
799
 RETURNS
800
    Returns non-negative on success, negative on failure.
801
 DESCRIPTION
802
    Encodes a property list into a binary buffer. If the buffer is NULL, then
803
    the call will set the size needed to encode the plist in nalloc. Otherwise
804
    the routine will encode the plist in buf.
805
 GLOBAL VARIABLES
806
 COMMENTS, BUGS, ASSUMPTIONS
807
 EXAMPLES
808
 REVISION LOG
809
--------------------------------------------------------------------------*/
810
herr_t
811
H5Pencode2(hid_t plist_id, void *buf, size_t *nalloc, hid_t fapl_id)
812
0
{
813
0
    H5P_genplist_t *plist;               /* Property list to query */
814
0
    herr_t          ret_value = SUCCEED; /* return value */
815
816
0
    FUNC_ENTER_API(FAIL)
817
818
    /* Check arguments. */
819
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
820
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
821
822
    /* Verify access property list and set up collective metadata if appropriate */
823
0
    if (H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, true) < 0)
824
0
        HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info");
825
826
    /* Call the internal encode routine */
827
0
    if ((ret_value = H5P__encode(plist, true, buf, nalloc)) < 0)
828
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTENCODE, FAIL, "unable to encode property list");
829
830
0
done:
831
0
    FUNC_LEAVE_API(ret_value)
832
0
} /* H5Pencode2() */
833
834
/*--------------------------------------------------------------------------
835
 NAME
836
    H5Pdecode
837
 PURPOSE
838
    API routine to decode a property list from a binary buffer.
839
 USAGE
840
    hid_t H5Pdecode(buf)
841
        void *buf;    IN: buffer that holds the encoded plist
842
 RETURNS
843
    Success: ID of new property list object
844
    Failure: H5I_INVALID_HID (negative)
845
 DESCRIPTION
846
     Decodes a property list from a binary buffer. The contents of the buffer
847
     contain the values for the corresponding properties of the plist. The decode
848
     callback of a certain property decodes its value from the buffer and sets it
849
     in the property list.
850
 GLOBAL VARIABLES
851
 COMMENTS, BUGS, ASSUMPTIONS
852
     Properties in the property list that are not encoded in the serialized
853
     form retain their default value.
854
 EXAMPLES
855
 REVISION LOG
856
--------------------------------------------------------------------------*/
857
hid_t
858
H5Pdecode(const void *buf)
859
0
{
860
0
    hid_t ret_value = H5I_INVALID_HID; /* return value */
861
862
0
    FUNC_ENTER_API(H5I_INVALID_HID)
863
864
    /* Call the internal decode routine */
865
0
    if ((ret_value = H5P__decode(buf)) < 0)
866
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTDECODE, H5I_INVALID_HID, "unable to decode property list");
867
868
0
done:
869
0
    FUNC_LEAVE_API(ret_value)
870
0
} /* H5Pdecode() */
871
872
/*--------------------------------------------------------------------------
873
 NAME
874
    H5Pget_class
875
 PURPOSE
876
    Routine to query the class of a generic property list
877
 USAGE
878
    hid_t H5Pget_class(plist_id)
879
        hid_t plist_id;         IN: Property list to query
880
 RETURNS
881
    Success: ID of class object
882
    Failure: H5I_INVALID_HID (negative)
883
 DESCRIPTION
884
    This routine retrieves the class of a property list.
885
886
 GLOBAL VARIABLES
887
 COMMENTS, BUGS, ASSUMPTIONS
888
    Change the name of this function to H5Pget_class (and remove old H5Pget_class)
889
 EXAMPLES
890
 REVISION LOG
891
--------------------------------------------------------------------------*/
892
hid_t
893
H5Pget_class(hid_t plist_id)
894
0
{
895
0
    H5P_genplist_t *plist;                       /* Property list to query */
896
0
    H5P_genclass_t *pclass    = NULL;            /* Property list class */
897
0
    hid_t           ret_value = H5I_INVALID_HID; /* return value */
898
899
0
    FUNC_ENTER_API(H5I_INVALID_HID)
900
901
    /* Check arguments. */
902
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
903
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list");
904
905
    /* Retrieve the property list class */
906
0
    if ((pclass = H5P_get_class(plist)) == NULL)
907
0
        HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5I_INVALID_HID, "unable to query class of property list");
908
909
    /* Increment the outstanding references to the class object */
910
0
    if (H5P__access_class(pclass, H5P_MOD_INC_REF) < 0)
911
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't increment class ID ref count");
912
913
    /* Get an ID for the class */
914
0
    if ((ret_value = H5I_register(H5I_GENPROP_CLS, pclass, true)) < 0)
915
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register property list class");
916
917
0
done:
918
0
    if (H5I_INVALID_HID == ret_value && pclass)
919
0
        H5P__close_class(pclass);
920
921
0
    FUNC_LEAVE_API(ret_value)
922
0
} /* H5Pget_class() */
923
924
/*--------------------------------------------------------------------------
925
 NAME
926
    H5Pget_nprops
927
 PURPOSE
928
    Routine to query the size of a property in a property list or class.
929
 USAGE
930
    herr_t H5Pget_nprops(id, nprops)
931
        hid_t id;               IN: ID of Property list or class to check
932
        size_t *nprops;         OUT: Number of properties in the property object
933
 RETURNS
934
    Success: non-negative value
935
    Failure: negative value
936
 DESCRIPTION
937
        This routine retrieves the number of properties in a property list or
938
    class.  If a property class ID is given, the number of registered properties
939
    in the class is returned in NPROPS.  If a property list ID is given, the
940
    current number of properties in the list is returned in NPROPS.
941
942
 GLOBAL VARIABLES
943
 COMMENTS, BUGS, ASSUMPTIONS
944
 EXAMPLES
945
 REVISION LOG
946
--------------------------------------------------------------------------*/
947
herr_t
948
H5Pget_nprops(hid_t id, size_t *nprops /*out*/)
949
0
{
950
0
    H5P_genplist_t *plist;               /* Property list to query */
951
0
    H5P_genclass_t *pclass;              /* Property class to query */
952
0
    herr_t          ret_value = SUCCEED; /* return value */
953
954
0
    FUNC_ENTER_API(FAIL)
955
956
    /* Check arguments. */
957
0
    if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id))
958
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object");
959
0
    if (nprops == NULL)
960
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property nprops pointer");
961
962
0
    if (H5I_GENPROP_LST == H5I_get_type(id)) {
963
0
        if (NULL == (plist = (H5P_genplist_t *)H5I_object(id)))
964
0
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
965
0
        if (H5P__get_nprops_plist(plist, nprops) < 0)
966
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query # of properties in plist");
967
0
    } /* end if */
968
0
    else if (H5I_GENPROP_CLS == H5I_get_type(id)) {
969
0
        if (NULL == (pclass = (H5P_genclass_t *)H5I_object(id)))
970
0
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class");
971
0
        if (H5P_get_nprops_pclass(pclass, nprops, false) < 0)
972
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to query # of properties in pclass");
973
0
    } /* end if */
974
0
    else
975
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object");
976
977
0
done:
978
0
    FUNC_LEAVE_API(ret_value)
979
0
} /* H5Pget_nprops() */
980
981
/*--------------------------------------------------------------------------
982
 NAME
983
    H5Pequal
984
 PURPOSE
985
    Routine to query whether two property lists or two property classes are equal
986
 USAGE
987
    htri_t H5Pequal(id1, id2)
988
        hid_t id1;         IN: Property list or class ID to compare
989
        hid_t id2;         IN: Property list or class ID to compare
990
 RETURNS
991
    Success: true if equal, false if unequal
992
    Failure: negative
993
 DESCRIPTION
994
    Determines whether two property lists or two property classes are equal.
995
996
 GLOBAL VARIABLES
997
 COMMENTS, BUGS, ASSUMPTIONS
998
 EXAMPLES
999
 REVISION LOG
1000
--------------------------------------------------------------------------*/
1001
htri_t
1002
H5Pequal(hid_t id1, hid_t id2)
1003
0
{
1004
0
    void  *obj1, *obj2;       /* Property objects to compare */
1005
0
    htri_t ret_value = false; /* return value */
1006
1007
0
    FUNC_ENTER_API(FAIL)
1008
1009
    /* Check arguments. */
1010
0
    if ((H5I_GENPROP_LST != H5I_get_type(id1) && H5I_GENPROP_CLS != H5I_get_type(id1)) ||
1011
0
        (H5I_GENPROP_LST != H5I_get_type(id2) && H5I_GENPROP_CLS != H5I_get_type(id2)))
1012
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property objects");
1013
0
    if (H5I_get_type(id1) != H5I_get_type(id2))
1014
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not the same kind of property objects");
1015
0
    if (NULL == (obj1 = H5I_object(id1)) || NULL == (obj2 = H5I_object(id2)))
1016
0
        HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist");
1017
1018
    /* Compare property lists */
1019
0
    if (H5I_GENPROP_LST == H5I_get_type(id1)) {
1020
0
        int cmp_ret = 0;
1021
1022
0
        if (H5P__cmp_plist((const H5P_genplist_t *)obj1, (const H5P_genplist_t *)obj2, &cmp_ret) < 0)
1023
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTCOMPARE, FAIL, "can't compare property lists");
1024
1025
        /* Set return value */
1026
0
        ret_value = cmp_ret == 0 ? true : false;
1027
0
    } /* end if */
1028
    /* Must be property classes */
1029
0
    else {
1030
0
        if (H5P__cmp_class((const H5P_genclass_t *)obj1, (const H5P_genclass_t *)obj2) == 0)
1031
0
            ret_value = true;
1032
0
    } /* end else */
1033
1034
0
done:
1035
0
    FUNC_LEAVE_API(ret_value)
1036
0
} /* H5Pequal() */
1037
1038
/*--------------------------------------------------------------------------
1039
 NAME
1040
    H5Pisa_class
1041
 PURPOSE
1042
    Routine to query whether a property list is a certain class
1043
 USAGE
1044
    hid_t H5Pisa_class(plist_id, pclass_id)
1045
        hid_t plist_id;         IN: Property list to query
1046
        hid_t pclass_id;        IN: Property class to query
1047
 RETURNS
1048
    Success: true (1) or false (0)
1049
    Failure: negative
1050
 DESCRIPTION
1051
    This routine queries whether a property list is a member of the property
1052
    list class.
1053
1054
 GLOBAL VARIABLES
1055
 COMMENTS, BUGS, ASSUMPTIONS
1056
    What about returning a value indicating that the property class is further
1057
    up the class hierarchy?
1058
 EXAMPLES
1059
 REVISION LOG
1060
--------------------------------------------------------------------------*/
1061
htri_t
1062
H5Pisa_class(hid_t plist_id, hid_t pclass_id)
1063
0
{
1064
0
    htri_t ret_value; /* return value */
1065
1066
0
    FUNC_ENTER_API(FAIL)
1067
1068
    /* Check arguments. */
1069
0
    if (H5I_GENPROP_LST != H5I_get_type(plist_id))
1070
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
1071
0
    if (H5I_GENPROP_CLS != H5I_get_type(pclass_id))
1072
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class");
1073
1074
    /* Compare the property list's class against the other class */
1075
0
    if ((ret_value = H5P_isa_class(plist_id, pclass_id)) < 0)
1076
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to compare property list classes");
1077
1078
0
done:
1079
0
    FUNC_LEAVE_API(ret_value)
1080
0
} /* H5Pisa_class() */
1081
1082
/*--------------------------------------------------------------------------
1083
 NAME
1084
    H5P__iterate_cb
1085
 PURPOSE
1086
    Internal callback routine when iterating over properties in property list
1087
    or class
1088
 USAGE
1089
    int H5P__iterate_cb(prop, udata)
1090
        H5P_genprop_t *prop;        IN: Pointer to the property
1091
        void *udata;                IN/OUT: Pointer to iteration data from user
1092
 RETURNS
1093
    Success: Returns the return value of the last call to ITER_FUNC
1094
    Failure: negative value
1095
 DESCRIPTION
1096
    This routine calls the actual callback routine for the property in the
1097
property list or class.
1098
 GLOBAL VARIABLES
1099
 COMMENTS, BUGS, ASSUMPTIONS
1100
 EXAMPLES
1101
 REVISION LOG
1102
--------------------------------------------------------------------------*/
1103
static int
1104
H5P__iterate_cb(H5P_genprop_t *prop, void *_udata)
1105
0
{
1106
0
    H5P_iter_ud_t *udata     = (H5P_iter_ud_t *)_udata; /* Pointer to user data */
1107
0
    int            ret_value = 0;                       /* Return value */
1108
1109
0
    FUNC_ENTER_PACKAGE_NOERR
1110
1111
    /* Sanity check */
1112
0
    assert(prop);
1113
0
    assert(udata);
1114
1115
    /* Call the user's callback routine */
1116
0
    ret_value = (*udata->iter_func)(udata->id, prop->name, udata->iter_data);
1117
1118
0
    FUNC_LEAVE_NOAPI(ret_value)
1119
0
} /* end H5P__iterate_cb() */
1120
1121
/*--------------------------------------------------------------------------
1122
 NAME
1123
    H5Piterate
1124
 PURPOSE
1125
    Routine to iterate over the properties in a property list or class
1126
 USAGE
1127
    int H5Piterate(pclass_id, idx, iter_func, iter_data)
1128
        hid_t id;                   IN: ID of property object to iterate over
1129
        int *idx;                   IN/OUT: Index of the property to begin with
1130
        H5P_iterate_t iter_func;    IN: Function pointer to function to be
1131
                                        called with each property iterated over.
1132
        void *iter_data;            IN/OUT: Pointer to iteration data from user
1133
 RETURNS
1134
    Success: Returns the return value of the last call to ITER_FUNC if it was
1135
                non-zero, or zero if all properties have been processed.
1136
    Failure: negative value
1137
 DESCRIPTION
1138
    This routine iterates over the properties in the property object specified
1139
with ID.  The properties in both property lists and classes may be iterated
1140
over with this function.  For each property in the object, the ITER_DATA and
1141
some additional information, specified below, are passed to the ITER_FUNC
1142
function.  The iteration begins with the IDX property in the object and the
1143
next element to be processed by the operator is returned in IDX.  If IDX is
1144
NULL, then the iterator starts at the first property; since no stopping point
1145
is returned in this case, the iterator cannot be restarted if one of the calls
1146
to its operator returns non-zero.  The IDX value is 0-based (ie. to start at
1147
the "first" property, the IDX value should be 0).
1148
1149
The prototype for H5P_iterate_t is:
1150
    typedef herr_t (*H5P_iterate_t)(hid_t id, const char *name, void *iter_data);
1151
The operation receives the property list or class identifier for the object
1152
being iterated over, ID, the name of the current property within the object,
1153
NAME, and the pointer to the operator data passed in to H5Piterate, ITER_DATA.
1154
1155
The return values from an operator are:
1156
    Zero causes the iterator to continue, returning zero when all properties
1157
        have been processed.
1158
    Positive causes the iterator to immediately return that positive value,
1159
        indicating short-circuit success. The iterator can be restarted at the
1160
        index of the next property.
1161
    Negative causes the iterator to immediately return that value, indicating
1162
        failure. The iterator can be restarted at the index of the next
1163
        property.
1164
1165
H5Piterate assumes that the properties in the object identified by ID remains
1166
unchanged through the iteration.  If the membership changes during the
1167
iteration, the function's behavior is undefined.
1168
1169
 GLOBAL VARIABLES
1170
 COMMENTS, BUGS, ASSUMPTIONS
1171
 EXAMPLES
1172
 REVISION LOG
1173
--------------------------------------------------------------------------*/
1174
int
1175
H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data)
1176
0
{
1177
0
    H5P_iter_ud_t udata;        /* User data for internal iterator callback */
1178
0
    int           fake_idx = 0; /* Index when user doesn't provide one */
1179
0
    void         *obj;          /* Property object to copy */
1180
0
    int           ret_value;    /* return value */
1181
1182
0
    FUNC_ENTER_API(FAIL)
1183
1184
    /* Check arguments. */
1185
0
    if (H5I_GENPROP_LST != H5I_get_type(id) && H5I_GENPROP_CLS != H5I_get_type(id))
1186
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object");
1187
0
    if (NULL == (obj = H5I_object(id)))
1188
0
        HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property object doesn't exist");
1189
0
    if (iter_func == NULL)
1190
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration callback");
1191
1192
    /* Set up user data */
1193
0
    udata.iter_func = iter_func;
1194
0
    udata.id        = id;
1195
0
    udata.iter_data = iter_data;
1196
1197
0
    if (H5I_GENPROP_LST == H5I_get_type(id)) {
1198
        /* Iterate over a property list */
1199
0
        if ((ret_value = H5P__iterate_plist((H5P_genplist_t *)obj, true, (idx ? idx : &fake_idx),
1200
0
                                            H5P__iterate_cb, &udata)) < 0)
1201
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over list");
1202
0
    } /* end if */
1203
0
    else if (H5I_GENPROP_CLS == H5I_get_type(id)) {
1204
        /* Iterate over a property class */
1205
0
        if ((ret_value = H5P__iterate_pclass((H5P_genclass_t *)obj, (idx ? idx : &fake_idx), H5P__iterate_cb,
1206
0
                                             &udata)) < 0)
1207
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over class");
1208
0
    } /* end if */
1209
0
    else
1210
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property object");
1211
1212
0
done:
1213
0
    FUNC_LEAVE_API(ret_value)
1214
0
} /* H5Piterate() */
1215
1216
/*--------------------------------------------------------------------------
1217
 NAME
1218
    H5Pget
1219
 PURPOSE
1220
    Routine to query the value of a property in a property list.
1221
 USAGE
1222
    herr_t H5Pget(plist_id, name, value)
1223
        hid_t plist_id;         IN: Property list to check
1224
        const char *name;       IN: Name of property to query
1225
        void *value;            OUT: Pointer to the buffer for the property value
1226
 RETURNS
1227
    Returns non-negative on success, negative on failure.
1228
 DESCRIPTION
1229
        Retrieves a copy of the value for a property in a property list.  The
1230
    property name must exist or this routine will fail.  If there is a
1231
    'get' callback routine registered for this property, the copy of the
1232
    value of the property will first be passed to that routine and any changes
1233
    to the copy of the value will be used when returning the property value
1234
    from this routine.
1235
        If the 'get' callback routine returns an error, 'value' will not be
1236
    modified and this routine will return an error.  This routine may not be
1237
    called for zero-sized properties.
1238
1239
 GLOBAL VARIABLES
1240
 COMMENTS, BUGS, ASSUMPTIONS
1241
 EXAMPLES
1242
 REVISION LOG
1243
--------------------------------------------------------------------------*/
1244
herr_t
1245
H5Pget(hid_t plist_id, const char *name, void *value /*out*/)
1246
0
{
1247
0
    H5P_genplist_t *plist;               /* Property list pointer */
1248
0
    herr_t          ret_value = SUCCEED; /* return value */
1249
1250
0
    FUNC_ENTER_API(FAIL)
1251
1252
    /* Check arguments. */
1253
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
1254
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
1255
0
    if (!name || !*name)
1256
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name");
1257
0
    if (value == NULL)
1258
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property value");
1259
1260
    /* Go get the value */
1261
0
    if (H5P_get(plist, name, value) < 0)
1262
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to query property value");
1263
1264
0
done:
1265
0
    FUNC_LEAVE_API(ret_value)
1266
0
} /* H5Pget() */
1267
1268
/*--------------------------------------------------------------------------
1269
 NAME
1270
    H5Premove
1271
 PURPOSE
1272
    Routine to remove a property from a property list.
1273
 USAGE
1274
    herr_t H5Premove(plist_id, name)
1275
        hid_t plist_id;         IN: Property list to modify
1276
        const char *name;       IN: Name of property to remove
1277
 RETURNS
1278
    Returns non-negative on success, negative on failure.
1279
 DESCRIPTION
1280
        Removes a property from a property list.  Both properties which were
1281
    in existence when the property list was created (i.e. properties registered
1282
    with H5Pregister2) and properties added to the list after it was created
1283
    (i.e. added with H5Pinsert2) may be removed from a property list.
1284
    Properties do not need to be removed a property list before the list itself
1285
    is closed, they will be released automatically when H5Pclose is called.
1286
    The 'close' callback for this property is called before the property is
1287
    release, if the callback exists.
1288
1289
 GLOBAL VARIABLES
1290
 COMMENTS, BUGS, ASSUMPTIONS
1291
 EXAMPLES
1292
 REVISION LOG
1293
--------------------------------------------------------------------------*/
1294
herr_t
1295
H5Premove(hid_t plist_id, const char *name)
1296
0
{
1297
0
    H5P_genplist_t *plist;     /* Property list to modify */
1298
0
    herr_t          ret_value; /* return value */
1299
1300
0
    FUNC_ENTER_API(FAIL)
1301
1302
    /* Check arguments. */
1303
0
    if (NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
1304
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
1305
0
    if (!name || !*name)
1306
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name");
1307
1308
    /* Create the new property list class */
1309
0
    if ((ret_value = H5P_remove(plist, name)) < 0)
1310
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property");
1311
1312
0
done:
1313
0
    FUNC_LEAVE_API(ret_value)
1314
0
} /* H5Premove() */
1315
1316
/*--------------------------------------------------------------------------
1317
 NAME
1318
    H5Pcopy_prop
1319
 PURPOSE
1320
    Routine to copy a property from one list or class to another
1321
 USAGE
1322
    herr_t H5Pcopy_prop(dst_id, src_id, name)
1323
        hid_t dst_id;               IN: ID of destination property list or class
1324
        hid_t src_id;               IN: ID of source property list or class
1325
        const char *name;           IN: Name of property to copy
1326
 RETURNS
1327
    Success: non-negative value.
1328
    Failure: negative value.
1329
 DESCRIPTION
1330
    Copies a property from one property list or class to another.
1331
1332
    If a property is copied from one class to another, all the property
1333
    information will be first deleted from the destination class and then the
1334
    property information will be copied from the source class into the
1335
    destination class.
1336
1337
    If a property is copied from one list to another list that already contains the property,
1338
    the property will be first deleted from the destination list (generating a call to the 'del'
1339
    callback for the property, if one exists) and then the property is copied
1340
    from the source list to the destination list (generating a call to the
1341
    'copy' callback for the property, if one exists).
1342
1343
    If the property does not exist in the destination class or list, this call
1344
    is equivalent to calling H5Pregister2 or H5Pinsert2 (for a class or list, as
1345
    appropriate) and the 'create' callback will be called in the case of the
1346
    property being copied into a list (if such a callback exists for the
1347
    property).
1348
1349
 GLOBAL VARIABLES
1350
 COMMENTS, BUGS, ASSUMPTIONS
1351
 EXAMPLES
1352
 REVISION LOG
1353
--------------------------------------------------------------------------*/
1354
herr_t
1355
H5Pcopy_prop(hid_t dst_id, hid_t src_id, const char *name)
1356
0
{
1357
0
    H5I_type_t src_id_type, dst_id_type; /* ID types */
1358
0
    herr_t     ret_value = SUCCEED;      /* return value */
1359
1360
0
    FUNC_ENTER_API(FAIL)
1361
1362
    /* Check arguments. */
1363
0
    if ((src_id_type = H5I_get_type(src_id)) < 0)
1364
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid source ID");
1365
0
    if ((dst_id_type = H5I_get_type(dst_id)) < 0)
1366
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid destination ID");
1367
0
    if ((H5I_GENPROP_LST != src_id_type && H5I_GENPROP_CLS != src_id_type) ||
1368
0
        (H5I_GENPROP_LST != dst_id_type && H5I_GENPROP_CLS != dst_id_type))
1369
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property objects");
1370
0
    if (src_id_type != dst_id_type)
1371
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not the same kind of property objects");
1372
0
    if (!name || !*name)
1373
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given");
1374
1375
    /* Compare property lists */
1376
0
    if (H5I_GENPROP_LST == src_id_type) {
1377
0
        if (H5P__copy_prop_plist(dst_id, src_id, name) < 0)
1378
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property between lists");
1379
0
    } /* end if */
1380
    /* Must be property classes */
1381
0
    else {
1382
0
        if (H5P__copy_prop_pclass(dst_id, src_id, name) < 0)
1383
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy property between classes");
1384
0
    } /* end else */
1385
1386
0
done:
1387
0
    FUNC_LEAVE_API(ret_value)
1388
0
} /* H5Pcopy_prop() */
1389
1390
/*--------------------------------------------------------------------------
1391
 NAME
1392
    H5Punregister
1393
 PURPOSE
1394
    Routine to remove a property from a property list class.
1395
 USAGE
1396
    herr_t H5Punregister(pclass_id, name)
1397
        hid_t pclass_id;         IN: Property list class to modify
1398
        const char *name;       IN: Name of property to remove
1399
 RETURNS
1400
    Returns non-negative on success, negative on failure.
1401
 DESCRIPTION
1402
        Removes a property from a property list class.  Future property lists
1403
    created of that class will not contain this property. Existing property lists
1404
    which still use the default value for this property will have this property removed.
1405
    Existing property lists which have modified this property will not be affected.
1406
1407
1408
 GLOBAL VARIABLES
1409
 COMMENTS, BUGS, ASSUMPTIONS
1410
 EXAMPLES
1411
 REVISION LOG
1412
--------------------------------------------------------------------------*/
1413
herr_t
1414
H5Punregister(hid_t pclass_id, const char *name)
1415
0
{
1416
0
    H5P_genclass_t *pclass;    /* Property list class to modify */
1417
0
    herr_t          ret_value; /* return value */
1418
1419
0
    FUNC_ENTER_API(FAIL)
1420
1421
    /* Check arguments. */
1422
0
    if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS)))
1423
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class");
1424
0
    if (!name || !*name)
1425
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name");
1426
1427
    /* Remove the property from property list class */
1428
0
    if ((ret_value = H5P__unregister(pclass, name)) < 0)
1429
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to remove property from class");
1430
1431
0
done:
1432
0
    FUNC_LEAVE_API(ret_value)
1433
0
} /* H5Punregister() */
1434
1435
/*--------------------------------------------------------------------------
1436
 NAME
1437
    H5Pclose
1438
 PURPOSE
1439
    Routine to close a property list.
1440
 USAGE
1441
    herr_t H5Pclose(plist_id)
1442
        hid_t plist_id;       IN: Property list to close
1443
 RETURNS
1444
    Returns non-negative on success, negative on failure.
1445
 DESCRIPTION
1446
        Closes a property list.  If a 'close' callback exists for the property
1447
    list class, it is called before the property list is destroyed.  If 'close'
1448
    callbacks exist for any individual properties in the property list, they are
1449
    called after the class 'close' callback.
1450
1451
 GLOBAL VARIABLES
1452
 COMMENTS, BUGS, ASSUMPTIONS
1453
 EXAMPLES
1454
 REVISION LOG
1455
--------------------------------------------------------------------------*/
1456
herr_t
1457
H5Pclose(hid_t plist_id)
1458
0
{
1459
0
    herr_t ret_value = SUCCEED; /* return value */
1460
1461
0
    FUNC_ENTER_API(FAIL)
1462
1463
    /* Allow default property lists to pass through without throwing an error */
1464
0
    if (H5P_DEFAULT != plist_id) {
1465
        /* Check arguments. */
1466
0
        if (H5I_GENPROP_LST != H5I_get_type(plist_id))
1467
0
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
1468
1469
        /* Close the property list */
1470
0
        if (H5I_dec_app_ref(plist_id) < 0)
1471
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close");
1472
0
    } /* end if */
1473
1474
0
done:
1475
0
    FUNC_LEAVE_API(ret_value)
1476
0
} /* H5Pclose() */
1477
1478
/*--------------------------------------------------------------------------
1479
 NAME
1480
    H5Pget_class_name
1481
 PURPOSE
1482
    Routine to query the name of a generic property list class
1483
 USAGE
1484
    char *H5Pget_class_name(pclass_id)
1485
        hid_t pclass_id;         IN: Property class to query
1486
 RETURNS
1487
    Success: Pointer to a malloc'ed string containing the class name
1488
    Failure: NULL
1489
 DESCRIPTION
1490
        This routine retrieves the name of a generic property list class.
1491
    The pointer to the name must be free'd by the user for successful calls.
1492
1493
 GLOBAL VARIABLES
1494
 COMMENTS, BUGS, ASSUMPTIONS
1495
 EXAMPLES
1496
 REVISION LOG
1497
--------------------------------------------------------------------------*/
1498
H5_ATTR_MALLOC char *
1499
H5Pget_class_name(hid_t pclass_id)
1500
0
{
1501
0
    H5P_genclass_t *pclass;    /* Property class to query */
1502
0
    char           *ret_value; /* return value */
1503
1504
0
    FUNC_ENTER_API(NULL)
1505
1506
    /* Check arguments. */
1507
0
    if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS)))
1508
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property class");
1509
1510
    /* Get the property list class name */
1511
0
    if ((ret_value = H5P_get_class_name(pclass)) == NULL)
1512
0
        HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "unable to query name of class");
1513
1514
0
done:
1515
0
    FUNC_LEAVE_API(ret_value)
1516
0
} /* H5Pget_class_name() */
1517
1518
/*--------------------------------------------------------------------------
1519
 NAME
1520
    H5Pget_class_parent
1521
 PURPOSE
1522
    routine to query the parent class of a generic property class
1523
 USAGE
1524
    hid_t H5Pget_class_parent(pclass_id)
1525
        hid_t pclass_id;         IN: Property class to query
1526
 RETURNS
1527
    Success: ID of parent class object
1528
    Failure: H5I_INVALID_HID (negative)
1529
 DESCRIPTION
1530
    This routine retrieves an ID for the parent class of a property class.
1531
1532
 GLOBAL VARIABLES
1533
 COMMENTS, BUGS, ASSUMPTIONS
1534
 EXAMPLES
1535
 REVISION LOG
1536
--------------------------------------------------------------------------*/
1537
hid_t
1538
H5Pget_class_parent(hid_t pclass_id)
1539
0
{
1540
0
    H5P_genclass_t *pclass;                      /* Property class to query */
1541
0
    H5P_genclass_t *parent    = NULL;            /* Parent's property class */
1542
0
    hid_t           ret_value = H5I_INVALID_HID; /* return value */
1543
1544
0
    FUNC_ENTER_API(H5I_INVALID_HID)
1545
1546
    /* Check arguments. */
1547
0
    if (NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS)))
1548
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property class");
1549
1550
    /* Retrieve the property class's parent */
1551
0
    if (NULL == (parent = H5P__get_class_parent(pclass)))
1552
0
        HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, H5I_INVALID_HID, "unable to query class of property list");
1553
1554
    /* Increment the outstanding references to the class object */
1555
0
    if (H5P__access_class(parent, H5P_MOD_INC_REF) < 0)
1556
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "Can't increment class ID ref count");
1557
1558
    /* Get an ID for the class */
1559
0
    if ((ret_value = H5I_register(H5I_GENPROP_CLS, parent, true)) < 0)
1560
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register property list class");
1561
1562
0
done:
1563
0
    if (H5I_INVALID_HID == ret_value && parent)
1564
0
        H5P__close_class(parent);
1565
1566
0
    FUNC_LEAVE_API(ret_value)
1567
0
} /* H5Pget_class_parent() */
1568
1569
/*--------------------------------------------------------------------------
1570
 NAME
1571
    H5Pclose_class
1572
 PURPOSE
1573
    Close a property list class.
1574
 USAGE
1575
    herr_t H5Pclose_class(cls_id)
1576
        hid_t cls_id;       IN: Property list class ID to class
1577
1578
 RETURNS
1579
    Returns non-negative on success, negative on failure.
1580
 DESCRIPTION
1581
    Releases memory and de-attach a class from the property list class hierarchy.
1582
 GLOBAL VARIABLES
1583
 COMMENTS, BUGS, ASSUMPTIONS
1584
 EXAMPLES
1585
 REVISION LOG
1586
--------------------------------------------------------------------------*/
1587
herr_t
1588
H5Pclose_class(hid_t cls_id)
1589
0
{
1590
0
    herr_t ret_value = SUCCEED; /* Return value     */
1591
1592
0
    FUNC_ENTER_API(FAIL)
1593
1594
    /* Check arguments */
1595
0
    if (H5I_GENPROP_CLS != H5I_get_type(cls_id))
1596
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class");
1597
1598
    /* Close the property list class */
1599
0
    if (H5I_dec_app_ref(cls_id) < 0)
1600
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close");
1601
1602
0
done:
1603
    FUNC_LEAVE_API(ret_value)
1604
0
} /* H5Pclose_class() */