diff options
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/h5dump.c | 339 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 28 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 2 | ||||
-rwxr-xr-x | tools/h5dump/testh5dumpxml.sh | 9 |
4 files changed, 34 insertions, 344 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index cbe67a3..4ef6bdf 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -628,7 +628,6 @@ usage(const char *prog) fprintf(stdout, "\n"); } - /*------------------------------------------------------------------------- * Function: print_datatype * @@ -957,7 +956,6 @@ print_datatype(hid_t type,unsigned in_group) } - /*------------------------------------------------------------------------- * Function: dump_datatype * @@ -2036,7 +2034,6 @@ dump_oid(hid_t oid) printf("%s %s %d %s\n", OBJID, BEGIN, oid, END); } - /*------------------------------------------------------------------------- * Function: dump_comment * @@ -2429,7 +2426,6 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id) indent -= COL; indentation(indent + COL); printf("%s\n",END); - } /*------------------------------------------------------------------------- @@ -2453,27 +2449,15 @@ dump_fcpl(hid_t fid) hsize_t userblock; /* userblock size retrieved from FCPL */ size_t off_size; /* size of offsets in the file */ size_t len_size; /* size of lengths in the file */ -#ifdef H5_WANT_H5_V1_6_COMPAT - int super; /* superblock version # */ - int freelist; /* free list version # */ - int stab; /* symbol table entry version # */ - int shhdr; /* shared object header version # */ -#else unsigned super; /* superblock version # */ unsigned freelist; /* free list version # */ unsigned stab; /* symbol table entry version # */ unsigned shhdr; /* shared object header version # */ -#endif hid_t fdriver; /* file driver */ char dname[15]; /* buffer to store driver name */ unsigned sym_lk; /* symbol table B-tree leaf 'K' value */ -#ifdef H5_WANT_H5_V1_6_COMPAT - int sym_ik; /* symbol table B-tree initial 'K' value */ - int istore_ik; /* indexed storage B-tree initial 'K' value */ -#else - unsigned sym_ik; /* symbol table B-tree initial 'K' value */ - unsigned istore_ik; /* indexed storage B-tree initial 'K' value */ -#endif + unsigned sym_ik; /* symbol table B-tree internal 'K' value */ + unsigned istore_ik; /* indexed storage B-tree internal 'K' value */ fcpl=H5Fget_create_plist(fid); H5Pget_version(fcpl, &super, &freelist, &stab, &shhdr); @@ -2492,19 +2476,19 @@ dump_fcpl(hid_t fid) */ printf("%s %s\n",SUPER_BLOCK, BEGIN); indentation(indent + COL); - printf("%s %d\n","SUPERBLOCK_VERSION", super); + printf("%s %u\n","SUPERBLOCK_VERSION", super); indentation(indent + COL); - printf("%s %d\n","FREELIST_VERSION", freelist); + printf("%s %u\n","FREELIST_VERSION", freelist); indentation(indent + COL); - printf("%s %d\n","SYMBOLTABLE_VERSION", stab); + printf("%s %u\n","SYMBOLTABLE_VERSION", stab); indentation(indent + COL); - printf("%s %d\n","OBJECTHEADER_VERSION", (int)shhdr); + printf("%s %u\n","OBJECTHEADER_VERSION", shhdr); indentation(indent + COL); HDfprintf(stdout,"%s %Hd\n","OFFSET_SIZE", (long_long)off_size); indentation(indent + COL); HDfprintf(stdout,"%s %Hd\n","LENGTH_SIZE", (long_long)len_size); indentation(indent + COL); - printf("%s %d\n","BTREE_RANK", sym_ik); + printf("%s %u\n","BTREE_RANK", sym_ik); indentation(indent + COL); printf("%s %d\n","BTREE_LEAF", sym_lk); @@ -2550,7 +2534,7 @@ dump_fcpl(hid_t fid) indentation(indent + COL); printf("%s %s\n","FILE_DRIVER", dname); indentation(indent + COL); - printf("%s %d\n","ISTORE_K", istore_ik); + printf("%s %u\n","ISTORE_K", istore_ik); printf("%s\n",END); /*------------------------------------------------------------------------- @@ -2609,10 +2593,6 @@ static void dump_fcontents(hid_t fid) } - - - - /*------------------------------------------------------------------------- * Function: set_output_file * @@ -2756,7 +2736,7 @@ parse_subset_params(char *dset) *brace++ = '\0'; s = calloc(1, sizeof(struct subset_t)); - s->start = (hssize_t *)parse_hsize_list(brace); + s->start = parse_hsize_list(brace); while (*brace && *brace != ';') brace++; @@ -3285,7 +3265,7 @@ parse_start: */ do { switch ((char)opt) { - case 's': free(s->start); s->start = (hssize_t *)parse_hsize_list(opt_arg); break; + case 's': free(s->start); s->start = parse_hsize_list(opt_arg); break; case 'S': free(s->stride); s->stride = parse_hsize_list(opt_arg); break; case 'c': free(s->count); s->count = parse_hsize_list(opt_arg); break; case 'k': free(s->block); s->block = parse_hsize_list(opt_arg); break; @@ -3487,11 +3467,9 @@ main(int argc, const char *argv[]) H5Giterate(fid, "/", NULL, fill_ref_path_table, NULL); H5Gclose(gid); - if (doxml) { /* initialize XML */ - /* reset prefix! */ strcpy(prefix, ""); @@ -3743,290 +3721,6 @@ print_enum(hid_t type) printf("\n%*s <empty>", indent + 4, ""); } -#if 0 - -/* - * XML support - */ - -/* - * XML needs a table to look up a path name for an object - * reference. - * - * This table stores mappings of reference -> path - * for all objects in the file that may be the target of - * an object reference. - * - * The 'path' is an absolute path by which the object - * can be accessed. When an object has > 1 such path, - * only one will be used in the table, with no particular - * method of selecting which one. - */ - - -ref_path_table_entry_t *ref_path_table = NULL; /* the table */ - -/*------------------------------------------------------------------------- - * Function: ref_path_table_lookup - * - * Purpose: Looks up a table entry given a path name. - * Used during construction of the table. - * - * Return: The table entre (pte) or NULL if not in the - * table. - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static ref_path_table_entry_t * -ref_path_table_lookup(const char *thepath) -{ - H5G_stat_t sb; - ref_path_table_entry_t *pte = ref_path_table; - - if(H5Gget_objinfo(thefile, thepath, TRUE, &sb)<0) { - /* fatal error ? */ - return NULL; - } - - while(pte!=NULL) { - if (sb.objno==pte->statbuf.objno) - return pte; - pte = pte->next; - } - - return NULL; -} - -/*------------------------------------------------------------------------- - * Function: ref_path_table_put - * - * Purpose: Enter the 'obj' with 'path' in the table if - * not already there. - * Create an object reference, pte, and store them - * in the table. - * - * Return: The object reference for the object. - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static ref_path_table_entry_t * -ref_path_table_put(hid_t obj, const char *path) -{ - ref_path_table_entry_t *pte; - - /* look up 'obj'. If already in table, return */ - pte = ref_path_table_lookup(path); - if (pte != NULL) - return pte; - - /* if not found, then make new entry */ - - pte = (ref_path_table_entry_t *) malloc(sizeof(ref_path_table_entry_t)); - if (pte == NULL) { - /* fatal error? */ - return NULL; - } - - pte->obj = obj; - - pte->apath = HDstrdup(path); - - if(H5Gget_objinfo(thefile, path, TRUE, &pte->statbuf)<0) { - /* fatal error? */ - free(pte); - return NULL; - } - - pte->next = ref_path_table; - ref_path_table = pte; - - return pte; -} - -/* - * counter used to disambiguate multiple instances of same object. - */ -static int xid = 1; - -static int get_next_xid() { - return xid++; -} - -/* - * This counter is used to create fake object ID's - * The idea is to set it to the largest possible offest, which - * minimizes the chance of collision with a real object id. - * - */ -haddr_t fake_xid = HADDR_MAX; -static haddr_t -get_fake_xid () { - return (fake_xid--); -} - -/* - * for an object that does not have an object id (e.g., soft link), - * create a table entry with a fake object id as the key. - */ - -static ref_path_table_entry_t * -ref_path_table_gen_fake(const char *path) -{ - ref_path_table_entry_t *pte; - - /* look up 'obj'. If already in table, return */ - pte = ref_path_table_lookup(path); - if (pte != NULL) { - return pte; - } - - /* if not found, then make new entry */ - - pte = (ref_path_table_entry_t *) malloc(sizeof(ref_path_table_entry_t)); - if (pte == NULL) { - /* fatal error? */ - return NULL; - } - - pte->obj = (hid_t)-1; - - memset(&pte->statbuf,0,sizeof(H5G_stat_t)); - pte->statbuf.objno = get_fake_xid(); - - pte->apath = HDstrdup(path); - - pte->next = ref_path_table; - ref_path_table = pte; - - return pte; -} - -/*------------------------------------------------------------------------- - * Function: lookup_ref_path - * - * Purpose: Lookup the path to the object with refernce 'ref'. - * - * Return: Return a path to the object, or NULL if not found. - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -char * -lookup_ref_path(hobj_ref_t ref) -{ - ref_path_table_entry_t *pte = ref_path_table; - - while(pte!=NULL) { - if (ref==pte->statbuf.objno) - return pte->apath; - pte = pte->next; - } - return NULL; -} - -/*------------------------------------------------------------------------- - * Function: fill_ref_path_table - * - * Purpose: Called by interator to create references for - * all objects and enter them in the table. - * - * Return: Error status. - * - * Programmer: REMcG - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -fill_ref_path_table(hid_t group, const char *name, void UNUSED * op_data) -{ - hid_t obj; - char *tmp; - H5G_stat_t statbuf; - ref_path_table_entry_t *pte; - char *thepath; - - H5Gget_objinfo(group, name, FALSE, &statbuf); - tmp = (char *) malloc(strlen(prefix) + strlen(name) + 2); - - if (tmp == NULL) - return FAIL; - - thepath = (char *) malloc(strlen(prefix) + strlen(name) + 2); - - if (thepath == NULL) { - free(tmp); - return FAIL; - } - - strcpy(tmp, prefix); - - strcpy(thepath, prefix); - strcat(thepath, "/"); - strcat(thepath, name); - - switch (statbuf.type) { - case H5G_DATASET: - if ((obj = H5Dopen(group, name)) >= 0) { - pte = ref_path_table_lookup(thepath); - if (pte == NULL) { - ref_path_table_put(obj, thepath); - } - H5Dclose(obj); - } else { - error_msg(progname, "unable to get dataset \"%s\"\n", name); - d_status = EXIT_FAILURE; - } - break; - case H5G_GROUP: - if ((obj = H5Gopen(group, name)) >= 0) { - strcat(strcat(prefix, "/"), name); - pte = ref_path_table_lookup(thepath); - if (pte == NULL) { - ref_path_table_put(obj, thepath); - H5Giterate(obj, ".", NULL, fill_ref_path_table, NULL); - strcpy(prefix, tmp); - } - H5Gclose(obj); - } else { - error_msg(progname, "unable to dump group \"%s\"\n", name); - d_status = EXIT_FAILURE; - } - break; - case H5G_TYPE: - if ((obj = H5Topen(group, name)) >= 0) { - pte = ref_path_table_lookup(thepath); - if (pte == NULL) { - ref_path_table_put(obj, thepath); - } - H5Tclose(obj); - } else { - error_msg(progname, "unable to get dataset \"%s\"\n", name); - d_status = EXIT_FAILURE; - } - break; - default: - break; - } - - free(tmp); - free(thepath); - return 0; -} - -#endif /* * create a string suitable for and XML NCNAME. Uses the @@ -4040,21 +3734,17 @@ int xml_name_to_XID(const char *str , char *outstr, int outlen, int gen) { ref_path_table_entry_t *r; - char *os; if (outlen < 22) return 1; - os = outstr; - r = ref_path_table_lookup(str); if (r == NULL) { if (strlen(str) == 0) { r = ref_path_table_lookup("/"); if (r == NULL) { if (gen) { - sprintf(os," "); /* ?? */ r = ref_path_table_gen_fake(str); - sprintf(os, "xid_"H5_PRINTF_HADDR_FMT, r->statbuf.objno); + sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, r->statbuf.objno); return 0; } else { return 1; @@ -4062,9 +3752,8 @@ xml_name_to_XID(const char *str , char *outstr, int outlen, int gen) } } else { if (gen) { - sprintf(os," "); /* ?? */ r = ref_path_table_gen_fake(str); - sprintf(os, "xid_"H5_PRINTF_HADDR_FMT, r->statbuf.objno); + sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, r->statbuf.objno); return 0; } else { return 1; @@ -4072,7 +3761,7 @@ xml_name_to_XID(const char *str , char *outstr, int outlen, int gen) } } - sprintf(os, "xid_"H5_PRINTF_HADDR_FMT, r->statbuf.objno); + sprintf(outstr, "xid_"H5_PRINTF_HADDR_FMT, r->statbuf.objno); return(0); } @@ -4793,7 +4482,7 @@ xml_dump_dataspace(hid_t space) default: printf("<!-- unknown dataspace -->\n"); } - + indentation(indent + COL); printf("</%sDataspace>\n", xmlnsprefix); } diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index b2a5208..26521c6 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -272,9 +272,9 @@ static void gent_dataset(void) dset2[i][j] = 0.0001*j+i; H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); + H5Sclose(space); H5Dclose(dataset); - H5Fclose(fid); } @@ -382,10 +382,10 @@ static void gent_attribute(void) H5Tset_size(type, 17); attr = H5Acreate (root, "attr5", type, space, H5P_DEFAULT); H5Awrite(attr, type, string); + + H5Tclose(type); H5Sclose(space); H5Aclose(attr); - - H5Tclose(type); H5Gclose(root); H5Fclose(fid); } @@ -1358,7 +1358,7 @@ static void gent_str2(void) hid_t fid, group, attr, dataset, space, space2, mem_space, hyper_space; hid_t fxdlenstr, fxdlenstr2, memtype; hsize_t dims[1], size[1], stride[1], count[1], block[1]; -hssize_t start[1]; +hsize_t start[1]; int i; @@ -1657,11 +1657,11 @@ static void gent_datareg(void) sid2; /* Dataspace ID #2 */ hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; - hssize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ + hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */ hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ - hssize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ + hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ hdset_reg_ref_t *wbuf, /* buffer to write to disk */ *rbuf; /* buffer read from disk */ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ @@ -1724,7 +1724,7 @@ static void gent_datareg(void) coord1[7][0]=9; coord1[7][1]=0; coord1[8][0]=7; coord1[8][1]=1; coord1[9][0]=3; coord1[9][1]=3; - H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(const hssize_t **)coord1); + H5Sselect_elements(sid2,H5S_SELECT_SET,POINT1_NPOINTS,(const hsize_t **)coord1); H5Sget_select_npoints(sid2); @@ -3077,7 +3077,7 @@ static void gent_char(void) * * Purpose: write attributes in LOC_ID (dataset, group, named datatype) * - * Return: + * Return: void * * Programmer: pvn@ncsa.uiuc.edu * @@ -3517,7 +3517,7 @@ static void write_attr_in(hid_t loc_id, * * Purpose: write datasets in LOC_ID * - * Return: + * Return: void * * Programmer: pvn@ncsa.uiuc.edu * @@ -3984,8 +3984,8 @@ static void write_dset_in(hid_t loc_id, static void gent_attr_all(void) { - hid_t file_id; - hid_t dset_id; + hid_t file_id; + hid_t dset_id; hid_t group_id; hid_t group2_id; hid_t root_id; @@ -4432,8 +4432,6 @@ int make_dset(hid_t loc_id, - - /*------------------------------------------------------------------------- * Function: make_external * @@ -4806,7 +4804,6 @@ set_local_myfilter(hid_t dcpl_id, hid_t UNUSED type_id, hid_t UNUSED space_id) return(SUCCEED); } - /*------------------------------------------------------------------------- * Function: gent_fcontents * @@ -5258,8 +5255,6 @@ static void gent_aindices(void) } - - /*------------------------------------------------------------------------- * Function: main * @@ -5322,3 +5317,4 @@ int main(void) return 0; } + diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 24fa908..6efc47c 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -112,7 +112,7 @@ TOOLTEST tgroup-2.ddl --group=/g2 --group / -g /y tgroup.h5 # test for displaying simple space datasets TOOLTEST tdset-1.ddl tdset.h5 # test for displaying selected datasets -TOOLTEST tdset-2.ddl -H -d dset1 -d /dset2 tdset.h5 +TOOLTEST tdset-2.ddl -H -d dset1 -d /dset2 --dataset=dset3 tdset.h5 # test for displaying attributes TOOLTEST tattr-1.ddl tattr.h5 diff --git a/tools/h5dump/testh5dumpxml.sh b/tools/h5dump/testh5dumpxml.sh index 6af3836..c2fa23f 100755 --- a/tools/h5dump/testh5dumpxml.sh +++ b/tools/h5dump/testh5dumpxml.sh @@ -62,8 +62,13 @@ TOOLTEST() { $RUNSERIAL $DUMPER_BIN $@ ) >$actual 2>$actual_err cat $actual_err >> $actual - - if $CMP $expect $actual; then + + + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + elif $CMP $expect $actual; then echo " PASSED" else echo "*FAILED*" |