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 * For details of the HDF libraries, see the HDF Documentation at:
16 * http://hdfgroup.org/HDF5/doc/
17 *
18 */
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
23
24 /*
25 * This code is the C-interface called by Java programs to access the
26 * general library functions of the HDF5 library.
27 *
28 * Each routine wraps a single HDF entry point, generally with the
29 * analogous arguments and return codes.
30 *
31 */
32
33 #include "hdf5.h"
34 #include <jni.h>
35 #include "h5jni.h"
36 #include "h5Imp.h"
37
38 /*
39 * Pointer to the JNI's Virtual Machine; used for callback functions.
40 */
41 /* extern JavaVM *jvm; */
42
43 /*
44 * Class: hdf_hdf5lib_H5
45 * Method: H5open
46 * Signature: ()I
47 */
48 JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5open(JNIEnv * env,jclass clss)49 Java_hdf_hdf5lib_H5_H5open
50 (JNIEnv *env, jclass clss)
51 {
52 herr_t retVal = FAIL;
53
54 UNUSED(clss);
55
56 if ((retVal = H5open()) < 0)
57 H5_LIBRARY_ERROR(ENVONLY);
58
59 done:
60 return (jint)retVal;
61 } /* end Java_hdf_hdf5lib_H5_H5open */
62
63 /*
64 * Class: hdf_hdf5lib_H5
65 * Method: H5close
66 * Signature: ()I
67 */
68 JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5close(JNIEnv * env,jclass clss)69 Java_hdf_hdf5lib_H5_H5close
70 (JNIEnv *env, jclass clss)
71 {
72 herr_t retVal = FAIL;
73
74 UNUSED(clss);
75
76 if ((retVal = H5close()) < 0)
77 H5_LIBRARY_ERROR(ENVONLY);
78
79 done:
80 return (jint)retVal;
81 } /* end Java_hdf_hdf5lib_H5_H5close */
82
83 /*
84 * Class: hdf_hdf5lib_H5
85 * Method: H5dont_atexit
86 * Signature: ()I
87 */
88 JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5dont_1atexit(JNIEnv * env,jclass clss)89 Java_hdf_hdf5lib_H5_H5dont_1atexit
90 (JNIEnv *env, jclass clss)
91 {
92 herr_t retVal = FAIL;
93
94 UNUSED(clss);
95
96 if ((retVal = H5dont_atexit()) < 0)
97 H5_LIBRARY_ERROR(ENVONLY);
98
99 done:
100 return (jint)retVal;
101 } /* end Java_hdf_hdf5lib_H5_H5dont_1atexit */
102
103 /*
104 * Class: hdf_hdf5lib_H5
105 * Method: H5get_libversion
106 * Signature: ([I)I
107 */
108 JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5get_1libversion(JNIEnv * env,jclass clss,jintArray libversion)109 Java_hdf_hdf5lib_H5_H5get_1libversion
110 (JNIEnv *env, jclass clss, jintArray libversion)
111 {
112 jboolean libversionArrayIsCopy;
113 int *libversionArray = NULL;
114 herr_t status = FAIL;
115
116 UNUSED(clss);
117
118 if (libversion == NULL)
119 H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5get_libversion: libversion is NULL");
120
121 PIN_INT_ARRAY(ENVONLY, libversion, libversionArray, &libversionArrayIsCopy, "H5get_libversion: libversion input not pinned");
122
123 if ((status = H5get_libversion((unsigned *) &(libversionArray[0]), (unsigned *) &(libversionArray[1]), (unsigned *) &(libversionArray[2]))) < 0)
124 H5_LIBRARY_ERROR(ENVONLY);
125
126 done:
127 if (libversionArray)
128 UNPIN_INT_ARRAY(ENVONLY, libversion, libversionArray, (status < 0) ? JNI_ABORT : 0);
129
130 return (jint)status;
131 } /* end Java_hdf_hdf5lib_H5_H5get_1libversion */
132
133 /*
134 * Class: hdf_hdf5lib_H5
135 * Method: H5check_version
136 * Signature: (III)I
137 */
138 JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5check_1version(JNIEnv * env,jclass clss,jint majnum,jint minnum,jint relnum)139 Java_hdf_hdf5lib_H5_H5check_1version
140 (JNIEnv *env, jclass clss, jint majnum, jint minnum, jint relnum)
141 {
142 UNUSED(env);
143 UNUSED(clss);
144
145 return (jint)H5check_version((unsigned)majnum, (unsigned)minnum, (unsigned)relnum);
146 } /* end Java_hdf_hdf5lib_H5_H5check_1version */
147
148 /*
149 * Class: hdf_hdf5lib_H5
150 * Method: H5garbage_collect
151 * Signature: ()I
152 *
153 */
154 JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5garbage_1collect(JNIEnv * env,jclass clss)155 Java_hdf_hdf5lib_H5_H5garbage_1collect
156 (JNIEnv *env, jclass clss)
157 {
158 herr_t retVal = FAIL;
159
160 UNUSED(clss);
161
162 if ((retVal = H5garbage_collect()) < 0)
163 H5_LIBRARY_ERROR(ENVONLY);
164
165 done:
166 return (jint)retVal;
167 } /* end Java_hdf_hdf5lib_H5_H5garbage_1collect */
168
169 /*
170 * Class: hdf_hdf5lib_H5
171 * Method: H5set_free_list_limits
172 * Signature: (IIIIII)I
173 */
174 JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits(JNIEnv * env,jclass clss,jint reg_global_lim,jint reg_list_lim,jint arr_global_lim,jint arr_list_lim,jint blk_global_lim,jint blk_list_lim)175 Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits
176 (JNIEnv *env, jclass clss, jint reg_global_lim, jint reg_list_lim,
177 jint arr_global_lim, jint arr_list_lim, jint blk_global_lim, jint blk_list_lim )
178 {
179 herr_t retVal = FAIL;
180
181 UNUSED(clss);
182
183 if ((retVal = H5set_free_list_limits((int)reg_global_lim, (int)reg_list_lim,
184 (int)arr_global_lim, (int)arr_list_lim, (int)blk_global_lim, (int)blk_list_lim)) < 0)
185 H5_LIBRARY_ERROR(ENVONLY);
186
187 done:
188 return (jint)retVal;
189 } /* end Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits */
190
191 /*
192 * Class: hdf_hdf5lib_H5
193 * Method: H5is_library_threadsafe
194 * Signature: ()Z
195 */
196 JNIEXPORT jboolean JNICALL
Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe(JNIEnv * env,jclass clss)197 Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe
198 (JNIEnv *env, jclass clss)
199 {
200 hbool_t is_ts = false;
201
202 UNUSED(clss);
203
204 if (H5is_library_threadsafe(&is_ts) < 0)
205 H5_LIBRARY_ERROR(ENVONLY);
206
207 done:
208 return (jboolean)is_ts;
209 } /* end Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe */
210
211
212 #ifdef __cplusplus
213 } /* end extern "C" */
214 #endif /* __cplusplus */
215