diff --git a/CMakeLists.txt b/CMakeLists.txt index b4c6fef84..9ac9330af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -955,9 +955,7 @@ IF(ENABLE_LARGE_FILE_SUPPORT) SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE") SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LARGEADDRESSAWARE") ELSE() - SET(_FILE_OFFSET_BITS 64) - SET(_LARGEFILE64_SOURCE TRUE) - SET(_LARGEFILE_SOURCE TRUE) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64") ENDIF() ENDIF() @@ -1234,6 +1232,8 @@ CHECK_INCLUDE_FILE("BaseTsd.h" HAVE_BASETSD_H) CHECK_INCLUDE_FILE("stddef.h" HAVE_STDDEF_H) CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H) CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H) +CHECK_INCLUDE_FILE("winsock2.h" HAVE_WINSOCK2_H) +CHECK_INCLUDE_FILE("ftw.h" HAVE_FTW_H) CHECK_INCLUDE_FILES("time.h;sys/time.h" TIME_WITH_SYS_TIME) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 982aa4cfb..57c0ca3ae 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,8 +7,9 @@ This file contains a high-level description of this package's evolution. Release ## 4.5.0 - TBD -### 4.5.0-rc2 - TBD +### 4.5.0-rc2 - August 7, 2017 +* [Bug Fix] Addressed an issue with how cmake was implementing large file support on 32-bit systems. See [GitHub #385](https://github.com/Unidata/netcdf-c/issues/385) for more information. * [Bug Fix] Addressed an issue where ncgen would not respect keyword case. See [GitHub #310](https://github.com/Unidata/netcdf-c/issues/310) for more information. ### 4.5.0-rc1 - June 5, 2017 diff --git a/cf b/cf index 6e66f166e..40ab555bf 100644 --- a/cf +++ b/cf @@ -111,7 +111,6 @@ FLAGS="$FLAGS --enable-logging" #FLAGS="$FLAGS --enable-jna" #FLAGS="$FLAGS --disable-properties-attribute" #FLAGS="$FLAGS --disable-silent-rules" -#FLAGS="$FLAGS --enable-dap4" #FLAGS="$FLAGS --with-testservers=remotestserver.localhost:8083" if test "x$PAR4" != x1 ; then diff --git a/cf.cmake b/cf.cmake index 8820e0eb3..f0625b5b7 100644 --- a/cf.cmake +++ b/cf.cmake @@ -1,5 +1,14 @@ # Visual Studio VS=1 +#VSSETUP=1 + +#export NCPATHDEBUG=1 + +if test "x$VSSETUP" = x1 ; then +CFG="Debug" +else +CFG="Release" +fi # Is netcdf-4 and/or DAP enabled? NC4=1 @@ -33,13 +42,13 @@ NCLIB=`pwd` if test "x$VS" != x ; then # Visual Studio -#CFG="RelWithDebInfo" -CFG="Release" NCLIB="${NCLIB}/build/liblib/$CFG" export PATH="${NCLIB}:${PATH}" cmake $FLAGS .. +if test "x$VSSETUP" = x ; then cmake --build . --config ${CFG} cmake --build . --config ${CFG} --target RUN_TESTS +fi else # GCC NCLIB="${NCLIB}/build/liblib" diff --git a/config.h.cmake.in b/config.h.cmake.in index 0db40ccd2..df6263155 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -13,7 +13,12 @@ * https://stackoverflow.com/questions/1372480/c-redefinition-header-files-winsock2-h */ + +#cmakedefine HAVE_WINSOCK2_H + +#ifdef HAVE_WINSOCK2_H #define _WINSOCKAPI_ +#endif #if _MSC_VER>=1900 #define STDC99 @@ -358,6 +363,9 @@ are set when opening a binary file on Windows. */ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STRING_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FTW_H 1 + /* Define to 1 if you have the `strlcat' function. */ #cmakedefine HAVE_STRLCAT 1 diff --git a/configure.ac b/configure.ac index c953dc4ec..9c581c046 100644 --- a/configure.ac +++ b/configure.ac @@ -790,6 +790,9 @@ AC_CHECK_HEADERS([sys/resource.h]) # Check for that conforms to C99 requirements AC_HEADER_STDBOOL +# See if we have ftw.h to walk directory trees +AC_CHECK_HEADERS([ftw.h]) + # Check for these functions... AC_CHECK_FUNCS([strlcat strerror snprintf strchr strrchr strcat strcpy \ strdup strcasecmp strtod strtoll strtoull strstr \ @@ -804,11 +807,10 @@ AC_ARG_ENABLE([diskless], test "x$enable_diskless" = xno || enable_diskless=yes AC_MSG_RESULT($enable_diskless) -# Check for enable DAP -if test "x$enable_dap" = "xyes" -a "xenable_diskless" = xno ; then -AC_MSG_NOTICE([--enable-dap requires --enable-diskless]) -AC_MSG_NOTICE([dap support disabled]) -enable_dap=no +# If DAP enabled and diskless not enabled, then warn of consequences +if test "x$enable_dap" = "xyes" -a "x$enable_diskless" = xno ; then +AC_MSG_NOTICE([Warning: DAP support is enabled but diskless support is disabled.]) +AC_MSG_NOTICE([=> temporary files will be created + reclaimed when using DAP.]) fi # disable dap4 if netcdf-4 is disabled diff --git a/dap4_test/CMakeLists.txt b/dap4_test/CMakeLists.txt index d748677e0..1b8e3a92b 100644 --- a/dap4_test/CMakeLists.txt +++ b/dap4_test/CMakeLists.txt @@ -2,7 +2,6 @@ SET(abs_top_srcdir ${CMAKE_CURRENT_SOURCE_DIR}) remove_definitions(-DDLL_EXPORT) - ADD_SUBDIRECTORY(baseline) ADD_SUBDIRECTORY(baselineraw) ADD_SUBDIRECTORY(baselineremote) diff --git a/dap4_test/baseline/CMakeLists.txt b/dap4_test/baseline/CMakeLists.txt index d46021ec0..2332d8f85 100644 --- a/dap4_test/baseline/CMakeLists.txt +++ b/dap4_test/baseline/CMakeLists.txt @@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) -SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am) +SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt) ADD_EXTRA_DIST("${CUR_EXTRA_DIST}") diff --git a/dap4_test/baseline/test_struct1.nc.d4d b/dap4_test/baseline/test_struct1.nc.d4d index 04629a051..e246bc9f0 100644 --- a/dap4_test/baseline/test_struct1.nc.d4d +++ b/dap4_test/baseline/test_struct1.nc.d4d @@ -6,7 +6,6 @@ types: }; // s_t variables: s_t s ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baseline/test_struct1.nc.d4m b/dap4_test/baseline/test_struct1.nc.d4m index bbc583409..c75622af9 100644 --- a/dap4_test/baseline/test_struct1.nc.d4m +++ b/dap4_test/baseline/test_struct1.nc.d4m @@ -6,7 +6,6 @@ types: }; // s_t variables: s_t s ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baseline/test_struct1.nc.d4p b/dap4_test/baseline/test_struct1.nc.d4p index 6d366ba0e..d4dd74441 100644 --- a/dap4_test/baseline/test_struct1.nc.d4p +++ b/dap4_test/baseline/test_struct1.nc.d4p @@ -11,10 +11,7 @@ - - - - + diff --git a/dap4_test/baseline/test_struct_array.6.nc.d4d b/dap4_test/baseline/test_struct_array.6.nc.d4d index 3eb90c35e..c5b3e6fe7 100644 --- a/dap4_test/baseline/test_struct_array.6.nc.d4d +++ b/dap4_test/baseline/test_struct_array.6.nc.d4d @@ -8,7 +8,6 @@ dimensions: _Anonymous2 = 2 ; variables: s_t s(_Anonymous2, _Anonymous2) ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: string :_dap4.ce = "/s[0:2:3][0:1]" ; diff --git a/dap4_test/baseline/test_struct_array.6.nc.d4m b/dap4_test/baseline/test_struct_array.6.nc.d4m index a8e60a07b..09940fad0 100644 --- a/dap4_test/baseline/test_struct_array.6.nc.d4m +++ b/dap4_test/baseline/test_struct_array.6.nc.d4m @@ -8,7 +8,6 @@ dimensions: _Anonymous2 = 2 ; variables: s_t s(_Anonymous2, _Anonymous2) ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: string :_dap4.ce = "/s[0:2:3][0:1]" ; diff --git a/dap4_test/baseline/test_struct_array.6.nc.d4p b/dap4_test/baseline/test_struct_array.6.nc.d4p index e73b6e0fa..6c695a172 100644 --- a/dap4_test/baseline/test_struct_array.6.nc.d4p +++ b/dap4_test/baseline/test_struct_array.6.nc.d4p @@ -17,8 +17,6 @@ - - diff --git a/dap4_test/baseline/test_struct_array.nc.d4d b/dap4_test/baseline/test_struct_array.nc.d4d index dd8c2f2d2..68fded454 100644 --- a/dap4_test/baseline/test_struct_array.nc.d4d +++ b/dap4_test/baseline/test_struct_array.nc.d4d @@ -9,7 +9,6 @@ dimensions: dy = 3 ; variables: s_t s(dx, dy) ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baseline/test_struct_array.nc.d4m b/dap4_test/baseline/test_struct_array.nc.d4m index cef0d70e1..b0684a3e6 100644 --- a/dap4_test/baseline/test_struct_array.nc.d4m +++ b/dap4_test/baseline/test_struct_array.nc.d4m @@ -9,7 +9,6 @@ dimensions: dy = 3 ; variables: s_t s(dx, dy) ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baseline/test_struct_array.nc.d4p b/dap4_test/baseline/test_struct_array.nc.d4p index e8c31f390..3d9313287 100644 --- a/dap4_test/baseline/test_struct_array.nc.d4p +++ b/dap4_test/baseline/test_struct_array.nc.d4p @@ -18,8 +18,6 @@ - - diff --git a/dap4_test/baseline/test_struct_array.syn.d4d b/dap4_test/baseline/test_struct_array.syn.d4d index 75958bab6..73d6092a5 100644 --- a/dap4_test/baseline/test_struct_array.syn.d4d +++ b/dap4_test/baseline/test_struct_array.syn.d4d @@ -11,7 +11,7 @@ variables: float z(dx) ; float t(dy) ; s_t s(dx, dy) ; - string s:_edu.ucar.maps = "/z", "/t" ; + string s:_edu.ucar.maps = "/z", "/t" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baseline/test_struct_array.syn.d4m b/dap4_test/baseline/test_struct_array.syn.d4m index 39c68c283..2326dbd8b 100644 --- a/dap4_test/baseline/test_struct_array.syn.d4m +++ b/dap4_test/baseline/test_struct_array.syn.d4m @@ -11,7 +11,7 @@ variables: float z(dx) ; float t(dy) ; s_t s(dx, dy) ; - string s:_edu.ucar.maps = "/z", "/t" ; + string s:_edu.ucar.maps = "/z", "/t" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baseline/test_struct_nested.nc.d4d b/dap4_test/baseline/test_struct_nested.nc.d4d index d14fb5f27..83bc77b67 100644 --- a/dap4_test/baseline/test_struct_nested.nc.d4d +++ b/dap4_test/baseline/test_struct_nested.nc.d4d @@ -14,7 +14,6 @@ types: }; // x_t variables: x_t x ; - string x:_edu.ucar.maps = "/x_field1.x", "/x_field1.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baseline/test_struct_nested.nc.d4m b/dap4_test/baseline/test_struct_nested.nc.d4m index 0a8fb6073..78567d8be 100644 --- a/dap4_test/baseline/test_struct_nested.nc.d4m +++ b/dap4_test/baseline/test_struct_nested.nc.d4m @@ -14,7 +14,6 @@ types: }; // x_t variables: x_t x ; - string x:_edu.ucar.maps = "/x_field1.x", "/x_field1.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baseline/test_struct_nested.nc.d4p b/dap4_test/baseline/test_struct_nested.nc.d4p index 91c3d5d48..5f875795b 100644 --- a/dap4_test/baseline/test_struct_nested.nc.d4p +++ b/dap4_test/baseline/test_struct_nested.nc.d4p @@ -19,10 +19,7 @@ - - - - + diff --git a/dap4_test/baseline/test_struct_type.nc.d4d b/dap4_test/baseline/test_struct_type.nc.d4d index 1f8395ffb..6d6e924b2 100644 --- a/dap4_test/baseline/test_struct_type.nc.d4d +++ b/dap4_test/baseline/test_struct_type.nc.d4d @@ -6,7 +6,6 @@ types: }; // s_t variables: s_t s ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baseline/test_struct_type.nc.d4m b/dap4_test/baseline/test_struct_type.nc.d4m index 941d72e1a..319a6d77e 100644 --- a/dap4_test/baseline/test_struct_type.nc.d4m +++ b/dap4_test/baseline/test_struct_type.nc.d4m @@ -6,7 +6,6 @@ types: }; // s_t variables: s_t s ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baseline/test_struct_type.nc.d4p b/dap4_test/baseline/test_struct_type.nc.d4p index ddb2fdacf..4fc19ba02 100644 --- a/dap4_test/baseline/test_struct_type.nc.d4p +++ b/dap4_test/baseline/test_struct_type.nc.d4p @@ -11,10 +11,7 @@ - - - - + diff --git a/dap4_test/baselineraw/CMakeLists.txt b/dap4_test/baselineraw/CMakeLists.txt index d46021ec0..2332d8f85 100644 --- a/dap4_test/baselineraw/CMakeLists.txt +++ b/dap4_test/baselineraw/CMakeLists.txt @@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) -SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am) +SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt) ADD_EXTRA_DIST("${CUR_EXTRA_DIST}") diff --git a/dap4_test/baselineraw/test_struct1.nc.dmp b/dap4_test/baselineraw/test_struct1.nc.dmp index e946f8149..23d3a2ef5 100644 --- a/dap4_test/baselineraw/test_struct1.nc.dmp +++ b/dap4_test/baselineraw/test_struct1.nc.dmp @@ -6,7 +6,6 @@ types: }; // s_t variables: s_t s ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baselineraw/test_struct_array.6.nc.dmp b/dap4_test/baselineraw/test_struct_array.6.nc.dmp index f5d79b276..00c92c06c 100644 --- a/dap4_test/baselineraw/test_struct_array.6.nc.dmp +++ b/dap4_test/baselineraw/test_struct_array.6.nc.dmp @@ -8,7 +8,6 @@ dimensions: _Anonymous2 = 2 ; variables: s_t s(_Anonymous2, _Anonymous2) ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: string :_dap4.ce = "/s[0:2:3][0:1]" ; diff --git a/dap4_test/baselineraw/test_struct_array.nc.dmp b/dap4_test/baselineraw/test_struct_array.nc.dmp index 0199c4882..c1d4a5b12 100644 --- a/dap4_test/baselineraw/test_struct_array.nc.dmp +++ b/dap4_test/baselineraw/test_struct_array.nc.dmp @@ -9,7 +9,6 @@ dimensions: dy = 3 ; variables: s_t s(dx, dy) ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baselineraw/test_struct_nested.nc.dmp b/dap4_test/baselineraw/test_struct_nested.nc.dmp index 9f3eda950..fb83ca2f6 100644 --- a/dap4_test/baselineraw/test_struct_nested.nc.dmp +++ b/dap4_test/baselineraw/test_struct_nested.nc.dmp @@ -14,7 +14,6 @@ types: }; // x_t variables: x_t x ; - string x:_edu.ucar.maps = "/x_field1.x", "/x_field1.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baselineraw/test_struct_type.nc.dmp b/dap4_test/baselineraw/test_struct_type.nc.dmp index e37f3e246..1675cbdc8 100644 --- a/dap4_test/baselineraw/test_struct_type.nc.dmp +++ b/dap4_test/baselineraw/test_struct_type.nc.dmp @@ -6,7 +6,6 @@ types: }; // s_t variables: s_t s ; - string s:_edu.ucar.maps = "/s.x", "/s.y" ; // global attributes: :_DAP4_Little_Endian = 1UB ; diff --git a/dap4_test/baselineremote/CMakeLists.txt b/dap4_test/baselineremote/CMakeLists.txt index d46021ec0..2332d8f85 100644 --- a/dap4_test/baselineremote/CMakeLists.txt +++ b/dap4_test/baselineremote/CMakeLists.txt @@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) -SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am) +SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt) ADD_EXTRA_DIST("${CUR_EXTRA_DIST}") diff --git a/dap4_test/cdltestfiles/CMakeLists.txt b/dap4_test/cdltestfiles/CMakeLists.txt index d46021ec0..2332d8f85 100644 --- a/dap4_test/cdltestfiles/CMakeLists.txt +++ b/dap4_test/cdltestfiles/CMakeLists.txt @@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) -SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am) +SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt) ADD_EXTRA_DIST("${CUR_EXTRA_DIST}") diff --git a/dap4_test/daptestfiles/CMakeLists.txt b/dap4_test/daptestfiles/CMakeLists.txt index d46021ec0..2332d8f85 100644 --- a/dap4_test/daptestfiles/CMakeLists.txt +++ b/dap4_test/daptestfiles/CMakeLists.txt @@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) -SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am) +SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt) ADD_EXTRA_DIST("${CUR_EXTRA_DIST}") diff --git a/dap4_test/daptestfiles/test_atomic_array.nc.dap b/dap4_test/daptestfiles/test_atomic_array.nc.dap index 511cfa384..ee66dbeb4 100644 Binary files a/dap4_test/daptestfiles/test_atomic_array.nc.dap and b/dap4_test/daptestfiles/test_atomic_array.nc.dap differ diff --git a/dap4_test/daptestfiles/test_atomic_array.syn.dap b/dap4_test/daptestfiles/test_atomic_array.syn.dap index 8032a754f..30138ab7b 100644 Binary files a/dap4_test/daptestfiles/test_atomic_array.syn.dap and b/dap4_test/daptestfiles/test_atomic_array.syn.dap differ diff --git a/dap4_test/daptestfiles/test_atomic_types.nc.dap b/dap4_test/daptestfiles/test_atomic_types.nc.dap index 19ca742d9..154de8165 100644 Binary files a/dap4_test/daptestfiles/test_atomic_types.nc.dap and b/dap4_test/daptestfiles/test_atomic_types.nc.dap differ diff --git a/dap4_test/daptestfiles/test_atomic_types.syn.dap b/dap4_test/daptestfiles/test_atomic_types.syn.dap index 13e9bd604..906759bc7 100644 Binary files a/dap4_test/daptestfiles/test_atomic_types.syn.dap and b/dap4_test/daptestfiles/test_atomic_types.syn.dap differ diff --git a/dap4_test/daptestfiles/test_enum.nc.dap b/dap4_test/daptestfiles/test_enum.nc.dap index e87e53b23..ec6975682 100644 Binary files a/dap4_test/daptestfiles/test_enum.nc.dap and b/dap4_test/daptestfiles/test_enum.nc.dap differ diff --git a/dap4_test/daptestfiles/test_enum_2.nc.dap b/dap4_test/daptestfiles/test_enum_2.nc.dap index 5cd58c495..d38f5337f 100644 Binary files a/dap4_test/daptestfiles/test_enum_2.nc.dap and b/dap4_test/daptestfiles/test_enum_2.nc.dap differ diff --git a/dap4_test/daptestfiles/test_enum_array.4.nc.dap b/dap4_test/daptestfiles/test_enum_array.4.nc.dap index 1ad1eed2c..e89b3c55f 100644 Binary files a/dap4_test/daptestfiles/test_enum_array.4.nc.dap and b/dap4_test/daptestfiles/test_enum_array.4.nc.dap differ diff --git a/dap4_test/daptestfiles/test_enum_array.nc.dap b/dap4_test/daptestfiles/test_enum_array.nc.dap index 7a2a20b69..60a17c752 100644 Binary files a/dap4_test/daptestfiles/test_enum_array.nc.dap and b/dap4_test/daptestfiles/test_enum_array.nc.dap differ diff --git a/dap4_test/daptestfiles/test_struct1.nc.dap b/dap4_test/daptestfiles/test_struct1.nc.dap index dca918834..1060ad4ff 100644 Binary files a/dap4_test/daptestfiles/test_struct1.nc.dap and b/dap4_test/daptestfiles/test_struct1.nc.dap differ diff --git a/dap4_test/daptestfiles/test_struct_array.6.nc.dap b/dap4_test/daptestfiles/test_struct_array.6.nc.dap index cc2b49bbb..f551cc102 100644 Binary files a/dap4_test/daptestfiles/test_struct_array.6.nc.dap and b/dap4_test/daptestfiles/test_struct_array.6.nc.dap differ diff --git a/dap4_test/daptestfiles/test_struct_array.nc.dap b/dap4_test/daptestfiles/test_struct_array.nc.dap index 818083498..78814dff9 100644 Binary files a/dap4_test/daptestfiles/test_struct_array.nc.dap and b/dap4_test/daptestfiles/test_struct_array.nc.dap differ diff --git a/dap4_test/daptestfiles/test_struct_nested.nc.dap b/dap4_test/daptestfiles/test_struct_nested.nc.dap index ce520c21a..33eb9ef14 100644 Binary files a/dap4_test/daptestfiles/test_struct_nested.nc.dap and b/dap4_test/daptestfiles/test_struct_nested.nc.dap differ diff --git a/dap4_test/daptestfiles/test_struct_type.nc.dap b/dap4_test/daptestfiles/test_struct_type.nc.dap index aeae2bac9..2b3ffbf1b 100644 Binary files a/dap4_test/daptestfiles/test_struct_type.nc.dap and b/dap4_test/daptestfiles/test_struct_type.nc.dap differ diff --git a/dap4_test/dmrtestfiles/CMakeLists.txt b/dap4_test/dmrtestfiles/CMakeLists.txt index d46021ec0..2332d8f85 100644 --- a/dap4_test/dmrtestfiles/CMakeLists.txt +++ b/dap4_test/dmrtestfiles/CMakeLists.txt @@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) -SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am) +SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt) ADD_EXTRA_DIST("${CUR_EXTRA_DIST}") diff --git a/dap4_test/dmrtestfiles/test_atomic_array.nc.dmr b/dap4_test/dmrtestfiles/test_atomic_array.nc.dmr index 29a27e1ac..5ede1b99f 100644 --- a/dap4_test/dmrtestfiles/test_atomic_array.nc.dmr +++ b/dap4_test/dmrtestfiles/test_atomic_array.nc.dmr @@ -51,7 +51,7 @@ - + diff --git a/dap4_test/dmrtestfiles/test_atomic_array.syn.dmr b/dap4_test/dmrtestfiles/test_atomic_array.syn.dmr index 5d7e2a434..a539d8dca 100644 --- a/dap4_test/dmrtestfiles/test_atomic_array.syn.dmr +++ b/dap4_test/dmrtestfiles/test_atomic_array.syn.dmr @@ -51,7 +51,7 @@ - + diff --git a/dap4_test/dmrtestfiles/test_atomic_types.nc.dmr b/dap4_test/dmrtestfiles/test_atomic_types.nc.dmr index 249b4bb59..e34b9e6b9 100644 --- a/dap4_test/dmrtestfiles/test_atomic_types.nc.dmr +++ b/dap4_test/dmrtestfiles/test_atomic_types.nc.dmr @@ -33,12 +33,12 @@ - + - + diff --git a/dap4_test/dmrtestfiles/test_atomic_types.syn.dmr b/dap4_test/dmrtestfiles/test_atomic_types.syn.dmr index 36cc7d1f1..ac11cb21c 100644 --- a/dap4_test/dmrtestfiles/test_atomic_types.syn.dmr +++ b/dap4_test/dmrtestfiles/test_atomic_types.syn.dmr @@ -33,12 +33,12 @@ - + - + diff --git a/dap4_test/dmrtestfiles/test_enum.nc.dmr b/dap4_test/dmrtestfiles/test_enum.nc.dmr index ef25fa758..456ef68a2 100644 --- a/dap4_test/dmrtestfiles/test_enum.nc.dmr +++ b/dap4_test/dmrtestfiles/test_enum.nc.dmr @@ -20,7 +20,7 @@ - + diff --git a/dap4_test/dmrtestfiles/test_enum_2.nc.dmr b/dap4_test/dmrtestfiles/test_enum_2.nc.dmr index a5c0d1d9e..ea663f873 100644 --- a/dap4_test/dmrtestfiles/test_enum_2.nc.dmr +++ b/dap4_test/dmrtestfiles/test_enum_2.nc.dmr @@ -24,7 +24,7 @@ - + diff --git a/dap4_test/dmrtestfiles/test_enum_array.4.nc.dmr b/dap4_test/dmrtestfiles/test_enum_array.4.nc.dmr index 3c0d9f991..aee224f84 100644 --- a/dap4_test/dmrtestfiles/test_enum_array.4.nc.dmr +++ b/dap4_test/dmrtestfiles/test_enum_array.4.nc.dmr @@ -21,7 +21,7 @@ - + diff --git a/dap4_test/dmrtestfiles/test_enum_array.nc.dmr b/dap4_test/dmrtestfiles/test_enum_array.nc.dmr index fcfa9ac28..1899edfcd 100644 --- a/dap4_test/dmrtestfiles/test_enum_array.nc.dmr +++ b/dap4_test/dmrtestfiles/test_enum_array.nc.dmr @@ -22,7 +22,7 @@ - + diff --git a/dap4_test/dmrtestfiles/test_struct1.nc.dmr b/dap4_test/dmrtestfiles/test_struct1.nc.dmr index 4dd5100cc..95b9d84ff 100644 --- a/dap4_test/dmrtestfiles/test_struct1.nc.dmr +++ b/dap4_test/dmrtestfiles/test_struct1.nc.dmr @@ -8,8 +8,6 @@ - - diff --git a/dap4_test/dmrtestfiles/test_struct_array.6.nc.dmr b/dap4_test/dmrtestfiles/test_struct_array.6.nc.dmr index 978d4e63b..914753b5b 100644 --- a/dap4_test/dmrtestfiles/test_struct_array.6.nc.dmr +++ b/dap4_test/dmrtestfiles/test_struct_array.6.nc.dmr @@ -10,8 +10,6 @@ - - diff --git a/dap4_test/dmrtestfiles/test_struct_array.nc.dmr b/dap4_test/dmrtestfiles/test_struct_array.nc.dmr index 3984fce68..44414528d 100644 --- a/dap4_test/dmrtestfiles/test_struct_array.nc.dmr +++ b/dap4_test/dmrtestfiles/test_struct_array.nc.dmr @@ -12,8 +12,6 @@ - - diff --git a/dap4_test/dmrtestfiles/test_struct_nested.nc.dmr b/dap4_test/dmrtestfiles/test_struct_nested.nc.dmr index b15e6f4c1..d9c758866 100644 --- a/dap4_test/dmrtestfiles/test_struct_nested.nc.dmr +++ b/dap4_test/dmrtestfiles/test_struct_nested.nc.dmr @@ -14,8 +14,6 @@ - - diff --git a/dap4_test/dmrtestfiles/test_struct_type.nc.dmr b/dap4_test/dmrtestfiles/test_struct_type.nc.dmr index 1d45e0a6e..d926dfcaa 100644 --- a/dap4_test/dmrtestfiles/test_struct_type.nc.dmr +++ b/dap4_test/dmrtestfiles/test_struct_type.nc.dmr @@ -8,8 +8,6 @@ - - diff --git a/dap4_test/nctestfiles/CMakeLists.txt b/dap4_test/nctestfiles/CMakeLists.txt index d46021ec0..2332d8f85 100644 --- a/dap4_test/nctestfiles/CMakeLists.txt +++ b/dap4_test/nctestfiles/CMakeLists.txt @@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*) FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE) FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) -SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am) +SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt) ADD_EXTRA_DIST("${CUR_EXTRA_DIST}") diff --git a/dap4_test/nctestfiles/test_atomic_array.nc b/dap4_test/nctestfiles/test_atomic_array.nc index b8b927273..076337bd2 100644 Binary files a/dap4_test/nctestfiles/test_atomic_array.nc and b/dap4_test/nctestfiles/test_atomic_array.nc differ diff --git a/dap4_test/nctestfiles/test_atomic_types.nc b/dap4_test/nctestfiles/test_atomic_types.nc index dc6659629..335845c71 100644 Binary files a/dap4_test/nctestfiles/test_atomic_types.nc and b/dap4_test/nctestfiles/test_atomic_types.nc differ diff --git a/dap4_test/nctestfiles/test_unlim1.nc b/dap4_test/nctestfiles/test_unlim1.nc index 45b8ea825..c9f5d8533 100644 Binary files a/dap4_test/nctestfiles/test_unlim1.nc and b/dap4_test/nctestfiles/test_unlim1.nc differ diff --git a/dap4_test/test_data.sh b/dap4_test/test_data.sh index 277c1df22..750a62ac2 100755 --- a/dap4_test/test_data.sh +++ b/dap4_test/test_data.sh @@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi . ${srcdir}/d4test_common.sh +echo "test_data.sh:" + cd ${DAPTESTFILES} F=`ls -1 *.dap | sed -e 's/[.]dap//g' | tr '\r\n' ' '` cd $WD diff --git a/dap4_test/test_meta.sh b/dap4_test/test_meta.sh index d659fdcb2..86b2b09ad 100755 --- a/dap4_test/test_meta.sh +++ b/dap4_test/test_meta.sh @@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi . ${srcdir}/d4test_common.sh +echo "test_meta.sh:" + cd ${DMRTESTFILES} F=`ls -1 *.dmr | sed -e 's/[.]dmr//g' | tr '\r\n' ' '` cd $WD @@ -15,7 +17,7 @@ STEM=`echo $f | cut -d. -f 1` if test -e ${CDLTESTFILES}/${STEM}.cdl ; then CDL="${CDL} ${STEM}" else - echo "Not found: ${CDLTESTFILES}/${STEM}.cdl" + echo "Not found: ${CDLTESTFILES}/${STEM}.cdl; ignored" fi done diff --git a/dap4_test/test_parse.sh b/dap4_test/test_parse.sh index a21aea507..2b75fc14e 100755 --- a/dap4_test/test_parse.sh +++ b/dap4_test/test_parse.sh @@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi . ${srcdir}/d4test_common.sh +echo "test_parse.sh:" + cd ${DMRTESTFILES} F=`ls -1 *.dmr | sed -e 's/[.]dmr//' |tr '\r\n' ' '` cd $WD diff --git a/dap4_test/test_raw.sh b/dap4_test/test_raw.sh index 5d0c2706b..38df2e494 100755 --- a/dap4_test/test_raw.sh +++ b/dap4_test/test_raw.sh @@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi . ${srcdir}/d4test_common.sh +echo "test_raw.sh:" + # Compute the set of testfiles PUSHD ${srcdir}/daptestfiles F=`ls -1d *.dap` diff --git a/dap4_test/test_remote.sh b/dap4_test/test_remote.sh index e37ea0023..d4ea148c6 100755 --- a/dap4_test/test_remote.sh +++ b/dap4_test/test_remote.sh @@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi . ${srcdir}/d4test_common.sh +echo "test_remote.sh:" + #BIG=1 #NOCSUM=1 diff --git a/include/ncwinpath.h b/include/ncwinpath.h index 09600111b..28e9058a4 100644 --- a/include/ncwinpath.h +++ b/include/ncwinpath.h @@ -10,15 +10,16 @@ #include #include "ncexternl.h" +#ifndef WINPATH #ifdef _MSC_VER #define WINPATH 1 #endif #ifdef __MINGW32__ #define WINPATH 1 #endif +#endif - -/* path converter */ +/* Path Converter */ EXTERNL char* NCpathcvt(const char* path); #ifdef WINPATH diff --git a/libdap2/dapcvt.c b/libdap2/dapcvt.c index 64ecdb627..65cc69278 100644 --- a/libdap2/dapcvt.c +++ b/libdap2/dapcvt.c @@ -209,17 +209,16 @@ dapcvtattrval(nc_type etype, void* dst, NClist* src) ok = 0; switch (etype) { - case NC_BYTE: { + case NC_BYTE: { /* Note that in DAP2, this is unsigned 8-bit integer */ + /*Needs special handling because Windows sscanf does not do %hhd*/ char* p = (char*)dstmem; -#ifdef _MSC_VER int ival; ok = sscanf(s,"%d%n",&ival,&nread); +#ifdef _MSC_VER _ASSERTE(_CrtCheckMemory()); - if(ival < NC_MIN_BYTE || ival > NC_MAX_BYTE) ok = 0; - *p = (char)ival; -#else - ok = sscanf(s,"%hhu%n",p,&nread); #endif + if(ival < 0 || ival > NC_MAX_UBYTE) ok = 0; + *p = (char)ival; } break; case NC_CHAR: { signed char* p = (signed char*)dstmem; diff --git a/libdap2/dapdebug.c b/libdap2/dapdebug.c index e8e476004..e9b504f15 100644 --- a/libdap2/dapdebug.c +++ b/libdap2/dapdebug.c @@ -20,9 +20,10 @@ dapbreakpoint(int err) } int -dapthrow(int err) +dapthrow(int err, int lineno, const char* filename) { if(err == 0) return err; + fprintf(stderr,"$dapthrow: err=%d line=%d file=%s\n",err,lineno,filename); fflush(stderr); return dapbreakpoint(err); } #endif diff --git a/libdap2/dapdebug.h b/libdap2/dapdebug.h index b54306bd9..dde23e53d 100644 --- a/libdap2/dapdebug.h +++ b/libdap2/dapdebug.h @@ -27,7 +27,7 @@ #undef PARSEDEBUG /* Warning: setting CATCHERROR has significant performance impact */ -#define CATCHERROR +#undef CATCHERROR #include #include @@ -51,11 +51,11 @@ extern int dappanic(const char* fmt, ...); #ifdef CATCHERROR /* Place breakpoint on dapbreakpoint to catch errors close to where they occur*/ -#define THROW(e) dapthrow(e) -#define THROWCHK(e) (void)dapthrow(e) +#define THROW(e) dapthrow(e,__LINE__,__FILE__) +#define THROWCHK(e) (void)dapthrow(e,__LINE__,__FILE__) extern int dapbreakpoint(int err); -extern int dapthrow(int err); +extern int dapthrow(int err, int lineno, const char* filename); #else #define THROW(e) (e) #define THROWCHK(e) diff --git a/libdap2/nccommon.h b/libdap2/nccommon.h index 5fc5e6e58..f0694dde4 100644 --- a/libdap2/nccommon.h +++ b/libdap2/nccommon.h @@ -126,7 +126,11 @@ typedef struct NCDAPCOMMON { NCCDF cdf; NCOC oc; NCCONTROLS controls; /* Control flags and parameters */ - int nc3id; /* nc3 file ncid used to hold metadata */ + struct { + int realfile; /* 1 => we created actual temp file */ + char* filename; /* of the substrate file */ + int nc3id; /* substrate nc4 file ncid used to hold metadata; not same as external id */ + } substrate; } NCDAPCOMMON; /**************************************************/ @@ -306,6 +310,6 @@ extern int nc__opendap(void); #define getncid(drno) (((NC*)drno)->ext_ncid) #define getdap(drno) ((NCDAPCOMMON*)((NC*)drno)->dispatchdata) -#define getnc3id(drno) (getdap(drno)->nc3id) +#define getnc3id(drno) (getdap(drno)->substrate.nc3id) #endif /*NCCOMMON_H*/ diff --git a/libdap2/ncd2dispatch.c b/libdap2/ncd2dispatch.c index 53ba6b2b4..b6db0c824 100644 --- a/libdap2/ncd2dispatch.c +++ b/libdap2/ncd2dispatch.c @@ -283,7 +283,7 @@ NCD2_get_vars(int ncid, int varid, /* See ncd2dispatch.c for other version */ int -NCD2_open(const char * path, int mode, +NCD2_open(const char* path, int mode, int basepe, size_t *chunksizehintp, int useparallel, void* mpidata, NC_Dispatch* dispatch, NC* drno) @@ -295,13 +295,15 @@ NCD2_open(const char * path, int mode, int nc3id = -1; if(path == NULL) - return NC_EDAPURL; - if(dispatch == NULL) PANIC("NCD3_open: no dispatch table"); + {ncstat = NC_EDAPURL; goto done;} + if(dispatch == NULL) + PANIC("NCD3_open: no dispatch table"); /* Setup our NC and NCDAPCOMMON state*/ dapcomm = (NCDAPCOMMON*)calloc(1,sizeof(NCDAPCOMMON)); - if(dapcomm == NULL) {ncstat = NC_ENOMEM; goto done;} + if(dapcomm == NULL) + {ncstat = NC_ENOMEM; goto done;} NCD2_DATA_SET(drno,dapcomm); drno->int_ncid = nc__pseudofd(); /* create a unique id */ @@ -364,26 +366,34 @@ NCD2_open(const char * path, int mode, /* Create fake file name: exact name must be unique, but is otherwise irrelevant because we are using NC_DISKLESS */ - snprintf(tmpname,sizeof(tmpname),"%d",drno->int_ncid); + snprintf(tmpname,sizeof(tmpname),"tmp_%d",drno->int_ncid); /* Now, use the file to create the hidden, in-memory netcdf file. We want this hidden file to always be NC_CLASSIC, so we need to force default format temporarily in case user changed it. + If diskless is enabled, then create file in-memory, else + create an actual temporary file in the file system. */ { int new = 0; /* format netcdf-3 */ int old = 0; + int ncflags = NC_CLOBBER|NC_CLASSIC_MODEL; +#ifdef USE_DISKLESS + ncflags |= NC_DISKLESS; +#endif nc_set_default_format(new,&old); /* save and change */ - ncstat = nc_create(tmpname,NC_DISKLESS|NC_CLASSIC_MODEL,&nc3id); + ncstat = nc_create(tmpname,ncflags,&nc3id); nc_set_default_format(old,&new); /* restore */ + dapcomm->substrate.realfile = ((ncflags & NC_DISKLESS) != 0); + dapcomm->substrate.filename = strdup(tmpname); + if(tmpname == NULL) ncstat = NC_ENOMEM; + dapcomm->substrate.nc3id = nc3id; } if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;} - dapcomm->nc3id = nc3id; /* Avoid fill */ nc_set_fill(nc3id,NC_NOFILL,NULL); } - dapcomm->oc.dapconstraint = (DCEconstraint*)dcecreate(CES_CONSTRAINT); dapcomm->oc.dapconstraint->projections = nclistnew(); dapcomm->oc.dapconstraint->selections = nclistnew(); @@ -673,7 +683,7 @@ builddims(NCDAPCOMMON* dapcomm) if(dapcomm->cdf.recorddim != NULL) { CDFnode* unlimited = dapcomm->cdf.recorddim; definename = getdefinename(unlimited); - ncstat = nc_def_dim(dapcomm->nc3id, + ncstat = nc_def_dim(dapcomm->substrate.nc3id, definename, NC_UNLIMITED, &unlimited->ncid); @@ -681,7 +691,7 @@ builddims(NCDAPCOMMON* dapcomm) if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;} /* get the id for the substrate */ - ncstat = NC_check_id(dapcomm->nc3id,&ncsub); + ncstat = NC_check_id(dapcomm->substrate.nc3id,&ncsub); if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;} #if 0 nc3sub = (NC3_INFO*)&ncsub->dispatchdata; @@ -700,7 +710,7 @@ builddims(NCDAPCOMMON* dapcomm) fprintf(stderr,"define: dim: %s=%ld\n",dim->ncfullname,(long)dim->dim.declsize); #endif definename = getdefinename(dim); - ncstat = nc_def_dim(dapcomm->nc3id,definename,dim->dim.declsize,&dimid); + ncstat = nc_def_dim(dapcomm->substrate.nc3id,definename,dim->dim.declsize,&dimid); if(ncstat != NC_NOERR) { THROWCHK(ncstat); nullfree(definename); goto done; } @@ -772,7 +782,7 @@ fprintf(stderr,"[%ld]",dim->dim.declsize); } fprintf(stderr,"\n"); #endif - ncstat = nc_def_var(dapcomm->nc3id, + ncstat = nc_def_var(dapcomm->substrate.nc3id, definename, var->externaltype, ncrank, @@ -833,7 +843,7 @@ buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root) } } if(ncbyteslength(buf) > 0) { - ncstat = nc_put_att_text(dapcomm->nc3id,NC_GLOBAL,"_sequence_dimensions", + ncstat = nc_put_att_text(dapcomm->substrate.nc3id,NC_GLOBAL,"_sequence_dimensions", ncbyteslength(buf),ncbytescontents(buf)); } } @@ -844,12 +854,12 @@ buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root) if(dapparamcheck(dapcomm,"show","translate")) { /* Add a global attribute to show the translation */ - ncstat = nc_put_att_text(dapcomm->nc3id,NC_GLOBAL,"_translate", + ncstat = nc_put_att_text(dapcomm->substrate.nc3id,NC_GLOBAL,"_translate", strlen("netcdf-3"),"netcdf-3"); } if(dapparamcheck(dapcomm,"show","url")) { if(dapcomm->oc.rawurltext != NULL) - ncstat = nc_put_att_text(dapcomm->nc3id,NC_GLOBAL,"_url", + ncstat = nc_put_att_text(dapcomm->substrate.nc3id,NC_GLOBAL,"_url", strlen(dapcomm->oc.rawurltext),dapcomm->oc.rawurltext); } if(dapparamcheck(dapcomm,"show","dds")) { @@ -860,7 +870,7 @@ buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root) /* replace newlines with spaces*/ nltxt = nulldup(txt); for(p=nltxt;*p;p++) {if(*p == '\n' || *p == '\r' || *p == '\t') {*p = ' ';}}; - ncstat = nc_put_att_text(dapcomm->nc3id,NC_GLOBAL,"_dds",strlen(nltxt),nltxt); + ncstat = nc_put_att_text(dapcomm->substrate.nc3id,NC_GLOBAL,"_dds",strlen(nltxt),nltxt); nullfree(nltxt); } } @@ -871,7 +881,7 @@ buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root) if(txt != NULL) { nltxt = nulldup(txt); for(p=nltxt;*p;p++) {if(*p == '\n' || *p == '\r' || *p == '\t') {*p = ' ';}}; - ncstat = nc_put_att_text(dapcomm->nc3id,NC_GLOBAL,"_das",strlen(nltxt),nltxt); + ncstat = nc_put_att_text(dapcomm->substrate.nc3id,NC_GLOBAL,"_das",strlen(nltxt),nltxt); nullfree(nltxt); } } @@ -913,9 +923,9 @@ buildattribute(NCDAPCOMMON* dapcomm, NCattribute* att, nc_type vartype, int vari } dapexpandescapes(newstring); if(newstring[0]=='\0') - ncstat = nc_put_att_text(dapcomm->nc3id,varid,att->name,1,newstring); + ncstat = nc_put_att_text(dapcomm->substrate.nc3id,varid,att->name,1,newstring); else - ncstat = nc_put_att_text(dapcomm->nc3id,varid,att->name,strlen(newstring),newstring); + ncstat = nc_put_att_text(dapcomm->substrate.nc3id,varid,att->name,strlen(newstring),newstring); free(newstring); if(ncstat) goto done; } else { @@ -945,7 +955,7 @@ buildattribute(NCDAPCOMMON* dapcomm, NCattribute* att, nc_type vartype, int vari _ASSERTE(_CrtCheckMemory()); #endif if(ncstat) {nullfree(mem); goto done;} - ncstat = nc_put_att(dapcomm->nc3id,varid,att->name,atype,nvalues,mem); + ncstat = nc_put_att(dapcomm->substrate.nc3id,varid,att->name,atype,nvalues,mem); #ifdef _MSC_VER _ASSERTE(_CrtCheckMemory()); #endif @@ -1764,6 +1774,11 @@ freeNCDAPCOMMON(NCDAPCOMMON* dapcomm) dcefree((DCEnode*)dapcomm->oc.dapconstraint); dapcomm->oc.dapconstraint = NULL; + /* Note that the ncio layer will figure out that the tmp file needs to be deleted, + so we do not have to do it. + */ + nullfree(dapcomm->substrate.filename); /* always reclaim */ + free(dapcomm); return NC_NOERR; diff --git a/libdap4/d4file.c b/libdap4/d4file.c index 6a27caf7b..e7e7a254e 100644 --- a/libdap4/d4file.c +++ b/libdap4/d4file.c @@ -9,7 +9,7 @@ #include "d4read.h" #include "d4curlfunctions.h" -#if defined(_WIN32) || defined(_WIN64) +#ifdef _MSC_VER #include #include #endif @@ -29,6 +29,7 @@ static void freeInfo(NCD4INFO*); static int paramcheck(NCD4INFO*, const char* key, const char* subkey); static const char* getparam(NCD4INFO* info, const char* key); static int set_curl_properties(NCD4INFO*); +static void d4removecookies(const char* path); /**************************************************/ /* Constants */ @@ -93,21 +94,32 @@ NCD4_open(const char * path, int mode, else snprintf(tmpname,sizeof(tmpname),"tmp_%d",nc->int_ncid); - /* Now, use the file to create the hidden, in-memory netcdf file. + /* Now, use the file to create the hidden substrate netcdf file. We want this hidden file to always be NC_NETCDF4, so we need to force default format temporarily in case user changed it. + If diskless is enabled, then create file in-memory, else + create an actual temporary file in the file system. */ { int new = NC_NETCDF4; int old = 0; - int ncflags = NC_DISKLESS|NC_NETCDF4|NC_CLOBBER; - - if(FLAGSET(d4info->controls.debugflags,NCF_DEBUG_COPY)) + int ncid = 0; + int ncflags = NC_NETCDF4|NC_CLOBBER; +#ifdef USE_DISKLESS + ncflags |= NC_DISKLESS; +#endif + if(FLAGSET(d4info->controls.debugflags,NCF_DEBUG_COPY)) { + /* Cause data to be dumped to real file */ ncflags |= NC_WRITE; - + ncflags &= ~(NC_DISKLESS); /* use real file */ + } nc_set_default_format(new,&old); /* save and change */ - ret = nc_create(tmpname,ncflags,&d4info->substrate.nc4id); + ret = nc_create(tmpname,ncflags,&ncid); nc_set_default_format(old,&new); /* restore */ + d4info->substrate.realfile = ((ncflags & NC_DISKLESS) == 0); + d4info->substrate.filename = strdup(tmpname); + if(tmpname == NULL) ret = NC_ENOMEM; + d4info->substrate.nc4id = ncid; } if(ret != NC_NOERR) goto done; /* Avoid fill */ @@ -280,7 +292,21 @@ freeInfo(NCD4INFO* d4info) nullfree(d4info->data.ondiskfilename); if(d4info->data.ondiskfile != NULL) fclose(d4info->data.ondiskfile); - nullfree(d4info->substrate.filename); + if(d4info->substrate.realfile + && !FLAGSET(d4info->controls.debugflags,NCF_DEBUG_COPY)) { + /* We used real file, so we need to delete the temp file + unless we are debugging. + Assume caller has done nc_close|nc_abort on the ncid. + Note that in theory, this should not be necessary since + AFAIK the substrate file is still in def mode, and + when aborted, it should be deleted. But that is not working + for some reason, so we delete it ourselves. + */ + if(d4info->substrate.filename != NULL) { + unlink(d4info->substrate.filename); + } + } + nullfree(d4info->substrate.filename); /* always reclaim */ NCD4_reclaimMeta(d4info->substrate.metadata); free(d4info); } @@ -294,7 +320,6 @@ freeCurl(NCD4curl* curl) nullfree(curl->errdata.code); nullfree(curl->errdata.message); nullfree(curl->curlflags.useragent); - nullfree(curl->curlflags.cookiejar); nullfree(curl->curlflags.netrc); nullfree(curl->ssl.certificate); nullfree(curl->ssl.key); @@ -304,6 +329,9 @@ freeCurl(NCD4curl* curl) nullfree(curl->proxy.host); nullfree(curl->proxy.userpwd); nullfree(curl->creds.userpwd); + if(curl->curlflags.createdflags & COOKIECREATED) + d4removecookies(curl->curlflags.cookiejar); + nullfree(curl->curlflags.cookiejar); } /* Define the set of protocols known to be constrainable */ @@ -353,32 +381,28 @@ set_curl_properties(NCD4INFO* d4info) if(d4info->curl->curlflags.cookiejar == NULL) { /* If no cookie file was defined, define a default */ - char tmp[4096+1]; int ok; -#if defined(_WIN32) || defined(_WIN64) - int pid = _getpid(); -#else - pid_t pid = getpid(); -#endif - snprintf(tmp,sizeof(tmp)-1,"%s/%s.%ld/",NCD4_globalstate->tempdir,"netcdf",(long)pid); - -#if defined(_WIN32) || defined(_WIN64) - ok = _mkdir(tmp); -#else - ok = mkdir(tmp,S_IRUSR | S_IWUSR | S_IXUSR); -#endif - if(ok != 0 && errno != EEXIST) { - fprintf(stderr,"Cannot create cookie directory\n"); - goto fail; - } + char* path = NULL; + char* name = NULL; + int len; errno = 0; /* Create the unique cookie file name */ - ok = NCD4_mktmp(tmp,&d4info->curl->curlflags.cookiejar); - d4info->curl->curlflags.createdflags |= COOKIECREATED; + len = + strlen(NCD4_globalstate->tempdir) + + 1 /* '/' */ + + strlen("ncd4cookies"); + path = (char*)malloc(len+1); + if(path == NULL) return NC_ENOMEM; + snprintf(path,len,"%s/nc4cookies",NCD4_globalstate->tempdir); + /* Create the unique cookie file name */ + ok = NCD4_mktmp(path,&name); + free(path); if(ok != NC_NOERR && errno != EEXIST) { fprintf(stderr,"Cannot create cookie file\n"); goto fail; } + d4info->curl->curlflags.cookiejar = name; + d4info->curl->curlflags.createdflags |= COOKIECREATED; errno = 0; } assert(d4info->curl->curlflags.cookiejar != NULL); @@ -489,3 +513,13 @@ getparam(NCD4INFO* info, const char* key) return NULL; return value; } + +static void +d4removecookies(const char* path) +{ +#ifdef _MSC_VER + DeleteFile(path); +#else + remove(path); +#endif +} diff --git a/libdap4/d4read.c b/libdap4/d4read.c index e3b02c599..51f21a492 100644 --- a/libdap4/d4read.c +++ b/libdap4/d4read.c @@ -49,16 +49,16 @@ NCD4_readDAP(NCD4INFO* state, int flags) ncurisetconstraints(url,state->constraint); #endif readurl = ncuribuild(url,NULL,".dods",NCURISVC); - if(readurl == NULL) + if(readurl == NULL) return THROW(NC_ENOMEM); - if (state->debug > 0) + if (state->debug > 0) {fprintf(stderr, "fetch url=%s\n", readurl);fflush(stderr);} stat = NCD4_fetchurl_file(state->curl, readurl, state->data.ondiskfile, &state->data.datasize, &lastmod); nullfree(readurl); if(stat == NC_NOERR) state->data.daplastmodified = lastmod; - if (state->debug > 0) + if (state->debug > 0) {fprintf(stderr,"fetch complete\n"); fflush(stderr);} } } @@ -167,7 +167,7 @@ readfile(const NCURI* uri, const char* suffix, NCbytes* packet) #ifdef O_BINARY flags |= O_BINARY; #endif -fprintf(stderr,"XXX: flags=0x%x file=%s\n",flags,filename); + fd = NCopen2(filename,flags); if(fd < 0) { nclog(NCLOGERR,"open failed:%s",filename); diff --git a/libdap4/d4util.c b/libdap4/d4util.c index 4f8f6942b..1f09cea5a 100644 --- a/libdap4/d4util.c +++ b/libdap4/d4util.c @@ -207,7 +207,7 @@ backslashEscape(const char* s) } /* Parse an fqn into a sequence of names; - initially using '/', then '.' */ + using '/', and then (conditionally) '.' */ int NCD4_parseFQN(const char* fqn0, NClist* pieces) { @@ -239,6 +239,7 @@ NCD4_parseFQN(const char* fqn0, NClist* pieces) break; } } +#ifdef ALLOWFIELDMAPS /* Step 2, walk the final piece to break up based on '.' */ for(p=start;*p;) { switch(*p) { @@ -255,6 +256,7 @@ NCD4_parseFQN(const char* fqn0, NClist* pieces) break; } } +#endif count++; /* acct for last piece */ /* Step 3: capture and de-scape the pieces */ for(p=fqn;count > 0;count--) { diff --git a/libdap4/ncd4types.h b/libdap4/ncd4types.h index 531f4e340..d77578a4f 100644 --- a/libdap4/ncd4types.h +++ b/libdap4/ncd4types.h @@ -13,6 +13,12 @@ are defined here. #undef COMPILEBYDEFAULT +/* +Control if struct fields can be map targets. +Currently turned off because semantics are unclear. +*/ +#undef ALLOWFIELDMAPS + #define long64 long long #define ncerror int @@ -217,7 +223,8 @@ typedef struct NCD4serial { /* This will be passed out of the parse */ struct NCD4meta { NCD4INFO* controller; - int ncid; /* root ncid of the substrate netcdf-4 file; copy of NCD4parse argument*/ + int ncid; /* root ncid of the substrate netcdf-4 file; + warning: copy of NCD4Info.substrate.nc4id */ NCD4node* root; NCD4mode mode; /* Are we reading DMR (only) or DAP (includes DMR) */ NClist* allnodes; /*list*/ @@ -345,6 +352,7 @@ struct NCD4INFO { long daplastmodified; } data; struct { + int realfile; /* 1 => we created actual temp file */ char* filename; /* of the substrate file */ int nc4id; /* substrate nc4 file ncid used to hold metadata; not same as external id */ NCD4meta* metadata; diff --git a/libdispatch/dfile.c b/libdispatch/dfile.c index 3e22ae58a..2ac53d9df 100644 --- a/libdispatch/dfile.c +++ b/libdispatch/dfile.c @@ -118,9 +118,11 @@ done: /*! Given an existing file, figure out its format and return that format value (NC_FORMATX_XXX) -in model arg. +in model arg. Assume any path conversion was +already performed at a higher level. */ -static int NC_check_file_type(const char *path, int flags, void *parameters, +static int +NC_check_file_type(const char *path, int flags, void *parameters, int* model, int* version) { char magic[MAGIC_NUMBER_LEN]; @@ -139,6 +141,7 @@ static int NC_check_file_type(const char *path, int flags, void *parameters, } else {/* presumably a real file */ /* Get the 4-byte magic from the beginning of the file. Don't use posix * for parallel, use the MPI functions instead. */ + #ifdef USE_PARALLEL if (use_parallel) { MPI_File fh; @@ -169,19 +172,18 @@ static int NC_check_file_type(const char *path, int flags, void *parameters, #else struct stat st; #endif - - if(path == NULL || strlen(path)==0) + if(path == NULL || strlen(path)==0) {status = NC_EINVAL; goto done;} - if (!(fp = fopen(path, "r"))) + if (!(fp = fopen(path, "r"))) {status = errno; goto done;} #ifdef HAVE_SYS_STAT_H - /* The file must be at least MAGIC_NUMBER_LEN in size, + /* The file must be at least MAGIC_NUMBER_LEN in size, or otherwise the following fread will exhibit unexpected behavior. */ - /* Windows and fstat have some issues, this will work around that. */ + /* Windows and fstat have some issues, this will work around that. */ #ifdef HAVE_FILE_LENGTH_I64 if((file_len = _filelengthi64(fileno(fp))) < 0) { fclose(fp); @@ -189,7 +191,6 @@ static int NC_check_file_type(const char *path, int flags, void *parameters, goto done; } - if(file_len < MAGIC_NUMBER_LEN) { fclose(fp); status = NC_ENOTNC; @@ -1659,6 +1660,10 @@ NC_create(const char *path0, int cmode, size_t initialsz, return stat; } +#ifndef USE_DISKLESS + cmode &= (~ NC_DISKLESS); /* Force off */ +#endif + #ifdef WINPATH /* Need to do path conversion */ path = NCpathcvt(path0); @@ -1811,8 +1816,8 @@ NC_open(const char *path0, int cmode, int stat = NC_NOERR; NC* ncp = NULL; NC_Dispatch* dispatcher = NULL; - int inmemory = ((cmode & NC_INMEMORY) == NC_INMEMORY); - int diskless = ((cmode & NC_DISKLESS) == NC_DISKLESS); + int inmemory = 0; + int diskless = 0; /* Need pieces of information for now to decide model*/ int model = 0; int isurl = 0; @@ -1826,10 +1831,22 @@ NC_open(const char *path0, int cmode, if(stat) return stat; } + /* Attempt to do file path conversion: note that this will do + nothing if path is a 'file:...' url, so it will need to be + repeated in protocol code: libdap2 and libdap4 + */ + +#ifndef USE_DISKLESS + /* Clean up cmode */ + cmode &= (~ NC_DISKLESS); +#endif + + inmemory = ((cmode & NC_INMEMORY) == NC_INMEMORY); + diskless = ((cmode & NC_DISKLESS) == NC_DISKLESS); + + #ifdef WINPATH - /* Need to do path conversion */ path = NCpathcvt(path0); -fprintf(stderr,"XXX: path0=%s path=%s\n",path0,path); fflush(stderr); #else path = nulldup(path0); #endif diff --git a/libdispatch/dwinpath.c b/libdispatch/dwinpath.c index 659533620..f14a8b625 100644 --- a/libdispatch/dwinpath.c +++ b/libdispatch/dwinpath.c @@ -18,6 +18,8 @@ #include "ncexternl.h" #include "ncwinpath.h" +#undef PATHFORMAT + /* Code to provide some path conversion code so that cygwin and (some) mingw paths can be passed to open/fopen @@ -38,6 +40,8 @@ static char* windrive = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; static size_t cdlen = 10; /* strlen("/cygdrive/") */ +static int pathdebug = -1; + EXTERNL char* /* caller frees */ NCpathcvt(const char* path) @@ -47,7 +51,14 @@ NCpathcvt(const char* path) char* q; size_t pathlen; - if(path == NULL) return NULL; /* defensive driving */ + if(path == NULL) goto done; /* defensive driving */ + + /* Check for path debug env vars */ + if(pathdebug < 0) { + const char* s = getenv("NCPATHDEBUG"); + pathdebug = (s == NULL ? 0 : 1); + } + pathlen = strlen(path); /* 1. look for MSYS path /D/... */ @@ -57,7 +68,7 @@ NCpathcvt(const char* path) && (path[2] == '/' || path[2] == '\\' || path[2] == '\0')) { /* Assume this is a mingw path */ outpath = (char*)malloc(pathlen+3); /* conservative */ - if(outpath == NULL) return NULL; + if(outpath == NULL) goto done; q = outpath; *q++ = path[1]; *q++ = ':'; @@ -76,8 +87,8 @@ NCpathcvt(const char* path) || path[cdlen+1] == '\0')) { /* Assume this is a cygwin path */ outpath = (char*)malloc(pathlen+1); /* conservative */ - if(outpath == NULL) return NULL; - outpath[0] = path[cdlen]; + if(outpath == NULL) goto done; + outpath[0] = path[cdlen]; /* drive letter */ outpath[1] = ':'; strcpy(&outpath[2],&path[cdlen+1]); if(strlen(outpath) == 2) @@ -99,12 +110,31 @@ NCpathcvt(const char* path) goto done; slashtrans: - /* In all #1 or #2 cases, translate '/' -> '\\' */ + /* In order to help debugging, and if not using MSC_VER or MINGW, + convert back slashes to forward, else convert forward to back + */ p = outpath; + /* In all #1 or #2 cases, translate '/' -> '\\' */ for(;*p;p++) { if(*p == '/') {*p = '\\';} } +#ifdef PATHFORMAT +#ifndef _MSC_VER + p = outpath; + /* Convert '\' back to '/' */ + for(;*p;p++) { + if(*p == '\\') {*p = '/';} + } + } +#endif /*!_MSC_VER*/ +#endif /*PATHFORMAT*/ + done: + if(pathdebug) { + fprintf(stderr,"XXXX: inpath=|%s| outpath=|%s|\n", + path?path:"NULL",outpath?outpath:"NULL"); + fflush(stderr); + } return outpath; } @@ -120,8 +150,6 @@ NCfopen(const char* path, const char* flags) { FILE* f = NULL; char* cvtname = NCpathcvt(path); -fprintf(stderr,"XXXX: path=|%s| cvtpath=|%s|\n",path,cvtname?cvtname:"null"); -fflush(stderr); if(cvtname == NULL) return NULL; f = fopen(cvtname,flags); free(cvtname); @@ -133,10 +161,8 @@ int NCopen3(const char* path, int flags, int mode) { int fd = -1; - fprintf(stderr,"XXXX: path=|%s|\n",path); fflush(stderr); char* cvtname = NCpathcvt(path); - fprintf(stderr,"XXXX: path=|%s| cvtpath=|%s|\n",path,cvtname?cvtname:"null"); fflush(stderr); if(cvtname == NULL) return -1; fd = open(cvtname,flags,mode); diff --git a/libdispatch/ncuri.c b/libdispatch/ncuri.c index 2d922cef3..7acf16e84 100644 --- a/libdispatch/ncuri.c +++ b/libdispatch/ncuri.c @@ -19,6 +19,9 @@ #define NCURIDEBUG +/* Extra debug info */ +#undef NCXDEBUG + #ifdef NCURIDEBUG #define THROW(n) {ret=(n); goto done;} #else @@ -314,10 +317,7 @@ ncuriparse(const char* uri0, NCURI** durip) if(strlen(pp)==0) {THROW(NCU_EUSRPWD);} /* we have empty password */ tmp.password = pp; - /* compress usr+pwd out of tmp.host */ - rem = strlen(newhost); - memmove(tmp.host,newhost,rem); - tmp.host[rem] = EOFCHAR; + tmp.host = newhost; } /* Breakup host into host + port */ pp = tmp.host; diff --git a/libdispatch/test_ncuri.c b/libdispatch/test_ncuri.c index dcf9ad340..957b41ad0 100644 --- a/libdispatch/test_ncuri.c +++ b/libdispatch/test_ncuri.c @@ -35,11 +35,13 @@ static Test TESTS[] = { {"[dap4]http://localhost:8081/x#show=fetch&log","http://localhost:8081/x#dap4&show=fetch&log"}, /* suffix param tests with constraint*/ {"http://localhost:8081/x?dap4.ce=x#dap4&show=fetch&log","http://localhost:8081/x?dap4.ce=x#dap4&show=fetch&log"}, +/* Test embedded user+pwd */ +{"http://tiggeUser:tigge@localhost:8081/thredds/dodsC/restrict/testData.nc", + "http://tiggeUser:tigge@localhost:8081/thredds/dodsC/restrict/testData.nc"}, /* Misc. */ {"http://localhost","http://localhost/"}, {"http:///x","http:///x"}, {"file:///home/osboxes/git/dap4/dap4_test/daptestfiles/test_anon_dim.2.syn#dap4&debug=copy&substratename=./results/test_anon_dim.2.syn.nc","file:///home/osboxes/git/dap4/dap4_test/daptestfiles/test_anon_dim.2.syn#dap4&debug=copy&substratename=./results/test_anon_dim.2.syn.nc"}, - {NULL,NULL} }; diff --git a/libdispatch/test_pathcvt.c b/libdispatch/test_pathcvt.c index 14959d6ce..e277e92ea 100644 --- a/libdispatch/test_pathcvt.c +++ b/libdispatch/test_pathcvt.c @@ -12,7 +12,6 @@ Test the NCpathcvt #include #include "ncwinpath.h" -#undef WINDEBUG #undef VERBOSE typedef struct Test { diff --git a/liblib/Makefile.am b/liblib/Makefile.am index 5c0949de9..0a7b344c3 100644 --- a/liblib/Makefile.am +++ b/liblib/Makefile.am @@ -70,6 +70,11 @@ libnetcdf_la_LIBADD += ${top_builddir}/libsrc4/libnetcdf4.la endif #USE_NETCDF4 +if ISCYGWIN +# Force binary mode for file read/write +AM_LDFLAGS += -lbinmode +endif + # We need at least one source file libnetcdf_la_SOURCES = nc_initialize.c EXTRA_DIST=CMakeLists.txt diff --git a/liblib/nc_initialize.c b/liblib/nc_initialize.c index cd03f824b..30da3e23c 100644 --- a/liblib/nc_initialize.c +++ b/liblib/nc_initialize.c @@ -35,6 +35,11 @@ extern int NCP_initialize(void); extern int NCP_finalize(void); #endif +#ifdef _MSC_VER +#include +#include +#endif + int NC_argc = 1; char* NC_argv[] = {"nc_initialize",NULL}; @@ -59,6 +64,11 @@ nc_initialize() NC_initialized = 1; NC_finalized = 0; +#ifdef _MSC_VER + /* Force binary mode */ + _set_fmode(_O_BINARY); +#endif + /* Do general initialization */ if((stat = NCDISPATCH_initialize())) goto done; diff --git a/libsrc/nc3internal.c b/libsrc/nc3internal.c index 3363828dd..03a483568 100644 --- a/libsrc/nc3internal.c +++ b/libsrc/nc3internal.c @@ -1113,7 +1113,7 @@ NC3_open(const char * path, int ioflags, #if defined(LOCKNUMREC) /* && _CRAYMPP */ if (status = NC_init_pe(nc3, basepe)) { - return status; + goto unwind_alloc; } #else /* @@ -1121,9 +1121,11 @@ NC3_open(const char * path, int ioflags, */ if(basepe != 0) { if(nc3) free(nc3); - return NC_EINVAL; + status = NC_EINVAL; + goto unwind_alloc; } #endif + status = ncio_open(path, ioflags, 0, 0, &nc3->chunk, parameters, &nc3->nciop, NULL); if(status) diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index c00809712..faeb4bf0d 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -25,10 +25,7 @@ extern int nc4_vararray_add(NC_GRP_INFO_T *grp, #ifdef USE_HDF4 #include #endif - -#ifdef USE_DISKLESS #include -#endif /* When we have open objects at file close, should we log them or print to stdout. Default is to log @@ -302,9 +299,7 @@ nc_check_for_hdf(const char *path, int flags, void* parameters, int *hdf_file) MPI_Info info = MPI_INFO_NULL; #endif int inmemory = ((flags & NC_INMEMORY) == NC_INMEMORY); -#ifdef USE_DISKLESS NC_MEM_INFO* meminfo = (NC_MEM_INFO*)parameters; -#endif #ifdef USE_PARALLEL4 if(use_parallel) { @@ -602,15 +597,15 @@ NC4_create(const char* path, int cmode, size_t initialsz, int basepe, /* Check the cmode for validity. */ if((cmode & ILLEGAL_CREATE_FLAGS) != 0) - return NC_EINVAL; + {res = NC_EINVAL; goto done;} /* Cannot have both */ if((cmode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX)) - return NC_EINVAL; + {res = NC_EINVAL; goto done;} /* Currently no parallel diskless io */ if((cmode & (NC_MPIIO | NC_MPIPOSIX)) && (cmode & NC_DISKLESS)) - return NC_EINVAL; + {res = NC_EINVAL; goto done;} #ifndef USE_PARALLEL_POSIX /* If the HDF5 library has been compiled without the MPI-POSIX VFD, alias @@ -636,8 +631,10 @@ NC4_create(const char* path, int cmode, size_t initialsz, int basepe, LOG((2, "cmode after applying default format: 0x%x", cmode)); nc_file->int_ncid = nc_file->ext_ncid; - res = nc4_create_file(nc_file->path, cmode, comm, info, nc_file); + res = nc4_create_file(path, cmode, comm, info, nc_file); + +done: return res; } @@ -2231,9 +2228,7 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc) int retval; NC_HDF5_FILE_INFO_T* nc4_info = NULL; int inmemory = ((mode & NC_INMEMORY) == NC_INMEMORY); -#ifdef USE_DISKLESS NC_MEM_INFO* meminfo = (NC_MEM_INFO*)parameters; -#endif #ifdef USE_PARALLEL4 NC_MPI_INFO* mpiinfo = (NC_MPI_INFO*)parameters; int comm_duped = 0; /* Whether the MPI Communicator was duplicated */ @@ -2845,11 +2840,11 @@ NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp, /* Check the mode for validity */ if((mode & ILLEGAL_OPEN_FLAGS) != 0) - return NC_EINVAL; + {res = NC_EINVAL; goto done;} /* Cannot have both */ if((mode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX)) - return NC_EINVAL; + {res = NC_EINVAL; goto done;} #ifndef USE_PARALLEL_POSIX /* If the HDF5 library has been compiled without the MPI-POSIX VFD, alias @@ -2864,7 +2859,7 @@ NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp, /* Figure out if this is a hdf4 or hdf5 file. */ if ((res = nc_check_for_hdf(path, use_parallel, parameters, &hdf_file))) - return res; + goto done; /* Depending on the type of file, open it. */ nc_file->int_ncid = nc_file->ext_ncid; @@ -2872,12 +2867,13 @@ NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp, res = nc4_open_file(path, mode, parameters, nc_file); #ifdef USE_HDF4 else if (hdf_file == NC_HDF4_FILE && inmemory) - return NC_EDISKLESS; + {res = NC_EDISKLESS; goto done;} else if (hdf_file == NC_HDF4_FILE) res = nc4_open_hdf4_file(path, mode, nc_file); #endif /* USE_HDF4 */ else - assert(0); /* should never happen */ + assert(0); /* should never happen */ +done: return res; } diff --git a/libsrc4/nc4internal.c b/libsrc4/nc4internal.c index fe6e2f6a9..6ad753799 100644 --- a/libsrc4/nc4internal.c +++ b/libsrc4/nc4internal.c @@ -102,6 +102,11 @@ nc4_check_name(const char *name, char *norm_name) retval = nc_utf8_normalize((const unsigned char *)name,(unsigned char**)&temp); if(retval != NC_NOERR) return retval; + if( strlen(temp) > NC_MAX_NAME ) + { + free(temp); + return NC_EMAXNAME; + } strcpy(norm_name, temp); free(temp); diff --git a/libsrcp/ncpdispatch.c b/libsrcp/ncpdispatch.c index 19b2d31a2..04f5ec8a6 100644 --- a/libsrcp/ncpdispatch.c +++ b/libsrcp/ncpdispatch.c @@ -9,6 +9,7 @@ #include #include "nc.h" #include "ncdispatch.h" + /* Must follow netcdf.h */ #include @@ -50,15 +51,15 @@ NCP_create(const char *path, int cmode, /* Check the cmode for only valid flags*/ if(cmode & ~LEGAL_CREATE_FLAGS) - return NC_EINVAL; + {res = NC_EINVAL; goto done;} /* Cannot have both MPIO flags */ if((cmode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX)) - return NC_EINVAL; + {res = NC_EINVAL; goto done;} /* Cannot have both NC_64BIT_OFFSET & NC_64BIT_DATA */ if((cmode & (NC_64BIT_OFFSET|NC_64BIT_DATA)) == (NC_64BIT_OFFSET|NC_64BIT_DATA)) - return NC_EINVAL; + {res = NC_EINVAL; goto done;} default_format = nc_get_default_format(); /* if (default_format == NC_FORMAT_CLASSIC) then we respect the format set in cmode */ @@ -72,14 +73,17 @@ NCP_create(const char *path, int cmode, } /* No MPI environment initialized */ - if (mpidata == NULL) return NC_ENOPAR; + if (mpidata == NULL) + {res = NC_ENOPAR; goto done;} comm = ((NC_MPI_INFO *)mpidata)->comm; info = ((NC_MPI_INFO *)mpidata)->info; /* Create our specific NCP_INFO instance */ + nc5 = (NCP_INFO*)calloc(1,sizeof(NCP_INFO)); - if(nc5 == NULL) return NC_ENOMEM; + if(nc5 == NULL) + {res = NC_ENOMEM; goto done;} /* Link nc5 and nc */ NCP_DATA_SET(nc,nc5); @@ -97,9 +101,11 @@ NCP_create(const char *path, int cmode, */ /* PnetCDF recognizes the flags below for create and ignores NC_LOCK and NC_SHARE */ cmode &= (NC_WRITE | NC_NOCLOBBER | NC_SHARE | NC_64BIT_OFFSET | NC_64BIT_DATA); + res = ncmpi_create(comm, path, cmode, info, &(nc->int_ncid)); if(res && nc5 != NULL) free(nc5); /* reclaim allocated space */ +done: return res; } @@ -116,16 +122,15 @@ NCP_open(const char *path, int cmode, /* Check the cmode for only valid flags*/ if(cmode & ~LEGAL_OPEN_FLAGS) - return NC_EINVAL; + {res = NC_EINVAL; goto done;} /* Cannot have both MPIO flags */ if((cmode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX)) - return NC_EINVAL; + {res = NC_EINVAL; goto done;} /* Appears that this comment is wrong; allow 64 bit offset*/ /* Cannot have 64 bit offset flag */ - /* if(cmode & (NC_64BIT_OFFSET)) return NC_EINVAL; */ - + /* if(cmode & (NC_64BIT_OFFSET)) {res = NC_EINVAL; goto done;} */ if(mpidata != NULL) { comm = ((NC_MPI_INFO *)mpidata)->comm; info = ((NC_MPI_INFO *)mpidata)->info; @@ -145,7 +150,7 @@ NCP_open(const char *path, int cmode, /* Create our specific NCP_INFO instance */ nc5 = (NCP_INFO*)calloc(1,sizeof(NCP_INFO)); - if(nc5 == NULL) return NC_ENOMEM; + if(nc5 == NULL) {res = NC_ENOMEM; goto done;} /* Link nc5 and nc */ NCP_DATA_SET(nc,nc5); @@ -157,7 +162,7 @@ NCP_open(const char *path, int cmode, res = ncmpi_begin_indep_data(nc->int_ncid); nc5->pnetcdf_access_mode = NC_INDEPENDENT; } - +done: return res; } diff --git a/nc_test/large_files.c b/nc_test/large_files.c index cd2352636..f92d78543 100644 --- a/nc_test/large_files.c +++ b/nc_test/large_files.c @@ -3,7 +3,7 @@ See COPYRIGHT file for copying and redistribution conditions. This is part of netCDF. - + This program also takes a long time to run - it writes some data in a very large file, and then reads it all back to be sure it's correct. @@ -47,11 +47,13 @@ main(int argc, char **argv) { int n_dim; #define NUMRECS 2 -#define I_LEN 5 -#if 0 -#define J_LEN 214700000 -#endif -#define J_LEN 500000000 +#define I_LEN 4106 + //#define I_LEN 5 + //#if 0 + //#define J_LEN 214700000 + //#endif + //#define J_LEN 500000000 +#define J_LEN 1023 #define K_LEN 1023 #define N_LEN 2 @@ -157,7 +159,7 @@ main(int argc, char **argv) { check_err(stat,__LINE__,__FILE__); { /* read var1 */ - + /*static float avar1[J_LEN];*/ static float *avar1 = NULL; avar1 = (float*)malloc(sizeof(float)*J_LEN); @@ -172,11 +174,11 @@ main(int argc, char **argv) { avar1_start[1] = i; stat = nc_get_vara_float(ncid, var1_id, avar1_start, avar1_count, avar1); check_err(stat,__LINE__,__FILE__); - for(j=0; j ./t_dap3a.c cat t_dap.c >> t_dap3a.c -t_dap4a.c: t_dap.c - cat t_dap.c >> ./t_dap4a.c - # One last thing BUILT_SOURCES = .dodsrc diff --git a/ncdap_test/t_dap.c b/ncdap_test/t_dap.c index ae7160b49..ba3bdacb9 100644 --- a/ncdap_test/t_dap.c +++ b/ncdap_test/t_dap.c @@ -307,6 +307,7 @@ int main() printf("ncstat=%d %s",ncstat,nc_strerror(ncstat)); exit(1); } + nc_close(ncid); return 0; } diff --git a/ncdap_test/t_dap3a.c b/ncdap_test/t_dap3a.c index 64bcb1b74..1ee374487 100644 --- a/ncdap_test/t_dap3a.c +++ b/ncdap_test/t_dap3a.c @@ -308,6 +308,7 @@ int main() printf("ncstat=%d %s",ncstat,nc_strerror(ncstat)); exit(1); } + nc_close(ncid); return 0; } diff --git a/ncdap_test/test_cvt.c b/ncdap_test/test_cvt.c index 112b2b4f1..2e9500a0e 100644 --- a/ncdap_test/test_cvt.c +++ b/ncdap_test/test_cvt.c @@ -307,6 +307,7 @@ int main() printf("ncstat=%d %s",ncstat,nc_strerror(ncstat)); exit(1); } + nc_close(ncid); return 0; } diff --git a/ncdap_test/test_varm3.c b/ncdap_test/test_varm3.c index 84bd767d4..30c5782dd 100644 --- a/ncdap_test/test_varm3.c +++ b/ncdap_test/test_varm3.c @@ -251,6 +251,7 @@ main() } printf("*** %s: stride case 3\n",(fail?"Fail":"Pass")); + nc_close(ncid); return fail; } diff --git a/ncdap_test/testauth.sh b/ncdap_test/testauth.sh index 536a22761..02dd6769c 100755 --- a/ncdap_test/testauth.sh +++ b/ncdap_test/testauth.sh @@ -3,6 +3,9 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi . ../test_common.sh +# Enable if using localhost +LOCAL=1 + RCEMBED=1 RCLOCAL=1 RCHOME=1 @@ -40,10 +43,13 @@ fi BASICCOMBO="tiggeUser:tigge" BADCOMBO="tiggeUser:xxxxx" -URLSERVER="remotetest.unidata.ucar.edu" -#http://remotetest.unidata.ucar.edu/thredds/dodsC/restrict/testData.nc.html -URLPATH="thredds/dodsC/restrict/testData.nc" +URLPATH="thredds/dodsC/testRestrictedDataset/testData2.nc" PROTO=http +if test "x$LOCAL" = x ; then +URLSERVER="remotetest.unidata.ucar.edu" +else +URLSERVER="localhost:8081" +fi # See if we need to override if test "x$URS" != "x" ; then diff --git a/ncdap_test/tst_ber.sh b/ncdap_test/tst_ber.sh new file mode 100755 index 000000000..fe1d3ab9c --- /dev/null +++ b/ncdap_test/tst_ber.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +export SETX=1 +#export NCPATHDEBUG=1 + +if test "x$srcdir" = x ; then srcdir=`pwd`; fi +. ../test_common.sh + +F="ber-2002-10-01.nc" +EXPECTED="${srcdir}/expected3" + +URL='[log][cache]file://' +URL="${URL}${srcdir}/testdata3/$F" +rm -f ./tmp +${NCDUMP} "${URL}" | sed 's/\\r//g' > ./tmp +diff -w ${EXPECTED}/$F.dmp ./tmp +#cleanup +rm -f ./tmp +exit diff --git a/ncdap_test/tst_ncdap.sh b/ncdap_test/tst_ncdap.sh index ca1c61dd9..bf12df1c4 100755 --- a/ncdap_test/tst_ncdap.sh +++ b/ncdap_test/tst_ncdap.sh @@ -74,9 +74,9 @@ for x in ${TESTSET} ; do done ok=1 echo command: ${VALGRIND} ${NCDUMP} ${FLAGS} "${url}" - if ${VALGRIND} ${NCDUMP} ${FLAGS} "${url}" > ${x}.dmp ; then ok=$ok; else ok=0; fi + if ${VALGRIND} ${NCDUMP} ${FLAGS} "${url}" | sed 's/\\r//g' > ${x}.dmp ; then ok=$ok; else ok=0; fi # compare with expected - if diff -w ${EXPECTED}/${x}.dmp ${x}.dmp ; then ok=$ok; else ok=0; fi + if diff -w ${EXPECTED}/${x}.dmp ${x}.dmp ; then ok=$ok; else ok=0; fi if test "$ok" = 1 ; then status=0 # succeed elif test "x$isxfail" = "x0" ; then @@ -84,7 +84,7 @@ for x in ${TESTSET} ; do else status=2 # xfail fi - + case "$status" in 0) passcount=`expr $passcount + 1` diff --git a/ncdap_test/tst_ncdap_shared.sh b/ncdap_test/tst_ncdap_shared.sh index 79acd1ad9..00bee51b6 100755 --- a/ncdap_test/tst_ncdap_shared.sh +++ b/ncdap_test/tst_ncdap_shared.sh @@ -34,11 +34,12 @@ test.vs2 test.vs3 test.vs4 test.vs5 whoi" ACTUALDATA2=\ "123bears.nc 123.nc bears.nc \ -ber-2002-10-01.nc ceopL2AIRS2-2.nc \ +ceopL2AIRS2-2.nc \ data.nc fnoc1.nc \ in1.nc in_2.nc in.nc \ in_no_three_double_dmn.nc in_v.nc saco1.nc \ test.nc text.nc \ +ber-2002-10-01.nc \ kwcase.nc" # XFAIL tests should be a subset of the other tests; this is used diff --git a/oc2/oc.c b/oc2/oc.c index 2d9df83c9..a3740c7eb 100644 --- a/oc2/oc.c +++ b/oc2/oc.c @@ -14,6 +14,7 @@ #include "occlientparams.h" #include "occurlfunctions.h" #include "ochttp.h" +#include "ncwinpath.h" #undef TRACK @@ -2085,11 +2086,10 @@ oc_set_netrc(OClink* link, const char* file) if(file == NULL || strlen(file) == 0) return OC_EINVAL; nclog(OCLOGDBG,"OC: using netrc file: %s",file); - /* See if it exists and is readable; complain if not */ - f = fopen(file,"r"); - if(f == NULL) - nclog(NCLOGWARN,"OC: netrc file is not readable; continuing"); - else { + /* See if it exists and is readable; ignore if not */ + f = NCfopen(file,"r"); + if(f != NULL) { /* Log what rc file is being used */ + nclog(NCLOGNOTE,"OC: netrc file found: %s",file); fclose(f); } return OCTHROW(ocset_netrc(state,file)); @@ -2142,7 +2142,7 @@ oc_set_rcfile(const char* rcfile) if(rcfile == NULL) { ocglobalstate.rc.ignore = 1; } else { - FILE* f = fopen(rcfile,"r"); + FILE* f = NCfopen(rcfile,"r"); if(f == NULL) { stat = (OC_ERCFILE); goto done; diff --git a/oc2/ocinternal.c b/oc2/ocinternal.c index 34cd03e62..29a74ed5e 100644 --- a/oc2/ocinternal.c +++ b/oc2/ocinternal.c @@ -10,12 +10,16 @@ #ifdef HAVE_SYS_STAT_H #include #endif -#if defined(_WIN32) || defined(_WIN64) +#if _MSC_VER #include #include #include #endif +#ifdef HAVE_FTW_H +#include +#endif + #include #include "ocinternal.h" @@ -25,31 +29,20 @@ #include "ochttp.h" #include "ocread.h" #include "dapparselex.h" +#include "ncwinpath.h" #define DATADDSFILE "datadds" -#if 0 -/* Note: TMPPATH must end in '/' */ -#ifdef __CYGWIN__ -#define TMPPATH1 "/cygdrive/c/temp/datadds" -#define TMPPATH2 "./datadds" -#elif defined(_WIN32) || defined(_WIN64) -#define TMPPATH1 "c:\\temp\\datadds" -#define TMPPATH2 ".\\datadds" -#else -#define TMPPATH1 "/tmp/datadds" -#define TMPPATH2 "./datadds" -#endif -#endif - #define CLBRACE '{' #define CRBRACE '}' +/*Forward*/ static OCerror ocextractddsinmemory(OCstate*,OCtree*,int); static OCerror ocextractddsinfile(OCstate*,OCtree*,int); static char* constraintescape(const char* url); static OCerror createtempfile(OCstate*,OCtree*); static int dataError(XXDR* xdrs, OCstate*); +static void ocremovefile(const char* path); static OCerror ocset_curlproperties(OCstate*); @@ -88,7 +81,7 @@ ocinternalinitialize(void) char* p; char* q; char cwd[4096]; -#if defined(_WIN32) || defined(_WIN64) +#ifdef _MSC_VER tempdir = getenv("TEMP"); #else tempdir = "/tmp"; @@ -105,7 +98,7 @@ ocinternalinitialize(void) *q = *p; } *q = '\0'; -#if defined(_WIN32) || defined(_WIN64) +#ifdef _MSC_VER #else /* Canonicalize */ for(p=ocglobalstate.tempdir;*p;p++) { @@ -132,7 +125,7 @@ ocinternalinitialize(void) *q = *p; } *q = '\0'; -#if defined(_WIN32) || defined(_WIN64) +#ifdef _MSC_VER #else /* Canonicalize */ for(p=home;*p;p++) { @@ -387,10 +380,11 @@ createtempfile(OCstate* state, OCtree* tree) #endif tree->data.filename = name; /* remember our tmp file name */ name = NULL; - tree->data.file = fopen(tree->data.filename,"w+"); + tree->data.file = NCfopen(tree->data.filename,"w+"); if(tree->data.file == NULL) return OC_EOPEN; - /* unlink the temp file so it will automatically be reclaimed */ - if(ocdebug == 0) unlink(tree->data.filename); + /* make the temp file so it will automatically be reclaimed on close */ + if(ocdebug == 0) + ocremovefile(tree->data.filename); return stat; fail: @@ -422,19 +416,11 @@ occlose(OCstate* state) ocfree(state->error.message); ocfree(state->curlflags.useragent); if(state->curlflags.cookiejar) { -#if 0 if(state->curlflags.createdflags & COOKIECREATED) - unlink(state->curlflags.cookiejar); -#endif + ocremovefile(state->curlflags.cookiejar); ocfree(state->curlflags.cookiejar); } - if(state->curlflags.netrc != NULL) { -#if 0 - if(state->curlflags.createdflags & NETRCCREATED) - unlink(state->curlflags.netrc); -#endif - ocfree(state->curlflags.netrc); - } + ocfree(state->curlflags.netrc); ocfree(state->ssl.certificate); ocfree(state->ssl.key); ocfree(state->ssl.keypasswd); @@ -606,26 +592,23 @@ ocset_curlproperties(OCstate* state) if(state->curlflags.cookiejar == NULL) { /* If no cookie file was defined, define a default */ - char tmp[OCPATHMAX+1]; int stat; -#if defined(_WIN32) || defined(_WIN64) - int pid = _getpid(); -#else - pid_t pid = getpid(); -#endif - snprintf(tmp,sizeof(tmp)-1,"%s/%s.%ld/",ocglobalstate.tempdir,OCDIR,(long)pid); -#ifdef _WIN32 - stat = mkdir(tmp); -#else - stat = mkdir(tmp,S_IRUSR | S_IWUSR | S_IXUSR); -#endif - if(stat != 0 && errno != EEXIST) { - fprintf(stderr,"Cannot create cookie directory\n"); - goto fail; - } + char* path = NULL; + char* name = NULL; + int len; errno = 0; /* Create the unique cookie file name */ - stat = ocmktmp(tmp,&state->curlflags.cookiejar); + len = + strlen(ocglobalstate.tempdir) + + 1 /* '/' */ + + strlen("occookies"); + path = (char*)malloc(len+1); + if(path == NULL) return OC_ENOMEM; + occopycat(path,len,3,ocglobalstate.tempdir,"/","occookies"); + stat = ocmktmp(path,&name); +fprintf(stderr,"%s => %s\n",state->uri->uri,name); fflush(stderr); + free(path); + state->curlflags.cookiejar = name; state->curlflags.createdflags |= COOKIECREATED; if(stat != OC_NOERR && errno != EEXIST) { fprintf(stderr,"Cannot create cookie file\n"); @@ -640,17 +623,17 @@ ocset_curlproperties(OCstate* state) FILE* f = NULL; char* fname = state->curlflags.cookiejar; /* See if the file exists already */ - f = fopen(fname,"r"); + f = NCfopen(fname,"r"); if(f == NULL) { /* Ok, create it */ - f = fopen(fname,"w+"); + f = NCfopen(fname,"w+"); if(f == NULL) { fprintf(stderr,"Cookie file cannot be read and written: %s\n",fname); {stat = OC_EPERM; goto fail;} } } else { /* test if file can be written */ fclose(f); - f = fopen(fname,"r+"); + f = NCfopen(fname,"r+"); if(f == NULL) { fprintf(stderr,"Cookie file is cannot be written: %s\n",fname); {stat = OC_EPERM; goto fail;} @@ -756,3 +739,13 @@ ocset_netrc(OCstate* state, const char* path) stat = ocset_curlflag(state,CURLOPT_NETRC); return stat; } + +static void +ocremovefile(const char* path) +{ +#ifdef _MSC_VER + DeleteFile(path); +#else + remove(path); +#endif +} diff --git a/oc2/ocinternal.h b/oc2/ocinternal.h index b1a75a0e1..a954c3cb7 100644 --- a/oc2/ocinternal.h +++ b/oc2/ocinternal.h @@ -116,7 +116,7 @@ typedef struct OCheader { #define nullstring(s) (s==NULL?"(null)":s) #define PATHSEPARATOR "." -#define OCDIR "oc" +#define OCCOOKIEDIR "occookies" /* Define infinity for memory size */ #if SIZEOF_SIZE_T == 4 @@ -199,7 +199,6 @@ struct OCstate { char* useragent; /*CURLOPT_USERAGENT*/ /* track which of these are created by oc */ #define COOKIECREATED 1 -#define NETRCCREATED 2 int createdflags; char* cookiejar; /*CURLOPT_COOKIEJAR,CURLOPT_COOKIEFILE*/ char* netrc; /*CURLOPT_NETRC,CURLOPT_NETRC_FILE*/ diff --git a/oc2/ocrc.c b/oc2/ocrc.c index 6ffc6a9c9..d000e75d2 100644 --- a/oc2/ocrc.c +++ b/oc2/ocrc.c @@ -13,6 +13,7 @@ #include "ocinternal.h" #include "ocdebug.h" #include "nclog.h" +#include "ncwinpath.h" #define OCRCFILEENV "DAPRCFILE" @@ -279,7 +280,7 @@ ocrc_compile(const char* path) ocrc->ntriples = 0; /* reset; nothing to free */ - in_file = fopen(path, "r"); /* Open the file to read it */ + in_file = NCfopen(path, "r"); /* Open the file to read it */ if (in_file == NULL) { nclog(NCLOGERR, "Could not open configuration file: %s",path); return OC_EPERM; @@ -714,9 +715,7 @@ rc_search(const char* prefix, const char* rcname, char** pathp) goto done; } /* see if file is readable */ - f = fopen(path,"r"); - if(f != NULL) - nclog(NCLOGDBG, "Found rc file=%s",path); + f = NCfopen(path,"r"); done: if(f == NULL || stat != OC_NOERR) { if(path != NULL) diff --git a/oc2/ocread.c b/oc2/ocread.c index aec723292..95d8e289f 100644 --- a/oc2/ocread.c +++ b/oc2/ocread.c @@ -13,12 +13,16 @@ #endif #ifdef _WIN32 #include +#ifndef O_BINARY +#define O_BINARY _O_BINARY +#endif #endif #include "ocinternal.h" #include "ocdebug.h" #include "ochttp.h" #include "ocread.h" #include "occurlfunctions.h" +#include "ncwinpath.h" /*Forward*/ static int readpacket(OCstate* state, NCURI*, NCbytes*, OCdxd, long*); @@ -214,10 +218,11 @@ readfile(const char* path, const char* suffix, NCbytes* packet) #ifdef O_BINARY flags |= O_BINARY; #endif - fd = open(filename,flags); + fd = NCopen2(filename,flags); if(fd < 0) { - nclog(NCLOGERR,"open failed:%s",filename); - return OCTHROW(OC_EOPEN); + nclog(NCLOGERR,"open failed: %s file=|%s|",ocerrstring(errno),filename); + stat = OC_EOPEN; + goto done; } /* Get the file size */ filesize = lseek(fd,(off_t)0,SEEK_END); diff --git a/oc2/ocutil.c b/oc2/ocutil.c index 5ad420043..bfa714365 100644 --- a/oc2/ocutil.c +++ b/oc2/ocutil.c @@ -721,9 +721,9 @@ ocmktmp(const char* base, char** tmpnamep) return OC_EOVERRUN; } #if defined(_WIN32) || defined(_WIN64) - fd=open(tmpname,O_RDWR|O_BINARY|O_CREAT, _S_IREAD|_S_IWRITE); + fd=NCopen3(tmpname,O_RDWR|O_BINARY|O_CREAT, _S_IREAD|_S_IWRITE); # else - fd=open(tmpname,O_RDWR|O_CREAT|O_EXCL, S_IRWXU); + fd=NCopen3(tmpname,O_RDWR|O_CREAT|O_EXCL, S_IRWXU); # endif } #endif /* !HAVE_MKSTEMP */