summaryrefslogtreecommitdiffstats
path: root/src/H5A.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-10-30 16:07:20 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-10-30 16:07:20 (GMT)
commitdbff4af21c57cfd14f7f35a6799faad5087c0867 (patch)
treece015ab8b594886613d43fd5bc5b4b6a5017fdc3 /src/H5A.c
parentaaddd739b4a3ebaf7d61a2c60dd4c3d9a08e0654 (diff)
downloadhdf5-dbff4af21c57cfd14f7f35a6799faad5087c0867.zip
hdf5-dbff4af21c57cfd14f7f35a6799faad5087c0867.tar.gz
hdf5-dbff4af21c57cfd14f7f35a6799faad5087c0867.tar.bz2
[svn-r14217] Description:
Change H5Aopen -> H5Aopen_by_name, in order to be more consistent with other new API routines. Re-add H5Aopen as a simpler routine, to open attributes on a particular object. (Much like the old H5Aopen_name routine). Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'src/H5A.c')
-rw-r--r--src/H5A.c68
1 files changed, 64 insertions, 4 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 7f0d7ed..5ba6ccf 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -439,7 +439,67 @@ done:
PURPOSE
Opens an attribute for an object by looking up the attribute name
USAGE
- hid_t H5Aopen(loc_id, obj_name, attr_name, aapl_id, lapl_id)
+ hid_t H5Aopen(loc_id, attr_name, aapl_id)
+ hid_t loc_id; IN: Object that attribute is attached to
+ const char *attr_name; IN: Name of attribute to locate and open
+ hid_t aapl_id; IN: Attribute access property list
+ RETURNS
+ ID of attribute on success, negative on failure
+
+ DESCRIPTION
+ This function opens an existing attribute for access. The attribute
+ name specified is used to look up the corresponding attribute for the
+ object. The attribute ID returned from this function must be released with
+ H5Aclose or resource leaks will develop.
+--------------------------------------------------------------------------*/
+hid_t
+H5Aopen(hid_t loc_id, const char *attr_name, hid_t UNUSED aapl_id)
+{
+ H5G_loc_t loc; /* Object location */
+ H5A_t *attr = NULL; /* Attribute opened */
+ hid_t ret_value;
+
+ FUNC_ENTER_API(H5Aopen, FAIL)
+ H5TRACE3("i", "i*si", loc_id, attr_name, aapl_id);
+
+ /* check arguments */
+ if(H5I_ATTR == H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!attr_name || !*attr_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name")
+
+ /* Read in attribute from object header */
+ if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, H5AC_ind_dxpl_id)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header")
+ attr->initialized = TRUE;
+
+ /* Finish initializing attribute */
+ if(H5A_open_common(&loc, attr) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize attribute")
+
+ /* Register the attribute and get an ID for it */
+ if((ret_value = H5I_register(H5I_ATTR, attr)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID")
+
+done:
+ /* Cleanup on failure */
+ if(ret_value < 0)
+ if(attr && H5A_close(attr) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
+
+ FUNC_LEAVE_API(ret_value)
+} /* H5Aopen() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Aopen_by_name
+ PURPOSE
+ Opens an attribute for an object by looking up the attribute name
+ USAGE
+ hid_t H5Aopen_by_name(loc_id, obj_name, attr_name, aapl_id, lapl_id)
hid_t loc_id; IN: Object that attribute is attached to
const char *obj_name; IN: Name of object relative to location
const char *attr_name; IN: Name of attribute to locate and open
@@ -455,14 +515,14 @@ done:
H5Aclose or resource leaks will develop.
--------------------------------------------------------------------------*/
hid_t
-H5Aopen(hid_t loc_id, const char *obj_name, const char *attr_name,
+H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
hid_t UNUSED aapl_id, hid_t lapl_id)
{
H5G_loc_t loc; /* Object location */
H5A_t *attr = NULL; /* Attribute opened */
hid_t ret_value;
- FUNC_ENTER_API(H5Aopen, FAIL)
+ FUNC_ENTER_API(H5Aopen_by_name, FAIL)
H5TRACE5("i", "i*s*sii", loc_id, obj_name, attr_name, aapl_id, lapl_id);
/* check arguments */
@@ -495,7 +555,7 @@ done:
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
FUNC_LEAVE_API(ret_value)
-} /* H5Aopen() */
+} /* H5Aopen_by_name() */
/*--------------------------------------------------------------------------