summaryrefslogtreecommitdiffstats
path: root/hl/src
diff options
context:
space:
mode:
Diffstat (limited to 'hl/src')
-rw-r--r--hl/src/H5DS.c86
-rw-r--r--hl/src/H5DS.h11
-rw-r--r--hl/src/H5IM.c14
-rw-r--r--hl/src/H5IM.h3
-rw-r--r--hl/src/H5LT.c4
-rw-r--r--hl/src/H5TB.c4
-rw-r--r--hl/src/H5TB.h4
7 files changed, 115 insertions, 11 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c
index 214769c..552de73 100644
--- a/hl/src/H5DS.c
+++ b/hl/src/H5DS.c
@@ -14,6 +14,10 @@
#include "H5DS.h"
#include "H5LT.h"
#include <stdlib.h>
+#include "H5IM.h"
+#include "H5TB.h"
+
+
/*-------------------------------------------------------------------------
* Function: H5DSset_scale
@@ -156,6 +160,15 @@ herr_t H5DSattach_scale(hid_t did,
if (H5I_DATASET!=it1 || H5I_DATASET!=it2)
return FAIL;
+ /* the DS dataset cannot have dimension scales */
+ if (H5LT_find_attribute(dsid,DIMENSION_LIST)==1)
+ return FAIL;
+
+ /* check if the dataset is a "reserved" dataset (image, table) */
+ if (H5DS_is_reserved(did)==1)
+ return FAIL;
+
+
/*-------------------------------------------------------------------------
* The dataset may or may not have the associated DS attribute
* First we try to open to see if it is already there; if not, it is created.
@@ -1959,3 +1972,76 @@ out:
+/*-------------------------------------------------------------------------
+ * Function: H5DS_is_reserved
+ *
+ * Purpose: Verify that a dataset's CLASS is either an image, palette or table
+ *
+ * Return: true, false, fail
+ *
+ * Programmer: pvn@ncsa.uiuc.edu
+ *
+ * Date: March 19, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t H5DS_is_reserved(hid_t did)
+{
+ int has_class;
+ hid_t tid;
+ hid_t aid;
+ char buf[40];
+ herr_t ret;
+
+ /* try to find the attribute "CLASS" on the dataset */
+ if ((has_class = H5LT_find_attribute(did,"CLASS"))<0)
+ return -1;
+
+ if ( has_class == 0 )
+ return 0;
+
+ else if ( has_class == 1 )
+ {
+ if ((aid = H5Aopen_name(did,"CLASS"))<0)
+ goto out;
+
+ if ((tid = H5Aget_type(aid))<0)
+ goto out;
+
+ if (H5Aread(aid,tid,buf)<0)
+ goto out;
+
+ if ( strcmp(buf,IMAGE_CLASS)==0 ||
+ strcmp(buf,PALETTE_CLASS)==0 ||
+ strcmp(buf,TABLE_CLASS)==0 )
+ ret = 1;
+ else
+ ret = 0;
+
+ if (H5Tclose(tid)<0)
+ goto out;
+
+ if (H5Aclose(aid)<0)
+ goto out;
+
+ }
+
+ return ret;
+
+/* error zone, gracefully close */
+out:
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Aclose(aid);
+ } H5E_END_TRY;
+ return FAIL;
+}
+
+
+
+
diff --git a/hl/src/H5DS.h b/hl/src/H5DS.h
index 48e2365..2aba941 100644
--- a/hl/src/H5DS.h
+++ b/hl/src/H5DS.h
@@ -80,6 +80,17 @@ htri_t H5DSis_attached(hid_t did,
unsigned int idx);
+
+/*-------------------------------------------------------------------------
+ * private functions
+ *-------------------------------------------------------------------------
+ */
+
+
+herr_t H5DS_is_reserved(hid_t did);
+
+
+
#ifdef __cplusplus
}
#endif
diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c
index d1633f0..2492562 100644
--- a/hl/src/H5IM.c
+++ b/hl/src/H5IM.c
@@ -55,7 +55,7 @@ herr_t H5IMmake_image_8bit( hid_t loc_id,
return -1;
/* Attach the CLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", "IMAGE" ) < 0 )
+ if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 )
return -1;
/* Attach the VERSION attribute */
@@ -130,7 +130,7 @@ herr_t H5IMmake_image_24bit( hid_t loc_id,
return -1;
/* Attach the CLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", "IMAGE" ) < 0 )
+ if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 )
return -1;
/* Attach the VERSION attribute */
@@ -484,7 +484,7 @@ herr_t H5IMmake_palette( hid_t loc_id,
return -1;
/* Attach the attribute "CLASS" to the >>palette<< dataset*/
- if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", "PALETTE" ) < 0 )
+ if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0 )
return -1;
/* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/
@@ -1152,7 +1152,7 @@ herr_t H5IMis_image( hid_t loc_id,
if ( H5Aread( attr_id, attr_type, attr_data ) < 0 )
goto out;
- if( strcmp( attr_data, "IMAGE" ) == 0 )
+ if( strcmp( attr_data, IMAGE_CLASS ) == 0 )
ret = 1;
else
ret = 0;
@@ -1216,7 +1216,7 @@ herr_t H5IMis_palette( hid_t loc_id,
if ( (did = H5Dopen( loc_id, dset_name )) < 0 )
return -1;
- /* Try to find the attribute "CLASS" on the dataset */
+ /* Try to find the attribute "CLASS" on the dataset */
has_class = H5LT_find_attribute( did, "CLASS" );
if ( has_class == 0 )
@@ -1240,7 +1240,7 @@ herr_t H5IMis_palette( hid_t loc_id,
if ( H5Aread( attr_id, attr_type, attr_data ) < 0 )
goto out;
- if( strcmp( attr_data, "PALETTE" ) == 0 )
+ if( strcmp( attr_data, PALETTE_CLASS ) == 0 )
ret = 1;
else
ret = 0;
@@ -1253,7 +1253,7 @@ herr_t H5IMis_palette( hid_t loc_id,
}
- /* Close the dataset. */
+ /* Close the dataset. */
if ( H5Dclose( did ) < 0 )
return -1;
diff --git a/hl/src/H5IM.h b/hl/src/H5IM.h
index db79222..608028f 100644
--- a/hl/src/H5IM.h
+++ b/hl/src/H5IM.h
@@ -21,6 +21,9 @@
extern "C" {
#endif
+#define IMAGE_CLASS "IMAGE"
+#define PALETTE_CLASS "PALETTE"
+
herr_t H5IMmake_image_8bit( hid_t loc_id,
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c
index a076058..daa420c 100644
--- a/hl/src/H5LT.c
+++ b/hl/src/H5LT.c
@@ -2691,8 +2691,8 @@ herr_t H5LT_get_attribute_disk( hid_t loc_id,
void *attr_out )
{
/* identifiers */
- hid_t attr_id;
- hid_t attr_type;
+ hid_t attr_id;
+ hid_t attr_type;
if ( ( attr_id = H5Aopen_name( loc_id, attr_name ) ) < 0 )
return -1;
diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c
index 84f626e..d006176 100644
--- a/hl/src/H5TB.c
+++ b/hl/src/H5TB.c
@@ -170,7 +170,7 @@ herr_t H5TBmake_table( const char *table_title,
*/
/* Attach the CLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", "TABLE" ) < 0 )
+ if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", TABLE_CLASS ) < 0 )
goto out;
/* Attach the VERSION attribute */
@@ -3512,7 +3512,7 @@ herr_t H5TB_attach_attributes( const char *table_title,
hsize_t i;
/* Attach the CLASS attribute */
- if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", "TABLE" ) < 0 )
+ if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", TABLE_CLASS ) < 0 )
goto out;
/* Attach the VERSION attribute */
diff --git a/hl/src/H5TB.h b/hl/src/H5TB.h
index 0b75228..5ce10f3 100644
--- a/hl/src/H5TB.h
+++ b/hl/src/H5TB.h
@@ -21,6 +21,10 @@
#include "H5LT.h"
+
+#define TABLE_CLASS "TABLE"
+
+
#define HLTB_MAX_FIELD_LEN 255
#if !defined(MAX)