2003-02-12 21:44:31 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* Copyright by The HDF Group. *
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
|
* All rights reserved. *
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Module Info: This module contains the functionality for opaque
|
|
|
|
|
* datatypes in the H5T interface.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define H5T_PACKAGE /*suppress error about including H5Tpkg */
|
|
|
|
|
|
2004-06-23 23:36:35 +08:00
|
|
|
|
/* Interface initialization */
|
|
|
|
|
#define H5_INTERFACE_INIT_FUNC H5T_init_opaque_interface
|
|
|
|
|
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2003-09-04 01:05:23 +08:00
|
|
|
|
#include "H5private.h" /* Generic Functions */
|
|
|
|
|
#include "H5Eprivate.h" /* Error handling */
|
|
|
|
|
#include "H5Iprivate.h" /* IDs */
|
|
|
|
|
#include "H5MMprivate.h" /* Memory management */
|
|
|
|
|
#include "H5Tpkg.h" /* Datatypes */
|
|
|
|
|
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
|
|
|
|
H5T_init_opaque_interface -- Initialize interface-specific information
|
|
|
|
|
USAGE
|
|
|
|
|
herr_t H5T_init_opaque_interface()
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2003-02-12 21:44:31 +08:00
|
|
|
|
RETURNS
|
|
|
|
|
Non-negative on success/Negative on failure
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Initializes any interface-specific data or routines. (Just calls
|
|
|
|
|
H5T_init_iterface currently).
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------*/
|
|
|
|
|
static herr_t
|
|
|
|
|
H5T_init_opaque_interface(void)
|
|
|
|
|
{
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT_NOERR
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2003-09-04 01:05:23 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(H5T_init())
|
2003-02-12 21:44:31 +08:00
|
|
|
|
} /* H5T_init_opaque_interface() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: H5Tset_tag
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Tag an opaque datatype with a unique ASCII identifier.
|
|
|
|
|
*
|
|
|
|
|
* Return: Non-negative on success/Negative on failure
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Thursday, May 20, 1999
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
|
|
|
|
H5Tset_tag(hid_t type_id, const char *tag)
|
|
|
|
|
{
|
|
|
|
|
H5T_t *dt=NULL;
|
|
|
|
|
herr_t ret_value=SUCCEED; /* Return value */
|
|
|
|
|
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_API(FAIL)
|
2007-03-09 00:57:36 +08:00
|
|
|
|
H5TRACE2("e", "i*s", type_id, tag);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
|
|
|
|
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
|
2003-09-04 01:05:23 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
|
[svn-r9329]
Purpose:
Feature
Description:
Datatypes and groups now use H5FO "file object" code that was previously
only used by datasets. These objects will hold a file open if the file
is closed but they have not yet been closed. If these objects are unlinked
then relinked, they will not be destroyed. If they are opened twice (even
by two different names), both IDs will "see" changes made to the object
using the other ID.
When an object is opened using two different names (e.g., if a dataset was
opened under one name, then mounted and opened under its new name), calling
H5Iget_name() on a given hid_t will return the name used to open that hid_t,
not the current name of the object (this is a feature, and a change from the
previous behavior of datasets).
Solution:
Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's,
and H5G_t's into a "shared" struct and a private struct. The shared structs
(H5D_shared_t, etc.) hold the object's information and are used by all IDs
that point to a given object in the file. The private structs are pointed
to by the hid_t and contain the object's group entry information (including its
name) and a pointer to the shared struct for that object.
This changed the naming of structs throughout the library (e.g., datatype->size
is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip.
Platforms tested:
Visual Studio 7, sleipnir, arabica, verbena
Misc. update:
2004-09-29 03:04:19 +08:00
|
|
|
|
if (H5T_STATE_TRANSIENT!=dt->shared->state)
|
2003-09-04 01:05:23 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only")
|
[svn-r9329]
Purpose:
Feature
Description:
Datatypes and groups now use H5FO "file object" code that was previously
only used by datasets. These objects will hold a file open if the file
is closed but they have not yet been closed. If these objects are unlinked
then relinked, they will not be destroyed. If they are opened twice (even
by two different names), both IDs will "see" changes made to the object
using the other ID.
When an object is opened using two different names (e.g., if a dataset was
opened under one name, then mounted and opened under its new name), calling
H5Iget_name() on a given hid_t will return the name used to open that hid_t,
not the current name of the object (this is a feature, and a change from the
previous behavior of datasets).
Solution:
Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's,
and H5G_t's into a "shared" struct and a private struct. The shared structs
(H5D_shared_t, etc.) hold the object's information and are used by all IDs
that point to a given object in the file. The private structs are pointed
to by the hid_t and contain the object's group entry information (including its
name) and a pointer to the shared struct for that object.
This changed the naming of structs throughout the library (e.g., datatype->size
is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip.
Platforms tested:
Visual Studio 7, sleipnir, arabica, verbena
Misc. update:
2004-09-29 03:04:19 +08:00
|
|
|
|
while (dt->shared->parent)
|
|
|
|
|
dt = dt->shared->parent; /*defer to parent*/
|
|
|
|
|
if (H5T_OPAQUE!=dt->shared->type)
|
2003-09-04 01:05:23 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an opaque data type")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
if (!tag)
|
2003-09-04 01:05:23 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no tag")
|
2005-06-15 05:18:32 +08:00
|
|
|
|
if (HDstrlen(tag) >= H5T_OPAQUE_TAG_MAX)
|
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "tag too long")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Commit */
|
[svn-r9329]
Purpose:
Feature
Description:
Datatypes and groups now use H5FO "file object" code that was previously
only used by datasets. These objects will hold a file open if the file
is closed but they have not yet been closed. If these objects are unlinked
then relinked, they will not be destroyed. If they are opened twice (even
by two different names), both IDs will "see" changes made to the object
using the other ID.
When an object is opened using two different names (e.g., if a dataset was
opened under one name, then mounted and opened under its new name), calling
H5Iget_name() on a given hid_t will return the name used to open that hid_t,
not the current name of the object (this is a feature, and a change from the
previous behavior of datasets).
Solution:
Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's,
and H5G_t's into a "shared" struct and a private struct. The shared structs
(H5D_shared_t, etc.) hold the object's information and are used by all IDs
that point to a given object in the file. The private structs are pointed
to by the hid_t and contain the object's group entry information (including its
name) and a pointer to the shared struct for that object.
This changed the naming of structs throughout the library (e.g., datatype->size
is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip.
Platforms tested:
Visual Studio 7, sleipnir, arabica, verbena
Misc. update:
2004-09-29 03:04:19 +08:00
|
|
|
|
H5MM_xfree(dt->shared->u.opaque.tag);
|
|
|
|
|
dt->shared->u.opaque.tag = H5MM_strdup(tag);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2003-09-04 01:05:23 +08:00
|
|
|
|
FUNC_LEAVE_API(ret_value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: H5Tget_tag
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Get tha tag associated with an opaque datatype.
|
|
|
|
|
*
|
|
|
|
|
* Return: A pointer to an allocated string. The caller should free
|
|
|
|
|
* the string. NULL is returned for errors.
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* Thursday, May 20, 1999
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
char *
|
|
|
|
|
H5Tget_tag(hid_t type_id)
|
|
|
|
|
{
|
|
|
|
|
H5T_t *dt=NULL;
|
|
|
|
|
char *ret_value;
|
|
|
|
|
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_API(NULL)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
|
|
|
|
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
|
2003-09-04 01:05:23 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type")
|
[svn-r9329]
Purpose:
Feature
Description:
Datatypes and groups now use H5FO "file object" code that was previously
only used by datasets. These objects will hold a file open if the file
is closed but they have not yet been closed. If these objects are unlinked
then relinked, they will not be destroyed. If they are opened twice (even
by two different names), both IDs will "see" changes made to the object
using the other ID.
When an object is opened using two different names (e.g., if a dataset was
opened under one name, then mounted and opened under its new name), calling
H5Iget_name() on a given hid_t will return the name used to open that hid_t,
not the current name of the object (this is a feature, and a change from the
previous behavior of datasets).
Solution:
Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's,
and H5G_t's into a "shared" struct and a private struct. The shared structs
(H5D_shared_t, etc.) hold the object's information and are used by all IDs
that point to a given object in the file. The private structs are pointed
to by the hid_t and contain the object's group entry information (including its
name) and a pointer to the shared struct for that object.
This changed the naming of structs throughout the library (e.g., datatype->size
is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip.
Platforms tested:
Visual Studio 7, sleipnir, arabica, verbena
Misc. update:
2004-09-29 03:04:19 +08:00
|
|
|
|
while (dt->shared->parent)
|
|
|
|
|
dt = dt->shared->parent; /*defer to parent*/
|
|
|
|
|
if (H5T_OPAQUE != dt->shared->type)
|
2003-09-04 01:05:23 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "operation not defined for data type class")
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2003-02-12 21:44:31 +08:00
|
|
|
|
/* result */
|
[svn-r9329]
Purpose:
Feature
Description:
Datatypes and groups now use H5FO "file object" code that was previously
only used by datasets. These objects will hold a file open if the file
is closed but they have not yet been closed. If these objects are unlinked
then relinked, they will not be destroyed. If they are opened twice (even
by two different names), both IDs will "see" changes made to the object
using the other ID.
When an object is opened using two different names (e.g., if a dataset was
opened under one name, then mounted and opened under its new name), calling
H5Iget_name() on a given hid_t will return the name used to open that hid_t,
not the current name of the object (this is a feature, and a change from the
previous behavior of datasets).
Solution:
Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's,
and H5G_t's into a "shared" struct and a private struct. The shared structs
(H5D_shared_t, etc.) hold the object's information and are used by all IDs
that point to a given object in the file. The private structs are pointed
to by the hid_t and contain the object's group entry information (including its
name) and a pointer to the shared struct for that object.
This changed the naming of structs throughout the library (e.g., datatype->size
is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip.
Platforms tested:
Visual Studio 7, sleipnir, arabica, verbena
Misc. update:
2004-09-29 03:04:19 +08:00
|
|
|
|
if (NULL==(ret_value=H5MM_strdup(dt->shared->u.opaque.tag)))
|
2003-09-04 01:05:23 +08:00
|
|
|
|
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2003-09-04 01:05:23 +08:00
|
|
|
|
FUNC_LEAVE_API(ret_value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|