summaryrefslogtreecommitdiffstats
path: root/hl/tools
diff options
context:
space:
mode:
Diffstat (limited to 'hl/tools')
-rw-r--r--hl/tools/CMakeLists.txt2
-rw-r--r--hl/tools/COPYING13
-rw-r--r--hl/tools/Makefile.am2
-rw-r--r--hl/tools/gif2h5/CMakeLists.txt51
-rw-r--r--hl/tools/gif2h5/CMakeTests.cmake18
-rw-r--r--hl/tools/gif2h5/Makefile.am8
-rw-r--r--hl/tools/gif2h5/decompress.c233
-rw-r--r--hl/tools/gif2h5/gif.h148
-rw-r--r--hl/tools/gif2h5/gif2hdf.c54
-rw-r--r--hl/tools/gif2h5/gif2mem.c197
-rw-r--r--hl/tools/gif2h5/gifread.c360
-rw-r--r--hl/tools/gif2h5/h52gifgentst.c70
-rw-r--r--hl/tools/gif2h5/h52giftest.sh.in18
-rw-r--r--hl/tools/gif2h5/hdf2gif.c273
-rw-r--r--hl/tools/gif2h5/hdfgifwr.c285
-rw-r--r--hl/tools/gif2h5/writehdf.c65
-rw-r--r--hl/tools/h5watch/CMakeLists.txt52
-rw-r--r--hl/tools/h5watch/CMakeTests.cmake82
-rw-r--r--hl/tools/h5watch/Makefile.am5
-rw-r--r--hl/tools/h5watch/extend_dset.c298
-rw-r--r--hl/tools/h5watch/h5watch.c667
-rw-r--r--hl/tools/h5watch/h5watchgentest.c307
-rw-r--r--hl/tools/h5watch/swmr_check_compat_vfd.c57
-rw-r--r--hl/tools/h5watch/testh5watch.sh.in11
24 files changed, 1612 insertions, 1664 deletions
diff --git a/hl/tools/CMakeLists.txt b/hl/tools/CMakeLists.txt
index c2889c3..fd9b6d9 100644
--- a/hl/tools/CMakeLists.txt
+++ b/hl/tools/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_HL_TOOLS C)
add_subdirectory (gif2h5)
diff --git a/hl/tools/COPYING b/hl/tools/COPYING
deleted file mode 100644
index 6497ace..0000000
--- a/hl/tools/COPYING
+++ /dev/null
@@ -1,13 +0,0 @@
-
- Copyright by The HDF Group and
- The Board of Trustees of the University of Illinois.
- All rights reserved.
-
- The files and subdirectories in this directory are part of HDF5.
- The full HDF5 copyright notice, including terms governing use,
- modification, and redistribution, is contained in the COPYING file
- which can be found at the root of the source code distribution tree
- or in https://support.hdfgroup.org/ftp/HDF5/releases. If you do
- not have access to either file, you may request a copy from
- help@hdfgroup.org.
-
diff --git a/hl/tools/Makefile.am b/hl/tools/Makefile.am
index 5d814df..4b179f5 100644
--- a/hl/tools/Makefile.am
+++ b/hl/tools/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
diff --git a/hl/tools/gif2h5/CMakeLists.txt b/hl/tools/gif2h5/CMakeLists.txt
index 3cd913f..372fb60 100644
--- a/hl/tools/gif2h5/CMakeLists.txt
+++ b/hl/tools/gif2h5/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_HL_TOOLS_GIF2H5 C)
#-----------------------------------------------------------------------------
@@ -16,7 +16,8 @@ set (GIF2H5_SOURCES
#-- Add gif2hdf5 program
if (NOT ONLY_SHARED_LIBS)
add_executable (gif2h5 ${GIF2H5_SOURCES})
- target_include_directories (gif2h5 PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(gif2h5 PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (gif2h5 PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (gif2h5 STATIC)
target_link_libraries (gif2h5 PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
set_target_properties (gif2h5 PROPERTIES FOLDER tools/hl)
@@ -28,7 +29,8 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (gif2h5-shared ${GIF2H5_SOURCES})
- target_include_directories (gif2h5-shared PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(gif2h5-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (gif2h5-shared PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (gif2h5-shared SHARED)
target_link_libraries (gif2h5-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET})
set_target_properties (gif2h5-shared PROPERTIES FOLDER tools/hl)
@@ -38,6 +40,17 @@ if (BUILD_SHARED_LIBS)
)
endif ()
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_HL_TOOLS_GIF2H5_FORMAT gif2h5)
+ else ()
+ clang_format (HDF5_HL_TOOLS_GIF2H5_FORMAT gif2h5-shared)
+ endif ()
+endif ()
+
#-- Add h52gif program
set (hdf2gif_SOURCES
${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/hdf2gif.c
@@ -45,7 +58,8 @@ set (hdf2gif_SOURCES
)
if (NOT ONLY_SHARED_LIBS)
add_executable (h52gif ${hdf2gif_SOURCES})
- target_include_directories (h52gif PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h52gif PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (h52gif PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h52gif STATIC)
target_link_libraries (h52gif PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
set_target_properties (h52gif PROPERTIES FOLDER tools/hl)
@@ -57,7 +71,8 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h52gif-shared ${hdf2gif_SOURCES})
- target_include_directories (h52gif-shared PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h52gif-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (h52gif-shared PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h52gif-shared SHARED)
target_link_libraries (h52gif-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} PRIVATE ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET})
set_target_properties (h52gif-shared PROPERTIES FOLDER tools/hl)
@@ -67,7 +82,18 @@ if (BUILD_SHARED_LIBS)
)
endif ()
-if (BUILD_TESTING)
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
+ if (NOT ONLY_SHARED_LIBS)
+ clang_format (HDF5_HL_TOOLS_H52GIF_FORMAT h52gif)
+ else ()
+ clang_format (HDF5_HL_TOOLS_H52GIF_FORMAT h52gif-shared)
+ endif ()
+endif ()
+
+if (BUILD_TESTING AND HDF5_TEST_SERIAL)
# --------------------------------------------------------------------
# This executable can generate the actual test files - Currently not
# used in the CMake Build system as we rely on the test files that are
@@ -75,15 +101,24 @@ if (BUILD_TESTING)
# --------------------------------------------------------------------
if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS)
add_executable (hl_h52gifgentest ${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/h52gifgentst.c)
- target_include_directories (hl_h52gifgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (hl_h52gifgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (hl_h52gifgentest STATIC)
target_link_libraries (hl_h52gifgentest PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (hl_h52gifgentest PROPERTIES FOLDER generator/tools/hl)
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_HL_TOOLS_hl_h52gifgentest_FORMAT hl_h52gifgentest)
+ endif ()
+
# add_test (NAME hl_h52gifgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:hl_h52gifgentest>)
endif ()
- include (CMakeTests.cmake)
+ if (HDF5_TEST_TOOLS)
+ include (CMakeTests.cmake)
+ endif ()
endif ()
#-----------------------------------------------------------------------------
diff --git a/hl/tools/gif2h5/CMakeTests.cmake b/hl/tools/gif2h5/CMakeTests.cmake
index 8537d7c..36ea5f9 100644
--- a/hl/tools/gif2h5/CMakeTests.cmake
+++ b/hl/tools/gif2h5/CMakeTests.cmake
@@ -5,7 +5,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
@@ -27,12 +27,6 @@ HDFTEST_COPY_FILE("${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/testfiles/h52giftst.h5" "$
HDFTEST_COPY_FILE("${HDF5_HL_TOOLS_GIF2H5_SOURCE_DIR}/testfiles/ex_image2.h5" "${PROJECT_BINARY_DIR}/testfiles/ex_image2.h5" "gif2h5_files")
add_custom_target(gif2h5_files ALL COMMENT "Copying files needed by gif2h5 tests" DEPENDS ${gif2h5_files_list})
-if (NOT BUILD_SHARED_LIBS)
- set (tgt_ext "")
-else ()
- set (tgt_ext "-shared")
-endif ()
-
# Remove any output file left over from previous test run
add_test (
NAME HL_TOOLS-clear-objects
@@ -45,29 +39,29 @@ add_test (
)
set_tests_properties (HL_TOOLS-clear-objects PROPERTIES FIXTURES_SETUP clear_tools_hl)
-add_test (NAME HL_TOOLS_gif2h5 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:gif2h5${tgt_ext}> testfiles/image1.gif image1.h5)
+add_test (NAME HL_TOOLS_gif2h5 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:gif2h5${tgt_file_ext}> testfiles/image1.gif image1.h5)
set_tests_properties (HL_TOOLS_gif2h5 PROPERTIES
FIXTURES_REQUIRED clear_tools_hl
)
-add_test (NAME HL_TOOLS_h52gif COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h52gif${tgt_ext}> testfiles/h52giftst.h5 image1.gif -i image)
+add_test (NAME HL_TOOLS_h52gif COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h52gif${tgt_file_ext}> testfiles/h52giftst.h5 image1.gif -i image)
set_tests_properties (HL_TOOLS_h52gif PROPERTIES
FIXTURES_REQUIRED clear_tools_hl
)
-add_test (NAME HL_TOOLS_h52gif_none COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h52gif${tgt_ext}> testfiles/h52giftst.h5 image.gif -i nosuch_image)
+add_test (NAME HL_TOOLS_h52gif_none COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h52gif${tgt_file_ext}> testfiles/h52giftst.h5 image.gif -i nosuch_image)
set_tests_properties (HL_TOOLS_h52gif_none PROPERTIES
WILL_FAIL "true"
FIXTURES_REQUIRED clear_tools_hl
)
-#add_test (NAME HL_TOOLS_h52gifpal COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h52gif${tgt_ext}> testfiles/h52giftst.h5 image.gif -i palette)
+#add_test (NAME HL_TOOLS_h52gifpal COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h52gif${tgt_file_ext}> testfiles/h52giftst.h5 image.gif -i palette)
#set_tests_properties (HL_TOOLS_h52gifpal PROPERTIES
# WILL_FAIL "true"
# FIXTURES_REQUIRED clear_tools_hl
#)
-add_test (NAME HL_TOOLS_h52gif24bits COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h52gif${tgt_ext}> testfiles/ex_image2.h5 image24.gif -i image24bitpixel)
+add_test (NAME HL_TOOLS_h52gif24bits COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h52gif${tgt_file_ext}> testfiles/ex_image2.h5 image24.gif -i image24bitpixel)
set_tests_properties (HL_TOOLS_h52gif24bits PROPERTIES
WILL_FAIL "true"
FIXTURES_REQUIRED clear_tools_hl
diff --git a/hl/tools/gif2h5/Makefile.am b/hl/tools/gif2h5/Makefile.am
index 9ffde58..f1d45dc 100644
--- a/hl/tools/gif2h5/Makefile.am
+++ b/hl/tools/gif2h5/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
@@ -29,9 +29,9 @@ bin_PROGRAMS=gif2h5 h52gif
h52gif_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
gif2h5_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
-gif2h5_SOURCES=gif2hdf.c gif2mem.c decompress.c gifread.c writehdf.c
+gif2h5_SOURCES=gif2hdf.c gif2mem.c decompress.c gifread.c writehdf.c
-h52gif_SOURCES=hdf2gif.c hdfgifwr.c
+h52gif_SOURCES=hdf2gif.c hdfgifwr.c
# Programs all depend on the hdf5 library, the tools library, and the HL
@@ -42,7 +42,7 @@ if BUILD_TESTS_CONDITIONAL
TEST_SCRIPT=h52giftest.sh
check_SCRIPTS=$(TEST_SCRIPT)
noinst_PROGRAMS=h52gifgentst
- h52gifgentst_SOURCES=h52gifgentst.c
+ h52gifgentst_SOURCES=h52gifgentst.c
endif
CHECK_CLEANFILES+=*.h5
diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c
index 6668c22..ca33f86 100644
--- a/hl/tools/gif2h5/decompress.c
+++ b/hl/tools/gif2h5/decompress.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -15,65 +15,63 @@
#include "gif.h"
-WORD iWIDE, iHIGH, eWIDE, eHIGH, expand, numcols, strip, nostrip;
-unsigned long cols[256];
-char *cmd;
+GIFWORD iWIDE, iHIGH, eWIDE, eHIGH, expand, numcols, strip, nostrip;
+unsigned long cols[256];
+char * cmd;
FILE *fp;
-static WORD
- XC = 0, YC = 0, /* Output X and Y coords of current pixel */
- InitCodeSize, /* Starting code size, used during Clear */
- CodeSize, /* Code size, read from GIF header */
- BytesPerScanline, /* Bytes per scanline in output raster */
- IWidth, IHeight; /* image dimensions */
-static int
- BitOffset = 0, /* Bit Offset of next code */
- Pass = 0, /* Used by output routine if WORDerlaced pic */
- OutCount = 0, /* Decompressor output 'stack count' */
- Code, /* Value returned by ReadCode */
- MaxCode, /* limiting value for current code size */
- ClearCode, /* GIF clear code */
- EOFCode, /* GIF end-of-information code */
- CurCode, OldCode, InCode, /* Decompressor variables */
- FirstFree, /* First free code, generated per GIF spec */
- FreeCode, /* Decompressor, next free slot in hash table */
- FinChar, /* Decompressor variable */
- DataMask, /* AND mask for data size */
- ReadMask; /* Code AND mask for current code size */
+static GIFWORD XC = 0, YC = 0, /* Output X and Y coords of current pixel */
+ InitCodeSize, /* Starting code size, used during Clear */
+ CodeSize, /* Code size, read from GIF header */
+ BytesPerScanline, /* Bytes per scanline in output raster */
+ IWidth, IHeight; /* image dimensions */
+static int BitOffset = 0, /* Bit Offset of next code */
+ Pass = 0, /* Used by output routine if GIFWORDerlaced pic */
+ OutCount = 0, /* Decompressor output 'stack count' */
+ Code, /* Value returned by ReadCode */
+ MaxCode, /* limiting value for current code size */
+ ClearCode, /* GIF clear code */
+ EOFCode, /* GIF end-of-information code */
+ CurCode, OldCode, InCode, /* Decompressor variables */
+ FirstFree, /* First free code, generated per GIF spec */
+ FreeCode, /* Decompressor, next free slot in hash table */
+ FinChar, /* Decompressor variable */
+ DataMask, /* AND mask for data size */
+ ReadMask; /* Code AND mask for current code size */
/*MODIFICATIONS*/
-BYTE tempbyte[10];
-BYTE * tempBYTEptr[10];
-WORD tempint[10];
-WORD ImageCount = 0;
+GIFBYTE tempbyte[10];
+GIFBYTE *tempGIFBYTEptr[10];
+GIFWORD tempint[10];
+GIFWORD ImageCount = 0;
/*END MODIFICATION*/
boolean Interlace, HasColormap;
-BYTE *Image; /* The result array */
-BYTE *RawGIF; /* The heap array to hold it, raw */
-BYTE *Raster; /* The raster data stream, unblocked */
+GIFBYTE *Image; /* The result array */
+GIFBYTE *RawGIF; /* The heap array to hold it, raw */
+GIFBYTE *Raster; /* The raster data stream, unblocked */
/* The hash table used by the decompressor */
-int Prefix[4096];
-int Suffix[4096];
+int *Prefix;
+int *Suffix;
/* An output array used by the decompressor */
-int OutCode[1025];
+int *OutCode;
/* The color map, read from the GIF header */
-int numused;
+int numused;
/*
* Fetch the next code from the raster data stream. The codes can be any
- * length from 3 to 12 bits, packed WORDo 8-bit BYTEs, so we have to maWORDain
- * our location in the Raster array as a BIT Offset. We compute the BYTE
- * Offset WORDo the raster array by dividing this by 8, pick up three BYTEs,
- * compute the bit Offset WORDo our 24-bit chunk, shift to bring the desired
+ * length from 3 to 12 bits, packed into 8-bit GIFBYTEs, so we have to maintain
+ * our location in the Raster array as a BIT Offset. We compute the GIFBYTE
+ * Offset into the raster array by dividing this by 8, pick up three GIFBYTEs,
+ * compute the bit Offset into our 24-bit chunk, shift to bring the desired
* code to the bottom, then mask it off and return it.
*/
static int
@@ -82,7 +80,7 @@ ReadCode(void)
int RawCode, ByteOffset;
ByteOffset = BitOffset / 8;
- RawCode = Raster[ByteOffset] + (0x100 * Raster[ByteOffset + 1]);
+ RawCode = Raster[ByteOffset] + (0x100 * Raster[ByteOffset + 1]);
if (CodeSize >= 8)
RawCode += (0x10000 * Raster[ByteOffset + 2]);
@@ -93,19 +91,17 @@ ReadCode(void)
}
static void
-AddToPixel(BYTE Index)
+AddToPixel(GIFBYTE Index)
{
- if (YC<IHeight)
- *(Image + YC * BytesPerScanline + XC) = Index;
-
-
+ if (YC < IHeight)
+ *(Image + YC * BytesPerScanline + XC) = Index;
/* Update the X-coordinate, and if it overflows, update the
* Y-coordinate */
if (++XC == IWidth) {
/*
- * If a non-WORDerlaced picture, just increment YC to the next scan
- * line. If it's WORDerlaced, deal with the WORDerlace as described
+ * If a non-interlaced picture, just increment YC to the next scan
+ * line. If it's interlaced, deal with the interlace as described
* in the GIF spec. Put the decoded scan line out to the screen if we
* haven't gone past the bottom of it.
*/
@@ -113,40 +109,41 @@ AddToPixel(BYTE Index)
if (!Interlace) {
YC++;
- } else {
+ }
+ else {
switch (Pass) {
- case 0:
- YC += 8;
-
- if (YC >= IHeight) {
- Pass++;
- YC = 4;
- }
-
- break;
- case 1:
- YC += 8;
-
- if (YC >= IHeight) {
- Pass++;
- YC = 2;
- }
-
- break;
- case 2:
- YC += 4;
-
- if (YC >= IHeight) {
- Pass++;
- YC = 1;
- }
-
- break;
- case 3:
- YC += 2;
- break;
- default:
- break;
+ case 0:
+ YC += 8;
+
+ if (YC >= IHeight) {
+ Pass++;
+ YC = 4;
+ }
+
+ break;
+ case 1:
+ YC += 8;
+
+ if (YC >= IHeight) {
+ Pass++;
+ YC = 2;
+ }
+
+ break;
+ case 2:
+ YC += 4;
+
+ if (YC >= IHeight) {
+ Pass++;
+ YC = 1;
+ }
+
+ break;
+ case 3:
+ YC += 2;
+ break;
+ default:
+ break;
}
}
}
@@ -154,26 +151,39 @@ AddToPixel(BYTE Index)
/* Main routine. Convert a GIF image to an HDF image */
-BYTE *
+GIFBYTE *
Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
{
int i;
- XC = 0;
- YC = 0;
- Pass = 0;
- OutCount = 0;
+ if (!(Prefix = calloc(4096, sizeof(int)))) {
+ printf("Out of memory");
+ exit(EXIT_FAILURE);
+ }
+ if (!(Suffix = calloc(4096, sizeof(int)))) {
+ printf("Out of memory");
+ exit(EXIT_FAILURE);
+ }
+ if (!(OutCode = calloc(1024, sizeof(int)))) {
+ printf("Out of memory");
+ exit(EXIT_FAILURE);
+ }
+
+ XC = 0;
+ YC = 0;
+ Pass = 0;
+ OutCount = 0;
BitOffset = 0;
- DataMask = (1 << ((GifHead->PackedField & 0x07) +1)) -1;
- Raster = GifImageDesc->GIFImage;
+ DataMask = (1 << ((GifHead->PackedField & 0x07) + 1)) - 1;
+ Raster = GifImageDesc->GIFImage;
- /* Check for image seperator */
+ /* Check for image separator */
/* Now read in values from the image descriptor */
- IWidth = GifImageDesc->ImageWidth;
- IHeight = GifImageDesc->ImageHeight;
- Interlace = GifImageDesc->PackedField & 0x40;
+ IWidth = GifImageDesc->ImageWidth;
+ IHeight = GifImageDesc->ImageHeight;
+ Interlace = (uint8_t)(GifImageDesc->PackedField & 0x40);
/*
* Note that I ignore the possible existence of a local color map. I'm
@@ -183,13 +193,13 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
*/
/*
- * Start reading the raster data. First we get the WORDial code size and
+ * Start reading the raster data. First we get the initial code size and
* compute decompressor constant values, based on this code size.
*/
- CodeSize = GifImageDesc->CodeSize;
+ CodeSize = GifImageDesc->CodeSize;
ClearCode = (1 << CodeSize);
- EOFCode = ClearCode + 1;
+ EOFCode = ClearCode + 1;
FreeCode = FirstFree = ClearCode + 2;
/*
@@ -201,18 +211,18 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
CodeSize++;
InitCodeSize = CodeSize;
- MaxCode = (1 << CodeSize);
- ReadMask = MaxCode - 1;
+ MaxCode = (1 << CodeSize);
+ ReadMask = MaxCode - 1;
/*
* Read the raster data. Here we just transpose it from the GIF array to
- * the Raster array, turning it from a series of blocks WORDo one long
+ * the Raster array, turning it from a series of blocks into one long
* data stream, which makes life much easier for ReadCode().
*/
/* Allocate the Image */
- if (!(Image = (BYTE *)malloc((size_t)IWidth*(size_t)IHeight))) {
+ if (!(Image = (GIFBYTE *)malloc((size_t)IWidth * (size_t)IHeight))) {
printf("Out of memory");
exit(EXIT_FAILURE);
}
@@ -233,13 +243,14 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
*/
if (Code == ClearCode) {
CodeSize = InitCodeSize;
- MaxCode = (1 << CodeSize);
+ MaxCode = (1 << CodeSize);
ReadMask = MaxCode - 1;
FreeCode = FirstFree;
CurCode = OldCode = Code = ReadCode();
- FinChar = CurCode & DataMask;
- AddToPixel((BYTE)FinChar);
- } else {
+ FinChar = CurCode & DataMask;
+ AddToPixel((GIFBYTE)FinChar);
+ }
+ else {
/*
* If not a clear code, then must be data: save same as CurCode
* and InCode
@@ -251,12 +262,12 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
* repeat the last character decoded
*/
if (CurCode >= FreeCode) {
- CurCode = OldCode;
+ CurCode = OldCode;
OutCode[OutCount++] = FinChar;
}
/*
- * Unless this code is raw data, pursue the chain poWORDed to by
+ * Unless this code is raw data, pursue the chain pointed to by
* CurCode through the hash table to its end; each code in the
* chain puts its associated output code on the output queue.
*/
@@ -266,11 +277,11 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
}
OutCode[OutCount++] = Suffix[CurCode];
- CurCode = Prefix[CurCode];
+ CurCode = Prefix[CurCode];
}
/* The last code in the chain is treated as raw data. */
- FinChar = CurCode & DataMask;
+ FinChar = CurCode & DataMask;
OutCode[OutCount++] = FinChar;
/*
@@ -278,7 +289,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
* stacked LIFO, so deal with it that way...
*/
for (i = OutCount - 1; i >= 0; i--)
- AddToPixel((BYTE)OutCode[i]);
+ AddToPixel((GIFBYTE)OutCode[i]);
OutCount = 0;
@@ -288,10 +299,10 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
*/
Prefix[FreeCode] = OldCode;
Suffix[FreeCode] = FinChar;
- OldCode = InCode;
+ OldCode = InCode;
/*
- * PoWORD to the next slot in the table. If we exceed the current
+ * Point to the next slot in the table. If we exceed the current
* MaxCode value, increment the code size unless it's already 12.
* If it is, do nothing: the next code decompressed better be
* CLEAR
@@ -309,5 +320,9 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead)
Code = ReadCode();
}
+ free(Prefix);
+ free(Suffix);
+ free(OutCode);
+
return Image;
}
diff --git a/hl/tools/gif2h5/gif.h b/hl/tools/gif2h5/gif.h
index ed1cc81..5ea8633 100644
--- a/hl/tools/gif2h5/gif.h
+++ b/hl/tools/gif2h5/gif.h
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -16,7 +16,7 @@
* Purpose: GIF Header file
*/
#ifndef GIF_H_
-#define GIF_H_ 1
+#define GIF_H_ 1
#include <stdio.h>
#include <stdlib.h>
@@ -26,24 +26,31 @@
#define MAX_PAL 768
-/* typedef H5T_NATIVE_UINT8 BYTE; */
-typedef unsigned char BYTE;
+/* typedef H5T_NATIVE_UINT8 GIFBYTE; */
+typedef unsigned char GIFBYTE;
-/* typedef H5T_NATIVE_UINT16 WORD; */
-typedef unsigned long WORD;
+/* typedef H5T_NATIVE_UINT16 GIFWORD; */
+typedef unsigned long GIFWORD;
-typedef char CHAR;
+typedef char GIFCHAR;
+
+#ifndef boolean
typedef unsigned char boolean;
+#endif
-#define false 0
-#define true 1
+#ifndef false
+#define false 0
+#endif
+#ifndef true
+#define true 1
+#endif
/* Set the EndianOrder.
** The GIF Reader file should do this.
** Set EndianOrder = 0 if machine is little endian
** EndianOrder = 1 if machine is big endian.
*/
-extern int EndianOrder;
+extern int EndianOrder;
/*
** The GIF header format.
@@ -52,68 +59,66 @@ extern int EndianOrder;
** descriptor, and the global color table for the GIF image.
*/
typedef struct _GifHeader { /* Offset Description */
- BYTE PackedField; /* 0Ah Color Information */
- WORD TableSize;
- BYTE ImageCount; /* Keep a count of the number of images */
- BYTE CommentCount;
- BYTE ApplicationCount;
- BYTE PlainTextCount;
- BYTE HDFPalette[256][3];
- BYTE HeaderDump[6]; /* BYTE array to dump header contents */
- BYTE LSDDump[7]; /* Logical Screen Descriptor dump */
+ GIFBYTE PackedField; /* 0Ah Color Information */
+ GIFWORD TableSize;
+ GIFBYTE ImageCount; /* Keep a count of the number of images */
+ GIFBYTE CommentCount;
+ GIFBYTE ApplicationCount;
+ GIFBYTE PlainTextCount;
+ GIFBYTE HDFPalette[256][3];
+ GIFBYTE HeaderDump[6]; /* GIFBYTE array to dump header contents */
+ GIFBYTE LSDDump[7]; /* Logical Screen Descriptor dump */
} GIFHEAD;
-
/*
** The GIF Image Descriptor.
*/
typedef struct _GifImageDescriptor {
- WORD ImageWidth; /* Width of the image in pixels */
- WORD ImageHeight; /* Height of the image in pixels */
- BYTE PackedField; /* Image and Color Table Data Information */
- WORD TableSize;
- WORD CodeSize; /* Minimum LZW CodeSize for image data */
- BYTE HDFPalette[256][3];
- BYTE GIDDump[9]; /* GifImageDescriptor dump */
-
- BYTE *Image; /* Decompressed Raster Image */
- BYTE *GIFImage;
+ GIFWORD ImageWidth; /* Width of the image in pixels */
+ GIFWORD ImageHeight; /* Height of the image in pixels */
+ GIFBYTE PackedField; /* Image and Color Table Data Information */
+ GIFWORD TableSize;
+ GIFWORD CodeSize; /* Minimum LZW CodeSize for image data */
+ GIFBYTE HDFPalette[256][3];
+ GIFBYTE GIDDump[9]; /* GifImageDescriptor dump */
+
+ GIFBYTE *Image; /* Decompressed Raster Image */
+ GIFBYTE *GIFImage;
} GIFIMAGEDESC;
/*
** GIF 89a Graphic Control Extension Block
*/
typedef struct _GifGraphicControlExtension {
- BYTE GCEDump[5]; /* Graphic Control Extension Dump */
+ GIFBYTE GCEDump[5]; /* Graphic Control Extension Dump */
} GIFGRAPHICCONTROL;
/*
** GIF 89a Plain Text Extension Block
*/
typedef struct _GifPlainTextExtension {
- BYTE PTEDump[15]; /* Plain Text Extension Dump */
- BYTE *PlainTextData; /* Plain Text data sub-blocks */
- WORD DataSize;
+ GIFBYTE PTEDump[15]; /* Plain Text Extension Dump */
+ GIFBYTE *PlainTextData; /* Plain Text data sub-blocks */
+ GIFWORD DataSize;
} GIFPLAINTEXT;
-
/*
** GIF 89a Application Extension Block
*/
typedef struct _GifApplicationExtension {
- BYTE AEDump[14]; /* Application Extension Dump */
- BYTE *ApplicationData; /* Application data sub-blocks */
- WORD DataSize;
+ GIFBYTE AEDump[14]; /* Application Extension Dump */
+ GIFBYTE *ApplicationData; /* Application data sub-blocks */
+ GIFWORD DataSize;
} GIFAPPLICATION;
/*
** GIF 89a Comment Extension Block
*/
typedef struct _GifCommentExtension {
- BYTE CEDump[2]; /* Comment Extension Dump */
- BYTE *CommentData; /* Comment data sub-blocks */
- WORD DataSize;
- BYTE Terminator; /* Block Terminator (always 0) */
+ GIFBYTE CEDump[2]; /* Comment Extension Dump */
+ GIFBYTE *CommentData; /* Comment data sub-blocks */
+ GIFWORD DataSize;
+ GIFBYTE Terminator; /* Block Terminator (always 0) */
} GIFCOMMENT;
/*
@@ -124,16 +129,16 @@ typedef struct _GifCommentExtension {
** in the HDF file.
** I have assumed that the ImageDescriptors and GraphicControls follow
** one another, ie. I have not associated them with each other. The driver
-** must assume a 1-1 correspondance. The same discussion with plain text
+** must assume a 1-1 correspondence. The same discussion with plain text
** extension.
*/
typedef struct _GifToMem {
- GIFHEAD *GifHeader;
- GIFIMAGEDESC **GifImageDesc;
- GIFGRAPHICCONTROL **GifGraphicControlExtension;
- GIFPLAINTEXT **GifPlainTextExtension;
- GIFAPPLICATION **GifApplicationExtension;
- GIFCOMMENT **GifCommentExtension;
+ GIFHEAD * GifHeader;
+ GIFIMAGEDESC ** GifImageDesc;
+ GIFGRAPHICCONTROL **GifGraphicControlExtension;
+ GIFPLAINTEXT ** GifPlainTextExtension;
+ GIFAPPLICATION ** GifApplicationExtension;
+ GIFCOMMENT ** GifCommentExtension;
} GIFTOMEM;
/*
@@ -141,40 +146,39 @@ typedef struct _GifToMem {
*/
/* GIF2MEM.C */
-int Gif2Mem(BYTE *, GIFTOMEM *);
+int Gif2Mem(GIFBYTE *, GIFTOMEM *);
/* GIFREAD.C */
-int ReadGifHeader(GIFHEAD *, BYTE **);
-int ReadGifImageDesc(GIFIMAGEDESC *, BYTE **);
-int ReadGifGraphicControl(GIFGRAPHICCONTROL *, BYTE **);
-int ReadGifPlainText(GIFPLAINTEXT *, BYTE **);
-int ReadGifApplication(GIFAPPLICATION *, BYTE **);
-int ReadGifComment(GIFCOMMENT *, BYTE **);
+int ReadGifHeader(GIFHEAD *, GIFBYTE **);
+int ReadGifImageDesc(GIFIMAGEDESC *, GIFBYTE **);
+int ReadGifGraphicControl(GIFGRAPHICCONTROL *, GIFBYTE **);
+int ReadGifPlainText(GIFPLAINTEXT *, GIFBYTE **);
+int ReadGifApplication(GIFAPPLICATION *, GIFBYTE **);
+int ReadGifComment(GIFCOMMENT *, GIFBYTE **);
/* HDFGIFWR.C */
-int hdfWriteGIF(FILE *fp, BYTE *pic, int ptype, int w, int h, BYTE *rmap,
- BYTE *gmap, BYTE *bmap, BYTE *pc2ncmap, int numcols,
- int colorstyle, int BitsPerPixel);
+int hdfWriteGIF(FILE *fp, GIFBYTE *pic, int ptype, int w, int h, const GIFBYTE *rmap, const GIFBYTE *gmap,
+ const GIFBYTE *bmap, const GIFBYTE *pc2ncmap, int numcols, int colorstyle, int BitsPerPixel);
/* WRITEHDF.C */
-int WriteHDF(GIFTOMEM , CHAR * );
+int WriteHDF(GIFTOMEM, GIFCHAR *);
/* Function: ReadHDF
** Return: 0 on completion without error, -1 on error
-** Input: CHAR *h5_file - HDF file name
-** CHAR *dset_name - Name of the HDF Image dataset
-** CHAR *pal_name - Name of the HDF palette
-** Output: BYTE* data - the HDF Image to be converted
-** BYTE palette[256][3] - the corresponding palette
+** Input: GIFCHAR *h5_file - HDF file name
+** GIFCHAR *dset_name - Name of the HDF Image dataset
+** GIFCHAR *pal_name - Name of the HDF palette
+** Output: GIFBYTE* data - the HDF Image to be converted
+** GIFBYTE palette[256][3] - the corresponding palette
** hsize_t* image_size - the size of each dimension of the image
*/
-int ReadHDF(BYTE** data, BYTE palette[256][3], hsize_t *image_size,
- CHAR *h5_file, CHAR *dset_name, CHAR *pal_name);
+int ReadHDF(GIFBYTE **data, GIFBYTE palette[256][3], hsize_t *image_size, GIFCHAR *h5_file,
+ GIFCHAR *dset_name, GIFCHAR *pal_name);
-BYTE *Decompress(GIFIMAGEDESC *, GIFHEAD *);
-BYTE GetByte(BYTE *);
-WORD GetWord(BYTE *);
+GIFBYTE *Decompress(GIFIMAGEDESC *, GIFHEAD *);
+GIFBYTE GetByte(const GIFBYTE *);
+GIFWORD GetWord(GIFBYTE *);
-void cleanup(BYTE*);
+void cleanup(GIFBYTE *);
-#endif /* GIF_H_ */
+#endif /* GIF_H_ */
diff --git a/hl/tools/gif2h5/gif2hdf.c b/hl/tools/gif2h5/gif2hdf.c
index 2e06d34..8de6d9a 100644
--- a/hl/tools/gif2h5/gif2hdf.c
+++ b/hl/tools/gif2h5/gif2hdf.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -18,11 +18,10 @@
#include "h5tools.h"
#include "h5tools_utils.h"
-
int
-main(int argv , char *argc[])
+main(int argv, char *argc[])
{
- GIFTOMEM GifMemoryStruct;
+ GIFTOMEM GifMemoryStruct;
GIFIMAGEDESC gifImageDesc;
FILE *fpGif;
@@ -31,8 +30,8 @@ main(int argv , char *argc[])
long i, ImageCount;
long filesize;
- BYTE *MemGif;
- BYTE *StartPos;
+ GIFBYTE *MemGif;
+ GIFBYTE *StartPos;
char *GIFFileName;
char *HDFFileName;
@@ -51,11 +50,9 @@ main(int argv , char *argc[])
/* Initialize h5tools lib */
h5tools_init();
- if ( argc[1] && (strcmp("-V",argc[1])==0) )
- {
+ if (argc[1] && (strcmp("-V", argc[1]) == 0)) {
print_version("gif2h5");
exit(EXIT_SUCCESS);
-
}
if (argv < 3) {
@@ -68,30 +65,30 @@ main(int argv , char *argc[])
GIFFileName = argc[1];
HDFFileName = argc[2];
- if (!(fpGif = fopen(GIFFileName,"rb"))) {
+ if (!(fpGif = fopen(GIFFileName, "rb"))) {
printf("Unable to open GIF file for reading.\n");
exit(EXIT_FAILURE);
}
/* Get the whole file into memory. Mem's much faster than I/O */
- fseek(fpGif, 0L , 2);
+ fseek(fpGif, 0L, 2);
filesize = ftell(fpGif);
- fseek(fpGif, 0L , 0);
+ fseek(fpGif, 0L, 0);
if (filesize == 0)
printf("File Size Zero");
- if (!(MemGif = StartPos = (BYTE *)malloc((size_t)filesize))) {
+ if (!(MemGif = StartPos = (GIFBYTE *)malloc((size_t)filesize))) {
printf("Out of memory");
exit(EXIT_FAILURE);
}
- if (fread(MemGif,(size_t)filesize,1,fpGif) != 1) {
+ if (fread(MemGif, (size_t)filesize, 1, fpGif) != 1) {
printf("Corrupted Input File");
exit(EXIT_FAILURE);
}
- fseek(fpGif,0L,0);
+ fseek(fpGif, 0L, 0);
/*
* Call Gif2Mem and break the whole file into parts. Gif2Mem also calls
@@ -100,8 +97,8 @@ main(int argv , char *argc[])
Gif2Mem(MemGif, &GifMemoryStruct);
if (ferror(fpGif)) {
- printf("File Stream Error\n\n");
- exit(EXIT_FAILURE);
+ printf("File Stream Error\n\n");
+ exit(EXIT_FAILURE);
}
fclose(fpGif);
@@ -110,54 +107,47 @@ main(int argv , char *argc[])
* Call WriteHDF from here. Go ahead and change WriteHDF to write whatever
* format you want
*/
- if (WriteHDF(GifMemoryStruct , HDFFileName))
+ if (WriteHDF(GifMemoryStruct, HDFFileName))
printf("HDF Write Error\n\n");
/* Free all buffers */
/* replacing int32 with long */
ImageCount = (long)((GifMemoryStruct.GifHeader)->ImageCount);
- for(i = 0; i < ImageCount ; i++) {
+ for (i = 0; i < ImageCount; i++) {
gifImageDesc = *(GifMemoryStruct.GifImageDesc[i]);
if (gifImageDesc.Image != NULL)
free(gifImageDesc.Image);
- if (GifMemoryStruct.GifImageDesc[i] != NULL)
- {
+ if (GifMemoryStruct.GifImageDesc[i] != NULL) {
free(GifMemoryStruct.GifImageDesc[i]);
GifMemoryStruct.GifImageDesc[i] = NULL;
}
- if (GifMemoryStruct.GifGraphicControlExtension[i] != NULL)
- {
+ if (GifMemoryStruct.GifGraphicControlExtension[i] != NULL) {
free(GifMemoryStruct.GifGraphicControlExtension[i]);
GifMemoryStruct.GifGraphicControlExtension[i] = NULL;
}
}
free(StartPos);
- if (GifMemoryStruct.GifHeader != NULL)
- {
+ if (GifMemoryStruct.GifHeader != NULL) {
free(GifMemoryStruct.GifHeader);
GifMemoryStruct.GifHeader = NULL;
}
- if (GifMemoryStruct.GifApplicationExtension != NULL)
- {
+ if (GifMemoryStruct.GifApplicationExtension != NULL) {
free(GifMemoryStruct.GifApplicationExtension);
GifMemoryStruct.GifApplicationExtension = NULL;
}
- if (GifMemoryStruct.GifImageDesc != NULL)
- {
+ if (GifMemoryStruct.GifImageDesc != NULL) {
free(GifMemoryStruct.GifImageDesc);
GifMemoryStruct.GifImageDesc = NULL;
}
- if (GifMemoryStruct.GifGraphicControlExtension != NULL)
- {
+ if (GifMemoryStruct.GifGraphicControlExtension != NULL) {
free(GifMemoryStruct.GifGraphicControlExtension);
GifMemoryStruct.GifGraphicControlExtension = NULL;
}
-
return EXIT_SUCCESS;
}
diff --git a/hl/tools/gif2h5/gif2mem.c b/hl/tools/gif2h5/gif2mem.c
index 8fb575c..44e18e0 100644
--- a/hl/tools/gif2h5/gif2mem.c
+++ b/hl/tools/gif2h5/gif2mem.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -36,35 +36,35 @@
#include "gif.h"
int
-Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
+Gif2Mem(GIFBYTE *MemGif, GIFTOMEM *GifMemoryStruct)
{
/*
* The gif structure outline for passing data to memory is given in gif.h.
- * These pointers are redunant, should take them out in ver. 2
+ * These pointers are redundant, should take them out in ver. 2
*/
- GIFHEAD *gifHead; /* GIF Header structure */
- GIFIMAGEDESC **gifImageDesc; /* Logical Image Descriptor struct */
- GIFPLAINTEXT **gifPlainText; /* Plain Text Extension structure */
- GIFAPPLICATION **gifApplication; /* Application Extension structure */
- GIFCOMMENT **gifComment; /* Comment Extension structure */
+ GIFHEAD * gifHead; /* GIF Header structure */
+ GIFIMAGEDESC ** gifImageDesc; /* Logical Image Descriptor struct */
+ GIFPLAINTEXT ** gifPlainText; /* Plain Text Extension structure */
+ GIFAPPLICATION ** gifApplication; /* Application Extension structure */
+ GIFCOMMENT ** gifComment; /* Comment Extension structure */
GIFGRAPHICCONTROL **gifGraphicControl; /* Graphic Control Extension strct */
- register WORD i; /* Loop counter */
- BYTE Identifier; /* Extension block identifier holder */
- BYTE Label; /* Extension block label holder */
- BYTE ImageCount; /* Count of the number of images in the file */
- BYTE ImageArray; /* Keep the size of the array to store Images */
- BYTE CommentCount;
- BYTE CommentArray;
- BYTE ApplicationCount;
- BYTE ApplicationArray;
- BYTE PlainTextCount;
- BYTE PlainTextArray;
- BYTE GCEflag;
- BYTE aTemp;
- BYTE j;
- BYTE w; /* Two more variables needed only while testing */
- BYTE *b; /* Endian Ordering */
+ GIFWORD i; /* Loop counter */
+ GIFBYTE Identifier; /* Extension block identifier holder */
+ GIFBYTE Label; /* Extension block label holder */
+ GIFBYTE ImageCount; /* Count of the number of images in the file */
+ GIFBYTE ImageArray; /* Keep the size of the array to store Images */
+ GIFBYTE CommentCount;
+ GIFBYTE CommentArray;
+ GIFBYTE ApplicationCount;
+ GIFBYTE ApplicationArray;
+ GIFBYTE PlainTextCount;
+ GIFBYTE PlainTextArray;
+ GIFBYTE GCEflag;
+ GIFBYTE aTemp;
+ GIFBYTE j;
+ GIFBYTE w; /* Two more variables needed only while testing */
+ GIFBYTE *b; /* Endian Ordering */
/* Allocate memory for the GIF structures */
/* Plug the structs into GifMemoryStruct at the end */
@@ -89,8 +89,8 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
/******************************/
/* Carry out Endian Testing and set Endian Order */
- w = 0x0001;
- b = (BYTE *) &w;
+ w = 0x0001;
+ b = (GIFBYTE *)&w;
EndianOrder = (b[0] ? 1 : 0);
/* Read the GIF image file header information */
@@ -103,22 +103,22 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
fputs("GIFHEAD: Error reading header information!\n", stderr);
exit(EXIT_FAILURE);
}
-#endif /* 0 */
+#endif /* 0 */
/*
* Identify, read, and display block information.
*/
- ImageCount = ImageArray = 0;
- CommentCount = CommentArray = 0;
+ ImageCount = ImageArray = 0;
+ CommentCount = CommentArray = 0;
ApplicationCount = ApplicationArray = 0;
- PlainTextCount = PlainTextArray = 0;
- GCEflag = 0;
+ PlainTextCount = PlainTextArray = 0;
+ GCEflag = 0;
for (;;) {
Identifier = *MemGif++;
switch (Identifier) {
- case 0x3B: /* Trailer */
+ case 0x3B: /* Trailer */
/*
* The counts are stored to make it easier while putting stuff
* into the HDF file and then deallocating space.
@@ -129,17 +129,17 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
gifHead->PlainTextCount = PlainTextCount;
/* putting stuff into the gif2mem structure */
- GifMemoryStruct->GifHeader = gifHead;
- GifMemoryStruct->GifImageDesc = gifImageDesc;
- GifMemoryStruct->GifPlainTextExtension = gifPlainText;
- GifMemoryStruct->GifApplicationExtension = gifApplication;
- GifMemoryStruct->GifCommentExtension = gifComment;
+ GifMemoryStruct->GifHeader = gifHead;
+ GifMemoryStruct->GifImageDesc = gifImageDesc;
+ GifMemoryStruct->GifPlainTextExtension = gifPlainText;
+ GifMemoryStruct->GifApplicationExtension = gifApplication;
+ GifMemoryStruct->GifCommentExtension = gifComment;
GifMemoryStruct->GifGraphicControlExtension = gifGraphicControl;
/* return the struct */
return 0;
- case 0x2C: /* Image Descriptor */
+ case 0x2C: /* Image Descriptor */
/*
* If there was no image descriptor before this increase image
* count. If an imagedescriptor was present, reset GCEflag
@@ -150,40 +150,37 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
GCEflag = 0;
if (ImageCount > ImageArray) {
- aTemp = ImageArray;
- ImageArray = (BYTE)((ImageArray << 1) + 1);
- if (!(gifImageDesc = (GIFIMAGEDESC **)realloc(gifImageDesc,
- sizeof(GIFIMAGEDESC *) * ImageArray))) {
+ aTemp = ImageArray;
+ ImageArray = (GIFBYTE)((ImageArray << 1) + 1);
+ if (!(gifImageDesc =
+ (GIFIMAGEDESC **)realloc(gifImageDesc, sizeof(GIFIMAGEDESC *) * ImageArray))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc(
- gifGraphicControl,
- sizeof(GIFGRAPHICCONTROL *) * ImageArray))) {
+ gifGraphicControl, sizeof(GIFGRAPHICCONTROL *) * ImageArray))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
- for (j = aTemp ; j < ImageArray ; j++) {
+ for (j = aTemp; j < ImageArray; j++) {
gifGraphicControl[j] = NULL;
- gifImageDesc[j] = NULL;
+ gifImageDesc[j] = NULL;
}
}
- if(!(gifImageDesc[ImageCount-1] = (GIFIMAGEDESC*)malloc(sizeof(GIFIMAGEDESC)))) {
+ if (!(gifImageDesc[ImageCount - 1] = (GIFIMAGEDESC *)malloc(sizeof(GIFIMAGEDESC)))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
-
- if (ReadGifImageDesc(gifImageDesc[ImageCount-1], &MemGif) == -1)
+ if (ReadGifImageDesc(gifImageDesc[ImageCount - 1], &MemGif) == -1)
fputs("Error reading Image Descriptor information\n", stderr);
/* Decompress the Image */
- gifImageDesc[ImageCount-1]->Image = Decompress(gifImageDesc[ImageCount-1],
- gifHead);
- free(gifImageDesc[ImageCount-1]->GIFImage);
+ gifImageDesc[ImageCount - 1]->Image = Decompress(gifImageDesc[ImageCount - 1], gifHead);
+ free(gifImageDesc[ImageCount - 1]->GIFImage);
/*
* Convert the local palette into an HDF compatible palette In
@@ -191,150 +188,146 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct)
* the HDFPalette If it is absent the global table is written
* as the HDFPalette.
*/
- if (!((gifImageDesc[ImageCount-1]->PackedField) & 0x80)) {
+ if (!((gifImageDesc[ImageCount - 1]->PackedField) & 0x80)) {
/* Check to see if the global color table exists.... */
if (gifHead->PackedField & 0x80) {
- for (i=0 ; i<gifHead->TableSize ; i++) {
- gifImageDesc[ImageCount-1]->HDFPalette[i][0] =
- gifHead->HDFPalette[i][0];
- gifImageDesc[ImageCount-1]->HDFPalette[i][1] =
- gifHead->HDFPalette[i][1];
- gifImageDesc[ImageCount-1]->HDFPalette[i][2] =
- gifHead->HDFPalette[i][2];
+ for (i = 0; i < gifHead->TableSize; i++) {
+ gifImageDesc[ImageCount - 1]->HDFPalette[i][0] = gifHead->HDFPalette[i][0];
+ gifImageDesc[ImageCount - 1]->HDFPalette[i][1] = gifHead->HDFPalette[i][1];
+ gifImageDesc[ImageCount - 1]->HDFPalette[i][2] = gifHead->HDFPalette[i][2];
}
}
- gifImageDesc[ImageCount-1]->TableSize = gifHead->TableSize;
+ gifImageDesc[ImageCount - 1]->TableSize = gifHead->TableSize;
}
break;
- case 0x21: /* Extension Block */
- Label = *MemGif++;
+ case 0x21: /* Extension Block */
+ Label = *MemGif++;
- switch (Label) {
- case 0x01: /* Plain Text Extension */
+ switch (Label) {
+ case 0x01: /* Plain Text Extension */
puts("Plain Text Extension\n");
PlainTextCount++;
if (PlainTextCount > PlainTextArray)
- PlainTextArray = (BYTE)((PlainTextArray << 1) + 1);
+ PlainTextArray = (GIFBYTE)((PlainTextArray << 1) + 1);
- if (!(gifPlainText = (GIFPLAINTEXT **)realloc(gifPlainText , sizeof(GIFPLAINTEXT *) * PlainTextArray))) {
+ if (!(gifPlainText = (GIFPLAINTEXT **)realloc(gifPlainText, sizeof(GIFPLAINTEXT *) *
+ PlainTextArray))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
- if(!(gifPlainText[PlainTextCount - 1] = (GIFPLAINTEXT*)malloc(sizeof(GIFPLAINTEXT)))) {
+ if (!(gifPlainText[PlainTextCount - 1] =
+ (GIFPLAINTEXT *)malloc(sizeof(GIFPLAINTEXT)))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
if (ReadGifPlainText(gifPlainText[PlainTextCount - 1], &MemGif))
- fprintf(stderr,
- "Error reading Plain Text Extension information.\n");
+ fprintf(stderr, "Error reading Plain Text Extension information.\n");
break;
- case 0xFE: /* Comment Extension */
+ case 0xFE: /* Comment Extension */
CommentCount++;
if (CommentCount > CommentArray)
- CommentArray = (BYTE)((CommentArray << 1) + 1);
+ CommentArray = (GIFBYTE)((CommentArray << 1) + 1);
- if (!(gifComment = (GIFCOMMENT **)realloc(gifComment , sizeof(GIFCOMMENT *) * CommentArray))) {
+ if (!(gifComment =
+ (GIFCOMMENT **)realloc(gifComment, sizeof(GIFCOMMENT *) * CommentArray))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
- if(!(gifComment[CommentCount - 1] = (GIFCOMMENT *)malloc(sizeof(GIFCOMMENT)))) {
+ if (!(gifComment[CommentCount - 1] = (GIFCOMMENT *)malloc(sizeof(GIFCOMMENT)))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
-
if (ReadGifComment(gifComment[CommentCount - 1], &MemGif))
- fprintf(stderr,
- "Error reading Comment Extension information\n");
+ fprintf(stderr, "Error reading Comment Extension information\n");
break;
- case 0xF9: /* Graphic Control Extension */
- if (GCEflag == 0 )
+ case 0xF9: /* Graphic Control Extension */
+ if (GCEflag == 0)
ImageCount++;
GCEflag = 1;
if (ImageCount > ImageArray) {
- aTemp = ImageArray;
- ImageArray = (BYTE)((ImageArray << 1) + 1);
+ aTemp = ImageArray;
+ ImageArray = (GIFBYTE)((ImageArray << 1) + 1);
- if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc(gifGraphicControl , sizeof(GIFGRAPHICCONTROL *) * ImageArray))) {
+ if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc(
+ gifGraphicControl, sizeof(GIFGRAPHICCONTROL *) * ImageArray))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
- if (!(gifImageDesc = (GIFIMAGEDESC **)realloc(gifImageDesc , sizeof(GIFIMAGEDESC *) * ImageArray))) {
+ if (!(gifImageDesc = (GIFIMAGEDESC **)realloc(
+ gifImageDesc, sizeof(GIFIMAGEDESC *) * ImageArray))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
- for (j = aTemp ; j < ImageArray ; j++) {
+ for (j = aTemp; j < ImageArray; j++) {
gifGraphicControl[j] = NULL;
gifImageDesc[j] = NULL;
}
}
- if(!(gifGraphicControl[ImageCount-1] = (GIFGRAPHICCONTROL*)malloc(sizeof(GIFGRAPHICCONTROL)))) {
+ if (!(gifGraphicControl[ImageCount - 1] =
+ (GIFGRAPHICCONTROL *)malloc(sizeof(GIFGRAPHICCONTROL)))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
-
- if (ReadGifGraphicControl(gifGraphicControl[ImageCount-1], &MemGif))
- fprintf(stderr,
- "Error reading Graphic Control Extension information\n");
+ if (ReadGifGraphicControl(gifGraphicControl[ImageCount - 1], &MemGif))
+ fprintf(stderr, "Error reading Graphic Control Extension information\n");
(*MemGif)++;
if ((!*MemGif) == 0)
- fprintf(stderr,
- "Error reading Graphic Control Extension\n");
+ fprintf(stderr, "Error reading Graphic Control Extension\n");
break;
- case 0xFF: /* Application Extension */
+ case 0xFF: /* Application Extension */
ApplicationCount++;
if (ApplicationCount > ApplicationArray)
- ApplicationArray = (BYTE)((ApplicationArray << 1) + 1);
+ ApplicationArray = (GIFBYTE)((ApplicationArray << 1) + 1);
- if (!(gifApplication = (GIFAPPLICATION **)realloc(gifApplication , sizeof(GIFAPPLICATION *) * ApplicationArray))) {
+ if (!(gifApplication = (GIFAPPLICATION **)realloc(
+ gifApplication, sizeof(GIFAPPLICATION *) * ApplicationArray))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
- if(!(gifApplication[ApplicationCount - 1] = (GIFAPPLICATION *)malloc(sizeof(GIFAPPLICATION)))) {
+ if (!(gifApplication[ApplicationCount - 1] =
+ (GIFAPPLICATION *)malloc(sizeof(GIFAPPLICATION)))) {
printf("Out of memory!");
exit(EXIT_FAILURE);
}
-
if (ReadGifApplication(gifApplication[ApplicationCount - 1], &MemGif))
- fprintf(stderr,
- "Error reading Application Extension information\n");
+ fprintf(stderr, "Error reading Application Extension information\n");
break;
default:
printf("Unknown Extension Label: %#02x\n", Label);
break;
- }
+ }
- break;
+ break;
default:
- fprintf(stderr,
- "Unknown Block Separator Character: %#02x\n", Identifier);
+ fprintf(stderr, "Unknown Block Separator Character: %#02x\n", Identifier);
}
}
}
diff --git a/hl/tools/gif2h5/gifread.c b/hl/tools/gif2h5/gifread.c
index 948e112..3a6bcae 100644
--- a/hl/tools/gif2h5/gifread.c
+++ b/hl/tools/gif2h5/gifread.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -17,59 +17,60 @@
int EndianOrder;
-static BYTE *ReadDataSubBlocks(BYTE **MemGif2, WORD *DSize);
+static GIFBYTE *ReadDataSubBlocks(GIFBYTE **MemGif2, GIFWORD *DSize);
-WORD
-GetWord(BYTE *MemGif)
+GIFWORD
+GetWord(GIFBYTE *MemGif)
{
- WORD w;
+ GIFWORD w;
if (EndianOrder == 1) {
/* LittleEndian */
- w = (WORD) (*MemGif++ & 0xFF);
- w |= (WORD) ((*MemGif++ & 0xFF) << 0x08);
- } else {
- w = (WORD) (*MemGif++ & 0xFF);
- w = ((WORD) (*MemGif++ & 0xFF)) | (w << 0x08);
+ w = (GIFWORD)(*MemGif++ & 0xFF);
+ w |= (GIFWORD)((*MemGif++ & 0xFF) << 0x08);
+ }
+ else {
+ w = (GIFWORD)(*MemGif++ & 0xFF);
+ w = ((GIFWORD)(*MemGif++ & 0xFF)) | (w << 0x08);
}
return w;
}
-BYTE
-GetByte(BYTE *MemGif)
+GIFBYTE
+GetByte(const GIFBYTE *MemGif)
{
return *MemGif;
}
/*
- * Read a GIF image BYTE Header.
+ * Read a GIF image GIFBYTE Header.
*
* This function reads the Header, Logical Screen Descriptor, and
* Global Color Table (if any) from a GIF image file. The information
* is stored in a GIFHEAD structure.
*
- * Returns: -1 if a FILE stream error occured during the read,
- * otherwise 0 if no error occured.
+ * Returns: -1 if a FILE stream error occurred during the read,
+ * otherwise 0 if no error occurred.
*/
int
-ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */
- BYTE **MemGif2) /* GIF image file input FILE stream */
+ReadGifHeader(GIFHEAD * GifHead, /* Pointer to GIF header structure */
+ GIFBYTE **MemGif2) /* GIF image file input FILE stream */
{
- WORD i; /* Loop counter */
- WORD tableSize; /* Number of entires in the Global Color Table */
+ GIFWORD i; /* Loop counter */
+ GIFWORD tableSize; /* Number of entries in the Global Color Table */
GifHead->TableSize = 0;
- for (i = 0 ; i < 6 ; i++) {
+ for (i = 0; i < 6; i++) {
GifHead->HeaderDump[i] = *(*MemGif2)++;
}
- if (strncmp((const char *)GifHead->HeaderDump , "GIF" , (size_t)3)) {
+ if (strncmp((const char *)GifHead->HeaderDump, "GIF", (size_t)3) != 0) {
printf("The file does not appear to be a valid GIF file.\n");
exit(EXIT_FAILURE);
}
- for (i = 0 ; i < 7 ; i++) {
+ for (i = 0; i < 7; i++) {
GifHead->LSDDump[i] = *(*MemGif2)++;
}
@@ -78,7 +79,7 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */
/* Check if a Global Color Table is present */
if (GifHead->PackedField & 0x80) {
/* Read number of color table entries */
- tableSize = (WORD) (1L << ((GifHead->PackedField & 0x07) + 1));
+ tableSize = (GIFWORD)(1L << ((GifHead->PackedField & 0x07) + 1));
GifHead->TableSize = tableSize;
/* Read the Global Color Table */
@@ -100,12 +101,11 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */
#if 0
if (ferror(FpGif))
return -1;
-#endif /* 0 */
+#endif /* 0 */
- return 0; /* No FILE stream error occured */
+ return 0; /* No FILE stream error occurred */
}
-
/*
** Read a GIF Local Image Descriptor.
**
@@ -116,225 +116,209 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */
** Note that the ImageSeparator field value in the GIFIMAGEDESC
** structure is assigned by the function calling ReadGifImageDesc().
**
-** Returns: -1 if a FILE stream error occured during the read,
-** otherwise 0 if no error occured.
+** Returns: -1 if a FILE stream error occurred during the read,
+** otherwise 0 if no error occurred.
*/
int
-ReadGifImageDesc(
- GIFIMAGEDESC *GifImageDesc, /* Pointer to GIF image descriptor structure */
- BYTE **MemGif2 /* GIF image file input FILE stream */
- )
+ReadGifImageDesc(GIFIMAGEDESC *GifImageDesc, /* Pointer to GIF image descriptor structure */
+ GIFBYTE ** MemGif2 /* GIF image file input FILE stream */
+)
{
- WORD i; /* Loop counter */
- WORD tableSize; /* Number of entries in the Local Color Table */
- /* BYTE Interlace; */ /* PackedField & 0x20 gives information on interlacing */
- BYTE *TempPtr;
- int ch , ch1;
-
- GifImageDesc->TableSize = 0;
- for (i = 0 ; i < 9 ; i++) {
- GifImageDesc->GIDDump[i] = *(*MemGif2)++;
- }
-
- /*
- ** Get the relevant fields. I need ImageWidth and Height actively hence I have
- ** taken information from those fields. I intend to keep the GifImageDesc data
- ** structure as it is so that anyone needing the rest of the fields can do so
- ** quickly.
- */
-
- if (EndianOrder == 1) /* LittleEndian */
- {
- GifImageDesc->ImageWidth = (WORD) (GifImageDesc->GIDDump[4] & 0xFF);
- GifImageDesc->ImageWidth |= (WORD) ((GifImageDesc->GIDDump[5] & 0xFF) << 0x08);
-
- GifImageDesc->ImageHeight = (WORD) (GifImageDesc->GIDDump[6] & 0xFF);
- GifImageDesc->ImageHeight |= (WORD) ((GifImageDesc->GIDDump[7] & 0xFF) << 0x08);
-
- }
- else
- {
- GifImageDesc->ImageWidth = (WORD) (GifImageDesc->GIDDump[4] & 0xFF);
- GifImageDesc->ImageWidth = ((WORD) (GifImageDesc->GIDDump[5] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08);
+ GIFWORD i; /* Loop counter */
+ GIFWORD tableSize; /* Number of entries in the Local Color Table */
+ /* GIFBYTE Interlace; */ /* PackedField & 0x20 gives information on interlacing */
+ GIFBYTE *TempPtr;
+ int ch, ch1;
+
+ GifImageDesc->TableSize = 0;
+ for (i = 0; i < 9; i++) {
+ GifImageDesc->GIDDump[i] = *(*MemGif2)++;
+ }
- GifImageDesc->ImageHeight = (WORD) (GifImageDesc->GIDDump[6] & 0xFF);
- GifImageDesc->ImageHeight = ((WORD) (GifImageDesc->GIDDump[7] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08);
+ /*
+ ** Get the relevant fields. I need ImageWidth and Height actively hence I have
+ ** taken information from those fields. I intend to keep the GifImageDesc data
+ ** structure as it is so that anyone needing the rest of the fields can do so
+ ** quickly.
+ */
+ if (EndianOrder == 1) /* LittleEndian */
+ {
+ GifImageDesc->ImageWidth = (GIFWORD)(GifImageDesc->GIDDump[4] & 0xFF);
+ GifImageDesc->ImageWidth |= (GIFWORD)((GifImageDesc->GIDDump[5] & 0xFF) << 0x08);
- }
+ GifImageDesc->ImageHeight = (GIFWORD)(GifImageDesc->GIDDump[6] & 0xFF);
+ GifImageDesc->ImageHeight |= (GIFWORD)((GifImageDesc->GIDDump[7] & 0xFF) << 0x08);
+ }
+ else {
+ GifImageDesc->ImageWidth = (GIFWORD)(GifImageDesc->GIDDump[4] & 0xFF);
+ GifImageDesc->ImageWidth =
+ ((GIFWORD)(GifImageDesc->GIDDump[5] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08);
+
+ GifImageDesc->ImageHeight = (GIFWORD)(GifImageDesc->GIDDump[6] & 0xFF);
+ GifImageDesc->ImageHeight =
+ ((GIFWORD)(GifImageDesc->GIDDump[7] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08);
+ }
- GifImageDesc->PackedField = GifImageDesc->GIDDump[8];
+ GifImageDesc->PackedField = GifImageDesc->GIDDump[8];
- /* Interlace = GifImageDesc->PackedField & 0x20; */
+ /* Interlace = GifImageDesc->PackedField & 0x20; */
/* Check if a Local Color Table is present */
- if (GifImageDesc->PackedField & 0x80)
- {
+ if (GifImageDesc->PackedField & 0x80) {
/* Read number of color table entries */
- tableSize = (WORD) (1L << ((GifImageDesc->PackedField & 0x07) + 1));
- GifImageDesc->TableSize = tableSize;
+ tableSize = (GIFWORD)(1L << ((GifImageDesc->PackedField & 0x07) + 1));
+ GifImageDesc->TableSize = tableSize;
/* Read the Local Color Table */
- for (i = 0; i < tableSize; i++)
- {
+ for (i = 0; i < tableSize; i++) {
GifImageDesc->HDFPalette[i][0] = *(*MemGif2)++;
GifImageDesc->HDFPalette[i][1] = *(*MemGif2)++;
GifImageDesc->HDFPalette[i][2] = *(*MemGif2)++;
}
}
- /*
- ** Get LZW minimum Code Size
- */
- GifImageDesc->CodeSize = (WORD)*(*MemGif2)++;
-
- /*GifImageDesc->GIFImage = ReadDataSubBlocks(FpGif);*/
- if (!(GifImageDesc->GIFImage = (BYTE *)malloc((GifImageDesc->ImageWidth) * (GifImageDesc->ImageHeight)))) {
- printf("Out of memory");
- exit(EXIT_FAILURE);
- }
-
-
- TempPtr = GifImageDesc->GIFImage;
- do
- {
- ch = ch1 = (int)*(*MemGif2)++;
- while (ch--) *TempPtr++ = *(*MemGif2)++;
- }
- while (ch1);
+ /*
+ ** Get LZW minimum Code Size
+ */
+ GifImageDesc->CodeSize = (GIFWORD) * (*MemGif2)++;
+
+ /*GifImageDesc->GIFImage = ReadDataSubBlocks(FpGif);*/
+ if (!(GifImageDesc->GIFImage =
+ (GIFBYTE *)malloc((GifImageDesc->ImageWidth) * (GifImageDesc->ImageHeight)))) {
+ printf("Out of memory");
+ exit(EXIT_FAILURE);
+ }
+ TempPtr = GifImageDesc->GIFImage;
+ do {
+ ch = ch1 = (int)*(*MemGif2)++;
+ while (ch--)
+ *TempPtr++ = *(*MemGif2)++;
+ } while (ch1);
- return(0); /* No FILE stream error occured */
+ return (0); /* No FILE stream error occurred */
}
-
/*
** Read a GIF Graphic Control Extension block.
**
** Note that the Introducer and Label field values in the GIFGRAPHICCONTROL
** structure are assigned by the function calling ReadGifGraphicControl().
**
-** Returns: -1 if a FILE stream error occured during the read,
-** otherwise 0 if no error occured.
+** Returns: -1 if a FILE stream error occurred during the read,
+** otherwise 0 if no error occurred.
*/
int
-ReadGifGraphicControl(
- GIFGRAPHICCONTROL *GifGraphicControl, /* Pointer to GC Extension structure */
- BYTE **MemGif2 /* GIF image file input FILE stream */
- )
+ReadGifGraphicControl(GIFGRAPHICCONTROL *GifGraphicControl, /* Pointer to GC Extension structure */
+ GIFBYTE ** MemGif2 /* GIF image file input FILE stream */
+)
{
int i;
- for (i = 0 ; i < 5 ; i++) {
- GifGraphicControl->GCEDump[i] = *(*MemGif2)++;
+ for (i = 0; i < 5; i++) {
+ GifGraphicControl->GCEDump[i] = *(*MemGif2)++;
}
- return(0); /* No FILE stream error occured */
+ return (0); /* No FILE stream error occurred */
}
-
/*
** Read a GIF Plain Text Extension block.
**
** Note that the Introducer and Label field values in the GIFLPLAINTEXT
** structure are assigned by the function calling ReadGifPlainText().
**
-** Returns: -1 if a FILE stream error occured during the read,
-** otherwise 0 if no error occured.
+** Returns: -1 if a FILE stream error occurred during the read,
+** otherwise 0 if no error occurred.
*/
int
-ReadGifPlainText(
- GIFPLAINTEXT *GifPlainText, /* Pointer to Plain Text Extension structure */
- BYTE **MemGif2 /* GIF image file input FILE stream */
- )
+ReadGifPlainText(GIFPLAINTEXT *GifPlainText, /* Pointer to Plain Text Extension structure */
+ GIFBYTE ** MemGif2 /* GIF image file input FILE stream */
+)
{
int i;
- for (i = 0 ; i < 13 ; i++) {
- GifPlainText->PTEDump[i] = *(*MemGif2)++;
- }
+ for (i = 0; i < 13; i++) {
+ GifPlainText->PTEDump[i] = *(*MemGif2)++;
+ }
/* Read in the Plain Text data sub-blocks */
- if (!(GifPlainText->PlainTextData = ReadDataSubBlocks(MemGif2 , &(GifPlainText->DataSize))))
- return(1);
+ if (!(GifPlainText->PlainTextData = ReadDataSubBlocks(MemGif2, &(GifPlainText->DataSize))))
+ return (1);
/*
GifPlainText->Terminator = 0;
*/
/* Check for a FILE stream error */
- /*
- if (ferror(FpGif))
- return(-1);
- */
+ /*
+ if (ferror(FpGif))
+ return(-1);
+ */
- return(0); /* No FILE stream error occured */
+ return (0); /* No FILE stream error occurred */
}
-
/*
** Read a GIF Application Extension block.
**
** Note that the Introducer and Label field values in the GIFAPPLICATION
** structure are assigned by the function calling ReadGifApplication().
**
-** Returns: -1 if a FILE stream error occured during the read,
-** otherwise 0 if no error occured.
+** Returns: -1 if a FILE stream error occurred during the read,
+** otherwise 0 if no error occurred.
*/
int
-ReadGifApplication(
- GIFAPPLICATION *GifApplication, /* Pointer to Application Extension structure */
- BYTE **MemGif2 /* GIF image file input FILE stream */
- )
+ReadGifApplication(GIFAPPLICATION *GifApplication, /* Pointer to Application Extension structure */
+ GIFBYTE ** MemGif2 /* GIF image file input FILE stream */
+)
{
int i;
- for (i = 0 ; i < 12 ; i++) {
- GifApplication->AEDump[i] = *(*MemGif2)++;
- }
+ for (i = 0; i < 12; i++) {
+ GifApplication->AEDump[i] = *(*MemGif2)++;
+ }
/* Read in the Plain Text data sub-blocks */
- if (!(GifApplication->ApplicationData = ReadDataSubBlocks(MemGif2 , &(GifApplication->DataSize))))
- return(1);
- /*
- GifApplication->Terminator = 0;
- */
+ if (!(GifApplication->ApplicationData = ReadDataSubBlocks(MemGif2, &(GifApplication->DataSize))))
+ return (1);
+ /*
+ GifApplication->Terminator = 0;
+ */
- /* Check for a FILE stream error */
- /*
- if (ferror(FpGif))
- return(-1);
- */
+ /* Check for a FILE stream error */
+ /*
+ if (ferror(FpGif))
+ return(-1);
+ */
- return(0); /* No FILE stream error occured */
+ return (0); /* No FILE stream error occurred */
}
-
/*
** Read a GIF Comment Extension block.
**
** Note that the Introducer and Label field values in the GIFCOMMENT
** structure are assigned by the function calling ReadGifComment().
**
-** Returns: -1 if a FILE stream error occured during the read,
-** otherwise 0 if no error occured.
+** Returns: -1 if a FILE stream error occurred during the read,
+** otherwise 0 if no error occurred.
*/
int
-ReadGifComment(
- GIFCOMMENT *GifComment, /* Pointer to GIF Comment Extension structure */
- BYTE **MemGif2 /* GIF image file input FILE stream */
- )
+ReadGifComment(GIFCOMMENT *GifComment, /* Pointer to GIF Comment Extension structure */
+ GIFBYTE ** MemGif2 /* GIF image file input FILE stream */
+)
{
/* Read in the Plain Text data sub-blocks */
- if (!(GifComment->CommentData = ReadDataSubBlocks(MemGif2 , &(GifComment->DataSize))))
- return(1);
+ if (!(GifComment->CommentData = ReadDataSubBlocks(MemGif2, &(GifComment->DataSize))))
+ return (1);
GifComment->Terminator = 0;
- return(0); /* No FILE stream error occured */
+ return (0); /* No FILE stream error occurred */
}
-
/*
** Read one or more GIF data sub-blocks and write the information
** to a buffer.
@@ -342,60 +326,52 @@ ReadGifComment(
** A GIF "sub-block" is a single count byte followed by 1 to 255
** additional data bytes.
**
-** Returns: A NULL pointer if a memory allocation error occured,
-** otherwise a valid pointer if no error occured.
+** Returns: A NULL pointer if a memory allocation error occurred,
+** otherwise a valid pointer if no error occurred.
*/
-static BYTE *
-ReadDataSubBlocks(BYTE **MemGif2, /* GIF image file input FILE stream */
- WORD *DSize)
+static GIFBYTE *
+ReadDataSubBlocks(GIFBYTE **MemGif2, /* GIF image file input FILE stream */
+ GIFWORD * DSize)
{
- BYTE *ptr1; /* Pointer used to "walk the heap" */
- BYTE *ptr2; /* Pointer used to mark the top of the heap */
- BYTE dataSize; /* Size of the current data sub-block being read */
- WORD bufSize; /* Total size of the Plain Text data buffer */
- int tempcount = 0;
+ GIFBYTE *ptr1; /* Pointer used to "walk the heap" */
+ GIFBYTE *ptr2; /* Pointer used to mark the top of the heap */
+ GIFBYTE dataSize; /* Size of the current data sub-block being read */
+ GIFWORD bufSize; /* Total size of the Plain Text data buffer */
+ int tempcount = 0;
- bufSize = 0; /* The output buffer is empty */
+ bufSize = 0; /* The output buffer is empty */
- dataSize = *(*MemGif2)++; /* Get the size of the first sub-block */
+ dataSize = *(*MemGif2)++; /* Get the size of the first sub-block */
/* Allocate initial data buffer */
- if (!(ptr1 = ptr2 = (BYTE *) malloc((size_t)dataSize + 1))) {
- printf("Out of memory. Allocation of memory for data sub-blocks for\neither Comment, Plain Text or Application Extensions failed");
- return((BYTE *) NULL);
- }
- for (;;)
- {
- tempcount++;
- bufSize += (dataSize); /* Running total of the buffer size */
- *DSize = bufSize;
+ if (!(ptr1 = ptr2 = (GIFBYTE *)malloc((size_t)dataSize + 1))) {
+ printf("Out of memory. Allocation of memory for data sub-blocks for\neither Comment, Plain Text or "
+ "Application Extensions failed");
+ return ((GIFBYTE *)NULL);
+ }
+ for (;;) {
+ tempcount++;
+ bufSize += (dataSize); /* Running total of the buffer size */
+ *DSize = bufSize;
#ifdef COMMENTED_OUT
- *ptr1++ = dataSize; /* Write the data count */
-#endif /* COMMENTED_OUT */
- while (dataSize--) /* Read/write the Plain Text data */
- *ptr1++ = *(*MemGif2)++;
+ *ptr1++ = dataSize; /* Write the data count */
+#endif /* COMMENTED_OUT */
+ while (dataSize--) /* Read/write the Plain Text data */
+ *ptr1++ = *(*MemGif2)++;
/* Check if there is another data sub-block */
if ((dataSize = *(*MemGif2)++) == 0)
- break; /* Block Terminator encountered */
-
- /* Increase the buffer size to accomodate the next sub-block */
- if (!(ptr1 = ptr2 = (BYTE *) realloc(ptr2, bufSize + dataSize + 1)))
- return((BYTE *) NULL);
-
-
- ptr1 += bufSize; /* Move pointer to the end of the data */
+ break; /* Block Terminator encountered */
+ /* Increase the buffer size to accommodate the next sub-block */
+ if (!(ptr1 = ptr2 = (GIFBYTE *)realloc(ptr2, bufSize + dataSize + 1)))
+ return ((GIFBYTE *)NULL);
+ ptr1 += bufSize; /* Move pointer to the end of the data */
}
*ptr1++ = '\0';
- return(ptr2); /* Return a pointer to the sub-block data */
+ return (ptr2); /* Return a pointer to the sub-block data */
}
-
-
-
-
-
diff --git a/hl/tools/gif2h5/h52gifgentst.c b/hl/tools/gif2h5/h52gifgentst.c
index 655563c..ba2e4f5 100644
--- a/hl/tools/gif2h5/h52gifgentst.c
+++ b/hl/tools/gif2h5/h52gifgentst.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -22,7 +22,7 @@
*
* Purpose: generate files for h52gif testing
*
- * Programmer: Pedro Vicente, pvn@hdfgroup.org
+ * Programmer: Pedro Vicente
*
* Date: March 15, 2007
*
@@ -30,11 +30,11 @@
*/
#define FILENAME "h52giftst.h5"
-#define WIDTH 400
-#define HEIGHT 200
-#define PAL_ENTRIES 256
-#define IMAGE1_NAME "image"
-#define PAL_NAME "palette"
+#define WIDTH 400
+#define HEIGHT 200
+#define PAL_ENTRIES 256
+#define IMAGE1_NAME "image"
+#define PAL_NAME "palette"
/*-------------------------------------------------------------------------
* Function: main
@@ -44,65 +44,61 @@
*-------------------------------------------------------------------------
*/
-int main(void)
+int
+main(void)
{
- hid_t fid;
- int i, j, n, space;
+ hid_t fid;
+ int i, j, n, space;
unsigned char *buf;
- unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */
- hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */
- hsize_t width = WIDTH;
- hsize_t height = HEIGHT;
+ unsigned char pal[PAL_ENTRIES * 3]; /* palette array */
+ hsize_t pal_dims[2] = {PAL_ENTRIES, 3}; /* palette dimensions */
+ hsize_t width = WIDTH;
+ hsize_t height = HEIGHT;
/* Allocate buffer */
- if(NULL == (buf = (unsigned char *)malloc(WIDTH * HEIGHT)))
+ if (NULL == (buf = (unsigned char *)malloc(WIDTH * HEIGHT)))
return EXIT_FAILURE;
/* create a file */
- if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0)
+ if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
return EXIT_FAILURE;
/* create an image */
- space = WIDTH*HEIGHT / PAL_ENTRIES;
- for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ )
- {
+ space = WIDTH * HEIGHT / PAL_ENTRIES;
+ for (i = 0, j = 0, n = 0; i < WIDTH * HEIGHT; i++, j++) {
buf[i] = (unsigned char)n;
- if ( j > space )
- {
+ if (j > space) {
n++;
- j=0;
+ j = 0;
}
-
}
/* make the image */
- if (H5IMmake_image_8bit( fid, IMAGE1_NAME, width, height, buf )<0)
+ if (H5IMmake_image_8bit(fid, IMAGE1_NAME, width, height, buf) < 0)
return EXIT_FAILURE;
- /*-------------------------------------------------------------------------
- * define a palette, blue to red tones
- *-------------------------------------------------------------------------
- */
- for ( i=0, n=0; i<PAL_ENTRIES*3; i+=3, n++)
- {
- pal[i] = (unsigned char)n; /* red */
- pal[i+1] = (unsigned char)0; /* green */
- pal[i+2] = (unsigned char)(255-n); /* blue */
+ /*-------------------------------------------------------------------------
+ * define a palette, blue to red tones
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0, n = 0; i < PAL_ENTRIES * 3; i += 3, n++) {
+ pal[i] = (unsigned char)n; /* red */
+ pal[i + 1] = (unsigned char)0; /* green */
+ pal[i + 2] = (unsigned char)(255 - n); /* blue */
}
/* make a palette */
- if (H5IMmake_palette( fid, PAL_NAME, pal_dims, pal )<0)
+ if (H5IMmake_palette(fid, PAL_NAME, pal_dims, pal) < 0)
return EXIT_FAILURE;
/* attach the palette to the image */
- if (H5IMlink_palette( fid, IMAGE1_NAME, PAL_NAME )<0)
+ if (H5IMlink_palette(fid, IMAGE1_NAME, PAL_NAME) < 0)
return EXIT_FAILURE;
- if(H5Fclose(fid)<0)
+ if (H5Fclose(fid) < 0)
return EXIT_FAILURE;
free(buf);
return EXIT_SUCCESS;
}
-
diff --git a/hl/tools/gif2h5/h52giftest.sh.in b/hl/tools/gif2h5/h52giftest.sh.in
index 5643e30..4f4057f 100644
--- a/hl/tools/gif2h5/h52giftest.sh.in
+++ b/hl/tools/gif2h5/h52giftest.sh.in
@@ -7,7 +7,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
@@ -46,7 +46,7 @@ TOOLTEST()
# Verify the test runs with failure (return code is not 0)
# Use for testing if tool can handle error conditions like
-# illegal input, bad arguments, exeeding limits, ...
+# illegal input, bad arguments, exceeding limits, ...
TOOLTESTFAIL()
{
# for now, discard any error messages generated.
@@ -70,20 +70,20 @@ echo ""
# Positive tests for h52gif
echo "**validate the h52gif tool processes input correctly..."
-TESTING "./h52gif h52giftst.h5 image1.gif -i image"
+TESTING "./h52gif h52giftst.h5 image1.gif -i image"
TOOLTEST ./h52gif $TESTFILE1 image1.gif -i image
echo ""
# Negative tests.
echo "**verify that the h52gif tool handles error conditions correctly..."
# nonexisting dataset name
-TESTING "./h52gif h52giftst.h5 image.gif -i nosuch_image"
-TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i nosuch_image"
+TESTING "./h52gif h52giftst.h5 image.gif -i nosuch_image"
+TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i nosuch_image"
# this test should have failed but it did not. Comment it out for now.
-#TESTING "./h52gif h52giftst.h5 image.gif -i palette"
-#TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i palette"
-TESTING "./h52gif h52giftst.h5 image24.gif -i image24bitpixel"
-TOOLTESTFAIL "./h52gif $TESTFILE3 image24.gif -i image24bitpixel"
+#TESTING "./h52gif h52giftst.h5 image.gif -i palette"
+#TOOLTESTFAIL "./h52gif $TESTFILE1 image.gif -i palette"
+TESTING "./h52gif h52giftst.h5 image24.gif -i image24bitpixel"
+TOOLTESTFAIL "./h52gif $TESTFILE3 image24.gif -i image24bitpixel"
echo ""
# all done. summarize results.
diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c
index ae63e92..d14a4cb 100644
--- a/hl/tools/gif2h5/hdf2gif.c
+++ b/hl/tools/gif2h5/hdf2gif.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -18,9 +18,11 @@
#include "h5tools.h"
#include "h5tools_utils.h"
-#define IMAGE_WIDTH_MAX 65535 /* unsigned 16bits integer */
-#define IMAGE_HEIGHT_MAX 65535 /* unsigned 16bits integer */
+/* Name of tool */
+#define PROGRAMNAME "hdf2gif"
+#define IMAGE_WIDTH_MAX 65535 /* unsigned 16bits integer */
+#define IMAGE_HEIGHT_MAX 65535 /* unsigned 16bits integer */
int EndianOrder;
@@ -28,8 +30,8 @@ static void
putword(int w, FILE *fp)
{
/* writes a 16-bit integer in GIF order (LSB first) */
- fputc(w &0xff, fp);
- fputc((w>>8)&0xff,fp);
+ fputc(w & 0xff, fp);
+ fputc((w >> 8) & 0xff, fp);
}
static void
@@ -39,79 +41,77 @@ usage(void)
fprintf(stdout, " h52gif -V \n");
fprintf(stdout, " Print HDF5 library version and exit\n");
printf("h52gif expects *at least* one h5_image.\n");
+}
+static void
+leave(int ret)
+{
+ h5tools_close();
+ HDexit(ret);
}
FILE *fpGif = NULL;
-int main(int argc , char **argv)
+int
+main(int argc, char **argv)
{
- BYTE *Image;
- void *edata;
- H5E_auto2_t func;
+ GIFBYTE *Image;
/* compression structs */
- CHAR *HDFName = NULL;
- CHAR *GIFName = NULL;
+ GIFCHAR *HDFName = NULL;
+ GIFCHAR *GIFName = NULL;
- BYTE* b;
+ GIFBYTE *b;
- BYTE GlobalPalette[256][3];
- BYTE Red[256];
- BYTE Green[256];
- BYTE Blue[256];
+ GIFBYTE GlobalPalette[256][3];
+ GIFBYTE Red[256];
+ GIFBYTE Green[256];
+ GIFBYTE Blue[256];
- int RWidth, RHeight;
- int ColorMapSize, InitCodeSize, Background, BitsPerPixel;
- int j,nc;
- int i;
- int numcols = 0;
+ int RWidth, RHeight;
+ int ColorMapSize, InitCodeSize, Background, BitsPerPixel;
+ int j, nc;
+ int i;
+ int numcols = 0;
- BYTE pc2nc[256] , r1[256] , g1[256] , b1[256];
+ GIFBYTE pc2nc[256], r1[256], g1[256], b1[256];
- int arg_index = 2;
- int bool_is_image = 0; /* 0 = false , 1 = true */
- char *image_name = NULL;
- int idx;
+ int arg_index = 2;
+ int bool_is_image = 0; /* 0 = false , 1 = true */
+ char *image_name = NULL;
+ int idx;
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
/* Initialize h5tools lib */
h5tools_init();
- if ( argv[1] && (strcmp("-V",argv[1])==0) )
- {
+ if (argv[1] && (strcmp("-V", argv[1]) == 0)) {
print_version("gif2h5");
- exit(EXIT_SUCCESS);
-
+ h5tools_setstatus(EXIT_SUCCESS);
}
-
- if (argc < 4)
- {
+ if (argc < 4) {
/* they didn't supply at least one image -- bail */
usage();
- return EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
HDFName = argv[1];
GIFName = argv[2];
/* get the options */
- while (arg_index++ < argc - 1)
- {
- if (!strcmp(argv[arg_index] , "-i")) {
+ while (arg_index++ < argc - 1) {
+ if (!strcmp(argv[arg_index], "-i")) {
bool_is_image = 1;
continue;
}
- if (bool_is_image)
- {
+ if (bool_is_image) {
/* allocate space to store the image name */
size_t len = strlen(argv[arg_index]);
- image_name = (CHAR*) malloc( len + 1);
- strcpy(image_name , argv[arg_index]);
+ image_name = (GIFCHAR *)malloc(len + 1);
+ strcpy(image_name, argv[arg_index]);
bool_is_image = 0;
continue;
@@ -123,69 +123,72 @@ int main(int argc , char **argv)
goto out;
}
- /* Do Endian Order testing and set Endian Order */
- idx = 0x0001;
- b = (BYTE *) &idx;
- EndianOrder = (b[0] ? 1:0);
+ /* Do Endian Order testing and set Endian Order */
+ idx = 0x0001;
+ b = (GIFBYTE *)&idx;
+ EndianOrder = (b[0] ? 1 : 0);
- if (!(fpGif = fopen(GIFName , "wb")))
- {
+ if (!(fpGif = fopen(GIFName, "wb"))) {
printf("Error opening gif file for output. Aborting.\n");
goto out;
}
Background = 0;
{
- hsize_t width, height, planes;
- hid_t fid;
- char interlace[20];
- hssize_t npals;
- hsize_t pal_dims[2];
+ hsize_t width, height, planes;
+ hid_t fid;
+ char interlace[20];
+ hssize_t npals;
+ hsize_t pal_dims[2];
unsigned char *pal;
- if ((fid = H5Fopen(HDFName , H5F_ACC_RDONLY , H5P_DEFAULT)) < 0)
- {
- fprintf(stderr , "Unable to open HDF file for input. Aborting.\n");
+ if ((fid = H5Fopen(HDFName, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) {
+ fprintf(stderr, "Unable to open HDF file for input. Aborting.\n");
goto out;
}
- /* read image */
- if ( H5IMget_image_info( fid, image_name, &width, &height, &planes, interlace, &npals ) < 0 )
+ /* get image's information */
+ if (H5IMget_image_info(fid, image_name, &width, &height, &planes, interlace, &npals) < 0) {
+ fprintf(stderr, "Unable to get information of the image. Aborting.\n");
goto out;
+ }
- if (width > IMAGE_WIDTH_MAX || height > IMAGE_HEIGHT_MAX){
- fprintf(stderr, "HDF5 image is too large. Limit is %d by %d.\n", IMAGE_WIDTH_MAX, IMAGE_HEIGHT_MAX);
- goto out;
- }
+ if (width > IMAGE_WIDTH_MAX || height > IMAGE_HEIGHT_MAX) {
+ fprintf(stderr, "HDF5 image is too large. Limit is %d by %d.\n", IMAGE_WIDTH_MAX,
+ IMAGE_HEIGHT_MAX);
+ goto out;
+ }
- /* tool can handle single plane images only. */
- if (planes > 1){
- fprintf(stderr, "Cannot handle multiple planes image\n");
- goto out;
- }
+ /* tool can handle single plane images only. */
+ if (planes > 1) {
+ fprintf(stderr, "Cannot handle multiple planes image\n");
+ goto out;
+ }
- Image = (BYTE*) malloc( (size_t) width * (size_t) height );
+ Image = (GIFBYTE *)malloc((size_t)width * (size_t)height);
- if ( H5IMread_image( fid, image_name, Image ) < 0 )
+ if (H5IMread_image(fid, image_name, Image) < 0) {
+ fprintf(stderr, "Unable to read the image. Aborting.\n");
goto out;
+ }
- if (npals)
- {
- if ( H5IMget_palette_info( fid, image_name, 0, pal_dims ) < 0 )
+ if (npals) {
+ if (H5IMget_palette_info(fid, image_name, 0, pal_dims) < 0) {
+ fprintf(stderr, "Unable to get information of the palette. Aborting.\n");
goto out;
+ }
- pal = (BYTE*) malloc( (size_t) pal_dims[0] * (size_t) pal_dims[1] );
+ pal = (GIFBYTE *)malloc((size_t)pal_dims[0] * (size_t)pal_dims[1]);
- if ( H5IMget_palette( fid, image_name, 0, pal ) < 0 )
+ if (H5IMget_palette(fid, image_name, 0, pal) < 0)
goto out;
- numcols = (int) pal_dims[0];
+ numcols = (int)pal_dims[0];
- for (i = 0, j = 0 ; i < numcols ; j+=3, i++)
- {
+ for (i = 0, j = 0; i < numcols; j += 3, i++) {
GlobalPalette[i][0] = pal[j];
- GlobalPalette[i][1] = pal[j+1];
- GlobalPalette[i][2] = pal[j+2];
+ GlobalPalette[i][1] = pal[j + 1];
+ GlobalPalette[i][2] = pal[j + 2];
}
free(pal);
@@ -196,7 +199,6 @@ int main(int argc , char **argv)
RWidth = (int)width;
RHeight = (int)height;
-
/*
* If the first image does not have a palette, I make my own global
* color table Obviously this is not the best thing to do, better
@@ -206,62 +208,52 @@ int main(int argc , char **argv)
* palette
* 2. Check for palettes in any of the other images.
*/
- if (!npals)
- {
+ if (!npals) {
numcols = 256;
- for (i = 0 ; i < numcols ; i++)
- {
- Red[i] = (BYTE)(255 - i);
- Green[i] = (BYTE)(255 - i);
- Blue[i] = (BYTE)(255 - i);
+ for (i = 0; i < numcols; i++) {
+ Red[i] = (GIFBYTE)(255 - i);
+ Green[i] = (GIFBYTE)(255 - i);
+ Blue[i] = (GIFBYTE)(255 - i);
}
}
- else
- {
- for (i = 0 ; i < numcols ; i++)
- {
- Red[i] = GlobalPalette[i][0];
+ else {
+ for (i = 0; i < numcols; i++) {
+ Red[i] = GlobalPalette[i][0];
Green[i] = GlobalPalette[i][1];
- Blue[i] = GlobalPalette[i][2];
+ Blue[i] = GlobalPalette[i][2];
}
}
- for (i = 0; i < numcols; i++)
- {
+ for (i = 0; i < numcols; i++) {
pc2nc[i] = r1[i] = g1[i] = b1[i] = 0;
}
/* compute number of unique colors */
nc = 0;
- for (i = 0; i < numcols; i++)
- {
+ for (i = 0; i < numcols; i++) {
/* see if color #i is already used */
- for (j = 0; j < i; j++)
- {
+ for (j = 0; j < i; j++) {
if (Red[i] == Red[j] && Green[i] == Green[j] && Blue[i] == Blue[j])
break;
}
- if (j==i)
- {
+ if (j == i) {
/* wasn't found */
- pc2nc[i] = (BYTE)nc;
- r1[nc] = Red[i];
- g1[nc] = Green[i];
- b1[nc] = Blue[i];
+ pc2nc[i] = (GIFBYTE)nc;
+ r1[nc] = Red[i];
+ g1[nc] = Green[i];
+ b1[nc] = Blue[i];
nc++;
}
- else
- {
+ else {
pc2nc[i] = pc2nc[j];
}
}
/* figure out 'BitsPerPixel' */
- for (i = 1; i < 8; i++)
- {
- if ((1<<i) >= nc)
+ for (i = 1; i < 8; i++) {
+ if ((1 << i) >= nc)
break;
}
@@ -273,59 +265,54 @@ int main(int argc , char **argv)
else
InitCodeSize = BitsPerPixel;
- if (!fpGif)
- {
- fprintf(stderr, "WriteGIF: file not open for writing\n" );
+ if (!fpGif) {
+ fprintf(stderr, "WriteGIF: file not open for writing\n");
goto out;
}
+ fwrite("GIF87a", sizeof(char), 6, fpGif); /* the GIF magic number */
- fwrite("GIF87a", sizeof( char ), 6, fpGif); /* the GIF magic number */
-
- putword(RWidth, fpGif); /* screen descriptor */
+ putword(RWidth, fpGif); /* screen descriptor */
putword(RHeight, fpGif);
- i = 0x00; /* No, there is no color map */
- i |= (8-1)<<4; /* OR in the color resolution (hardwired 8) */
- i |= (BitsPerPixel - 1); /* OR in the # of bits per pixel */
- fputc(i,fpGif);
-
- fputc(Background,fpGif); /* background color */
- fputc(0, fpGif); /* future expansion byte */
+ i = 0x00; /* No, there is no color map */
+ i |= (8 - 1) << 4; /* OR in the color resolution (hardwired 8) */
+ i |= (BitsPerPixel - 1); /* OR in the # of bits per pixel */
+ fputc(i, fpGif);
+ fputc(Background, fpGif); /* background color */
+ fputc(0, fpGif); /* future expansion byte */
/*
* Put Image Descriptor
* Hardwiring Left Offset and Top Offset to 0x00
*/
- fputc(0x2c , fpGif);
- putword(0x00 , fpGif);
- putword(0x00 , fpGif);
- putword(RWidth , fpGif);
- putword(RHeight , fpGif);
+ fputc(0x2c, fpGif);
+ putword(0x00, fpGif);
+ putword(0x00, fpGif);
+ putword(RWidth, fpGif);
+ putword(RHeight, fpGif);
/* since we always have a local color palette ... */
- fputc((0x80 | (BitsPerPixel - 1)) , fpGif);
+ fputc((0x80 | (BitsPerPixel - 1)), fpGif);
- for (i = 0; i < ColorMapSize; i++)
- {
+ for (i = 0; i < ColorMapSize; i++) {
/* write out Global colormap */
fputc(r1[i], fpGif);
fputc(g1[i], fpGif);
fputc(b1[i], fpGif);
}
- fputc(InitCodeSize , fpGif);
+ fputc(InitCodeSize, fpGif);
- i = hdfWriteGIF(fpGif , Image , 0 , RHeight , RWidth , r1, g1 , b1 , pc2nc , 256 , 8 , BitsPerPixel);
+ i = hdfWriteGIF(fpGif, Image, 0, RHeight, RWidth, r1, g1, b1, pc2nc, 256, 8, BitsPerPixel);
fputc(0x00, fpGif);
free(Image);
}
- if (fputc(';',fpGif) == EOF)
- {
+ if (fputc(';', fpGif) == EOF) {
/* Write GIF file terminator */
- fprintf(stderr , "Error!");
+ fprintf(stderr, "Error!");
goto out;
}
@@ -334,10 +321,7 @@ int main(int argc , char **argv)
if (image_name != NULL)
free(image_name);
- H5Eset_auto2(H5E_DEFAULT, func, edata);
-
- return EXIT_SUCCESS;
-
+ leave(h5tools_getstatus());
out:
@@ -346,7 +330,6 @@ out:
if (image_name != NULL)
free(image_name);
- H5Eset_auto2(H5E_DEFAULT, func, edata);
-
- return EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
+ leave(h5tools_getstatus());
}
diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c
index 6f5ab58..7126da9 100644
--- a/hl/tools/gif2h5/hdfgifwr.c
+++ b/hl/tools/gif2h5/hdfgifwr.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -44,14 +44,13 @@
* Joe Orost (decvax!vax135!petsd!joe)
*****************************************************************/
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gif.h"
-typedef BYTE byte;
+typedef GIFBYTE byte;
typedef long int count_int;
#ifdef __STDC__
@@ -65,71 +64,32 @@ static void flush_char(void);
#else
static void compress(), output(), cl_block(), cl_hash();
static void char_init(), char_out(), flush_char();
-#endif /* __STDC__ */
+#endif /* __STDC__ */
static byte pc2nc[256];
-/*************************************************************/
-int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap,
- byte *gmap, byte *bmap, byte *pc2ncmap, int numcols,
- int colorstyle, int BitsPerPixel)
-{
- int InitCodeSize;
- int i;
- byte *pic8 = pic;
-
- /* Shut compiler up... */
- ptype=ptype;
- rmap=rmap;
- gmap=gmap;
- bmap=bmap;
- numcols=numcols;
- colorstyle=colorstyle;
-
- for (i = 0; i < 256; i++) {
- pc2nc[i] = pc2ncmap[i];
- }
-
- if (BitsPerPixel <= 1)
- InitCodeSize = 2;
- else
- InitCodeSize = BitsPerPixel;
-
- if (!fp) {
- fprintf(stderr, "WriteGIF: file not open for writing\n" );
- return (1);
- }
-
- compress(InitCodeSize+1, fp, pic8, w*h);
-
- if (ferror(fp))
- return -1;
-
- return 0 ;
-}
-
/***********************************************************************/
static unsigned long cur_accum = 0;
-static int cur_bits = 0;
+static int cur_bits = 0;
-#define MAXCODE(n_bits) ( (1 << (n_bits)) - 1)
-#define XV_BITS 12 /* BITS was already defined on some systems */
-#define HSIZE 5003 /* 80% occupancy */
+#define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
+#define XV_BITS 12 /* BITS was already defined on some systems */
+#define HSIZE 5003 /* 80% occupancy */
-typedef unsigned char char_type;
+typedef unsigned char char_type;
static int n_bits; /* number of bits/code */
static int maxbits = XV_BITS; /* user settable max # bits/code */
static int maxcode; /* maximum code, given n_bits */
static int maxmaxcode = 1 << XV_BITS; /* NEVER generate this */
-static count_int htab [HSIZE];
-static unsigned short codetab [HSIZE];
+static count_int * htab;
+static unsigned short *codetab;
-#define HashTabOf(i) htab[i]
-#define CodeTabOf(i) codetab[i]
+#define HashTabOf(i) htab[i]
+#define CodeTabOf(i) codetab[i]
-static int hsize = HSIZE; /* for dynamic table sizing */
+static int hsize = HSIZE; /* for dynamic table sizing */
/*
* To save much memory, we overlay the table used by compress() with those
@@ -140,7 +100,7 @@ static int hsize = HSIZE; /* for dynamic table sizing */
* used to be 8000 characters).
*/
-static int free_ent = 0; /* first unused entry */
+static int free_ent = 0; /* first unused entry */
/*
* block compression parameters -- after all codes are used up,
@@ -148,8 +108,8 @@ static int free_ent = 0; /* first unused entry */
*/
static int clear_flg = 0;
-static long int in_count = 1; /* length of input */
-static long int out_count = 0; /* # of codes output (for debugging) */
+static long int in_count = 1; /* length of input */
+static long int out_count = 0; /* # of codes output (for debugging) */
/*
* compress stdin to stdout
@@ -167,22 +127,74 @@ static long int out_count = 0; /* # of codes output (for debugging) */
* about this implementation to ames!jaw.
*/
-static int g_init_bits;
+static int g_init_bits;
static FILE *g_outfile;
static int ClearCode;
static int EOFCode;
+/*************************************************************/
+int
+hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, const byte *rmap, const byte *gmap,
+ const byte *bmap, const byte *pc2ncmap, int numcols, int colorstyle, int BitsPerPixel)
+{
+ int InitCodeSize;
+ int i;
+ byte *pic8 = pic;
+
+ if (!(htab = calloc(HSIZE, sizeof(count_int)))) {
+ fprintf(stderr, "Out of memory");
+ return 1;
+ }
+ if (!(codetab = calloc(HSIZE, sizeof(unsigned short)))) {
+ fprintf(stderr, "Out of memory");
+ return 1;
+ }
+
+ /* Shut compiler up... */
+ (void)ptype;
+ (void)rmap;
+ (void)gmap;
+ (void)bmap;
+ (void)numcols;
+ (void)colorstyle;
+
+ for (i = 0; i < 256; i++) {
+ pc2nc[i] = pc2ncmap[i];
+ }
+
+ if (BitsPerPixel <= 1)
+ InitCodeSize = 2;
+ else
+ InitCodeSize = BitsPerPixel;
+
+ if (!fp) {
+ fprintf(stderr, "WriteGIF: file not open for writing\n");
+ return 1;
+ }
+
+ compress(InitCodeSize + 1, fp, pic8, w * h);
+
+ free(htab);
+ free(codetab);
+
+ if (ferror(fp))
+ return -1;
+
+ return 0;
+}
+
/********************************************************/
-static void compress(int init_bits, FILE *outfile, byte *data, int len)
+static void
+compress(int init_bits, FILE *outfile, byte *data, int len)
{
- register long fcode;
- register int i = 0;
- register int c;
- register int ent;
- register int disp;
- register int hsize_reg;
- register int hshift;
+ long fcode;
+ int i = 0;
+ int c;
+ int ent;
+ int disp;
+ int hsize_reg;
+ int hshift;
/*
* Set up the globals: g_init_bits - initial number of bits g_outfile -
@@ -192,40 +204,38 @@ static void compress(int init_bits, FILE *outfile, byte *data, int len)
g_outfile = outfile;
/* initialize 'compress' globals */
- maxbits = XV_BITS;
- maxmaxcode = 1<<XV_BITS;
- memset(htab, 0, sizeof(htab));
- memset(codetab, 0, sizeof(codetab));
- hsize = HSIZE;
- free_ent = 0;
- clear_flg = 0;
- in_count = 1;
- out_count = 0;
- cur_accum = 0;
- cur_bits = 0;
+ maxbits = XV_BITS;
+ maxmaxcode = 1 << XV_BITS;
+ hsize = HSIZE;
+ free_ent = 0;
+ clear_flg = 0;
+ in_count = 1;
+ out_count = 0;
+ cur_accum = 0;
+ cur_bits = 0;
/* Set up the necessary values */
out_count = 0;
clear_flg = 0;
- in_count = 1;
- maxcode = MAXCODE(n_bits = g_init_bits);
+ in_count = 1;
+ maxcode = MAXCODE(n_bits = g_init_bits);
ClearCode = (1 << (init_bits - 1));
- EOFCode = ClearCode + 1;
- free_ent = ClearCode + 2;
+ EOFCode = ClearCode + 1;
+ free_ent = ClearCode + 2;
char_init();
ent = pc2nc[*data++];
len--;
hshift = 0;
- for (fcode = (long)hsize; fcode < 65536L; fcode *= 2L )
+ for (fcode = (long)hsize; fcode < 65536L; fcode *= 2L)
hshift++;
hshift = 8 - hshift; /* set hash code range bound */
hsize_reg = hsize;
- cl_hash( (count_int) hsize_reg); /* clear hash table */
+ cl_hash((count_int)hsize_reg); /* clear hash table */
output(ClearCode);
@@ -234,32 +244,33 @@ static void compress(int init_bits, FILE *outfile, byte *data, int len)
len--;
in_count++;
- fcode = (long)(((long) c << maxbits) + ent);
- i = (((int) c << hshift) ^ ent); /* xor hashing */
+ fcode = (long)(((long)c << maxbits) + ent);
+ i = (((int)c << hshift) ^ ent); /* xor hashing */
- if ( HashTabOf (i) == fcode ) {
- ent = CodeTabOf (i);
+ if (HashTabOf(i) == fcode) {
+ ent = CodeTabOf(i);
continue;
- } else if ( (long)HashTabOf (i) < 0) {
+ }
+ else if ((long)HashTabOf(i) < 0) {
/* empty slot */
goto nomatch;
}
- disp = hsize_reg - i; /* secondary hash (after G. Knott) */
+ disp = hsize_reg - i; /* secondary hash (after G. Knott) */
- if ( i == 0 )
+ if (i == 0)
disp = 1;
probe:
if ((i -= disp) < 0)
i += hsize_reg;
- if (HashTabOf (i) == fcode) {
- ent = CodeTabOf (i);
+ if (HashTabOf(i) == fcode) {
+ ent = CodeTabOf(i);
continue;
}
- if ((long)HashTabOf (i) >= 0)
+ if ((long)HashTabOf(i) >= 0)
goto probe;
nomatch:
@@ -268,9 +279,10 @@ nomatch:
ent = c;
if (free_ent < maxmaxcode) {
- CodeTabOf (i) = (unsigned short)free_ent++; /* code -> hashtable */
- HashTabOf (i) = fcode;
- } else {
+ CodeTabOf(i) = (unsigned short)free_ent++; /* code -> hashtable */
+ HashTabOf(i) = fcode;
+ }
+ else {
cl_block();
}
}
@@ -281,7 +293,6 @@ nomatch:
output(EOFCode);
}
-
/*****************************************************************
* TAG( output )
*
@@ -299,11 +310,8 @@ nomatch:
* code in turn. When the buffer fills up empty it and start over.
*/
-static
-unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F,
- 0x001F, 0x003F, 0x007F, 0x00FF,
- 0x01FF, 0x03FF, 0x07FF, 0x0FFF,
- 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
+static unsigned long masks[] = {0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF,
+ 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF};
static void
output(int code)
@@ -317,8 +325,8 @@ output(int code)
cur_bits += n_bits;
- while( cur_bits >= 8 ) {
- char_out( (int)((unsigned int) cur_accum & 0xff) );
+ while (cur_bits >= 8) {
+ char_out((int)((unsigned int)cur_accum & 0xff));
cur_accum >>= 8;
cur_bits -= 8;
}
@@ -329,12 +337,13 @@ output(int code)
*/
if (free_ent > maxcode || clear_flg) {
if (clear_flg) {
- maxcode = MAXCODE (n_bits = g_init_bits);
+ maxcode = MAXCODE(n_bits = g_init_bits);
clear_flg = 0;
- } else {
+ }
+ else {
n_bits++;
- if ( n_bits == maxbits )
+ if (n_bits == maxbits)
maxcode = maxmaxcode;
else
maxcode = MAXCODE(n_bits);
@@ -343,17 +352,17 @@ output(int code)
if (code == EOFCode) {
/* At EOF, write the rest of the buffer */
- while( cur_bits > 0 ) {
- char_out( (int)((unsigned int)cur_accum & 0xff) );
+ while (cur_bits > 0) {
+ char_out((int)((unsigned int)cur_accum & 0xff));
cur_accum >>= 8;
cur_bits -= 8;
}
flush_char();
- fflush( g_outfile );
+ fflush(g_outfile);
#ifdef FOO
- if(ferror( g_outfile))
+ if (ferror(g_outfile))
FatalError("unable to write GIF file");
#endif
}
@@ -361,45 +370,45 @@ output(int code)
/********************************/
static void
-cl_block(void) /* table clear for block compress */
+cl_block(void) /* table clear for block compress */
{
/* Clear out the hash table */
- cl_hash((count_int) hsize);
- free_ent = ClearCode + 2;
+ cl_hash((count_int)hsize);
+ free_ent = ClearCode + 2;
clear_flg = 1;
output(ClearCode);
}
/********************************/
static void
-cl_hash(count_int hashsize) /* reset code table */
+cl_hash(count_int hashsize) /* reset code table */
{
- count_int *htab_p = htab+hashsize;
- long i, m1 = -1;
+ count_int *htab_p = htab + hashsize;
+ long i, m1 = -1;
i = hashsize - 16;
- do { /* might use Sys V memset(3) here */
- *(htab_p-16) = m1;
- *(htab_p-15) = m1;
- *(htab_p-14) = m1;
- *(htab_p-13) = m1;
- *(htab_p-12) = m1;
- *(htab_p-11) = m1;
- *(htab_p-10) = m1;
- *(htab_p-9) = m1;
- *(htab_p-8) = m1;
- *(htab_p-7) = m1;
- *(htab_p-6) = m1;
- *(htab_p-5) = m1;
- *(htab_p-4) = m1;
- *(htab_p-3) = m1;
- *(htab_p-2) = m1;
- *(htab_p-1) = m1;
+ do { /* might use Sys V memset(3) here */
+ *(htab_p - 16) = m1;
+ *(htab_p - 15) = m1;
+ *(htab_p - 14) = m1;
+ *(htab_p - 13) = m1;
+ *(htab_p - 12) = m1;
+ *(htab_p - 11) = m1;
+ *(htab_p - 10) = m1;
+ *(htab_p - 9) = m1;
+ *(htab_p - 8) = m1;
+ *(htab_p - 7) = m1;
+ *(htab_p - 6) = m1;
+ *(htab_p - 5) = m1;
+ *(htab_p - 4) = m1;
+ *(htab_p - 3) = m1;
+ *(htab_p - 2) = m1;
+ *(htab_p - 1) = m1;
htab_p -= 16;
} while ((i -= 16) >= 0);
- for ( i += 16; i > 0; i-- )
+ for (i += 16; i > 0; i--)
*--htab_p = m1;
}
@@ -426,7 +435,7 @@ char_init(void)
/*
* Define the storage for the packet accumulator
*/
-static char accum[ 256 ];
+static char accum[256];
/*
* Add a character to the end of the current packet, and if it is 254
@@ -435,7 +444,7 @@ static char accum[ 256 ];
static void
char_out(int c)
{
- accum[ a_count++ ] = (char)c;
+ accum[a_count++] = (char)c;
if (a_count >= 254)
flush_char();
@@ -448,8 +457,8 @@ static void
flush_char(void)
{
if (a_count > 0) {
- fputc( a_count, g_outfile );
- fwrite( accum, (size_t)1, (size_t)a_count, g_outfile);
+ fputc(a_count, g_outfile);
+ fwrite(accum, (size_t)1, (size_t)a_count, g_outfile);
a_count = 0;
}
}
diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c
index b656c36..b49e2a6 100644
--- a/hl/tools/gif2h5/writehdf.c
+++ b/hl/tools/gif2h5/writehdf.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -27,7 +27,7 @@
* Programmer: Unknown
*
* Modifications: pvn
- * Use the HDF5 IMAGE API to write the HDF5 image and pallete
+ * Use the HDF5 IMAGE API to write the HDF5 image and palette
*
* Date: January, 31, 2006
*
@@ -37,21 +37,21 @@
int
WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName)
{
- GIFHEAD gifHead; /* GIF Header structure */
- GIFIMAGEDESC *gifImageDesc; /* Logical Image Descriptor struct */
- int has_pal=0;
+ GIFHEAD gifHead; /* GIF Header structure */
+ GIFIMAGEDESC *gifImageDesc; /* Logical Image Descriptor struct */
+ int has_pal = 0;
- long ImageCount; /* number of images */
+ long ImageCount; /* number of images */
#ifdef UNUSED
- long CommentCount, /* number of comments */
- ApplicationCount, /* number of application extensions */
- PlainTextCount; /* number of plain text extensions */
-#endif /* UNUSED */
+ long CommentCount, /* number of comments */
+ ApplicationCount, /* number of application extensions */
+ PlainTextCount; /* number of plain text extensions */
+#endif /* UNUSED */
- char ImageName[256]; /* Image name for the Image */
+ char ImageName[256]; /* Image name for the Image */
/* H5 variables */
- hid_t file_id; /* H5 file id */
+ hid_t file_id; /* H5 file id */
/* temp counter */
int i;
@@ -62,35 +62,36 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName)
/* get some data from gifHead */
ImageCount = gifHead.ImageCount;
#ifdef UNUSED
- CommentCount = (WORD)gifHead.CommentCount;
- ApplicationCount = (WORD)gifHead.ApplicationCount;
- PlainTextCount = (WORD)gifHead.PlainTextCount;
+ CommentCount = (GIFWORD)gifHead.CommentCount;
+ ApplicationCount = (GIFWORD)gifHead.ApplicationCount;
+ PlainTextCount = (GIFWORD)gifHead.PlainTextCount;
#endif /* UNUSED */
- if ((file_id = H5Fcreate(HDFName , H5F_ACC_TRUNC , H5P_DEFAULT , H5P_DEFAULT)) < 0) {
- /* error occured opening the HDF File for write */
- fprintf(stderr , "HDF file could not be opened for writing\n");
- fprintf(stderr , "NOTE: GIF file must be present in the same directory as the binary on UNIX systems.\n");
+ if ((file_id = H5Fcreate(HDFName, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
+ /* error occurred opening the HDF File for write */
+ fprintf(stderr, "HDF file could not be opened for writing\n");
+ fprintf(stderr,
+ "NOTE: GIF file must be present in the same directory as the binary on UNIX systems.\n");
exit(1);
}
/* first create the global palette if there is one */
if (gifHead.PackedField & 0x80) { /* global palette exists */
- hsize_t dims[2]; /* specify the dimensions of the palette */
+ hsize_t dims[2]; /* specify the dimensions of the palette */
/* size of the palette is tablesize (rows) X 3 (columns) */
dims[0] = gifHead.TableSize;
dims[1] = 3;
/* make a palette */
- if (H5IMmake_palette(file_id,PAL_NAME,dims,(unsigned char *)gifHead.HDFPalette)<0)
- return -1;
+ if (H5IMmake_palette(file_id, PAL_NAME, dims, (unsigned char *)gifHead.HDFPalette) < 0)
+ return -1;
- has_pal=1;
+ has_pal = 1;
}
- for(i = 0; i < ImageCount; i++) {
- hsize_t dims[2]; /* dimensions for the dataset */
+ for (i = 0; i < ImageCount; i++) {
+ hsize_t dims[2]; /* dimensions for the dataset */
/* get the gifImageDesc */
gifImageDesc = GifMemoryStruct.GifImageDesc[i];
@@ -99,26 +100,24 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName)
dims[1] = gifImageDesc->ImageWidth;
/* create the image name */
- sprintf(ImageName , "Image%d" , i);
+ snprintf(ImageName, sizeof(ImageName), "Image%d", i);
/* write image */
- if (H5IMmake_image_8bit(file_id,ImageName,dims[1],dims[0],(gifImageDesc->Image))<0)
- return -1;
+ if (H5IMmake_image_8bit(file_id, ImageName, dims[1], dims[0], (gifImageDesc->Image)) < 0)
+ return -1;
/* attach the palette to the image dataset */
- if (has_pal)
- {
- if (H5IMlink_palette(file_id,ImageName,PAL_NAME)<0)
+ if (has_pal) {
+ if (H5IMlink_palette(file_id, ImageName, PAL_NAME) < 0)
return -1;
}
}
/* close the H5 file */
if (H5Fclose(file_id) < 0) {
- fprintf(stderr , "Could not close HDF5 file. Aborting...\n");
+ fprintf(stderr, "Could not close HDF5 file. Aborting...\n");
return -1;
}
return 0;
}
-
diff --git a/hl/tools/h5watch/CMakeLists.txt b/hl/tools/h5watch/CMakeLists.txt
index b3d65f7..1ab473d 100644
--- a/hl/tools/h5watch/CMakeLists.txt
+++ b/hl/tools/h5watch/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.10)
+cmake_minimum_required (VERSION 3.12)
project (HDF5_HL_TOOLS_H5WATCH C)
#-----------------------------------------------------------------------------
@@ -11,7 +11,8 @@ set (H5WATCH_SOURCES
#-- Add h5watch program
if (NOT ONLY_SHARED_LIBS)
add_executable (h5watch ${H5WATCH_SOURCES})
- target_include_directories (h5watch PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5watch PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (h5watch PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5watch STATIC)
target_link_libraries (h5watch PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
set_target_properties (h5watch PROPERTIES FOLDER tools/hl)
@@ -19,35 +20,33 @@ if (NOT ONLY_SHARED_LIBS)
endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5watch-shared ${H5WATCH_SOURCES})
- target_include_directories (h5watch-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5watch-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (h5watch-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5watch-shared SHARED)
target_link_libraries (h5watch-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET})
set_target_properties (h5watch-shared PROPERTIES FOLDER tools/hl)
set (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} h5watch-shared)
endif ()
-if (BUILD_TESTING)
- #-- Add swmr_check_compat_vfd program
- set (hl_swmr_check_compat_vfd_SOURCES
- ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/swmr_check_compat_vfd.c
- )
- add_executable (hl_swmr_check_compat_vfd ${hl_swmr_check_compat_vfd_SOURCES})
- target_include_directories (hl_swmr_check_compat_vfd PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+#-----------------------------------------------------------------------------
+# Add Target to clang-format
+#-----------------------------------------------------------------------------
+if (HDF5_ENABLE_FORMATTERS)
if (NOT ONLY_SHARED_LIBS)
- TARGET_C_PROPERTIES (hl_swmr_check_compat_vfd STATIC)
- target_link_libraries (hl_swmr_check_compat_vfd PRIVATE ${HDF5_LIB_TARGET})
+ clang_format (HDF5_HL_TOOLS_H5WATCH_FORMAT h5watch)
else ()
- TARGET_C_PROPERTIES (hl_swmr_check_compat_vfd SHARED)
- target_link_libraries (hl_swmr_check_compat_vfd PRIVATE ${HDF5_LIBSH_TARGET})
+ clang_format (HDF5_HL_TOOLS_H5WATCH_FORMAT h5watch-shared)
endif ()
- set_target_properties (hl_swmr_check_compat_vfd PROPERTIES FOLDER tools/hl)
+endif ()
+if (BUILD_TESTING AND HDF5_TEST_SWMR AND HDF5_TEST_SERIAL)
#-- Add extend_dset program
set (extend_dset_SOURCES
${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/extend_dset.c
)
add_executable (extend_dset ${extend_dset_SOURCES})
- target_include_directories (extend_dset PRIVATE "${HDF5_HL_SRC_DIR}/test;${HDF5_HL_SRC_DIR}/src;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(extend_dset PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (extend_dset PRIVATE "${HDF5_HL_SRC_DIR}/test;${HDF5_HL_SRC_DIR}/src;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
if (NOT ONLY_SHARED_LIBS)
TARGET_C_PROPERTIES (extend_dset STATIC)
target_link_libraries (extend_dset PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET})
@@ -57,8 +56,16 @@ if (BUILD_TESTING)
endif ()
set_target_properties (extend_dset PROPERTIES FOLDER tools/hl)
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_HL_TOOLS_H5WATCH_extend_dset_FORMAT extend_dset)
+ endif ()
+
add_executable (h5watchgentest ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/h5watchgentest.c)
- target_include_directories (h5watchgentest PRIVATE "${HDF5_HL_SRC_DIR}/src;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5watchgentest PRIVATE "${HDF5_CMAKE_C_FLAGS}")
+ target_include_directories (h5watchgentest PRIVATE "${HDF5_HL_SRC_DIR}/src;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
if (NOT ONLY_SHARED_LIBS)
TARGET_C_PROPERTIES (h5watchgentest STATIC)
target_link_libraries (h5watchgentest PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET})
@@ -68,7 +75,16 @@ if (BUILD_TESTING)
endif ()
set_target_properties (h5watchgentest PROPERTIES FOLDER generator/tools/hl)
- include (CMakeTests.cmake)
+ #-----------------------------------------------------------------------------
+ # Add Target to clang-format
+ #-----------------------------------------------------------------------------
+ if (HDF5_ENABLE_FORMATTERS)
+ clang_format (HDF5_HL_TOOLS_H5WATCH_h5watchgentest_FORMAT h5watchgentest)
+ endif ()
+
+ if (HDF5_TEST_TOOLS)
+ include (CMakeTests.cmake)
+ endif ()
endif ()
#-----------------------------------------------------------------------------
diff --git a/hl/tools/h5watch/CMakeTests.cmake b/hl/tools/h5watch/CMakeTests.cmake
index 0424140..b2f689b 100644
--- a/hl/tools/h5watch/CMakeTests.cmake
+++ b/hl/tools/h5watch/CMakeTests.cmake
@@ -5,7 +5,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
@@ -68,19 +68,13 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes
##############################################################################
##############################################################################
- if (NOT BUILD_SHARED_LIBS)
- set (tgt_ext "")
- else ()
- set (tgt_ext "-shared")
- endif ()
-
macro (ADD_H5_TEST resultfile resultcode)
if (NOT HDF5_ENABLE_USING_MEMCHECKER)
add_test (
NAME H5WATCH_ARGS-h5watch-${resultfile}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
- -D "TEST_PROGRAM=$<TARGET_FILE:h5watch${tgt_ext}>"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5watch${tgt_file_ext}>"
-D "TEST_ARGS:STRING=${ARGN}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
-D "TEST_OUTPUT=${resultfile}.out"
@@ -102,7 +96,7 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes
NAME H5WATCH_ARGS-h5watch-${resultfile}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
- -D "TEST_PROGRAM=$<TARGET_FILE:h5watch${tgt_ext}>"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5watch${tgt_file_ext}>"
-D "TEST_ARGS:STRING=${ARGN}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
-D "TEST_OUTPUT=${resultfile}.out"
@@ -131,7 +125,7 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes
NAME H5WATCH-${resultfile}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
- -D "TEST_PROGRAM=$<TARGET_FILE:h5watch${tgt_ext}>"
+ -D "TEST_PROGRAM=$<TARGET_FILE:h5watch${tgt_file_ext}>"
-D "TEST_ARGS:STRING=${ARGN}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles"
-D "TEST_OUTPUT=${resultfile}.out"
@@ -155,18 +149,22 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes
# Check to see if the VFD specified by the HDF5_DRIVER environment variable
# supports SWMR.
-set (SWMR_INCOMPAT ${hl_swmr_check_compat_vfd})
+add_test (
+ NAME H5WATCH-SWMR_INCOMPAT
+ COMMAND swmr_check_compat_vfd
+)
+set_tests_properties (H5WATCH-SWMR_INCOMPAT PROPERTIES FIXTURES_SETUP swmr_vfd_check_compat)
-if (NOT SWMR_INCOMPAT)
# Remove any output file left over from previous test run
- add_test (
- NAME H5WATCH-clearall-objects
- COMMAND ${CMAKE_COMMAND} -E remove WATCH.h5
- )
- if (last_test)
- set_tests_properties (H5WATCH-clearall-objects PROPERTIES DEPENDS ${last_test})
- endif ()
- set (last_test "H5WATCH-clearall-objects")
+add_test (
+ NAME H5WATCH-clearall-objects
+ COMMAND ${CMAKE_COMMAND} -E remove WATCH.h5
+)
+set_tests_properties (H5WATCH-clearall-objects PROPERTIES FIXTURES_REQUIRED swmr_vfd_check_compat)
+if (last_test)
+ set_tests_properties (H5WATCH-clearall-objects PROPERTIES DEPENDS ${last_test})
+endif ()
+set (last_test "H5WATCH-clearall-objects")
#################################################################################################
# #
@@ -188,32 +186,32 @@ if (NOT SWMR_INCOMPAT)
# #
#################################################################################################
# create the output files to be used.
- add_test (NAME H5WATCH-h5watchgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5watchgentest>)
- set_tests_properties (H5WATCH-h5watchgentest PROPERTIES
- WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
- DEPENDS "H5WATCH-clearall-objects"
- )
- set_tests_properties (H5WATCH-h5watchgentest PROPERTIES FIXTURES_SETUP gen_test_watch)
- set (last_test "H5WATCH-h5watchgentest")
+add_test (NAME H5WATCH-h5watchgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5watchgentest>)
+set_tests_properties (H5WATCH-h5watchgentest PROPERTIES
+ WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles"
+ DEPENDS "H5WATCH-clearall-objects"
+)
+set_tests_properties (H5WATCH-h5watchgentest PROPERTIES FIXTURES_SETUP gen_test_watch)
+set_tests_properties (H5WATCH-h5watchgentest PROPERTIES FIXTURES_REQUIRED swmr_vfd_check_compat)
+set (last_test "H5WATCH-h5watchgentest")
# Test on --help options
- ADD_H5_TEST (w-help1 0 --help)
+ADD_H5_TEST (w-help1 0 --help)
#
# Tests on expected failures
- ADD_H5_ERR_TEST (w-err-dset1 1 WATCH.h5)
- ADD_H5_ERR_TEST (w-err-dset2 1 WATCH.h5/group/DSET_CMPD)
- ADD_H5_ERR_TEST (w-err-dset-none 1 WATCH.h5/DSET_NONE)
- ADD_H5_ERR_TEST (w-err-dset-nomax 1 WATCH.h5/DSET_NOMAX)
- ADD_H5_ERR_TEST (w-err-file 1 ../WATCH.h5/DSET_CMPD)
- ADD_H5_TEST (w-err-width 1 --width=-8 WATCH.h5/DSET_ONE)
- ADD_H5_TEST (w-err-poll 1 --polling=-8 WATCH.h5/DSET_ONE)
- ADD_H5_TEST (w-err-poll0 1 --polling=0 WATCH.h5/DSET_ONE)
+ADD_H5_ERR_TEST (w-err-dset1 1 WATCH.h5)
+ADD_H5_ERR_TEST (w-err-dset2 1 WATCH.h5/group/DSET_CMPD)
+ADD_H5_ERR_TEST (w-err-dset-none 1 WATCH.h5/DSET_NONE)
+ADD_H5_ERR_TEST (w-err-dset-nomax 1 WATCH.h5/DSET_NOMAX)
+ADD_H5_ERR_TEST (w-err-file 1 ../WATCH.h5/DSET_CMPD)
+ADD_H5_TEST (w-err-width 1 --width=-8 WATCH.h5/DSET_ONE)
+ADD_H5_TEST (w-err-poll 1 --polling=-8 WATCH.h5/DSET_ONE)
+ADD_H5_TEST (w-err-poll0 1 --polling=0 WATCH.h5/DSET_ONE)
#
# Tests on invalid field names via --fields option for a compound typed dataset: DSET_CMPD
- ADD_H5_ERR_TEST (w-err-cmpd1 1 --fields=fieldx WATCH.h5/DSET_CMPD)
- ADD_H5_ERR_TEST (w-err-cmpd2 1 --fields=field1,field2. WATCH.h5/DSET_CMPD)
- ADD_H5_ERR_TEST (w-err-cmpd3 1 --fields=field1,field2, WATCH.h5/DSET_CMPD)
- ADD_H5_ERR_TEST (w-err-cmpd4 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD)
- ADD_H5_ERR_TEST (w-err-cmpd5 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD)
+ADD_H5_ERR_TEST (w-err-cmpd1 1 --fields=fieldx WATCH.h5/DSET_CMPD)
+ADD_H5_ERR_TEST (w-err-cmpd2 1 --fields=field1,field2. WATCH.h5/DSET_CMPD)
+ADD_H5_ERR_TEST (w-err-cmpd3 1 --fields=field1,field2, WATCH.h5/DSET_CMPD)
+ADD_H5_ERR_TEST (w-err-cmpd4 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD)
+ADD_H5_ERR_TEST (w-err-cmpd5 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD)
#
-endif ()
diff --git a/hl/tools/h5watch/Makefile.am b/hl/tools/h5watch/Makefile.am
index 0bf265e..13bd820 100644
--- a/hl/tools/h5watch/Makefile.am
+++ b/hl/tools/h5watch/Makefile.am
@@ -6,7 +6,7 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
@@ -24,7 +24,6 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib -I$(top_srcdir)/hl/sr
# These are our main targets, the tools
bin_PROGRAMS=h5watch
-noinst_PROGRAMS=swmr_check_compat_vfd
# Add h5watch specific linker flags here
h5watch_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS)
@@ -38,7 +37,7 @@ if BUILD_TESTS_CONDITIONAL
TEST_SCRIPT=testh5watch.sh
check_SCRIPTS=$(TEST_SCRIPT)
SCRIPT_DEPEND=swmr_check_compat_vfd$(EXEEXT) extend_dset$(EXEEXT) h5watch$(EXEEXT)
- noinst_PROGRAMS+=h5watchgentest extend_dset
+ noinst_PROGRAMS=h5watchgentest extend_dset
# Add extend_dset specific preprocessor flags here
# (add the main test subdirectory to the include file path)
extend_dset_CPPFLAGS=$(AM_CPPFLAGS) -I$(top_srcdir)/test
diff --git a/hl/tools/h5watch/extend_dset.c b/hl/tools/h5watch/extend_dset.c
index 4dcf25e..7756506 100644
--- a/hl/tools/h5watch/extend_dset.c
+++ b/hl/tools/h5watch/extend_dset.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -16,18 +16,18 @@
/*
* Extending datasets in WATCH.h5 generated by h5watchgentest.c
*/
-#define DSET_ONE "DSET_ONE"
-#define DSET_TWO "DSET_TWO"
-#define DSET_CMPD "DSET_CMPD"
-#define DSET_CMPD_ESC "DSET_CMPD_ESC"
-#define DSET_CMPD_TWO "DSET_CMPD_TWO"
-#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
+#define DSET_ONE "DSET_ONE"
+#define DSET_TWO "DSET_TWO"
+#define DSET_CMPD "DSET_CMPD"
+#define DSET_CMPD_ESC "DSET_CMPD_ESC"
+#define DSET_CMPD_TWO "DSET_CMPD_TWO"
+#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY"
/* The message sent by this process (extend_dset) to the test script to start "h5watch" */
-#define WRITER_MESSAGE "writer_message"
+#define WRITER_MESSAGE "writer_message"
/* The message received from the test script to start extending dataset */
-#define READER_MESSAGE "reader_message"
+#define READER_MESSAGE "reader_message"
/* Size of data buffer */
#define TEST_BUF_SIZE 100
@@ -35,7 +35,6 @@
static herr_t extend_dset_two(const char *file, char *dname, int action1, int action2);
static herr_t extend_dset_one(const char *file, char *dname, int action);
-
/* Data structures for datasets with compound data type */
typedef struct sub22_t {
int a;
@@ -44,9 +43,9 @@ typedef struct sub22_t {
} sub22_t;
typedef struct sub2_t {
- int a;
+ int a;
sub22_t b;
- int c;
+ int c;
} sub2_t;
typedef struct sub4_t {
@@ -55,7 +54,7 @@ typedef struct sub4_t {
} sub4_t;
typedef struct set_t {
- int field1;
+ int field1;
sub2_t field2;
double field3;
sub4_t field4;
@@ -66,73 +65,73 @@ typedef struct set_t {
*
* Extending a two-dimensional dataset by action1 and action2.
* --action1 and action2 can be a positive # or negative # or 0.
- *
+ *
***********************************************************************
*/
static herr_t
extend_dset_two(const char *file, char *dname, int action1, int action2)
{
- hid_t fid = -1; /* file id */
- hid_t fapl = -1; /* file access property list id */
- hid_t did = -1; /* dataset id */
- hid_t sid = -1; /* dataspace id */
- hid_t dtid = -1; /* dataset's datatype id */
- int ndims; /* # of dimension sizes */
- unsigned i; /* local index variable */
- hsize_t ext_dims[2]; /* new dimension sizes after extension */
- hsize_t cur_dims[2]; /* current dimension sizes */
- size_t dtype_size; /* size of the dataset's datatype */
- unsigned num_elmts; /* number of elements in the dataset */
- int *ibuf = NULL; /* buffer for storing retrieved elements (integer) */
- set_t *cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */
+ hid_t fid = -1; /* file id */
+ hid_t fapl = -1; /* file access property list id */
+ hid_t did = -1; /* dataset id */
+ hid_t sid = -1; /* dataspace id */
+ hid_t dtid = -1; /* dataset's datatype id */
+ int ndims; /* # of dimension sizes */
+ unsigned i; /* local index variable */
+ hsize_t ext_dims[2]; /* new dimension sizes after extension */
+ hsize_t cur_dims[2]; /* current dimension sizes */
+ size_t dtype_size; /* size of the dataset's datatype */
+ unsigned num_elmts; /* number of elements in the dataset */
+ int * ibuf = NULL; /* buffer for storing retrieved elements (integer) */
+ set_t * cbuf = NULL; /* buffer for storing retrieved elements (compound) */
/* Allocate memory */
- if(NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int))))
+ if (NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int))))
goto error;
- if(NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t))))
+ if (NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t))))
goto error;
/* Create a copy of file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
goto error;
/* Set to use the latest library format */
- if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
goto error;
/* Open the file and dataset with SWMR write */
- if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0)
+ if ((fid = H5Fopen(file, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0)
goto error;
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
goto error;
/* Send message to the test script to start "h5watch" */
h5_send_message(WRITER_MESSAGE, NULL, NULL);
- if((sid = H5Dget_space(did)) < 0)
+ if ((sid = H5Dget_space(did)) < 0)
goto error;
- if((ndims = H5Sget_simple_extent_ndims(sid)) < 0)
+ if ((ndims = H5Sget_simple_extent_ndims(sid)) < 0)
goto error;
/* Get the size of the dataset's datatype */
- if((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0)
+ if ((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0)
goto error;
/* Get the dataset's data type */
- if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
goto error;
/* Wait for message from the test script to start extending dataset */
- if(h5_wait_message(READER_MESSAGE) < 0)
+ if (h5_wait_message(READER_MESSAGE) < 0)
goto error;
/* sleep to emulate about 2 seconds of application operation */
HDsleep(2);
/* Get current dimension sizes */
- if(H5LDget_dset_dims(did, cur_dims) < 0)
+ if (H5LDget_dset_dims(did, cur_dims) < 0)
goto error;
/* Set up the new extended dimension sizes */
@@ -140,68 +139,74 @@ extend_dset_two(const char *file, char *dname, int action1, int action2)
ext_dims[1] = cur_dims[1] + (hsize_t)action2;
/* Extend the dataset */
- if(H5Dset_extent(did, ext_dims) < 0)
+ if (H5Dset_extent(did, ext_dims) < 0)
goto error;
num_elmts = 1;
- for(i = 0; i < (unsigned)ndims; i++)
+ for (i = 0; i < (unsigned)ndims; i++)
num_elmts *= (unsigned)ext_dims[i];
/* Compound type */
- if(!HDstrcmp(dname, DSET_CMPD_TWO)) {
+ if (!HDstrcmp(dname, DSET_CMPD_TWO)) {
HDmemset(cbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
- for(i = 0; i < num_elmts; i++) {
- cbuf[i].field1 = action1;
- cbuf[i].field2.a = action1;
- cbuf[i].field2.c = action1;
+ for (i = 0; i < num_elmts; i++) {
+ cbuf[i].field1 = action1;
+ cbuf[i].field2.a = action1;
+ cbuf[i].field2.c = action1;
cbuf[i].field2.b.a = action1;
cbuf[i].field2.b.b = action1;
cbuf[i].field2.b.c = action1;
- cbuf[i].field3 = action1;
- cbuf[i].field4.a = action1;
- cbuf[i].field4.b = action1;
+ cbuf[i].field3 = action1;
+ cbuf[i].field4.a = action1;
+ cbuf[i].field4.b = action1;
} /* end for */
- /* Write to the dataset */
- if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
+ /* Write to the dataset */
+ if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, cbuf) < 0)
goto error;
-
- } else { /* Integer type */
+ }
+ else { /* Integer type */
HDmemset(ibuf, 0, TEST_BUF_SIZE * sizeof(int));
- for(i = 0; i < num_elmts; i++)
+ for (i = 0; i < num_elmts; i++)
ibuf[i] = action1;
/* Write to the dataset */
- if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
+ if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf) < 0)
goto error;
} /* end if-else */
- if(H5Dflush(did) < 0)
+ if (H5Dflush(did) < 0)
goto error;
/* Closing */
- if(H5Tclose(dtid) < 0) goto error;
- if(H5Dclose(did) < 0) goto error;
- if(H5Pclose(fapl) < 0) goto error;
- if(H5Fclose(fid) < 0) goto error;
+ if (H5Tclose(dtid) < 0)
+ goto error;
+ if (H5Dclose(did) < 0)
+ goto error;
+ if (H5Pclose(fapl) < 0)
+ goto error;
+ if (H5Fclose(fid) < 0)
+ goto error;
- if(ibuf) HDfree(ibuf);
- if(cbuf) HDfree(cbuf);
+ if (ibuf)
+ HDfree(ibuf);
+ if (cbuf)
+ HDfree(cbuf);
return SUCCEED;
error:
H5E_BEGIN_TRY
- H5Tclose(dtid);
- H5Dclose(did);
- H5Pclose(fapl);
- H5Fclose(fid);
+ H5Tclose(dtid);
+ H5Dclose(did);
+ H5Pclose(fapl);
+ H5Fclose(fid);
H5E_END_TRY
- if(ibuf)
+ if (ibuf)
HDfree(ibuf);
- if(cbuf)
+ if (cbuf)
HDfree(cbuf);
return FAIL;
@@ -219,98 +224,98 @@ error:
static herr_t
extend_dset_one(const char *file, char *dname, int action)
{
- hid_t fid = -1; /* file id */
- hid_t fapl = -1; /* file access property list id */
- hid_t did = -1; /* dataset id */
- hid_t dtid = -1; /* dataset's datatype id */
- hid_t sid = -1; /* dataspace id */
- hid_t mid = -1; /* memory space id */
- int i; /* local index variable */
- hsize_t cur_dims[1]; /* current dimension sizes */
- hsize_t ext_dims[1]; /* new dimension sizes after extension */
- hsize_t offset[1]; /* starting offsets of appended data */
- hsize_t count[1]; /* dimension sizes of appended data */
- size_t dtype_size; /* size of the dataset's datatype */
- int *ibuf = NULL; /* buffer for storing retrieved elements (integer) */
- set_t *cbuf = NULL; /* buffer for storing retrieved elemnets (compound) */
+ hid_t fid = -1; /* file id */
+ hid_t fapl = -1; /* file access property list id */
+ hid_t did = -1; /* dataset id */
+ hid_t dtid = -1; /* dataset's datatype id */
+ hid_t sid = -1; /* dataspace id */
+ hid_t mid = -1; /* memory space id */
+ int i; /* local index variable */
+ hsize_t cur_dims[1]; /* current dimension sizes */
+ hsize_t ext_dims[1]; /* new dimension sizes after extension */
+ hsize_t offset[1]; /* starting offsets of appended data */
+ hsize_t count[1]; /* dimension sizes of appended data */
+ size_t dtype_size; /* size of the dataset's datatype */
+ int * ibuf = NULL; /* buffer for storing retrieved elements (integer) */
+ set_t * cbuf = NULL; /* buffer for storing retrieved elements (compound) */
/* Allocate memory */
- if(NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int))))
+ if (NULL == (ibuf = (int *)HDcalloc(TEST_BUF_SIZE, sizeof(int))))
goto error;
- if(NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t))))
+ if (NULL == (cbuf = (set_t *)HDcalloc(TEST_BUF_SIZE, sizeof(set_t))))
goto error;
/* Create a copy of file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
goto error;
/* Set to use the latest library format */
- if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
goto error;
/* Open the file and dataset with SWMR write */
- if((fid = H5Fopen(file, H5F_ACC_RDWR|H5F_ACC_SWMR_WRITE, fapl)) < 0)
+ if ((fid = H5Fopen(file, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl)) < 0)
goto error;
/* Send message to the test script to start "h5watch" */
h5_send_message(WRITER_MESSAGE, NULL, NULL);
- if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
+ if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0)
goto error;
/* Get size of the dataset's datatype */
- if((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0)
+ if ((dtype_size = H5LDget_dset_type_size(did, NULL)) == 0)
goto error;
/* Get dataset's datatype */
- if((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
+ if ((dtid = H5Tget_native_type(H5Dget_type(did), H5T_DIR_DEFAULT)) < 0)
goto error;
/* Wait for message from the test script to start extending dataset */
- if(h5_wait_message(READER_MESSAGE) < 0)
+ if (h5_wait_message(READER_MESSAGE) < 0)
goto error;
/* sleep to emulate about 2 seconds of application operation */
HDsleep(2);
/* Get current dimension sizes */
- if(H5LDget_dset_dims(did, cur_dims) < 0)
+ if (H5LDget_dset_dims(did, cur_dims) < 0)
goto error;
/* Set up the new extended dimension sizes */
ext_dims[0] = cur_dims[0] + (hsize_t)action;
/* Extend the dataset */
- if(H5Dset_extent(did, ext_dims) < 0)
+ if (H5Dset_extent(did, ext_dims) < 0)
goto error;
/* Write to the new appended region of the dataset */
- if(action > 0) {
+ if (action > 0) {
/* Select the extended region */
offset[0] = cur_dims[0];
- count[0] = (hsize_t)action;
- if((sid = H5Dget_space(did)) < 0)
+ count[0] = (hsize_t)action;
+ if ((sid = H5Dget_space(did)) < 0)
goto error;
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
+ if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, offset, NULL, count, NULL) < 0)
goto error;
/* Set up memory space and get dataset's datatype */
- if((mid = H5Screate_simple(1, count, NULL)) < 0)
+ if ((mid = H5Screate_simple(1, count, NULL)) < 0)
goto error;
/* Initialize data for the extended region of the dataset */
/* Compound type */
- if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
+ if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
HDmemset(cbuf, 0, TEST_BUF_SIZE * sizeof(set_t));
- for(i = 0; i < action; i++) {
- cbuf[i].field1 = i + 1;
- cbuf[i].field2.a = i + 2;
+ for (i = 0; i < action; i++) {
+ cbuf[i].field1 = i + 1;
+ cbuf[i].field2.a = i + 2;
cbuf[i].field2.b.a = i + 2;
cbuf[i].field2.b.b = i + 2;
cbuf[i].field2.b.c = i + 2;
- cbuf[i].field2.c = i + 2;
+ cbuf[i].field2.c = i + 2;
cbuf[i].field3 = i + 3;
@@ -319,57 +324,65 @@ extend_dset_one(const char *file, char *dname, int action)
} /* end for */
/* Write to the extended region of the dataset */
- if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, cbuf) < 0)
+ if (H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, cbuf) < 0)
goto error;
- } else { /* Integer type */
+ }
+ else { /* Integer type */
HDmemset(ibuf, 0, TEST_BUF_SIZE * sizeof(int));
- for(i = 0; i < action; i++)
+ for (i = 0; i < action; i++)
ibuf[i] = (int)i;
/* Write to the extended region of the dataset */
- if(H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, ibuf) < 0)
+ if (H5Dwrite(did, dtid, mid, sid, H5P_DEFAULT, ibuf) < 0)
goto error;
} /* end if-else */
/* Closing */
- if(H5Sclose(sid) < 0) goto error;
- if(H5Sclose(mid) < 0) goto error;
+ if (H5Sclose(sid) < 0)
+ goto error;
+ if (H5Sclose(mid) < 0)
+ goto error;
} /* end if */
- if(H5Dflush(did) < 0)
+ if (H5Dflush(did) < 0)
goto error;
/* Closing */
- if(H5Tclose(dtid) < 0) goto error;
- if(H5Dclose(did) < 0) goto error;
- if(H5Pclose(fapl) < 0) goto error;
- if(H5Fclose(fid) < 0) goto error;
+ if (H5Tclose(dtid) < 0)
+ goto error;
+ if (H5Dclose(did) < 0)
+ goto error;
+ if (H5Pclose(fapl) < 0)
+ goto error;
+ if (H5Fclose(fid) < 0)
+ goto error;
- if(ibuf) HDfree(ibuf);
- if(cbuf) HDfree(cbuf);
+ if (ibuf)
+ HDfree(ibuf);
+ if (cbuf)
+ HDfree(cbuf);
return SUCCEED;
error:
H5E_BEGIN_TRY
- H5Sclose(sid);
- H5Sclose(mid);
- H5Tclose(dtid);
- H5Dclose(did);
- H5Pclose(fapl);
- H5Fclose(fid);
+ H5Sclose(sid);
+ H5Sclose(mid);
+ H5Tclose(dtid);
+ H5Dclose(did);
+ H5Pclose(fapl);
+ H5Fclose(fid);
H5E_END_TRY
- if(ibuf)
+ if (ibuf)
HDfree(ibuf);
- if(cbuf)
+ if (cbuf)
HDfree(cbuf);
return FAIL;
} /* end extend_dset_one() */
-
/*
***********************************************************************
*
@@ -379,36 +392,37 @@ error:
***********************************************************************
*/
int
-main(int argc, const char *argv[])
+main(int argc, char *argv[])
{
char *dname = NULL;
char *fname = NULL;
- int action1, action2;
+ int action1, action2;
- if(argc != 5) {
+ if (argc != 5) {
HDfprintf(stderr, "Should have file name, dataset name, and the extended amount...\n");
goto error;
} /* end if */
/* Get the dataset name to be extended */
- fname = HDstrdup(argv[1]);
- dname = HDstrdup(argv[2]);
+ fname = HDstrdup(argv[1]);
+ dname = HDstrdup(argv[2]);
action1 = HDatoi(argv[3]);
action2 = HDatoi(argv[4]);
- if(!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
- if(extend_dset_one(fname, dname, action1) < 0)
+ if (!HDstrcmp(dname, DSET_CMPD) || !HDstrcmp(dname, DSET_CMPD_ESC)) {
+ if (extend_dset_one(fname, dname, action1) < 0)
goto error;
- } else if(!HDstrcmp(dname, DSET_ONE) ||
- !HDstrcmp(dname, DSET_ALLOC_LATE) ||
- !HDstrcmp(dname, DSET_ALLOC_EARLY)) {
- if(extend_dset_one(fname, dname, action1) < 0)
+ }
+ else if (!HDstrcmp(dname, DSET_ONE) || !HDstrcmp(dname, DSET_ALLOC_LATE) ||
+ !HDstrcmp(dname, DSET_ALLOC_EARLY)) {
+ if (extend_dset_one(fname, dname, action1) < 0)
goto error;
- } else if(!HDstrcmp(dname, DSET_TWO) ||
- !HDstrcmp(dname, DSET_CMPD_TWO)) {
- if(extend_dset_two(fname, dname, action1, action2) < 0)
+ }
+ else if (!HDstrcmp(dname, DSET_TWO) || !HDstrcmp(dname, DSET_CMPD_TWO)) {
+ if (extend_dset_two(fname, dname, action1, action2) < 0)
goto error;
- } else {
+ }
+ else {
HDfprintf(stdout, "Dataset cannot be extended...\n");
goto error;
} /* end if-else */
@@ -416,9 +430,9 @@ main(int argc, const char *argv[])
HDexit(EXIT_SUCCESS);
error:
- if(dname)
+ if (dname)
HDfree(dname);
- if(fname)
+ if (fname)
HDfree(fname);
HDexit(EXIT_FAILURE);
} /* end main() */
diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c
index d1f4e32..5a6fe6f 100644
--- a/hl/tools/h5watch/h5watch.c
+++ b/hl/tools/h5watch/h5watch.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -18,98 +18,74 @@
/*
* Note: This tool used private routine
*/
-#define PROGRAMNAME "h5watch" /* Name of tool */
-#define FIELD_SEP "," /* nested field separator */
-#define DEFAULT_RETRY 50 /* number of times to try opening the file */
-
+#define PROGRAMNAME "h5watch" /* Name of tool */
+#define FIELD_SEP "," /* nested field separator */
+#define DEFAULT_RETRY 50 /* number of times to try opening the file */
/*
* Note:(see comments in hl/src/H5LDprivate.h)
* This tool uses private routines H5LD_construct_vector()and H5LD_clean_vector()
- * This tool uses H5LD_memb_t data structure declared in H5LDprivate.h
+ * This tool uses H5LD_memb_t data structure declared in H5LDprivate.h
*/
-const char *progname = "h5watch"; /* tool name */
-static char *g_list_of_fields = NULL; /* command line input for "list_of_fields" */
-static char *g_dup_fields = NULL; /* copy of "list_of_fields" */
-static H5LD_memb_t **g_listv = NULL; /* vector info for "list_of_fields" */
+const char * progname = "h5watch"; /* tool name */
+static char * g_list_of_fields = NULL; /* command line input for "list_of_fields" */
+static char * g_dup_fields = NULL; /* copy of "list_of_fields" */
+static H5LD_memb_t **g_listv = NULL; /* vector info for "list_of_fields" */
-static hbool_t g_monitor_size_only = FALSE; /* monitor changes in dataset dimension sizes */
-static unsigned g_polling_interval = 1; /* polling interval to check appended data */
+static hbool_t g_monitor_size_only = FALSE; /* monitor changes in dataset dimension sizes */
+static unsigned g_polling_interval = 1; /* polling interval to check appended data */
-static hbool_t g_label = FALSE; /* label compound values */
-static int g_display_width = 80; /* output width in characters */
-static hbool_t g_simple_output = FALSE; /* make output more machine-readable */
-static unsigned g_retry = DEFAULT_RETRY; /* # of times to try opening the file if somehow file is unstable */
-static hbool_t g_display_hex = FALSE; /* display data in hexadecimal format : LATER */
-static hbool_t g_user_interrupt = FALSE; /* Flag to indicate that user interrupted execution */
+static hbool_t g_label = FALSE; /* label compound values */
+static int g_display_width = 80; /* output width in characters */
+static hbool_t g_simple_output = FALSE; /* make output more machine-readable */
+static unsigned g_retry = DEFAULT_RETRY; /* # of times to try opening the file if somehow file is unstable */
+static hbool_t g_display_hex = FALSE; /* display data in hexadecimal format : LATER */
+static hbool_t g_user_interrupt = FALSE; /* Flag to indicate that user interrupted execution */
-static herr_t doprint(hid_t did, hsize_t *start, hsize_t *block, int rank);
-static herr_t slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims,
- hsize_t *start, hsize_t *block, int rank, int subrank);
+static herr_t doprint(hid_t did, const hsize_t *start, const hsize_t *block, int rank);
+static herr_t slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block,
+ int rank, int subrank);
static herr_t monitor_dataset(hid_t fid, char *dsetname);
static herr_t process_cmpd_fields(hid_t fid, char *dsetname);
static herr_t check_dataset(hid_t fid, char *dsetname);
-static void leave(int ret);
-static void usage(const char *prog);
-static void parse_command_line(int argc, const char *argv[]);
-
+static void leave(int ret);
+static void usage(const char *prog);
+static void parse_command_line(int argc, const char *const *argv);
/*
* Command-line options: The user can only specify long-named parameters.
* The long-named ones can be partially spelled. When
* adding more, make sure that they don't clash with each other.
*/
-static const char *s_opts ="?";
-static struct long_options l_opts[] = {
- { "help", no_arg, 'h' },
- { "hel", no_arg, 'h' },
- { "dim", no_arg, 'd' },
- { "di", no_arg, 'd' },
- { "label", no_arg, 'l' },
- { "labe", no_arg, 'l' },
- { "lab", no_arg, 'l' },
- { "la", no_arg, 'l' },
- { "simple", no_arg, 'S' },
- { "simpl", no_arg, 'S' },
- { "simp", no_arg, 'S' },
- { "sim", no_arg, 'S' },
- { "si", no_arg, 'S' },
- { "hexdump", no_arg, 'x' },
- { "hexdum", no_arg, 'x' },
- { "hexdu", no_arg, 'x' },
- { "hexd", no_arg, 'x' },
- { "hex", no_arg, 'x' },
- { "width", require_arg, 'w' },
- { "widt", require_arg, 'w' },
- { "wid", require_arg, 'w' },
- { "wi", require_arg, 'w' },
- { "polling", require_arg, 'p' },
- { "pollin", require_arg, 'p' },
- { "polli", require_arg, 'p' },
- { "poll", require_arg, 'p' },
- { "pol", require_arg, 'p' },
- { "po", require_arg, 'p' },
- { "fields", require_arg, 'f' },
- { "field", require_arg, 'f' },
- { "fiel", require_arg, 'f' },
- { "fie", require_arg, 'f' },
- { "fi", require_arg, 'f' },
- { "version", no_arg, 'V' },
- { "versio", no_arg, 'V' },
- { "versi", no_arg, 'V' },
- { "vers", no_arg, 'V' },
- { "ver", no_arg, 'V' },
- { "ve", no_arg, 'V' },
- { NULL, 0, '\0' }
-};
+static const char * s_opts = "?";
+static struct h5_long_options l_opts[] = {{"help", no_arg, 'h'}, {"hel", no_arg, 'h'},
+ {"dim", no_arg, 'd'}, {"di", no_arg, 'd'},
+ {"label", no_arg, 'l'}, {"labe", no_arg, 'l'},
+ {"lab", no_arg, 'l'}, {"la", no_arg, 'l'},
+ {"simple", no_arg, 'S'}, {"simpl", no_arg, 'S'},
+ {"simp", no_arg, 'S'}, {"sim", no_arg, 'S'},
+ {"si", no_arg, 'S'}, {"hexdump", no_arg, 'x'},
+ {"hexdum", no_arg, 'x'}, {"hexdu", no_arg, 'x'},
+ {"hexd", no_arg, 'x'}, {"hex", no_arg, 'x'},
+ {"width", require_arg, 'w'}, {"widt", require_arg, 'w'},
+ {"wid", require_arg, 'w'}, {"wi", require_arg, 'w'},
+ {"polling", require_arg, 'p'}, {"pollin", require_arg, 'p'},
+ {"polli", require_arg, 'p'}, {"poll", require_arg, 'p'},
+ {"pol", require_arg, 'p'}, {"po", require_arg, 'p'},
+ {"fields", require_arg, 'f'}, {"field", require_arg, 'f'},
+ {"fiel", require_arg, 'f'}, {"fie", require_arg, 'f'},
+ {"fi", require_arg, 'f'}, {"version", no_arg, 'V'},
+ {"versio", no_arg, 'V'}, {"versi", no_arg, 'V'},
+ {"vers", no_arg, 'V'}, {"ver", no_arg, 'V'},
+ {"ve", no_arg, 'V'}, {NULL, 0, '\0'}};
/*-------------------------------------------------------------------------
* Function: doprint()
*
* Purpose: Prepare to print the dataset's appended data.
* Call the tools library routine h5tools_dump_dset() to do the printing.
- * (This routine is mostly copied from dump_dataset_values() in tools/h5ls/h5ls.c
+ * (This routine is mostly copied from dump_dataset_values() in tools/h5ls/h5ls.c
* and modified accordingly).
*
* Return: 0 on success; negative on failure
@@ -119,45 +95,46 @@ static struct long_options l_opts[] = {
*-------------------------------------------------------------------------
*/
static herr_t
-doprint(hid_t did, hsize_t *start, hsize_t *block, int rank)
+doprint(hid_t did, const hsize_t *start, const hsize_t *block, int rank)
{
- h5tools_context_t ctx; /* print context */
- h5tool_format_t info; /* Format info for the tools library */
- static char fmt_double[16], fmt_float[16]; /* Format info */
- struct subset_t subset; /* Subsetting info */
- hsize_t ss_start[H5S_MAX_RANK]; /* Info for hyperslab */
- hsize_t ss_stride[H5S_MAX_RANK]; /* Info for hyperslab */
- hsize_t ss_block[H5S_MAX_RANK]; /* Info for hyperslab */
- hsize_t ss_count[H5S_MAX_RANK]; /* Info for hyperslab */
- int i; /* Local index variable */
- herr_t ret_value = SUCCEED; /* Return value */
+ h5tools_context_t ctx; /* print context */
+ h5tool_format_t info; /* Format info for the tools library */
+ static char fmt_double[16], fmt_float[16]; /* Format info */
+ struct subset_t subset; /* Subsetting info */
+ hsize_t ss_start[H5S_MAX_RANK]; /* Info for hyperslab */
+ hsize_t ss_stride[H5S_MAX_RANK]; /* Info for hyperslab */
+ hsize_t ss_block[H5S_MAX_RANK]; /* Info for hyperslab */
+ hsize_t ss_count[H5S_MAX_RANK]; /* Info for hyperslab */
+ int i; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
/* Subsetting information for the tools library printing routines */
- subset.start.data = ss_start;
+ subset.start.data = ss_start;
subset.stride.data = ss_stride;
- subset.block.data = ss_block;
- subset.count.data = ss_count;
+ subset.block.data = ss_block;
+ subset.count.data = ss_count;
/* Initialize subsetting information */
- for(i = 0; i < rank; i++) {
+ for (i = 0; i < rank; i++) {
subset.stride.data[i] = 1;
- subset.count.data[i] = 1;
- subset.start.data[i] = start[i];
- subset.block.data[i] = block[i];
+ subset.count.data[i] = 1;
+ subset.start.data[i] = start[i];
+ subset.block.data[i] = block[i];
} /* end for */
HDmemset(&ctx, 0, sizeof(ctx));
+ ctx.sset = &subset;
/* Set to all default values and then override */
HDmemset(&info, 0, sizeof info);
- if(g_simple_output) {
- info.idx_fmt = "";
- info.line_ncols = 65535; /*something big*/
- info.line_per_line = 1;
+ if (g_simple_output) {
+ info.idx_fmt = "";
+ info.line_ncols = 65535; /*something big*/
+ info.line_per_line = 1;
info.line_multi_new = 0;
- info.line_pre = " ";
- info.line_cont = " ";
+ info.line_pre = " ";
+ info.line_cont = " ";
info.arr_pre = "";
info.arr_suf = "";
@@ -168,18 +145,18 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank)
info.cmpd_sep = " ";
/* The "fields" selected by the user */
- info.cmpd_listv = (const struct H5LD_memb_t * const *)g_listv;
+ info.cmpd_listv = (const struct H5LD_memb_t *const *)g_listv;
- if(g_label)
+ if (g_label)
info.cmpd_name = "%s=";
- info.elmt_suf1 = " ";
+ info.elmt_suf1 = " ";
info.str_locale = ESCAPE_HTML;
-
- } else {
+ }
+ else {
info.idx_fmt = "(%s)";
- if(!g_display_width) {
- info.line_ncols = 65535;
+ if (!g_display_width) {
+ info.line_ncols = 65535;
info.line_per_line = 1;
} /* end if */
else
@@ -188,39 +165,39 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank)
info.line_multi_new = 1;
/* The "fields" selected by the user */
- info.cmpd_listv = (const struct H5LD_memb_t * const *)g_listv;
- if(g_label)
+ info.cmpd_listv = (const struct H5LD_memb_t *const *)g_listv;
+ if (g_label)
info.cmpd_name = "%s=";
- info.line_pre = " %s ";
- info.line_cont = " %s ";
+ info.line_pre = " %s ";
+ info.line_cont = " %s ";
info.str_repeat = 8;
} /* end else */
/* Floating point types should display full precision */
- sprintf(fmt_float, "%%1.%dg", FLT_DIG);
+ snprintf(fmt_float, sizeof(fmt_float), "%%1.%dg", FLT_DIG);
info.fmt_float = fmt_float;
- sprintf(fmt_double, "%%1.%dg", DBL_DIG);
+ snprintf(fmt_double, sizeof(fmt_double), "%%1.%dg", DBL_DIG);
info.fmt_double = fmt_double;
- info.dset_format = "DSET-%s ";
+ info.dset_format = "DSET-%s ";
info.dset_hidefileno = 0;
- info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT;
+ info.obj_format = "-%lu:%" PRIuHADDR;
info.obj_hidefileno = 0;
info.dset_blockformat_pre = "%sBlk%lu: ";
- info.dset_ptformat_pre = "%sPt%lu: ";
+ info.dset_ptformat_pre = "%sPt%lu: ";
info.line_indent = "";
- if(g_display_hex) {
+ if (g_display_hex) {
/* Print all data in hexadecimal format if the `-x' or `--hexdump'
* command line switch was given. */
info.raw = TRUE;
} /* end if */
/* Print the values. */
- if((ret_value = h5tools_dump_dset(stdout, &info, &ctx, did, &subset)) < 0)
+ if ((ret_value = h5tools_dump_dset(stdout, &info, &ctx, did)) < 0)
error_msg("unable to print data\n");
HDfprintf(stdout, "\n");
@@ -250,25 +227,26 @@ doprint(hid_t did, hsize_t *start, hsize_t *block, int rank)
*-------------------------------------------------------------------------
*/
static herr_t
-slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block, int rank, int subrank)
+slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsize_t *block, int rank,
+ int subrank)
{
- int i; /* Local index variable */
- int ind; /* Index for the current rank */
+ int i; /* Local index variable */
+ int ind; /* Index for the current rank */
herr_t ret_value = SUCCEED; /* Return value */
-
+
ind = rank - subrank;
- if((subrank - 1) > 0) {
+ if ((subrank - 1) > 0) {
/* continue onto the next dimension */
- for (i = 0; i < (hssize_t)MIN(prev_dims[ind], cur_dims[ind]); i++){
+ for (i = 0; i < (hssize_t)MIN(prev_dims[ind], cur_dims[ind]); i++) {
start[ind] = (hsize_t)i;
- if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, rank, subrank-1)) < 0)
+ if ((ret_value = slicendump(did, prev_dims, cur_dims, start, block, rank, subrank - 1)) < 0)
goto done;
} /* end for */
- } /* end if */
+ } /* end if */
/* this dimension remains the same or shrinking */
- if(cur_dims[ind] <= prev_dims[ind])
+ if (cur_dims[ind] <= prev_dims[ind])
goto done;
/* select first the slice for the faster changing dimension */
@@ -276,7 +254,7 @@ slicendump(hid_t did, hsize_t *prev_dims, hsize_t *cur_dims, hsize_t *start, hsi
start[ind] = prev_dims[ind];
block[ind] = cur_dims[ind] - prev_dims[ind];
- for(i = ind + 1; i < rank; i++){
+ for (i = ind + 1; i < rank; i++) {
start[i] = 0;
block[i] = cur_dims[i];
} /* end for */
@@ -288,7 +266,6 @@ done:
return ret_value;
} /* end slicendump() */
-
/*-------------------------------------------------------------------------
* Function: monitor_dataset
*
@@ -305,33 +282,33 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+static herr_t
monitor_dataset(hid_t fid, char *dsetname)
{
- hid_t did; /* dataset id */
- hid_t sid; /* dataspace id */
- int ndims; /* # of dimensions in the dataspace */
- int i, u; /* local index variable */
- hsize_t prev_dims[H5S_MAX_RANK]; /* current dataspace dimensions */
- hsize_t cur_dims[H5S_MAX_RANK]; /* previous dataspace dimensions */
- herr_t ret_value = SUCCEED; /* return value */
+ hid_t did; /* dataset id */
+ hid_t sid; /* dataspace id */
+ int ndims; /* # of dimensions in the dataspace */
+ int i, u; /* local index variable */
+ hsize_t prev_dims[H5S_MAX_RANK]; /* current dataspace dimensions */
+ hsize_t cur_dims[H5S_MAX_RANK]; /* previous dataspace dimensions */
+ herr_t ret_value = SUCCEED; /* return value */
HDfprintf(stdout, "Monitoring dataset %s...\n", dsetname);
/* Open the dataset for minitoring */
- if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) {
+ if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) {
error_msg("error in opening dataset \"%s\"\n", dsetname);
ret_value = FAIL;
goto done;
- }
- if((sid = H5Dget_space(did)) < 0) {
+ }
+ if ((sid = H5Dget_space(did)) < 0) {
error_msg("error in getting dataspace id for dataset \"%s\"\n", dsetname);
ret_value = FAIL;
goto done;
}
/* Get the dataset's dimension sizes */
- if((ndims = H5Sget_simple_extent_dims(sid, prev_dims, NULL)) < 0) {
+ if ((ndims = H5Sget_simple_extent_dims(sid, prev_dims, NULL)) < 0) {
error_msg("unable to get dimensions sizes for \"%s\"\n", dsetname);
ret_value = FAIL;
goto done;
@@ -339,58 +316,60 @@ monitor_dataset(hid_t fid, char *dsetname)
HDfflush(stdout);
/* Loop until an error occurs or the user interrupts execution */
- while(!g_user_interrupt) {
+ while (!g_user_interrupt) {
/* Refreshes the dataset */
- if(H5Drefresh(did) < 0) {
+ if (H5Drefresh(did) < 0) {
ret_value = FAIL;
goto done;
}
/* Get the dataset's current dimension sizes */
- if(H5LDget_dset_dims(did, cur_dims) < 0) {
+ if (H5LDget_dset_dims(did, cur_dims) < 0) {
error_msg("unable to get dimension sizes for \"%s\"\n", dsetname);
ret_value = FAIL;
goto done;
}
/* Check the dimension sizes */
- for(i = 0; i < ndims; i++)
- if(cur_dims[i] != prev_dims[i])
+ for (i = 0; i < ndims; i++)
+ if (cur_dims[i] != prev_dims[i])
break;
/* at least one dimension has changed */
- if(i != ndims) {
+ if (i != ndims) {
/* Printing changes in dimension sizes */
- for(u = 0; u < ndims; u++) {
- HDfprintf(stdout, "dimension %u: %Hu->%Hu", (unsigned)u, prev_dims[u], cur_dims[u]);
- if(cur_dims[u] > prev_dims[u])
+ for (u = 0; u < ndims; u++) {
+ HDfprintf(stdout, "dimension %d: %" PRIuHSIZE "->%" PRIuHSIZE "", u, prev_dims[u],
+ cur_dims[u]);
+ if (cur_dims[u] > prev_dims[u])
HDfprintf(stdout, " (increases)\n");
- else if(cur_dims[u] < prev_dims[u])
+ else if (cur_dims[u] < prev_dims[u])
HDfprintf(stdout, " (decreases)\n");
else
HDfprintf(stdout, " (unchanged)\n");
}
/* Printing elements appended to the dataset if there is */
- if(!g_monitor_size_only) {
+ if (!g_monitor_size_only) {
/* See if at least one dimension size has increased */
- for(u = 0; u < ndims; u++) {
- int j;
+ for (u = 0; u < ndims; u++) {
+ int j;
hsize_t start[H5S_MAX_RANK];
hsize_t block[H5S_MAX_RANK];
/* Print the new appended data to the dataset */
- if(cur_dims[u] > prev_dims[u]) {
+ if (cur_dims[u] > prev_dims[u]) {
HDfprintf(stdout, " Data:\n");
- for(j = 0; j < ndims; j++) {
+ for (j = 0; j < ndims; j++) {
start[j] = 0;
block[j] = 1;
}
- if((ret_value = slicendump(did, prev_dims, cur_dims, start, block, ndims, ndims)) < 0)
+ if ((ret_value = slicendump(did, prev_dims, cur_dims, start, block, ndims, ndims)) <
+ 0)
goto done;
break;
}
@@ -398,7 +377,7 @@ monitor_dataset(hid_t fid, char *dsetname)
}
HDfflush(stdout);
}
-
+
/* Save the current dimension sizes */
HDmemcpy(prev_dims, cur_dims, (size_t)ndims * sizeof(hsize_t));
@@ -411,10 +390,10 @@ monitor_dataset(hid_t fid, char *dsetname)
done:
/* Closing */
H5E_BEGIN_TRY
- H5Dclose(did);
+ H5Dclose(did);
H5E_END_TRY
- return(ret_value);
+ return (ret_value);
} /* monitor_dataset() */
/*-------------------------------------------------------------------------
@@ -432,53 +411,53 @@ done:
static herr_t
process_cmpd_fields(hid_t fid, char *dsetname)
{
- hid_t did=-1; /* dataset id */
- hid_t dtid=-1, tid=-1; /* dataset's data type id */
+ hid_t did = -1; /* dataset id */
+ hid_t dtid = -1, tid = -1; /* dataset's data type id */
size_t len; /* number of comma-separated fields in "g_list_of_fields" */
herr_t ret_value = SUCCEED; /* Return value */
HDassert(g_list_of_fields && *g_list_of_fields);
-
+
/* Open the dataset */
- if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) {
+ if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) {
error_msg("error in opening dataset \"%s\"\n", dsetname);
ret_value = FAIL;
goto done;
}
/* Get the dataset's datatype */
- if(((dtid = H5Dget_type(did)) < 0) || (tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) {
+ if (((dtid = H5Dget_type(did)) < 0) || (tid = H5Tget_native_type(dtid, H5T_DIR_DEFAULT)) < 0) {
error_msg("error in getting dataset's datatype\n");
ret_value = FAIL;
goto done;
}
/* Check to make sure that the dataset's datatype is compound type */
- if(H5Tget_class(dtid) != H5T_COMPOUND) {
+ if (H5Tget_class(dtid) != H5T_COMPOUND) {
error_msg("dataset should be compound type for <list_of_fields>\n");
ret_value = FAIL;
- goto done;
+ goto done;
}
/* Make a copy of "g_list_of_fields" */
- if((g_dup_fields = HDstrdup(g_list_of_fields)) == NULL) {
+ if ((g_dup_fields = HDstrdup(g_list_of_fields)) == NULL) {
error_msg("error in duplicating g_list_of_fields\n");
ret_value = FAIL;
- goto done;
+ goto done;
}
/* Estimate the number of comma-separated fields in "g_list of_fields" */
- len = HDstrlen(g_list_of_fields)/2 + 2;
+ len = HDstrlen(g_list_of_fields) / 2 + 2;
/* Allocate memory for a list vector of H5LD_memb_t structures to store "g_list_of_fields" info */
- if((g_listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))) == NULL) {
+ if ((g_listv = (H5LD_memb_t **)HDcalloc(len, sizeof(H5LD_memb_t *))) == NULL) {
error_msg("error in allocating memory for H5LD_memb_t\n");
ret_value = FAIL;
- goto done;
+ goto done;
}
/* Process and store info for "g_listv" */
- if(H5LD_construct_vector(g_dup_fields, g_listv, tid) < 0) {
+ if (H5LD_construct_vector(g_dup_fields, g_listv, tid) < 0) {
error_msg("error in processing <list_of_fields>\n");
ret_value = FAIL;
goto done;
@@ -488,14 +467,13 @@ process_cmpd_fields(hid_t fid, char *dsetname)
done:
/* Closing */
H5E_BEGIN_TRY
- H5Tclose(dtid);
- H5Tclose(tid);
- H5Dclose(did);
+ H5Tclose(dtid);
+ H5Tclose(tid);
+ H5Dclose(did);
H5E_END_TRY
- return(ret_value);
+ return (ret_value);
} /* process_cmpd_fields() */
-
/*-------------------------------------------------------------------------
* Function: check_dataset
*
@@ -512,44 +490,44 @@ done:
static herr_t
check_dataset(hid_t fid, char *dsetname)
{
- hid_t did=-1; /* Dataset id */
- hid_t dcp=-1; /* Dataset creation property */
- hid_t sid=-1; /* Dataset's dataspace id */
- int ndims; /* # of dimensions in the dataspace */
- unsigned u; /* Local index variable */
- hsize_t cur_dims[H5S_MAX_RANK]; /* size of dataspace dimensions */
- hsize_t max_dims[H5S_MAX_RANK]; /* maximum size of dataspace dimensions */
- hbool_t unlim_max_dims = FALSE; /* whether dataset has unlimited or max. dimension setting */
- void *edata;
- H5E_auto2_t func;
- H5D_layout_t layout;
- herr_t ret_value = SUCCEED; /* Return value */
+ hid_t did = -1; /* Dataset id */
+ hid_t dcp = -1; /* Dataset creation property */
+ hid_t sid = -1; /* Dataset's dataspace id */
+ int ndims; /* # of dimensions in the dataspace */
+ unsigned u; /* Local index variable */
+ hsize_t cur_dims[H5S_MAX_RANK]; /* size of dataspace dimensions */
+ hsize_t max_dims[H5S_MAX_RANK]; /* maximum size of dataspace dimensions */
+ hbool_t unlim_max_dims = FALSE; /* whether dataset has unlimited or max. dimension setting */
+ void * edata;
+ H5E_auto2_t func;
+ H5D_layout_t layout;
+ herr_t ret_value = SUCCEED; /* Return value */
/* Disable error reporting */
H5Eget_auto2(H5E_DEFAULT, &func, &edata);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
/* Open the dataset */
- if((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) {
+ if ((did = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) {
error_msg("unable to open dataset \"%s\"\n", dsetname);
ret_value = FAIL;
goto done;
}
/* Get dataset's creation property list */
- if((dcp = H5Dget_create_plist(did)) < 0) {
+ if ((dcp = H5Dget_create_plist(did)) < 0) {
error_msg("unable to get dataset's creation property list \"%s\"\n", dsetname);
ret_value = FAIL;
goto done;
}
/* Query dataset's layout; the layout should be chunked or virtual */
- if((layout = H5Pget_layout(dcp)) < 0) {
+ if ((layout = H5Pget_layout(dcp)) < 0) {
error_msg("unable to get dataset layout \"%s\"\n", dsetname);
ret_value = FAIL;
goto done;
}
- if(layout != H5D_CHUNKED && layout != H5D_VIRTUAL) {
+ if (layout != H5D_CHUNKED && layout != H5D_VIRTUAL) {
error_msg("\"%s\" should be a chunked or virtual dataset\n", dsetname);
ret_value = FAIL;
goto done;
@@ -559,45 +537,44 @@ check_dataset(hid_t fid, char *dsetname)
HDmemset(max_dims, 0, sizeof max_dims);
/* Get dataset's dataspace */
- if((sid = H5Dget_space(did)) < 0) {
+ if ((sid = H5Dget_space(did)) < 0) {
error_msg("can't get dataset's dataspace\"%s\"\n", dsetname);
ret_value = FAIL;
goto done;
}
/* Get dimension size of dataset's dataspace */
- if((ndims = H5Sget_simple_extent_dims(sid, cur_dims, max_dims)) < 0) {
+ if ((ndims = H5Sget_simple_extent_dims(sid, cur_dims, max_dims)) < 0) {
error_msg("can't get dataspace dimensions for dataset \"%s\"\n", dsetname);
ret_value = FAIL;
goto done;
}
/* Check whether dataset has unlimited dimension or max. dimension setting */
- for(u = 0; u < (unsigned)ndims; u++)
- if(max_dims[u] == H5S_UNLIMITED || cur_dims[u] != max_dims[u]) {
- unlim_max_dims = TRUE;
- break;
- }
+ for (u = 0; u < (unsigned)ndims; u++)
+ if (max_dims[u] == H5S_UNLIMITED || cur_dims[u] != max_dims[u]) {
+ unlim_max_dims = TRUE;
+ break;
+ }
- if(!unlim_max_dims) {
+ if (!unlim_max_dims) {
error_msg("\"%s\" should have unlimited or max. dimension setting\n", dsetname);
ret_value = FAIL;
}
-done:
+done:
H5Eset_auto2(H5E_DEFAULT, func, edata);
/* Closing */
H5E_BEGIN_TRY
- H5Sclose(sid);
- H5Pclose(dcp);
- H5Dclose(did);
+ H5Sclose(sid);
+ H5Pclose(dcp);
+ H5Dclose(did);
H5E_END_TRY
- return(ret_value);
+ return (ret_value);
} /* check_dataset() */
-
/*-------------------------------------------------------------------------
* Function: leave
*
@@ -618,7 +595,6 @@ leave(int ret)
exit(ret);
}
-
/*-------------------------------------------------------------------------
* Function: usage
*
@@ -630,7 +606,7 @@ leave(int ret)
*
*-------------------------------------------------------------------------
*/
-static void
+static void
usage(const char *prog)
{
HDfflush(stdout);
@@ -646,20 +622,23 @@ usage(const char *prog)
HDfprintf(stdout, " A value of 0 sets the number of columns to the\n");
HDfprintf(stdout, " maximum (65535). The default width is 80 columns.\n");
HDfprintf(stdout, " --polling=N Set the polling interval to N (in seconds) when the\n");
- HDfprintf(stdout, " dataset will be checked for appended data. The default\n");
+ HDfprintf(stdout,
+ " dataset will be checked for appended data. The default\n");
HDfprintf(stdout, " polling interval is 1.\n");
HDfprintf(stdout, " --fields=<list_of_fields>\n");
- HDfprintf(stdout, " Display data for the fields specified in <list_of_fields>\n");
+ HDfprintf(stdout,
+ " Display data for the fields specified in <list_of_fields>\n");
HDfprintf(stdout, " for a compound data type. <list_of_fields> can be\n");
HDfprintf(stdout, " specified as follows:\n");
HDfprintf(stdout, " 1) A comma-separated list of field names in a\n");
- HDfprintf(stdout, " compound data type. \",\" is the separator\n");
+ HDfprintf(stdout, " compound data type. \",\" is the separator\n");
HDfprintf(stdout, " for field names while \".\" is the separator\n");
HDfprintf(stdout, " for a nested field.\n");
HDfprintf(stdout, " 2) A single field name in a compound data type.\n");
HDfprintf(stdout, " Can use this option multiple times.\n");
HDfprintf(stdout, " Note that backslash is the escape character to avoid\n");
- HDfprintf(stdout, " characters in field names that conflict with the tool's\n");
+ HDfprintf(stdout,
+ " characters in field names that conflict with the tool's\n");
HDfprintf(stdout, " separators.\n");
HDfprintf(stdout, "\n");
HDfprintf(stdout, " OBJECT is specified as [<filename>/<path_to_dataset>/<dsetname>]\n");
@@ -668,11 +647,11 @@ usage(const char *prog)
HDfprintf(stdout, " <path_to_dataset> Path separated by slashes to the specified dataset\n");
HDfprintf(stdout, " <dsetname> Name of the dataset\n");
HDfprintf(stdout, "\n");
- HDfprintf(stdout, " User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM).\n");
+ HDfprintf(stdout,
+ " User can end the h5watch process by ctrl-C (SIGINT) or kill the process (SIGTERM).\n");
} /* usage() */
-
/*-------------------------------------------------------------------------
* Function: parse_command_line
*
@@ -686,103 +665,99 @@ usage(const char *prog)
*-------------------------------------------------------------------------
*/
static void
-parse_command_line(int argc, const char *argv[])
+parse_command_line(int argc, const char *const *argv)
{
- int opt; /* Command line option */
+ int opt; /* Command line option */
int tmp;
- /* no arguments */
+ /* no arguments */
if (argc == 1) {
usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
/* parse command line options */
- while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
+ while ((opt = H5_get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
- case '?':
- case 'h': /* --help */
- usage(h5tools_getprogname());
- leave(EXIT_SUCCESS);
- break;
+ case '?':
+ case 'h': /* --help */
+ usage(h5tools_getprogname());
+ leave(EXIT_SUCCESS);
+ break;
- case 'V': /* --version */
- print_version(progname);
- leave(EXIT_SUCCESS);
- break;
+ case 'V': /* --version */
+ print_version(progname);
+ leave(EXIT_SUCCESS);
+ break;
- case 'w': /* --width=N */
- g_display_width = (int)HDstrtol(opt_arg, NULL, 0);
- if(g_display_width < 0) {
- usage(h5tools_getprogname());
- leave(EXIT_FAILURE);
- }
- break;
+ case 'w': /* --width=N */
+ g_display_width = (int)HDstrtol(H5_optarg, NULL, 0);
+ if (g_display_width < 0) {
+ usage(h5tools_getprogname());
+ leave(EXIT_FAILURE);
+ }
+ break;
- case 'd': /* --dim */
- g_monitor_size_only = TRUE;
- break;
+ case 'd': /* --dim */
+ g_monitor_size_only = TRUE;
+ break;
- case 'S': /* --simple */
- g_simple_output = TRUE;
- break;
-
- case 'l': /* --label */
- g_label = TRUE;
- break;
+ case 'S': /* --simple */
+ g_simple_output = TRUE;
+ break;
- case 'p': /* --polling=N */
- /* g_polling_interval = HDstrtod(opt_arg, NULL); */
- if((tmp = (int)HDstrtol(opt_arg, NULL, 10)) <= 0) {
- usage(h5tools_getprogname());
- leave(EXIT_FAILURE);
- }
- g_polling_interval = (unsigned)tmp;
- break;
+ case 'l': /* --label */
+ g_label = TRUE;
+ break;
- case 'f': /* --fields=<list_of_fields> */
- if(g_list_of_fields == NULL) {
- if((g_list_of_fields = HDstrdup(opt_arg)) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
+ case 'p': /* --polling=N */
+ /* g_polling_interval = HDstrtod(H5_optarg, NULL); */
+ if ((tmp = (int)HDstrtol(H5_optarg, NULL, 10)) <= 0) {
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
- } else {
- char *str;
+ g_polling_interval = (unsigned)tmp;
+ break;
- if((str = HDstrdup(opt_arg)) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
- leave(EXIT_FAILURE);
+ case 'f': /* --fields=<list_of_fields> */
+ if (g_list_of_fields == NULL) {
+ if ((g_list_of_fields = HDstrdup(H5_optarg)) == NULL) {
+ error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__);
+ leave(EXIT_FAILURE);
+ }
}
- if((g_list_of_fields = (char *)HDrealloc(g_list_of_fields, HDstrlen(g_list_of_fields) + HDstrlen(str) + 2)) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
- leave(EXIT_FAILURE);
+ else {
+ char *str;
+ if ((str = HDstrdup(H5_optarg)) == NULL) {
+ error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__);
+ leave(EXIT_FAILURE);
+ }
+ if ((g_list_of_fields = (char *)HDrealloc(
+ g_list_of_fields, HDstrlen(g_list_of_fields) + HDstrlen(str) + 2)) == NULL) {
+ error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__);
+ leave(EXIT_FAILURE);
+ }
+ HDstrcat(g_list_of_fields, FIELD_SEP);
+ HDstrcat(g_list_of_fields, str);
}
- HDstrcat(g_list_of_fields, FIELD_SEP);
- HDstrcat(g_list_of_fields, str);
- }
- break;
+ break;
- default:
- usage(h5tools_getprogname());
- leave(EXIT_FAILURE);
+ default:
+ usage(h5tools_getprogname());
+ leave(EXIT_FAILURE);
}
}
-
/* check for object to be processed */
- if (argc <= opt_ind) {
+ if (argc <= H5_optind) {
error_msg("missing dataset name\n");
usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
} /* parse_command_line() */
-
/*-------------------------------------------------------------------------
* Function: catch_signal
*
@@ -795,13 +770,13 @@ parse_command_line(int argc, const char *argv[])
*
*-------------------------------------------------------------------------
*/
-static void catch_signal(int H5_ATTR_UNUSED signo)
+static void
+catch_signal(int H5_ATTR_UNUSED signo)
{
/* Set the flag to get out of the main loop */
g_user_interrupt = TRUE;
} /* catch_signal() */
-
/*-------------------------------------------------------------------------
* Function: main
*
@@ -815,53 +790,50 @@ static void catch_signal(int H5_ATTR_UNUSED signo)
*-------------------------------------------------------------------------
*/
int
-main(int argc, const char *argv[])
+main(int argc, char *argv[])
{
- char drivername[50]; /* VFD name */
- char *fname = NULL; /* File name */
- char *dname = NULL; /* Dataset name */
- void *edata; /* Error reporting */
- H5E_auto2_t func; /* Error reporting */
- char *x; /* Temporary string pointer */
- hid_t fid = -1; /* File ID */
- hid_t fapl = -1; /* File access property list */
+ char drivername[50]; /* VFD name */
+ char *fname = NULL; /* File name */
+ char *dname = NULL; /* Dataset name */
+ char *x; /* Temporary string pointer */
+ hid_t fid = -1; /* File ID */
+ hid_t fapl = -1; /* File access property list */
/* Set up tool name and exit status */
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* Disable error reporting */
- H5Eget_auto2(H5E_DEFAULT, &func, &edata);
- H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
-
/* Initialize h5tools lib */
h5tools_init();
/* To exit from h5watch for SIGTERM signal */
- if(HDsignal(SIGTERM, catch_signal) == SIG_ERR) {
+ if (HDsignal(SIGTERM, catch_signal) == SIG_ERR) {
error_msg("An error occurred while setting a signal handler.\n");
leave(EXIT_FAILURE);
}
/* To exit from h5watch for SIGINT signal */
- if(HDsignal(SIGINT, catch_signal) == SIG_ERR) {
+ if (HDsignal(SIGINT, catch_signal) == SIG_ERR) {
error_msg("An error occurred while setting a signal handler.\n");
leave(EXIT_FAILURE);
}
/* parse command line options */
- parse_command_line(argc, argv);
+ parse_command_line(argc, (const char *const *)argv);
- if(argc <= opt_ind) {
+ if (argc <= H5_optind) {
error_msg("missing dataset name\n");
usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* Mostly copied from tools/h5ls coding & modified accordingly */
- /*
- * [OBJECT] is specified as
- * [<filename>/<path_to_dataset>/<dsetname>]
+ /*
+ * [OBJECT] is specified as
+ * [<filename>/<path_to_dataset>/<dsetname>]
*
* Example: ../dir1/foo/bar/dset
* \_________/\______/
@@ -871,101 +843,116 @@ main(int argc, const char *argv[])
* succeeds. The first call uses the entire name and each subsequent call
* chops off the last component. If we reach the beginning of the name
* then there must have been something wrong with the file (perhaps it
- * doesn't exist).
+ * doesn't exist).
*/
- if((fname = HDstrdup(argv[opt_ind])) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
+ if ((fname = HDstrdup(argv[H5_optind])) == NULL) {
+ error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__);
h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
/* Create a copy of file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- return -1;
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
/* Set to use the latest library format */
- if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
- return -1;
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
do {
- while(fname && *fname) {
- fid = h5tools_fopen(fname, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl, NULL, drivername, sizeof drivername);
+ while (fname && *fname) {
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, fapl, FALSE, drivername,
+ sizeof drivername);
- if(fid >= 0) {
+ if (fid >= 0) {
HDfprintf(stdout, "Opened \"%s\" with %s driver.\n", fname, drivername);
break; /*success*/
- } /* end if */
+ } /* end if */
/* Shorten the file name; lengthen the object name */
- x = dname;
+ x = dname;
dname = HDstrrchr(fname, '/');
- if(x)
+ if (x)
*x = '/';
- if(!dname)
+ if (!dname)
break;
*dname = '\0';
} /* end while */
- /* Try opening the file again if somehow unstable */
- } while(g_retry-- > 0 && fid == FAIL);
+ /* Try opening the file again if somehow unstable */
+ } while (g_retry-- > 0 && fid == FAIL);
- if(fid < 0) {
+ if (fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
- if(fname) HDfree(fname);
- if(fapl >= 0) H5Pclose(fapl);
- leave(EXIT_FAILURE);
- }
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
- if(!dname) {
+ if (!dname) {
error_msg("no dataset specified\n");
h5tools_setstatus(EXIT_FAILURE);
- } else {
+ goto done;
+ }
+ else {
*dname = '/';
- x = dname;
- if((dname = HDstrdup(dname)) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
+ x = dname;
+ if ((dname = HDstrdup(dname)) == NULL) {
+ error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__);
h5tools_setstatus(EXIT_FAILURE);
- } else {
+ goto done;
+ }
+ else {
*x = '\0';
/* Validate dataset */
- if(check_dataset(fid, dname) < 0)
+ if (check_dataset(fid, dname) < 0) {
h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
/* Validate input "fields" */
- else if(g_list_of_fields && *g_list_of_fields)
- if(process_cmpd_fields(fid, dname) < 0)
+ else if (g_list_of_fields && *g_list_of_fields) {
+ if (process_cmpd_fields(fid, dname) < 0) {
h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ }
}
- }
+ }
- /* If everything is fine, start monitoring the datset */
- if(h5tools_getstatus() != EXIT_FAILURE)
- if(monitor_dataset(fid, dname) < 0)
+ /* If everything is fine, start monitoring the dataset */
+ if (h5tools_getstatus() != EXIT_FAILURE)
+ if (monitor_dataset(fid, dname) < 0)
h5tools_setstatus(EXIT_FAILURE);
-
+
+done:
/* Free spaces */
- if(fname) HDfree(fname);
- if(dname) HDfree(dname);
- if(g_list_of_fields) HDfree(g_list_of_fields);
- if(g_listv) {
+ if (fname)
+ HDfree(fname);
+ if (dname)
+ HDfree(dname);
+ if (g_list_of_fields)
+ HDfree(g_list_of_fields);
+ if (g_listv) {
H5LD_clean_vector(g_listv);
HDfree(g_listv);
}
- if(g_dup_fields) HDfree(g_dup_fields);
+ if (g_dup_fields)
+ HDfree(g_dup_fields);
/* Close the file access property list */
- if(fapl >= 0 && H5Pclose(fapl) < 0) {
+ if (fapl >= 0 && H5Pclose(fapl) < 0) {
error_msg("unable to close file access property list\n");
h5tools_setstatus(EXIT_FAILURE);
}
/* Close the file */
- if(H5Fclose(fid) < 0) {
+ if (fid >= 0 && H5Fclose(fid) < 0) {
error_msg("unable to close file\n");
h5tools_setstatus(EXIT_FAILURE);
}
- H5Eset_auto2(H5E_DEFAULT, func, edata);
/* exit */
leave(h5tools_getstatus());
} /* main() */
-
diff --git a/hl/tools/h5watch/h5watchgentest.c b/hl/tools/h5watch/h5watchgentest.c
index 18e15fc..44cb0cb 100644
--- a/hl/tools/h5watch/h5watchgentest.c
+++ b/hl/tools/h5watch/h5watchgentest.c
@@ -6,7 +6,7 @@
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
@@ -15,44 +15,44 @@
#include "H5HLprivate2.h"
/*
- * WATCH.h5: file with various types of datasets for testing--
+ * WATCH.h5: file with various types of datasets for testing--
*
- * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting:
- * DSET_ONE: one-dimensional dataset
- * DSET_TWO: two-dimensional dataset
- * DSET_CMPD: one-dimensional dataset with compound type
+ * The following datasets are chunked, H5D_ALLOC_TIME_INCR, max. dimensional setting:
+ * DSET_ONE: one-dimensional dataset
+ * DSET_TWO: two-dimensional dataset
+ * DSET_CMPD: one-dimensional dataset with compound type
* DSET_CMPD_ESC: one-dimensional dataset with compound type and member names with
- * escape/separator characters
- * DSET_CMPD_TWO: two-dimensional dataset with compound type
- *
- * The following datasets are one-dimensional, chunked, max. dimension setting:
- * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY
- * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE
- *
- * The following datasets are one-dimensional:
- * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE
- * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR
+ * escape/separator characters
+ * DSET_CMPD_TWO: two-dimensional dataset with compound type
+ *
+ * The following datasets are one-dimensional, chunked, max. dimension setting:
+ * DSET_ALLOC_EARLY: dataset with H5D_ALLOC_TIME_EARLY
+ * DSET_ALLOC_LATE: dataset H5D_ALLOC_TIME_LATE
+ *
+ * The following datasets are one-dimensional:
+ * DSET_NONE: fixed dimension setting, contiguous, H5D_ALLOC_TIME_LATE
+ * DSET_NOMAX: fixed dimension setting, chunked, H5D_ALLOC_TIME_INCR
*/
-#define ONE_DIMS0 10
-#define MAX_ONE_DIMS0 100
+#define ONE_DIMS0 10
+#define MAX_ONE_DIMS0 100
-#define DSET_ONE "DSET_ONE"
-#define DSET_NONE "DSET_NONE"
-#define DSET_NOMAX "DSET_NOMAX"
-#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
+#define DSET_ONE "DSET_ONE"
+#define DSET_NONE "DSET_NONE"
+#define DSET_NOMAX "DSET_NOMAX"
+#define DSET_ALLOC_LATE "DSET_ALLOC_LATE"
#define DSET_ALLOC_EARLY "DSET_ALLOC_EARLY"
-#define DSET_CMPD "DSET_CMPD"
-#define DSET_CMPD_ESC "DSET_CMPD_ESC"
+#define DSET_CMPD "DSET_CMPD"
+#define DSET_CMPD_ESC "DSET_CMPD_ESC"
-#define TWO_DIMS0 4
-#define TWO_DIMS1 10
-#define MAX_TWO_DIMS0 60
-#define MAX_TWO_DIMS1 100
+#define TWO_DIMS0 4
+#define TWO_DIMS1 10
+#define MAX_TWO_DIMS0 60
+#define MAX_TWO_DIMS1 100
-#define DSET_TWO "DSET_TWO"
-#define DSET_CMPD_TWO "DSET_CMPD_TWO"
+#define DSET_TWO "DSET_TWO"
+#define DSET_CMPD_TWO "DSET_CMPD_TWO"
-#define CHUNK_SIZE 2
+#define CHUNK_SIZE 2
#define FILE "WATCH.h5"
@@ -64,9 +64,9 @@ typedef struct sub22_t {
} sub22_t;
typedef struct sub2_t {
- int a;
+ int a;
sub22_t b;
- int c;
+ int c;
} sub2_t;
typedef struct sub4_t {
@@ -75,7 +75,7 @@ typedef struct sub4_t {
} sub4_t;
typedef struct set_t {
- int field1;
+ int field1;
sub2_t field2;
double field3;
sub4_t field4;
@@ -90,58 +90,63 @@ typedef struct set_t {
**************************************************************************************
*/
static herr_t
-generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid, void *data)
+generate_dset(hid_t fid, const char *dname, int ndims, hsize_t *dims, hsize_t *maxdims, hid_t dtid,
+ void *data)
{
- hid_t dcpl=-1; /* Dataset creation property */
- hid_t did=-1; /* Dataset id */
- hid_t sid=-1; /* Dataspace id */
- int i; /* Local index variable */
- hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */
+ hid_t dcpl = -1; /* Dataset creation property */
+ hid_t did = -1; /* Dataset id */
+ hid_t sid = -1; /* Dataspace id */
+ int i; /* Local index variable */
+ hsize_t chunk_dims[H5S_MAX_RANK]; /* Dimension sizes for chunks */
/* Create the dataspace */
- if((sid = H5Screate_simple(ndims, dims, maxdims)) < 0)
+ if ((sid = H5Screate_simple(ndims, dims, maxdims)) < 0)
goto done;
/* Set up dataset's creation properties */
- if(!HDstrcmp(dname, DSET_NONE))
+ if (!HDstrcmp(dname, DSET_NONE))
dcpl = H5P_DEFAULT;
else {
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
goto done;
- for(i = 0; i < ndims; i++)
+ for (i = 0; i < ndims; i++)
chunk_dims[i] = CHUNK_SIZE;
- if(H5Pset_chunk(dcpl, ndims, chunk_dims) < 0)
+ if (H5Pset_chunk(dcpl, ndims, chunk_dims) < 0)
goto done;
} /* end else */
- if(!HDstrcmp(dname, DSET_ALLOC_LATE)) {
- if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0)
+ if (!HDstrcmp(dname, DSET_ALLOC_LATE)) {
+ if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0)
goto done;
- } else if(!HDstrcmp(dname, DSET_ALLOC_EARLY)) {
- if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0)
+ }
+ else if (!HDstrcmp(dname, DSET_ALLOC_EARLY)) {
+ if (H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_EARLY) < 0)
goto done;
} /* end if-else */
/* Create the dataset */
- if((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ if ((did = H5Dcreate2(fid, dname, dtid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
goto done;
/* Write to the dataset */
- if(H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
+ if (H5Dwrite(did, dtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
goto done;
/* Closing */
- if(H5Pclose(dcpl) < 0) goto done;
- if(H5Sclose(sid) < 0) goto done;
- if(H5Dclose(did) < 0) goto done;
+ if (H5Pclose(dcpl) < 0)
+ goto done;
+ if (H5Sclose(sid) < 0)
+ goto done;
+ if (H5Dclose(did) < 0)
+ goto done;
return SUCCEED;
done:
H5E_BEGIN_TRY
- H5Sclose(sid);
- H5Pclose(dcpl);
- H5Dclose(did);
+ H5Sclose(sid);
+ H5Pclose(dcpl);
+ H5Dclose(did);
H5E_END_TRY
return FAIL;
@@ -150,49 +155,49 @@ done:
int
main(void)
{
- hid_t fid=-1; /* File id */
- hid_t fapl=-1; /* File access property list id */
- hsize_t cur_dims[1]; /* Dimension sizes */
- hsize_t max_dims[1]; /* Maximum dimension sizes */
- hsize_t cur2_dims[2]; /* Current dimension sizes */
- hsize_t max2_dims[2]; /* Maximum dimension sizes */
- hid_t set_tid=-1, esc_set_tid=-1; /* Compound type id */
- hid_t sub22_tid=-1; /* Compound type id */
- hid_t sub2_tid=-1, esc_sub2_tid=-1; /* Compound type id */
- hid_t sub4_tid=-1, esc_sub4_tid=-1; /* Compound type id */
- int one_data[ONE_DIMS0]; /* Buffer for data */
- int two_data[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data */
- set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */
- set_t two_cbuf[TWO_DIMS0*TWO_DIMS1]; /* Buffer for data with compound type */
- int i; /* Local index variable */
+ hid_t fid = -1; /* File id */
+ hid_t fapl = -1; /* File access property list id */
+ hsize_t cur_dims[1]; /* Dimension sizes */
+ hsize_t max_dims[1]; /* Maximum dimension sizes */
+ hsize_t cur2_dims[2]; /* Current dimension sizes */
+ hsize_t max2_dims[2]; /* Maximum dimension sizes */
+ hid_t set_tid = -1, esc_set_tid = -1; /* Compound type id */
+ hid_t sub22_tid = -1; /* Compound type id */
+ hid_t sub2_tid = -1, esc_sub2_tid = -1; /* Compound type id */
+ hid_t sub4_tid = -1, esc_sub4_tid = -1; /* Compound type id */
+ int one_data[ONE_DIMS0]; /* Buffer for data */
+ int two_data[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data */
+ set_t one_cbuf[ONE_DIMS0]; /* Buffer for data with compound type */
+ set_t two_cbuf[TWO_DIMS0 * TWO_DIMS1]; /* Buffer for data with compound type */
+ int i; /* Local index variable */
/* Create a copy of file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
HDexit(EXIT_FAILURE);
/* Set to use the latest library format */
- if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
HDexit(EXIT_FAILURE);
/* Create a file with the latest format */
- if((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ if ((fid = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
HDexit(EXIT_FAILURE);
/* Initialization for one-dimensional dataset */
cur_dims[0] = ONE_DIMS0;
max_dims[0] = MAX_ONE_DIMS0;
- for(i = 0; i < ONE_DIMS0; i++)
+ for (i = 0; i < ONE_DIMS0; i++)
one_data[i] = i;
/* Generate DSET_ONE, DSET_NONE, DSET_NOMAX, DSET_ALLOC_LATE, DSET_EARLY */
- if(generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
+ if (generate_dset(fid, DSET_ONE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
goto done;
- if(generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0)
+ if (generate_dset(fid, DSET_NONE, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0)
goto done;
- if(generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0)
+ if (generate_dset(fid, DSET_NOMAX, 1, cur_dims, NULL, H5T_NATIVE_INT, one_data) < 0)
goto done;
- if(generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
+ if (generate_dset(fid, DSET_ALLOC_LATE, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
goto done;
- if(generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
+ if (generate_dset(fid, DSET_ALLOC_EARLY, 1, cur_dims, max_dims, H5T_NATIVE_INT, one_data) < 0)
goto done;
/* Initialization for two-dimensional dataset */
@@ -201,98 +206,98 @@ main(void)
max2_dims[0] = MAX_TWO_DIMS0;
max2_dims[1] = MAX_TWO_DIMS1;
- for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++)
+ for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++)
two_data[i] = i;
/* Generate DSET_TWO */
- if(generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0)
+ if (generate_dset(fid, DSET_TWO, 2, cur2_dims, max2_dims, H5T_NATIVE_INT, two_data) < 0)
goto done;
/* Initialization for one-dimensional compound typed dataset */
cur_dims[0] = ONE_DIMS0;
max_dims[0] = MAX_ONE_DIMS0;
- for(i = 0; i < ONE_DIMS0; i++) {
- one_cbuf[i].field1 = 1;
- one_cbuf[i].field2.a = 2;
- one_cbuf[i].field2.c = 4;
+ for (i = 0; i < ONE_DIMS0; i++) {
+ one_cbuf[i].field1 = 1;
+ one_cbuf[i].field2.a = 2;
+ one_cbuf[i].field2.c = 4;
one_cbuf[i].field2.b.a = 20;
one_cbuf[i].field2.b.b = 40;
one_cbuf[i].field2.b.c = 80;
- one_cbuf[i].field3 = 3.0F;
- one_cbuf[i].field4.a = 4;
- one_cbuf[i].field4.b = 8;
+ one_cbuf[i].field3 = 3.0;
+ one_cbuf[i].field4.a = 4;
+ one_cbuf[i].field4.b = 8;
} /* end for */
/* Create the compound type */
- if((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0)
+ if ((sub22_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub22_t))) < 0)
goto done;
- if(H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(sub22_tid, "a", HOFFSET(sub22_t, a), H5T_NATIVE_INT) < 0)
goto done;
- if(H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(sub22_tid, "b", HOFFSET(sub22_t, b), H5T_NATIVE_INT) < 0)
goto done;
- if(H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(sub22_tid, "c", HOFFSET(sub22_t, c), H5T_NATIVE_INT) < 0)
goto done;
- if((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0)
+ if ((sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0)
goto done;
- if(H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(sub2_tid, "a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0)
goto done;
- if(H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0)
+ if (H5Tinsert(sub2_tid, "b", HOFFSET(sub2_t, b), sub22_tid) < 0)
goto done;
- if(H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(sub2_tid, "c", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0)
goto done;
- if((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0)
+ if ((sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0)
goto done;
- if(H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(sub4_tid, "a", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0)
goto done;
- if(H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(sub4_tid, "b", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0)
goto done;
- if((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0)
+ if ((set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0)
goto done;
- if(H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(set_tid, "field1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0)
goto done;
- if(H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0)
+ if (H5Tinsert(set_tid, "field2", HOFFSET(set_t, field2), sub2_tid) < 0)
goto done;
- if(H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0)
+ if (H5Tinsert(set_tid, "field3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0)
goto done;
- if(H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0)
+ if (H5Tinsert(set_tid, "field4", HOFFSET(set_t, field4), sub4_tid) < 0)
goto done;
/* Create the compound type with escape/separator characters */
- if((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0)
+ if ((esc_sub2_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub2_t))) < 0)
goto done;
- if(H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(esc_sub2_tid, ".a", HOFFSET(sub2_t, a), H5T_NATIVE_INT) < 0)
goto done;
- if(H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0)
+ if (H5Tinsert(esc_sub2_tid, ",b", HOFFSET(sub2_t, b), sub22_tid) < 0)
goto done;
- if(H5Tinsert(esc_sub2_tid, "\\K", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(esc_sub2_tid, "\\K", HOFFSET(sub2_t, c), H5T_NATIVE_INT) < 0)
goto done;
- if((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0)
+ if ((esc_sub4_tid = H5Tcreate(H5T_COMPOUND, sizeof(sub4_t))) < 0)
goto done;
- if(H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(esc_sub4_tid, "a.", HOFFSET(sub4_t, a), H5T_NATIVE_INT) < 0)
goto done;
- if(H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(esc_sub4_tid, "b,", HOFFSET(sub4_t, b), H5T_NATIVE_INT) < 0)
goto done;
- if((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0)
+ if ((esc_set_tid = H5Tcreate(H5T_COMPOUND, sizeof(set_t))) < 0)
goto done;
- if(H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0)
+ if (H5Tinsert(esc_set_tid, "field,1", HOFFSET(set_t, field1), H5T_NATIVE_INT) < 0)
goto done;
- if(H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0)
+ if (H5Tinsert(esc_set_tid, "field2.", HOFFSET(set_t, field2), esc_sub2_tid) < 0)
goto done;
- if(H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0)
+ if (H5Tinsert(esc_set_tid, "field\\3", HOFFSET(set_t, field3), H5T_NATIVE_DOUBLE) < 0)
goto done;
- if(H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0)
+ if (H5Tinsert(esc_set_tid, "field4,", HOFFSET(set_t, field4), esc_sub4_tid) < 0)
goto done;
/* Generate DSET_CMPD, DSET_CMPD_ESC */
- if(generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0)
+ if (generate_dset(fid, DSET_CMPD, 1, cur_dims, max_dims, set_tid, one_cbuf) < 0)
goto done;
- if(generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0)
+ if (generate_dset(fid, DSET_CMPD_ESC, 1, cur_dims, max_dims, esc_set_tid, one_cbuf) < 0)
goto done;
/* Initialization for two-dimensional compound typed dataset */
@@ -301,48 +306,56 @@ main(void)
max2_dims[0] = MAX_TWO_DIMS0;
max2_dims[0] = MAX_TWO_DIMS1;
- for(i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) {
- two_cbuf[i].field1 = 1;
- two_cbuf[i].field2.a = 2;
- two_cbuf[i].field2.c = 4;
+ for (i = 0; i < (TWO_DIMS0 * TWO_DIMS1); i++) {
+ two_cbuf[i].field1 = 1;
+ two_cbuf[i].field2.a = 2;
+ two_cbuf[i].field2.c = 4;
two_cbuf[i].field2.b.a = 20;
two_cbuf[i].field2.b.b = 40;
two_cbuf[i].field2.b.c = 80;
- two_cbuf[i].field3 = 3.0F;
- two_cbuf[i].field4.a = 4;
- two_cbuf[i].field4.b = 8;
+ two_cbuf[i].field3 = 3.0;
+ two_cbuf[i].field4.a = 4;
+ two_cbuf[i].field4.b = 8;
} /* end for */
/* Generate DSET_CMPD_TWO */
- if(generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0)
+ if (generate_dset(fid, DSET_CMPD_TWO, 2, cur2_dims, max2_dims, set_tid, two_cbuf) < 0)
goto done;
/* Closing */
- if(H5Tclose(sub22_tid) < 0) goto done;
- if(H5Tclose(sub2_tid) < 0) goto done;
- if(H5Tclose(sub4_tid) < 0) goto done;
- if(H5Tclose(set_tid) < 0) goto done;
- if(H5Tclose(esc_sub2_tid) < 0) goto done;
- if(H5Tclose(esc_sub4_tid) < 0) goto done;
- if(H5Tclose(esc_set_tid) < 0) goto done;
- if(H5Pclose(fapl) < 0) goto done;
- if(H5Fclose(fid) < 0) goto done;
+ if (H5Tclose(sub22_tid) < 0)
+ goto done;
+ if (H5Tclose(sub2_tid) < 0)
+ goto done;
+ if (H5Tclose(sub4_tid) < 0)
+ goto done;
+ if (H5Tclose(set_tid) < 0)
+ goto done;
+ if (H5Tclose(esc_sub2_tid) < 0)
+ goto done;
+ if (H5Tclose(esc_sub4_tid) < 0)
+ goto done;
+ if (H5Tclose(esc_set_tid) < 0)
+ goto done;
+ if (H5Pclose(fapl) < 0)
+ goto done;
+ if (H5Fclose(fid) < 0)
+ goto done;
HDexit(EXIT_SUCCESS);
done:
H5E_BEGIN_TRY
- H5Tclose(sub22_tid);
- H5Tclose(sub2_tid);
- H5Tclose(sub4_tid);
- H5Tclose(set_tid);
- H5Tclose(esc_sub2_tid);
- H5Tclose(esc_sub4_tid);
- H5Tclose(esc_set_tid);
- H5Pclose(fapl);
- H5Fclose(fid);
+ H5Tclose(sub22_tid);
+ H5Tclose(sub2_tid);
+ H5Tclose(sub4_tid);
+ H5Tclose(set_tid);
+ H5Tclose(esc_sub2_tid);
+ H5Tclose(esc_sub4_tid);
+ H5Tclose(esc_set_tid);
+ H5Pclose(fapl);
+ H5Fclose(fid);
H5E_END_TRY
HDexit(EXIT_FAILURE);
} /* end main() */
-
diff --git a/hl/tools/h5watch/swmr_check_compat_vfd.c b/hl/tools/h5watch/swmr_check_compat_vfd.c
deleted file mode 100644
index 26f76cb..0000000
--- a/hl/tools/h5watch/swmr_check_compat_vfd.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Copyright by The HDF Group. *
- * Copyright by the Board of Trustees of the University of Illinois. *
- * All rights reserved. *
- * *
- * This file is part of HDF5. The full HDF5 copyright notice, including *
- * terms governing use, modification, and redistribution, is contained in *
- * the COPYING file, which can be found at the root of the source code *
- * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
- * If you do not have access to either file, you may request a copy from *
- * help@hdfgroup.org. *
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-/* Purpose: This is a small program that checks if the HDF5_DRIVER
- * environment variable is set to a value that supports SWMR.
- *
- * It is intended for use in shell scripts.
- */
-
-#include <stdlib.h>
-
-#include "H5private.h"
-
-/* This file needs to access the file driver testing code */
-#define H5FD_FRIEND /*suppress error about including H5FDpkg */
-#define H5FD_TESTING
-#include "H5FDpkg.h" /* File drivers */
-
-
-/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose: Inspects the HDF5_DRIVER environment variable, which
- * determines the VFD that the test harness will use with
- * the majority of the tests.
- *
- * Return: VFD supports SWMR: EXIT_SUCCESS
- *
- * VFD does not support SWMR
- * or failure: EXIT_FAILURE
- *
- *-------------------------------------------------------------------------
- */
-int
-main(void)
-{
- char *driver = NULL;
-
- driver = HDgetenv("HDF5_DRIVER");
-
- if(H5FD__supports_swmr_test(driver))
- return EXIT_SUCCESS;
- else
- return EXIT_FAILURE;
-
-} /* end main() */
-
diff --git a/hl/tools/h5watch/testh5watch.sh.in b/hl/tools/h5watch/testh5watch.sh.in
index d31bcc3..0432384 100644
--- a/hl/tools/h5watch/testh5watch.sh.in
+++ b/hl/tools/h5watch/testh5watch.sh.in
@@ -7,18 +7,19 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
# Tests for the h5watch tool
#
+utils_testdir=@abs_top_builddir@/@H5_UTILS_TEST_BUILDDIR@
# Check to see if the VFD specified by the HDF5_DRIVER environment variable
# supports SWMR.
-./swmr_check_compat_vfd
+$utils_testdir/swmr_check_compat_vfd
rc=$?
-if [[ $rc != 0 ]] ; then
+if [ $rc != 0 ] ; then
echo
echo "The VFD specified by the HDF5_DRIVER environment variable"
echo "does not support SWMR."
@@ -66,10 +67,6 @@ fi
nerrors=0
verbose=yes
-# The build (current) directory might be different than the source directory.
-if test -z "$srcdir"; then
- srcdir=.
-fi
test -d ../testfiles || mkdir ../testfiles
# Print a line-line message left justified in a field of 70 characters