summaryrefslogtreecommitdiffstats
path: root/tools/h5ls
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-02-02 03:32:41 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-02-02 03:32:41 (GMT)
commit233319898db1bc7e8e28c150e55c9dcc7f068d82 (patch)
treed43f20aab2c9716e9756360ffc1adc2ea888ab71 /tools/h5ls
parent0ce42d9ed905b0d28c8afa1e33c67fb1cdaaab8b (diff)
downloadhdf5-233319898db1bc7e8e28c150e55c9dcc7f068d82.zip
hdf5-233319898db1bc7e8e28c150e55c9dcc7f068d82.tar.gz
hdf5-233319898db1bc7e8e28c150e55c9dcc7f068d82.tar.bz2
[svn-r8143] Purpose:
New Feature. (Contributed by Robb) Description: Allow h5ls to specify a VFL with the '--vfl=' command line flag. Add MPI-I/O & MPI-POSIX VFL drivers to list of drivers available for h5ls and h5dump. Platforms tested: FreeBSD 4.9 (sleipnir) w/parallel h5committested
Diffstat (limited to 'tools/h5ls')
-rw-r--r--tools/h5ls/h5ls.c361
1 files changed, 199 insertions, 162 deletions
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index 267e40f..9302ca8 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -112,6 +112,7 @@ usage: %s [OPTIONS] [OBJECTS...]\n\
-wN, --width=N Set the number of columns of output\n\
-v, --verbose Generate more verbose output\n\
-V, --version Print version number and exit\n\
+ --vfd=DRIVER Use the specified virtual file driver\n\
-x, --hexdump Show raw data in hexadecimal format\n\
\n\
OBJECTS\n\
@@ -1957,6 +1958,31 @@ get_width(void)
/*-------------------------------------------------------------------------
+ * Function: leave
+ *
+ * Purpose: Close HDF5 and MPI and call exit()
+ *
+ * Return: Does not return
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, January 31, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+leave(int ret)
+{
+ H5close();
+#ifdef H5_HAVE_PARALLEL
+ MPI_Finalize();
+#endif
+ exit(ret);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Opens a file and lists the specified group
@@ -1985,6 +2011,11 @@ main (int argc, char *argv[])
iter_t iter;
static char root_name[] = "/";
char drivername[50];
+ char *preferred_driver=NULL;
+
+#ifdef H5_HAVE_PARALLEL
+ MPI_Init(&argc, &argv);
+#endif
/* Initialize h5tools lib */
h5tools_init();
@@ -2010,132 +2041,134 @@ main (int argc, char *argv[])
/* Switches come before non-switch arguments */
for (argno=1; argno<argc && '-'==argv[argno][0]; argno++) {
- if (!strcmp(argv[argno], "--")) {
- /* Last switch */
- argno++;
- break;
- } else if (!strcmp(argv[argno], "--help")) {
- usage(progname);
- exit(0);
- } else if (!strcmp(argv[argno], "--address")) {
- address_g = TRUE;
- } else if (!strcmp(argv[argno], "--data")) {
- data_g = TRUE;
- } else if (!strcmp(argv[argno], "--errors")) {
- show_errors_g = TRUE;
- } else if (!strcmp(argv[argno], "--full")) {
- fullname_g = TRUE;
- } else if (!strcmp(argv[argno], "--group")) {
- grp_literal_g = TRUE;
- } else if (!strcmp(argv[argno], "--label")) {
- label_g = TRUE;
- } else if (!strcmp(argv[argno], "--recursive")) {
- recursive_g = TRUE;
- fullname_g = TRUE;
- } else if (!strcmp(argv[argno], "--simple")) {
- simple_output_g = TRUE;
- } else if (!strcmp(argv[argno], "--string")) {
- string_g = TRUE;
- } else if (!strncmp(argv[argno], "--width=", 8)) {
- width_g = (int)strtol(argv[argno]+8, &rest, 0);
- if (width_g<=0 || *rest) {
- usage(progname);
- exit(1);
- }
- } else if (!strcmp(argv[argno], "--width")) {
- if (argno+1>=argc) {
- usage(progname);
- exit(1);
- } else {
- s = argv[++argno];
- }
- width_g = (int)strtol(s, &rest, 0);
- if (width_g<=0 || *rest) {
- usage(progname);
- exit(1);
- }
- } else if (!strcmp(argv[argno], "--verbose")) {
- verbose_g++;
- } else if (!strcmp(argv[argno], "--version")) {
+ if (!strcmp(argv[argno], "--")) {
+ /* Last switch */
+ argno++;
+ break;
+ } else if (!strcmp(argv[argno], "--help")) {
+ usage(progname);
+ leave(0);
+ } else if (!strcmp(argv[argno], "--address")) {
+ address_g = TRUE;
+ } else if (!strcmp(argv[argno], "--data")) {
+ data_g = TRUE;
+ } else if (!strcmp(argv[argno], "--errors")) {
+ show_errors_g = TRUE;
+ } else if (!strcmp(argv[argno], "--full")) {
+ fullname_g = TRUE;
+ } else if (!strcmp(argv[argno], "--group")) {
+ grp_literal_g = TRUE;
+ } else if (!strcmp(argv[argno], "--label")) {
+ label_g = TRUE;
+ } else if (!strcmp(argv[argno], "--recursive")) {
+ recursive_g = TRUE;
+ fullname_g = TRUE;
+ } else if (!strcmp(argv[argno], "--simple")) {
+ simple_output_g = TRUE;
+ } else if (!strcmp(argv[argno], "--string")) {
+ string_g = TRUE;
+ } else if (!strncmp(argv[argno], "--vfd=", 6)) {
+ preferred_driver = argv[argno]+6;
+ } else if (!strncmp(argv[argno], "--width=", 8)) {
+ width_g = (int)strtol(argv[argno]+8, &rest, 0);
+ if (width_g<=0 || *rest) {
+ usage(progname);
+ leave(1);
+ }
+ } else if (!strcmp(argv[argno], "--width")) {
+ if (argno+1>=argc) {
+ usage(progname);
+ leave(1);
+ } else {
+ s = argv[++argno];
+ }
+ width_g = (int)strtol(s, &rest, 0);
+ if (width_g<=0 || *rest) {
+ usage(progname);
+ leave(1);
+ }
+ } else if (!strcmp(argv[argno], "--verbose")) {
+ verbose_g++;
+ } else if (!strcmp(argv[argno], "--version")) {
print_version(progname);
- exit(0);
- } else if (!strcmp(argv[argno], "--hexdump")) {
- hexdump_g = TRUE;
- } else if (!strncmp(argv[argno], "-w", 2)) {
- if (argv[argno][2]) {
- s = argv[argno]+2;
- } else if (argno+1>=argc) {
- usage(progname);
- exit(1);
- } else {
- s = argv[++argno];
- }
- width_g = (int)strtol(s, &rest, 0);
- if (width_g<=0 || *rest) {
- usage(progname);
- exit(1);
- }
- } else if ('-'!=argv[argno][1]) {
- /* Single-letter switches */
- for (s=argv[argno]+1; *s; s++) {
- switch (*s) {
- case '?':
- case 'h': /* --help */
- usage(progname);
- exit(0);
- case 'a': /* --address */
- address_g = TRUE;
- break;
- case 'd': /* --data */
- data_g = TRUE;
- break;
- case 'e': /* --errors */
- show_errors_g = TRUE;
- break;
- case 'f': /* --full */
- fullname_g = TRUE;
- break;
- case 'g': /* --group */
- grp_literal_g = TRUE;
- break;
- case 'l': /* --label */
- label_g = TRUE;
- break;
- case 'r': /* --recursive */
- recursive_g = TRUE;
- fullname_g = TRUE;
- break;
- case 'S': /* --simple */
- simple_output_g = TRUE;
- break;
- case 's': /* --string */
- string_g = TRUE;
- break;
- case 'v': /* --verbose */
- verbose_g++;
- break;
- case 'V': /* --version */
- print_version(progname);
- exit(0);
- case 'x': /* --hexdump */
- hexdump_g = TRUE;
- break;
- default:
- usage(progname);
- exit(1);
- }
- }
- } else {
- usage(progname);
- exit(1);
- }
+ leave(0);
+ } else if (!strcmp(argv[argno], "--hexdump")) {
+ hexdump_g = TRUE;
+ } else if (!strncmp(argv[argno], "-w", 2)) {
+ if (argv[argno][2]) {
+ s = argv[argno]+2;
+ } else if (argno+1>=argc) {
+ usage(progname);
+ leave(1);
+ } else {
+ s = argv[++argno];
+ }
+ width_g = (int)strtol(s, &rest, 0);
+ if (width_g<=0 || *rest) {
+ usage(progname);
+ leave(1);
+ }
+ } else if ('-'!=argv[argno][1]) {
+ /* Single-letter switches */
+ for (s=argv[argno]+1; *s; s++) {
+ switch (*s) {
+ case '?':
+ case 'h': /* --help */
+ usage(progname);
+ leave(0);
+ case 'a': /* --address */
+ address_g = TRUE;
+ break;
+ case 'd': /* --data */
+ data_g = TRUE;
+ break;
+ case 'e': /* --errors */
+ show_errors_g = TRUE;
+ break;
+ case 'f': /* --full */
+ fullname_g = TRUE;
+ break;
+ case 'g': /* --group */
+ grp_literal_g = TRUE;
+ break;
+ case 'l': /* --label */
+ label_g = TRUE;
+ break;
+ case 'r': /* --recursive */
+ recursive_g = TRUE;
+ fullname_g = TRUE;
+ break;
+ case 'S': /* --simple */
+ simple_output_g = TRUE;
+ break;
+ case 's': /* --string */
+ string_g = TRUE;
+ break;
+ case 'v': /* --verbose */
+ verbose_g++;
+ break;
+ case 'V': /* --version */
+ print_version(progname);
+ leave(0);
+ case 'x': /* --hexdump */
+ hexdump_g = TRUE;
+ break;
+ default:
+ usage(progname);
+ leave(1);
+ }
+ }
+ } else {
+ usage(progname);
+ leave(1);
+ }
}
/* If no arguments remain then print a usage message (instead of doing
* absolutely nothing ;-) */
if (argno>=argc) {
- usage(progname);
- exit(1);
+ usage(progname);
+ leave(1);
}
/* Turn off HDF5's automatic error printing unless you're debugging h5ls */
@@ -2160,58 +2193,62 @@ main (int argc, char *argv[])
* doesn't exist). */
show_file_name_g = (argc-argno > 1); /*show file names if more than one*/
while (argno<argc) {
- fname = argv[argno++];
- oname = NULL;
- file = -1;
-
- while (fname && *fname) {
- file = h5tools_fopen(fname, NULL, drivername, sizeof drivername);
-
- if (file>=0) {
- if (verbose_g) {
- printf("Opened \"%s\" with %s driver.\n",
- fname, drivername);
- }
- break; /*success*/
- }
-
- /* Shorten the file name; lengthen the object name */
- x = oname;
- oname = strrchr(fname, '/');
- if (x) *x = '/';
- if (!oname) break;
- *oname = '\0';
- }
- if (file<0) {
- fprintf(stderr, "%s: unable to open file\n", argv[argno-1]);
+ fname = argv[argno++];
+ oname = NULL;
+ file = -1;
+
+ while (fname && *fname) {
+ file = h5tools_fopen(fname, preferred_driver, drivername, sizeof drivername);
+
+ if (file>=0) {
+ if (verbose_g) {
+ printf("Opened \"%s\" with %s driver.\n",
+ fname, drivername);
+ }
+ break; /*success*/
+ }
+
+ /* Shorten the file name; lengthen the object name */
+ x = oname;
+ oname = strrchr(fname, '/');
+ if (x) *x = '/';
+ if (!oname) break;
+ *oname = '\0';
+ }
+ if (file<0) {
+ fprintf(stderr, "%s: unable to open file\n", argv[argno-1]);
continue;
- }
- if (oname) oname++;
- if (!oname || !*oname) oname = root_name;
+ }
+ if (oname) oname++;
+ if (!oname || !*oname) oname = root_name;
- /* Open the object and display it's information */
- if (H5Gget_objinfo(file, oname, TRUE, &sb)>=0 &&
- H5G_GROUP==sb.type && !grp_literal_g) {
+ /* Open the object and display it's information */
+ if (H5Gget_objinfo(file, oname, TRUE, &sb)>=0 &&
+ H5G_GROUP==sb.type && !grp_literal_g) {
/* Specified name is a group. List the complete contents of the
* group. */
- sym_insert(&sb, oname);
+ sym_insert(&sb, oname);
iter.container = container = fix_name(show_file_name_g?fname:"", oname);
- H5Giterate(file, oname, NULL, list, &iter);
- free(container);
+ H5Giterate(file, oname, NULL, list, &iter);
+ free(container);
- } else if ((root=H5Gopen(file, "/"))<0) {
- exit(1); /*major problem!*/
-
- } else {
+ } else if ((root=H5Gopen(file, "/"))<0) {
+ leave(1); /*major problem!*/
+
+ } else {
/* Specified name is a non-group object -- list that object. The
- * container for the object is everything up to the base name. */
+ * container for the object is everything up to the base name. */
iter.container = show_file_name_g ? fname : "/";
- list(root, oname, &iter);
- if (H5Gclose(root)<0) exit(1);
- }
- H5Fclose(file);
+ list(root, oname, &iter);
+ if (H5Gclose(root)<0) leave(1);
+ }
+ H5Fclose(file);
}
h5tools_close();
+ H5close();
+#ifdef H5_HAVE_PARALLEL
+ MPI_Finalize();
+#endif
return 0;
}