1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * Copyright by the Board of Trustees of the University of Illinois.         *
4  * All rights reserved.                                                      *
5  *                                                                           *
6  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
7  * terms governing use, modification, and redistribution, is contained in    *
8  * the COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*-------------------------------------------------------------------------
15  *
16  * Created:		H5Pgcpl.c
17  *			August 29 2006
18  *			Quincey Koziol <koziol@ncsa.uiuc.edu>
19  *
20  * Purpose:		Group creation property list class routines
21  *
22  *-------------------------------------------------------------------------
23  */
24 
25 /****************/
26 /* Module Setup */
27 /****************/
28 
29 #include "H5Pmodule.h"          /* This source code file is part of the H5P module */
30 
31 
32 /***********/
33 /* Headers */
34 /***********/
35 #include "H5private.h"		/* Generic Functions			*/
36 #include "H5Eprivate.h"		/* Error handling		  	*/
37 #include "H5Gprivate.h"         /* Groups                               */
38 #include "H5Iprivate.h"		/* IDs			  		*/
39 #include "H5Oprivate.h"		/* Object headers		  	*/
40 #include "H5Ppkg.h"		/* Property lists		  	*/
41 
42 
43 /****************/
44 /* Local Macros */
45 /****************/
46 
47 /* ========= Group Creation properties ============ */
48 #define H5G_CRT_GROUP_INFO_ENC    H5P__gcrt_group_info_enc
49 #define H5G_CRT_GROUP_INFO_DEC    H5P__gcrt_group_info_dec
50 #define H5G_CRT_LINK_INFO_ENC     H5P__gcrt_link_info_enc
51 #define H5G_CRT_LINK_INFO_DEC     H5P__gcrt_link_info_dec
52 
53 
54 /******************/
55 /* Local Typedefs */
56 /******************/
57 
58 
59 /********************/
60 /* Package Typedefs */
61 /********************/
62 
63 
64 /********************/
65 /* Local Prototypes */
66 /********************/
67 
68 /* Property class callbacks */
69 static herr_t H5P__gcrt_reg_prop(H5P_genclass_t *pclass);
70 
71 /* Property callbacks */
72 static herr_t H5P__gcrt_group_info_enc(const void *value, void **_pp, size_t *size);
73 static herr_t H5P__gcrt_group_info_dec(const void **_pp, void *value);
74 static herr_t H5P__gcrt_link_info_enc(const void *value, void **_pp, size_t *size);
75 static herr_t H5P__gcrt_link_info_dec(const void **_pp, void *value);
76 
77 
78 /*********************/
79 /* Package Variables */
80 /*********************/
81 
82 /* Group creation property list class library initialization object */
83 const H5P_libclass_t H5P_CLS_GCRT[1] = {{
84     "group create",		/* Class name for debugging     */
85     H5P_TYPE_GROUP_CREATE,      /* Class type                   */
86 
87     &H5P_CLS_OBJECT_CREATE_g,	/* Parent class                 */
88     &H5P_CLS_GROUP_CREATE_g,	/* Pointer to class             */
89     &H5P_CLS_GROUP_CREATE_ID_g,	/* Pointer to class ID          */
90     &H5P_LST_GROUP_CREATE_ID_g,	/* Pointer to default property list ID */
91     H5P__gcrt_reg_prop,		/* Default property registration routine */
92 
93     NULL,		        /* Class creation callback      */
94     NULL,		        /* Class creation callback info */
95     NULL,			/* Class copy callback          */
96     NULL,		        /* Class copy callback info     */
97     NULL,			/* Class close callback         */
98     NULL 		        /* Class close callback info    */
99 }};
100 
101 
102 /*****************************/
103 /* Library Private Variables */
104 /*****************************/
105 
106 
107 /*******************/
108 /* Local Variables */
109 /*******************/
110 
111 /* Property value defaults */
112 static const H5O_ginfo_t H5G_def_ginfo_g = H5G_CRT_GROUP_INFO_DEF;     /* Default group info settings */
113 static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF;      /* Default link info settings */
114 
115 
116 
117 /*-------------------------------------------------------------------------
118  * Function:    H5P__gcrt_reg_prop
119  *
120  * Purpose:     Initialize the group creation property list class
121  *
122  * Return:      Non-negative on success/Negative on failure
123  *
124  * Programmer:  Quincey Koziol
125  *              October 31, 2006
126  *-------------------------------------------------------------------------
127  */
128 static herr_t
H5P__gcrt_reg_prop(H5P_genclass_t * pclass)129 H5P__gcrt_reg_prop(H5P_genclass_t *pclass)
130 {
131     herr_t ret_value = SUCCEED;         /* Return value */
132 
133     FUNC_ENTER_STATIC
134 
135     /* Register group info property */
136     if(H5P_register_real(pclass, H5G_CRT_GROUP_INFO_NAME, H5G_CRT_GROUP_INFO_SIZE, &H5G_def_ginfo_g,
137             NULL, NULL, NULL, H5G_CRT_GROUP_INFO_ENC, H5G_CRT_GROUP_INFO_DEC,
138             NULL, NULL, NULL, NULL) < 0)
139         HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
140 
141     /* Register link info property */
142     if(H5P_register_real(pclass, H5G_CRT_LINK_INFO_NAME, H5G_CRT_LINK_INFO_SIZE, &H5G_def_linfo_g,
143             NULL, NULL, NULL, H5G_CRT_LINK_INFO_ENC, H5G_CRT_LINK_INFO_DEC,
144             NULL, NULL, NULL, NULL) < 0)
145         HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
146 
147 done:
148     FUNC_LEAVE_NOAPI(ret_value)
149 } /* end H5P__gcrt_reg_prop() */
150 
151 
152 /*-------------------------------------------------------------------------
153  * Function:    H5Pset_local_heap_size_hint
154  *
155  * Purpose:     Set the "size hint" for creating local heaps for a group.
156  *
157  * Return:      Non-negative on success/Negative on failure
158  *
159  * Programmer:  Quincey Koziol
160  *              August 29, 2005
161  *-------------------------------------------------------------------------
162  */
163 herr_t
H5Pset_local_heap_size_hint(hid_t plist_id,size_t size_hint)164 H5Pset_local_heap_size_hint(hid_t plist_id, size_t size_hint)
165 {
166     H5P_genplist_t *plist;      /* Property list pointer */
167     H5O_ginfo_t ginfo;          /* Group information structure */
168     herr_t ret_value = SUCCEED;       /* Return value */
169 
170     FUNC_ENTER_API(FAIL)
171     H5TRACE2("e", "iz", plist_id, size_hint);
172 
173     /* Get the plist structure */
174     if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
175         HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
176 
177     /* Get value */
178     if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
179         HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
180 
181     /* Update field */
182     H5_CHECKED_ASSIGN(ginfo.lheap_size_hint, uint32_t, size_hint, size_t);
183 
184     /* Set value */
185     if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
186         HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
187 
188 done:
189     FUNC_LEAVE_API(ret_value)
190 } /* end H5Pset_local_heap_size_hint() */
191 
192 
193 /*-------------------------------------------------------------------------
194  * Function:    H5Pget_local_heap_size_hint
195  *
196  * Purpose:     Returns the local heap size hint, which is used for creating
197  *              groups
198  *
199  * Return:      Non-negative on success/Negative on failure
200  *
201  * Programmer:  Quincey Koziol
202  *              August 29, 2005
203  *-------------------------------------------------------------------------
204  */
205 herr_t
H5Pget_local_heap_size_hint(hid_t plist_id,size_t * size_hint)206 H5Pget_local_heap_size_hint(hid_t plist_id, size_t *size_hint /*out*/)
207 {
208     herr_t ret_value = SUCCEED;   /* return value */
209 
210     FUNC_ENTER_API(FAIL)
211     H5TRACE2("e", "ix", plist_id, size_hint);
212 
213     if(size_hint) {
214         H5P_genplist_t *plist;      /* Property list pointer */
215         H5O_ginfo_t ginfo;          /* Group information structure */
216 
217         /* Get the plist structure */
218         if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
219             HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
220 
221         /* Get value */
222         if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
223             HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
224 
225         /* Update field */
226         *size_hint = ginfo.lheap_size_hint;
227     } /* end if */
228 
229 done:
230     FUNC_LEAVE_API(ret_value)
231 } /* end H5Pget_local_heap_size_hint() */
232 
233 
234 /*-------------------------------------------------------------------------
235  * Function:    H5Pset_link_phase_change
236  *
237  * Purpose:     Set the maximum # of links to store "compactly" and the
238  *              minimum # of links to store "densely".  (These should
239  *              overlap).
240  *
241  * Note:        Currently both of these must be updated at the same time.
242  *
243  * Note:        Come up with better name & description! -QAK
244  *
245  * Return:      Non-negative on success/Negative on failure
246  *
247  * Programmer:  Quincey Koziol
248  *              August 29, 2005
249  *-------------------------------------------------------------------------
250  */
251 herr_t
H5Pset_link_phase_change(hid_t plist_id,unsigned max_compact,unsigned min_dense)252 H5Pset_link_phase_change(hid_t plist_id, unsigned max_compact, unsigned min_dense)
253 {
254     H5P_genplist_t *plist;              /* Property list pointer */
255     H5O_ginfo_t ginfo;                  /* Group information structure */
256     herr_t ret_value = SUCCEED;         /* Return value */
257 
258     FUNC_ENTER_API(FAIL)
259     H5TRACE3("e", "iIuIu", plist_id, max_compact, min_dense);
260 
261     /* Range check values */
262     if(max_compact < min_dense)
263         HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be >= min dense value")
264     if(max_compact > 65535)
265         HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max compact value must be < 65536")
266     if(min_dense > 65535)
267         HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min dense value must be < 65536")
268 
269     /* Get the plist structure */
270     if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
271         HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
272 
273     /* Get group info */
274     if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
275         HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
276 
277     /* Update fields */
278     if(max_compact != H5G_CRT_GINFO_MAX_COMPACT || min_dense != H5G_CRT_GINFO_MIN_DENSE)
279         ginfo.store_link_phase_change = TRUE;
280     else
281         ginfo.store_link_phase_change = FALSE;
282     ginfo.max_compact = (uint16_t)max_compact;
283     ginfo.min_dense = (uint16_t)min_dense;
284 
285     /* Set group info */
286     if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
287         HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
288 
289 done:
290     FUNC_LEAVE_API(ret_value)
291 } /* end H5Pset_link_phase_change() */
292 
293 
294 /*-------------------------------------------------------------------------
295  * Function:    H5Pget_link_phase_change
296  *
297  * Purpose:     Returns the max. # of compact links & the min. # of dense
298  *              links, which are used for storing groups
299  *
300  * Return:      Non-negative on success/Negative on failure
301  *
302  * Programmer:  Quincey Koziol
303  *              August 29, 2005
304  *-------------------------------------------------------------------------
305  */
306 herr_t
H5Pget_link_phase_change(hid_t plist_id,unsigned * max_compact,unsigned * min_dense)307 H5Pget_link_phase_change(hid_t plist_id, unsigned *max_compact /*out*/, unsigned *min_dense /*out*/)
308 {
309     herr_t ret_value = SUCCEED;   /* return value */
310 
311     FUNC_ENTER_API(FAIL)
312     H5TRACE3("e", "ixx", plist_id, max_compact, min_dense);
313 
314     /* Get values */
315     if(max_compact || min_dense) {
316         H5P_genplist_t *plist;      /* Property list pointer */
317         H5O_ginfo_t ginfo;          /* Group information structure */
318 
319         /* Get the plist structure */
320         if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
321             HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
322 
323         /* Get group info */
324         if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
325             HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
326 
327         if(max_compact)
328             *max_compact = ginfo.max_compact;
329         if(min_dense)
330             *min_dense = ginfo.min_dense;
331     } /* end if */
332 
333 done:
334     FUNC_LEAVE_API(ret_value)
335 } /* end H5Pget_link_phase_change() */
336 
337 
338 /*-------------------------------------------------------------------------
339  * Function:    H5Pset_est_link_info
340  *
341  * Purpose:     Set the estimates for the number of entries and length of each
342  *              entry name in a group.
343  *
344  * Note:        Currently both of these must be updated at the same time.
345  *
346  * Note:        EST_NUM_ENTRIES applies only when the number of entries is less
347  *              than the MAX_COMPACT # of entries (from H5Pset_link_phase_change).
348  *
349  * Note:        Come up with better name & description? -QAK
350  *
351  * Return:      Non-negative on success/Negative on failure
352  *
353  * Programmer:  Quincey Koziol
354  *              September  6, 2005
355  *-------------------------------------------------------------------------
356  */
357 herr_t
H5Pset_est_link_info(hid_t plist_id,unsigned est_num_entries,unsigned est_name_len)358 H5Pset_est_link_info(hid_t plist_id, unsigned est_num_entries, unsigned est_name_len)
359 {
360     H5P_genplist_t *plist;              /* Property list pointer */
361     H5O_ginfo_t ginfo;                  /* Group information structure */
362     herr_t ret_value = SUCCEED;         /* Return value */
363 
364     FUNC_ENTER_API(FAIL)
365     H5TRACE3("e", "iIuIu", plist_id, est_num_entries, est_name_len);
366 
367     /* Range check values */
368     if(est_num_entries > 65535)
369         HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "est. number of entries must be < 65536")
370     if(est_name_len > 65535)
371         HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "est. name length must be < 65536")
372 
373     /* Get the plist structure */
374     if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
375         HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
376 
377     /* Get group info */
378     if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
379         HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
380 
381     /* Update fields */
382     if(est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES || est_name_len != H5G_CRT_GINFO_EST_NAME_LEN)
383         ginfo.store_est_entry_info = TRUE;
384     else
385         ginfo.store_est_entry_info = FALSE;
386     ginfo.est_num_entries = (uint16_t)est_num_entries;
387     ginfo.est_name_len = (uint16_t)est_name_len;
388 
389     /* Set group info */
390     if(H5P_set(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
391         HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info")
392 
393 done:
394     FUNC_LEAVE_API(ret_value)
395 } /* end H5Pset_est_link_info() */
396 
397 
398 /*-------------------------------------------------------------------------
399  * Function:    H5Pget_est_link_info
400  *
401  * Purpose:     Returns the est. # of links in a group & the est. length of
402  *              the name of each link.
403  *
404  * Return:      Non-negative on success/Negative on failure
405  *
406  * Programmer:  Quincey Koziol
407  *              September  6, 2005
408  *-------------------------------------------------------------------------
409  */
410 herr_t
H5Pget_est_link_info(hid_t plist_id,unsigned * est_num_entries,unsigned * est_name_len)411 H5Pget_est_link_info(hid_t plist_id, unsigned *est_num_entries /*out*/, unsigned *est_name_len /*out*/)
412 {
413     herr_t ret_value = SUCCEED;   /* return value */
414 
415     FUNC_ENTER_API(FAIL)
416     H5TRACE3("e", "ixx", plist_id, est_num_entries, est_name_len);
417 
418     /* Get values */
419     if(est_num_entries || est_name_len) {
420         H5P_genplist_t *plist;      /* Property list pointer */
421         H5O_ginfo_t ginfo;          /* Group information structure */
422 
423         /* Get the plist structure */
424         if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
425             HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
426 
427         /* Get group info */
428         if(H5P_get(plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0)
429             HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get group info")
430 
431         if(est_num_entries)
432             *est_num_entries = ginfo.est_num_entries;
433         if(est_name_len)
434             *est_name_len = ginfo.est_name_len;
435     } /* end if */
436 
437 done:
438     FUNC_LEAVE_API(ret_value)
439 } /* end H5Pget_est_link_info() */
440 
441 
442 /*-------------------------------------------------------------------------
443  * Function:    H5Pset_link_creation_order
444  *
445  * Purpose:     Set the flags for creation order of links in a group
446  *
447  * Return:      Non-negative on success/Negative on failure
448  *
449  * Programmer:  Quincey Koziol
450  *              September 12, 2006
451  *-------------------------------------------------------------------------
452  */
453 herr_t
H5Pset_link_creation_order(hid_t plist_id,unsigned crt_order_flags)454 H5Pset_link_creation_order(hid_t plist_id, unsigned crt_order_flags)
455 {
456     H5P_genplist_t *plist;              /* Property list pointer */
457     H5O_linfo_t linfo;                  /* Link information structure */
458     herr_t ret_value = SUCCEED;         /* Return value */
459 
460     FUNC_ENTER_API(FAIL)
461     H5TRACE2("e", "iIu", plist_id, crt_order_flags);
462 
463         /* Check for bad combination of flags */
464     if(!(crt_order_flags & H5P_CRT_ORDER_TRACKED) && (crt_order_flags & H5P_CRT_ORDER_INDEXED))
465         HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "tracking creation order is required for index")
466 
467     /* Get the plist structure */
468     if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
469         HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
470 
471     /* Get link info */
472     if(H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
473         HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info")
474 
475     /* Update fields */
476     linfo.track_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? TRUE : FALSE);
477     linfo.index_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? TRUE : FALSE);
478 
479     /* Set link info */
480     if(H5P_set(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
481         HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info")
482 
483 done:
484     FUNC_LEAVE_API(ret_value)
485 } /* end H5Pset_link_creation_order() */
486 
487 
488 /*-------------------------------------------------------------------------
489  * Function:    H5Pget_link_creation_order
490  *
491  * Purpose:     Returns the flag indicating that creation order is tracked
492  *              for links in a group.
493  *
494  * Return:      Non-negative on success/Negative on failure
495  *
496  * Programmer:  Quincey Koziol
497  *              September 12, 2006
498  *-------------------------------------------------------------------------
499  */
500 herr_t
H5Pget_link_creation_order(hid_t plist_id,unsigned * crt_order_flags)501 H5Pget_link_creation_order(hid_t plist_id, unsigned *crt_order_flags /*out*/)
502 {
503     herr_t ret_value = SUCCEED;   /* return value */
504 
505     FUNC_ENTER_API(FAIL)
506     H5TRACE2("e", "ix", plist_id, crt_order_flags);
507 
508     /* Get values */
509     if(crt_order_flags) {
510         H5P_genplist_t *plist;      /* Property list pointer */
511         H5O_linfo_t linfo;          /* Link information structure */
512 
513         /* Reset the value to return */
514         *crt_order_flags = 0;
515 
516         /* Get the plist structure */
517         if(NULL == (plist = H5P_object_verify(plist_id, H5P_GROUP_CREATE)))
518             HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
519 
520         /* Get link info */
521         if(H5P_get(plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0)
522             HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get link info")
523 
524         *crt_order_flags |= linfo.track_corder ? H5P_CRT_ORDER_TRACKED : 0;
525         *crt_order_flags |= linfo.index_corder ? H5P_CRT_ORDER_INDEXED : 0;
526     } /* end if */
527 
528 done:
529     FUNC_LEAVE_API(ret_value)
530 } /* end H5Pget_link_creation_order() */
531 
532 
533 /*-------------------------------------------------------------------------
534  * Function:       H5P__gcrt_group_info_enc
535  *
536  * Purpose:        Callback routine which is called whenever the group
537  *                 property in the dataset access property list is
538  *                 encoded.
539  *
540  * Return:	   Success:	Non-negative
541  *		   Failure:	Negative
542  *
543  * Programmer:     Mohamad Chaarawi
544  *                 Monday, October 10, 2011
545  *
546  *-------------------------------------------------------------------------
547  */
548 static herr_t
H5P__gcrt_group_info_enc(const void * value,void ** _pp,size_t * size)549 H5P__gcrt_group_info_enc(const void *value, void **_pp, size_t *size)
550 {
551     const H5O_ginfo_t *ginfo = (const H5O_ginfo_t *)value; /* Create local aliases for values */
552     uint8_t **pp = (uint8_t **)_pp;
553 
554     FUNC_ENTER_STATIC_NOERR
555 
556     if(NULL != *pp) {
557         UINT32ENCODE(*pp, ginfo->lheap_size_hint)
558         UINT16ENCODE(*pp, ginfo->max_compact)
559         UINT16ENCODE(*pp, ginfo->min_dense)
560         UINT16ENCODE(*pp, ginfo->est_num_entries)
561         UINT16ENCODE(*pp, ginfo->est_name_len)
562     } /* end if */
563 
564     *size += sizeof(uint16_t) * 4 + sizeof(uint32_t);
565 
566     FUNC_LEAVE_NOAPI(SUCCEED)
567 } /* end H5P__gcrt_group_info_enc() */
568 
569 
570 /*-------------------------------------------------------------------------
571  * Function:       H5P__gcrt_group_info_dec
572  *
573  * Purpose:        Callback routine which is called whenever the group info
574  *                 property in the dataset access property list is
575  *                 decoded.
576  *
577  * Return:	   Success:	Non-negative
578  *		   Failure:	Negative
579  *
580  * Programmer:     Mohamad Chaarawi
581  *                 Monday, October 10, 2011
582  *
583  *-------------------------------------------------------------------------
584  */
585 static herr_t
H5P__gcrt_group_info_dec(const void ** _pp,void * _value)586 H5P__gcrt_group_info_dec(const void **_pp, void *_value)
587 {
588     H5O_ginfo_t *ginfo = (H5O_ginfo_t *)_value;     /* Group info settings */
589     const uint8_t **pp = (const uint8_t **)_pp;
590     herr_t ret_value = SUCCEED;         /* Return value */
591 
592     FUNC_ENTER_STATIC_NOERR
593 
594     /* Set property to default value */
595     HDmemset(ginfo, 0, sizeof(H5O_ginfo_t));
596     *ginfo = H5G_def_ginfo_g;
597 
598     UINT32DECODE(*pp, ginfo->lheap_size_hint)
599     UINT16DECODE(*pp, ginfo->max_compact)
600     UINT16DECODE(*pp, ginfo->min_dense)
601     UINT16DECODE(*pp, ginfo->est_num_entries)
602     UINT16DECODE(*pp, ginfo->est_name_len)
603 
604     /* Update fields */
605     if(ginfo->max_compact != H5G_CRT_GINFO_MAX_COMPACT ||
606             ginfo->min_dense != H5G_CRT_GINFO_MIN_DENSE)
607         ginfo->store_link_phase_change = TRUE;
608     else
609         ginfo->store_link_phase_change = FALSE;
610 
611     if(ginfo->est_num_entries != H5G_CRT_GINFO_EST_NUM_ENTRIES ||
612             ginfo->est_name_len != H5G_CRT_GINFO_EST_NAME_LEN)
613         ginfo->store_est_entry_info = TRUE;
614     else
615         ginfo->store_est_entry_info = FALSE;
616 
617     FUNC_LEAVE_NOAPI(ret_value)
618 } /* end H5P__gcrt_group_info_dec() */
619 
620 
621 /*-------------------------------------------------------------------------
622  * Function:       H5P__gcrt_link_info_enc
623  *
624  * Purpose:        Callback routine which is called whenever the link
625  *                 property in the dataset access property list is
626  *                 encoded.
627  *
628  * Return:	   Success:	Non-negative
629  *		   Failure:	Negative
630  *
631  * Programmer:     Mohamad Chaarawi
632  *                 Monday, October 10, 2011
633  *
634  *-------------------------------------------------------------------------
635  */
636 static herr_t
H5P__gcrt_link_info_enc(const void * value,void ** _pp,size_t * size)637 H5P__gcrt_link_info_enc(const void *value, void **_pp, size_t *size)
638 {
639     const H5O_linfo_t *linfo = (const H5O_linfo_t *)value; /* Create local aliases for values */
640     uint8_t **pp = (uint8_t **)_pp;
641 
642     FUNC_ENTER_STATIC_NOERR
643 
644     if(NULL != *pp) {
645         unsigned crt_order_flags = 0;
646 
647         crt_order_flags |= linfo->track_corder ? H5P_CRT_ORDER_TRACKED : 0;
648         crt_order_flags |= linfo->index_corder ? H5P_CRT_ORDER_INDEXED : 0;
649 
650         /* Encode the size of unsigned*/
651         *(*pp)++ = (uint8_t)sizeof(unsigned);
652 
653         /* Encode the value */
654         H5_ENCODE_UNSIGNED(*pp, crt_order_flags)
655     } /* end if */
656 
657     *size += (1 + sizeof(unsigned));
658 
659     FUNC_LEAVE_NOAPI(SUCCEED)
660 } /* end H5P__gcrt_link_info_enc() */
661 
662 
663 /*-------------------------------------------------------------------------
664  * Function:       H5P__gcrt_link_info_dec
665  *
666  * Purpose:        Callback routine which is called whenever the link info
667  *                 property in the dataset access property list is
668  *                 decoded.
669  *
670  * Return:	   Success:	Non-negative
671  *		   Failure:	Negative
672  *
673  * Programmer:     Mohamad Chaarawi
674  *                 Monday, October 10, 2011
675  *
676  *-------------------------------------------------------------------------
677  */
678 static herr_t
H5P__gcrt_link_info_dec(const void ** _pp,void * _value)679 H5P__gcrt_link_info_dec(const void **_pp, void *_value)
680 {
681     H5O_linfo_t *linfo = (H5O_linfo_t *)_value;  /* Link info settings */
682     const uint8_t **pp = (const uint8_t **)_pp;
683     unsigned crt_order_flags;
684     unsigned enc_size;
685     herr_t ret_value = SUCCEED;                 /* Return value */
686 
687     FUNC_ENTER_STATIC
688 
689     enc_size = *(*pp)++;
690     if(enc_size != sizeof(unsigned))
691         HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded")
692 
693     /* Set property to default value */
694     HDmemset(linfo, 0, sizeof(H5O_linfo_t));
695     *linfo = H5G_def_linfo_g;
696 
697     H5_DECODE_UNSIGNED(*pp, crt_order_flags)
698 
699     /* Update fields */
700     linfo->track_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? TRUE : FALSE);
701     linfo->index_corder = (hbool_t)((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? TRUE : FALSE);
702 
703 done:
704     FUNC_LEAVE_NOAPI(ret_value)
705 } /* end H5P__gcrt_link_info_dec() */
706 
707