diff options
Diffstat (limited to 'tools/h5jam')
-rw-r--r-- | tools/h5jam/CMakeLists.txt | 108 | ||||
-rw-r--r-- | tools/h5jam/Makefile.am | 2 | ||||
-rw-r--r-- | tools/h5jam/Makefile.in | 4 | ||||
-rw-r--r-- | tools/h5jam/getub.c | 26 | ||||
-rw-r--r-- | tools/h5jam/h5jam.c | 48 | ||||
-rw-r--r-- | tools/h5jam/h5unjam.c | 46 | ||||
-rw-r--r-- | tools/h5jam/tellub.c | 26 |
7 files changed, 192 insertions, 68 deletions
diff --git a/tools/h5jam/CMakeLists.txt b/tools/h5jam/CMakeLists.txt new file mode 100644 index 0000000..166d272 --- /dev/null +++ b/tools/h5jam/CMakeLists.txt @@ -0,0 +1,108 @@ +cmake_minimum_required (VERSION 2.8) +PROJECT (HDF5_TOOLS_H5JAM) + +#----------------------------------------------------------------------------- +# Setup include Directories +#----------------------------------------------------------------------------- +INCLUDE_DIRECTORIES (${HDF5_TOOLS_SOURCE_DIR}/lib) +INCLUDE_DIRECTORIES (${HDF5_PROJECT_DIR}/test) + +# -------------------------------------------------------------------- +# Add the h5jam and test executables +# -------------------------------------------------------------------- +ADD_EXECUTABLE (h5jam ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/h5jam.c) +H5_NAMING (h5jam) +IF (WIN32) + IF (MSVC) + IF (NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES (h5jam + PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:MSVCRT" + ) + ENDIF (NOT BUILD_SHARED_LIBS) + ENDIF (MSVC) +ENDIF (WIN32) +TARGET_LINK_LIBRARIES (h5jam ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) + +ADD_EXECUTABLE (getub ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/getub.c) +H5_NAMING (getub) +IF (WIN32) + IF (MSVC) + IF (NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES (getub + PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:MSVCRT" + ) + ENDIF (NOT BUILD_SHARED_LIBS) + ENDIF (MSVC) +ENDIF (WIN32) +TARGET_LINK_LIBRARIES (getub ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) + +ADD_EXECUTABLE (tellub ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/tellub.c) +H5_NAMING (tellub) +IF (WIN32) + IF (MSVC) + IF (NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES (tellub + PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:MSVCRT" + ) + ENDIF (NOT BUILD_SHARED_LIBS) + ENDIF (MSVC) +ENDIF (WIN32) +TARGET_LINK_LIBRARIES (tellub ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) + +ADD_EXECUTABLE (h5unjam ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/h5unjam.c) +H5_NAMING (h5unjam) +IF (WIN32) + IF (MSVC) + IF (NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES (h5unjam + PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:MSVCRT" + ) + ENDIF (NOT BUILD_SHARED_LIBS) + ENDIF (MSVC) +ENDIF (WIN32) +TARGET_LINK_LIBRARIES (h5unjam ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) + +SET (H5_DEP_EXECUTABLES + h5jam + getub + tellub + h5unjam +) + +IF (BUILD_TESTING) + IF (NOT BUILD_SHARED_LIBS) + ADD_EXECUTABLE (h5jamgentest ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/h5jamgentest.c) + H5_NAMING (h5jamgentest) + IF (WIN32) + IF (MSVC) + SET_TARGET_PROPERTIES (h5jamgentest + PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:MSVCRT" + ) + ENDIF (MSVC) + ENDIF (WIN32) + TARGET_LINK_LIBRARIES (h5jamgentest ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) + + #ADD_TEST (NAME h5jamgentest COMMAND $<TARGET_FILE:h5jamgentest>) + + SET (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} + # h5jamgentest + ) + ENDIF (NOT BUILD_SHARED_LIBS) +ENDIF (BUILD_TESTING) + +#-----------------------------------------------------------------------------
+# Rules for Installation of tools using make Install target
+#-----------------------------------------------------------------------------
+INSTALL ( + TARGETS + h5jam h5unjam + RUNTIME DESTINATION + bin/tools + COMPONENT + toolsapplications +) diff --git a/tools/h5jam/Makefile.am b/tools/h5jam/Makefile.am index 2f9bc00..c6ccebf 100644 --- a/tools/h5jam/Makefile.am +++ b/tools/h5jam/Makefile.am @@ -39,7 +39,7 @@ LDADD=$(LIBH5TOOLS) $(LIBHDF5) # Temporary files. *.h5 are generated by jamgentest. They should # copied to the testfiles/ directory if update is required. -CHECK_CLEANFILES+=*.h5 *.txt +CHECK_CLEANFILES+=*.h5 DISTCLEANFILES=testh5jam.sh include $(top_srcdir)/config/conclude.am diff --git a/tools/h5jam/Makefile.in b/tools/h5jam/Makefile.in index 2c89e4f..bf5219a 100644 --- a/tools/h5jam/Makefile.in +++ b/tools/h5jam/Makefile.in @@ -206,12 +206,12 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTRUMENT = @INSTRUMENT@ INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@ +LARGEFILE = @LARGEFILE@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LINUX_LFS = @LINUX_LFS@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ @@ -373,7 +373,7 @@ TRACE = perl $(top_srcdir)/bin/trace # Temporary files. *.h5 are generated by jamgentest. They should # copied to the testfiles/ directory if update is required. -CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5 *.txt +CHECK_CLEANFILES = *.chkexe *.chklog *.clog *.h5 # Include src and tools/lib directories INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/tools/lib diff --git a/tools/h5jam/getub.c b/tools/h5jam/getub.c index 2fb5833..293aa17 100644 --- a/tools/h5jam/getub.c +++ b/tools/h5jam/getub.c @@ -28,7 +28,8 @@ void parse_command_line (int argc, const char *argv[]); #define TRUE 1 #define FALSE 0 -static const char *progname="getub"; +/* Name of tool */ +#define PROGRAMNAME "getub" char *nbytes = NULL; static const char *s_opts = "c:"; /* add more later ? */ @@ -89,15 +90,15 @@ parse_command_line (int argc, const char *argv[]) break; case '?': default: - usage (progname); + usage (h5tools_getprogname()); exit (EXIT_FAILURE); } } if (argc <= opt_ind) { - error_msg (progname, "missing file name\n"); - usage (progname); + error_msg("missing file name\n"); + usage (h5tools_getprogname()); exit (EXIT_FAILURE); } } @@ -111,19 +112,22 @@ main (int argc, const char *argv[]) long res; char *buf; + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); + parse_command_line (argc, argv); if (nbytes == NULL) { /* missing arg */ - error_msg (progname, "missing size\n"); - usage (progname); + error_msg("missing size\n"); + usage (h5tools_getprogname()); exit (EXIT_FAILURE); } if (argc <= (opt_ind)) { - error_msg (progname, "missing file name\n"); - usage (progname); + error_msg("missing file name\n"); + usage (h5tools_getprogname()); exit (EXIT_FAILURE); } filename = HDstrdup (argv[opt_ind]); @@ -133,15 +137,15 @@ main (int argc, const char *argv[]) if (res == EOF) { /* fail */ - error_msg (progname, "missing file name\n"); - usage (progname); + error_msg("missing file name\n"); + usage (h5tools_getprogname()); exit (EXIT_FAILURE); } fd = HDopen (filename, O_RDONLY, 0); if (fd < 0) { - error_msg (progname, "can't open file %s\n", filename); + error_msg("can't open file %s\n", filename); exit (EXIT_FAILURE); } diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c index cceed75..17b1384 100644 --- a/tools/h5jam/h5jam.c +++ b/tools/h5jam/h5jam.c @@ -24,6 +24,9 @@ #include "H5private.h" #include "h5tools_utils.h" +/* Name of tool */ +#define PROGRAMNAME "h5jam" + #define TRUE 1 #define FALSE 0 @@ -32,8 +35,6 @@ hsize_t compute_user_block_size (hsize_t); hsize_t copy_some_to_file (int, int, hsize_t, hsize_t, ssize_t); void parse_command_line (int, const char *[]); -const char *progname = "h5jam"; -int d_status = EXIT_SUCCESS; int do_clobber = FALSE; char *output_file = NULL; char *input_file = NULL; @@ -131,14 +132,14 @@ parse_command_line (int argc, const char *argv[]) do_clobber = TRUE; break; case 'h': - usage (progname); + usage (h5tools_getprogname()); exit (EXIT_SUCCESS); case 'V': - print_version (progname); + print_version (h5tools_getprogname()); exit (EXIT_SUCCESS); case '?': default: - usage (progname); + usage (h5tools_getprogname()); exit (EXIT_FAILURE); } } @@ -180,6 +181,9 @@ main (int argc, const char *argv[]) struct stat sbuf2; int res; + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); + /* Disable error reporting */ H5Eget_auto2(H5E_DEFAULT, &func, &edata); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); @@ -189,16 +193,16 @@ main (int argc, const char *argv[]) if (ub_file == NULL) { /* no user block */ - error_msg (progname, "no user block file name\n"); - usage (progname); + error_msg("no user block file name\n"); + usage (h5tools_getprogname()); exit (EXIT_FAILURE); } if (input_file == NULL) { /* no user block */ - error_msg (progname, "no HDF5 file\n"); - usage (progname); + error_msg("no HDF5 file\n"); + usage (h5tools_getprogname()); exit (EXIT_FAILURE); } @@ -206,7 +210,7 @@ main (int argc, const char *argv[]) if (testval <= 0) { - error_msg (progname, "Input HDF5 file is not HDF \"%s\"\n", input_file); + error_msg("Input HDF5 file is not HDF \"%s\"\n", input_file); exit (EXIT_FAILURE); } @@ -214,14 +218,14 @@ main (int argc, const char *argv[]) if (ifile < 0) { - error_msg (progname, "Can't open input HDF5 file \"%s\"\n", input_file); + error_msg("Can't open input HDF5 file \"%s\"\n", input_file); exit (EXIT_FAILURE); } plist = H5Fget_create_plist (ifile); if (plist < 0) { - error_msg (progname, "Can't get file creation plist for file \"%s\"\n", + error_msg("Can't get file creation plist for file \"%s\"\n", input_file); exit (EXIT_FAILURE); } @@ -229,7 +233,7 @@ main (int argc, const char *argv[]) status = H5Pget_userblock (plist, &usize); if (status < 0) { - error_msg (progname, "Can't get user block for file \"%s\"\n", + error_msg("Can't get user block for file \"%s\"\n", input_file); exit (EXIT_FAILURE); } @@ -241,7 +245,7 @@ main (int argc, const char *argv[]) if (ufid < 0) { - error_msg (progname, "unable to open user block file \"%s\"\n", + error_msg("unable to open user block file \"%s\"\n", ub_file); exit (EXIT_FAILURE); } @@ -250,7 +254,7 @@ main (int argc, const char *argv[]) if (res < 0) { - error_msg (progname, "Can't stat file \"%s\"\n", ub_file); + error_msg("Can't stat file \"%s\"\n", ub_file); exit (EXIT_FAILURE); } @@ -260,7 +264,7 @@ main (int argc, const char *argv[]) if (h5fid < 0) { - error_msg (progname, "unable to open HDF5 file for read \"%s\"\n", + error_msg("unable to open HDF5 file for read \"%s\"\n", input_file); exit (EXIT_FAILURE); } @@ -269,7 +273,7 @@ main (int argc, const char *argv[]) if (res < 0) { - error_msg (progname, "Can't stat file \"%s\"\n", input_file); + error_msg("Can't stat file \"%s\"\n", input_file); exit (EXIT_FAILURE); } @@ -281,7 +285,7 @@ main (int argc, const char *argv[]) if (ofid < 0) { - error_msg (progname, "unable to open output file \"%s\"\n", + error_msg("unable to open output file \"%s\"\n", output_file); exit (EXIT_FAILURE); } @@ -292,7 +296,7 @@ main (int argc, const char *argv[]) if (ofid < 0) { - error_msg (progname, "unable to create output file \"%s\"\n", + error_msg("unable to create output file \"%s\"\n", output_file); exit (EXIT_FAILURE); } @@ -346,7 +350,7 @@ main (int argc, const char *argv[]) HDclose (h5fid); HDclose (ofid); - return d_status; + return h5tools_getstatus(); } /*------------------------------------------------------------------------- @@ -395,7 +399,7 @@ copy_some_to_file (int infid, int outfid, hsize_t startin, hsize_t startout, if (startin > startout) { /* this case is prohibited */ - error_msg (progname, "copy_some_to_file: panic: startin > startout?\n"); + error_msg("copy_some_to_file: panic: startin > startout?\n"); exit (EXIT_FAILURE); } @@ -405,7 +409,7 @@ copy_some_to_file (int infid, int outfid, hsize_t startin, hsize_t startout, if (res < 0) { - error_msg (progname, "Can't stat file \n"); + error_msg("Can't stat file \n"); exit (EXIT_FAILURE); } diff --git a/tools/h5jam/h5unjam.c b/tools/h5jam/h5unjam.c index 5e4d864..8e31ce1 100644 --- a/tools/h5jam/h5unjam.c +++ b/tools/h5jam/h5unjam.c @@ -26,6 +26,9 @@ #include "H5private.h" #include "h5tools_utils.h" +/* Name of tool */ +#define PROGRAMNAME "h5unjam" + #define TRUE 1 #define FALSE 0 #define COPY_BUF_SIZE 1024 @@ -34,8 +37,6 @@ hsize_t write_pad( int , hsize_t ); hsize_t compute_pad( hsize_t ); herr_t copy_to_file( int , int , ssize_t, ssize_t ); -const char *progname = "h5unjam"; -int d_status = EXIT_SUCCESS; int do_delete = FALSE; char *output_file = NULL; char *input_file = NULL; @@ -125,14 +126,14 @@ parse_command_line(int argc, const char *argv[]) do_delete = TRUE; break; case 'h': - usage(progname); + usage(h5tools_getprogname()); exit(EXIT_SUCCESS); case 'V': - print_version (progname); + print_version (h5tools_getprogname()); exit (EXIT_SUCCESS); case '?': default: - usage(progname); + usage(h5tools_getprogname()); exit(EXIT_FAILURE); } } @@ -140,8 +141,8 @@ parse_command_line(int argc, const char *argv[]) /* check for file name to be processed */ /* if (argc <= opt_ind+2) { - error_msg(progname, "missing file name\n"); - usage(progname); + error_msg("missing file name\n"); + usage(h5tools_getprogname()); exit(EXIT_FAILURE); } */ @@ -178,6 +179,9 @@ main(int argc, const char *argv[]) int res; struct stat sbuf; + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); + /* Disable error reporting */ H5Eget_auto2(H5E_DEFAULT, &func, &edata); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); @@ -187,32 +191,32 @@ main(int argc, const char *argv[]) testval = H5Fis_hdf5(input_file); if (testval <= 0) { - error_msg(progname, "Input HDF5 file is not HDF \"%s\"\n", input_file); + error_msg("Input HDF5 file is not HDF \"%s\"\n", input_file); exit(EXIT_FAILURE); } ifile = H5Fopen(input_file, H5F_ACC_RDONLY , H5P_DEFAULT); if (ifile < 0) { - error_msg(progname, "Can't open input HDF5 file \"%s\"\n", input_file); + error_msg("Can't open input HDF5 file \"%s\"\n", input_file); exit(EXIT_FAILURE); } plist = H5Fget_create_plist(ifile); if (plist < 0) { - error_msg(progname, "Can't get file creation plist for file \"%s\"\n", input_file); + error_msg("Can't get file creation plist for file \"%s\"\n", input_file); exit(EXIT_FAILURE); } status = H5Pget_userblock(plist, & usize ); if (status < 0) { - error_msg(progname, "Can't get user block for file \"%s\"\n", input_file); + error_msg("Can't get user block for file \"%s\"\n", input_file); exit(EXIT_FAILURE); } if (usize == 0) { /* no user block to remove: message? */ - error_msg(progname, "\"%s\" has no user block: no change to file\n", input_file); + error_msg("\"%s\" has no user block: no change to file\n", input_file); exit(EXIT_SUCCESS); } @@ -220,7 +224,7 @@ main(int argc, const char *argv[]) res = stat(input_file, &sbuf); if (res < 0) { - error_msg(progname, "Can't stat file \"%s\"\n", input_file); + error_msg("Can't stat file \"%s\"\n", input_file); exit(EXIT_FAILURE); } @@ -229,12 +233,12 @@ main(int argc, const char *argv[]) ifid = HDopen(input_file,O_RDONLY,0); if (ifid < 0) { - error_msg(progname, "unable to open input HDF5 file \"%s\"\n", input_file); + error_msg("unable to open input HDF5 file \"%s\"\n", input_file); exit(EXIT_FAILURE); } if (do_delete && (ub_file != NULL)) { - error_msg(progname, "??\"%s\"\n", ub_file); + error_msg("??\"%s\"\n", ub_file); exit(EXIT_FAILURE); } @@ -245,7 +249,7 @@ main(int argc, const char *argv[]) ufid = HDopen(ub_file,O_WRONLY|O_CREAT|O_TRUNC, 0644 ); if (ufid < 0) { - error_msg(progname, "unable to open user block file for output\"%s\"\n", ub_file); + error_msg("unable to open user block file for output\"%s\"\n", ub_file); exit(EXIT_FAILURE); } } @@ -254,14 +258,14 @@ main(int argc, const char *argv[]) h5fid = HDopen(input_file,O_WRONLY, 0); if (h5fid < 0) { - error_msg(progname, "unable to open output HDF5 file \"%s\"\n", input_file); + error_msg("unable to open output HDF5 file \"%s\"\n", input_file); exit(EXIT_FAILURE); } } else { h5fid = HDopen(output_file,O_WRONLY|O_CREAT|O_TRUNC, 0644 ); if (h5fid < 0) { - error_msg(progname, "unable to open output HDF5 file \"%s\"\n", output_file); + error_msg("unable to open output HDF5 file \"%s\"\n", output_file); exit(EXIT_FAILURE); } } @@ -270,7 +274,7 @@ main(int argc, const char *argv[]) /* copy from 0 to 'usize - 1' into ufid */ if (!do_delete) { if(copy_to_file(ifid, ufid, 0, (ssize_t) usize) < 0) { - error_msg(progname, "unable to copy user block to output file \"%s\"\n", ub_file); + error_msg("unable to copy user block to output file \"%s\"\n", ub_file); exit(EXIT_FAILURE); } } @@ -279,7 +283,7 @@ main(int argc, const char *argv[]) * starting at end of user block if present */ if(copy_to_file(ifid, h5fid, (ssize_t) usize, (ssize_t)(fsize - (ssize_t)usize)) < 0) { - error_msg(progname, "unable to copy hdf5 data to output file \"%s\"\n", output_file); + error_msg("unable to copy hdf5 data to output file \"%s\"\n", output_file); exit(EXIT_FAILURE); } @@ -288,7 +292,7 @@ main(int argc, const char *argv[]) HDclose(h5fid); HDclose(ifid); - return d_status; + return h5tools_getstatus(); } /* diff --git a/tools/h5jam/tellub.c b/tools/h5jam/tellub.c index d39b958..2cf30e2 100644 --- a/tools/h5jam/tellub.c +++ b/tools/h5jam/tellub.c @@ -26,7 +26,8 @@ #define TRUE 1 #define FALSE 0 -const char *progname = "tellub"; +/* Name of tool */ +#define PROGRAMNAME "tellub" /* * Command-line options: The user can specify short or long-named @@ -91,11 +92,11 @@ parse_command_line (int argc, const char *argv[]) switch ((char) opt) { case 'h': - usage (progname); + usage (h5tools_getprogname()); exit (EXIT_SUCCESS); case '?': default: - usage (progname); + usage (h5tools_getprogname()); exit (EXIT_FAILURE); } } @@ -103,8 +104,8 @@ parse_command_line (int argc, const char *argv[]) /* check for file name to be processed */ if (argc <= opt_ind) { - error_msg (progname, "missing file name\n"); - usage (progname); + error_msg(h5tools_getprogname(), "missing file name\n"); + usage (h5tools_getprogname()); exit (EXIT_FAILURE); } } @@ -135,6 +136,9 @@ main (int argc, const char *argv[]) herr_t status; hid_t plist; + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); + /* Disable error reporting */ H5Eget_auto2(H5E_DEFAULT, &func, &edata); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); @@ -143,8 +147,8 @@ main (int argc, const char *argv[]) if (argc <= (opt_ind)) { - error_msg (progname, "missing file name\n"); - usage (progname); + error_msg("missing file name\n"); + usage (h5tools_getprogname()); return (EXIT_FAILURE); } @@ -154,7 +158,7 @@ main (int argc, const char *argv[]) if (testval <= 0) { - error_msg (progname, "Input HDF5 file is not HDF \"%s\"\n", ifname); + error_msg("Input HDF5 file is not HDF \"%s\"\n", ifname); return (EXIT_FAILURE); } @@ -162,14 +166,14 @@ main (int argc, const char *argv[]) if (ifile < 0) { - error_msg (progname, "Can't open input HDF5 file \"%s\"\n", ifname); + error_msg("Can't open input HDF5 file \"%s\"\n", ifname); return (EXIT_FAILURE); } plist = H5Fget_create_plist (ifile); if (plist < 0) { - error_msg (progname, "Can't get file creation plist for file \"%s\"\n", + error_msg("Can't get file creation plist for file \"%s\"\n", ifname); return (EXIT_FAILURE); } @@ -177,7 +181,7 @@ main (int argc, const char *argv[]) status = H5Pget_userblock (plist, &usize); if (status < 0) { - error_msg (progname, "Can't get user block for file \"%s\"\n", ifname); + error_msg("Can't get user block for file \"%s\"\n", ifname); return (EXIT_FAILURE); } |