/* * Class: hdf_hdf5lib_H5 * Method: H5PLget * Signature: (I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5PLget (JNIEnv *env, jclass clss, jint index) { char *aName; jstring str = NULL; ssize_t buf_size; /* get the length of the name */ buf_size = H5PLget(index, NULL, 0); if (buf_size <= 0) { h5badArgument(env, "H5PLget: buf_size <= 0"); } /* end if */ else { buf_size++; /* add extra space for the null terminator */ aName = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); if (aName == NULL) { h5outOfMemory(env, "H5PLget: malloc failed"); } /* end if */ else { buf_size = H5PLget(index, aName, (size_t)buf_size); if (buf_size < 0) { h5libraryError(env); } /* end if */ else { str = ENVPTR->NewStringUTF(ENVPAR aName); } HDfree(aName); } } return str; } /* end Java_hdf_hdf5lib_H5_H5PLget */
/* * Class: hdf_hdf5lib_H5 * Method: H5Iget_name_long * Signature: (JLjava/lang/String;J)J */ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Iget_1name_1long (JNIEnv *env, jclass clss, jlong obj_id, jobjectArray name, jlong buf_size) { char *aName; jstring str; hssize_t size = -1; long bs; bs = (long)buf_size; if (bs <= 0) { h5badArgument(env, "H5Iget_name: buf_size <= 0"); } /* end if */ else { aName = (char*)HDmalloc(sizeof(char) * (size_t)bs); if (aName == NULL) { h5outOfMemory(env, "H5Iget_name: malloc failed"); } /* end if */ else { size = H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size); if (size < 0) { h5libraryError(env); } /* end if */ else { str = ENVPTR->NewStringUTF(ENVPAR aName); ENVPTR->SetObjectArrayElement(ENVPAR name, 0, str); } HDfree(aName); } } return (jlong)size; } /* end Java_hdf_hdf5lib_H5_H5Iget_1name */
/* * Class: hdf_hdf5lib_H5 * Method: H5Aget_name * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Aget_1name (JNIEnv *env, jclass clss, jlong attr_id) { char *aName; jstring str = NULL; ssize_t buf_size; /* get the length of the name */ buf_size = H5Aget_name((hid_t)attr_id, 0, NULL); if (buf_size <= 0) { h5badArgument(env, "H5Aget_name: buf_size <= 0"); } /* end if */ else { buf_size++; /* add extra space for the null terminator */ aName = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); if (aName == NULL) { h5outOfMemory(env, "H5Aget_name: malloc failed"); } /* end if */ else { buf_size = H5Aget_name((hid_t)attr_id, (size_t)buf_size, aName); if (buf_size < 0) { HDfree(aName); h5libraryError(env); } /* end if */ else { /* save the string; */ str = ENVPTR->NewStringUTF(ENVPAR aName); HDfree(aName); } /* end else */ } /* end else */ } /* end else */ return str; } /* end Java_hdf_hdf5lib_H5_H5Aget_1name */
/* * Class: hdf_hdf5lib_H5 * Method: H5Eget_msg * Signature: (J[I)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Eget_1msg (JNIEnv *env, jclass cls, jlong msg_id, jintArray error_msg_type_list) { char *namePtr; jstring str = NULL; jboolean isCopy; ssize_t buf_size; jint *theArray; H5E_type_t error_msg_type; if (msg_id < 0) { h5badArgument(env, "H5Eget_msg: invalid argument"); } /* end if */ else if (error_msg_type_list == NULL) { h5nullArgument(env, "H5Eget_msg: error_msg_type_list is NULL"); } /* end if */ else { /* get the length of the name */ buf_size = H5Eget_msg((hid_t)msg_id, NULL, NULL, 0); if ((buf_size < 0) || (buf_size == 0)) { h5JNIFatalError(env, "H5Eget_msg: Invalid message"); } /* end if */ else { buf_size++; /* add extra space for the null terminator */ namePtr = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); if (namePtr == NULL) { h5outOfMemory(env, "H5Eget_msg: malloc failed"); } /* end if */ else { theArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR error_msg_type_list, &isCopy); if (theArray == NULL) { HDfree(namePtr); h5JNIFatalError(env, "H5Eget_msg: error_msg_type_list not pinned"); } /* end if */ else { buf_size = H5Eget_msg((hid_t)msg_id, &error_msg_type, (char *)namePtr, (size_t)buf_size); if (buf_size < 0) { HDfree(namePtr); ENVPTR->ReleaseIntArrayElements(ENVPAR error_msg_type_list, theArray, JNI_ABORT); h5libraryError(env); } /* end if */ else { theArray[0] = error_msg_type; ENVPTR->ReleaseIntArrayElements(ENVPAR error_msg_type_list, theArray, 0); str = ENVPTR->NewStringUTF(ENVPAR namePtr); HDfree(namePtr); } /* end else */ } /* end else */ } /* end else */ } /* end else */ } /* end else */ return str; } /* end Java_hdf_hdf5lib_H5_H5Eget_1msg */
/* * Class: hdf_hdf5lib_H5 * Method: H5Rget_name * Signature: (JI[B[Ljava/lang/String;J)J */ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Rget_1name(JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref, jobjectArray name, jlong size) { jlong ret_val = -1; jbyte *refP; jboolean isCopy; char *aName = NULL; jstring str; size_t bs; bs = (size_t)size; if (bs <= 0) { h5badArgument(env, "H5Rget_name: size <= 0"); } /* end if */ else if (ref == NULL) { h5nullArgument(env, "H5Rget_name: ref is NULL"); } /* end else if */ else { if ((ref_type == H5R_OBJECT) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_OBJ_REF_BUF_SIZE) { h5badArgument(env, "H5Rget_name: obj ref input array != H5R_OBJ_REF_BUF_SIZE"); } /* end if */ else if ((ref_type == H5R_DATASET_REGION) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_DSET_REG_REF_BUF_SIZE) { h5badArgument(env, "H5Rget_name: region ref input array != H5R_DSET_REG_REF_BUF_SIZE"); } /* end else if */ else { refP = (jbyte *)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); if (refP == NULL) { h5JNIFatalError(env, "H5Rget_name: ref not pinned"); } /* end if */ else { aName = (char*)HDmalloc(sizeof(char)*bs); if (aName == NULL) { ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); h5outOfMemory(env, "H5Rget_name: malloc failed"); } /* end if */ else { ret_val = (jlong)H5Rget_name((hid_t)loc_id, (H5R_type_t)ref_type, refP, aName, bs) ; ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); if (ret_val < 0) { HDfree(aName); h5libraryError(env); } /* end if */ else { str = ENVPTR->NewStringUTF(ENVPAR aName); ENVPTR->SetObjectArrayElement(ENVPAR name, 0, str); HDfree(aName); } /* end else */ } /* end else */ } /* end else */ } /* end else */ } /* end else */ return ret_val; } /* end Java_hdf_hdf5lib_H5_H5Rget_1name */
/* * Class: hdf_hdf5lib_H5 * Method: H5Aget_name_by_idx * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jint idx_type, jint order, jlong n, jlong lapl_id) { size_t buf_size; char *aValue; jlong status_size; jstring str = NULL; const char *aName; PIN_JAVA_STRING(obj_name, aName); if (aName != NULL) { /* get the length of the attribute name */ status_size = H5Aget_name_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, (H5_iter_order_t) order, (hsize_t) n, (char*)NULL, (size_t)0, (hid_t)lapl_id); if(status_size < 0) { UNPIN_JAVA_STRING(obj_name, aName); h5libraryError(env); } /* end if */ else { buf_size = (size_t)status_size + 1;/* add extra space for the null terminator */ aValue = (char*)HDmalloc(sizeof(char) * buf_size); if (aValue == NULL) { UNPIN_JAVA_STRING(obj_name, aName); h5outOfMemory(env, "H5Aget_name_by_idx: malloc failed "); } /* end if */ else { status_size = H5Aget_name_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, (H5_iter_order_t) order, (hsize_t) n, (char*)aValue, (size_t)buf_size, (hid_t)lapl_id); UNPIN_JAVA_STRING(obj_name, aName); if (status_size < 0) { HDfree(aValue); h5libraryError(env); } /* end if */ else { str = ENVPTR->NewStringUTF(ENVPAR aValue); HDfree(aValue); if (str == NULL) { /* exception -- fatal JNI error */ h5JNIFatalError(env, "H5Aget_name_by_idx: return string not created"); } /* end if */ } /* end else */ } /* end else */ } /* end else */ } return str; } /* end Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx */
/* * Class: hdf_hdf5lib_H5 * Method: H5Lget_name_by_idx * Signature: (JLjava/lang/String;IIJJ)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jlong access_id) { jlong status_size; jstring str = NULL; size_t buf_size; const char *lName; char *lValue; PIN_JAVA_STRING(name, lName); if (lName != NULL) { /* get the length of the link name */ status_size = H5Lget_name_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char*)NULL, (size_t)0, H5P_DEFAULT); if(status_size < 0) { h5libraryError(env); } /* end if */ else { buf_size = (size_t)status_size + 1;/* add extra space for the null terminator */ lValue = (char*)HDmalloc(sizeof(char) * buf_size); if (lValue == NULL) { h5outOfMemory(env, "H5Lget_name_by_idx: malloc failed "); } /* end if */ else { status_size = H5Lget_name_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char*)lValue, (size_t)buf_size, (hid_t)access_id); if (status_size < 0) { HDfree(lValue); h5libraryError(env); } /* end if */ else { str = ENVPTR->NewStringUTF(ENVPAR lValue); HDfree(lValue); if (str == NULL) h5JNIFatalError(env, "H5Lget_name_by_idx: return string not created"); } /* end else */ } /* end else */ } /* end else */ UNPIN_JAVA_STRING(name, lName); } return str; } /* end Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx */
/* * Class: hdf_hdf5lib_H5 * Method: H5Oget_comment_by_name * Signature: (JLjava/lang/String;J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { char *oComment; const char *oName; ssize_t buf_size; ssize_t status; jstring str = NULL; PIN_JAVA_STRING(name, oName); if (oName != NULL) { /* get the length of the comment */ buf_size = H5Oget_comment_by_name((hid_t)loc_id, oName, NULL, 0, (hid_t)access_id); if (buf_size < 0) { h5badArgument( env, "H5Oget_comment_by_name: buf_size < 0"); } /* end if */ else if (buf_size > 0) { buf_size++; /* add extra space for the null terminator */ oComment = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); if (oComment == NULL) { h5outOfMemory( env, "H5Oget_comment_by_name: malloc failed"); } /* end if */ else { status = H5Oget_comment_by_name((hid_t)loc_id, oName, oComment, (size_t)buf_size, (hid_t)access_id); if (status < 0) { h5libraryError(env); } /* end if */ else { /* may throw OutOfMemoryError */ str = ENVPTR->NewStringUTF(ENVPAR oComment); if (str == NULL) { h5JNIFatalError( env, "H5Oget_comment_by_name: return string not allocated"); } /* end if */ } /* end else */ HDfree(oComment); } } /* end if */ UNPIN_JAVA_STRING(name, oName); } return (jstring)str; } /* end Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name */
/* * Class: hdf_hdf5lib_H5 * Method: H5Eget_class_name * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Eget_1class_1name (JNIEnv *env, jclass cls, jlong cls_id) { char *namePtr; jstring str = NULL; ssize_t buf_size; if (cls_id < 0) { h5badArgument(env, "H5Eget_class_name: invalid argument"); } /* end if */ else { /* get the length of the name */ buf_size = H5Eget_class_name((hid_t)cls_id, NULL, 0); if (buf_size < 0) { h5badArgument( env, "H5Eget_class_name: buf_size < 0"); } /* end if */ else if (buf_size == 0) { h5badArgument( env, "H5Eget_class_name: No class name"); } /* end else if */ else { buf_size++; /* add extra space for the null terminator */ namePtr = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); if (namePtr == NULL) { h5outOfMemory( env, "H5Eget_class_name: malloc failed"); } /* end if */ else { buf_size = H5Eget_class_name((hid_t)cls_id, (char *)namePtr, (size_t)buf_size); if (buf_size < 0) { HDfree(namePtr); h5libraryError(env); } /* end if */ else { str = ENVPTR->NewStringUTF(ENVPAR namePtr); HDfree(namePtr); } /* end else */ } /* end else */ } /* end else */ } /* end else */ return str; } /* end Java_hdf_hdf5lib_H5_H5Eget_1class_1name */
/* * Class: hdf_hdf5lib_H5 * Method: H5Oget_comment * Signature: (J)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Oget_1comment (JNIEnv *env, jclass clss, jlong loc_id) { char *oComment; ssize_t buf_size; ssize_t status; jstring str = NULL; /* get the length of the comment */ buf_size = H5Oget_comment((hid_t)loc_id, NULL, 0); if (buf_size < 0) { h5badArgument( env, "H5Oget_comment: buf_size < 0"); } /* end if */ else if (buf_size > 0) { buf_size++; /* add extra space for the null terminator */ oComment = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); if (oComment == NULL) { /* exception -- out of memory */ h5outOfMemory( env, "H5Oget_comment: malloc failed"); } /* end if */ else { status = H5Oget_comment((hid_t)loc_id, oComment, (size_t)buf_size); if (status < 0) { h5libraryError(env); } /* end if */ else { /* may throw OutOfMemoryError */ str = ENVPTR->NewStringUTF(ENVPAR oComment); if (str == NULL) { h5JNIFatalError( env, "H5Oget_comment: return string not allocated"); } /* end if */ } /* end else */ HDfree(oComment); } } /* end else if */ return (jstring)str; } /* end Java_hdf_hdf5lib_H5_H5Oget_1comment */
/* * Class: hdf_hdf5lib_H5 * Method: H5Lget_value_by_idx * Signature: (JLjava/lang/String;IIJ[Ljava/lang/String;J)I */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jobjectArray link_value, jlong access_id) { herr_t status; size_t buf_size; H5L_info_t infobuf; const char *lName; void *lValue; const char *file_name; const char *obj_name; jstring str; infobuf.type = -1; PIN_JAVA_STRING(name, lName); if (lName != NULL) { /* get the length of the link valuee */ status = H5Lget_info_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id); if(status < 0) { h5libraryError(env); } /* end if */ else { buf_size = infobuf.u.val_size; if(buf_size == 0) { h5libraryError(env); } /* end if */ else { lValue = (void*)HDmalloc(buf_size); if (lValue == NULL) { h5outOfMemory(env, "H5Lget_val_by_idx: malloc failed "); } /* end if */ else { status = H5Lget_val_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (void*)lValue, (size_t)buf_size, (hid_t)access_id); if (status < 0) { h5libraryError(env); } /* end if */ else if(infobuf.type == H5L_TYPE_EXTERNAL) { status = H5Lunpack_elink_val((char*)lValue, (size_t)infobuf.u.val_size, (unsigned*)NULL, (const char**)&file_name, (const char**)&obj_name); if (status < 0) { h5libraryError(env); } /* end if */ else { str = ENVPTR->NewStringUTF(ENVPAR obj_name); if (str == NULL) { h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); } /* end if */ else { ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); str = ENVPTR->NewStringUTF(ENVPAR file_name); if (str == NULL) { h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); } /* end if */ else { ENVPTR->SetObjectArrayElement(ENVPAR link_value, 1, str); } /* end else */ } /* end else */ } /* end else */ } /* end else if */ else { str = ENVPTR->NewStringUTF(ENVPAR (char *)lValue); if (str == NULL) { h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); } /* end if */ else { ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); } /* end else */ } /* end else */ HDfree(lValue); } /* end else */ } /* end else */ } /* end else */ UNPIN_JAVA_STRING(name, lName); } return infobuf.type; } /* end Java_hdf_hdf5lib_H5_H5Lget_1val_1by_1idx */
/* * Class: hdf_hdf5lib_H5 * Method: H5Lget_value * Signature: (JLjava/lang/String;[Ljava/lang/String;J)I */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lget_1value (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jobjectArray link_value, jlong access_id) { size_t buf_size; herr_t status; H5L_info_t infobuf; const char *lName; char *lValue; const char *file_name; const char *obj_name; jstring str; infobuf.type = -1; PIN_JAVA_STRING(name, lName); if (lName != NULL) { /* get the length of the link val */ status = H5Lget_info((hid_t)loc_id, lName, &infobuf, H5P_DEFAULT); if(status < 0) { h5libraryError(env); } /* end if */ else { buf_size = infobuf.u.val_size + 1;/* add extra space for the null terminator */ if(infobuf.type == H5L_TYPE_HARD) { h5JNIFatalError(env, "H5Lget_val: link is hard type"); } /* end if */ else { lValue = (char*)HDmalloc(sizeof(char) * buf_size); if (lValue == NULL) { h5outOfMemory(env, "H5Lget_val: malloc failed"); } /* end if */ else { status = H5Lget_val((hid_t)loc_id, lName, (void*)lValue, buf_size, (hid_t)access_id); if (status < 0) { h5libraryError(env); } /* end if */ else if(infobuf.type == H5L_TYPE_EXTERNAL) { status = H5Lunpack_elink_val(lValue, (size_t)infobuf.u.val_size, (unsigned*)NULL, &file_name, &obj_name); if (status < 0) { h5libraryError(env); } /* end if */ else { str = ENVPTR->NewStringUTF(ENVPAR obj_name); if (str == NULL) { h5JNIFatalError(env, "H5Lget_val: return string not created"); } /* end if */ else { ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); str = ENVPTR->NewStringUTF(ENVPAR file_name); if (str == NULL) { h5JNIFatalError(env, "H5Lget_val: return string not created"); } /* end if */ else { ENVPTR->SetObjectArrayElement(ENVPAR link_value, 1, str); } /* end else */ } /* end else */ } /* end else */ } /* end else if */ else { str = ENVPTR->NewStringUTF(ENVPAR lValue); if (str == NULL) { /* exception -- fatal JNI error */ h5JNIFatalError(env, "H5Lget_val: return string not created"); } /* end if */ else { ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); } /* end else */ } /* end else */ HDfree(lValue); } /* end else */ } /* end else */ } /* end else */ UNPIN_JAVA_STRING(name, lName); } return infobuf.type; } /* end Java_hdf_hdf5lib_H5_H5Lget_1val */