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 /* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
15 * Saturday May 31, 2003
16 *
17 * Purpose: Generic Property Testing Functions
18 */
19
20 #define H5P_PACKAGE /*suppress error about including H5Ppkg */
21 #define H5P_TESTING /*suppress warning about H5P testing funcs*/
22
23
24 /* Private header files */
25 #include "H5private.h" /* Generic Functions */
26 #include "H5Eprivate.h" /* Error handling */
27 #include "H5Iprivate.h" /* IDs */
28 #include "H5Ppkg.h" /* Property lists */
29 #include "H5Dprivate.h" /* Dataset */
30
31 /* Local variables */
32
33 /* Local typedefs */
34
35
36 /*--------------------------------------------------------------------------
37 NAME
38 H5P_get_class_path_test
39 PURPOSE
40 Routine to query the full path of a generic property list class
41 USAGE
42 char *H5P_get_class_name_test(pclass_id)
43 hid_t pclass_id; IN: Property class to query
44 RETURNS
45 Success: Pointer to a malloc'ed string containing the full path of class
46 Failure: NULL
47 DESCRIPTION
48 This routine retrieves the full path name of a generic property list
49 class, starting with the root of the class hierarchy.
50 The pointer to the name must be free'd by the user for successful calls.
51
52 GLOBAL VARIABLES
53 COMMENTS, BUGS, ASSUMPTIONS
54 DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING H5P_get_class_path()
55 EXAMPLES
56 REVISION LOG
57 --------------------------------------------------------------------------*/
58 char *
H5P_get_class_path_test(hid_t pclass_id)59 H5P_get_class_path_test(hid_t pclass_id)
60 {
61 H5P_genclass_t *pclass; /* Property class to query */
62 char *ret_value; /* return value */
63
64 FUNC_ENTER_NOAPI(NULL)
65
66 /* Check arguments. */
67 if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS)))
68 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property class");
69
70 /* Get the property list class path */
71 if(NULL == (ret_value = H5P_get_class_path(pclass)))
72 HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "unable to query full path of class")
73
74 done:
75 FUNC_LEAVE_NOAPI(ret_value)
76 } /* H5P_get_class_path_test() */
77
78
79 /*--------------------------------------------------------------------------
80 NAME
81 H5P_open_class_path_test
82 PURPOSE
83 Routine to open a [copy of] a class with its full path name
84 USAGE
85 hid_t H5P_open_class_name_test(path)
86 const char *path; IN: Full path name of class to open [copy of]
87 RETURNS
88 Success: ID of generic property class
89 Failure: NULL
90 DESCRIPTION
91 This routine opens [a copy] of the class indicated by the full path.
92
93 GLOBAL VARIABLES
94 COMMENTS, BUGS, ASSUMPTIONS
95 DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING H5P_open_class_path()
96 EXAMPLES
97 REVISION LOG
98 --------------------------------------------------------------------------*/
99 hid_t
H5P_open_class_path_test(const char * path)100 H5P_open_class_path_test(const char *path)
101 {
102 H5P_genclass_t *pclass=NULL;/* Property class to query */
103 hid_t ret_value; /* Return value */
104
105 FUNC_ENTER_NOAPI(FAIL)
106
107 /* Check arguments. */
108 if (NULL == path || *path=='\0')
109 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid class path");
110
111 /* Open the property list class */
112 if ((pclass=H5P_open_class_path(path))==NULL)
113 HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "unable to find class with full path");
114
115 /* Get an atom for the class */
116 if ((ret_value=H5I_register(H5I_GENPROP_CLS, pclass, TRUE))<0)
117 HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to atomize property list class");
118
119 done:
120 if(ret_value<0 && pclass)
121 H5P_close_class(pclass);
122
123 FUNC_LEAVE_NOAPI(ret_value)
124 } /* H5P_open_class_path_test() */
125
126
127 /*--------------------------------------------------------------------------
128 NAME
129 H5P_reset_external_file_test
130 PURPOSE
131 Routine to reset external file list
132 USAGE
133 herr_t H5P_reset_external_file_test(plist)
134 hid_t dcpl_id; IN: the property list
135
136 RETURNS
137 Non-negative on success/Negative on failure
138
139 PROGRAMMER
140 Peter Cao
141 April 30, 2007
142 --------------------------------------------------------------------------*/
143 herr_t
H5P_reset_external_file_test(hid_t dcpl_id)144 H5P_reset_external_file_test(hid_t dcpl_id)
145 {
146 H5O_efl_t efl; /* External file list */
147 H5P_genplist_t *plist; /* Property list */
148 herr_t ret_value = SUCCEED; /* Return value */
149
150 FUNC_ENTER_NOAPI(FAIL)
151
152 /* Check arguments */
153 if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id)))
154 HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list")
155
156 /* get external file list */
157 if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
158 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list")
159
160 /* Clean up any values set for the external file-list */
161 if(H5O_msg_reset(H5O_EFL_ID, &efl) < 0)
162 HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release external file list info")
163
164 /* set external file list */
165 if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
166 HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list")
167
168 done:
169 FUNC_LEAVE_NOAPI(ret_value)
170 } /* H5P_reset_external_file_test() */
171
172