diff --git a/.clang-format b/.clang-format index 0f2cc0f852..ea769c8bda 100644 --- a/.clang-format +++ b/.clang-format @@ -11,7 +11,7 @@ BraceWrapping: BreakBeforeBraces: Stroustrup BreakAfterJavaFieldAnnotations: true BreakStringLiterals: true -ColumnLimit: 110 # Update $max_trace_macro_line_len in bin/trace also +ColumnLimit: 110 IndentWidth: 4 --- Language: Cpp @@ -24,7 +24,6 @@ AllowShortFunctionsOnASingleLine: None AlwaysBreakAfterReturnType: AllDefinitions # Can enable the following section when llvm 12.x is out #AttributeMacros: -ForEachMacros: ['ALL_MEMBERS', 'UNIQUE_MEMBERS'] IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 3 diff --git a/.github/workflows/autotools.yml b/.github/workflows/autotools.yml index c98abc3422..0105e7bb43 100644 --- a/.github/workflows/autotools.yml +++ b/.github/workflows/autotools.yml @@ -11,29 +11,10 @@ permissions: # in parallel. We just have one job, but the matrix items defined below will # run in parallel. jobs: - call-workflow-xdr-autotools: - name: "Autotools XDR Workflows" - uses: ./.github/workflows/main-auto.yml - with: - xdr: enable - netcdf: enable - shared: enable - build_mode: "production" - - call-system-xdr-autotools: - name: "Autotools System XDR Workflows" - uses: ./.github/workflows/main-auto.yml - with: - xdr: disable - netcdf: enable - shared: enable - build_mode: "production" - call-debug-netcdf-autotools: name: "Autotools Debug NetCDF Workflows" uses: ./.github/workflows/main-auto.yml with: - xdr: enable netcdf: enable shared: enable build_mode: "debug" @@ -42,7 +23,6 @@ jobs: name: "Autotools Release NetCDF Workflows" uses: ./.github/workflows/main-auto.yml with: - xdr: enable netcdf: enable shared: enable build_mode: "production" @@ -52,7 +32,6 @@ jobs: uses: ./.github/workflows/main-auto.yml with: netcdf: disable - xdr: enable shared: disable build_mode: "debug" @@ -61,7 +40,6 @@ jobs: uses: ./.github/workflows/main-auto.yml with: netcdf: disable - xdr: enable shared: disable build_mode: "production" diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index be69fb34dc..fec84b3a86 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -13,5 +13,5 @@ jobs: - uses: actions/checkout@v4 - uses: codespell-project/actions-codespell@master with: - skip: ./config/sanitizer/sanitizers.cmake,./hdf/util/testfiles/*.raw,./hdf/util/testfiles/head.r8,./mfhdf/ncdump/*,./mfhdf/ncgen/*,./mfhdf/nctest/*,./mfhdf/xdr/*,./mfhdf/README,./mfhdf/THANKS,./mfhdf/FAQ + skip: ./config/sanitizer/sanitizers.cmake,./hdf/util/testfiles/*.raw,./hdf/util/testfiles/head.r8,./mfhdf/ncdump/*,./mfhdf/ncgen/*,./mfhdf/nctest/*,./mfhdf/README,./mfhdf/THANKS,./mfhdf/FAQ ignore_words_list: acount,anid,ans,clude,isnt,inout,fo,msdos,nam,nd,pres,sav,shs,siz,varn,vlone diff --git a/.github/workflows/hdfeos2.yml b/.github/workflows/hdfeos2.yml index 3b1803127f..d9951a3a31 100644 --- a/.github/workflows/hdfeos2.yml +++ b/.github/workflows/hdfeos2.yml @@ -16,7 +16,7 @@ jobs: - name: Install HDF4 run: | ./autogen.sh - ./configure --prefix=/usr/local --enable-shared --enable-hdf4-xdr -disable-fortran --disable-netcdf + ./configure --prefix=/usr/local --enable-shared --disable-fortran --disable-netcdf make sudo make install - name: Install HDF-EOS2 diff --git a/.github/workflows/intel-auto.yml b/.github/workflows/intel-auto.yml index e8a9a46fd0..d3ceb7d0c4 100644 --- a/.github/workflows/intel-auto.yml +++ b/.github/workflows/intel-auto.yml @@ -60,7 +60,6 @@ jobs: --enable-build-mode=${{ inputs.build_mode }} \ --enable-netcdf \ --enable-shared \ - --enable-hdf4-xdr \ --disable-fortran # BUILD diff --git a/.github/workflows/main-auto.yml b/.github/workflows/main-auto.yml index 735d51510a..94e65aaaa7 100644 --- a/.github/workflows/main-auto.yml +++ b/.github/workflows/main-auto.yml @@ -16,10 +16,6 @@ on: description: "netcdf enable/disable" required: true type: string - xdr: - description: "xdr enable/disable(system)" - required: true - type: string permissions: contents: read @@ -33,7 +29,7 @@ jobs: # Linux (Ubuntu) w/ gcc + Autotools # Autotools_build_and_test: - name: "GCC-${{ inputs.build_mode }}-NC=${{ inputs.netcdf }}d-XDR=${{ inputs.xdr }}d" + name: "GCC-${{ inputs.build_mode }}-NC=${{ inputs.netcdf }}d" # Don't run the action if the commit message says to skip CI if: "!contains(github.event.head_commit.message, 'skip-ci')" @@ -64,7 +60,6 @@ jobs: cd "${{ runner.workspace }}/build" $GITHUB_WORKSPACE/configure \ --enable-build-mode=${{ inputs.build_mode }} \ - --${{ inputs.xdr }}-hdf4-xdr \ --${{ inputs.netcdf }}-netcdf \ --disable-fortran \ --${{ inputs.shared }}-java \ diff --git a/.github/workflows/main-cmake-mingw.yml b/.github/workflows/main-cmake-mingw.yml index 44d5182c7d..1c55852cd5 100644 --- a/.github/workflows/main-cmake-mingw.yml +++ b/.github/workflows/main-cmake-mingw.yml @@ -69,7 +69,6 @@ jobs: -DBUILD_SHARED_LIBS:BOOL=${{ inputs.shared }} \ -DHDF4_BUILD_EXAMPLES:BOOL=ON \ -DBUILD_JPEG_WITH_PIC:BOOL=ON \ - -DHDF4_BUILD_XDR_LIB:BOOL=ON \ -DHDF4_ENABLE_NETCDF:BOOL=${{ inputs.netcdf }} \ -DHDF4_BUILD_FORTRAN:BOOL=OFF \ -DHDF4_BUILD_JAVA:BOOL=OFF \ @@ -104,4 +103,4 @@ jobs: - name: List files in the space run: | ls -l ${{ runner.workspace }}/build - \ No newline at end of file + diff --git a/.github/workflows/main-cmake.yml b/.github/workflows/main-cmake.yml index a3d4bf71da..98a85ce9a4 100644 --- a/.github/workflows/main-cmake.yml +++ b/.github/workflows/main-cmake.yml @@ -52,7 +52,6 @@ jobs: - name: "Windows MSVC" os: windows-latest toolchain: "" - xdr: ON fortran: OFF java: ON docs: ON @@ -69,7 +68,6 @@ jobs: # so it's not critical - name: "Ubuntu gcc" os: ubuntu-latest - xdr: ON fortran: OFF java: ON docs: ON @@ -88,7 +86,6 @@ jobs: # but that seems unnecessary - name: "MacOS Clang" os: macos-13 - xdr: ON fortran: OFF java: ON docs: ON @@ -168,7 +165,6 @@ jobs: -DBUILD_SHARED_LIBS:BOOL=${{ inputs.shared }} \ -DHDF4_BUILD_EXAMPLES:BOOL=ON \ -DBUILD_JPEG_WITH_PIC:BOOL=ON \ - -DHDF4_BUILD_XDR_LIB:BOOL=${{ matrix.xdr }} \ -DHDF4_ENABLE_NETCDF:BOOL=${{ inputs.netcdf }} \ -DHDF4_BUILD_FORTRAN:BOOL=${{ matrix.fortran }} \ -DHDF4_BUILD_JAVA:BOOL=${{ env.useJava }} \ @@ -231,4 +227,4 @@ jobs: path: ${{ runner.workspace }}/build/HDF-*-Darwin.tar.gz if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` if: ${{ (matrix.os == 'macos-13') && (inputs.netcdf == 'true') && (inputs.shared == 'true') }} - \ No newline at end of file + diff --git a/.github/workflows/ppc64.yml b/.github/workflows/ppc64.yml index 0a402b31bc..505683fbc8 100644 --- a/.github/workflows/ppc64.yml +++ b/.github/workflows/ppc64.yml @@ -44,7 +44,6 @@ jobs: cd "build" ../configure \ --enable-build-mode=production \ - --enable-hdf4-xdr \ --enable-netcdf \ --disable-fortran \ --disable-java \ @@ -91,7 +90,6 @@ jobs: -DBUILD_SHARED_LIBS:BOOL=ON \ -DHDF4_BUILD_EXAMPLES=ON \ -DBUILD_JPEG_WITH_PIC:BOOL=ON \ - -DHDF4_BUILD_XDR_LIB:BOOL=ON \ -DHDF4_ENABLE_NETCDF:BOOL=ON \ -DHDF4_BUILD_FORTRAN=OFF \ -DHDF4_BUILD_JAVA=OFF \ diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index 3eeb4c79a7..60a3321b39 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -51,7 +51,6 @@ endif () set (HDF4_INCLUDES_BUILD_TIME ${HDF4_HDF_SOURCE_DIR} ${HDF4_MFHDF_SOURCE_DIR} - ${HDF4_MFHDF_XDR_DIR} ${HDF4_BINARY_DIR} ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d08b682f2..189f542dfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,7 +152,6 @@ set (HDF4_SRC_LIB_CORENAME "hdf") set (HDF4_SRC_FCSTUB_LIB_CORENAME "hdf_fcstub") set (HDF4_SRC_FORTRAN_LIB_CORENAME "hdf_fortran") set (HDF4_MF_LIB_CORENAME "mfhdf") -set (HDF4_MF_XDR_LIB_CORENAME "xdr") set (HDF4_HDF_TEST_LIB_CORENAME "hdf_test") set (HDF4_HDF_TEST_FCSTUB_LIB_CORENAME "hdf_test_fcstub") set (HDF4_MF_FCSTUB_LIB_CORENAME "mfhdf_fcstub") @@ -170,7 +169,6 @@ set (HDF4_SRC_LIB_NAME "${HDF4_EXTERNAL_LIB_PREFIX}${HDF4_SRC_LIB_COREN set (HDF4_SRC_FCSTUB_LIB_NAME "${HDF4_EXTERNAL_LIB_PREFIX}${HDF4_SRC_FCSTUB_LIB_CORENAME}") set (HDF4_SRC_FORTRAN_LIB_NAME "${HDF4_EXTERNAL_LIB_PREFIX}${HDF4_SRC_FORTRAN_LIB_CORENAME}") set (HDF4_MF_LIB_NAME "${HDF4_EXTERNAL_LIB_PREFIX}${HDF4_MF_LIB_CORENAME}") -set (HDF4_MF_XDR_LIB_NAME "${HDF4_EXTERNAL_LIB_PREFIX}${HDF4_MF_XDR_LIB_CORENAME}") set (HDF4_HDF_TEST_LIB_NAME "${HDF4_EXTERNAL_LIB_PREFIX}${HDF4_HDF_TEST_LIB_CORENAME}") set (HDF4_HDF_TEST_FCSTUB_LIB_NAME "${HDF4_EXTERNAL_LIB_PREFIX}${HDF4_HDF_TEST_FCSTUB_LIB_CORENAME}") set (HDF4_MF_FCSTUB_LIB_NAME "${HDF4_EXTERNAL_LIB_PREFIX}${HDF4_MF_FCSTUB_LIB_CORENAME}") @@ -188,7 +186,6 @@ set (HDF4_SRC_LIB_TARGET "${HDF4_SRC_LIB_CORENAME}-static") set (HDF4_SRC_FCSTUB_LIB_TARGET "${HDF4_SRC_FCSTUB_LIB_CORENAME}-static") set (HDF4_SRC_FORTRAN_LIB_TARGET "${HDF4_SRC_FORTRAN_LIB_CORENAME}-static") set (HDF4_MF_LIB_TARGET "${HDF4_MF_LIB_CORENAME}-static") -set (HDF4_MF_XDR_LIB_TARGET "${HDF4_MF_XDR_LIB_CORENAME}-static") set (HDF4_HDF_TEST_LIB_TARGET "${HDF4_HDF_TEST_LIB_CORENAME}-static") set (HDF4_HDF_TEST_FCSTUB_LIB_TARGET "${HDF4_HDF_TEST_FCSTUB_LIB_CORENAME}-static") set (HDF4_MF_FCSTUB_LIB_TARGET "${HDF4_MF_FCSTUB_LIB_CORENAME}-static") @@ -202,7 +199,6 @@ set (HDF4_SRC_LIBSH_TARGET "${HDF4_SRC_LIB_CORENAME}-shared") set (HDF4_SRC_FCSTUB_LIBSH_TARGET "${HDF4_SRC_FCSTUB_LIB_CORENAME}-shared") set (HDF4_SRC_FORTRAN_LIBSH_TARGET "${HDF4_SRC_FORTRAN_LIB_CORENAME}-shared") set (HDF4_MF_LIBSH_TARGET "${HDF4_MF_LIB_CORENAME}-shared") -set (HDF4_MF_XDR_LIBSH_TARGET "${HDF4_MF_XDR_LIB_CORENAME}-shared") set (HDF4_MF_FCSTUB_LIBSH_TARGET "${HDF4_MF_FCSTUB_LIB_CORENAME}-shared") set (HDF4_MF_FORTRAN_LIBSH_TARGET "${HDF4_MF_FORTRAN_LIB_CORENAME}-shared") set (HDF4_TOOLS_LIBSH_TARGET "${HDF4_TOOLS_LIB_CORENAME}-shared") @@ -218,7 +214,6 @@ set (HDF4_MFHDFSOURCE_DIR ${HDF4_SOURCE_DIR}/mfhdf/libsrc) set (HDF4_MFHDF_TEST_DIR ${HDF4_SOURCE_DIR}/mfhdf/test) set (HDF4_MFHDF_UTIL_DIR ${HDF4_SOURCE_DIR}/mfhdf/util) set (HDF4_MFHDF_FORTRAN_DIR ${HDF4_SOURCE_DIR}/mfhdf/fortran) -set (HDF4_MFHDF_XDR_DIR ${HDF4_SOURCE_DIR}/mfhdf/xdr) set (HDF4_JAVA_JNI_SRC_DIR ${HDF4_SOURCE_DIR}/java/src/jni) set (HDF4_JAVA_HDF_SRC_DIR ${HDF4_SOURCE_DIR}/java/src/hdf) set (HDF4_JAVA_TEST_SRC_DIR ${HDF4_SOURCE_DIR}/java/test) @@ -472,48 +467,12 @@ if (HDF4_ENABLE_NETCDF) set (${HDF_PREFIX}_BUILD_NETCDF 1) endif () -#----------------------------------------------------------------------------- -# Option to build HDF4 xdr Library -#----------------------------------------------------------------------------- -option (HDF4_BUILD_XDR_LIB "Build HDF4 XDR Library" OFF) -if (WIN32 OR MINGW OR APPLE) - set (HDF4_BUILD_XDR_LIB ON CACHE BOOL "Build HDF4 XDR Library" FORCE) -else () - if (NOT HDF4_BUILD_XDR_LIB) - include (FindXDR) - if (XDR_FOUND) - set (CMAKE_REQUIRED_LIBRARIES "${XDR_LIBRARIES}" ) - message (STATUS "HDF4 XDR Library found: ${XDR_LIBRARIES}") - set (LINK_LIBS ${LINK_LIBS} ${XDR_LIBRARIES}) - set (LINK_SHARED_LIBS ${LINK_SHARED_LIBS} ${XDR_LIBRARIES}) - include_directories(${XDR_INCLUDE_DIRS}) - else () - set (HDF4_BUILD_XDR_LIB ON CACHE BOOL "Build HDF4 XDR Library" FORCE) - message (STATUS "HDF4 XDR Library will be built") - endif () - endif () -endif () - -if (HDF4_BUILD_XDR_LIB) - set (H4_NO_SYS_XDR_INC 1) - add_subdirectory (mfhdf/xdr) -endif () - #----------------------------------------------------------------------------- # Add the HDF4 Library Target to the build #----------------------------------------------------------------------------- add_subdirectory (hdf/src) add_subdirectory (mfhdf/libsrc) -if (HDF4_BUILD_XDR_LIB) - if (NOT ONLY_SHARED_LIBS) - add_dependencies (${HDF4_MF_LIB_TARGET} ${HDF4_MF_XDR_LIB_TARGET}) - endif () - if (BUILD_SHARED_LIBS) - add_dependencies (${HDF4_MF_LIBSH_TARGET} ${HDF4_MF_XDR_LIBSH_TARGET}) - endif () -endif () - #----------------------------------------------------------------------------- # Option to build documentation #----------------------------------------------------------------------------- diff --git a/CMakePresets.json b/CMakePresets.json index 4ca0d298e5..e3d2b31e1a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -58,7 +58,6 @@ "inherits": ["ci-StdCompression", "ci-StdExamples"], "cacheVariables": { "HDF_PACKAGE_NAMESPACE": {"type": "STRING", "value": "hdf4::"}, - "HDF4_BUILD_XDR_LIB": "ON", "HDF4_BUILD_GENERATORS": "ON", "HDF4_ENABLE_ALL_WARNINGS": "ON", "HDF4_MINGW_STATIC_GCC_LIBS": "ON" diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 70586cd453..9cb997d00a 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -41,7 +41,7 @@ macro (CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) endmacro () # ---------------------------------------------------------------------- -# WINDOWS Hard code Values +# WINDOWS hard-coded values # ---------------------------------------------------------------------- set (WINDOWS) @@ -64,7 +64,7 @@ if (WIN32 AND NOT MINGW) endif () if (WINDOWS) - set (HDF4_REQUIRED_LIBRARIES "ws2_32.lib;wsock32.lib") + set (CMAKE_REQUIRED_LIBRARIES "ws2_32.lib;wsock32.lib") set (${HDF_PREFIX}_HAVE_WIN32_API 1) set (${HDF_PREFIX}_HAVE_LIBM 1) set (${HDF_PREFIX}_HAVE_STRDUP 1) @@ -85,7 +85,7 @@ if (WINDOWS) endif () # ---------------------------------------------------------------------- -# END of WINDOWS Hard code Values +# END of WINDOWS hard-coded values # ---------------------------------------------------------------------- if (NOT WINDOWS) @@ -451,19 +451,6 @@ CHECK_FUNCTION_EXISTS (asprintf ${HDF_PREFIX}_HAVE_ASPRINTF) CHECK_FUNCTION_EXISTS (vasprintf ${HDF_PREFIX}_HAVE_VASPRINTF) CHECK_FUNCTION_EXISTS (waitpid ${HDF_PREFIX}_HAVE_WAITPID) -if (NOT WINDOWS) - CHECK_FUNCTION_EXISTS (ntohl ${HDF_PREFIX}_HAVE_NTOHL) - CHECK_FUNCTION_EXISTS (htonl ${HDF_PREFIX}_HAVE_HTONL) - CHECK_FUNCTION_EXISTS (ntohs ${HDF_PREFIX}_HAVE_NTOHS) - CHECK_FUNCTION_EXISTS (htons ${HDF_PREFIX}_HAVE_HTONS) -else () - set (CMAKE_REQUIRED_LIBRARIES "ws2_32") - check_symbol_exists (ntohl "winsock2.h" ${HDF_PREFIX}_HAVE_NTOHL) - check_symbol_exists (htonl "winsock2.h" ${HDF_PREFIX}_HAVE_HTONL) - check_symbol_exists (ntohs "winsock2.h" ${HDF_PREFIX}_HAVE_NTOHS) - check_symbol_exists (htons "winsock2.h" ${HDF_PREFIX}_HAVE_HTONS) -endif () - #----------------------------------------------------------------------------- # Check how to print a Long Long integer #----------------------------------------------------------------------------- diff --git a/config/cmake/FindXDR.cmake b/config/cmake/FindXDR.cmake deleted file mode 100644 index ded9ba13a7..0000000000 --- a/config/cmake/FindXDR.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# Try to find the XDR library and set some required variables -# -# Once run this will define: -# -# XDR_FOUND = system has XDR lib -# -# XDR_LIBRARIES = full path to the libraries, if required -# - -include(CheckIncludeFile) -include(CheckCSourceCompiles) -include(CheckFunctionExists) -include(CheckTypeSize) -include(CheckLibraryExists) - -## First try to find the required header files (rpc/types.h, rpc/xdr.h) -find_path(XDR_INCLUDE_DIR NAMES rpc/types.h PATHS "/usr/include" "/usr/include/tirpc") - -#check for the XDR functions: their interface and the libraries they're hidden in. - ## Now let's see if we need an extra lib to compile it - set(XDR_INT_FOUND) - CHECK_FUNCTION_EXISTS(xdr_int XDR_INT_FOUND) - if (NOT XDR_INT_FOUND) - foreach(lib nsl rpc tirpc) - ## Try to find the corresponding lib - message(STATUS "Try to find the library ${lib}.") - set(XDR_INT_LIBRARY) - find_library(XDR_INT_LIBRARY ${lib}) - - if (XDR_INT_LIBRARY) - message(STATUS "Found library ${lib}. Check for symbol.") - CHECK_LIBRARY_EXISTS(${XDR_INT_LIBRARY} xdr_int "" XDR_INT_SYMBOL_FOUND) - endif() - if (XDR_INT_SYMBOL_FOUND) - set(XDR_LIBRARIES ${XDR_INT_LIBRARY}) - set(XDR_INCLUDE_DIRS ${XDR_INCLUDE_DIR}) - set(XDR_INT_FOUND TRUE) - break() - endif() - endforeach() - endif() - - if(NOT XDR_INT_FOUND) - message(STATUS "Could not locate xdr symbols.") - else() - set(XDR_FOUND TRUE) - endif() diff --git a/config/cmake/h4config.h.in b/config/cmake/h4config.h.in index afe8127835..2207a3bd70 100644 --- a/config/cmake/h4config.h.in +++ b/config/cmake/h4config.h.in @@ -41,12 +41,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine H4_HAVE_WINSOCK2_H @H4_HAVE_WINSOCK2_H@ -/* Define to 1 if you have the `htonl' function. */ -#cmakedefine H4_HAVE_HTONL @H4_HAVE_HTONL@ - -/* Define to 1 if you have the `htons' function. */ -#cmakedefine H4_HAVE_HTONS @H4_HAVE_HTONS@ - /* Define to 1 if you have the header file. */ #cmakedefine H4_HAVE_INTTYPES_H @H4_HAVE_INTTYPES_H@ @@ -77,18 +71,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine H4_HAVE_NETINET_IN_H @H4_HAVE_NETINET_IN_H@ -/* Define to 1 if you have the `ntohl' function. */ -#cmakedefine H4_HAVE_NTOHL @H4_HAVE_NTOHL@ - -/* Define to 1 if you have the `ntohs' function. */ -#cmakedefine H4_HAVE_NTOHS @H4_HAVE_NTOHS@ - /* Define to 1 if you have the header file. */ #cmakedefine H4_HAVE_RESOLV_H @H4_HAVE_RESOLV_H@ -/* Define to 1 if you have the system XDR library. */ -#cmakedefine H4_HAVE_RPC @H4_HAVE_RPC@ - /* Define to 1 if you have the header file. */ #cmakedefine H4_HAVE_STDDEF_H @H4_HAVE_STDDEF_H@ @@ -159,9 +144,6 @@ /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #cmakedefine H4_NO_MINUS_C_MINUS_O @H4_NO_MINUS_C_MINUS_O@ -/* Not using system xdr */ -#cmakedefine H4_NO_SYS_XDR_INC @H4_NO_SYS_XDR_INC@ - /* Name of package */ #define H4_PACKAGE "@HDF4_PACKAGE@" @@ -183,6 +165,9 @@ /* Define to the version of this package. */ #define H4_PACKAGE_VERSION "@HDF4_PACKAGE_VERSION_STRING@" +/* The size of `long', as computed by sizeof. */ +#define H4_SIZEOF_LONG @H4_SIZEOF_LONG@ + /* Define to 1 if all of the C90 standard headers exist (not just the ones required in a freestanding environment). This macro is provided for backward compatibility; new code need not use it. */ diff --git a/config/cmake/hdf4-config.cmake.in b/config/cmake/hdf4-config.cmake.in index 40f14b55ae..bd6fa1ae0d 100644 --- a/config/cmake/hdf4-config.cmake.in +++ b/config/cmake/hdf4-config.cmake.in @@ -18,7 +18,6 @@ set (${HDF4_PACKAGE_NAME}_VALID_COMPONENTS #----------------------------------------------------------------------------- set (${HDF4_PACKAGE_NAME}_BUILD_FORTRAN @HDF4_BUILD_FORTRAN@) set (${HDF4_PACKAGE_NAME}_BUILD_JAVA @HDF4_BUILD_JAVA@) -set (${HDF4_PACKAGE_NAME}_BUILD_XDR_LIB @HDF4_BUILD_XDR_LIB@) set (${HDF4_PACKAGE_NAME}_BUILD_TOOLS @HDF4_BUILD_TOOLS@) set (${HDF4_PACKAGE_NAME}_BUILD_UTILS @HDF4_BUILD_UTILS@) set (${HDF4_PACKAGE_NAME}_ENABLE_JPEG_LIB_SUPPORT @HDF4_ENABLE_JPEG_LIB_SUPPORT@) diff --git a/config/cmake/scripts/HDF4options.cmake b/config/cmake/scripts/HDF4options.cmake index 3191f4ae18..e5948bfb23 100755 --- a/config/cmake/scripts/HDF4options.cmake +++ b/config/cmake/scripts/HDF4options.cmake @@ -33,10 +33,6 @@ set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_FORTRAN:BOOL=OFF") #### java disabled #### set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_JAVA:BOOL=OFF") -############################################################################################# -#### hdf4 xdr enabled #### -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_XDR_LIB:BOOL=ON") - ############################################################################################# ### change install prefix (default use INSTALLDIR value) set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALLDIR}") diff --git a/config/commence.am b/config/commence.am index d946ebe98e..1185d9f23d 100644 --- a/config/commence.am +++ b/config/commence.am @@ -27,12 +27,8 @@ LIBMFHDF = $(top_builddir)/mfhdf/libsrc/libmfhdf.la H4CC = ${DESTDIR}$(bindir)/h4cc H4FC = ${DESTDIR}$(bindir)/h4fc -if HDF_BUILD_XDR - XDR_ADD = -R$(abs_top_builddir)/mfhdf/xdr/.libs -endif - if HDF_BUILD_SHARED - AM_LDFLAGS = -R$(abs_top_builddir)/mfhdf/libsrc/.libs -R$(abs_top_builddir)/hdf/src/.libs $(XDR_ADD) + AM_LDFLAGS = -R$(abs_top_builddir)/mfhdf/libsrc/.libs -R$(abs_top_builddir)/hdf/src/.libs endif ACLOCAL_AMFLAGS = "-I m4" diff --git a/configure.ac b/configure.ac index cec3f8dd0c..4eda96d5ee 100644 --- a/configure.ac +++ b/configure.ac @@ -880,92 +880,6 @@ AC_SUBST([SZIP_HAS_ENCODER]) AM_CONDITIONAL([BUILD_SHARED_SZIP_CONDITIONAL], [test "X$USE_COMP_SZIP" = "Xyes" && test "X$LL_PATH" != "X"]) -## ---------------------------------------------------------------------- -## Is XDR support present? The TRY_LINK info was gotten from the -## mfhdf/libsrc/local_nc.c file. -AC_MSG_CHECKING([for xdr library support]) - -AC_ARG_ENABLE([hdf4-xdr], - [AS_HELP_STRING([--enable-hdf4-xdr], - [Build xdr library from code in HDF4 source. - Not supported for 64 bit mode. [default="no"]])], - [enableval="yes"],[enableval="no"]) - -case "$enableval" in - yes) - BUILD_XDR="yes" - AC_MSG_RESULT([using HDF4 XDR]); - ;; - no) - BUILD_XDR="no" - AC_MSG_RESULT([using system XDR]); - ;; -esac - - -## Check headers and add libraries for XDR if the HDF4 XDR library is not used. -if test "X$BUILD_XDR" != "Xyes"; then - ## For Solaris systems, add the -nsl for XDR support - ## - ## The SunRPC of the glibc has been replaced by a TI-RPC (Transport Independent RPC) library for IPv6 support - ## ====================================================================== - ## Checks for header files - ## ====================================================================== - HAVE_RPC="yes" - HAVE_OLDRPC="yes" - HAVE_TIRPC="yes" - ## save current settings - SYSCPPFLAGS="$CPPFLAGS" - SYSCFLAGS="$CFLAGS" - case "$host" in - *-solaris*) - LIBS="$LIBS -lnsl" - ;; - *-pc-cygwin* | *-linux*) - AC_CHECK_HEADER([rpc/rpc.h],[:], [unset HAVE_OLDRPC]) - AC_CHECK_HEADER([tirpc/netconfig.h],[:], [unset HAVE_TIRPC]) - if test -z "$HAVE_OLDRPC" ; then - LIBS="$LIBS -ltirpc" - CFLAGS="$SYSCFLAGS -I/usr/include/tirpc" - CPPFLAGS="$SYSCPPFLAGS -I/usr/include/tirpc" - if test -z "$HAVE_TIRPC" ; then - CFLAGS="$SYSCFLAGS" - CPPFLAGS="$SYSCPPFLAGS" - AC_MSG_ERROR([couldn't find rpc headers]) - fi - else - HAVE_TIRPC="" - fi - ;; - *) ;; - esac - - ## ---------------------------------------------------------------------- - ## We're trying to link against the rpc library when building on Cygwin, - ## but we need to make sure that it is present on the system. Do that here, - ## The SunRPC of the glibc has been replaced by a TI-RPC (Transport Independent RPC) library for IPv6 support - case "$host" in - *-pc-cygwin* | *-linux*) - if test -n "$HAVE_TIRPC"; then - AC_CHECK_LIB([tirpc], [xdr_opaque],[:], [unset HAVE_RPC]) - if test -z "$HAVE_RPC"; then - AC_MSG_ERROR([couldn't find rpc library]) - fi - fi - ;; - esac - - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #include - #include ]], [[xdr_int]])],[BUILD_XDR="no"],[BUILD_XDR="yes"]) -fi - -if test "X$BUILD_XDR" != "Xno"; then - AC_DEFINE([NO_SYS_XDR_INC], [1], [Not using system xdr]) -fi - -AM_CONDITIONAL([HDF_BUILD_XDR], [test "X$BUILD_XDR" = "Xyes"]) - ## ====================================================================== ## Set POSIX level ## ====================================================================== @@ -976,19 +890,6 @@ AM_CONDITIONAL([HDF_BUILD_XDR], [test "X$BUILD_XDR" = "Xyes"]) ## http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html CPPFLAGS="-D_POSIX_C_SOURCE=200809L $CPPFLAGS" -## ====================================================================== -## Checks for endianness functions -## The htons and ntohs functions are available on most systems. -## These functions convert betweennetwork endiannessand hostendianness. -## Network endianness is big-endian; because the standard TCP/IP network -## protocols use big-endian ordering. These functions come in two sizes: -## htonl and ntohl operate on 4-byte quantities, and -## htons and ntohs operate on 2-byte quantities. -## The hton functions convert host endianness to network endianness. -## The ntoh functions convert network endianness to host endianness -## ====================================================================== -AC_CHECK_FUNCS([htonl htons ntohl ntohs]) - ## ====================================================================== ## Checks for headers ## ====================================================================== @@ -1000,6 +901,24 @@ AC_CHECK_HEADERS([sys/types.h]) AC_CHECK_HEADERS([io.h]) AC_CHECK_HEADERS([arpa/inet.h netinet/in.h]) +## Special MinGW checks +case "`uname`" in + MINGW*) + # Check for Winsock library + AC_CHECK_LIB([ws2_32], [htonl]) + ;; +esac + +## ---------------------------------------------------------------------- +## XDR grew up in a world where long integers were 32 bits in size. Now +## that many platforms have 64-bit longs, we need some hacks to paper +## over the differences in sizes, particularly on big-endian machines. +## + +AC_CHECK_SIZEOF([long]) + +## ---------------------------------------------------------------------- + AC_PROG_CC_C_O if test "X$BUILD_FORTRAN" = "Xyes"; then @@ -1322,7 +1241,6 @@ AC_CONFIG_FILES([Makefile mfhdf/nctest/Makefile mfhdf/test/Makefile mfhdf/test/testmfhdf.sh - mfhdf/xdr/Makefile java/Makefile java/src/Makefile java/src/jni/Makefile diff --git a/hdf/src/H4api_adpt.h b/hdf/src/H4api_adpt.h index c3ebfff79d..cd5531728a 100644 --- a/hdf/src/H4api_adpt.h +++ b/hdf/src/H4api_adpt.h @@ -25,14 +25,6 @@ /* This will only be defined if HDF4 was built with CMake */ #if defined(H4_BUILT_AS_DYNAMIC_LIB) -#if defined(xdr_shared_EXPORTS) -#if defined(_MSC_VER) || defined(__MINGW32__) /* MSVC Compiler Case */ -#define XDRLIBAPI extern __declspec(dllexport) -#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ -#define XDRLIBAPI extern __attribute__((visibility("default"))) -#endif -#endif /* xdr_shared_EXPORTS */ - #if defined(hdf_shared_EXPORTS) #if defined(_MSC_VER) || defined(__MINGW32__) /* MSVC Compiler Case */ #define HDFERRPUBLIC extern __declspec(dllimport) @@ -113,13 +105,6 @@ #endif #endif /* mfhdf_hrepack_shared_EXPORTS */ -#if !defined(XDRLIBAPI) -#if defined(_MSC_VER) || defined(__MINGW32__) /* MSVC Compiler Case */ -#define XDRLIBAPI extern __declspec(dllimport) -#elif (__GNUC__ >= 4) /* GCC 4.x has support for visibility options */ -#define XDRLIBAPI extern __attribute__((visibility("default"))) -#endif -#endif #if !defined(HDFERRPUBLIC) #if defined(_MSC_VER) || defined(__MINGW32__) /* MSVC Compiler Case */ #define HDFERRPUBLIC extern __declspec(dllimport) @@ -150,7 +135,6 @@ #endif #else -#define XDRLIBAPI extern #define HDFERRPUBLIC extern #define HDFPUBLIC #define HDFLIBAPI extern diff --git a/hdf/src/cszip.c b/hdf/src/cszip.c index c361f45b0b..f06d9c3a8e 100644 --- a/hdf/src/cszip.c +++ b/hdf/src/cszip.c @@ -1085,8 +1085,7 @@ HCPsetup_szip_parms(comp_info *c_info, int32 nt, int32 ncomp, int32 ndims, int32 intn HCPrm_szip_special_bit(comp_info *c_info) { - int sz_newway = 0; /* indicates the special bit presents in the options_mask */ - intn ret_value = SUCCEED; + int sz_newway = 0; /* indicates the special bit presents in the options_mask */ if (c_info == NULL) HRETURN_ERROR(DFE_INTERNAL, FAIL); @@ -1097,6 +1096,5 @@ HCPrm_szip_special_bit(comp_info *c_info) if (sz_newway) c_info->szip.options_mask = c_info->szip.options_mask & ~SZ_H4_REV_2; -done: return SUCCEED; } diff --git a/hdf/src/dfimcomp.c b/hdf/src/dfimcomp.c index e724d45b52..ca8f1f661c 100644 --- a/hdf/src/dfimcomp.c +++ b/hdf/src/dfimcomp.c @@ -53,18 +53,13 @@ struct box { struct box *right; }; -static uint8 *new_pal; /* pointer to new palette */ - -static int *hist = (int *)NULL; /* histogram for distinct colors */ -static struct box *frontier = (struct box *)NULL; /* pointer to the */ -/* list of boxes */ -static struct rgb *distinct_pt = (struct rgb *)NULL; /* contains all */ -/* distinct rgb points */ - -static struct rgb *color_pt = (struct rgb *)NULL; /*contains the hi-lo */ -/*colors for each block */ -static uint8 *image; /* contains the compressed image */ -static int trans[MAXCOLOR]; /* color translation table */ +static uint8 *new_pal = NULL; /* pointer to new palette */ +static int *hist = NULL; /* histogram for distinct colors */ +static struct box *frontier = NULL; /* pointer to the list of boxes */ +static struct rgb *distinct_pt = NULL; /* contains all distinct rgb points */ +static struct rgb *color_pt = NULL; /* contains the hi-lo colors for each block */ +static uint8 *image = NULL; /* contains the compressed image */ +static int *trans = NULL; /* color translation table */ static void compress(unsigned char raster[], int block); static void init_global(int32 xdim, int32 ydim, void *out, void *out_pal); @@ -156,9 +151,6 @@ DFCIimcomp(int32 xdim, int32 ydim, const uint8 *in, uint8 out[], uint8 in_pal[], /* set palette */ nmbr = cnt_color(blocks); - /* - printf("Number of colors %d \n", nmbr); - */ if (nmbr <= PALSIZE) set_palette(blocks); else { @@ -169,6 +161,8 @@ DFCIimcomp(int32 xdim, int32 ydim, const uint8 *in, uint8 out[], uint8 in_pal[], fillin_color(blocks); free(color_pt); color_pt = NULL; + free(trans); + trans = NULL; } /* end of DFCIimcomp */ @@ -273,8 +267,10 @@ init_global(int32 xdim, int32 ydim, void *out, void *out_pal) new_pal = (unsigned char *)out_pal; free(color_pt); color_pt = (struct rgb *)malloc((unsigned)((xdim * ydim) / 8) * sizeof(struct rgb)); + free(trans); + trans = (int *)malloc(MAXCOLOR * sizeof(int)); - if (image == NULL || color_pt == NULL || new_pal == NULL) { + if (image == NULL || color_pt == NULL || new_pal == NULL || trans == NULL) { return; /* punt! */ } @@ -291,36 +287,40 @@ init_global(int32 xdim, int32 ydim, void *out, void *out_pal) } /* end of init_global */ /************************************************************************/ -/* Function : cnt_color */ -/* Purpose : Counts the number of distinct colors compressd image */ -/* Parameter : */ -/* blocks - total number of pixel blocks */ -/* Returns : Number of distinct colors */ +/* Function : cnt_color */ +/* Purpose : Counts the number of distinct colors compressd image */ +/* Parameter : */ +/* blocks - total number of pixel blocks */ +/* Returns : Number of distinct colors, -1 on errors */ /* Called by : DFCimcomp() */ -/* Calls : indx() */ +/* Calls : indx() */ /************************************************************************/ static int cnt_color(int blocks) { - int temp[MAXCOLOR]; - int i, k, count; + int *temp = NULL; + int k, count; - for (i = 0; i < MAXCOLOR; i++) + if (NULL == (temp = (int *)malloc(sizeof(int) * MAXCOLOR))) + return -1; + + for (int i = 0; i < MAXCOLOR; i++) temp[i] = -1; - for (i = 0; i < (2 * blocks); i++) { + for (int i = 0; i < (2 * blocks); i++) { k = indx(color_pt[i].c[RED], color_pt[i].c[GREEN], color_pt[i].c[BLUE]); - /* printf("cnt_color: k is %d\n",k); */ - if (k < MAXCOLOR) /* Fortner Fix: supplied by Peter Lawton */ + if (k < MAXCOLOR) temp[k] = 0; } count = 0; - for (i = 0; i < MAXCOLOR; i++) + for (int i = 0; i < MAXCOLOR; i++) if (temp[i] == 0) count++; + free(temp); + return count; } /* end of cnt_color */ @@ -598,7 +598,7 @@ static void init(int blocks, int distinct, struct rgb *my_color_pt) { int i, j, k, l; - int temp[MAXCOLOR]; + int *temp = NULL; struct box *first; struct box *dummy; @@ -607,6 +607,7 @@ init(int blocks, int distinct, struct rgb *my_color_pt) free(distinct_pt); hist = (int *)malloc((unsigned)distinct * sizeof(int)); distinct_pt = (struct rgb *)malloc((unsigned)distinct * sizeof(struct rgb)); + temp = (int *)malloc(sizeof(int) * MAXCOLOR); for (i = 0; i < distinct; i++) hist[i] = 0; @@ -663,6 +664,9 @@ init(int blocks, int distinct, struct rgb *my_color_pt) free(first); free(dummy); + free(temp); + + return; } /* end of init */ /************************************************************************/ @@ -780,14 +784,14 @@ find_box(void) } /************************************************************************/ -/* Function : split_box */ -/* Purpose : Splits a selected box into 2 and reinserts the 2 sub- */ -/* boxes into the frontier list */ -/* Parameter : */ -/* ptr - pointer to box to be split */ -/* Returns : none */ -/* Called by : sel_palette() */ -/* Calls : find_med(), select_dim(), classify() */ +/* Function : split_box */ +/* Purpose : Splits a selected box into 2 and reinserts the 2 sub- */ +/* boxes into the frontier list */ +/* Parameter : */ +/* ptr - pointer to box to be split */ +/* Returns : none */ +/* Called by : sel_palette() */ +/* Calls : find_med(), select_dim(), classify() */ /************************************************************************/ static void @@ -797,6 +801,12 @@ split_box(struct box *ptr) float median; struct box *l_child, *r_child; + /* This function should really return an error code, but for now + * we'll at least guard against NULL pointer dereferences + */ + if (NULL == ptr) + return; + dim = select_dim(ptr); median = find_med(ptr, dim); diff --git a/hdf/test/testhdf.c b/hdf/test/testhdf.c index 8d9a7568c3..77cd1adc6f 100644 --- a/hdf/test/testhdf.c +++ b/hdf/test/testhdf.c @@ -51,7 +51,9 @@ struct TestStruct { int SkipFlag; char Name[16]; void (*Call)(void); -} Test[MAXNUMOFTESTS]; +}; + +struct TestStruct *Test = NULL; static void InitTest(const char *TheName, void (*TheCall)(void), const char *TheDescr); static void usage(void); @@ -62,7 +64,8 @@ InitTest(const char *TheName, void (*TheCall)(void), const char *TheDescr) if (Index >= MAXNUMOFTESTS) { printf("Uh-oh, too many tests added, increase MAXNUMOFTEST!\n"); exit(0); - } /* end if */ + } + strcpy(Test[Index].Description, TheDescr); strcpy(Test[Index].Name, TheName); Test[Index].Call = TheCall; @@ -116,6 +119,11 @@ main(int argc, char *argv[]) /* Un-buffer stdout */ setbuf(stdout, NULL); + if (NULL == (Test = (struct TestStruct *)calloc(MAXNUMOFTESTS, sizeof(struct TestStruct)))) { + printf("Could not allocate memory for tests!\n"); + exit(0); + } + /* Tests are generally arranged from least to most complexity... */ #if !defined _WIN32 InitTest("bitvect", test_bitvect, "Bit-Vector routines"); @@ -263,9 +271,13 @@ main(int argc, char *argv[]) if (CleanUp) { MESSAGE(2, printf("\nCleaning Up...\n\n");); #ifndef H4_HAVE_WIN32_API - system("rm -f *.hdf *.tmp"); + if (system("rm -f *.hdf *.tmp") != 0) { + MESSAGE(2, printf("\n!!! Unable to clean files !!!\n\n");); + } #endif } - exit(num_errs); + + free(Test); + return num_errs; } /* end main() */ diff --git a/hdf/util/hdfls.c b/hdf/util/hdfls.c index 29f0585b5a..a08715abf2 100644 --- a/hdf/util/hdfls.c +++ b/hdf/util/hdfls.c @@ -65,7 +65,6 @@ print_item(int32 fid, dd_t *desc_list, intn n) intn status; int32 len; char *name, *label_str; - intn i; /* loop variable*/ printf("\tRef no %6d\t%8d bytes\n", (int)desc_list[n].ref, (int)desc_list[n].length); @@ -138,7 +137,7 @@ print_item(int32 fid, dd_t *desc_list, intn n) printf("\tChunked Element: \n \tlogical size: %ld\n \tnumber of dimensions: %ld \n", (long)info.chunk_size, (long)info.ndims); printf("\tarray of chunk lengths for each dimension:"); - for (i = 0; i < info.ndims; i++) + for (int i = 0; i < info.ndims; i++) printf("\t %ld", (long)info.cdims[i]); printf("\n"); free(info.cdims); @@ -176,7 +175,6 @@ print_item(int32 fid, dd_t *desc_list, intn n) int32 ntagrefs; int32 vkey; int32 *tag_arr, *ref_arr; - intn i; if (v_init_done == FALSE) { /* init the V routines */ v_init_done = TRUE; @@ -194,7 +192,7 @@ print_item(int32 fid, dd_t *desc_list, intn n) } else { if (Vgettagrefs(vkey, tag_arr, ref_arr, ntagrefs) != FAIL) { - for (i = 0; i < ntagrefs; i++) { + for (int i = 0; i < ntagrefs; i++) { name = (char *)HDgettagsname((uint16)tag_arr[i]); if (!name) printf("\t\t%-30s: (tag=%6d) ref=%d\n", "Unknown Tag", (int)tag_arr[i], diff --git a/java/src/jni/Makefile.am b/java/src/jni/Makefile.am index 714441fbc6..a893fdfd08 100644 --- a/java/src/jni/Makefile.am +++ b/java/src/jni/Makefile.am @@ -13,7 +13,7 @@ AM_CPPFLAGS=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/libsrc \ -I$(top_builddir)/mfhdf/libsrc \ -I$(top_srcdir)/java/src/jni \ - $(JNIFLAGS) $(XDRINC) + $(JNIFLAGS) # This is our main target lib_LTLIBRARIES=libhdf_java.la @@ -25,12 +25,12 @@ libhdf_java_la_SOURCES=hdfanImp.c hdfdfpalImp.c \ hdfvhImp.c hdfvqImp.c hdfvsqImp.c # HDF Java (JNI) library depends on HDF Library. -libhdf_java_la_LIBADD=$(LIBMFHDF) $(LIBHDF) $(XDRLIB) @LIBS@ -libhdf_java_la_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +libhdf_java_la_LIBADD=$(LIBMFHDF) $(LIBHDF) @LIBS@ +libhdf_java_la_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) libhdf_java_la_INCLUDES=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/libsrc \ -I$(top_builddir)/mfhdf/libsrc \ -I$(top_srcdir)/java/src/jni \ - $(JNIFLAGS) $(XDRINC) + $(JNIFLAGS) include $(top_srcdir)/config/conclude.am diff --git a/mfhdf/Makefile.am b/mfhdf/Makefile.am index 8b61a8c851..3e37caca3a 100644 --- a/mfhdf/Makefile.am +++ b/mfhdf/Makefile.am @@ -1,15 +1,5 @@ include $(top_srcdir)/config/commence.am -if HDF_BUILD_XDR -XDR_DIR = xdr -export XDRLIB = $(abs_top_builddir)/mfhdf/xdr/libxdr.la -export XDRINC = -I$(abs_top_srcdir)/mfhdf/xdr -else -XDR_DIR = -XDRLIB = -XDRINC = -endif - if HDF_BUILD_FORTRAN FORTRAN_DIR = fortran else @@ -23,9 +13,9 @@ NETCDF_DIRS = nctest endif # src folder in root Makefile, build other folders now -SUBDIRS = $(XDR_DIR) libsrc $(FORTRAN_DIR) test $(NETCDF_DIRS) dumper hdfimport hdiff hrepack +SUBDIRS = libsrc $(FORTRAN_DIR) test $(NETCDF_DIRS) dumper hdfimport hdiff hrepack -DIST_SUBDIRS = xdr libsrc fortran test $(NETCDF_DIRS) dumper hdfimport hdiff hrepack examples +DIST_SUBDIRS = libsrc fortran test $(NETCDF_DIRS) dumper hdfimport hdiff hrepack examples installcheck-local: @(cd examples && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; diff --git a/mfhdf/README b/mfhdf/README index 2c2bdeab1a..abb3061073 100644 --- a/mfhdf/README +++ b/mfhdf/README @@ -50,10 +50,8 @@ Included in this distribution are: the C source for the netCDF data access library, sources for the FORTRAN jacket library for various systems, documentation for the netCDF library and utilities in the form of a netCDF User's Guide, source for the netCDF utilities ncdump and -ncgen, a directory of test programs to verify the correct implementation -of the netCDF library in new environments, and a directory of XDR -(eXternal Data Representation) source code for environments that do not -support XDR. +ncgen, and a directory of test programs to verify the correct implementation +of the netCDF library in new environments. Other files available for anonymous FTP from the pub/netcdf/ directory of unidata.ucar.edu include diff --git a/mfhdf/dumper/CMakeLists.txt b/mfhdf/dumper/CMakeLists.txt index 18b66f95dc..e9dafb21c2 100644 --- a/mfhdf/dumper/CMakeLists.txt +++ b/mfhdf/dumper/CMakeLists.txt @@ -16,7 +16,7 @@ set (hdp_SRCS if (NOT ONLY_SHARED_LIBS) add_executable (hdp ${hdp_SRCS}) - target_include_directories(hdp PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(hdp PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (hdp STATIC) target_link_libraries (hdp PRIVATE ${HDF4_MF_LIB_TARGET}) set_target_properties (hdp PROPERTIES COMPILE_DEFINITIONS "HDF") @@ -26,7 +26,7 @@ endif () if (BUILD_SHARED_LIBS) add_executable (hdp-shared ${hdp_SRCS}) - target_include_directories(hdp-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(hdp-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (hdp-shared SHARED) target_link_libraries (hdp-shared PRIVATE ${HDF4_MF_LIBSH_TARGET}) set_target_properties (hdp-shared PROPERTIES COMPILE_DEFINITIONS "HDF") diff --git a/mfhdf/dumper/Makefile.am b/mfhdf/dumper/Makefile.am index a40aafece9..13d50cf862 100644 --- a/mfhdf/dumper/Makefile.am +++ b/mfhdf/dumper/Makefile.am @@ -8,7 +8,7 @@ hdp_INCLUDES=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/libsrc \ -I$(top_builddir)/mfhdf/libsrc DEFINES=-DHDF -AM_CPPFLAGS=$(hdp_INCLUDES) $(XDRINC) $(DEFINES) +AM_CPPFLAGS=$(hdp_INCLUDES) $(DEFINES) ## Add hdp specific linker flags here hdp_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) @@ -22,8 +22,8 @@ bin_PROGRAMS = hdp ## Information for building the "hdp" program hdp_SOURCES = hdp.c hdp_dump.c hdp_gr.c hdp_list.c hdp_rig.c hdp_sds.c \ hdp_util.c hdp_vd.c hdp_vg.c show.c -hdp_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) @LIBS@ -hdp_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +hdp_LDADD = $(LIBMFHDF) $(LIBHDF) @LIBS@ +hdp_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) ############################################################################# ## Testing -- Here there be dragons. ## diff --git a/mfhdf/fortran/Makefile.am b/mfhdf/fortran/Makefile.am index 43a0ad1d7a..7b4174a9fd 100644 --- a/mfhdf/fortran/Makefile.am +++ b/mfhdf/fortran/Makefile.am @@ -9,7 +9,7 @@ fort_INCLUDES=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/libsrc \ -I$(top_builddir)/mfhdf/libsrc DEFINES=-DHDF -AM_CPPFLAGS=$(fort_INCLUDES) $(XDRINC) $(DEFINES) +AM_CPPFLAGS=$(fort_INCLUDES) $(DEFINES) DIST_SUBDIRS = examples @@ -31,22 +31,22 @@ check_SCRIPTS = testfortran.sh if HDF_BUILD_NETCDF ftest_SOURCES = ftest.f ftest_LDADD = $(top_builddir)/hdf/test/forsupff.o $(top_builddir)/hdf/test/forsupf.o \ - $(LIBMFHDF) $(LIBHDF) $(XDRLIB) @LIBS@ + $(LIBMFHDF) $(LIBHDF) @LIBS@ ftest_DEPENDENCIES = $(top_builddir)/hdf/test/forsupff.o $(top_builddir)/hdf/test/forsupf.o \ - $(LIBMFHDF) $(LIBHDF) $(XDRLIB) + $(LIBMFHDF) $(LIBHDF) endif hdftest_SOURCES = hdftest.f -hdftest_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) @LIBS@ -hdftest_DEPENDENCIES = testdir $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +hdftest_LDADD = $(LIBMFHDF) $(LIBHDF) @LIBS@ +hdftest_DEPENDENCIES = testdir $(LIBMFHDF) $(LIBHDF) hdftest1_SOURCES = hdftest1.f -hdftest1_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) @LIBS@ -hdftest1_DEPENDENCIES = testdir $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +hdftest1_LDADD = $(LIBMFHDF) $(LIBHDF) @LIBS@ +hdftest1_DEPENDENCIES = testdir $(LIBMFHDF) $(LIBHDF) tszip_SOURCES = tszip.f -tszip_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) @LIBS@ -tszip_DEPENDENCIES = testdir $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +tszip_LDADD = $(LIBMFHDF) $(LIBHDF) @LIBS@ +tszip_DEPENDENCIES = testdir $(LIBMFHDF) $(LIBHDF) testdir: -mkdir testdir diff --git a/mfhdf/hdfimport/CMakeLists.txt b/mfhdf/hdfimport/CMakeLists.txt index 5fbc7ff9e4..601a6718f6 100644 --- a/mfhdf/hdfimport/CMakeLists.txt +++ b/mfhdf/hdfimport/CMakeLists.txt @@ -11,7 +11,7 @@ set (hdfimport_SRCS if (NOT ONLY_SHARED_LIBS) add_executable (hdfimport ${hdfimport_SRCS}) - target_include_directories(hdfimport PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(hdfimport PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (hdfimport STATIC) target_link_libraries (hdfimport PRIVATE ${HDF4_MF_LIB_TARGET}) set_target_properties (hdfimport PROPERTIES COMPILE_DEFINITIONS "HDF") @@ -22,7 +22,7 @@ endif () if (BUILD_SHARED_LIBS) add_executable (hdfimport-shared ${hdfimport_SRCS}) - target_include_directories(hdfimport-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(hdfimport-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (hdfimport-shared SHARED) target_link_libraries (hdfimport-shared PRIVATE ${HDF4_MF_LIBSH_TARGET}) set_target_properties (hdfimport-shared PROPERTIES COMPILE_DEFINITIONS "HDF") diff --git a/mfhdf/hdfimport/Makefile.am b/mfhdf/hdfimport/Makefile.am index 4afe4708cb..d577cefc0f 100644 --- a/mfhdf/hdfimport/Makefile.am +++ b/mfhdf/hdfimport/Makefile.am @@ -9,7 +9,7 @@ hdfimport_INCLUDES=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/libsrc \ -I$(top_builddir)/mfhdf/libsrc DEFINES=-DHDF -AM_CPPFLAGS=$(hdfimport_INCLUDES) $(XDRINC) $(DEFINES) +AM_CPPFLAGS=$(hdfimport_INCLUDES) $(DEFINES) ## Add hdfimport specific linker flags here hdfimport_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) @@ -18,7 +18,7 @@ hdfimport_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) ## Libraries to link against ## ############################################################################# -LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) @LIBS@ +LDADD = $(LIBMFHDF) $(LIBHDF) @LIBS@ ############################################################################# ## Programs to build ## diff --git a/mfhdf/hdiff/CMakeLists.txt b/mfhdf/hdiff/CMakeLists.txt index bd4a9c08d3..297351606f 100644 --- a/mfhdf/hdiff/CMakeLists.txt +++ b/mfhdf/hdiff/CMakeLists.txt @@ -23,7 +23,7 @@ set (hdiff_SRCS if (NOT ONLY_SHARED_LIBS) add_executable(hdiff ${hdiff_SRCS}) - target_include_directories(hdiff PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};${HDF4_MFHDF_UTIL_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(hdiff PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};${HDF4_MFHDF_UTIL_DIR}") TARGET_C_PROPERTIES (hdiff STATIC) target_link_libraries(hdiff PRIVATE ${HDF4_MF_LIB_TARGET} ${HDF4_SRC_LIB_TARGET} ${LINK_LIBS}) set_global_variable (HDF4_UTILS_TO_EXPORT "${HDF4_UTILS_TO_EXPORT};hdiff") @@ -33,7 +33,7 @@ endif () if (BUILD_SHARED_LIBS) add_executable(hdiff-shared ${hdiff_SRCS}) - target_include_directories(hdiff-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};${HDF4_MFHDF_UTIL_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(hdiff-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};${HDF4_MFHDF_UTIL_DIR}") TARGET_C_PROPERTIES (hdiff-shared SHARED) target_link_libraries(hdiff-shared PRIVATE ${HDF4_MF_LIBSH_TARGET} ${HDF4_SRC_LIBSH_TARGET} ${LINK_LIBS}) set_global_variable (HDF4_UTILS_TO_EXPORT "${HDF4_UTILS_TO_EXPORT};hdiff-shared") diff --git a/mfhdf/hdiff/Makefile.am b/mfhdf/hdiff/Makefile.am index 06b28792f0..7d2f3b883a 100644 --- a/mfhdf/hdiff/Makefile.am +++ b/mfhdf/hdiff/Makefile.am @@ -10,7 +10,7 @@ hdiff_INCLUDES=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/util \ -I$(top_builddir)/mfhdf/libsrc DEFINES=-DHDF -AM_CPPFLAGS=$(hdiff_INCLUDES) $(XDRINC) $(DEFINES) +AM_CPPFLAGS=$(hdiff_INCLUDES) $(DEFINES) ## Add hdiff specific linker flags here hdiff_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) @@ -25,8 +25,8 @@ bin_PROGRAMS = hdiff hdiff_SOURCES = hdiff.c hdiff_array.c hdiff_gr.c hdiff_list.c hdiff_main.c \ hdiff_mattbl.c hdiff_gattr.c hdiff_misc.c hdiff_sds.c \ hdiff_table.c hdiff_vs.c hdiff_dim.c $(top_srcdir)/mfhdf/util/h4getopt.c -hdiff_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) -lm -hdiff_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +hdiff_LDADD = $(LIBMFHDF) $(LIBHDF) -lm +hdiff_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) ############################################################################# ## Testing ## @@ -39,8 +39,8 @@ check_SCRIPTS = testhdiff.sh noinst_PROGRAMS = hdifftst hdifftst_SOURCES = hdifftst.c -hdifftst_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) -hdifftst_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +hdifftst_LDADD = $(LIBMFHDF) $(LIBHDF) +hdifftst_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) ############################################################################# ## And the cleanup ## diff --git a/mfhdf/hrepack/CMakeLists.txt b/mfhdf/hrepack/CMakeLists.txt index 65f5cf5607..dc7610b7d8 100644 --- a/mfhdf/hrepack/CMakeLists.txt +++ b/mfhdf/hrepack/CMakeLists.txt @@ -21,14 +21,14 @@ set (hrepack_SRCS if (NOT ONLY_SHARED_LIBS) add_executable (hrepack ${hrepack_SRCS}) - target_include_directories(hrepack PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(hrepack PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (hrepack STATIC) target_link_libraries (hrepack PRIVATE ${HDF4_MF_LIB_TARGET} ${LINK_COMP_LIBS}) set_target_properties (hrepack PROPERTIES COMPILE_DEFINITIONS "HDF") set_global_variable (HDF4_UTILS_TO_EXPORT "${HDF4_UTILS_TO_EXPORT};hrepack") add_executable (hrepack_check ${HDF4_MFHDF_HREPACK_SOURCE_DIR}/hrepack_check.c) - target_include_directories(hrepack_check PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(hrepack_check PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (hrepack_check STATIC) target_link_libraries (hrepack_check PRIVATE ${HDF4_MF_LIB_TARGET}) set_target_properties (hrepack_check PROPERTIES COMPILE_DEFINITIONS "HDF") @@ -38,14 +38,14 @@ endif () if (BUILD_SHARED_LIBS) add_executable (hrepack-shared ${hrepack_SRCS}) - target_include_directories(hrepack-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(hrepack-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (hrepack-shared SHARED) target_link_libraries (hrepack-shared PRIVATE ${HDF4_MF_LIBSH_TARGET} ${LINK_COMP_LIBS}) set_target_properties (hrepack-shared PROPERTIES COMPILE_DEFINITIONS "HDF") set_global_variable (HDF4_UTILS_TO_EXPORT "${HDF4_UTILS_TO_EXPORT};hrepack-shared") add_executable (hrepack_check-shared ${HDF4_MFHDF_HREPACK_SOURCE_DIR}/hrepack_check.c) - target_include_directories(hrepack_check-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(hrepack_check-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (hrepack_check-shared SHARED) target_link_libraries (hrepack_check-shared PRIVATE ${HDF4_MF_LIBSH_TARGET}) set_target_properties (hrepack_check-shared PROPERTIES COMPILE_DEFINITIONS "HDF") diff --git a/mfhdf/hrepack/Makefile.am b/mfhdf/hrepack/Makefile.am index 70e30e1d22..41e9628849 100644 --- a/mfhdf/hrepack/Makefile.am +++ b/mfhdf/hrepack/Makefile.am @@ -10,7 +10,7 @@ hrepack_INCLUDES=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/libsrc \ -I$(top_builddir)/mfhdf/libsrc DEFINES=-DHDF -AM_CPPFLAGS=$(hrepack_INCLUDES) $(XDRINC) $(DEFINES) +AM_CPPFLAGS=$(hrepack_INCLUDES) $(DEFINES) ## Add hrepack specific linker flags here hrepack_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) @@ -26,8 +26,8 @@ hrepack_SOURCES = hrepack.c hrepack_an.c hrepack_gr.c \ hrepack_opttable.c hrepack_parse.c \ hrepack_sds.c hrepack_utils.c \ hrepack_vg.c hrepack_vs.c hrepack_dim.c -hrepack_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) -hrepack_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +hrepack_LDADD = $(LIBMFHDF) $(LIBHDF) +hrepack_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) ############################################################################# ## Testing -- Here there be dragons. ## @@ -39,12 +39,12 @@ check_SCRIPTS=hrepack.sh check_PROGRAMS = hrepack_check test_hrepack test_hrepack_SOURCES = hrepacktst.c -test_hrepack_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) -lm -test_hrepack_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +test_hrepack_LDADD = $(LIBMFHDF) $(LIBHDF) -lm +test_hrepack_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) hrepack_check_SOURCES = hrepack_check.c -hrepack_check_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) -hrepack_check_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +hrepack_check_LDADD = $(LIBMFHDF) $(LIBHDF) +hrepack_check_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) # The hrepack.sh script needs test_hrepack to run first. hrepack.sh.chkexe_: test_hrepack.chkexe_ diff --git a/mfhdf/libsrc/CMakeLists.txt b/mfhdf/libsrc/CMakeLists.txt index 90c67935cc..b3bf90d17d 100644 --- a/mfhdf/libsrc/CMakeLists.txt +++ b/mfhdf/libsrc/CMakeLists.txt @@ -31,7 +31,7 @@ set (HDF4_MFHDF_LIBSRC_CSRCS ${HDF4_MFHDF_LIBSRC_SOURCE_DIR}/sharray.c ${HDF4_MFHDF_LIBSRC_SOURCE_DIR}/string.c ${HDF4_MFHDF_LIBSRC_SOURCE_DIR}/var.c - ${HDF4_MFHDF_LIBSRC_SOURCE_DIR}/xdrposix.c + ${HDF4_MFHDF_LIBSRC_SOURCE_DIR}/h4_xdr.c ) set (HDF4_MFHDF_LIBSRC_INSTALL_CHDRS @@ -46,6 +46,7 @@ set (HDF4_MFHDF_LIBSRC_CHDRS ${HDF4_MFHDF_LIBSRC_INSTALL_CHDRS} ${HDF4_MFHDF_LIBSRC_SOURCE_DIR}/error.h ${HDF4_MFHDF_LIBSRC_SOURCE_DIR}/mfprivate.h + ${HDF4_MFHDF_LIBSRC_SOURCE_DIR}/h4_xdr.h ) if (HDF4_ENABLE_NETCDF) @@ -59,7 +60,7 @@ endif () if (NOT ONLY_SHARED_LIBS) add_library (${HDF4_MF_LIB_TARGET} STATIC ${HDF4_MFHDF_LIBSRC_CSRCS} ${HDF4_MFHDF_LIBSRC_CHDRS}) target_include_directories (${HDF4_MF_LIB_TARGET} - PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};$<$:${HDF4_MFHDF_XDR_DIR}>" + PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES}" INTERFACE "$/include>" ) target_compile_options(${HDF4_MF_LIB_TARGET} PRIVATE "${HDF4_CMAKE_C_FLAGS}") @@ -69,9 +70,7 @@ if (NOT ONLY_SHARED_LIBS) ${HDF_EXTRA_FLAGS} ) TARGET_C_PROPERTIES (${HDF4_MF_LIB_TARGET} STATIC) - if (HDF4_BUILD_XDR_LIB) - target_link_libraries (${HDF4_MF_LIB_TARGET} PUBLIC ${HDF4_MF_XDR_LIB_TARGET}) - endif () + target_link_libraries (${HDF4_MF_LIB_TARGET} PUBLIC "$<$,$>:ws2_32.lib>") target_link_libraries (${HDF4_MF_LIB_TARGET} PUBLIC ${HDF4_SRC_LIB_TARGET}) set_global_variable (HDF4_LIBRARIES_TO_EXPORT "${HDF4_LIBRARIES_TO_EXPORT};${HDF4_MF_LIB_TARGET}") H4_SET_LIB_OPTIONS (${HDF4_MF_LIB_TARGET} ${HDF4_MF_LIB_NAME} STATIC) @@ -86,7 +85,7 @@ endif () if (BUILD_SHARED_LIBS) add_library (${HDF4_MF_LIBSH_TARGET} SHARED ${HDF4_MFHDF_LIBSRC_CSRCS} ${HDF4_MFHDF_LIBSRC_CHDRS}) target_include_directories (${HDF4_MF_LIBSH_TARGET} - PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES};$<$:${HDF4_MFHDF_XDR_DIR}>" + PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};${HDF4_COMP_INCLUDE_DIRECTORIES}" INTERFACE "$/include>" ) target_compile_options(${HDF4_MF_LIBSH_TARGET} PRIVATE "${HDF4_CMAKE_C_FLAGS}") @@ -96,9 +95,7 @@ if (BUILD_SHARED_LIBS) ${HDF_EXTRA_FLAGS} ) TARGET_C_PROPERTIES (${HDF4_MF_LIBSH_TARGET} SHARED) - if (HDF4_BUILD_XDR_LIB) - target_link_libraries (${HDF4_MF_LIBSH_TARGET} PUBLIC ${HDF4_MF_XDR_LIBSH_TARGET}) - endif () + target_link_libraries (${HDF4_MF_LIBSH_TARGET} PUBLIC "$<$,$>:ws2_32.lib>") target_link_libraries (${HDF4_MF_LIBSH_TARGET} PUBLIC ${HDF4_SRC_LIBSH_TARGET}) set_global_variable (HDF4_LIBRARIES_TO_EXPORT "${HDF4_LIBRARIES_TO_EXPORT};${HDF4_MF_LIBSH_TARGET}") H4_SET_LIB_OPTIONS (${HDF4_MF_LIBSH_TARGET} ${HDF4_MF_LIB_NAME} SHARED) diff --git a/mfhdf/libsrc/Makefile.am b/mfhdf/libsrc/Makefile.am index 24d24f8321..64862de8a5 100644 --- a/mfhdf/libsrc/Makefile.am +++ b/mfhdf/libsrc/Makefile.am @@ -8,7 +8,7 @@ include $(top_srcdir)/config/commence.am lib_INCLUDES = -I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/libsrc DEFINES = -DHDF -AM_CPPFLAGS = $(lib_INCLUDES) $(XDRINC) $(DEFINES) +AM_CPPFLAGS = $(lib_INCLUDES) $(DEFINES) ############################################################################# ## Library to build ## @@ -17,9 +17,9 @@ AM_CPPFLAGS = $(lib_INCLUDES) $(XDRINC) $(DEFINES) lib_LTLIBRARIES = libmfhdf.la ## Information for building the "libmfhdf.la" library -CSOURCES = array.c attr.c cdf.c dim.c file.c hdfsds.c iarray.c error.c \ - globdef.c mfsd.c mfdatainfo.c nssdc.c putget.c putgetg.c \ - sharray.c string.c var.c xdrposix.c +CSOURCES = array.c attr.c cdf.c dim.c file.c hdfsds.c iarray.c error.c \ + globdef.c mfsd.c mfdatainfo.c nssdc.c putget.c putgetg.c \ + sharray.c string.c var.c h4_xdr.c if HDF_BUILD_NETCDF FSOURCES = $(top_builddir)/mfhdf/fortran/jackets.c $(top_srcdir)/mfhdf/fortran/mfsdf.c $(top_srcdir)/mfhdf/fortran/mfsdff.f @@ -33,7 +33,7 @@ else libmfhdf_la_SOURCES = $(CSOURCES) endif -libmfhdf_la_LIBADD = $(XDRLIB) $(top_builddir)/hdf/src/libdf.la +libmfhdf_la_LIBADD = $(top_builddir)/hdf/src/libdf.la if HDF_BUILD_NETCDF include_HEADERS = hdf2netcdf.h local_nc.h mfhdf.h netcdf.h mfhdfi.h mfdatainfo.h diff --git a/mfhdf/libsrc/array.c b/mfhdf/libsrc/array.c index 1316b48e2d..64db095ba0 100644 --- a/mfhdf/libsrc/array.c +++ b/mfhdf/libsrc/array.c @@ -472,13 +472,13 @@ xdr_NC_array(XDR *xdrs, NC_array **app) break; } - if (!xdr_int(xdrs, &type)) { - NCadvise(NC_EXDR, "xdr_NC_array:xdr_int (enum)"); + if (!h4_xdr_int(xdrs, &type)) { + NCadvise(NC_EXDR, "xdr_NC_array:h4_xdr_int (enum)"); return (FALSE); } - if (!xdr_u_int(xdrs, &temp_count)) { - NCadvise(NC_EXDR, "xdr_NC_array:xdr_u_long"); + if (!h4_xdr_u_int(xdrs, &temp_count)) { + NCadvise(NC_EXDR, "xdr_NC_array:h4_xdr_u_int"); return (FALSE); } *countp = temp_count; @@ -501,19 +501,19 @@ xdr_NC_array(XDR *xdrs, NC_array **app) case NC_UNSPECIFIED: case NC_BYTE: case NC_CHAR: - xdr_NC_fnct = xdr_opaque; + xdr_NC_fnct = h4_xdr_opaque; goto func; case NC_SHORT: xdr_NC_fnct = xdr_shorts; goto func; case NC_LONG: - xdr_NC_fnct = xdr_int; + xdr_NC_fnct = h4_xdr_int; goto loop; case NC_FLOAT: - xdr_NC_fnct = xdr_float; + xdr_NC_fnct = h4_xdr_float; goto loop; case NC_DOUBLE: - xdr_NC_fnct = xdr_double; + xdr_NC_fnct = h4_xdr_double; goto loop; /* private types */ case NC_STRING: diff --git a/mfhdf/libsrc/cdf.c b/mfhdf/libsrc/cdf.c index 3acc57f2b0..b19edc59d5 100644 --- a/mfhdf/libsrc/cdf.c +++ b/mfhdf/libsrc/cdf.c @@ -62,7 +62,7 @@ NC_free_cdf(NC *handle) HGOTO_FAIL(FAIL); /* destroy xdr struct */ - xdr_destroy(handle->xdrs); + h4_xdr_destroy(handle->xdrs); free(handle->xdrs); handle->xdrs = NULL; @@ -245,7 +245,7 @@ NC_new_cdf(const char *name, int mode) */ switch (cdf->file_type) { case HDF_FILE: - hdf_xdrfile_create(cdf->xdrs, mode); /* return type is 'void' */ + h4_xdr_setup_nofile(cdf->xdrs, mode); /* return type is 'void' */ break; case netCDF_FILE: if (NCxdrfile_create(cdf->xdrs, name, mode) < 0) @@ -254,7 +254,7 @@ NC_new_cdf(const char *name, int mode) case CDF_FILE: /* CDF_xdrfile_create(); */ /* try this, I bet it will be sufficient */ - hdf_xdrfile_create(cdf->xdrs, mode); + h4_xdr_setup_nofile(cdf->xdrs, mode); break; } @@ -354,7 +354,7 @@ NC_new_cdf(const char *name, int mode) These routines only free up allocated memory. */ NC_free_xcdf(cdf); /* no point in catching error here */ if (cdf->xdrs != NULL) { - xdr_destroy(cdf->xdrs); + h4_xdr_destroy(cdf->xdrs); free(cdf->xdrs); } free(cdf); @@ -490,28 +490,28 @@ xdr_cdf(XDR *xdrs, NC **handlep) static bool_t NC_xdr_cdf(XDR *xdrs, NC **handlep) { - u_long magic; + unsigned magic; if (xdrs->x_op == XDR_FREE) { NC_free_xcdf(*handlep); return (TRUE); } - if (xdr_getpos(xdrs) != 0) { - if (!xdr_setpos(xdrs, 0)) { + if (h4_xdr_getpos(xdrs) != 0) { + if (!h4_xdr_setpos(xdrs, 0)) { nc_serror("Can't set position to begin"); return (FALSE); } } /* magic number */ - if (!xdr_u_long(xdrs, &magic)) { + if (!h4_xdr_u_int(xdrs, &magic)) { if (xdrs->x_op == XDR_DECODE) { NCadvise(NC_ENOTNC, "Not a netcdf file (Can't read magic number)"); } else { /* write error */ - nc_serror("xdr_cdf: xdr_u_long"); + nc_serror("xdr_cdf: h4_xdr_u_int"); } return (FALSE); } @@ -2334,19 +2334,20 @@ xdr_numrecs(XDR *xdrs, NC *handle) * record so we can successfully read back the * entire last record. */ - if (!xdr_setpos(xdrs, handle->begin_rec + handle->numrecs * handle->recsize)) { + if (!h4_xdr_setpos(xdrs, handle->begin_rec + handle->numrecs * handle->recsize)) { nc_serror("Can't set position to EOF"); - return (FALSE); + return FALSE; } - if (!xdr_u_long(xdrs, &(handle->numrecs))) - return (FALSE); + + if (!h4_xdr_u_int(xdrs, &(handle->numrecs))) + return FALSE; } - if (!xdr_setpos(xdrs, RECPOS)) { + if (!h4_xdr_setpos(xdrs, RECPOS)) { nc_serror("Can't set position to RECPOS"); - return (FALSE); + return FALSE; } - return (xdr_u_long(xdrs, &(handle->numrecs))); + return h4_xdr_u_int(xdrs, &(handle->numrecs)); } static bool_t @@ -2362,8 +2363,8 @@ xdr_NC_fill(XDR *xdrs, NC_var *vp) char fillp[2 * sizeof(double)]; bool_t stat; bool_t (*xdr_NC_fnct)(); - u_long alen = vp->len; - NC_attr **attr = NULL; + unsigned long alen = vp->len; + NC_attr **attr = NULL; /* * set up fill value @@ -2392,7 +2393,7 @@ xdr_NC_fill(XDR *xdrs, NC_var *vp) case NC_BYTE: case NC_CHAR: alen /= 4; - xdr_NC_fnct = xdr_bytes; + xdr_NC_fnct = h4_xdr_bytes; break; case NC_SHORT: alen /= 4; @@ -2400,15 +2401,15 @@ xdr_NC_fill(XDR *xdrs, NC_var *vp) break; case NC_LONG: alen /= 4; - xdr_NC_fnct = xdr_int; + xdr_NC_fnct = h4_xdr_int; break; case NC_FLOAT: alen /= 4; - xdr_NC_fnct = xdr_float; + xdr_NC_fnct = h4_xdr_float; break; case NC_DOUBLE: alen /= 8; - xdr_NC_fnct = xdr_double; + xdr_NC_fnct = h4_xdr_double; break; default: NCadvise(NC_EBADTYPE, "bad type %d", vp->type); diff --git a/mfhdf/libsrc/dim.c b/mfhdf/libsrc/dim.c index df73543142..82b4ade374 100644 --- a/mfhdf/libsrc/dim.c +++ b/mfhdf/libsrc/dim.c @@ -268,14 +268,14 @@ xdr_NC_dim(XDR *xdrs, NC_dim **dpp) { if (xdrs->x_op == XDR_FREE) { NC_free_dim((*dpp)); - return (TRUE); + return TRUE; } if (xdrs->x_op == XDR_DECODE) { *dpp = malloc(sizeof(NC_dim)); if (*dpp == NULL) { nc_serror("xdr_NC_dim"); - return (FALSE); + return FALSE; } } @@ -284,8 +284,8 @@ xdr_NC_dim(XDR *xdrs, NC_dim **dpp) (*dpp)->count = 0; if (!xdr_NC_string(xdrs, &((*dpp)->name))) - return (FALSE); - return (xdr_long(xdrs, &((*dpp)->size))); + return FALSE; + return h4_xdr_int(xdrs, &((*dpp)->size)); } /* diff --git a/mfhdf/libsrc/file.c b/mfhdf/libsrc/file.c index e8d681e60b..1f2dd6f297 100644 --- a/mfhdf/libsrc/file.c +++ b/mfhdf/libsrc/file.c @@ -627,10 +627,10 @@ ncredef(int cdfid) static void NC_begins(NC *handle) { - unsigned ii; - u_long index = 0; - NC_var **vpp; - NC_var *last = NULL; + unsigned ii; + unsigned long index = 0; + NC_var **vpp; + NC_var *last = NULL; if (handle->vars == NULL) return; @@ -675,9 +675,6 @@ NC_begins(NC *handle) * Copy nbytes bytes from source to target. * Streams target and source should be positioned before the call. * opaque I/O, no XDR conversion performed (or needed). - * The Macros XDR_GETBYTES and XDR_PUTBYTES may not be - * supported on your xdr implementation. If not, calls - * to xdr_opaque may be used. */ bool_t NC_dcpy(XDR *target, XDR *source, long nbytes) @@ -687,16 +684,16 @@ NC_dcpy(XDR *target, XDR *source, long nbytes) char buf[NC_DCP_BUFSIZE]; while (nbytes > sizeof(buf)) { - if (!XDR_GETBYTES(source, buf, sizeof(buf))) + if (!h4_xdr_getbytes(source, buf, sizeof(buf))) goto err; - if (!XDR_PUTBYTES(target, buf, sizeof(buf))) + if (!h4_xdr_putbytes(target, buf, sizeof(buf))) goto err; nbytes -= sizeof(buf); } /* we know nbytes <= sizeof(buf) at this point */ - if (!XDR_GETBYTES(source, buf, nbytes)) + if (!h4_xdr_getbytes(source, buf, nbytes)) goto err; - if (!XDR_PUTBYTES(target, buf, nbytes)) + if (!h4_xdr_putbytes(target, buf, nbytes)) goto err; return (TRUE); err: @@ -714,8 +711,8 @@ NC_vcpy(XDR *target, NC *old, int varid) vpp = (NC_var **)old->vars->values; vpp += varid; - if (!xdr_setpos(old->xdrs, (*vpp)->begin)) { - NCadvise(NC_EXDR, "NC_vcpy: xdr_setpos"); + if (!h4_xdr_setpos(old->xdrs, (*vpp)->begin)) { + NCadvise(NC_EXDR, "NC_vcpy: h4_xdr_setpos"); return (FALSE); } @@ -732,8 +729,8 @@ NC_reccpy(XDR *target, NC *old, int varid, int recnum) vpp = (NC_var **)old->vars->values; vpp += varid; - if (!xdr_setpos(old->xdrs, (*vpp)->begin + old->recsize * recnum)) { - NCadvise(NC_EXDR, "NC_reccpy: xdr_setpos"); + if (!h4_xdr_setpos(old->xdrs, (*vpp)->begin + old->recsize * recnum)) { + NCadvise(NC_EXDR, "NC_reccpy: h4_xdr_setpos"); return (FALSE); } @@ -825,7 +822,7 @@ NC_endef(int cdfid, NC *handle) /* close stash */ /* NC_free_cdf(stash) ; */ #ifdef H4_HAVE_WIN32_API - xdr_destroy(handle->xdrs); /* close handle */ + h4_xdr_destroy(handle->xdrs); /* close handle */ if (remove(realpath) != 0) nc_serror("couldn't remove filename \"%s\"", realpath); #endif @@ -986,3 +983,58 @@ ncsetfill(int id, int fillmode) return ret; } + +int +NCxdrfile_sync(XDR *xdrs) +{ + return h4_xdr_sync(xdrs); +} + +int +NCxdrfile_create(XDR *xdrs, const char *path, int ncmode) +{ + int fmode; + int fd; + enum xdr_op op; + + switch (ncmode & 0x0f) { + case NC_NOCLOBBER: + fmode = O_RDWR | O_CREAT | O_EXCL; + break; + case NC_CLOBBER: + fmode = O_RDWR | O_CREAT | O_TRUNC; + break; + case NC_WRITE: + fmode = O_RDWR; + break; + case NC_NOWRITE: + fmode = O_RDONLY; + break; + default: + NCadvise(NC_EINVAL, "Bad flag %0x", ncmode & 0x0f); + return -1; + } + +#ifdef H4_HAVE_WIN32_API + /* Set default mode to binary to suppress the expansion of 0x0f into CRLF */ + _fmode |= O_BINARY; +#endif + + fd = open(path, fmode, 0666); + if (fd == -1) { + nc_serror("filename \"%s\"", path); + return -1; + } + + if (ncmode & NC_CREAT) { + op = XDR_ENCODE; + } + else { + op = XDR_DECODE; + } + + if (h4_xdr_create(xdrs, fd, fmode, op) < 0) + return -1; + else + return fd; +} diff --git a/mfhdf/libsrc/h4_xdr.c b/mfhdf/libsrc/h4_xdr.c new file mode 100644 index 0000000000..8e53036dba --- /dev/null +++ b/mfhdf/libsrc/h4_xdr.c @@ -0,0 +1,713 @@ +/* + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * xdr.c, Generic XDR routines implementation. + * + * Copyright (C) 1986, Sun Microsystems, Inc. + * + * These are the "generic" xdr routines used to serialize and de-serialize + * most common data items. See xdr.h for more info on the interface to + * xdr. + */ + +#include "h4config.h" + +#include +#include +#include +#include + +/* Which header files include htonl() ? */ + +#ifdef H4_HAVE_WIN32_API +/* Use winsock on Win32 (including MinGW) */ +#include +#else +/* And normal network headers everywhere else */ +#ifdef H4_HAVE_ARPA_INET_H +#include +#endif +#ifdef H4_HAVE_NETINET_IN_H +#include /* for htonl() */ +#endif +#endif + +#include "mfhdf.h" +#include "h4_xdr.h" + +/* + * This is the number of bytes per unit of external data. + */ +#define BYTES_PER_XDR_UNIT (4) + +/* + * for unit alignment + */ +static const char xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0}; + +/* Forward declarations */ +static bool_t h4_xdr_get32(XDR *xdrs, uint32_t *up); +static bool_t h4_xdr_put32(XDR *xdrs, const uint32_t *up); + +/******************/ +/* XDR Type Calls */ +/******************/ + +/* These per-type API calls encode/decode/free depending on the op field + * in the XDR struct. They use the lower-level XDR calls found after the + * I/O buffering code, below. + */ + +/* + * XDR integers + */ +bool_t +h4_xdr_int(XDR *xdrs, int *ip) +{ + switch (xdrs->x_op) { + + case XDR_ENCODE: + return h4_xdr_put32(xdrs, (uint32_t *)ip); + + case XDR_DECODE: + return h4_xdr_get32(xdrs, (uint32_t *)ip); + + case XDR_FREE: + return TRUE; + } + /* NOTREACHED */ + return FALSE; +} + +/* + * XDR unsigned integers + */ +bool_t +h4_xdr_u_int(XDR *xdrs, unsigned *up) +{ + switch (xdrs->x_op) { + + case XDR_ENCODE: + return h4_xdr_put32(xdrs, up); + + case XDR_DECODE: + return h4_xdr_get32(xdrs, up); + + case XDR_FREE: + return TRUE; + } + /* NOTREACHED */ + return FALSE; +} + +/* + * XDR opaque data + * + * Allows the specification of a fixed size sequence of opaque bytes. + * cp points to the opaque object and cnt gives the byte length. + */ +bool_t +h4_xdr_opaque(XDR *xdrs, char *cp, unsigned cnt) +{ + unsigned rndup; + static int crud[BYTES_PER_XDR_UNIT]; + + /* + * if no data we are done + */ + if (cnt == 0) + return TRUE; + + /* + * round byte count to full xdr units + */ + rndup = cnt % BYTES_PER_XDR_UNIT; + if (rndup > 0) + rndup = BYTES_PER_XDR_UNIT - rndup; + + if (xdrs->x_op == XDR_DECODE) { + if (!h4_xdr_getbytes(xdrs, cp, cnt)) + return FALSE; + if (rndup == 0) + return TRUE; + return h4_xdr_getbytes(xdrs, (char *)crud, rndup); + } + + if (xdrs->x_op == XDR_ENCODE) { + if (!h4_xdr_putbytes(xdrs, cp, cnt)) + return FALSE; + if (rndup == 0) + return TRUE; + return h4_xdr_putbytes(xdrs, xdr_zero, rndup); + } + + if (xdrs->x_op == XDR_FREE) + return TRUE; + + return FALSE; +} + +/* + * XDR counted bytes + * + * This is a special data structure that starts with the size, followed + * by the raw bytes (as an opaque XDR type). + * + * For raw, uninterpreted byte I/O, see the xdr_put/getbytes() calls. + * + * *cpp is a pointer to the bytes, *sizep is the count. + * If *cpp is NULL maxsize bytes are allocated + */ +bool_t +h4_xdr_bytes(XDR *xdrs, char **cpp, unsigned *sizep, unsigned maxsize) +{ + char *sp = *cpp; /* sp is the actual string pointer */ + unsigned nodesize; + bool_t ret; + bool_t allocated = FALSE; + + /* + * first deal with the length since xdr bytes are counted + */ + if (!h4_xdr_u_int(xdrs, sizep)) + return FALSE; + nodesize = *sizep; + if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) + return FALSE; + + /* + * now deal with the actual bytes + */ + switch (xdrs->x_op) { + + case XDR_DECODE: + if (nodesize == 0) + return TRUE; + if (sp == NULL) { + *cpp = sp = calloc(1, nodesize); + allocated = TRUE; + } + if (sp == NULL) { + fprintf(stderr, "h4_xdr_bytes: out of memory\n"); + return FALSE; + } + /* FALLTHROUGH */ + + case XDR_ENCODE: + ret = h4_xdr_opaque(xdrs, sp, nodesize); + if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) { + if (allocated == TRUE) { + free(sp); + *cpp = NULL; + } + } + return ret; + + case XDR_FREE: + if (sp != NULL) { + free(sp); + *cpp = NULL; + } + return TRUE; + } + /* NOTREACHED */ + return FALSE; +} + +/* + * XDR 4-byte floats + */ +bool_t +h4_xdr_float(XDR *xdrs, float *fp) +{ + switch (xdrs->x_op) { + + case XDR_ENCODE: + return h4_xdr_int(xdrs, (int *)fp); + + case XDR_DECODE: + return h4_xdr_int(xdrs, (int *)fp); + + case XDR_FREE: + return TRUE; + } + return FALSE; +} + +/* + * XDR 8-byte doubles + * + * Performed in two 32-bit operations because XDR does not have a 64-bit + * I/O operation. + */ +bool_t +h4_xdr_double(XDR *xdrs, double *dp) +{ + int *ip; + bool_t rv; + + if (!dp) + return FALSE; + + switch (xdrs->x_op) { + case XDR_ENCODE: + ip = (int *)(void *)dp; +#ifdef H4_WORDS_BIGENDIAN + rv = h4_xdr_int(xdrs, ip); + if (!rv) + return rv; + rv = h4_xdr_int(xdrs, ip + 1); +#else + rv = h4_xdr_int(xdrs, ip + 1); + if (!rv) + return rv; + rv = h4_xdr_int(xdrs, ip); +#endif + return rv; + break; + + case XDR_DECODE: + ip = (int *)(void *)dp; +#ifdef H4_WORDS_BIGENDIAN + rv = h4_xdr_int(xdrs, ip); + if (!rv) + return rv; + rv = h4_xdr_int(xdrs, ip + 1); +#else + rv = h4_xdr_int(xdrs, ip + 1); + if (!rv) + return rv; + rv = h4_xdr_int(xdrs, ip); +#endif + return rv; + break; + + case XDR_FREE: + return TRUE; + } + + return FALSE; +} + +/****************************/ +/* I/O Buffer Functionality */ +/****************************/ + +/* As an optimization, the XDR I/O layer uses a single I/O buffer to + * speed up nearby reads and writes ("bio" == Buffered I/O). + * + * TODO: This is not a very big cache! Bumping it might enhance I/O + * performance. + */ + +/* Size of the I/O buffer in bytes */ +#define BIOBUFSIZ 8192 + +/* # of valid bytes in the buffer */ +#define CNT(p) ((p)->ptr - (p)->base) + +/* # of unread bytes in buffer */ +#define REM(p) ((p)->cnt - CNT(p)) + +/* Available space for write in buffer */ +#define BREM(p) (BIOBUFSIZ - CNT(p)) + +/* POSIX and I/O buffer info + * + * Stored in the XDR struct's private data + * + * NOTE: off_t is 32-bits on Windows, but that shouldn't be a problem since + * HDF4 files are limited to 4 GB. + */ +typedef struct biobuf { + int fd; /* POSIX file descriptor */ + int mode; /* File access mode, O_RDONLY, etc */ + int isdirty; /* Dirty buffer flag */ + off_t page; /* Location in the file */ + int nread; /* Number of bytes successfully read */ + int nwrote; /* Number of bytes last written */ + int cnt; /* Number of valid bytes in buffer */ + uint8_t *ptr; /* Next byte (pointer into base) */ + uint8_t base[BIOBUFSIZ]; /* Data buffer */ +} biobuf; + +/* + * Initialize the POSIX/buffer XDR state + */ +static biobuf * +bio_get_new(int fd, int fmode) +{ + biobuf *biop = NULL; + + if (NULL == (biop = (biobuf *)calloc(1, sizeof(biobuf)))) + return NULL; + + biop->fd = fd; + biop->mode = fmode; + biop->ptr = biop->base; + + return biop; +} + +/* + * Read a page from the file into the buffer + */ +static int +bio_read_page(biobuf *biop) +{ + /* Clear out the buffer */ + memset(biop->base, 0, BIOBUFSIZ); + + if (biop->mode & O_WRONLY) { + /* If we're only writing, the buffer is empty */ + biop->cnt = 0; + } + else { + if (biop->nwrote != BIOBUFSIZ) { + /* Last write wasn't a full block, adjust position ahead */ + if (lseek(biop->fd, biop->page * BIOBUFSIZ, SEEK_SET) == ((off_t)-1)) + return -1; + } + + /* Read from storage into the buffer */ + biop->nread = biop->cnt = read(biop->fd, (void *)biop->base, BIOBUFSIZ); + } + + biop->ptr = biop->base; + + return biop->cnt; +} + +/* + * Write a page from the buffer to the file + */ +static int +bio_write_page(biobuf *biop) +{ + + if (!((biop->mode & O_WRONLY) || (biop->mode & O_RDWR)) || biop->cnt == 0) { + biop->nwrote = 0; + } + else { + if (biop->nread != 0) { + /* If we read something, we have to adjust position back */ + if (lseek(biop->fd, biop->page * BIOBUFSIZ, SEEK_SET) == ((off_t)-1)) + return -1; + } + biop->nwrote = write(biop->fd, (void *)biop->base, biop->cnt); + } + biop->isdirty = 0; + + return biop->nwrote; +} + +/* + * Get the next page from the file + * + * Returns the number of valid bytes in the buffer + */ +static int +bio_get_next_page(biobuf *biop) +{ + /* Flush if dirty */ + if (biop->isdirty) { + if (bio_write_page(biop) < 0) + return -1; + } + + biop->page++; + + /* Read in the next page */ + if (bio_read_page(biop) < 0) + return -1; + + return biop->cnt; +} + +/* + * Read bytes from the file through the buffer + */ +static int +bio_read(biobuf *biop, unsigned char *ptr, int nbytes) +{ + int ngot = 0; + size_t rem; + + if (nbytes == 0) + return 0; + + while (nbytes > (rem = REM(biop))) { + if (rem > 0) { + (void)memcpy(ptr, biop->ptr, rem); + ptr += rem; + nbytes -= rem; + ngot += rem; + } + if (bio_get_next_page(biop) <= 0) + return ngot; + } + + /* We know nbytes <= REM at this point */ + (void)memcpy(ptr, biop->ptr, (size_t)nbytes); + biop->ptr += nbytes; + ngot += nbytes; + return ngot; +} + +/* + * Write bytes to the file through the buffer + */ +static int +bio_write(biobuf *biop, unsigned char *ptr, int nbytes) +{ + size_t rem; + int nwrote = 0; + int cnt; + + if (!((biop->mode & O_WRONLY) || (biop->mode & O_RDWR))) + return -1; + + while (nbytes > (rem = BREM(biop))) { + if (rem > 0) { + (void)memcpy(biop->ptr, ptr, rem); + biop->isdirty = !0; + biop->cnt = BIOBUFSIZ; + ptr += rem; + nbytes -= rem; + nwrote += rem; + } + if (bio_get_next_page(biop) < 0) + return nwrote; + } + + /* We know nbytes <= BREM at this point */ + (void)memcpy(biop->ptr, ptr, (size_t)nbytes); + biop->isdirty = !0; + biop->ptr += nbytes; + if ((cnt = CNT(biop)) > biop->cnt) + biop->cnt = cnt; + nwrote += nbytes; + + return nwrote; +} + +/***********************/ +/* Low-Level XDR Calls */ +/***********************/ + +/* + * Read/write the number of bytes in a C long to the XDR file. 'uint32_t' is + * being used in the sense of '4 bytes' and not a long integer value. + */ + +static bool_t +h4_xdr_get32(XDR *xdrs, uint32_t *up) +{ + uint8_t *p = (uint8_t *)up; + + if (bio_read((biobuf *)xdrs->x_private, p, 4) < 4) + return FALSE; + +#ifndef H4_WORDS_BIGENDIAN + /* Reminder that ntohl returns a uint32_t on modern systems */ + *up = ntohl(*up); +#endif + + return TRUE; +} + +static bool_t +h4_xdr_put32(XDR *xdrs, const uint32_t *up) +{ + + uint8_t *p = (uint8_t *)up; + +#ifndef H4_WORDS_BIGENDIAN + /* Reminder that htonl returns a uint32_t on modern systems */ + uint32_t mycopy = htonl(*up); + p = (uint8_t *)&mycopy; +#endif + + if (bio_write((biobuf *)xdrs->x_private, p, 4) < 4) + return FALSE; + return TRUE; +} + +/* + * Read/Write a bunch of bytes to/from an XDR file + * + * NOTE: These deal with raw bytes, not "counted bytes", like h4_xdr_bytes() does! + */ + +bool_t +h4_xdr_getbytes(XDR *xdrs, char *addr, unsigned len) +{ + if ((len != 0) && (bio_read((biobuf *)xdrs->x_private, (unsigned char *)addr, (int)len) != len)) + return FALSE; + return TRUE; +} + +bool_t +h4_xdr_putbytes(XDR *xdrs, const char *addr, unsigned len) +{ + if ((len != 0) && (bio_write((biobuf *)xdrs->x_private, (unsigned char *)addr, (int)len) != len)) + return FALSE; + return TRUE; +} + +/* + * Get/set the position in an XDR file. Goes through the I/O buffer. + */ + +unsigned +h4_xdr_getpos(XDR *xdrs) +{ + biobuf *biop = (biobuf *)xdrs->x_private; + return BIOBUFSIZ * biop->page + CNT(biop); +} + +bool_t +h4_xdr_setpos(XDR *xdrs, unsigned pos) +{ + biobuf *biop = (biobuf *)xdrs->x_private; + if (biop != NULL) { + off_t page; + int index; + int nread; + page = pos / BIOBUFSIZ; + index = pos % BIOBUFSIZ; + if (page != biop->page) { + if (biop->isdirty) { + if (bio_write_page(biop) < 0) + return FALSE; + } + if (page != biop->page + 1) + biop->nwrote = 0; /* force seek in bio_read_page */ + + biop->page = page; + + nread = bio_read_page(biop); + if (nread < 0 || ((biop->mode & O_RDONLY) && nread < index)) + return FALSE; + } + biop->ptr = biop->base + index; + return TRUE; + } + else + return FALSE; +} + +/************************/ +/* XDR File State Calls */ +/************************/ + +/* + * Set up the I/O buffer in the passed-in XDR struct + * + * This is used in the netCDF code, which has a different way of setting + * up the file. + */ +void +h4_xdr_setup_nofile(XDR *xdrs, int ncop) +{ + biobuf *biop = bio_get_new(-1, 0); + + if (ncop & NC_CREAT) + xdrs->x_op = XDR_ENCODE; + else + xdrs->x_op = XDR_DECODE; + + xdrs->x_private = biop; +} + +/* + * Initialize a POSIX XDR file + * + * Sets up XDR to use the POSIX file descriptor fd + * + * Operation flag is initialized to op + */ +int +h4_xdr_create(XDR *xdrs, int fd, int fmode, enum xdr_op op) +{ + biobuf *biop = bio_get_new(fd, fmode); + xdrs->x_op = op; + xdrs->x_private = biop; + if (biop == NULL) + return -1; + + /* If write only, or just created (empty), done */ + if ((biop->mode & O_WRONLY) || (biop->mode & O_CREAT)) + return 0; + + /* Else, read the first bufferful */ + return bio_read_page(biop); +} + +/* + * Flush the I/O buffer to the file + */ +int +h4_xdr_sync(XDR *xdrs) +{ + biobuf *biop = (biobuf *)xdrs->x_private; + if (biop->isdirty) { + /* Flush */ + if (bio_write_page(biop) < 0) + return -1; + } + + biop->nwrote = 0; /* Force seek in bio_read_page */ + + /* Read it in */ + if (bio_read_page(biop) < 0) + return -1; + + return biop->cnt; +} + +/* + * Destroy a POSIX XDR stream + * + * Cleans up after h4_xdr_create() + */ +void +h4_xdr_destroy(XDR *xdrs) +{ + /* Flush */ + biobuf *biop = (biobuf *)xdrs->x_private; + if (biop != NULL) { + if (biop->isdirty) { + (void)bio_write_page(biop); + } + if (biop->fd != -1) + (void)close(biop->fd); + free(biop); + } +} diff --git a/mfhdf/libsrc/h4_xdr.h b/mfhdf/libsrc/h4_xdr.h new file mode 100644 index 0000000000..561e312ff6 --- /dev/null +++ b/mfhdf/libsrc/h4_xdr.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2009, Sun Microsystems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of Sun Microsystems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * xdr.h, External Data Representation Serialization Routines. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef H4_XDR_H +#define H4_XDR_H + +#include "H4api_adpt.h" + +#include +#include +#include + +#ifdef H4_HAVE_SYS_TYPES_H +#include +#endif + +#include "mfhdf.h" + +/* NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE + * + * This is not a normal XDR implementation! + * + * XDR has caused a lot of problems due to the waning availability of the + * library (removed from libc some time ago) and the variable size of long + * integers and the way various XDR implementations handled that. + * + * What we have here is a stripped-down implementation of XDR that only + * performs POSIX I/O to a file and removes the problematic XDR "long" + * operations. + * + * In the future, this implementation will be replaced with something + * even simpler. + * + * NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE + */ + +/* XDR Boolean type */ +typedef int32_t bool_t; + +/* + * XDR operations + * + * - XDR_ENCODE causes the type to be encoded into the stream + * - XDR_DECODE causes the type to be extracted from the stream + * - XDR_FREE can be used to release the space allocated by an XDR_DECODE request + */ +enum xdr_op { XDR_ENCODE = 0, XDR_DECODE = 1, XDR_FREE = 2 }; + +/* Forward declaration */ +struct biobuf; + +/* + * The XDR handle + * + * Contains the operation which is being applied to the stream and a + * private field. + */ +typedef struct xinfo { + enum xdr_op x_op; /* Operation */ + struct biobuf *x_private; /* Pointer to private data */ +} XDR; + +#ifdef __cplusplus +extern "C" { +#endif + +/* NOTE! There are additional netCDF XDR ops scattered throughout the code! */ + +/* + * Operations defined on an XDR handle + */ +HDFLIBAPI bool_t h4_xdr_getbytes(XDR *, char *, unsigned); +HDFLIBAPI bool_t h4_xdr_putbytes(XDR *, const char *, unsigned); + +HDFLIBAPI unsigned h4_xdr_getpos(XDR *); +HDFLIBAPI bool_t h4_xdr_setpos(XDR *, unsigned); + +/* + * "Data type" XDR routines that read/write/free depending on the op + * parameter of the XDR struct + */ +HDFLIBAPI bool_t h4_xdr_int(XDR *, int *); +HDFLIBAPI bool_t h4_xdr_u_int(XDR *, unsigned *); + +HDFLIBAPI bool_t h4_xdr_bytes(XDR *, char **, unsigned *, unsigned); +HDFLIBAPI bool_t h4_xdr_opaque(XDR *, char *, unsigned); + +HDFLIBAPI bool_t h4_xdr_float(XDR *, float *); +HDFLIBAPI bool_t h4_xdr_double(XDR *, double *); + +/* XDR file manipulation */ +HDFLIBAPI int h4_xdr_create(XDR *xdrs, int fd, int fmode, enum xdr_op op); +HDFLIBAPI int h4_xdr_sync(XDR *xdrs); +HDFLIBAPI void h4_xdr_destroy(XDR *); + +HDFLIBAPI void h4_xdr_setup_nofile(XDR *xdrs, int ncop); + +#ifdef __cplusplus +} +#endif + +#endif /* H4_XDR_H */ diff --git a/mfhdf/libsrc/iarray.c b/mfhdf/libsrc/iarray.c index 44315e7509..8d20ba81b8 100644 --- a/mfhdf/libsrc/iarray.c +++ b/mfhdf/libsrc/iarray.c @@ -67,9 +67,9 @@ NC_free_iarray(NC_iarray *iarray) bool_t xdr_NC_iarray(XDR *xdrs, NC_iarray **ipp) { - int *ip; - u_long count = 0; - bool_t stat = TRUE; + int *ip; + unsigned count = 0; + bool_t stat = TRUE; switch (xdrs->x_op) { case XDR_FREE: @@ -77,7 +77,7 @@ xdr_NC_iarray(XDR *xdrs, NC_iarray **ipp) return (TRUE); case XDR_DECODE: /* need the length to pass to new */ - if (!xdr_u_long(xdrs, &count)) { + if (!h4_xdr_u_int(xdrs, &count)) { return (FALSE); } (*ipp) = NC_new_iarray((unsigned)count, (int *)NULL); @@ -85,17 +85,17 @@ xdr_NC_iarray(XDR *xdrs, NC_iarray **ipp) return (FALSE); /* then deal with the array */ for (ip = (*ipp)->values; (count > 0) && stat; count--) - stat = xdr_int(xdrs, ip++); + stat = h4_xdr_int(xdrs, ip++); return (stat); case XDR_ENCODE: /* first deal with the length */ count = (*ipp)->count; - if (!xdr_u_long(xdrs, &count)) { + if (!h4_xdr_u_int(xdrs, &count)) { return (FALSE); } /* then deal with the array */ for (ip = (*ipp)->values; (count > 0) && stat; count--) - stat = xdr_int(xdrs, ip++); + stat = h4_xdr_int(xdrs, ip++); return (stat); } return (FALSE); diff --git a/mfhdf/libsrc/local_nc.h b/mfhdf/libsrc/local_nc.h index 5fd33675e2..4c261327c2 100644 --- a/mfhdf/libsrc/local_nc.h +++ b/mfhdf/libsrc/local_nc.h @@ -30,34 +30,8 @@ #define FILENAME_MAX 255 #endif -/* Do we have system XDR files */ -#ifndef H4_NO_SYS_XDR_INC - -#ifdef __CYGWIN__ -#ifndef __u_char_defined -typedef unsigned char u_char; -#define __u_char_defined -#endif -#ifndef __u_short_defined -typedef unsigned short u_short; -#define __u_short_defined -#endif -#ifndef __u_int_defined -typedef unsigned int u_int; -#define __u_int_defined -#endif -#ifndef __u_long_defined -typedef unsigned long u_long; -#define __u_long_defined -#endif -#endif /* __CYGWIN__ */ - -#include -#include -#else /* H4_NO_SYS_XDR_INC */ -#include "types.h" -#include "xdr.h" -#endif /* H4_NO_SYS_XDR_INC */ +/* HDF4's stripped-down XDR implementation */ +#include "h4_xdr.h" #ifdef H4_HAVE_NETCDF #include "netcdf.h" /* needed for defs of nc_type, ncvoid, ... */ @@ -149,7 +123,7 @@ typedef struct { /* NC dimension structure */ typedef struct { NC_string *name; - long size; + int32 size; int32 dim00_compat; /* compatible with Dim0.0 */ int32 vgid; /* id of the Vgroup representing this dimension */ int32 count; /* Number of pointers to this dimension */ @@ -171,15 +145,15 @@ typedef struct { unsigned long recsize; /* length of 'record' */ int redefid; /* below gets xdr'd */ - unsigned long numrecs; /* number of 'records' allocated */ - NC_array *dims; - NC_array *attrs; - NC_array *vars; - int32 hdf_file; - int file_type; - int32 vgid; - int hdf_mode; /* mode we are attached for */ - hdf_file_t cdf_fp; /* file pointer used for CDF files */ + unsigned numrecs; /* number of 'records' allocated */ + NC_array *dims; + NC_array *attrs; + NC_array *vars; + int32 hdf_file; + int file_type; + int32 vgid; + int hdf_mode; /* mode we are attached for */ + hdf_file_t cdf_fp; /* file pointer used for CDF files */ } NC; /* NC variable: description and data */ @@ -257,8 +231,9 @@ extern "C" { #endif /* If using the real netCDF library and API (when --disable-netcdf configure flag is used) - need to mangle the HDF versions of netCDF API function names - to not conflict w/ oriinal netCDF ones */ + * need to mangle the HDF versions of netCDF API function names + * to not conflict w/ oriinal netCDF ones + */ #ifndef H4_HAVE_NETCDF #define nc_serror HNAME(nc_serror) #define NCadvise HNAME(NCadvise) @@ -315,10 +290,8 @@ extern "C" { #define NC_dcpy HNAME(NC_dcpy) #define NCxdrfile_sync HNAME(NCxdrfile_sync) #define NCxdrfile_create HNAME(NCxdrfile_create) -#ifdef HDF -#define NCgenio HNAME(NCgenio) /* from putgetg.c */ -#define NC_var_shape HNAME(NC_var_shape) /* from var.c */ -#endif +#define NCgenio HNAME(NCgenio) /* from putgetg.c */ +#define NC_var_shape HNAME(NC_var_shape) /* from var.c */ #endif /* !H4_HAVE_NETCDF ie. NOT USING HDF version of netCDF ncxxx API */ #define nncpopt H4_F77_FUNC(ncpopt, NCPOPT) @@ -453,7 +426,7 @@ HDFLIBAPI bool_t NCcktype(nc_type datatype); HDFLIBAPI bool_t NC_indefine(int cdfid, bool_t iserr); HDFLIBAPI bool_t xdr_cdf(XDR *xdrs, NC **handlep); HDFLIBAPI bool_t xdr_numrecs(XDR *xdrs, NC *handle); -HDFLIBAPI bool_t xdr_shorts(XDR *xdrs, short *sp, u_int cnt); +HDFLIBAPI bool_t xdr_shorts(XDR *xdrs, short *sp, unsigned cnt); HDFLIBAPI bool_t xdr_NC_array(XDR *xdrs, NC_array **app); HDFLIBAPI bool_t xdr_NC_attr(XDR *xdrs, NC_attr **app); HDFLIBAPI bool_t xdr_NC_dim(XDR *xdrs, NC_dim **dpp); @@ -485,9 +458,6 @@ HDFLIBAPI int NCxdrfile_sync(XDR *xdrs); HDFLIBAPI int NCxdrfile_create(XDR *xdrs, const char *path, int ncmode); -/* this routine is found in 'xdrposix.c' */ -HDFLIBAPI void hdf_xdrfile_create(XDR *xdrs, int ncop); - HDFLIBAPI intn hdf_fill_array(Void *storage, int32 len, Void *value, int32 type); HDFLIBAPI intn hdf_get_data(NC *handle, NC_var *vp); diff --git a/mfhdf/libsrc/mfsd.c b/mfhdf/libsrc/mfsd.c index c6894566b0..efa7cc5be1 100644 --- a/mfhdf/libsrc/mfsd.c +++ b/mfhdf/libsrc/mfsd.c @@ -3762,10 +3762,8 @@ SDgetcompress( comp_info *c_info /* OUT: ptr to compression information structure for storing the retrieved info */ ) { - NC *handle; - NC_var *var = NULL; - intn status = FAIL; - intn ret_value = SUCCEED; + intn status = FAIL; + intn ret_value = SUCCEED; /* clear error stack */ HEclear(); diff --git a/mfhdf/libsrc/putget.c b/mfhdf/libsrc/putget.c index d4df776f85..2befea8f31 100644 --- a/mfhdf/libsrc/putget.c +++ b/mfhdf/libsrc/putget.c @@ -19,12 +19,13 @@ #include "hfile.h" /* Ugh! We need the defs for HI_READ and HI_SEEK */ /* Local function prototypes */ -static bool_t nssdc_xdr_NCvdata(NC *handle, NC_var *vp, u_long where, nc_type type, uint32 count, +static bool_t nssdc_xdr_NCvdata(NC *handle, NC_var *vp, unsigned long where, nc_type type, uint32 count, void *values); -static intn hdf_xdr_NCvdata(NC *handle, NC_var *vp, u_long where, nc_type type, uint32 count, void *values); +static intn hdf_xdr_NCvdata(NC *handle, NC_var *vp, unsigned long where, nc_type type, uint32 count, + void *values); -static intn hdf_xdr_NCv1data(NC *handle, NC_var *vp, u_long where, nc_type type, void *values); +static intn hdf_xdr_NCv1data(NC *handle, NC_var *vp, unsigned long where, nc_type type, void *values); static intn SDIresizebuf(void **buf, int32 *buf_size, int32 size_wanted); @@ -32,7 +33,7 @@ static const long *NCvcmaxcontig(NC *, NC_var *, const long *, const long *); int NC_fill_buffer(NC *handle, int varid, const long *edges, void *values); -#define xdr_NCsetpos(xdrs, pos) xdr_setpos((xdrs), (pos)) +#define xdr_NCsetpos(xdrs, pos) h4_xdr_setpos((xdrs), (pos)) /* * Check if an ncxxx function has called the current function @@ -264,10 +265,10 @@ NCcoordck(NC *handle, NC_var *vp, const long *coords) /* * Translate the (variable, coords) pair into a seek index */ -static u_long +static unsigned long NC_varoffset(NC *handle, NC_var *vp, const long *coords) { - u_long offset; + unsigned long offset; const long *ip; unsigned long *up; const long *boundary; @@ -342,22 +343,22 @@ NC_varoffset(NC *handle, NC_var *vp, const long *coords) static bool_t xdr_NCvbyte(XDR *xdrs, unsigned rem, unsigned count, char *values) { - char buf[4]; - u_long origin = 0; - enum xdr_op x_op = xdrs->x_op; /* save state */ + char buf[4]; + unsigned long origin = 0; + enum xdr_op x_op = xdrs->x_op; /* save state */ if (x_op == XDR_ENCODE) { /* * Since we only read/write multiples of four bytes, * We will read in the word to change one byte in it. */ - origin = xdr_getpos(xdrs); + origin = h4_xdr_getpos(xdrs); /* Next op is a get */ xdrs->x_op = XDR_DECODE; } - if (!xdr_opaque(xdrs, buf, 4)) { + if (!h4_xdr_opaque(xdrs, buf, 4)) { /* Get failed, assume we are trying to read off the end */ memset(buf, 0, sizeof(buf)); } @@ -376,9 +377,9 @@ xdr_NCvbyte(XDR *xdrs, unsigned rem, unsigned count, char *values) } if (x_op == XDR_ENCODE) { - if (!xdr_setpos(xdrs, origin)) + if (!h4_xdr_setpos(xdrs, origin)) return (FALSE); - if (!xdr_opaque(xdrs, buf, 4)) + if (!h4_xdr_opaque(xdrs, buf, 4)) return (FALSE); } @@ -393,17 +394,17 @@ bool_t xdr_NCvshort(XDR *xdrs, unsigned which, short *values) { unsigned char buf[4]; /* unsigned is important here */ - u_long origin = 0; + unsigned long origin = 0; enum xdr_op x_op = xdrs->x_op; /* save state */ if (x_op == XDR_ENCODE) { - origin = xdr_getpos(xdrs); + origin = h4_xdr_getpos(xdrs); /* Next op is a get */ xdrs->x_op = XDR_DECODE; } - if (!xdr_opaque(xdrs, (char *)buf, 4)) { + if (!h4_xdr_opaque(xdrs, (char *)buf, 4)) { /* Get failed, assume we are trying to read off the end */ memset(buf, 0, sizeof(buf)); } @@ -418,9 +419,9 @@ xdr_NCvshort(XDR *xdrs, unsigned which, short *values) buf[which + 1] = *values % 256; buf[which] = (*values >> 8); - if (!xdr_setpos(xdrs, origin)) + if (!h4_xdr_setpos(xdrs, origin)) return (FALSE); - if (!xdr_opaque(xdrs, (char *)buf, 4)) + if (!h4_xdr_opaque(xdrs, (char *)buf, 4)) return (FALSE); } else { @@ -437,9 +438,9 @@ xdr_NCvshort(XDR *xdrs, unsigned which, short *values) * xdr a single datum of type 'type' at 'where' */ static bool_t -xdr_NCv1data(XDR *xdrs, u_long where, nc_type type, Void *values) +xdr_NCv1data(XDR *xdrs, unsigned long where, nc_type type, Void *values) { - u_long rem = 0; + unsigned long rem = 0; switch (type) { case NC_BYTE: @@ -461,15 +462,12 @@ xdr_NCv1data(XDR *xdrs, u_long where, nc_type type, Void *values) case NC_SHORT: return (xdr_NCvshort(xdrs, (unsigned)rem / 2, (short *)values)); case NC_LONG: -#ifdef H4_HAVE_LP64 - return (xdr_int(xdrs, (nclong *)values)); -#else - return (xdr_long(xdrs, (nclong *)values)); -#endif + /* nclong is defined to a 32-bit integer type in netcdf.h */ + return (h4_xdr_int(xdrs, (nclong *)values)); case NC_FLOAT: - return (xdr_float(xdrs, (float *)values)); + return (h4_xdr_float(xdrs, (float *)values)); case NC_DOUBLE: - return (xdr_double(xdrs, (double *)values)); + return (h4_xdr_double(xdrs, (double *)values)); default: break; } @@ -782,7 +780,7 @@ hdf_get_vp_aid(NC *handle, NC_var *vp) * The calling routine is responsible for calling DFKsetNT() as required. */ static intn -hdf_xdr_NCvdata(NC *handle, NC_var *vp, u_long where, nc_type type, uint32 count, void *values) +hdf_xdr_NCvdata(NC *handle, NC_var *vp, unsigned long where, nc_type type, uint32 count, void *values) { NC_attr **attr = NULL; /* pointer to the fill-value attribute */ int32 status; @@ -1303,7 +1301,7 @@ hdf_xdr_NCvdata(NC *handle, NC_var *vp, u_long where, nc_type type, uint32 count * Return TRUE if everything worked, else FALSE */ static intn -hdf_xdr_NCv1data(NC *handle, NC_var *vp, u_long where, nc_type type, void *values) +hdf_xdr_NCv1data(NC *handle, NC_var *vp, unsigned long where, nc_type type, void *values) { intn ret_value = SUCCEED; @@ -1330,7 +1328,7 @@ hdf_xdr_NCv1data(NC *handle, NC_var *vp, u_long where, nc_type type, void *value * it 100 percent -GV */ static bool_t -nssdc_xdr_NCvdata(NC *handle, NC_var *vp, u_long where, nc_type type, uint32 count, void *values) +nssdc_xdr_NCvdata(NC *handle, NC_var *vp, unsigned long where, nc_type type, uint32 count, void *values) { int32 status; int32 byte_count; @@ -1355,8 +1353,8 @@ nssdc_xdr_NCvdata(NC *handle, NC_var *vp, u_long where, nc_type type, uint32 cou static int NCvar1io(NC *handle, int varid, const long *coords, Void *value) { - NC_var *vp; - u_long offset; + NC_var *vp; + unsigned long offset; if (handle->flags & NC_INDEF) return (-1); @@ -1440,9 +1438,9 @@ ncvarget1(int cdfid, int varid, const long *coords, ncvoid *value) * xdr 'count' items of contiguous data of type 'type' at 'where' */ static bool_t -xdr_NCvdata(XDR *xdrs, u_long where, nc_type type, unsigned count, Void *values) +xdr_NCvdata(XDR *xdrs, unsigned long where, nc_type type, unsigned count, Void *values) { - u_long rem = 0; + unsigned long rem = 0; bool_t (*xdr_NC_fnct)(); bool_t stat; size_t szof; @@ -1473,7 +1471,7 @@ xdr_NCvdata(XDR *xdrs, u_long where, nc_type type, unsigned count, Void *values) rem = count % 4; /* tail remainder */ count -= rem; - if (!xdr_opaque(xdrs, values, count)) + if (!h4_xdr_opaque(xdrs, values, count)) return (FALSE); if (rem != 0) { @@ -1500,15 +1498,15 @@ xdr_NCvdata(XDR *xdrs, u_long where, nc_type type, unsigned count, Void *values) } /* else */ return (TRUE); case NC_LONG: - xdr_NC_fnct = xdr_int; + xdr_NC_fnct = h4_xdr_int; szof = sizeof(nclong); break; case NC_FLOAT: - xdr_NC_fnct = xdr_float; + xdr_NC_fnct = h4_xdr_float; szof = sizeof(float); break; case NC_DOUBLE: - xdr_NC_fnct = xdr_double; + xdr_NC_fnct = h4_xdr_double; szof = sizeof(double); break; default: @@ -1692,11 +1690,11 @@ NCvario(NC *handle, int varid, const long *start, const long *edges, void *value /* now edp = edp0 - 1 */ { /* inline */ - long coords[H4_MAX_VAR_DIMS], upper[H4_MAX_VAR_DIMS]; - long *cc; - const long *mm; - u_long offset; - size_t szof = nctypelen(vp->type); + long coords[H4_MAX_VAR_DIMS], upper[H4_MAX_VAR_DIMS]; + long *cc; + const long *mm; + unsigned long offset; + size_t szof = nctypelen(vp->type); /* copy in starting indices */ cc = coords; @@ -1975,12 +1973,12 @@ ncrecinq(int cdfid, int *nrecvars, int *recvarids, long *recsizes) static int NCrecio(NC *handle, long recnum, Void **datap) { - int nrvars; - NC_var *rvp[H4_MAX_NC_VARS]; - int ii; - long coords[H4_MAX_VAR_DIMS]; - u_long offset; - unsigned iocount; + int nrvars; + NC_var *rvp[H4_MAX_NC_VARS]; + int ii; + long coords[H4_MAX_VAR_DIMS]; + unsigned long offset; + unsigned iocount; nrvars = NCnumrecvars(handle, rvp, (int *)NULL); if (nrvars == -1) diff --git a/mfhdf/libsrc/sharray.c b/mfhdf/libsrc/sharray.c index 87198814b2..fa737a91ac 100644 --- a/mfhdf/libsrc/sharray.c +++ b/mfhdf/libsrc/sharray.c @@ -24,7 +24,7 @@ * internal function, bulk xdr of an even number of shorts, less than NC_NSHRTS_PER */ static bool_t -NCxdr_shortsb(XDR *xdrs, short *sp, u_int nshorts) +NCxdr_shortsb(XDR *xdrs, short *sp, unsigned nshorts) { unsigned char buf[NC_SHRT_BUFSIZ]; unsigned char *cp; @@ -37,7 +37,7 @@ NCxdr_shortsb(XDR *xdrs, short *sp, u_int nshorts) } } - if (!xdr_opaque(xdrs, (char *)buf, nbytes)) + if (!h4_xdr_opaque(xdrs, (char *)buf, nbytes)) return FALSE; if (xdrs->x_op == XDR_DECODE) { @@ -57,7 +57,7 @@ NCxdr_shortsb(XDR *xdrs, short *sp, u_int nshorts) * Translate an array of cnt short integers at sp. */ bool_t -xdr_shorts(XDR *xdrs, short *sp, u_int cnt) +xdr_shorts(XDR *xdrs, short *sp, unsigned cnt) { int odd; /* 1 if cnt is odd, 0 otherwise */ diff --git a/mfhdf/libsrc/string.c b/mfhdf/libsrc/string.c index 838213aeda..558c27e4f4 100644 --- a/mfhdf/libsrc/string.c +++ b/mfhdf/libsrc/string.c @@ -121,8 +121,8 @@ NC_re_string(NC_string *old, unsigned count, const char *str) bool_t xdr_NC_string(XDR *xdrs, NC_string **spp) { - u_long count = 0; - int status; + unsigned count = 0; + int status; switch (xdrs->x_op) { case XDR_FREE: @@ -130,7 +130,7 @@ xdr_NC_string(XDR *xdrs, NC_string **spp) return (TRUE); case XDR_DECODE: /* need the length to pass to new */ - if (!xdr_u_long(xdrs, &count)) { + if (!h4_xdr_u_int(xdrs, &count)) { return (FALSE); } if (count == 0) { @@ -142,7 +142,7 @@ xdr_NC_string(XDR *xdrs, NC_string **spp) return (FALSE); (*spp)->values[count] = 0; /* then deal with the characters */ - status = xdr_opaque(xdrs, (*spp)->values, (*spp)->count); + status = h4_xdr_opaque(xdrs, (*spp)->values, (*spp)->count); /* might be padded */ (*spp)->len = strlen((*spp)->values); @@ -151,14 +151,14 @@ xdr_NC_string(XDR *xdrs, NC_string **spp) /* first deal with the length */ if (*spp == NULL) { count = 0; - return (xdr_u_long(xdrs, &count)); + return (h4_xdr_u_int(xdrs, &count)); } /* else */ count = (*spp)->count; - if (!xdr_u_long(xdrs, &count)) { + if (!h4_xdr_u_int(xdrs, &count)) { return (FALSE); } /* then deal with the characters */ - return (xdr_opaque(xdrs, (*spp)->values, (*spp)->count)); + return (h4_xdr_opaque(xdrs, (*spp)->values, (*spp)->count)); } return (FALSE); } diff --git a/mfhdf/libsrc/var.c b/mfhdf/libsrc/var.c index f7a3bac353..acf78812bf 100644 --- a/mfhdf/libsrc/var.c +++ b/mfhdf/libsrc/var.c @@ -517,12 +517,12 @@ xdr_NC_var(XDR *xdrs, NC_var **vpp) if (!xdr_NC_array(xdrs, &((*vpp)->attrs))) return (FALSE); - if (!xdr_int(xdrs, &temp_type)) { + if (!h4_xdr_int(xdrs, &temp_type)) { return (FALSE); } (*vpp)->type = (nc_type)temp_type; - if (!xdr_u_int(xdrs, &temp_len)) { + if (!h4_xdr_u_int(xdrs, &temp_len)) { return (FALSE); } (*vpp)->len = (unsigned long)temp_len; @@ -532,7 +532,7 @@ xdr_NC_var(XDR *xdrs, NC_var **vpp) if (xdrs->x_op == XDR_ENCODE) begin = (*vpp)->begin; - if (!xdr_u_int(xdrs, &begin)) + if (!h4_xdr_u_int(xdrs, &begin)) return (FALSE); if (xdrs->x_op == XDR_DECODE) (*vpp)->begin = begin; diff --git a/mfhdf/xdr/NOTICE.h b/mfhdf/libsrc/xdr_NOTICE.h similarity index 94% rename from mfhdf/xdr/NOTICE.h rename to mfhdf/libsrc/xdr_NOTICE.h index 28f3a43ab4..6f796c8a8c 100644 --- a/mfhdf/xdr/NOTICE.h +++ b/mfhdf/libsrc/xdr_NOTICE.h @@ -7,7 +7,7 @@ * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the diff --git a/mfhdf/xdr/README b/mfhdf/libsrc/xdr_README similarity index 97% rename from mfhdf/xdr/README rename to mfhdf/libsrc/xdr_README index 35bdcca975..758452eb78 100644 --- a/mfhdf/xdr/README +++ b/mfhdf/libsrc/xdr_README @@ -7,7 +7,7 @@ Please read "NOTICE.h" This is the minimum subset of RPCSRC 3.9 needed to build the netcdf library. It is included here for those systems which lack xdr support. If your system already has these xdr routines, by all means use them. -Unix systems which suport the Network File System (NFS) usually have these +Unix systems which support the Network File System (NFS) usually have these routines in the 'c' library, /usr/lib/libc.a, so you don't need to link in any additional libraries. Another candididate is librpclib.a in /usr/lib or /usr/local/lib. diff --git a/mfhdf/libsrc/xdrposix.c b/mfhdf/libsrc/xdrposix.c deleted file mode 100644 index df412d4ce2..0000000000 --- a/mfhdf/libsrc/xdrposix.c +++ /dev/null @@ -1,532 +0,0 @@ -/* - * XDR implementation on POSIX file interface, with buffering - * - * Copyright (C) 1992, University Corp for Atmospheric Research - * - * This set of routines implements a XDR on a POSIX file descriptor. - * XDR_ENCODE serializes onto the descriptor, XDR_DECODE de-serializes - * from the descriptor. As in stdio, we buffer i/o. This XDR is most - * useful when the descriptor actually represents a file. It - * corrects some performance problems with xdrstdio_getpos() and - * xdrstdio_getpos() in the xdr_stdio implementation. - */ -#include "h4config.h" - -#include -#include - -#ifdef H4_HAVE_FCNTL_H -#include -#endif - -#ifdef H4_HAVE_IO_H -#include -#endif - -#ifdef H4_HAVE_UNISTD_H -#include -#endif - -#ifdef H4_HAVE_SYS_TYPES_H -#include -#endif - -/* prototypes for NCadvis, nc_error also obtains , , & - * - */ -#include "local_nc.h" - -#include "mfhdf.h" - -#ifdef H4_HAVE_ARPA_INET_H -#include -#endif - -#ifdef H4_HAVE_NETINET_IN_H -#include /* for htonl() */ -#endif - -typedef struct { - int fd; /* the file descriptor */ - int mode; /* file access mode, O_RDONLY, etc */ - int isdirty; - off_t page; - int nread; /* number of bytes successfully read */ - int nwrote; /* number of bytes last write */ - int cnt; /* number of valid bytes in buffer */ - unsigned char *ptr; /* next byte */ -#define BIOBUFSIZ 8192 - unsigned char base[BIOBUFSIZ]; /* the data buffer */ -} biobuf; - -static biobuf * -new_biobuf(int fd, int fmode) -{ - biobuf *biop; - - biop = malloc(sizeof(biobuf)); - if (biop == NULL) - return NULL; - biop->fd = fd; - - biop->mode = fmode; - - biop->isdirty = 0; - biop->page = 0; - biop->nread = 0; - biop->nwrote = 0; - biop->cnt = 0; - memset(biop->base, 0, ((size_t)(BIOBUFSIZ))); - biop->ptr = biop->base; - - return biop; -} - -static int -rdbuf(biobuf *biop) -{ - memset(biop->base, 0, ((size_t)(BIOBUFSIZ))); - - if (biop->mode & O_WRONLY) { - biop->cnt = 0; - } - else { - if (biop->nwrote != BIOBUFSIZ) { - /* last write wasn't a full block, adjust position ahead */ - if (lseek(biop->fd, biop->page * BIOBUFSIZ, SEEK_SET) == ((off_t)-1)) - return -1; - } - biop->nread = biop->cnt = read(biop->fd, (void *)biop->base, BIOBUFSIZ); - } - biop->ptr = biop->base; - return biop->cnt; -} - -static int -wrbuf(biobuf *biop) -{ - - if (!((biop->mode & O_WRONLY) || (biop->mode & O_RDWR)) || biop->cnt == 0) { - biop->nwrote = 0; - } - else { - if (biop->nread != 0) { - /* if we read something, we have to adjust position back */ - if (lseek(biop->fd, biop->page * BIOBUFSIZ, SEEK_SET) == ((off_t)-1)) - return -1; - } - biop->nwrote = write(biop->fd, (void *)biop->base, biop->cnt); - } - biop->isdirty = 0; - - return biop->nwrote; -} - -static int -nextbuf(biobuf *biop) -{ - if (biop->isdirty) { - if (wrbuf(biop) < 0) - return -1; - } - - biop->page++; - - /* read it in */ - if (rdbuf(biop) < 0) - return -1; - - return biop->cnt; -} - -#define CNT(p) ((p)->ptr - (p)->base) - -/* # of unread bytes in buffer */ -#define REM(p) ((p)->cnt - CNT(p)) - -/* available space for write in buffer */ -#define BREM(p) (BIOBUFSIZ - CNT(p)) - -static int -bioread(biobuf *biop, unsigned char *ptr, int nbytes) -{ - int ngot = 0; - size_t rem; - - if (nbytes == 0) - return 0; - - while (nbytes > (rem = REM(biop))) { - if (rem > 0) { - (void)memcpy(ptr, biop->ptr, rem); - ptr += rem; - nbytes -= rem; - ngot += rem; - } - if (nextbuf(biop) <= 0) - return ngot; - } - /* we know nbytes <= REM at this point */ - (void)memcpy(ptr, biop->ptr, (size_t)nbytes); - biop->ptr += nbytes; - ngot += nbytes; - return ngot; -} - -static int -biowrite(biobuf *biop, unsigned char *ptr, int nbytes) -{ - size_t rem; - int nwrote = 0; - int cnt; - - if (!((biop->mode & O_WRONLY) || (biop->mode & O_RDWR))) - return -1; - - while (nbytes > (rem = BREM(biop))) { - if (rem > 0) { - (void)memcpy(biop->ptr, ptr, rem); - biop->isdirty = !0; - biop->cnt = BIOBUFSIZ; - ptr += rem; - nbytes -= rem; - nwrote += rem; - } - if (nextbuf(biop) < 0) - return nwrote; - } - /* we know nbytes <= BREM at this point */ - (void)memcpy(biop->ptr, ptr, (size_t)nbytes); - biop->isdirty = !0; - biop->ptr += nbytes; - if ((cnt = CNT(biop)) > biop->cnt) - biop->cnt = cnt; - nwrote += nbytes; - - return nwrote; -} - -static bool_t xdrposix_getlong(XDR *xdrs, long *lp); -static bool_t xdrposix_putlong(XDR *xdrs, const long *lp); -static bool_t xdrposix_getbytes(XDR *xdrs, char *addr, u_int len); -static bool_t xdrposix_putbytes(XDR *xdrs, const char *addr, u_int len); -static u_int xdrposix_getpos(XDR *xdrs); -static bool_t xdrposix_setpos(XDR *xdrs, u_int pos); -static int32_t *xdrposix_inline(XDR *xdrs, u_int len); -static void xdrposix_destroy(XDR *xdrs); -#if (defined __sun && defined _LP64) -static bool_t xdrposix_getint(XDR *xdrs, int *lp); -static bool_t xdrposix_putint(XDR *xdrs, const int *lp); -#endif - -/* - * Ops vector for posix type XDR - */ -static struct xdr_ops xdrposix_ops = { - xdrposix_getlong, /* deserialize a 32-bit int */ - xdrposix_putlong, /* serialize a 32-bit int */ - xdrposix_getbytes, /* deserialize counted bytes */ - xdrposix_putbytes, /* serialize counted bytes */ - xdrposix_getpos, /* get offset in the stream */ - xdrposix_setpos, /* set offset in the stream */ - xdrposix_inline, /* prime stream for inline macros */ - xdrposix_destroy, /* destroy stream */ - NULL, /* no xdr_control function defined */ -#if defined(__sun) && defined(_LP64) - /* Solaris 64-bit (arch=v9 and arch=amd64) differentiates between - * 32-bit integers and 64-bit longs via two extra callbacks for - * int here. These are not present on other XDR implementations - * like TI-RPC. - */ - xdrposix_getint, /* deserialize a 32-bit int */ - xdrposix_putint /* serialize a 32-bit int */ -#endif -}; - -/* - * Fake an XDR initialization for HDF files - */ -void -hdf_xdrfile_create(XDR *xdrs, int ncop) -{ - biobuf *biop = new_biobuf(-1, 0); - - if (ncop & NC_CREAT) - xdrs->x_op = XDR_ENCODE; - else - xdrs->x_op = XDR_DECODE; - - xdrs->x_ops = &xdrposix_ops; - xdrs->x_private = (char *)biop; - -} /* hdf_xdrfile_create */ - -/* - * Initialize a posix xdr stream. - * Sets the xdr stream handle xdrs for use on the file descriptor fd. - * Operation flag is set to op. - */ -static int -xdrposix_create(XDR *xdrs, int fd, int fmode, enum xdr_op op) -{ - biobuf *biop = new_biobuf(fd, fmode); -#ifdef XDRDEBUG - fprintf(stderr, "xdrposix_create(): xdrs=%p, fd=%d, fmode=%d, op=%d\n", xdrs, fd, fmode, (int)op); - fprintf(stderr, "xdrposix_create(): after new_biobuf(), biop=%p\n", biop); -#endif - xdrs->x_op = op; - xdrs->x_ops = &xdrposix_ops; - xdrs->x_private = (char *)biop; - /* unused */ - xdrs->x_handy = 0; - xdrs->x_base = 0; - if (biop == NULL) - return -1; - - /* if write only, or just created (empty), done */ - if ((biop->mode & O_WRONLY) || (biop->mode & O_CREAT)) - return 0; - -#ifdef XDRDEBUG - fprintf(stderr, "xdrposix_create(): before rdbuf()\n"); -#endif - /* else, read the first bufferful */ - return rdbuf(biop); -} - -/* - * "sync" a posix xdr stream. - */ -static int -xdrposix_sync(XDR *xdrs) -{ - biobuf *biop = (biobuf *)xdrs->x_private; - if (biop->isdirty) { - /* flush */ - if (wrbuf(biop) < 0) - return -1; - } - - biop->nwrote = 0; /* force seek in rdbuf */ - - /* read it in */ - if (rdbuf(biop) < 0) - return -1; - - return biop->cnt; -} - -/* - * Destroy a posix xdr stream. - * Cleans up the xdr stream handle xdrs previously set up by xdrposix_create. - */ -static void -xdrposix_destroy(XDR *xdrs) -{ - /* flush */ - biobuf *biop = (biobuf *)xdrs->x_private; - if (biop != NULL) { - if (biop->isdirty) { - (void)wrbuf(biop); - } - if (biop->fd != -1) - (void)close(biop->fd); - free(biop); - } -} - -static bool_t -xdrposix_getlong(XDR *xdrs, long *lp) -{ - unsigned char *up = (unsigned char *)lp; -#if (defined AIX5L64 || defined __powerpc64__) - *lp = 0; - up += (sizeof(long) - 4); -#endif - if (bioread((biobuf *)xdrs->x_private, up, 4) < 4) - return FALSE; -#ifndef H4_WORDS_BIGENDIAN - *lp = ntohl(*lp); -#endif - return TRUE; -} - -static bool_t -xdrposix_putlong(XDR *xdrs, const long *lp) -{ - - unsigned char *up = (unsigned char *)lp; -#ifndef H4_WORDS_BIGENDIAN - int32_t mycopy = htonl(*lp); - up = (unsigned char *)&mycopy; -#endif -#if (defined AIX5L64 || defined __powerpc64__) - up += (sizeof(long) - 4); -#endif - - if (biowrite((biobuf *)xdrs->x_private, up, 4) < 4) - return FALSE; - return TRUE; -} - -static bool_t -xdrposix_getbytes(XDR *xdrs, char *addr, u_int len) -{ - if ((len != 0) && (bioread((biobuf *)xdrs->x_private, (unsigned char *)addr, (int)len) != len)) - return FALSE; - return TRUE; -} - -static bool_t -xdrposix_putbytes(XDR *xdrs, const char *addr, u_int len) -{ - if ((len != 0) && (biowrite((biobuf *)xdrs->x_private, (unsigned char *)addr, (int)len) != len)) - return FALSE; - return TRUE; -} - -static u_int -xdrposix_getpos(XDR *xdrs) -{ - biobuf *biop = (biobuf *)xdrs->x_private; - return BIOBUFSIZ * biop->page + CNT(biop); -} - -static bool_t -xdrposix_setpos(XDR *xdrs, u_int pos) -{ - biobuf *biop = (biobuf *)xdrs->x_private; - if (biop != NULL) { - off_t page; - int index; - int nread; - page = pos / BIOBUFSIZ; - index = pos % BIOBUFSIZ; - if (page != biop->page) { - if (biop->isdirty) { - if (wrbuf(biop) < 0) - return FALSE; - } - if (page != biop->page + 1) - biop->nwrote = 0; /* force seek in rdbuf */ - - biop->page = page; - - nread = rdbuf(biop); - if (nread < 0 || ((biop->mode & O_RDONLY) && nread < index)) - return FALSE; - } - biop->ptr = biop->base + index; - return TRUE; - } - else - return FALSE; -} - -static int32_t * -xdrposix_inline(XDR *xdrs, u_int len) -{ - (void)xdrs; - (void)len; - /* - * Must do some work to implement this: must insure - * enough data in the underlying posix buffer, - * that the buffer is aligned so that we can indirect through a - * int32_t *, and stuff this pointer in xdrs->x_buf. - */ - return NULL; -} - -#if (defined __sun && defined _LP64) - -static bool_t -xdrposix_getint(XDR *xdrs, int *lp) -{ - unsigned char *up = (unsigned char *)lp; - if (bioread((biobuf *)xdrs->x_private, up, 4) < 4) - return FALSE; -#ifndef H4_WORDS_BIGENDIAN - *lp = ntohl(*lp); -#endif - return TRUE; -} - -static bool_t -xdrposix_putint(XDR *xdrs, const int *lp) -{ - unsigned char *up = (unsigned char *)lp; -#ifndef H4_WORDS_BIGENDIAN - int32_t mycopy = htonl(*lp); - up = (unsigned char *)&mycopy; -#endif - if (biowrite((biobuf *)xdrs->x_private, up, 4) < 4) - return FALSE; - return TRUE; -} -#endif /* end of xdrposix_put(get)int */ - -int -NCxdrfile_sync(XDR *xdrs) -{ - return xdrposix_sync(xdrs); -} - -int -NCxdrfile_create(XDR *xdrs, const char *path, int ncmode) -{ - int fmode; - int fd; - enum xdr_op op; - -#ifdef XDRDEBUG - fprintf(stderr, "NCxdrfile_create(): XDR=%p, path=%s, ncmode=%d\n", xdrs, path, ncmode); -#endif - switch (ncmode & 0x0f) { - case NC_NOCLOBBER: - fmode = O_RDWR | O_CREAT | O_EXCL; - break; - case NC_CLOBBER: - fmode = O_RDWR | O_CREAT | O_TRUNC; - break; - case NC_WRITE: - fmode = O_RDWR; - break; - case NC_NOWRITE: - fmode = O_RDONLY; - break; - default: - NCadvise(NC_EINVAL, "Bad flag %0x", ncmode & 0x0f); - return -1; - } - -#ifdef H4_HAVE_WIN32_API - /* Set default mode to binary to suppress the expansion of 0x0f into CRLF */ - _fmode |= O_BINARY; -#endif - - fd = open(path, fmode, 0666); -#ifdef XDRDEBUG - fprintf(stderr, "NCxdrfile_create(): fmode=%d, fd=%d\n", fmode, fd); -#endif - if (fd == -1) { - nc_serror("filename \"%s\"", path); - return -1; - } - - if (ncmode & NC_CREAT) { - op = XDR_ENCODE; - } - else { - op = XDR_DECODE; - } - -#ifdef XDRDEBUG - fprintf(stderr, "NCxdrfile_create(): before xdrposix_create()\n"); -#endif - if (xdrposix_create(xdrs, fd, fmode, op) < 0) - return -1; -#ifdef XDRDEBUG - fprintf(stderr, "NCxdrfile_create(): after xdrposix_create()\n"); -#endif - return fd; -} diff --git a/mfhdf/ncdump/CMakeLists.txt b/mfhdf/ncdump/CMakeLists.txt index 39f334ac02..e2aaf1a5dd 100644 --- a/mfhdf/ncdump/CMakeLists.txt +++ b/mfhdf/ncdump/CMakeLists.txt @@ -1,10 +1,6 @@ cmake_minimum_required (VERSION 3.12) project (HDF4_MFHDF_NCDUMP C) -if (HDF4_BUILD_XDR_LIB) - INCLUDE_DIRECTORIES (${HDF4_MFHDF_XDR_DIR}) -endif () - set (ncdump_SRCS ${HDF4_MFHDF_NCDUMP_SOURCE_DIR}/dumplib.c ${HDF4_MFHDF_NCDUMP_SOURCE_DIR}/ncdump.c @@ -14,7 +10,7 @@ set (ncdump_SRCS if (NOT ONLY_SHARED_LIBS) add_executable (ncdump ${ncdump_SRCS}) - target_include_directories (ncdump PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_MFHDF_UTIL_DIR};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories (ncdump PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_MFHDF_UTIL_DIR};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (ncdump STATIC) target_link_libraries (ncdump PRIVATE ${HDF4_MF_LIB_TARGET}) set_target_properties (ncdump PROPERTIES COMPILE_DEFINITIONS "HDF") @@ -24,7 +20,7 @@ endif () if (BUILD_SHARED_LIBS) add_executable (ncdump-shared ${ncdump_SRCS}) - target_include_directories (ncdump-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_MFHDF_UTIL_DIR};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories (ncdump-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_MFHDF_UTIL_DIR};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (ncdump-shared SHARED) target_link_libraries (ncdump-shared PRIVATE ${HDF4_MF_LIBSH_TARGET}) set_target_properties (ncdump-shared PROPERTIES COMPILE_DEFINITIONS "HDF") diff --git a/mfhdf/ncdump/Makefile.am b/mfhdf/ncdump/Makefile.am index 21b61bc6f6..d0fabe0269 100644 --- a/mfhdf/ncdump/Makefile.am +++ b/mfhdf/ncdump/Makefile.am @@ -10,7 +10,7 @@ ncdump_INCLUDES=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/util \ -I$(top_builddir)/mfhdf/libsrc DEFINES=-DHDF -AM_CPPFLAGS=$(ncdump_INCLUDES) $(XDRINC) $(DEFINES) +AM_CPPFLAGS=$(ncdump_INCLUDES) $(DEFINES) ## Add ncdump specific linker flags here ncdump_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) @@ -26,8 +26,8 @@ man1_MANS = ncdump.1 ## Information for building the "ncdump" program ncdump_SOURCES = dumplib.c ncdump.c vardata.c $(top_srcdir)/mfhdf/util/h4getopt.c -ncdump_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) -ncdump_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +ncdump_LDADD = $(LIBMFHDF) $(LIBHDF) +ncdump_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) ############################################################################# ## And the cleanup ## diff --git a/mfhdf/ncgen/CMakeLists.txt b/mfhdf/ncgen/CMakeLists.txt index d9c14eb087..4e7e1cf5f1 100644 --- a/mfhdf/ncgen/CMakeLists.txt +++ b/mfhdf/ncgen/CMakeLists.txt @@ -22,7 +22,7 @@ set (ncgen_SRCS if (NOT ONLY_SHARED_LIBS) add_executable (ncgen ${ncgen_SRCS}) - target_include_directories(ncgen PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_MFHDF_UTIL_DIR};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(ncgen PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_MFHDF_UTIL_DIR};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (ncgen STATIC) target_link_libraries (ncgen PRIVATE ${HDF4_MF_LIB_TARGET}) set_target_properties (ncgen PROPERTIES COMPILE_DEFINITIONS "HDF") @@ -32,7 +32,7 @@ endif () if (BUILD_SHARED_LIBS) add_executable (ncgen-shared ${ncgen_SRCS}) - target_include_directories(ncgen-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_MFHDF_UTIL_DIR};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") + target_include_directories(ncgen-shared PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_MFHDF_UTIL_DIR};${HDF4_BINARY_DIR}") TARGET_C_PROPERTIES (ncgen-shared SHARED) target_link_libraries (ncgen-shared PRIVATE ${HDF4_MF_LIBSH_TARGET}) set_target_properties (ncgen-shared PROPERTIES COMPILE_DEFINITIONS "HDF") diff --git a/mfhdf/ncgen/Makefile.am b/mfhdf/ncgen/Makefile.am index 3bee3f216a..6760dcdc47 100644 --- a/mfhdf/ncgen/Makefile.am +++ b/mfhdf/ncgen/Makefile.am @@ -16,7 +16,7 @@ ncgen_INCLUDES=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/util \ -I$(top_builddir)/mfhdf/libsrc DEFINES=-DHDF -AM_CPPFLAGS=$(ncgen_INCLUDES) $(XDRINC) $(DEFINES) +AM_CPPFLAGS=$(ncgen_INCLUDES) $(DEFINES) ## Add ncgen specific linker flags here ncgen_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) @@ -40,12 +40,12 @@ endif ## Information for building the "ncgen" program ncgen_SOURCES = close.c escapes.c generate.c genlib.c getfill.c init.c \ load.c main.c ncgentab.c $(top_srcdir)/mfhdf/util/h4getopt.c -ncgen_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) -ncgen_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +ncgen_LDADD = $(LIBMFHDF) $(LIBHDF) +ncgen_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) ctest0_SOURCES= -ctest0_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) -ctest0_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +ctest0_LDADD = $(LIBMFHDF) $(LIBHDF) +ctest0_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) ftest0_SOURCES= diff --git a/mfhdf/nctest/CMakeLists.txt b/mfhdf/nctest/CMakeLists.txt index 62c69996d8..e9f2d08c70 100644 --- a/mfhdf/nctest/CMakeLists.txt +++ b/mfhdf/nctest/CMakeLists.txt @@ -25,7 +25,7 @@ set (nctest_SRCS ) add_executable (nctest ${nctest_SRCS}) -target_include_directories(nctest PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR};$<$:${HDF4_MFHDF_XDR_DIR}>") +target_include_directories(nctest PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDFSOURCE_DIR};${HDF4_BINARY_DIR}") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (nctest STATIC) target_link_libraries (nctest PRIVATE ${HDF4_MF_LIB_TARGET}) diff --git a/mfhdf/nctest/Makefile.am b/mfhdf/nctest/Makefile.am index 3507f1e1c7..cfdaf5ff99 100644 --- a/mfhdf/nctest/Makefile.am +++ b/mfhdf/nctest/Makefile.am @@ -9,7 +9,7 @@ nctest_INCLUDES=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/libsrc \ -I$(top_builddir)/mfhdf/libsrc DEFINES=-DHDF -AM_CPPFLAGS=$(nctest_INCLUDES) $(XDRINC) $(DEFINES) +AM_CPPFLAGS=$(nctest_INCLUDES) $(DEFINES) ############################################################################# ## Programs to build ## @@ -23,8 +23,8 @@ nctest_SOURCES = add.c atttests.c cdftests.c dimtests.c driver.c emalloc.c \ error.c misctest.c rec.c slabs.c val.c varget_unlim.c \ varget.c vargetg.c varput.c varputg.c vardef.c vartests.c \ vputget.c vputgetg.c -nctest_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) -nctest_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) +nctest_LDADD = $(LIBMFHDF) $(LIBHDF) +nctest_DEPENDENCIES = $(LIBMFHDF) $(LIBHDF) ############################################################################# ## And the cleanup ## diff --git a/mfhdf/nctest/nctest.lnk b/mfhdf/nctest/nctest.lnk index 4910f3cdbd..d33b0482aa 100644 --- a/mfhdf/nctest/nctest.lnk +++ b/mfhdf/nctest/nctest.lnk @@ -1,5 +1,5 @@ driver vartests cdftests dimtests atttests misctest nctest /noi nctest -nctest.lib ..\libsrc\netcdf.lib ..\xdr\xdr.lib \hdf\hdf\lib\df.lib /NOD:llibce llibcewq libw +nctest.lib ..\libsrc\netcdf.lib \hdf\hdf\lib\df.lib /NOD:llibce llibcewq libw nctest diff --git a/mfhdf/test/CMakeTests.cmake b/mfhdf/test/CMakeTests.cmake index 431aadcea5..91900509d8 100644 --- a/mfhdf/test/CMakeTests.cmake +++ b/mfhdf/test/CMakeTests.cmake @@ -130,44 +130,3 @@ set_tests_properties (MFHDF_TEST-hdfnctest PROPERTIES DEPENDS MFHDF_TEST-cdftest LABELS ${PROJECT_NAME} ) - -#-- Adding test for xdrtest -if (HDF4_BUILD_XDR_LIB) - add_executable (xdrtest ${HDF4_MFHDF_XDR_DIR}/xdrtest.c) - target_include_directories(xdrtest PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDF_XDR_SOURCE_DIR};${HDF4_BINARY_DIR}") - if (NOT BUILD_SHARED_LIBS) - TARGET_C_PROPERTIES (xdrtest STATIC) - target_link_libraries (xdrtest PRIVATE ${HDF4_MF_XDR_LIB_TARGET}) - else () - TARGET_C_PROPERTIES (xdrtest SHARED) - target_link_libraries (xdrtest PRIVATE ${HDF4_MF_XDR_LIBSH_TARGET}) - endif () - if (CMAKE_C_COMPILER_ID MATCHES "IntelLLVM") - target_compile_options(xdrtest PRIVATE "-Wno-incompatible-function-pointer-types") - endif () - - if (MSVC_VERSION LESS 1900) - HDFTEST_COPY_FILE("${HDF4_MFHDF_XDR_DIR}/xdrtest.out" "${PROJECT_BINARY_DIR}/TEST/xdrtest.out" "xdrtest_files") - else () - HDFTEST_COPY_FILE("${HDF4_MFHDF_XDR_DIR}/xdrtest.cyg" "${PROJECT_BINARY_DIR}/TEST/xdrtest.out" "xdrtest_files") - endif () - add_custom_target(xdrtest_files ALL COMMENT "Copying files needed by xdrtest tests" DEPENDS ${xdrtest_files_list}) - - if (HDF4_ENABLE_USING_MEMCHECKER) - add_test (NAME MFHDF_TEST-xdrtest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) - else () - add_test ( - NAME MFHDF_TEST-xdrtest - COMMAND "${CMAKE_COMMAND}" - -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/TEST" - -D "TEST_OUTPUT=xdrtest.tst" - -D "TEST_EXPECT=0" - -D "TEST_REFERENCE=xdrtest.out" - -P "${HDF_RESOURCES_DIR}/runTest.cmake" - ) - endif () - set_tests_properties (MFHDF_TEST-xdrtest PROPERTIES DEPENDS hdfnctest LABELS ${PROJECT_NAME}) -endif () diff --git a/mfhdf/test/Makefile.am b/mfhdf/test/Makefile.am index 4c96916b7c..129e1450da 100644 --- a/mfhdf/test/Makefile.am +++ b/mfhdf/test/Makefile.am @@ -9,11 +9,7 @@ test_INCLUDES=-I$(top_srcdir)/hdf/src \ -I$(top_srcdir)/mfhdf/libsrc \ -I$(top_builddir)/mfhdf/libsrc DEFINES=-DHDF -AM_CPPFLAGS=$(test_INCLUDES) $(XDRINC) $(DEFINES) - -if HDF_BUILD_XDR -XDRLIB = $(top_builddir)/mfhdf/xdr/libxdr.la -endif +AM_CPPFLAGS=$(test_INCLUDES) $(DEFINES) ############################################################################# ## Testing ## @@ -25,17 +21,17 @@ check_PROGRAMS = cdftest hdfnctest hdftest check_SCRIPTS = testmfhdf.sh cdftest_SOURCES = cdftest.c -cdftest_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) @LIBS@ +cdftest_LDADD = $(LIBMFHDF) $(LIBHDF) @LIBS@ hdfnctest_SOURCES = hdfnctest.c tutils.c tncvargetfill.c tunlim.c \ tncunlim.c -hdfnctest_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) @LIBS@ +hdfnctest_LDADD = $(LIBMFHDF) $(LIBHDF) @LIBS@ hdftest_SOURCES = hdftest.c tutils.c tchunk.c tcomp.c tcoordvar.c \ tdim.c temptySDSs.c tattributes.c texternal.c tfile.c \ tmixed_apis.c tnetcdf.c trank0.c tsd.c tsdsprops.c \ tszip.c tattdatainfo.c tdatainfo.c tdatasizes.c -hdftest_LDADD = $(LIBMFHDF) $(LIBHDF) $(XDRLIB) @LIBS@ +hdftest_LDADD = $(LIBMFHDF) $(LIBHDF) @LIBS@ ############################################################################# ## And the cleanup ## diff --git a/mfhdf/xdr/CMakeLists.txt b/mfhdf/xdr/CMakeLists.txt deleted file mode 100644 index 09df1bbd9a..0000000000 --- a/mfhdf/xdr/CMakeLists.txt +++ /dev/null @@ -1,92 +0,0 @@ -cmake_minimum_required (VERSION 3.12) -project (HDF4_MFHDF_XDR C) - -set (HDF4_MFHDF_XDR_SRCS - ${HDF4_MFHDF_XDR_SOURCE_DIR}/xdr.c - ${HDF4_MFHDF_XDR_SOURCE_DIR}/xdrfloat.c - ${HDF4_MFHDF_XDR_SOURCE_DIR}/xdrstdio.c - ${HDF4_MFHDF_XDR_SOURCE_DIR}/xdrarray.c -) - -set (HDF4_MFHDF_XDR_HDRS - ${HDF4_MFHDF_XDR_SOURCE_DIR}/xdr.h - ${HDF4_MFHDF_XDR_SOURCE_DIR}/types.h -) - -if (NOT ONLY_SHARED_LIBS) - add_library (${HDF4_MF_XDR_LIB_TARGET} STATIC ${HDF4_MFHDF_XDR_SRCS} ${HDF4_MFHDF_XDR_HDRS}) - target_include_directories(${HDF4_MF_XDR_LIB_TARGET} PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDF_XDR_SOURCE_DIR};${HDF4_BINARY_DIR}") - target_compile_options(${HDF4_MF_XDR_LIB_TARGET} PRIVATE "${HDF4_CMAKE_C_FLAGS}") - target_compile_definitions(${HDF4_MF_XDR_LIB_TARGET} - PUBLIC - ${HDF_EXTRA_C_FLAGS} - ${HDF_EXTRA_FLAGS} - ) - target_link_libraries (${HDF4_MF_XDR_LIB_TARGET} PUBLIC "$<$,$>:ws2_32.lib>") - TARGET_C_PROPERTIES (${HDF4_MF_XDR_LIB_TARGET} STATIC) - set_global_variable (HDF4_LIBRARIES_TO_EXPORT "${HDF4_LIBRARIES_TO_EXPORT};${HDF4_MF_XDR_LIB_TARGET}") - H4_SET_LIB_OPTIONS (${HDF4_MF_XDR_LIB_TARGET} ${HDF4_MF_XDR_LIB_NAME} STATIC) - set_target_properties (${HDF4_MF_XDR_LIB_TARGET} PROPERTIES - FOLDER libraries - COMPILE_DEFINITIONS "HDF" - INTERFACE_INCLUDE_DIRECTORIES "$/include>" - ) - set (install_targets ${HDF4_MF_XDR_LIB_TARGET}) -endif () - -if (BUILD_SHARED_LIBS) - add_library (${HDF4_MF_XDR_LIBSH_TARGET} SHARED ${HDF4_MFHDF_XDR_SRCS} ${HDF4_MFHDF_XDR_HDRS}) - target_include_directories(${HDF4_MF_XDR_LIBSH_TARGET} PRIVATE "${HDF4_HDFSOURCE_DIR};${HDF4_MFHDF_XDR_SOURCE_DIR};${HDF4_BINARY_DIR}") - target_compile_options(${HDF4_MF_XDR_LIBSH_TARGET} PRIVATE "${HDF4_CMAKE_C_FLAGS}") - target_compile_definitions(${HDF4_MF_XDR_LIBSH_TARGET} - PUBLIC - ${HDF_EXTRA_C_FLAGS} - ${HDF_EXTRA_FLAGS} - ) - target_link_libraries (${HDF4_MF_XDR_LIBSH_TARGET} PUBLIC "$<$,$>:ws2_32.lib>") - TARGET_C_PROPERTIES (${HDF4_MF_XDR_LIBSH_TARGET} SHARED) - set_global_variable (HDF4_LIBRARIES_TO_EXPORT "${HDF4_LIBRARIES_TO_EXPORT};${HDF4_MF_XDR_LIBSH_TARGET}") - H4_SET_LIB_OPTIONS (${HDF4_MF_XDR_LIBSH_TARGET} ${HDF4_MF_XDR_LIB_NAME} SHARED) - set_target_properties (${HDF4_MF_XDR_LIBSH_TARGET} PROPERTIES - FOLDER libraries - COMPILE_DEFINITIONS "HDF;H4_BUILT_AS_DYNAMIC_LIB" - INTERFACE_INCLUDE_DIRECTORIES "$/include>" - INTERFACE_COMPILE_DEFINITIONS H4_BUILT_AS_DYNAMIC_LIB=1 - ) - set (install_targets ${install_targets} ${HDF4_MF_XDR_LIBSH_TARGET}) -endif () - -#----------------------------------------------------------------------------- -# Add file(s) to CMake Install -#----------------------------------------------------------------------------- -install ( - FILES - ${HDF4_MFHDF_XDR_SOURCE_DIR}/xdr.h - ${HDF4_MFHDF_XDR_SOURCE_DIR}/types.h - DESTINATION - ${HDF4_INSTALL_INCLUDE_DIR} - COMPONENT - headers -) - -#----------------------------------------------------------------------------- -# Add library to CMake Install : Installs lib and cmake config info -#----------------------------------------------------------------------------- -if (BUILD_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF4_MF_XDR_LIBSH_TARGET} ${HDF4_INSTALL_BIN_DIR} libraries) -endif () -if (NOT ONLY_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF4_MF_XDR_LIB_TARGET} ${HDF4_INSTALL_LIB_DIR} libraries) -endif () - -install ( - TARGETS - ${install_targets} - EXPORT - ${HDF4_EXPORTED_TARGETS} - LIBRARY DESTINATION ${HDF4_INSTALL_LIB_DIR} COMPONENT libraries - ARCHIVE DESTINATION ${HDF4_INSTALL_LIB_DIR} COMPONENT libraries - RUNTIME DESTINATION ${HDF4_INSTALL_BIN_DIR} COMPONENT libraries - FRAMEWORK DESTINATION ${HDF4_INSTALL_FWRK_DIR} COMPONENT libraries - INCLUDES DESTINATION include -) diff --git a/mfhdf/xdr/Makefile.am b/mfhdf/xdr/Makefile.am deleted file mode 100644 index 1d1e52d2e9..0000000000 --- a/mfhdf/xdr/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -## Makefile.am -## Run automake to generate a Makefile.in from this file. -# -# XDR Library Makefile(.in) -# - -include $(top_srcdir)/config/commence.am - -## Setup the different includes and preprocessor #defines we need. -AM_CPPFLAGS=-I$(srcdir) -I$(top_srcdir)/hdf/src - -# XDR Library -lib_LTLIBRARIES = libxdr.la -libxdr_la_SOURCES = xdr.c xdrfloat.c xdrstdio.c xdrarray.c -include_HEADERS = xdr.h types.h - -LDADD = ./libxdr.la - -# Test program. Link using libxdr.la -check_PROGRAMS = xdrtest -TEST_PROG = xdrtest -xdrtest_SOURCES = xdrtest.c - -include $(top_srcdir)/config/conclude.am diff --git a/mfhdf/xdr/byteordr.c b/mfhdf/xdr/byteordr.c deleted file mode 100644 index d9a8a6cc12..0000000000 --- a/mfhdf/xdr/byteordr.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Example: Use the standard library version instead, if you have one. - */ - -/* switch the order of the bytes in a long integer */ -long -ntohl(long i_in) -{ - long i_out; - unsigned char *inptr, *outptr; - - inptr = (unsigned char *)&i_in; - outptr = (unsigned char *)&i_out; - - outptr[3] = inptr[0]; - outptr[2] = inptr[1]; - outptr[1] = inptr[2]; - outptr[0] = inptr[3]; - - return (i_out); -} - -/* switch the order of the bytes in a long integer */ -long -htonl(long i_in) -{ - long i_out; - unsigned char *inptr, *outptr; - - inptr = (unsigned char *)&i_in; - outptr = (unsigned char *)&i_out; - - outptr[3] = inptr[0]; - outptr[2] = inptr[1]; - outptr[1] = inptr[2]; - outptr[0] = inptr[3]; - - return (i_out); -} - -/* switch the order of the bytes in a short integer */ -short -ntohs(short i_in) -{ - short i_out; - unsigned char *inptr, *outptr; - - inptr = (unsigned char *)&i_in; - outptr = (unsigned char *)&i_out; - - outptr[1] = inptr[0]; - outptr[0] = inptr[1]; - - return (i_out); -} - -/* switch the order of the bytes in a short integer */ -short -htons(short i_in) -{ - short i_out; - unsigned char *inptr, *outptr; - - inptr = (unsigned char *)&i_in; - outptr = (unsigned char *)&i_out; - - outptr[1] = inptr[0]; - outptr[0] = inptr[1]; - - return (i_out); -} diff --git a/mfhdf/xdr/test_xdr.sav b/mfhdf/xdr/test_xdr.sav deleted file mode 100644 index 06e8dd0263..0000000000 Binary files a/mfhdf/xdr/test_xdr.sav and /dev/null differ diff --git a/mfhdf/xdr/testout.sav b/mfhdf/xdr/testout.sav deleted file mode 100644 index 474fdf1c2f..0000000000 --- a/mfhdf/xdr/testout.sav +++ /dev/null @@ -1,22 +0,0 @@ -string: Hiya sailor. New in town? -unsigned bytes: 254 255 0 1 2 0 0 0 -ints: 5 6 7 8 9 -unsigned ints: 65535 65534 0 1 2 -LONG: 82555 -longs: -4 -3 -2 -1 0 -unsigned longs: 65535 65534 0 1 2 -floats: - 1.001250e+02 - 1.002500e+02 - 1.003750e+02 - 1.005000e+02 - 1.006250e+02 - -doubles: - 8.388608250000e+06 - 4.194304125000e+06 - 2.097152062500e+06 - 1.048576031250e+06 - 5.242880156250e+05 - -enums: 0 1 2 3 4 diff --git a/mfhdf/xdr/types.h b/mfhdf/xdr/types.h deleted file mode 100644 index a9b03d0ca1..0000000000 --- a/mfhdf/xdr/types.h +++ /dev/null @@ -1,88 +0,0 @@ -/* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)types.h 1.18 87/07/24 SMI - * from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC - * $FreeBSD: src/include/rpc/types.h,v 1.10.6.1 2003/12/18 00:59:50 peter Exp $ - */ -/* - * Rpc additions to - */ -#ifndef H4_XDR_TYPES_H -#define H4_XDR_TYPES_H - -#include "h4config.h" - -#include -#include -#include -#include - -#ifdef H4_HAVE_SYS_TIME_H -#include -#endif - -#ifdef H4_HAVE_SYS_TYPES_H -#include -#endif - -#ifndef u_char -typedef unsigned char u_char; -#endif -#ifndef u_short -typedef uint16_t u_short; -#endif -#ifndef u_int -typedef uint32_t u_int; -#endif -#ifndef u_long -typedef unsigned long u_long; -#endif -#ifndef u_quad_t -typedef uint64_t u_quad_t; -#endif -#ifndef quad_t -typedef int64_t quad_t; -#endif -#ifndef caddr_t -typedef char *caddr_t; -#endif - -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif -typedef int32_t bool_t; - -/* Define the enumerated type in the wire protocol. */ -typedef int32_t enum_t; - -#endif /* H4_XDR_TYPES_H */ diff --git a/mfhdf/xdr/xdr.c b/mfhdf/xdr/xdr.c deleted file mode 100644 index af24f480c4..0000000000 --- a/mfhdf/xdr/xdr.c +++ /dev/null @@ -1,890 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * xdr.c, Generic XDR routines implementation. - * - * Copyright (C) 1986, Sun Microsystems, Inc. - * - * These are the "generic" xdr routines used to serialize and de-serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr.c 1.35 87/08/12"; -#endif - -#include "h4config.h" - -#include -#include - -#include "types.h" -#include "xdr.h" - -typedef quad_t longlong_t; /* ANSI long long type */ -typedef u_quad_t u_longlong_t; /* ANSI unsigned long long type */ - -/* - * constants specific to the xdr "protocol" - */ -#define XDR_FALSE ((long)0) -#define XDR_TRUE ((long)1) -#define LASTUNSIGNED ((u_int)0 - 1) - -/* - * for unit alignment - */ -static const char xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0}; - -/* - * Free a data structure using XDR - * Not a filter, but a convenient utility nonetheless - */ -void -xdr_free(xdrproc_t proc, void *objp) -{ - XDR x; - - x.x_op = XDR_FREE; - (*proc)(&x, objp); -} - -/* - * XDR nothing - */ -bool_t -xdr_void(void) -{ - - return TRUE; -} - -/* - * XDR integers - */ -bool_t -xdr_int(XDR *xdrs, int *ip) -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long)*ip; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *ip = (int)l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned integers - */ -bool_t -xdr_u_int(XDR *xdrs, u_int *up) -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long)*up; - return (XDR_PUTLONG(xdrs, (long *)&l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long *)&l)) { - return (FALSE); - } - *up = (u_int)l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR long integers - */ -bool_t -xdr_long(XDR *xdrs, long *lp) -{ - switch (xdrs->x_op) { - case XDR_ENCODE: - return (XDR_PUTLONG(xdrs, lp)); - case XDR_DECODE: - return (XDR_GETLONG(xdrs, lp)); - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned long integers - */ -bool_t -xdr_u_long(XDR *xdrs, u_long *ulp) -{ - switch (xdrs->x_op) { - case XDR_ENCODE: - return (XDR_PUTLONG(xdrs, (long *)ulp)); - case XDR_DECODE: - return (XDR_GETLONG(xdrs, (long *)ulp)); - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR 32-bit integers - */ -bool_t -xdr_int32_t(XDR *xdrs, int32_t *int32_p) -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long)*int32_p; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *int32_p = (int32_t)l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned 32-bit integers - */ -bool_t -xdr_uint32_t(XDR *xdrs, uint32_t *uint32_p) -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long)*uint32_p; - return (XDR_PUTLONG(xdrs, (long *)&l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long *)&l)) { - return (FALSE); - } - *uint32_p = (uint32_t)l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR short integers - */ -bool_t -xdr_short(XDR *xdrs, short *sp) -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long)*sp; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *sp = (short)l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned short integers - */ -bool_t -xdr_u_short(XDR *xdrs, u_short *usp) -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long)*usp; - return (XDR_PUTLONG(xdrs, (long *)&l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long *)&l)) { - return (FALSE); - } - *usp = (u_short)l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR 16-bit integers - */ -bool_t -xdr_int16_t(XDR *xdrs, int16_t *int16_p) -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long)*int16_p; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *int16_p = (int16_t)l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned 16-bit integers - */ -bool_t -xdr_uint16_t(XDR *xdrs, uint16_t *uint16_p) -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long)*uint16_p; - return (XDR_PUTLONG(xdrs, (long *)&l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long *)&l)) { - return (FALSE); - } - *uint16_p = (uint16_t)l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR 8-bit integers - */ -bool_t -xdr_int8_t(XDR *xdrs, int8_t *int8_p) -{ - long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (long)*int8_p; - return (XDR_PUTLONG(xdrs, &l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *int8_p = (int8_t)l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned 8-bit integers - */ -bool_t -xdr_uint8_t(XDR *xdrs, uint8_t *uint8_p) -{ - u_long l; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - l = (u_long)*uint8_p; - return (XDR_PUTLONG(xdrs, (long *)&l)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long *)&l)) { - return (FALSE); - } - *uint8_p = (uint8_t)l; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR a char - */ -bool_t -xdr_char(XDR *xdrs, char *cp) -{ - int i; - - i = (*cp); - if (!xdr_int(xdrs, &i)) { - return (FALSE); - } - *cp = i; - return (TRUE); -} - -/* - * XDR an unsigned char - */ -bool_t -xdr_u_char(XDR *xdrs, u_char *cp) -{ - u_int u; - - u = (*cp); - if (!xdr_u_int(xdrs, &u)) { - return (FALSE); - } - *cp = u; - return (TRUE); -} - -/* - * XDR booleans - */ -bool_t -xdr_bool(XDR *xdrs, bool_t *bp) -{ - long lb; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - lb = *bp ? XDR_TRUE : XDR_FALSE; - return (XDR_PUTLONG(xdrs, &lb)); - - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &lb)) { - return (FALSE); - } - *bp = (lb == XDR_FALSE) ? FALSE : TRUE; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR enumerations - */ -bool_t -xdr_enum(XDR *xdrs, enum_t *ep) -{ - enum sizecheck { SIZEVAL }; /* used to find the size of an enum */ - - /* - * enums are treated as ints - */ - if (sizeof(enum sizecheck) == sizeof(long)) { - return xdr_long(xdrs, (long *)(void *)ep); - } - else if (sizeof(enum sizecheck) == sizeof(int)) { - return xdr_int(xdrs, (int *)(void *)ep); - } - else if (sizeof(enum sizecheck) == sizeof(short)) { - return xdr_short(xdrs, (short *)(void *)ep); - } - else { - return FALSE; - } -} - -/* - * XDR opaque data - * Allows the specification of a fixed size sequence of opaque bytes. - * cp points to the opaque object and cnt gives the byte length. - */ -bool_t -xdr_opaque(XDR *xdrs, char *cp, u_int cnt) -{ - u_int rndup; - static int crud[BYTES_PER_XDR_UNIT]; - - /* - * if no data we are done - */ - if (cnt == 0) - return (TRUE); - - /* - * round byte count to full xdr units - */ - rndup = cnt % BYTES_PER_XDR_UNIT; - if (rndup > 0) - rndup = BYTES_PER_XDR_UNIT - rndup; - - if (xdrs->x_op == XDR_DECODE) { - if (!XDR_GETBYTES(xdrs, cp, cnt)) { - return (FALSE); - } - if (rndup == 0) - return (TRUE); - return (XDR_GETBYTES(xdrs, (char *)crud, rndup)); - } - - if (xdrs->x_op == XDR_ENCODE) { - if (!XDR_PUTBYTES(xdrs, cp, cnt)) { - return (FALSE); - } - if (rndup == 0) - return (TRUE); - return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); - } - - if (xdrs->x_op == XDR_FREE) { - return (TRUE); - } - - return (FALSE); -} - -/* - * XDR counted bytes - * *cpp is a pointer to the bytes, *sizep is the count. - * If *cpp is NULL maxsize bytes are allocated - */ -bool_t -xdr_bytes(XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize) -{ - char *sp = *cpp; /* sp is the actual string pointer */ - u_int nodesize; - bool_t ret, allocated = FALSE; - - /* - * first deal with the length since xdr bytes are counted - */ - if (!xdr_u_int(xdrs, sizep)) { - return (FALSE); - } - nodesize = *sizep; - if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) { - return (FALSE); - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) { - - case XDR_DECODE: - if (nodesize == 0) { - return (TRUE); - } - if (sp == NULL) { - *cpp = sp = calloc(1, nodesize); - allocated = TRUE; - } - if (sp == NULL) { - fprintf(stderr, "xdr_bytes: out of memory\n"); - return (FALSE); - } - /* FALLTHROUGH */ - - case XDR_ENCODE: - ret = xdr_opaque(xdrs, sp, nodesize); - if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) { - if (allocated == TRUE) { - free(sp); - *cpp = NULL; - } - } - return (ret); - - case XDR_FREE: - if (sp != NULL) { - free(sp); - *cpp = NULL; - } - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * Implemented here due to commonality of the object. - */ -bool_t -xdr_netobj(XDR *xdrs, struct netobj *np) -{ - - return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ)); -} - -/* - * XDR a descriminated union - * Support routine for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * an entry with a null procedure pointer. The routine gets - * the discriminant value and then searches the array of xdrdiscrims - * looking for that value. It calls the procedure given in the xdrdiscrim - * to handle the discriminant. If there is no specific routine a default - * routine may be called. - * If there is no specific or default routine an error is returned. - */ -/* dscmp - enum to decide which arm to work on */ -/* unp - the union itself */ -/* choices - [value, xdr proc] for each arm */ -/* dfault - default xdr routine */ -bool_t -xdr_union(XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choices, xdrproc_t dfault) -{ - enum_t dscm; - - /* - * we deal with the discriminator; it's an enum - */ - if (!xdr_enum(xdrs, dscmp)) { - return (FALSE); - } - dscm = *dscmp; - - /* - * search choices for a value that matches the discriminator. - * if we find one, execute the xdr routine for that value. - */ - for (; choices->proc != NULL_xdrproc_t; choices++) { - if (choices->value == dscm) - return ((*(choices->proc))(xdrs, unp)); - } - - /* - * no match - execute the default xdr routine if there is one - */ - return ((dfault == NULL_xdrproc_t) ? FALSE : (*dfault)(xdrs, unp)); -} - -/* - * Non-portable xdr primitives. - * Care should be taken when moving these routines to new architectures. - */ - -/* - * XDR null terminated ASCII strings - * xdr_string deals with "C strings" - arrays of bytes that are - * terminated by a NULL character. The parameter cpp references a - * pointer to storage; If the pointer is null, then the necessary - * storage is allocated. The last parameter is the max allowed length - * of the string as specified by a protocol. - */ -bool_t -xdr_string(XDR *xdrs, char **cpp, u_int maxsize) -{ - char *sp = *cpp; /* sp is the actual string pointer */ - u_int size; - u_int nodesize; - bool_t ret, allocated = FALSE; - - /* - * first deal with the length since xdr strings are counted-strings - */ - switch (xdrs->x_op) { - case XDR_FREE: - if (sp == NULL) { - return (TRUE); /* already free */ - } - /* FALLTHROUGH */ - case XDR_ENCODE: - if (sp == NULL) - return FALSE; - size = strlen(sp); - break; - case XDR_DECODE: - break; - } - if (!xdr_u_int(xdrs, &size)) { - return (FALSE); - } - if (size > maxsize) { - return (FALSE); - } - nodesize = size + 1; - if (nodesize == 0) { - /* This means an overflow. It a bug in the caller which - * provided a too large maxsize but nevertheless catch it - * here. - */ - return FALSE; - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) { - - case XDR_DECODE: - if (sp == NULL) { - *cpp = sp = calloc(1, nodesize); - allocated = TRUE; - } - if (sp == NULL) { - fprintf(stderr, "xdr_string: out of memory\n"); - return (FALSE); - } - sp[size] = 0; - /* FALLTHROUGH */ - - case XDR_ENCODE: - ret = xdr_opaque(xdrs, sp, size); - if ((xdrs->x_op == XDR_DECODE) && (ret == FALSE)) { - if (allocated == TRUE) { - free(sp); - *cpp = NULL; - } - } - return (ret); - - case XDR_FREE: - free(sp); - *cpp = NULL; - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -#define RPC_MAXDATASIZE 9000 -/* - * Wrapper for xdr_string that can be called directly from - * routines like clnt_call - */ -bool_t -xdr_wrapstring(XDR *xdrs, char **cpp) -{ - return xdr_string(xdrs, cpp, RPC_MAXDATASIZE); -} - -/* - * NOTE: xdr_hyper(), xdr_u_hyper(), xdr_longlong_t(), and xdr_u_longlong_t() - * are in the "non-portable" section because they require that a `long long' - * be a 64-bit type. - * - * --thorpej@netbsd.org, November 30, 1999 - */ - -/* - * XDR 64-bit integers - */ -bool_t -xdr_int64_t(XDR *xdrs, int64_t *llp) -{ - u_long ul[2]; - - switch (xdrs->x_op) { - case XDR_ENCODE: - ul[0] = (u_long)((uint64_t)*llp >> 32) & 0xffffffff; - ul[1] = (u_long)((uint64_t)*llp) & 0xffffffff; - if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - return (XDR_PUTLONG(xdrs, (long *)&ul[1])); - case XDR_DECODE: - if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE) - return (FALSE); - *llp = (int64_t)(((uint64_t)ul[0] << 32) | ((uint64_t)(ul[1]) & 0xffffffff)); - return (TRUE); - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR unsigned 64-bit integers - */ -bool_t -xdr_uint64_t(XDR *xdrs, uint64_t *ullp) -{ - u_long ul[2]; - - switch (xdrs->x_op) { - case XDR_ENCODE: - ul[0] = (u_long)(*ullp >> 32) & 0xffffffff; - ul[1] = (u_long)(*ullp) & 0xffffffff; - if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - return (XDR_PUTLONG(xdrs, (long *)&ul[1])); - case XDR_DECODE: - if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE) - return (FALSE); - *ullp = (uint64_t)(((uint64_t)ul[0] << 32) | ((uint64_t)(ul[1]) & 0xffffffff)); - return (TRUE); - case XDR_FREE: - return (TRUE); - } - /* NOTREACHED */ - return (FALSE); -} - -/* - * XDR hypers - */ -bool_t -xdr_hyper(XDR *xdrs, longlong_t *llp) -{ - /* - * Don't bother open-coding this; it's a fair amount of code. Just - * call xdr_int64_t(). - */ - return (xdr_int64_t(xdrs, (int64_t *)llp)); -} - -/* - * XDR unsigned hypers - */ -bool_t -xdr_u_hyper(XDR *xdrs, u_longlong_t *ullp) -{ - /* - * Don't bother open-coding this; it's a fair amount of code. Just - * call xdr_uint64_t(). - */ - return (xdr_uint64_t(xdrs, (uint64_t *)ullp)); -} - -/* - * XDR longlong_t's - */ -bool_t -xdr_longlong_t(XDR *xdrs, longlong_t *llp) -{ - - /* - * Don't bother open-coding this; it's a fair amount of code. Just - * call xdr_int64_t(). - */ - return (xdr_int64_t(xdrs, (int64_t *)llp)); -} - -/* - * XDR u_longlong_t's - */ -bool_t -xdr_u_longlong_t(XDR *xdrs, u_longlong_t *ullp) -{ - - /* - * Don't bother open-coding this; it's a fair amount of code. Just - * call xdr_uint64_t(). - */ - return (xdr_uint64_t(xdrs, (uint64_t *)ullp)); -} - -/* - * XDR quad_t - */ -bool_t -xdr_quad_t(XDR *xdrs, int64_t *llp) -{ - return (xdr_int64_t(xdrs, (int64_t *)llp)); -} - -/* - * XDR u_quad_t - */ -bool_t -xdr_u_quad_t(XDR *xdrs, uint64_t *ullp) -{ - return (xdr_uint64_t(xdrs, (uint64_t *)ullp)); -} diff --git a/mfhdf/xdr/xdr.h b/mfhdf/xdr/xdr.h deleted file mode 100644 index d7d80b0123..0000000000 --- a/mfhdf/xdr/xdr.h +++ /dev/null @@ -1,326 +0,0 @@ -/* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $ */ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * from: @(#)xdr.h 1.19 87/04/22 SMI - * from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/xdr.h,v 1.23 2003/03/07 13:19:40 nectar Exp $ - */ - -/* - * xdr.h, External Data Representation Serialization Routines. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef H4_XDR_H -#define H4_XDR_H - -#include "H4api_adpt.h" - -#include - -/* - * XDR provides a conventional way for converting between C data - * types and an external bit-string representation. Library supplied - * routines provide for the conversion on built-in C data types. These - * routines and utility routines defined here are used to help implement - * a type encode/decode routine for each user-defined type. - * - * Each data type provides a single procedure which takes two arguments: - * - * bool_t - * xdrproc(xdrs, argresp) - * XDR *xdrs; - * *argresp; - * - * xdrs is an instance of a XDR handle, to which or from which the data - * type is to be converted. argresp is a pointer to the structure to be - * converted. The XDR handle contains an operation field which indicates - * which of the operations (ENCODE, DECODE * or FREE) is to be performed. - * - * XDR_DECODE may allocate space if the pointer argresp is null. This - * data can be freed with the XDR_FREE operation. - * - * We write only one procedure per data type to make it easy - * to keep the encode and decode procedures for a data type consistent. - * In many cases the same code performs all operations on a user defined type, - * because all the hard work is done in the component type routines. - * decode as a series of calls on the nested data types. - */ - -/* - * Xdr operations. XDR_ENCODE causes the type to be encoded into the - * stream. XDR_DECODE causes the type to be extracted from the stream. - * XDR_FREE can be used to release the space allocated by an XDR_DECODE - * request. - */ -enum xdr_op { XDR_ENCODE = 0, XDR_DECODE = 1, XDR_FREE = 2 }; - -/* - * This is the number of bytes per unit of external data. - */ -#define BYTES_PER_XDR_UNIT (4) -#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) * BYTES_PER_XDR_UNIT) - -/* - * The XDR handle. - * Contains operation which is being applied to the stream, - * an operations vector for the particular implementation (e.g. see xdr_mem.c), - * and two private fields for the use of the particular implementation. - */ -typedef struct __rpc_xdr { - enum xdr_op x_op; /* operation; fast additional param */ - struct xdr_ops { - /* Get/put long from underlying stream */ - bool_t (*x_getlong)(struct __rpc_xdr *, long *); - bool_t (*x_putlong)(struct __rpc_xdr *, const long *); - /* Get/put bytes. */ - bool_t (*x_getbytes)(struct __rpc_xdr *, char *, u_int); - bool_t (*x_putbytes)(struct __rpc_xdr *, const char *, u_int); - /* Get or seek within the stream (offsets from beginning of stream). */ - u_int (*x_getpostn)(struct __rpc_xdr *); - bool_t (*x_setpostn)(struct __rpc_xdr *, u_int); - /* Returns a pointer to the next n bytes in the stream. */ - int32_t *(*x_inline)(struct __rpc_xdr *, u_int); - /* Free the stream. */ - void (*x_destroy)(struct __rpc_xdr *); - /* Control */ - bool_t (*x_control)(struct __rpc_xdr *, int, void *); - } * x_ops; - char *x_public; /* users' data */ - void *x_private; /* pointer to private data */ - char *x_base; /* private used for position info */ - u_int x_handy; /* extra private word */ -} XDR; - -/*                                                                                - * A xdrproc_t exists for each data type which is to be encoded or decoded.       - *                                                                                - * The second argument to the xdrproc_t is a pointer to an opaque pointer.        - * The opaque pointer generally points to a structure of the data type            - * to be decoded.  If this pointer is 0, then the type routines should            - * allocate dynamic storage of the appropriate size and return it.                - *                                                                                - * This typedef has caused problems in the past. Most compilers flag the          - * signature as incompatible and this can result in undefined behavior            - * according to the C99 standard.                                                 - *                                                                                - * The current typedef used here works on all tested platforms, but be            - * aware that future compilers could have trouble with it. Failures               - * will most often be raised in xdr_vector calls in xdrtest.c. We've              - * papered over the incompatible pointer warnings with casts for the              - * time being.                                                                    - */ -typedef bool_t (*xdrproc_t)(XDR *, void *, ...); - -/* - * Operations defined on a XDR handle - * - * XDR *xdrs; - * long *longp; - * char * addr; - * u_int len; - * u_int pos; - */ -#define XDR_GETLONG(xdrs, longp) (*(xdrs)->x_ops->x_getlong)(xdrs, longp) -#define xdr_getlong(xdrs, longp) (*(xdrs)->x_ops->x_getlong)(xdrs, longp) - -#define XDR_PUTLONG(xdrs, longp) (*(xdrs)->x_ops->x_putlong)(xdrs, longp) -#define xdr_putlong(xdrs, longp) (*(xdrs)->x_ops->x_putlong)(xdrs, longp) - -static __inline int -xdr_getint32(XDR *xdrs, int32_t *ip) -{ - long l; - - if (!xdr_getlong(xdrs, &l)) - return (FALSE); - *ip = (int32_t)l; - return (TRUE); -} - -static __inline int -xdr_putint32(XDR *xdrs, int32_t *ip) -{ - long l; - - l = (long)*ip; - return xdr_putlong(xdrs, &l); -} - -#define XDR_GETINT32(xdrs, int32p) xdr_getint32(xdrs, int32p) -#define XDR_PUTINT32(xdrs, int32p) xdr_putint32(xdrs, int32p) - -#define XDR_GETBYTES(xdrs, addr, len) (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) -#define xdr_getbytes(xdrs, addr, len) (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) - -#define XDR_PUTBYTES(xdrs, addr, len) (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) -#define xdr_putbytes(xdrs, addr, len) (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) - -#define XDR_GETPOS(xdrs) (*(xdrs)->x_ops->x_getpostn)(xdrs) -#define xdr_getpos(xdrs) (*(xdrs)->x_ops->x_getpostn)(xdrs) - -#define XDR_SETPOS(xdrs, pos) (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) -#define xdr_setpos(xdrs, pos) (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) - -#define XDR_INLINE(xdrs, len) (*(xdrs)->x_ops->x_inline)(xdrs, len) -#define xdr_inline(xdrs, len) (*(xdrs)->x_ops->x_inline)(xdrs, len) - -#define XDR_DESTROY(xdrs) \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs) -#define xdr_destroy(xdrs) \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs) - -/* - * Support struct for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * an entry with a null procedure pointer. The xdr_union routine gets - * the discriminant value and then searches the array of structures - * for a matching value. If a match is found the associated xdr routine - * is called to handle that part of the union. If there is - * no match, then a default routine may be called. - * If there is no match and no default routine it is an error. - */ -#define NULL_xdrproc_t ((xdrproc_t)0) -struct xdr_discrim { - int value; - xdrproc_t proc; -}; - -/* - * In-line routines for fast encode/decode of primitive data types. - * Caveat emptor: these use single memory cycles to get the - * data from the underlying buffer, and will fail to operate - * properly if the data is not aligned. The standard way to use these - * is to say: - * if ((buf = XDR_INLINE(xdrs, count)) == NULL) - * return (FALSE); - * <<< macro calls >>> - * where ``count'' is the number of bytes of data occupied - * by the primitive data types. - * - * N.B. and frozen for all time: each data type here uses 4 bytes - * of external representation. - */ -#define IXDR_GET_INT32(buf) ((int32_t)ntohl((uint32_t) * (buf)++)) -#define IXDR_PUT_INT32(buf, v) (*(buf)++ = (int32_t)htonl((uint32_t)v)) -#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) -#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) - -#define IXDR_GET_LONG(buf) ((long)ntohl((uint32_t) * (buf)++)) -#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (int32_t)htonl((uint32_t)v)) - -#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) -#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) -#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) - -#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), (v)) -#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), (v)) -#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), (v)) -#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) -#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) - -/* - * These are the "generic" xdr routines. - */ -#ifdef __cplusplus -extern "C" { -#endif -XDRLIBAPI bool_t xdr_void(void); -XDRLIBAPI bool_t xdr_int(XDR *, int *); -XDRLIBAPI bool_t xdr_u_int(XDR *, u_int *); -XDRLIBAPI bool_t xdr_long(XDR *, long *); -XDRLIBAPI bool_t xdr_u_long(XDR *, u_long *); -XDRLIBAPI bool_t xdr_short(XDR *, short *); -XDRLIBAPI bool_t xdr_u_short(XDR *, u_short *); -XDRLIBAPI bool_t xdr_int8_t(XDR *, int8_t *); -XDRLIBAPI bool_t xdr_uint8_t(XDR *, uint8_t *); -XDRLIBAPI bool_t xdr_int16_t(XDR *, int16_t *); -XDRLIBAPI bool_t xdr_uint16_t(XDR *, uint16_t *); -XDRLIBAPI bool_t xdr_int32_t(XDR *, int32_t *); -XDRLIBAPI bool_t xdr_uint32_t(XDR *, uint32_t *); -XDRLIBAPI bool_t xdr_int64_t(XDR *, int64_t *); -XDRLIBAPI bool_t xdr_uint64_t(XDR *, uint64_t *); -XDRLIBAPI bool_t xdr_quad_t(XDR *, int64_t *); -XDRLIBAPI bool_t xdr_u_quad_t(XDR *, uint64_t *); -XDRLIBAPI bool_t xdr_bool(XDR *, bool_t *); -XDRLIBAPI bool_t xdr_enum(XDR *, enum_t *); -XDRLIBAPI bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, xdrproc_t); -XDRLIBAPI bool_t xdr_bytes(XDR *, char **, u_int *, u_int); -XDRLIBAPI bool_t xdr_opaque(XDR *, char *, u_int); -XDRLIBAPI bool_t xdr_string(XDR *, char **, u_int); -XDRLIBAPI bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t); -XDRLIBAPI bool_t xdr_char(XDR *, char *); -XDRLIBAPI bool_t xdr_u_char(XDR *, u_char *); -XDRLIBAPI bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); -XDRLIBAPI bool_t xdr_float(XDR *, float *); -XDRLIBAPI bool_t xdr_double(XDR *, double *); -XDRLIBAPI bool_t xdr_quadruple(XDR *, long double *); -XDRLIBAPI bool_t xdr_reference(XDR *, char **, u_int, xdrproc_t); -XDRLIBAPI bool_t xdr_pointer(XDR *, char **, u_int, xdrproc_t); -XDRLIBAPI bool_t xdr_wrapstring(XDR *, char **); -XDRLIBAPI void xdr_free(xdrproc_t, void *); -XDRLIBAPI bool_t xdr_hyper(XDR *, quad_t *); -XDRLIBAPI bool_t xdr_u_hyper(XDR *, u_quad_t *); -XDRLIBAPI bool_t xdr_longlong_t(XDR *, quad_t *); -XDRLIBAPI bool_t xdr_u_longlong_t(XDR *, u_quad_t *); -XDRLIBAPI u_long xdr_sizeof(xdrproc_t, void *); - -/* - * Common opaque bytes objects used by many rpc protocols; - * declared here due to commonality. - */ -#define MAX_NETOBJ_SZ 1024 -struct netobj { - u_int n_len; - char *n_bytes; -}; -typedef struct netobj netobj; -XDRLIBAPI bool_t xdr_netobj(XDR *, struct netobj *); - -/* - * These are the public routines for the various implementations of - * xdr streams. - */ -#ifdef __cplusplus -extern "C" { -#endif - -/* XDR using stdio library */ -XDRLIBAPI void xdrstdio_create(XDR *, FILE *, enum xdr_op); - -#ifdef __cplusplus -} -#endif - -#endif /* H4_XDR_H */ diff --git a/mfhdf/xdr/xdrarray.c b/mfhdf/xdr/xdrarray.c deleted file mode 100644 index b4bc239e43..0000000000 --- a/mfhdf/xdr/xdrarray.c +++ /dev/null @@ -1,149 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * xdr_array.c, Generic XDR routines impelmentation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "non-trivial" xdr primitives used to serialize and de-serialize - * arrays. See xdr.h for more info on the interface to xdr. - */ -#if !defined(lint) && defined(SCCSIDS) -static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro"; -#endif - -#include "h4config.h" - -#include -#include /* for memset() */ -#include /* for UINT_MAX */ - -#include "types.h" -#include "xdr.h" - -#define LASTUNSIGNED ((u_int)0 - 1) - -/* - * XDR an array of arbitrary elements - * *addrp is a pointer to the array, *sizep is the number of elements. - * If addrp is NULL (*sizep * elsize) bytes are allocated. - * elsize is the size (in bytes) of each element, and elproc is the - * xdr procedure to call to handle each element of the array. - */ -/* addrp - array pointer */ -/* sizep - number of elements */ -/* maxsize - max numberof elements */ -/* elsize - size in bytes of each element */ -/* elproc - xdr routine to handle each element */ -bool_t -xdr_array(XDR *xdrs, char **addrp, u_int *sizep, u_int maxsize, u_int elsize, xdrproc_t elproc) -{ - u_int i; - char *target = *addrp; - u_int c; /* the actual element count */ - bool_t stat = TRUE; - u_int nodesize; - - /* like strings, arrays are really counted arrays */ - if (!xdr_u_int(xdrs, sizep)) { - return (FALSE); - } - c = *sizep; - if ((c > maxsize || UINT_MAX / elsize < c) && (xdrs->x_op != XDR_FREE)) { - return (FALSE); - } - nodesize = c * elsize; - - /* - * if we are deserializing, we may need to allocate an array. - * We also save time by checking for a null array if we are freeing. - */ - if (target == NULL) - switch (xdrs->x_op) { - case XDR_ENCODE: - break; /* keep gcc happy */ - case XDR_DECODE: - if (c == 0) - return (TRUE); - *addrp = target = calloc(1, nodesize); - if (target == NULL) { - (void)fprintf(stderr, "xdr_array: out of memory\n"); - return (FALSE); - } - (void)memset(target, 0, nodesize); - break; - - case XDR_FREE: - return (TRUE); - } - - /* - * now we xdr each element of array - */ - for (i = 0; (i < c) && stat; i++) { - stat = (*elproc)(xdrs, target); - target += elsize; - } - - /* - * the array may need freeing - */ - if (xdrs->x_op == XDR_FREE) { - free(*addrp); - *addrp = NULL; - } - return (stat); -} - -/* - * xdr_vector(): - * - * XDR a fixed length array. Unlike variable-length arrays, - * the storage of fixed length arrays is static and unfreeable. - * > basep: base of the array - * > size: size of the array - * > elemsize: size of each element - * > xdr_elem: routine to XDR each element - */ -bool_t -xdr_vector(XDR *xdrs, char *basep, u_int nelem, u_int elemsize, xdrproc_t xdr_elem) -{ - u_int i; - char *elptr; - - elptr = basep; - for (i = 0; i < nelem; i++) { - if (!(*xdr_elem)(xdrs, elptr)) { - return (FALSE); - } - elptr += elemsize; - } - return (TRUE); -} diff --git a/mfhdf/xdr/xdrfloat.c b/mfhdf/xdr/xdrfloat.c deleted file mode 100644 index 80d57b7b3f..0000000000 --- a/mfhdf/xdr/xdrfloat.c +++ /dev/null @@ -1,111 +0,0 @@ - -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * xdr_float.c, Generic XDR routines implementation. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * These are the "floating point" xdr routines used to (de)serialize - * most common data items. See xdr.h for more info on the interface to - * xdr. - */ - -#include "h4config.h" - -#include - -#include "types.h" -#include "xdr.h" - -bool_t -xdr_float(XDR *xdrs, float *fp) -{ - switch (xdrs->x_op) { - - case XDR_ENCODE: - return (XDR_PUTINT32(xdrs, (int32_t *)fp)); - - case XDR_DECODE: - return (XDR_GETINT32(xdrs, (int32_t *)fp)); - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -bool_t -xdr_double(XDR *xdrs, double *dp) -{ - int32_t *i32p; - bool_t rv; - - if (!dp) - return FALSE; - - switch (xdrs->x_op) { - case XDR_ENCODE: - i32p = (int32_t *)(void *)dp; -#ifdef H4_WORDS_BIGENDIAN - rv = XDR_PUTINT32(xdrs, i32p); - if (!rv) - return (rv); - rv = XDR_PUTINT32(xdrs, i32p + 1); -#else - rv = XDR_PUTINT32(xdrs, i32p + 1); - if (!rv) - return (rv); - rv = XDR_PUTINT32(xdrs, i32p); -#endif - return rv; - break; - - case XDR_DECODE: - i32p = (int32_t *)(void *)dp; -#ifdef H4_WORDS_BIGENDIAN - rv = XDR_GETINT32(xdrs, i32p); - if (!rv) - return (rv); - rv = XDR_GETINT32(xdrs, i32p + 1); -#else - rv = XDR_GETINT32(xdrs, i32p + 1); - if (!rv) - return (rv); - rv = XDR_GETINT32(xdrs, i32p); -#endif - return (rv); - break; - - case XDR_FREE: - return TRUE; - } /* switch xdrs->x_op */ - - return FALSE; -} diff --git a/mfhdf/xdr/xdrstdio.c b/mfhdf/xdr/xdrstdio.c deleted file mode 100644 index ae91ba9788..0000000000 --- a/mfhdf/xdr/xdrstdio.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2009, Sun Microsystems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of Sun Microsystems, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * xdr_stdio.c, XDR implementation on standard i/o file. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * This set of routines implements a XDR on a stdio stream. - * XDR_ENCODE serializes onto the stream, XDR_DECODE de-serializes - * from the stream. - */ -#include "h4config.h" - -#include - -#ifdef H4_HAVE_ARPA_INET_H -#include -#endif - -#ifdef H4_HAVE_NETINET_IN_H -#include /* for htonl() */ -#else -#ifdef H4_HAVE_WINSOCK2_H -#include -#endif -#endif - -#include "types.h" -#include "xdr.h" - -static void xdrstdio_destroy(XDR *); -static bool_t xdrstdio_getlong(XDR *, long *); -static bool_t xdrstdio_putlong(XDR *, const long *); -static bool_t xdrstdio_getbytes(XDR *, char *, u_int); -static bool_t xdrstdio_putbytes(XDR *, const char *, u_int); -static u_int xdrstdio_getpos(XDR *); -static bool_t xdrstdio_setpos(XDR *, u_int); -static int32_t *xdrstdio_inline(XDR *, u_int); - -/* - * Ops vector for stdio type XDR - */ -static const struct xdr_ops xdrstdio_ops = { - xdrstdio_getlong, /* deseraialize a long int */ - xdrstdio_putlong, /* seraialize a long int */ - xdrstdio_getbytes, /* deserialize counted bytes */ - xdrstdio_putbytes, /* serialize counted bytes */ - xdrstdio_getpos, /* get offset in the stream */ - xdrstdio_setpos, /* set offset in the stream */ - xdrstdio_inline, /* prime stream for inline macros */ - xdrstdio_destroy, /* destroy stream */ - NULL /* control */ -}; - -/* - * Initialize a stdio xdr stream. - * Sets the xdr stream handle xdrs for use on the stream file. - * Operation flag is set to op. - */ -void -xdrstdio_create(XDR *xdrs, FILE *file, enum xdr_op op) -{ - xdrs->x_op = op; - xdrs->x_ops = &xdrstdio_ops; - xdrs->x_private = file; - xdrs->x_handy = 0; - xdrs->x_base = 0; -} - -/* - * Destroy a stdio xdr stream. - * Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create. - */ -static void -xdrstdio_destroy(XDR *xdrs) -{ - (void)fflush((FILE *)xdrs->x_private); - /* xx should we close the file ?? */ -} - -static bool_t -xdrstdio_getlong(XDR *xdrs, long *lp) -{ - int32_t mycopy; - - if (fread(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1) - return (FALSE); - - *lp = (long)ntohl(mycopy); - return (TRUE); -} - -static bool_t -xdrstdio_putlong(XDR *xdrs, const long *lp) -{ - int32_t mycopy; - - if ((*lp > INT32_MAX) || (*lp < INT32_MIN)) - return FALSE; - - mycopy = (int32_t)htonl((int32_t)*lp); - if (fwrite(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1) - return FALSE; - return TRUE; -} - -static bool_t -xdrstdio_getbytes(XDR *xdrs, char *addr, u_int len) -{ - - if ((len != 0) && (fread(addr, (size_t)len, 1, (FILE *)xdrs->x_private) != 1)) - return (FALSE); - return (TRUE); -} - -static bool_t -xdrstdio_putbytes(XDR *xdrs, const char *addr, u_int len) -{ - - if ((len != 0) && (fwrite(addr, (size_t)len, 1, (FILE *)xdrs->x_private) != 1)) - return (FALSE); - return (TRUE); -} - -static u_int -xdrstdio_getpos(XDR *xdrs) -{ - - return ((u_int)ftell((FILE *)xdrs->x_private)); -} - -static bool_t -xdrstdio_setpos(XDR *xdrs, u_int pos) -{ - - return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ? FALSE : TRUE); -} - -static int32_t * -xdrstdio_inline(XDR *xdrs, u_int len) -{ - (void)xdrs; - (void)len; - /* - * Must do some work to implement this: must insure - * enough data in the underlying stdio buffer, - * that the buffer is aligned so that we can indirect through a - * long *, and stuff this pointer in xdrs->x_buf. Doing - * a fread or fwrite to a scratch buffer would defeat - * most of the gains to be had here and require storage - * management on this buffer, so we don't do this. - */ - return (NULL); -} diff --git a/mfhdf/xdr/xdrtest.c b/mfhdf/xdr/xdrtest.c deleted file mode 100644 index b707b4f0e0..0000000000 --- a/mfhdf/xdr/xdrtest.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright 1988, University Corporation for Atmospheric Research - * Not for Resale. All copies to include this notice. - */ - -#include "h4config.h" - -/* - * This program tests only the xdr library functionality required by netCDF. - * 'xdr_vector' is not used by the netCDF, it is used here for convenience. - */ - -#ifdef H4_HAVE_NETINET_IN_H -#include /* for htonl() */ -#else -#ifdef H4_HAVE_WINSOCK2_H -#include -#endif -#endif - -#define xdr_assert(ex) \ - { \ - if (!(ex)) { \ - (void)fprintf(stderr, "Assertion failed: file \"%s\", line %d\n", __FILE__, __LINE__); \ - } \ - } - -#ifndef H4_NO_SYS_XDR_INC -#include -#include -#else -#include "types.h" -#include "xdr.h" -#endif - -#define TESTFILE "test.xdr" -/* if this is NOT defined, then the program just reads the file */ -#define CREATE - -#ifdef __FreeBSD__ -#define EPSILON .005 -#else /* __FreeBSD__ */ -#define EPSILON .0005 -#endif /* __FreeBSD__ */ - -int -main(int ac, char *av[]) -{ - int ii; - const char *fname; - FILE *F; - XDR xdrs[1]; - size_t count; - u_int szof; - - /* some random numbers, divisible by 4 and less than 32k */ - static u_int seeks[] = { - 16828, - 8448, - 20632, - 8124, - 16764, - 17232, - 3476, - 28168, /* +(5 * sizeof(double) + (5 * sizeof(enum) */ - /* */ - 28108, - 16796, - 10968, - 24104, - 30560, - 16880, - 17260, - 12556, - }; - - u_int poses[9]; - int jj = 0; - - static char text[32] = {"Hiya sailor. New in town?"}; - char got_s[32]; - - static unsigned char bytes[8] = {254, 255, 0, 1, 2}; - unsigned char *bp, got_ab[8]; - - static int ints[5] = {5, 6, 7, 8, 9}; - int *ip, got_ip[5]; - - static unsigned int u_ints[5] = {((unsigned)65535), ((unsigned)65534), ((unsigned)0), ((unsigned)1), - ((unsigned)2)}; - unsigned int *uip, got_uip[5]; - - long lnum = 82555; - - static long longs[5] = {-4, -3, -2, -1, 0}; - long *lp, got_al[5]; - - static unsigned long u_longs[5] = {((unsigned)65535), ((unsigned)65534), ((unsigned)0), ((unsigned)1), - ((unsigned)2)}; - unsigned long *ulp, got_aul[5]; - - static float floats[5] = {100.125, 100.25, 100.375, 100.5, 100.625}; - float *fp, got_af[5]; - - /* These all require 25 bits: 2^(25-i)+1/2^i, i = 2, 3, ..., 6 */ - static double doubles[5] = {8388608.25, 4194304.125, 2097152.0625, 1048576.03125, 524288.015625}; - - double *dp, got_ad[5]; - - typedef enum { ZERO_E, ONE_E, TWO_E, THREE_E, FOUR_E } encount; - static encount encounts[5] = {ZERO_E, ONE_E, TWO_E, THREE_E, FOUR_E}; - encount *ep, got_ep[5]; - - fname = TESTFILE; - if (ac > 1) { - fname = av[1]; - } -#ifdef CREATE - /* Create */ - - F = fopen(fname, "wb"); - if (F == NULL) { - perror("fopen failed"); - exit(EXIT_FAILURE); - } - - /* fill the file so seeks will work even on non-virtual machines */ - for (ii = 0; ii < 28227; ii++) { - xdr_assert(putc(0, F) != EOF); - } - - xdrstdio_create(xdrs, F, XDR_ENCODE); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - xdr_assert(xdr_opaque(xdrs, text, sizeof(text))); - poses[jj++] = xdr_getpos(xdrs); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - xdr_assert(xdr_opaque(xdrs, (char *)bytes, sizeof(bytes))); - - /* no setpos, just for variety */ - szof = sizeof(int); - count = sizeof(ints) / sizeof(int); - xdr_assert(xdr_vector(xdrs, (char *)ints, count, szof, (xdrproc_t)xdr_int)); - poses[jj++] = xdr_getpos(xdrs); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - szof = sizeof(unsigned int); - count = sizeof(u_ints) / sizeof(unsigned int); - xdr_assert(xdr_vector(xdrs, (char *)u_ints, count, szof, (xdrproc_t)xdr_u_int)); - poses[jj++] = xdr_getpos(xdrs); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - xdr_assert(xdr_long(xdrs, &lnum)); - poses[jj++] = xdr_getpos(xdrs); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - szof = sizeof(long); - count = sizeof(longs) / sizeof(long); - xdr_assert(xdr_vector(xdrs, (char *)longs, count, szof, (xdrproc_t)xdr_long)); - poses[jj++] = xdr_getpos(xdrs); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - szof = sizeof(unsigned long); - count = sizeof(u_longs) / sizeof(unsigned long); - xdr_assert(xdr_vector(xdrs, (char *)u_longs, count, szof, (xdrproc_t)xdr_u_long)); - poses[jj++] = xdr_getpos(xdrs); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - szof = sizeof(float); - count = sizeof(floats) / sizeof(float); - xdr_assert(xdr_vector(xdrs, (char *)floats, count, szof, (xdrproc_t)xdr_float)); - poses[jj++] = xdr_getpos(xdrs); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - szof = sizeof(double); - count = sizeof(doubles) / sizeof(double); - xdr_assert(xdr_vector(xdrs, (char *)doubles, count, szof, (xdrproc_t)xdr_double)); - poses[jj++] = xdr_getpos(xdrs); - - /* again no setpos */ - szof = sizeof(encount); - count = sizeof(encounts) / sizeof(encount); - xdr_assert(xdr_vector(xdrs, (char *)encounts, count, szof, (xdrproc_t)xdr_enum)); - poses[jj++] = xdr_getpos(xdrs); - - /* flush, rewind and reopen */ - - xdr_assert(fflush((FILE *)xdrs->x_private) != EOF); /* xdr_destroy(xdrs) */ - - xdr_assert(fclose(F) != EOF); -#endif /* CREATE */ - F = fopen(fname, "rb"); - if (F == NULL) { - perror("fopen failed"); - exit(-1); - } - xdrstdio_create(xdrs, F, XDR_DECODE); - - jj = 0; - - /* check contents */ - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - xdr_assert(xdr_opaque(xdrs, got_s, sizeof(text))); - xdr_assert(poses[jj++] = xdr_getpos(xdrs)); - printf("string: %s\n", got_s); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - xdr_assert(xdr_opaque(xdrs, (char *)got_ab, sizeof(bytes))); - printf("unsigned bytes: "); - for (ii = 0, bp = got_ab; ii < (int)sizeof(bytes); ii++, bp++) { - printf("%u ", *bp); - xdr_assert(*bp == bytes[ii]); - } - putchar('\n'); - - szof = sizeof(int); - count = sizeof(ints) / sizeof(int); - xdr_assert(xdr_vector(xdrs, (char *)got_ip, count, szof, (xdrproc_t)xdr_int)); - xdr_assert(poses[jj++] = xdr_getpos(xdrs)); - printf("ints: "); - for (ii = 0, ip = got_ip; ii < (int)count; ii++, ip++) { - printf("%d ", *ip); - xdr_assert(*ip == ints[ii]); - } - putchar('\n'); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - szof = sizeof(unsigned int); - count = sizeof(u_ints) / sizeof(unsigned int); - xdr_assert(xdr_vector(xdrs, (char *)got_uip, count, szof, (xdrproc_t)xdr_u_int)); - xdr_assert(poses[jj++] = xdr_getpos(xdrs)); - printf("unsigned ints: "); - for (ii = 0, uip = got_uip; ii < (int)count; ii++, uip++) { - printf("%u ", *uip); - xdr_assert(*uip == u_ints[ii]); - } - putchar('\n'); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - xdr_assert(xdr_long(xdrs, got_al)); - xdr_assert(poses[jj++] = xdr_getpos(xdrs)); - printf("LONG: %ld\n", *got_al); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - szof = sizeof(long); - count = sizeof(longs) / sizeof(long); - xdr_assert(xdr_vector(xdrs, (char *)got_al, count, szof, (xdrproc_t)xdr_long)); - xdr_assert(poses[jj++] = xdr_getpos(xdrs)); - printf("longs: "); - for (ii = 0, lp = got_al; ii < (int)count; ii++, lp++) { - printf("%d ", (int)*lp); - xdr_assert((int)*lp == (int)longs[ii]); - } - putchar('\n'); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - szof = sizeof(unsigned long); - count = sizeof(u_longs) / sizeof(unsigned long); - xdr_assert(xdr_vector(xdrs, (char *)got_aul, count, szof, (xdrproc_t)xdr_u_long)); - xdr_assert(poses[jj++] = xdr_getpos(xdrs)); - printf("unsigned longs: "); - for (ii = 0, ulp = got_aul; ii < (int)count; ii++, ulp++) { - printf("%lu ", *ulp); - xdr_assert(*ulp == u_longs[ii]); - } - putchar('\n'); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - szof = sizeof(float); - count = sizeof(floats) / sizeof(float); - xdr_assert(xdr_vector(xdrs, (char *)got_af, count, szof, (xdrproc_t)xdr_float)); - xdr_assert(poses[jj++] = xdr_getpos(xdrs)); - printf("floats:\n"); - for (ii = 0, fp = got_af; ii < (int)count; ii++, fp++) { - printf("\t% .6e\n", *fp); - xdr_assert(*fp floats[ii] - EPSILON); - } - putchar('\n'); - - xdr_assert(xdr_setpos(xdrs, seeks[jj])); - szof = sizeof(double); - count = sizeof(doubles) / sizeof(double); - xdr_assert(xdr_vector(xdrs, (char *)got_ad, count, szof, (xdrproc_t)xdr_double)); - xdr_assert(poses[jj++] = xdr_getpos(xdrs)); - printf("doubles:\n"); - for (ii = 0, dp = got_ad; ii < (int)count; ii++, dp++) { - printf("\t% .12e\n", *dp); - xdr_assert((*dp < (doubles[ii] + (double)EPSILON)) && (*dp > (doubles[ii] - (double)EPSILON))); - } - putchar('\n'); - - szof = sizeof(encount); - count = sizeof(encounts) / sizeof(encount); - xdr_assert(xdr_vector(xdrs, (char *)got_ep, count, szof, (xdrproc_t)xdr_enum)); - printf("enums: "); - for (ii = 0, ep = got_ep; ii < (int)count; ii++, ep++) { - printf("%d ", (int)*ep); - xdr_assert(*ep == encounts[ii]); - } - putchar('\n'); - xdr_assert(poses[jj++] = xdr_getpos(xdrs)); - - exit(EXIT_SUCCESS); -} diff --git a/mfhdf/xdr/xdrtest.cyg b/mfhdf/xdr/xdrtest.cyg deleted file mode 100644 index 474fdf1c2f..0000000000 --- a/mfhdf/xdr/xdrtest.cyg +++ /dev/null @@ -1,22 +0,0 @@ -string: Hiya sailor. New in town? -unsigned bytes: 254 255 0 1 2 0 0 0 -ints: 5 6 7 8 9 -unsigned ints: 65535 65534 0 1 2 -LONG: 82555 -longs: -4 -3 -2 -1 0 -unsigned longs: 65535 65534 0 1 2 -floats: - 1.001250e+02 - 1.002500e+02 - 1.003750e+02 - 1.005000e+02 - 1.006250e+02 - -doubles: - 8.388608250000e+06 - 4.194304125000e+06 - 2.097152062500e+06 - 1.048576031250e+06 - 5.242880156250e+05 - -enums: 0 1 2 3 4 diff --git a/mfhdf/xdr/xdrtest.opt b/mfhdf/xdr/xdrtest.opt deleted file mode 100644 index d2ce3564ed..0000000000 --- a/mfhdf/xdr/xdrtest.opt +++ /dev/null @@ -1 +0,0 @@ -sys$library:vaxcrtl.exe/share diff --git a/mfhdf/xdr/xdrtest.out b/mfhdf/xdr/xdrtest.out deleted file mode 100644 index 66555283cf..0000000000 --- a/mfhdf/xdr/xdrtest.out +++ /dev/null @@ -1,22 +0,0 @@ -string: Hiya sailor. New in town? -unsigned bytes: 254 255 0 1 2 0 0 0 -ints: 5 6 7 8 9 -unsigned ints: 65535 65534 0 1 2 -LONG: 82555 -longs: -4 -3 -2 -1 0 -unsigned longs: 65535 65534 0 1 2 -floats: - 1.001250e+002 - 1.002500e+002 - 1.003750e+002 - 1.005000e+002 - 1.006250e+002 - -doubles: - 8.388608250000e+006 - 4.194304125000e+006 - 2.097152062500e+006 - 1.048576031250e+006 - 5.242880156250e+005 - -enums: 0 1 2 3 4 diff --git a/release_notes/INSTALL b/release_notes/INSTALL index 787a892d57..f31bd68541 100644 --- a/release_notes/INSTALL +++ b/release_notes/INSTALL @@ -87,18 +87,9 @@ To Configure: 4) Use the configure command in the top level HDF4 directory hdf-X.Y.Z: - Note: On macOS platforms version 10.13 or newer, XDR functions from the - system libraries do not work with HDF4. It is therefore necessary - to build the internal HDF4 XDR library, using --enable-hdf4-xdr for - autotools configure, or adding the corresponding CMake option: - set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF4_BUILD_XDR_LIB:BOOL=ON") - to HDF4options.cmake. The options may also be used but are not required - on Linux platforms. - ./configure --with-zlib=/path_to_ZLIB_install_directory --with-jpeg=/path_to_JPEG_install_directory [--with-szlib=/path_to_SZIP_install_directory] - [--enable-hdf4-xdr] --prefix=/path_to_HDF4_install_directory * Please note that when the szlib option is not used, the Szip diff --git a/release_notes/INSTALL_CMake.txt b/release_notes/INSTALL_CMake.txt index d49b77e764..f5426a7020 100644 --- a/release_notes/INSTALL_CMake.txt +++ b/release_notes/INSTALL_CMake.txt @@ -687,9 +687,6 @@ HDF4_BUILD_EXAMPLES "Build HDF4 Library Examples" OFF HDF4_BUILD_FORTRAN "Build FORTRAN support" OFF HDF4_BUILD_TOOLS "Build HDF4 Tools" ON HDF4_BUILD_UTILS "Build HDF4 Utilities" OFF -HDF4_BUILD_XDR_LIB "Build HDF4 XDR Library" OFF -if (WIN32 OR MINGW OR APPLE) - HDF4_BUILD_XDR_LIB "Build HDF4 XDR Library" ON HDF4_ENABLE_NETCDF "Build HDF4 versions of NetCDF-3 APIS" ON HDF4_BUILD_JAVA "Build Java HDF Library" OFF HDF4_BUILD_NETCDF_TOOLS "Build HDF4 versions of ncdump and ncgen" ON diff --git a/release_notes/INSTALL_CYGWIN.txt b/release_notes/INSTALL_CYGWIN.txt index c009631e5b..aa3ba720d1 100644 --- a/release_notes/INSTALL_CYGWIN.txt +++ b/release_notes/INSTALL_CYGWIN.txt @@ -61,15 +61,6 @@ Preconditions: tirpc : RPC library zlib : Zlib compression library - Back in 2005, the SunRPC of the glibc has been replaced by a TI-RPC - (Transport Independent RPC) library to support IPv6. Note that HDF4 configure - expects to find the library with the name libtirpc.a, since Cygwin 1.7.7. - - HDF4 also requires xdr support which is not provided by the Cygwin - version of tirpc. HDF4 provides a library for xdr support when the - configure flag --enable-hdf4-xdr is specified (see note 3 in the section - "Build, Test and Install HDF4 on Cygwin"). - HDF4 may be configured to use the SZIP compression library. For more information about the SZIP library, see @@ -114,7 +105,6 @@ Build, Test and Install HDF4 on Cygwin 3. To configure ./configure <--disable-fortran> - --enable-hdf4-xdr --with-zlib=/path_to_ZLIB_install_directory --with-jpeg=/path_to_JPEG_install_directory <--with-szlib=/path_to_SZIP_install_directory> diff --git a/release_notes/RELEASE.txt b/release_notes/RELEASE.txt index f609e74326..be039771aa 100644 --- a/release_notes/RELEASE.txt +++ b/release_notes/RELEASE.txt @@ -38,6 +38,24 @@ New features and changes ======================== Configuration: ------------- + - XDR changes + + We now only support building HDF4 with the XDR implementation packaged + with the HDF4 source, which is always built with the mfhdf library. + + The following options have been removed: + + Autotools: --enable-hdf4-xdr + CMake: HDF4_BUILD_XDR_LIB + + The following header files are no longer deployed: + + types.h, xdr.h + + The XDR functionality has been incorporated into the mfhdf library, + so a separate XDR library is no longer distributed with either build + system. + - Man pages were removed The few man pages in the HDF4 library are woefully incomplete and/or