summaryrefslogtreecommitdiffstats
path: root/src/H5A.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-08-31 13:46:47 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-08-31 13:46:47 (GMT)
commit1e38c1378582208f6f109042c37c8fff858f985d (patch)
treecbed547d5490029b2f49f31a61187d33edaa8933 /src/H5A.c
parente4053f38c2b2732ffa48b7401581db2516b47951 (diff)
downloadhdf5-1e38c1378582208f6f109042c37c8fff858f985d.zip
hdf5-1e38c1378582208f6f109042c37c8fff858f985d.tar.gz
hdf5-1e38c1378582208f6f109042c37c8fff858f985d.tar.bz2
[svn-r633] Changes since 19980828
---------------------- ./RELEASE Updated with important changes I made since the second beta. ./src/H5A.c ./src/H5D.c ./src/H5Dprivate.h ./src/H5G.c ./src/H5Gprivate.h ./src/H5R.c ./src/H5Rprivate.h ./src/H5T.c ./src/H5Tprivate.h Any API function that used to take an `hid_t loc_id' followed by a `const char *name' can now take any type of object for the loc_id as long as the object is somehow associated with a file. Internally, H5G_loc() was modified to return an H5G_entry_t* instead of an H5G_t* so it's more general. Among other things, this allows one to retrieve information about an object like a named type or dataset without knowing the name of the type or dataset: int get_nlinks (hid_t obj) { H5G_stat_t sb; if (H5Gstat(obj, ".", TRUE, &sb)<0) return -1; return sb.nlink; } ./test/gheap.c ./test/istore.c These files needed a couple of changes because they call some of the internal functions whose H5G_t arguments changed to H5G_entry_t. ./src/H5A.c Got rid of all the switch statements for getting symbol table entries for varous objects and replaced them with a call to H5G_loc() allowing attributes to automatically apply to any type of object that belongs to a file. ./test/Makefile.in Moved the ragged array tests from the normal list of tests to the `make timings' target. ./test/ragged.c Added rewrite tests -- rewrite the rows of a dataset changing the number of rows and the length of each row. ./test/mtime.c Added a test that checks that H5Gstat() can be called with a dataset as the first argument. ./src/H5S.c Added #ifdef HAVE_PARALLEL around code to check for the HDF5_MPI_OPT_TYPES environment variable because the global variable that gets set is #ifdef'd. ./bin/release bzip2 uses .bz2 as the file extension.
Diffstat (limited to 'src/H5A.c')
-rw-r--r--src/H5A.c142
1 files changed, 39 insertions, 103 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 5142bae..268258a 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -153,7 +153,6 @@ hid_t
H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
hid_t plist_id)
{
- void *obj = NULL;
H5G_entry_t *ent = NULL;
H5T_t *type = NULL;
H5S_t *space = NULL;
@@ -163,25 +162,13 @@ H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
H5TRACE5("i","isiii",loc_id,name,type_id,space_id,plist_id);
/* check arguments */
- if (NULL==(obj=H5I_object (loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom");
+ if (H5_FILE==H5I_group(loc_id) ||
+ H5_ATTR==H5I_group(loc_id)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "location is not valid for an attribute");
}
- switch (H5I_group (loc_id)) {
- case H5_DATASET:
- ent = H5D_entof ((H5D_t*)obj);
- break;
- case H5_DATATYPE:
- if (NULL==(ent=H5T_entof ((H5T_t*)obj))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "target data type is not committed");
- }
- break;
- case H5_GROUP:
- ent = H5G_entof ((H5G_t*)obj);
- break;
- default:
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "inappropriate attribute target");
+ if (NULL==(ent=H5G_loc(loc_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
}
if (!name || !*name) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
@@ -235,10 +222,10 @@ static hid_t
H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type,
const H5S_t *space)
{
- H5A_t *attr = NULL;
- H5A_t found_attr;
- intn seq=0;
- hid_t ret_value = FAIL;
+ H5A_t *attr = NULL;
+ H5A_t found_attr;
+ intn seq=0;
+ hid_t ret_value = FAIL;
FUNC_ENTER(H5A_create, FAIL);
@@ -400,7 +387,6 @@ hid_t
H5Aopen_name(hid_t loc_id, const char *name)
{
H5G_entry_t *ent = NULL; /*Symtab entry of object to attribute*/
- void *obj = NULL;
intn idx=0;
hid_t ret_value = FAIL;
@@ -408,25 +394,13 @@ H5Aopen_name(hid_t loc_id, const char *name)
H5TRACE2("i","is",loc_id,name);
/* check arguments */
- if(NULL == (obj = H5I_object(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom");
+ if (H5_FILE==H5I_group(loc_id) ||
+ H5_ATTR==H5I_group(loc_id)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "location is not valid for an attribute");
}
- switch (H5I_group (loc_id)) {
- case H5_DATASET:
- ent = H5D_entof ((H5D_t*)obj);
- break;
- case H5_DATATYPE:
- if (NULL==(ent=H5T_entof ((H5T_t*)obj))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "target data type is not committed");
- }
- break;
- case H5_GROUP:
- ent = H5G_entof ((H5G_t*)obj);
- break;
- default:
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "inappropriate attribute target");
+ if (NULL==(ent=H5G_loc(loc_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
}
if (!name || !*name) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
@@ -477,32 +451,19 @@ hid_t
H5Aopen_idx(hid_t loc_id, unsigned idx)
{
H5G_entry_t *ent = NULL; /*Symtab entry of object to attribute */
- void *obj = NULL;
hid_t ret_value = FAIL;
FUNC_ENTER(H5Aopen_idx, FAIL);
H5TRACE2("i","iIu",loc_id,idx);
/* check arguments */
- if(NULL == (obj = H5I_object(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom");
+ if (H5_FILE==H5I_group(loc_id) ||
+ H5_ATTR==H5I_group(loc_id)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "location is not valid for an attribute");
}
- switch (H5I_group (loc_id)) {
- case H5_DATASET:
- ent = H5D_entof ((H5D_t*)obj);
- break;
- case H5_DATATYPE:
- if (NULL==(ent=H5T_entof ((H5T_t*)obj))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "target data type is not committed");
- }
- break;
- case H5_GROUP:
- ent = H5G_entof ((H5G_t*)obj);
- break;
- default:
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "inappropriate attribute target");
+ if (NULL==(ent=H5G_loc(loc_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
}
/* Go do the real work for opening the attribute */
@@ -1109,6 +1070,11 @@ H5Anum_attrs(hid_t loc_id)
H5TRACE1("Is","i",loc_id);
/* check arguments */
+ if (H5_FILE==H5I_group(loc_id) ||
+ H5_ATTR==H5I_group(loc_id)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "location is not valid for an attribute");
+ }
if(NULL == (obj = H5I_object(loc_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom");
}
@@ -1187,7 +1153,6 @@ int
H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data)
{
H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */
- void *obj = NULL;
H5A_t found_attr;
intn ret_value = 0;
intn idx;
@@ -1196,31 +1161,15 @@ H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data)
H5TRACE4("Is","i*Iuxx",loc_id,attr_num,op,op_data);
/* check arguments */
- if(NULL == (obj = H5I_object(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom");
- }
- switch (H5I_group (loc_id)) {
- case H5_DATASET:
- ent = H5D_entof ((H5D_t*)obj);
- break;
- case H5_DATATYPE:
- if (NULL==(ent=H5T_entof ((H5T_t*)obj))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "target data type is not committed");
- }
- break;
- case H5_GROUP:
- ent = H5G_entof ((H5G_t*)obj);
- break;
- default:
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "inappropriate attribute target");
+ if (H5_FILE==H5I_group(loc_id) ||
+ H5_ATTR==H5I_group(loc_id)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "location is not valid for an attribute");
}
- if (!op) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid operator");
+ if (NULL==(ent=H5G_loc(loc_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
}
-
/*
* Look up the attribute for the object. Make certain the start point is
* reasonable.
@@ -1276,7 +1225,6 @@ H5Adelete(hid_t loc_id, const char *name)
{
H5A_t found_attr;
H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */
- void *obj = NULL;
intn idx=0, found=-1;
herr_t ret_value = FAIL;
@@ -1284,25 +1232,13 @@ H5Adelete(hid_t loc_id, const char *name)
H5TRACE2("e","is",loc_id,name);
/* check arguments */
- if(NULL == (obj = H5I_object(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom");
+ if (H5_FILE==H5I_group(loc_id) ||
+ H5_ATTR==H5I_group(loc_id)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "location is not valid for an attribute");
}
- switch (H5I_group (loc_id)) {
- case H5_DATASET:
- ent = H5D_entof ((H5D_t*)obj);
- break;
- case H5_DATATYPE:
- if (NULL==(ent=H5T_entof ((H5T_t*)obj))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "target data type is not committed");
- }
- break;
- case H5_GROUP:
- ent = H5G_entof ((H5G_t*)obj);
- break;
- default:
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "inappropriate attribute target");
+ if (NULL==(ent=H5G_loc(loc_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
}
if (!name || !*name) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");