Esempio n. 1
0
/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Eregister_class
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J
 */
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Eregister_1class
    (JNIEnv *env, jclass cls, jstring cls_name, jstring lib_name, jstring version)
{
    hid_t       ret_val = -1;
    const char* the_cls_name;
    const char* the_lib_name;
    const char* the_version;

    PIN_JAVA_STRING_THREE(cls_name, the_cls_name, lib_name, the_lib_name, version, the_version);
    if (the_cls_name != NULL && the_lib_name != NULL && the_version != NULL) {
        ret_val = H5Eregister_class(the_cls_name, the_lib_name, the_version);

        UNPIN_JAVA_STRING_THREE(cls_name, the_cls_name, lib_name, the_lib_name, version, the_version);

        if (ret_val < 0)
            h5libraryError(env);
    }

    return (jlong)ret_val;
} /* end Java_hdf_hdf5lib_H5_H5Eregister_1class */
Esempio n. 2
0
/*-------------------------------------------------------------------------
 * Function:	init_error
 *
 * Purpose:	Initialize error information.
 *
 * Return:	Success:	0
 *
 *		Failure:	-1
 *
 * Programmer:	Raymond Lu
 *		July 10, 2003
 *
 *-------------------------------------------------------------------------
 */
static herr_t
init_error(void)
{
    ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME) + 1;
    ssize_t msg_size = (ssize_t)HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1;
    char   *cls_name = NULL;
    char   *msg = NULL;
    H5E_type_t msg_type;

    if(NULL == (cls_name = (char *)HDmalloc(HDstrlen(ERR_CLS_NAME) + 1)))
        TEST_ERROR
    if(NULL == (msg = (char *)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1)))
        TEST_ERROR

    if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS)) < 0)
        TEST_ERROR;

    if(cls_size != H5Eget_class_name(ERR_CLS, cls_name, (size_t)cls_size) + 1)
        TEST_ERROR;
    if(HDstrcmp(ERR_CLS_NAME, cls_name))
        TEST_ERROR;

    if((ERR_MAJ_TEST = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_TEST_MSG)) < 0)
        TEST_ERROR;
    if((ERR_MAJ_IO = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_IO_MSG)) < 0)
        TEST_ERROR;
    if((ERR_MAJ_API = H5Ecreate_msg(ERR_CLS, H5E_MAJOR, ERR_MAJ_API_MSG)) < 0)
        TEST_ERROR;

    if((ERR_MIN_SUBROUTINE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_SUBROUTINE_MSG)) < 0)
        TEST_ERROR;
    if((ERR_MIN_ERRSTACK = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_ERRSTACK_MSG)) < 0)
        TEST_ERROR;
    if((ERR_MIN_CREATE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_CREATE_MSG)) < 0)
        TEST_ERROR;
    if((ERR_MIN_WRITE = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_WRITE_MSG)) < 0)
        TEST_ERROR;
    if((ERR_MIN_GETNUM = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_GETNUM_MSG)) < 0)
        TEST_ERROR;

    if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, &msg_type, msg, (size_t)msg_size) + 1)
        TEST_ERROR;
    if(msg_type != H5E_MINOR)
        TEST_ERROR;
    if(HDstrcmp(msg, ERR_MIN_SUBROUTINE_MSG))
        TEST_ERROR;

    /* Register another class for later testing. */
    if((ERR_CLS2 = H5Eregister_class(ERR_CLS2_NAME, PROG2_NAME, PROG_VERS)) < 0)
        TEST_ERROR;

    HDfree(cls_name);
    HDfree(msg);

    return 0;

error:
    if(cls_name)
        HDfree(cls_name);
    if(msg)
        HDfree(msg);

    return -1;
} /* end init_error() */