summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-02-21 14:44:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-02-21 14:44:30 (GMT)
commit32898a5cd124db2d20eefc144d0ea83243acfff8 (patch)
tree9bc35e4fb92b64d0421e91b4fdf134f60f3487f9 /src
parentdec964c4d551829ceac7a6b68e9366a0f6cf2f9f (diff)
downloadhdf5-32898a5cd124db2d20eefc144d0ea83243acfff8.zip
hdf5-32898a5cd124db2d20eefc144d0ea83243acfff8.tar.gz
hdf5-32898a5cd124db2d20eefc144d0ea83243acfff8.tar.bz2
[svn-r13362] Description:
Eliminate unneeded new version in attribute encoding. Add character set & string padding to string datatype debugging output Add character set to attribute name debugging output Tested on: Mac OS X/32 10.4.8 (duty)
Diffstat (limited to 'src')
-rw-r--r--src/H5Oattr.c67
-rw-r--r--src/H5Odtype.c75
2 files changed, 119 insertions, 23 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 473a80e..d3d246d 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -89,22 +89,22 @@ const H5O_msg_class_t H5O_MSG_ATTR[1] = {{
/* This is the initial version, which does not have support for shared datatypes */
#define H5O_ATTR_VERSION_1 1
-/* This version allows support for shared datatypes */
+/* This version allows support for shared datatypes & dataspaces by adding a
+ * 'flag' byte indicating when those components are shared. This version
+ * also dropped the alignment on all the components */
#define H5O_ATTR_VERSION_2 2
/* Add support for different character encodings of attribute names */
#define H5O_ATTR_VERSION_3 3
-/* Add support for shared dataspaces */
-#define H5O_ATTR_VERSION_4 4
-
/* The latest version of the format. Look through the 'encode'
* and 'size' callback for places to change when updating this. */
-#define H5O_ATTR_VERSION_LATEST H5O_ATTR_VERSION_4
+#define H5O_ATTR_VERSION_LATEST H5O_ATTR_VERSION_3
/* Flags for attribute flag encoding */
#define H5O_ATTR_FLAG_TYPE_SHARED 0x01
#define H5O_ATTR_FLAG_SPACE_SHARED 0x02
+#define H5O_ATTR_FLAG_ALL 0x03
/* Declare external the free list for H5S_t's */
H5FL_EXTERN(H5S_t);
@@ -154,12 +154,17 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, unsigned UNUSED mesg_flags,
/* Version number */
version = *p++;
- if(version < H5O_ATTR_VERSION_1 || version > H5O_ATTR_VERSION_4)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for attribute message")
+ if(version < H5O_ATTR_VERSION_1 || version > H5O_ATTR_VERSION_LATEST)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "bad version number for attribute message")
/* Get the flags byte if we have a later version of the attribute */
- if(version > H5O_ATTR_VERSION_1)
+ if(version >= H5O_ATTR_VERSION_2) {
flags = *p++;
+
+ /* Check for unknown flag */
+ if(flags & (unsigned)~H5O_ATTR_FLAG_ALL)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTLOAD, NULL, "unknown flag for attribute message")
+ } /* end if */
else
p++; /* Byte is unused when version<2 */
@@ -312,12 +317,10 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
/* Check which version to write out */
if(use_latest_format)
version = H5O_ATTR_VERSION_LATEST; /* Write out latest version of format */
- else if(space_shared)
- version = H5O_ATTR_VERSION_4; /* Write version with shared dataspaces */
else if(attr->encoding != H5T_CSET_ASCII)
version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */
- else if(type_shared)
- version = H5O_ATTR_VERSION_2; /* Write out version with shared datatype */
+ else if(type_shared || space_shared)
+ version = H5O_ATTR_VERSION_2; /* Write out version with flag for shared datatype & dataspaces */
else
version = H5O_ATTR_VERSION_1; /* Write out basic version */
@@ -325,12 +328,11 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
*p++ = version;
/* Set attribute flags if version >1 */
- if(version > H5O_ATTR_VERSION_1)
- {
+ if(version >= H5O_ATTR_VERSION_2) {
flags = (type_shared ? H5O_ATTR_FLAG_TYPE_SHARED : 0 );
flags |= (space_shared ? H5O_ATTR_FLAG_SPACE_SHARED : 0);
*p++ = flags; /* Set flags for attribute */
- }
+ } /* end if */
else
*p++ = 0; /* Reserved, for version <2 */
@@ -478,18 +480,16 @@ H5O_attr_size(const H5F_t *f, const void *_mesg)
/* Check which version to write out */
if(use_latest_format)
version = H5O_ATTR_VERSION_LATEST; /* Write out latest version of format */
- else if(space_shared)
- version = H5O_ATTR_VERSION_4; /* Write version with shared dataspaces */
else if(attr->encoding != H5T_CSET_ASCII)
version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */
- else if(type_shared)
- version = H5O_ATTR_VERSION_2; /* Write out version with shared datatype */
+ else if(type_shared || space_shared)
+ version = H5O_ATTR_VERSION_2; /* Write out version with flag for indicating shared datatype or dataspace */
else
version = H5O_ATTR_VERSION_1; /* Write out basic version */
/* Common size information */
ret_value = 1 + /*version */
- 1 + /*reserved */
+ 1 + /*reserved/flags */
2 + /*name size inc. null */
2 + /*type size */
2; /*space size */
@@ -505,7 +505,7 @@ H5O_attr_size(const H5F_t *f, const void *_mesg)
attr->dt_size + /*datatype */
attr->ds_size + /*dataspace */
attr->data_size; /*the data itself */
- else if(version == H5O_ATTR_VERSION_3 || version == H5O_ATTR_VERSION_4)
+ else if(version == H5O_ATTR_VERSION_3)
ret_value += 1 + /*character encoding */
name_len + /*attribute name */
attr->dt_size + /*datatype */
@@ -1053,7 +1053,9 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
int fwidth)
{
const H5A_t *mesg = (const H5A_t *)_mesg;
- herr_t ret_value = SUCCEED; /* Return value */
+ const char *s; /* Temporary string pointer */
+ char buf[256]; /* Temporary string buffer */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5O_attr_debug)
@@ -1066,6 +1068,21 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
fprintf(stream, "%*s%-*s \"%s\"\n", indent, "", fwidth,
"Name:",
mesg->name);
+ switch(mesg->encoding) {
+ case H5T_CSET_ASCII:
+ s = "ASCII";
+ break;
+ case H5T_CSET_UTF8:
+ s = "UTF-8";
+ break;
+ default:
+ sprintf(buf, "H5T_CSET_RESERVED_%d", (int)(mesg->encoding));
+ s = buf;
+ break;
+ } /* end switch */
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Character Set of Name:",
+ s);
HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth,
"Initialized:",
mesg->initialized);
@@ -1076,6 +1093,12 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in
"Object:",
mesg->oloc.addr);
+ /* Check for attribute creation order index on the attribute */
+ if(mesg->crt_idx != H5O_MAX_CRT_ORDER_IDX)
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Creation Index:",
+ (unsigned)mesg->crt_idx);
+
fprintf(stream, "%*sDatatype...\n", indent, "");
fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0,fwidth-3),
"Encoded Size:",
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index fd3fc75..9112b1f 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -1531,7 +1531,7 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream,
sprintf(buf, "H5T_CLASS_%d", (int)(dt->shared->type));
s = buf;
break;
- }
+ } /* end switch */
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Type class:",
s);
@@ -1580,6 +1580,41 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream,
} else if(H5T_REFERENCE == dt->shared->type) {
fprintf(stream, "%*s%-*s\n", indent, "", fwidth,
"Fix dumping reference types!");
+ } else if(H5T_STRING == dt->shared->type) {
+ switch(dt->shared->u.atomic.u.s.cset) {
+ case H5T_CSET_ASCII:
+ s = "ASCII";
+ break;
+ case H5T_CSET_UTF8:
+ s = "UTF-8";
+ break;
+ default:
+ sprintf(buf, "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.cset));
+ s = buf;
+ break;
+ } /* end switch */
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Character Set:",
+ s);
+
+ switch(dt->shared->u.atomic.u.s.pad) {
+ case H5T_STR_NULLTERM:
+ s = "NULL Terminated";
+ break;
+ case H5T_STR_NULLPAD:
+ s = "NULL Padded";
+ break;
+ case H5T_STR_SPACEPAD:
+ s = "Space Padded";
+ break;
+ default:
+ sprintf(buf, "H5T_STR_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.pad));
+ s = buf;
+ break;
+ } /* end switch */
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "String Padding:",
+ s);
} else if(H5T_VLEN == dt->shared->type) {
switch(dt->shared->u.vlen.type) {
case H5T_VLEN_SEQUENCE:
@@ -1610,6 +1645,44 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream,
} /* end switch */
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Location:", s);
+
+ /* Extra information for VL-strings */
+ if(dt->shared->u.vlen.type == H5T_VLEN_STRING) {
+ switch(dt->shared->u.vlen.cset) {
+ case H5T_CSET_ASCII:
+ s = "ASCII";
+ break;
+ case H5T_CSET_UTF8:
+ s = "UTF-8";
+ break;
+ default:
+ sprintf(buf, "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.vlen.cset));
+ s = buf;
+ break;
+ } /* end switch */
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Character Set:",
+ s);
+
+ switch(dt->shared->u.vlen.pad) {
+ case H5T_STR_NULLTERM:
+ s = "NULL Terminated";
+ break;
+ case H5T_STR_NULLPAD:
+ s = "NULL Padded";
+ break;
+ case H5T_STR_SPACEPAD:
+ s = "Space Padded";
+ break;
+ default:
+ sprintf(buf, "H5T_STR_RESERVED_%d", (int)(dt->shared->u.vlen.pad));
+ s = buf;
+ break;
+ } /* end switch */
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "String Padding:",
+ s);
+ } /* end if */
} else if(H5T_ARRAY == dt->shared->type) {
fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
"Rank:",