/*------------------------------------------------------------------------- * Function: init_ref_path_table * * Purpose: Initalize the reference path table * * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * *------------------------------------------------------------------------- */ static int init_ref_path_table(void) { /* Sanity check */ HDassert(thefile > 0); /* Create skip list to store reference path information */ if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, NULL))==NULL) return (-1); /* Iterate over objects in this file */ if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) { error_msg("unable to construct reference path table\n"); h5tools_setstatus(EXIT_FAILURE); } /* end if */ return(0); }
/*------------------------------------------------------------------------- * Function: init_objs * * Purpose: Initialize tables for groups, datasets & named datatypes * * Return: Success: SUCCEED * * Failure: FAIL * * Programmer: Ruey-Hsia Li * * Modifications: * *------------------------------------------------------------------------- */ herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table) { /* Initialize the tables */ init_table(group_table); init_table(dset_table); init_table(type_table); /* Init the find_objs_t */ info->fid = fid; info->group_table = *group_table; info->type_table = *type_table; info->dset_table = *dset_table; /* Find all shared objects */ return(h5trav_visit(fid, "/", TRUE, TRUE, find_objs_cb, NULL, info)); }
/*------------------------------------------------------------------------- * Function: main * * Modifications: * 2/2010; Vailin Choi * Get the size of user block * *------------------------------------------------------------------------- */ int main(int argc, const char *argv[]) { iter_t iter; const char *fname = NULL; hid_t fid = -1; hid_t fcpl; struct handler_t *hand = NULL; H5F_info_t finfo; int i; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); /* Disable error reporting */ H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* Initialize h5tools lib */ h5tools_init(); if((hand = parse_command_line(argc, argv))==NULL) { goto done; } fname = argv[opt_ind]; printf("Filename: %s\n", fname); HDmemset(&iter, 0, sizeof(iter)); fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); if(fid < 0) { error_msg("unable to open file \"%s\"\n", fname); h5tools_setstatus(EXIT_FAILURE); goto done; } /* end if */ /* Initialize iter structure */ iter.fid = fid; if(H5Fget_filesize(fid, &iter.filesize) < 0) warn_msg("Unable to retrieve file size\n"); HDassert(iter.filesize != 0); /* Get storge info for file-level structures */ if(H5Fget_info(fid, &finfo) < 0) warn_msg("Unable to retrieve file info\n"); else { iter.super_ext_size = finfo.super_ext_size; iter.SM_hdr_storage_size = finfo.sohm.hdr_size; iter.SM_index_storage_size = finfo.sohm.msgs_info.index_size; iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size; } /* end else */ if((fcpl = H5Fget_create_plist(fid)) < 0) warn_msg("Unable to retrieve file creation property\n"); if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0) warn_msg("Unable to retrieve userblock size\n"); /* Walk the objects or all file */ if(display_object) { unsigned u; u = 0; while(hand[u].obj) { if (h5trav_visit(fid, hand[u].obj, TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) warn_msg("Unable to traverse object \"%s\"\n", hand[u].obj); else print_statistics(hand[u].obj, &iter); u++; } /* end while */ } /* end if */ else { if (h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) warn_msg("Unable to traverse objects/links in file \"%s\"\n", fname); else print_statistics("/", &iter); } /* end else */ done: if(hand) { for (i = 0; i < argc; i++) if(hand[i].obj) { free(hand[i].obj); hand[i].obj=NULL; } free(hand); hand = NULL; /* Free iter structure */ iter_free(&iter); if(fid >= 0 && H5Fclose(fid) < 0) { error_msg("unable to close file \"%s\"\n", fname); h5tools_setstatus(EXIT_FAILURE); } } leave(h5tools_getstatus()); }
int main(int argc, const char *argv[]) { iter_t iter; const char *fname = NULL; hid_t fid; struct handler_t *hand; H5F_info_t finfo; /* Disable error reporting */ H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* Initialize h5tools lib */ h5tools_init(); hand = parse_command_line (argc, argv); if(!hand) { error_msg(progname, "unable to parse command line arguments \n"); leave(EXIT_FAILURE); } /* end if */ fname = argv[opt_ind]; printf("Filename: %s\n", fname); fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); if(fid < 0) { error_msg(progname, "unable to open file \"%s\"\n", fname); leave(EXIT_FAILURE); } /* end if */ /* Initialize iter structure */ iter_init(&iter, fid); /* Get storge info for SOHM's btree/list/heap and superblock extension */ if(H5Fget_info(fid, &finfo) < 0) warn_msg(progname, "Unable to retrieve SOHM info\n"); else { iter.super_ext_size = finfo.super_ext_size; iter.SM_hdr_storage_size = finfo.sohm.hdr_size; iter.SM_index_storage_size = finfo.sohm.msgs_info.index_size; iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size; } /* end else */ /* Walk the objects or all file */ if(display_object) { unsigned u; u = 0; while(hand[u].obj) { if (h5trav_visit(fid, hand[u].obj, TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) warn_msg(progname, "Unable to traverse object \"%s\"\n", hand[u].obj); else print_statistics(hand[u].obj, &iter); u++; } /* end while */ } /* end if */ else { if (h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) warn_msg(progname, "Unable to traverse objects/links in file \"%s\"\n", fname); else print_statistics("/", &iter); } /* end else */ if (hand) free(hand); if(H5Fclose(fid) < 0) { error_msg(progname, "unable to close file \"%s\"\n", fname); leave(EXIT_FAILURE); } leave(EXIT_SUCCESS); }