/* * Copyright (C) 1998 NCSA * All rights reserved. * * Programmer: Robb Matzke * Monday, March 23, 1998 */ #include #include #include #include #include #include #ifndef HAVE_ATTRIBUTE # undef __attribute__ # define __attribute__(X) /*void*/ # define __unused__ /*void*/ #else # define __unused__ __attribute__((unused)) #endif /* Verbosity level */ static int verbose_g = 0; /*------------------------------------------------------------------------- * Function: usage * * Purpose: Prints a usage message on stderr and then returns. * * Return: void * * Programmer: Robb Matzke * Thursday, July 16, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static void usage (const char *progname) { fprintf(stderr, "\ usage: %s [OPTIONS] FILE [GROUP]\n\ OPTIONS\n\ -h, -?, --help Print a usage message and exit\n\ -v, --verbose Generate more verbose output\n\ -V, --version Print version number and exit\n\ FILE\n\ The file name may include a printf(3C) integer format such as\n\ \"%%05d\" to open a file family.\n\ GROUP\n\ If a group name is not specified then the contents of the root group\n\ \"/\" are displayed.\n", progname); } /*------------------------------------------------------------------------- * Function: dump_dataset_values * * Purpose: Prints all values of a dataset. * * Return: void * * Programmer: Robb Matzke * Tuesday, July 21, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static void dump_dataset_values(hid_t dset) { hid_t file_space, mem_space, type; hsize_t start, file_nelmts, mem_nelmts; hssize_t zero = 0; unsigned char buf[1024]; hsize_t i; file_space = H5Dget_space(dset); type = H5Dget_type(dset); if (H5Tequal(type, H5T_NATIVE_CHAR)) { printf("%*svalue = \"", 26, ""); file_nelmts = H5Sextent_npoints(file_space); mem_nelmts = sizeof(buf); mem_space = H5Screate_simple(1, &mem_nelmts, NULL); for (start=0; start=0) { sprintf (buf, "%lu:%lu:%lu:%lu", statbuf.fileno[1], statbuf.fileno[0], statbuf.objno[1], statbuf.objno[0]); printf ("%-20s ", buf); } if ((obj=H5Dopen (group, name))>=0) { hsize_t size[64]; hsize_t maxsize[64]; hid_t space = H5Dget_space (obj); int ndims = H5Sextent_dims(space, size, maxsize); printf ("Dataset {"); for (i=0; i0) { HDfprintf(stdout, "/%Hu", maxsize[i]); } } printf ("}\n"); H5Dclose (space); H5Aiterate (obj, NULL, list_attr, NULL); dump_dataset_values(obj); H5Dclose (obj); } else if ((obj=H5Gopen (group, name))>=0) { printf ("Group\n"); H5Aiterate (obj, NULL, list_attr, NULL); H5Gclose (obj); } else if (H5Gget_linkval (group, name, sizeof(buf), buf)>=0) { if (NULL==HDmemchr (buf, 0, sizeof(buf))) { strcpy (buf+sizeof(buf)-4, "..."); } printf (" -> %s\n", buf); } else if ((obj=H5Topen (group, name))>=0) { printf ("Data type\n"); H5Aiterate (obj, NULL, list_attr, NULL); H5Tclose (obj); } else { printf ("Unknown Type\n"); } /* Display the comment if the object has one */ H5Gget_comment(group, name, sizeof(comment), comment); strcpy(comment+sizeof(comment)-4, "..."); if (comment[0]) printf("%26s%s\n", "", comment); /* Restore error reporting */ H5Eset_auto (func, edata); return 0; } /*------------------------------------------------------------------------- * Function: main * * Purpose: Opens a file and lists the specified group * * Return: Success: 0 * * Failure: 1 * * Programmer: Robb Matzke * Monday, March 23, 1998 * * Modifications: * *------------------------------------------------------------------------- */ int main (int argc, char *argv[]) { hid_t file, plist=H5P_DEFAULT; const char *fname = NULL; const char *gname = "/"; const char *progname; const char *s; int argno; /* Name of this program without the path */ if ((progname=strrchr (argv[0], '/'))) progname++; else progname = argv[0]; /* Switches come before non-switch arguments */ for (argno=1; argno