summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2009-05-07 21:45:32 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2009-05-07 21:45:32 (GMT)
commit72af05c9ecda4477d8417a68be415bd991d93d77 (patch)
tree1c8b5af2a18f458187ef091ec825528c3550a82d
parentab740c1affcba544805387679522892a9b3eff5d (diff)
downloadhdf5-72af05c9ecda4477d8417a68be415bd991d93d77.zip
hdf5-72af05c9ecda4477d8417a68be415bd991d93d77.tar.gz
hdf5-72af05c9ecda4477d8417a68be415bd991d93d77.tar.bz2
[svn-r16926] Added PACKED_BITS OFFSET=N LENGHT=M to -M option display. Added test for option.
-rw-r--r--tools/h5dump/h5dump.c29
-rw-r--r--tools/h5dump/h5dump.h3
-rw-r--r--tools/h5dump/testh5dump.sh.in2
-rw-r--r--tools/lib/h5tools_str.c4
-rw-r--r--tools/testfiles/tpackedbits.ddl22
5 files changed, 60 insertions, 0 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 89269e5..f7fe292 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -100,6 +100,10 @@ static int display_packed_bits = FALSE; /*print 1-byte numbers as packe
static H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */
static H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | descending] */
+/* packed bits display parameters */
+static int packed_offset[8];
+static int packed_lenght[8];
+
/**
** Added for XML **
**/
@@ -119,6 +123,7 @@ static int indent; /*how far in to indent the line
/* internal functions */
static hid_t h5_fileaccess(void);
static void dump_oid(hid_t oid);
+static void dump_packed_bits(unsigned int packed_index);
static void print_enum(hid_t type);
static int xml_name_to_XID(const char *, char *, int , int );
static void init_prefix(char **prfx, size_t prfx_len);
@@ -2221,6 +2226,9 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
if(display_dcpl)
dump_dcpl(dcpl_id, type, did);
+ if(display_packed_bits)
+ dump_packed_bits(packed_output-1);
+
if(display_data)
switch(H5Tget_class(type)) {
case H5T_TIME:
@@ -2596,6 +2604,22 @@ dump_oid(hid_t oid)
}
/*-------------------------------------------------------------------------
+ * Function: dump_packed_bits
+ *
+ * Purpose: Prints the packed bits offset and lenght
+ *
+ * Return: void
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+dump_packed_bits(unsigned int packed_index)
+{
+ indentation(indent + COL);
+ printf("%s %s=%d %s=%d\n", PACKED_BITS, PACKED_OFFSET, packed_offset[packed_index], PACKED_LENGHT, packed_lenght[packed_index]);
+}
+
+/*-------------------------------------------------------------------------
* Function: dump_comment
*
* Purpose: prints the comment for the the object name
@@ -3500,6 +3524,8 @@ parse_mask_list(const char *h_list)
packed_counter = 0;
memset(packed_mask,0,8);
+ memset(packed_offset,0,8);
+ memset(packed_lenght,0,8);
if (!h_list || !*h_list || *h_list == ';')
return;
@@ -3539,6 +3565,9 @@ parse_mask_list(const char *h_list)
ptr++;
}
if(lenght_value>=0) {
+ packed_offset[packed_output] = offset_value;
+ packed_lenght[packed_output] = lenght_value;
+
packed_mask[packed_output] = 1 << offset_value;
while(lenght_value>1) {
packed_mask[packed_output] = packed_mask[packed_output] << 1;
diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h
index e16705c..132f8a2 100644
--- a/tools/h5dump/h5dump.h
+++ b/tools/h5dump/h5dump.h
@@ -69,6 +69,9 @@
#define EXTERNAL_FILE "EXTERNAL_FILE"
#define FILLVALUE "FILLVALUE"
#define FILE_CONTENTS "FILE_CONTENTS"
+#define PACKED_BITS "PACKED_BITS"
+#define PACKED_OFFSET "OFFSET"
+#define PACKED_LENGHT "LENGHT"
#define BEGIN "{"
#define END "}"
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index 080726f..16b4b04 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -513,6 +513,8 @@ TOOLTEST textlinksrc.ddl textlinksrc.h5
TOOLTEST textlinkfar.ddl textlinkfar.h5
+# test for dataset packed bits
+TOOLTEST tpackedbits.ddl -d /dset1 -M 0,2 tdset.h5
if test $nerrors -eq 0 ; then
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index c7046e3..e83fff3 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -860,10 +860,14 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info,
}
else if (H5Tequal(type, H5T_NATIVE_LONG)) {
HDmemcpy(&templong, vp, sizeof(long));
+ if(packed_output)
+ templong &= packed_counter;
h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
}
else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
HDmemcpy(&tempulong, vp, sizeof(unsigned long));
+ if(packed_output)
+ tempulong &= packed_counter;
h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
}
else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
diff --git a/tools/testfiles/tpackedbits.ddl b/tools/testfiles/tpackedbits.ddl
new file mode 100644
index 0000000..8340cfc
--- /dev/null
+++ b/tools/testfiles/tpackedbits.ddl
@@ -0,0 +1,22 @@
+#############################
+Expected output for 'h5dump -d /dset1 -M 0,2 tdset.h5'
+#############################
+HDF5 "tdset.h5" {
+DATASET "/dset1" {
+ DATATYPE H5T_STD_I32BE
+ DATASPACE SIMPLE { ( 10, 20 ) / ( 10, 20 ) }
+ PACKED_BITS OFFSET=0 LENGHT=2
+ DATA {
+ (0,0): 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
+ (1,0): 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0,
+ (2,0): 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1,
+ (3,0): 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2,
+ (4,0): 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
+ (5,0): 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0,
+ (6,0): 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1,
+ (7,0): 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2,
+ (8,0): 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,
+ (9,0): 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0
+ }
+}
+}