JNIEXPORT jint JNICALL Java_hdf_hdflib_HDFLibrary_Vfindclass (JNIEnv *env, jclass clss, jlong file_id, jstring vgclassname) { int32 rval = -1; const char * vgcn; PIN_JAVA_STRING(vgclassname, vgcn); if (vgcn != NULL) { rval = Vfindclass((int32)file_id, (char *)vgcn); UNPIN_JAVA_STRING(vgclassname, vgcn); if (rval == FAIL) CALL_ERROR_CHECK(); } return rval; }
static void test_undefined(void) { int32 status; /* Status values from routines */ int32 file_id; /* File ID */ int32 vg1; /* Vdata ID */ int32 ref; /* Vdata ref */ intn is_internal; /* to test Vgisinternal */ uint16 name_len; /* Length of a vgroup's name or class name */ /* to simulate calls to Vgetclass/Vgetname in older applications */ char vgname[VGNAMELENMAX+1], vgclass[VGNAMELENMAX+1]; /* Open the HDF file. */ file_id = Hopen(NONAMECLASS, DFACC_CREATE, 0); CHECK_VOID(file_id,FAIL,"Hopen"); /* Initialize HDF for subsequent vgroup/vdata access. */ status = Vstart(file_id); CHECK_VOID(status,FAIL,"Vstart"); /* Create a vgroup which will have name set but not class */ vg1 = Vattach(file_id, -1, "w"); CHECK_VOID(vg1,FAIL,"VSattach"); status=Vsetname(vg1, VG_LONGNAME); CHECK_VOID(status,FAIL,"VSsetname"); status = Vdetach(vg1); CHECK_VOID(status,FAIL,"Vdetach"); /* Create another vgroup which will have class but not name */ vg1 = Vattach(file_id, -1, "w"); CHECK_VOID(vg1,FAIL,"VSattach"); status=Vsetclass(vg1, VG_LONGCLASS); CHECK_VOID(status,FAIL,"VSsetname"); status = Vdetach(vg1); CHECK_VOID(status,FAIL,"Vdetach"); status = Vend(file_id); CHECK_VOID(status,FAIL,"Vend"); status = Hclose(file_id); CHECK_VOID(status,FAIL,"Hclose"); /* Re-open the HDF file. */ file_id = Hopen(NONAMECLASS, DFACC_RDWR, 0); CHECK_VOID(file_id,FAIL,"Hopen"); /* Initialize HDF for subsequent vgroup/vdata access. */ status = Vstart(file_id); CHECK_VOID(status,FAIL,"Vstart"); /* Find the long name vgroup. */ ref=Vfind(file_id,VG_LONGNAME); CHECK_VOID(ref,FAIL,"VSfind"); vg1 = Vattach(file_id, ref, "r"); CHECK_VOID(vg1,FAIL,"VSattach"); /* Test Vgisinternal */ is_internal = Vgisinternal(vg1); CHECK_VOID(is_internal, FAIL, "Vgisinternal"); VERIFY_VOID(is_internal, FALSE, "Vgisinternal"); /* Try getting the vgroup's class without calling first Vgetclassnamelen. This shows that bug HDFFR-1288 is fixed. */ status=Vgetclass(vg1, vgclass); CHECK_VOID(status,FAIL,"Vgetclass"); VERIFY_VOID(HDstrlen(vgclass), 0, "VSgetclass"); /* The length of the class name should be 0 */ status = Vgetclassnamelen(vg1, &name_len); CHECK_VOID(status,FAIL,"Vgetclassnamelen"); VERIFY_VOID(name_len, 0, "VSgetclassnamelen"); status = Vdetach(vg1); CHECK_VOID(status,FAIL,"Vdetach"); /* Find the vgroup with class VG_LONGCLASS. This vgroup doesn't have a name */ ref=Vfindclass(file_id, VG_LONGCLASS); CHECK_VOID(ref,FAIL,"VSfindclass"); vg1 = Vattach(file_id, ref, "r"); CHECK_VOID(vg1,FAIL,"VSattach"); /* Try getting the vgroup's name without calling first Vgetclassnamelen. Similar to class name in bug HDFFR-1288. */ status=Vgetname(vg1, vgname); CHECK_VOID(status,FAIL,"Vgetname"); VERIFY_VOID(HDstrlen(vgname), 0, "VSgetname"); /* The length of the name should be 0 */ status = Vgetnamelen(vg1, &name_len); CHECK_VOID(status,FAIL,"Vgetnamelen"); VERIFY_VOID(name_len, 0, "VSgetnamelen"); status = Vdetach(vg1); CHECK_VOID(status,FAIL,"Vdetach"); status = Vend(file_id); CHECK_VOID(status,FAIL,"Vend"); status = Hclose(file_id); CHECK_VOID(status,FAIL,"Hclose"); } /* test_undefined() */