diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..2b663cc8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +CMakeLists.txt export-subst diff --git a/.github/workflows/build_test_wheels.yml b/.github/workflows/build_test_wheels.yml new file mode 100644 index 00000000..e34de4e0 --- /dev/null +++ b/.github/workflows/build_test_wheels.yml @@ -0,0 +1,166 @@ +name: test building and upload wheels to testpypi + +on: + push: + branches: + - release/* + - main + +jobs: + build_wheels: + # name: build wheels on ${{matrix.os}} ${{matrix.arch}} + name: build wheels on ${{matrix.build-platform[0]}} ${{matrix.build-platform[1]}} + # runs-on: ${{matrix.os}} + runs-on: ${{matrix.build-platform[0]}} + strategy: + fail-fast: false + matrix: + build-platform: + # skip longer-running builds + # - [ubuntu-latest, x86_64, manylinux2014_x86_64] + - [ubuntu-latest, x86_64, manylinux_2_28_x86_64] + # - [ubuntu-latest,aarch64,manylinux_2_28_aarch64] + - [macos-13, x86_64, macosx_x86_64] + - [macos-14, arm64, macosx_arm64] + + steps: + - uses: actions/checkout@v3 + # need git tags available for setuptools_scm to grab tags? will lead to slower checkout + with: + fetch-depth: 0 + + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v3 + with: + platforms: all + + - name: Build manylinux2014 wheels + if: startswith(matrix.build-platform[2], 'manylinux2014') + uses: pypa/cibuildwheel@v2.17.0 + with: + package-dir: ./source/wrappers/python + config-file: ./source/wrappers/python/pyproject.toml + env: + CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 + CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 + CIBW_ARCHS: ${{matrix.build-platform[1]}} + CIBW_BUILD: cp*-manylinux* + CIBW_SKIP: cp*-musllinux* *-musllinux* + CIBW_BEFORE_ALL: > + yum update -y && + yum install -y wget openssl-devel libxml2-devel libtirpc-devel && + cd /tmp && + wget https://github.com/fmtlib/fmt/archive/refs/tags/10.0.0.tar.gz && + tar xzf 10.0.0.tar.gz && + cd fmt-10.0.0 && + cmake -Bbuild -H. -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && + cmake --build build -j --config Release --target install && + cd /tmp && + wget https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz && + tar xzf v1.11.0.tar.gz && + cd spdlog-1.11.0 && + cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && + cmake --build build -j --config Release --target install && + cd /tmp && + wget https://github.com/capnproto/capnproto/archive/refs/tags/v0.10.4.tar.gz && + tar xzf v0.10.4.tar.gz && + cd capnproto-0.10.4 && + cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && + cmake --build build && + cmake --install build && + cd /tmp && + wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz && + tar xzf boost_1_80_0.tar.gz && + cd boost_1_80_0 && + ./bootstrap.sh --prefix=/usr/local && + ./b2 --without-python --prefix=/usr/local install && + cd /project && + cmake -B build -DNO_JAVA_WRAPPER=ON -DBUILD_SHARED_LIBS=ON -DSSLAUTHENTICATION=ON -DENABLE_CAPNP=ON -DCLIENT_ONLY=ON && + cmake --build build -j --config Release --target install && + cp -r /usr/local/python_installer/* /project/source/wrappers/python/ + + - name: Build manylinux_2_28 wheels + if: startswith(matrix.build-platform[2], 'manylinux_2_28') + uses: pypa/cibuildwheel@v2.17.0 + with: + package-dir: ./source/wrappers/python + config-file: ./source/wrappers/python/pyproject.toml + env: + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 + CIBW_ARCHS: ${{matrix.build-platform[1]}} + CIBW_BUILD: cp*-manylinux* + CIBW_SKIP: cp*-musllinux* *-musllinux* + CIBW_BEFORE_ALL: > + dnf update -y && + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm && + dnf install -y boost-devel openssl-devel libxml2-devel libtirpc-devel + fmt fmt-devel spdlog spdlog-devel capnproto capnproto-devel && + cd /project && + cmake -B build + -DBUILD_SHARED_LIBS=ON + -DCMAKE_BUILD_TYPE=Release + -DSSLAUTHENTICATION=ON + -DNO_JAVA_WRAPPER=ON + -DENABLE_CAPNP=ON -DCLIENT_ONLY=ON && + cmake --build build -j --config Release --target install && + cp -r /usr/local/python_installer/* /project/source/wrappers/python/ + + - name: build uda on macos + if: runner.os == 'macOS' + run: > + brew update-reset && brew install + git + boost + openssl + cmake + libxml2 + spdlog + capnp && + cd ${{github.workspace}} && + cmake -B build + -DBUILD_SHARED_LIBS=ON + -DCMAKE_BUILD_TYPE=Release + -DSSLAUTHENTICATION=ON + -DENABLE_CAPNP=ON + -DNO_JAVA_WRAPPER=ON + -DCMAKE_INSTALL_PREFIX=$PWD/install + -DCLIENT_ONLY=ON && + cmake --build build -j --config Release --target install && + cp -r $PWD/install/python_installer/* ${{github.workspace}}/source/wrappers/python/ + + - name: Build macos wheels + if: runner.os == 'macOS' + uses: pypa/cibuildwheel@v2.17.0 + with: + package-dir: ./source/wrappers/python + config-file: ./source/wrappers/python/pyproject.toml + env: + CIBW_ARCHS: ${{matrix.build-platform[1]}} + CIBW_PLATFORM: macos + CIBW_BUILD: cp*-${{matrix.build-platform[2]}} + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + upload_pypi: + needs: build_wheels + runs-on: ubuntu-latest + environment: + name: testpypi + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml new file mode 100644 index 00000000..17b8357f --- /dev/null +++ b/.github/workflows/build_wheels.yml @@ -0,0 +1,163 @@ +name: build and upload wheels + +on: + push: + tags: + - '*' + +jobs: + build_wheels: + name: build wheels on ${{matrix.build-platform[0]}} ${{matrix.build-platform[1]}} + runs-on: ${{matrix.build-platform[0]}} + strategy: + fail-fast: false + matrix: + build-platform: + - [ubuntu-latest, x86_64, manylinux2014_x86_64] + - [ubuntu-latest, x86_64, manylinux_2_28_x86_64] + - [ubuntu-latest,aarch64,manylinux_2_28_aarch64] + - [macos-13, x86_64, macosx_x86_64] + - [macos-14, arm64, macosx_arm64] + + steps: + - uses: actions/checkout@v3 + # need git tags available for setuptools_scm to grab tags? will elad to slower checkout + with: + fetch-depth: 0 + + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v3 + with: + platforms: all + + - name: Build manylinux2014 wheels + if: startswith(matrix.build-platform[2], 'manylinux2014') + uses: pypa/cibuildwheel@v2.17.0 + with: + package-dir: ./source/wrappers/python + config-file: ./source/wrappers/python/pyproject.toml + env: + CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 + CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 + CIBW_ARCHS: ${{matrix.build-platform[1]}} + CIBW_BUILD: cp*-manylinux* + CIBW_SKIP: cp*-musllinux* *-musllinux* + CIBW_BEFORE_ALL: > + sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && + sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* && + yum update -y && + yum install -y wget openssl-devel libxml2-devel libtirpc-devel && + cd /tmp && + wget https://github.com/fmtlib/fmt/archive/refs/tags/10.0.0.tar.gz && + tar xzf 10.0.0.tar.gz && + cd fmt-10.0.0 && + cmake -Bbuild -H. -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && + cmake --build build -j --config Release --target install && + cd /tmp && + wget https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz && + tar xzf v1.11.0.tar.gz && + cd spdlog-1.11.0 && + cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && + cmake --build build -j --config Release --target install && + cd /tmp && + wget https://github.com/capnproto/capnproto/archive/refs/tags/v0.10.4.tar.gz && + tar xzf v0.10.4.tar.gz && + cd capnproto-0.10.4 && + cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && + cmake --build build && + cmake --install build && + cd /tmp && + wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz && + tar xzf boost_1_80_0.tar.gz && + cd boost_1_80_0 && + ./bootstrap.sh --prefix=/usr/local && + ./b2 --without-python --prefix=/usr/local install && + cd /project && + cmake -B build -DNO_JAVA_WRAPPER=ON -DBUILD_SHARED_LIBS=ON -DSSLAUTHENTICATION=ON -DENABLE_CAPNP=ON -DCLIENT_ONLY=ON && + cmake --build build -j --config Release --target install && + cp -r /usr/local/python_installer/* /project/source/wrappers/python/ + + - name: Build manylinux_2_28 wheels + if: startswith(matrix.build-platform[2], 'manylinux_2_28') + uses: pypa/cibuildwheel@v2.17.0 + with: + package-dir: ./source/wrappers/python + config-file: ./source/wrappers/python/pyproject.toml + env: + CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 + CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 + CIBW_ARCHS: ${{matrix.build-platform[1]}} + CIBW_BUILD: cp*-manylinux* + CIBW_SKIP: cp*-musllinux* *-musllinux* + CIBW_BEFORE_ALL: > + dnf update -y && + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm && + dnf install -y boost-devel openssl-devel libxml2-devel libtirpc-devel + fmt fmt-devel spdlog spdlog-devel capnproto capnproto-devel && + cd /project && + cmake -B build + -DBUILD_SHARED_LIBS=ON + -DCMAKE_BUILD_TYPE=Release + -DSSLAUTHENTICATION=ON + -DNO_JAVA_WRAPPER=ON + -DENABLE_CAPNP=ON -DCLIENT_ONLY=ON && + cmake --build build -j --config Release --target install && + cp -r /usr/local/python_installer/* /project/source/wrappers/python/ + + - name: build uda on macos + if: runner.os == 'macOS' + run: > + brew update-reset && brew install + git + boost + openssl + cmake + libxml2 + spdlog + capnp && + cd ${{github.workspace}} && + cmake -B build + -DBUILD_SHARED_LIBS=ON + -DCMAKE_BUILD_TYPE=Release + -DSSLAUTHENTICATION=ON + -DENABLE_CAPNP=ON + -DNO_JAVA_WRAPPER=ON + -DCMAKE_INSTALL_PREFIX=$PWD/install + -DCLIENT_ONLY=ON && + cmake --build build -j --config Release --target install && + cp -r $PWD/install/python_installer/* ${{github.workspace}}/source/wrappers/python/ + + - name: Build macos wheels + if: runner.os == 'macOS' + uses: pypa/cibuildwheel@v2.17.0 + with: + package-dir: ./source/wrappers/python + config-file: ./source/wrappers/python/pyproject.toml + env: + CIBW_ARCHS: ${{matrix.build-platform[1]}} + CIBW_PLATFORM: macos + CIBW_BUILD: cp*-${{matrix.build-platform[2]}} + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + upload_pypi: + needs: build_wheels + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/uda + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 3eb83e51..18785d58 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -192,7 +192,7 @@ jobs: python3 -m venv ${{github.workspace}}/venv && source ${{github.workspace}}/venv/bin/activate && pip3 install --upgrade pip && - pip3 install wheel Cython numpy six && + pip3 install wheel Cython "numpy<2" six && pip3 install ${{github.workspace}}/python_installer - name: Test pyuda import diff --git a/CMakeLists.txt b/CMakeLists.txt index deda2226..2db7a74e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,23 +45,12 @@ set( Boost_USE_MULTITHREADED OFF ) ######################################################################################################################## # Version and Machine information -include( GetGitRevisionDescription ) +# Set VERSION and FULL_VERSION from `git describe` +# but use git export attribute for release tarballs +set( GIT_ARCHIVE_DESCRIBE [[$Format:%(describe)$]] ) +include( DetermineVersion ) -git_describe( GIT_TAG --tags ) - -if( "${GIT_TAG}" MATCHES "^.*NOTFOUND$" ) - message( WARNING "Failed to get git revision: ${GIT_TAG}" ) - set( GIT_VERSION "0.0.0" ) -elseif( "${GIT_TAG}" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)$" ) - set( GIT_VERSION "${GIT_TAG}" ) -elseif( "${GIT_TAG}" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-.*$" ) - set( GIT_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" ) -else() - message( WARNING "invalid git tag for version parsing: ${GIT_TAG}" ) - set( GIT_VERSION "0.0.0" ) -endif() - -project( uda VERSION ${GIT_VERSION} ) +project( uda VERSION ${VERSION} ) set( USER $ENV{USER} ) diff --git a/cmake/DetermineVersion.cmake b/cmake/DetermineVersion.cmake new file mode 100644 index 00000000..5c4399ee --- /dev/null +++ b/cmake/DetermineVersion.cmake @@ -0,0 +1,53 @@ +# Determine the version of the current AL component, based on git describe + +if( NOT GIT_ARCHIVE_DESCRIBE ) + message( FATAL_ERROR "GIT_ARCHIVE_DESCRIBE should be set before including ALDetermineVersion" ) +endif() + +if( NOT GIT_ARCHIVE_DESCRIBE MATCHES "^.Format:%.describe" ) + # We are part of an exported tarball and git-archive set the describe content: + set( _GIT_DESCRIBE_ERROR_CODE 0 ) + set( _GIT_DESCRIBE_OUTPUT "${GIT_ARCHIVE_DESCRIBE}" ) +else() + # Ask git for a describe: + find_package( Git ) + if( GIT_EXECUTABLE ) + # Generate a git-describe version string from Git repository tags + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags --dirty + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE _GIT_DESCRIBE_OUTPUT + RESULT_VARIABLE _GIT_DESCRIBE_ERROR_CODE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + endif() +endif() + +# Process git describe output: +if( _GIT_DESCRIBE_OUTPUT AND NOT _GIT_DESCRIBE_ERROR_CODE ) + # Git describe should return the version (MAJOR.MINOR.PATCH) and potentially + # a suffix "--g[-dirty]" + # Use a regex to extract all parts: + if( _GIT_DESCRIBE_OUTPUT MATCHES "([0-9]+)[.]([0-9]+)[.]*([0-9]+)(.*)" ) + set( VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" ) + if( CMAKE_MATCH_4 MATCHES "-([0-9]+)-(.*)" ) + # Use ncommits as fourth version component for the CMAKE project version + set( VERSION "${VERSION}.${CMAKE_MATCH_1}" ) + endif() + else() + message( FATAL_ERROR "Unexpected output of git describe: '${_GIT_DESCRIBE_OUTPUT}'") + endif() + + # Generate a version string that conforms to the Python standards + # e.g. 5.1.0-3-g7c620eb5-dirty becomes 5.1.0+3-g7c620eb5-dirty + string( REGEX REPLACE "-(.*)$" "+\\1" FULL_VERSION ${_GIT_DESCRIBE_OUTPUT} ) + message( VERBOSE "Determined project version: ${VERSION}" ) +endif() + +# Fallback: git not found, or git describe fails +# Set version to 0.0.0 and report a warning +if( NOT DEFINED VERSION ) + set( VERSION "0.0.0" ) + set( FULL_VERSION "0.0.0+unknown" ) + message( WARNING "Failed to determine VERSION from git tags. Falling back to default version '${VERSION}'" ) +endif() diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 5a0867c3..1ae6917a 100755 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -133,6 +133,12 @@ foreach( PKGCONFIG_FILE ${PKGCONFIG_FILES} ) ) endforeach() +install( + DIRECTORY + ${CMAKE_BINARY_DIR}/lib/pkgconfig + DESTINATION lib +) + find_program( XINETD_EXE xinetd PATHS /usr/sbin/ /usr/local/sbin/ ) configure_file( diff --git a/source/authentication/udaServerSSL.cpp b/source/authentication/udaServerSSL.cpp index 8354091c..62ba90ac 100644 --- a/source/authentication/udaServerSSL.cpp +++ b/source/authentication/udaServerSSL.cpp @@ -322,7 +322,7 @@ int startUdaServerSSL() } // Get the Client's certificate and verify - X509* peer = SSL_get1_peer_certificate(g_ssl); + X509* peer = SSL_get_peer_certificate(g_ssl); if (peer != nullptr) { if ((rc = (int)SSL_get_verify_result(g_ssl)) != X509_V_OK) { @@ -557,4 +557,4 @@ int readUdaServerSSL(void* iohandle, char* buf, int count) return rc; } -#endif // SERVERBUILD \ No newline at end of file +#endif // SERVERBUILD diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index ee5b83b2..a648bc06 100755 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -66,6 +66,8 @@ set( HEADER_FILES udaPutAPI.h updateSelectParms.h udaClientHostList.h + legacy_accAPI.h + legacy_client.h ) include_directories( diff --git a/source/client/accAPI.cpp b/source/client/accAPI.cpp index 982a06bc..fdbb97d1 100755 --- a/source/client/accAPI.cpp +++ b/source/client/accAPI.cpp @@ -96,8 +96,9 @@ int getThreadId(thread_t id) } // Lock the thread and set the previous STATE -void lockIdamThread(CLIENT_FLAGS* client_flags) +void udaLockThread() { + CLIENT_FLAGS* client_flags = udaClientFlags(); static unsigned int mutex_initialised = 0; if (!mutex_initialised) { @@ -162,8 +163,9 @@ void lockIdamThread(CLIENT_FLAGS* client_flags) /** * Unlock the thread and save the current STATE */ -void unlockUdaThread(CLIENT_FLAGS* client_flags) +void udaUnlockThread() { + CLIENT_FLAGS* client_flags = udaClientFlags(); #ifdef __GNUC__ thread_t threadId = pthread_self(); #else @@ -188,9 +190,9 @@ void unlockUdaThread(CLIENT_FLAGS* client_flags) /** * Free thread resources */ -void freeIdamThread(CLIENT_FLAGS* client_flags) +void udaFreeThread() { - lockIdamThread(client_flags); + udaLockThread(); #ifdef __GNUC__ thread_t threadId = pthread_self(); #else @@ -212,13 +214,13 @@ void freeIdamThread(CLIENT_FLAGS* client_flags) initServerBlock(&(idamState[threadCount].server_block), 0); threadList[threadCount] = 0; } - unlockUdaThread(client_flags); + udaUnlockThread(); } #else -void lockIdamThread() {} -void unlockIdamThread() {} -void freeIdamThread() {} +void udaLockThread() {} +void udaUnlockThread() {} +void udaFreeThread() {} #endif // NOPTHREADS int getIdamThreadLastHandle() @@ -240,8 +242,9 @@ void acc_freeDataBlocks() putIdamThreadLastHandle(-1); } -DATA_BLOCK* acc_getCurrentDataBlock(CLIENT_FLAGS* client_flags) +DATA_BLOCK* udaGetCurrentDataBlock() { + CLIENT_FLAGS* client_flags = udaClientFlags(); if ((client_flags->flags & CLIENTFLAG_REUSELASTHANDLE || client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) && getIdamThreadLastHandle() >= 0) { return &data_blocks[getIdamThreadLastHandle()]; @@ -249,8 +252,9 @@ DATA_BLOCK* acc_getCurrentDataBlock(CLIENT_FLAGS* client_flags) return &data_blocks.back(); } -int acc_getCurrentDataBlockIndex(CLIENT_FLAGS* client_flags) +int udaGetCurrentDataBlockIndex() { + CLIENT_FLAGS* client_flags = udaClientFlags(); if ((client_flags->flags & CLIENTFLAG_REUSELASTHANDLE || client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) && getIdamThreadLastHandle() >= 0) { return getIdamThreadLastHandle(); @@ -258,8 +262,9 @@ int acc_getCurrentDataBlockIndex(CLIENT_FLAGS* client_flags) return data_blocks.size() - 1; } -int acc_growIdamDataBlocks(CLIENT_FLAGS* client_flags) +int udaGrowDataBlocks() { + CLIENT_FLAGS* client_flags = udaClientFlags(); if ((client_flags->flags & CLIENTFLAG_REUSELASTHANDLE || client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) && getIdamThreadLastHandle() >= 0) { return 0; @@ -284,8 +289,9 @@ static int findNewHandleIndex() return -1; } -int acc_getIdamNewDataHandle(CLIENT_FLAGS* client_flags) +int udaGetNewDataHandle() { + CLIENT_FLAGS* client_flags = udaClientFlags(); int newHandleIndex = -1; if ((client_flags->flags & CLIENTFLAG_REUSELASTHANDLE || client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) && @@ -372,8 +378,9 @@ void resetIdamPrivateFlag(unsigned int flag) * @return Void. */ -void setIdamClientFlag(CLIENT_FLAGS* client_flags, unsigned int flag) +void udaSetClientFlag(unsigned int flag) { + CLIENT_FLAGS* client_flags = udaClientFlags(); client_flags->flags = client_flags->flags | flag; } @@ -384,8 +391,9 @@ void setIdamClientFlag(CLIENT_FLAGS* client_flags, unsigned int flag) * @return Void. */ -void resetIdamClientFlag(CLIENT_FLAGS* client_flags, unsigned int flag) +void udaResetClientFlag(unsigned int flag) { + CLIENT_FLAGS* client_flags = udaClientFlags(); client_flags->flags &= !flag; } @@ -417,9 +425,10 @@ void resetIdamClientFlag(CLIENT_FLAGS* client_flags, unsigned int flag) * @param property the name of the property to set true or a name value pair. * @return Void. */ -void setIdamProperty(const char* property, CLIENT_FLAGS* client_flags) +void udaSetProperty(const char* property) { // User settings for Client and Server behaviour + CLIENT_FLAGS* client_flags = udaClientFlags(); char name[56]; char* value; @@ -477,9 +486,10 @@ void setIdamProperty(const char* property, CLIENT_FLAGS* client_flags) * @param property the name of the property. * @return Void. */ -int getIdamProperty(const char* property, const CLIENT_FLAGS* client_flags) +int udaGetProperty(const char* property) { // User settings for Client and Server behaviour + CLIENT_FLAGS* client_flags = udaClientFlags(); if (property[0] == 'g') { if (STR_IEQUALS(property, "get_datadble")) return client_flags->get_datadble; @@ -513,9 +523,10 @@ int getIdamProperty(const char* property, const CLIENT_FLAGS* client_flags) * @return Void. */ -void resetIdamProperty(const char* property, CLIENT_FLAGS* client_flags) +void udaResetProperty(const char* property) { // User settings for Client and Server behaviour + CLIENT_FLAGS* client_flags = udaClientFlags(); if (property[0] == 'g') { if (STR_IEQUALS(property, "get_datadble")) client_flags->get_datadble = 0; @@ -547,9 +558,10 @@ void resetIdamProperty(const char* property, CLIENT_FLAGS* client_flags) /** * @return Void. */ -void resetIdamProperties(CLIENT_FLAGS* client_flags) +void udaResetProperties() { // Reset on Both Client and Server + CLIENT_FLAGS* client_flags = udaClientFlags(); client_flags->get_datadble = 0; client_flags->get_dimdble = 0; @@ -851,9 +863,9 @@ int getIdamDataStatus(int handle) /** \return handle. */ -int getIdamLastHandle(CLIENT_FLAGS* client_flags) +int udaGetLastHandle() { - return acc_getCurrentDataBlockIndex(client_flags); + return udaGetCurrentDataBlockIndex(); } //! returns the number of data items in the data object diff --git a/source/client/accAPI.h b/source/client/accAPI.h index 53ce83af..70cfdf39 100755 --- a/source/client/accAPI.h +++ b/source/client/accAPI.h @@ -15,13 +15,13 @@ extern "C" { #define UDA_NUM_CLIENT_THREADS 30 -LIBRARY_API DATA_BLOCK* acc_getCurrentDataBlock(CLIENT_FLAGS* client_flags); +LIBRARY_API DATA_BLOCK* udaGetCurrentDataBlock(); -LIBRARY_API int acc_getCurrentDataBlockIndex(CLIENT_FLAGS* client_flags); +LIBRARY_API int udaGetCurrentDataBlockIndex(); -LIBRARY_API int acc_growIdamDataBlocks(CLIENT_FLAGS* client_flags); +LIBRARY_API int udaGrowDataBlocks(); -LIBRARY_API int acc_getIdamNewDataHandle(CLIENT_FLAGS* client_flags); +LIBRARY_API int udaGetNewDataHandle(); LIBRARY_API void acc_freeDataBlocks(); @@ -29,21 +29,22 @@ LIBRARY_API void setIdamPrivateFlag(unsigned int flag); LIBRARY_API void resetIdamPrivateFlag(unsigned int flag); -LIBRARY_API void setIdamClientFlag(CLIENT_FLAGS* client_flags, unsigned int flag); +LIBRARY_API void udaSetClientFlag(unsigned int flag); -LIBRARY_API void resetIdamClientFlag(CLIENT_FLAGS* client_flags, unsigned int flag); +LIBRARY_API void udaResetClientFlag(unsigned int flag); -LIBRARY_API void setIdamProperty(const char* property, CLIENT_FLAGS* client_flags); +LIBRARY_API void udaSetProperty(const char* property); -LIBRARY_API int getIdamProperty(const char* property, const CLIENT_FLAGS* client_flags); +LIBRARY_API int udaGetProperty(const char* property); -LIBRARY_API void resetIdamProperty(const char* property, CLIENT_FLAGS* client_flags); +LIBRARY_API void udaResetProperty(const char* property); -LIBRARY_API void resetIdamProperties(CLIENT_FLAGS* client_flags); +LIBRARY_API void udaResetProperties(); -LIBRARY_API CLIENT_BLOCK saveIdamProperties(const CLIENT_FLAGS* client_flags); +LIBRARY_API CLIENT_BLOCK udaSaveProperties(); -LIBRARY_API void restoreIdamProperties(CLIENT_BLOCK cb, CLIENT_FLAGS* client_flags); +LIBRARY_API void udaRestoreProperties(CLIENT_BLOCK cb); +// LIBRARY_API void restoreIdamProperties(CLIENT_BLOCK cb, CLIENT_FLAGS* client_flags); LIBRARY_API CLIENT_BLOCK* getIdamProperties(int handle); @@ -83,7 +84,7 @@ LIBRARY_API int getIdamSignalStatus(int handle); LIBRARY_API int getIdamDataStatus(int handle); -LIBRARY_API int getIdamLastHandle(CLIENT_FLAGS* client_flags); +LIBRARY_API int udaGetLastHandle(); LIBRARY_API int getIdamDataNum(int handle); @@ -245,11 +246,11 @@ LIBRARY_API int getIdamDataCheckSum(int handle); LIBRARY_API int getIdamDimDataCheckSum(int handle, int ndim); -LIBRARY_API void lockIdamThread(CLIENT_FLAGS* client_flags); +LIBRARY_API void udaLockThread(); -LIBRARY_API void unlockUdaThread(CLIENT_FLAGS* client_flags); +LIBRARY_API void udaUnlockThread(); -LIBRARY_API void freeIdamThread(CLIENT_FLAGS* client_flags); +LIBRARY_API void udaFreeThread(); LIBRARY_API int getIdamThreadLastHandle(); diff --git a/source/client/legacy_accAPI.h b/source/client/legacy_accAPI.h new file mode 100644 index 00000000..0e285133 --- /dev/null +++ b/source/client/legacy_accAPI.h @@ -0,0 +1,185 @@ +#ifndef UDA_LEGACY_ACCAPI_H +#define UDA_LEGACY_ACCAPI_H + +#include +#include "udaClient.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef UDA_CLIENT_FLAGS_API +// #warning "Using legacy API names with redundant \"client_flags\" arguments, these will be deprecated in future" + + LIBRARY_API inline DATA_BLOCK* acc_getCurrentDataBlock(CLIENT_FLAGS* client_flags) + { + return udaGetCurrentDataBlock(); + } + + LIBRARY_API inline int acc_getCurrentDataBlockIndex(CLIENT_FLAGS* client_flags) + { + return udaGetCurrentDataBlockIndex(); + } + + LIBRARY_API inline int acc_growIdamDataBlocks(CLIENT_FLAGS* client_flags) + { + return udaGrowDataBlocks(); + } + + LIBRARY_API inline int acc_getIdamNewDataHandle(CLIENT_FLAGS* client_flags) + { + return udaGetNewDataHandle(); + } + + LIBRARY_API inline void setIdamClientFlag(CLIENT_FLAGS* client_flags, unsigned int flag) + { + udaSetClientFlag(flag); + } + + LIBRARY_API inline void resetIdamClientFlag(CLIENT_FLAGS* client_flags, unsigned int flag) + { + udaResetClientFlag(flag); + } + + LIBRARY_API inline void setIdamProperty(const char* property, CLIENT_FLAGS* client_flags) + { + udaSetProperty(property); + } + + LIBRARY_API inline int getIdamProperty(const char* property, const CLIENT_FLAGS* client_flags) + { + return udaGetProperty(property); + } + + LIBRARY_API inline void resetIdamProperty(const char* property, CLIENT_FLAGS* client_flags) + { + udaResetProperty(property); + } + + LIBRARY_API inline void resetIdamProperties(CLIENT_FLAGS* client_flags) + { + udaResetProperties(); + } + + CLIENT_BLOCK saveIdamProperties(const CLIENT_FLAGS* client_flags) + { + return udaSaveProperties(); + } + + LIBRARY_API inline void restoreIdamProperties(CLIENT_BLOCK cb, CLIENT_FLAGS* client_flags) + { + udaRestoreProperties(cb); + } + + LIBRARY_API inline int getIdamLastHandle(CLIENT_FLAGS* client_flags) + { + return udaGetLastHandle(); + } + + LIBRARY_API inline void lockIdamThread(CLIENT_FLAGS* client_flags) + { + udaLockThread(); + } + + LIBRARY_API inline void unlockUdaThread(CLIENT_FLAGS* client_flags) + { + udaUnlockThread(); + } + + LIBRARY_API inline void freeIdamThread(CLIENT_FLAGS* client_flags) + { + udaFreeThread(); + } + +#else + + LIBRARY_API inline DATA_BLOCK* acc_getCurrentDataBlock() + { + return udaGetCurrentDataBlock(); + } + + LIBRARY_API inline int acc_getCurrentDataBlockIndex() + { + return udaGetCurrentDataBlockIndex(); + } + + LIBRARY_API inline int acc_growIdamDataBlocks() + { + return udaGrowDataBlocks(); + } + + LIBRARY_API inline int acc_getIdamNewDataHandle() + { + return udaGetNewDataHandle(); + } + + LIBRARY_API inline void setIdamClientFlag(unsigned int flag) + { + udaSetClientFlag(flag); + } + + LIBRARY_API inline void resetIdamClientFlag(unsigned int flag) + { + udaResetClientFlag(flag); + } + + LIBRARY_API inline void setIdamProperty(const char* property) + { + udaSetProperty(property); + } + + LIBRARY_API inline int getIdamProperty(const char* property) + { + return udaGetProperty(property); + } + + LIBRARY_API inline void resetIdamProperty(const char* property) + { + udaResetProperty(property); + } + + LIBRARY_API inline void resetIdamProperties() + { + udaResetProperties(); + } + + LIBRARY_API inline CLIENT_BLOCK saveIdamProperties() + { + return udaSaveProperties(); + } + + LIBRARY_API inline void restoreIdamProperties(CLIENT_BLOCK cb) + { + udaRestoreProperties(cb); + } + + LIBRARY_API inline int getIdamLastHandle() + { + return udaGetLastHandle(); + } + + LIBRARY_API inline void lockIdamThread() + { + udaLockThread(); + } + + LIBRARY_API inline void unlockUdaThread() + { + udaUnlockThread(); + } + + LIBRARY_API inline void freeIdamThread() + { + udaFreeThread(); + } + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif // UDA_LEGACY_ACCAPI_H diff --git a/source/client/legacy_client.h b/source/client/legacy_client.h new file mode 100644 index 00000000..b91280e7 --- /dev/null +++ b/source/client/legacy_client.h @@ -0,0 +1,26 @@ +#ifndef UDA_LEGACY_CLIENT_H +#define UDA_LEGACY_CLIENT_H + +#include +#include "udaClient.h" + +#ifdef __cplusplus +extern "C" { +#endif + +LIBRARY_API inline void idamFree(int handle) +{ + udaFree(handle); +} + +LIBRARY_API inline void idamFreeAll() +{ + udaFreeAll(); +} + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/source/client/udaClient.cpp b/source/client/udaClient.cpp index 82b350f7..93699792 100755 --- a/source/client/udaClient.cpp +++ b/source/client/udaClient.cpp @@ -125,7 +125,7 @@ int check_file_cache(const REQUEST_DATA* request_data, DATA_BLOCK** p_data_block if (data != nullptr) { // Success - int data_block_idx = acc_getIdamNewDataHandle(client_flags); + int data_block_idx = udaGetNewDataHandle(); if (data_block_idx < 0) { // Error return -data_block_idx; @@ -163,7 +163,7 @@ int check_mem_cache(uda::cache::UdaCache* cache, REQUEST_DATA* request_data, DAT if (data != nullptr) { // Success - int data_block_idx = acc_getIdamNewDataHandle(client_flags); + int data_block_idx = udaGetNewDataHandle(); if (data_block_idx < 0) { // Error return -data_block_idx; @@ -930,7 +930,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) //------------------------------------------------------------------------------ // Allocate memory for the Data Block Structure // Re-use existing stale Data Blocks - int data_block_idx = acc_getIdamNewDataHandle(client_flags); + int data_block_idx = udaGetNewDataHandle(); if (data_block_idx < 0) { // Error data_block_indices[i] = -data_block_idx; @@ -1008,7 +1008,7 @@ int idamClient(REQUEST_BLOCK* request_block, int* indices) for (int i = 0; i < data_block_list0.count; ++i) { DATA_BLOCK* data_block0 = &data_block_list0.data[i]; - int data_block_idx = acc_getIdamNewDataHandle(client_flags); + int data_block_idx = udaGetNewDataHandle(); DATA_BLOCK* data_block = getIdamDataBlock(data_block_idx); // data blocks may have been realloc'ed copyDataBlock(data_block, data_block0); @@ -1426,9 +1426,7 @@ void udaFreeAll() uda::cache::free_cache(); #endif - CLIENT_FLAGS* client_flags = udaClientFlags(); - - for (int i = 0; i < acc_getCurrentDataBlockIndex(client_flags); ++i) { + for (int i = 0; i < udaGetCurrentDataBlockIndex(); ++i) { #ifndef FATCLIENT freeDataBlock(getIdamDataBlock(i)); #else @@ -1493,9 +1491,11 @@ void putIdamThreadClientBlock(CLIENT_BLOCK* str) client_block = *str; } -CLIENT_BLOCK saveIdamProperties(const CLIENT_FLAGS* client_flags) -{ // save current state of properties for future rollback +CLIENT_BLOCK udaSaveProperties() +{ + // save current state of properties for future rollback CLIENT_BLOCK cb = client_block; // Copy of Global Structure (maybe not initialised! i.e. idam API not called) + CLIENT_FLAGS* client_flags = udaClientFlags(); cb.get_datadble = client_flags->get_datadble; // Copy individual properties only cb.get_dimdble = client_flags->get_dimdble; cb.get_timedble = client_flags->get_timedble; @@ -1513,8 +1513,9 @@ CLIENT_BLOCK saveIdamProperties(const CLIENT_FLAGS* client_flags) return cb; } -void restoreIdamProperties(CLIENT_BLOCK cb, CLIENT_FLAGS* client_flags) -{ // Restore Properties to a prior saved state +void udaRestoreProperties(CLIENT_BLOCK cb) +{ + // Restore Properties to a prior saved state client_block.get_datadble = cb.get_datadble; // Overwrite Individual Global Structure Components client_block.get_dimdble = cb.get_dimdble; client_block.get_timedble = cb.get_timedble; @@ -1528,6 +1529,7 @@ void restoreIdamProperties(CLIENT_BLOCK cb, CLIENT_FLAGS* client_flags) client_block.clientFlags = cb.clientFlags; client_block.altRank = cb.altRank; + CLIENT_FLAGS* client_flags = udaClientFlags(); client_flags->get_datadble = client_block.get_datadble; client_flags->get_dimdble = client_block.get_dimdble; client_flags->get_timedble = client_block.get_timedble; diff --git a/source/client/udaGetAPI.cpp b/source/client/udaGetAPI.cpp index 3c1fd02d..fc43ed4e 100755 --- a/source/client/udaGetAPI.cpp +++ b/source/client/udaGetAPI.cpp @@ -148,7 +148,7 @@ int idamGetAPIWithHost(const char* data_object, const char* data_source, const c CLIENT_FLAGS* client_flags = udaClientFlags(); // Lock the thread - lockIdamThread(client_flags); + udaLockThread(); if (host != nullptr) { putIdamServerHost(host); @@ -176,7 +176,7 @@ int idamGetAPIWithHost(const char* data_object, const char* data_source, const c static bool reopen_logs = true; if (udaStartup(0, client_flags, &reopen_logs) != 0) { - unlockUdaThread(client_flags); + udaUnlockThread(); return PROBLEM_OPENING_LOGS; } @@ -217,7 +217,7 @@ int idamGetAPIWithHost(const char* data_object, const char* data_source, const c UDA_LOG(UDA_LOG_ERROR, "Error identifying the Data Source [%s]\n", data_source); addIdamError(UDA_CODE_ERROR_TYPE, __func__, 999, "Error identifying the Data Source"); } - unlockUdaThread(client_flags); + udaUnlockThread(); return -err; } @@ -227,7 +227,7 @@ int idamGetAPIWithHost(const char* data_object, const char* data_source, const c // Fetch Data #ifdef TESTSERVERCLIENT - unlockIdamThread(); + udaUnlockThread(); return -1; #endif @@ -246,7 +246,7 @@ int idamGetAPIWithHost(const char* data_object, const char* data_source, const c freeClientRequestBlock(&request_block); // Unlock the thread - unlockUdaThread(client_flags); + udaUnlockThread(); return handle; } @@ -260,7 +260,7 @@ int idamGetBatchAPIWithHost(const char** signals, const char** sources, int coun CLIENT_FLAGS* client_flags = udaClientFlags(); // Lock the thread - lockIdamThread(client_flags); + udaLockThread(); if (host != nullptr) { putIdamServerHost(host); @@ -287,7 +287,7 @@ int idamGetBatchAPIWithHost(const char** signals, const char** sources, int coun static bool reopen_logs = true; if (udaStartup(0, client_flags, &reopen_logs) != 0) { - unlockUdaThread(client_flags); + udaUnlockThread(); return PROBLEM_OPENING_LOGS; } @@ -328,7 +328,7 @@ int idamGetBatchAPIWithHost(const char** signals, const char** sources, int coun if (udaNumErrors() == 0) { addIdamError(UDA_CODE_ERROR_TYPE, __func__, 999, "Error identifying the Data Source"); } - unlockUdaThread(client_flags); + udaUnlockThread(); return -err; } @@ -339,7 +339,7 @@ int idamGetBatchAPIWithHost(const char** signals, const char** sources, int coun // Fetch Data #ifdef TESTSERVERCLIENT - unlockIdamThread(); + udaUnlockThread(); return -1; #endif @@ -353,6 +353,6 @@ int idamGetBatchAPIWithHost(const char** signals, const char** sources, int coun #endif // Unlock the thread - unlockUdaThread(client_flags); + udaUnlockThread(); return err; } diff --git a/source/clientserver/protocol2.cpp b/source/clientserver/protocol2.cpp index 1ddbe7a9..b0d71d92 100755 --- a/source/clientserver/protocol2.cpp +++ b/source/clientserver/protocol2.cpp @@ -709,7 +709,11 @@ static int handle_data_block(XDR* xdrs, int direction, const void* str, int prot break; } - if (data_block->data_n == 0) break; // No Data to Receive! + if (data_block->data_n == 0) { + data_block->data_type = UDA_TYPE_UNKNOWN; + data_block->rank = 0; + break; // No Data to Receive! + } if ((err = allocData(data_block)) != 0) break; // Allocate Heap Memory diff --git a/source/etc/machine.d/mast.l.cfg b/source/etc/machine.d/mast.l.cfg index 9882e812..7905d3b3 100644 --- a/source/etc/machine.d/mast.l.cfg +++ b/source/etc/machine.d/mast.l.cfg @@ -12,6 +12,8 @@ export UDA_PORT2=${UDA_PORT} DATA_ARCHIVE=/net/raidsrvr/data +export UDA_BYTES_PLUGIN_ALLOWED_PATHS="/net/raidsrvr/data;/common/uda-scratch;/projects/physics/omfit" + export MAST_DATA=${DATA_ARCHIVE}/MAST_Data export MAST_IMAGES=${DATA_ARCHIVE}/MAST_IMAGES export MAST_NEW=${DATA_ARCHIVE}/MAST_NEW diff --git a/source/etc/uda-cpp.pc.in b/source/etc/uda-cpp.pc.in index 1bc14774..744bf6a3 100755 --- a/source/etc/uda-cpp.pc.in +++ b/source/etc/uda-cpp.pc.in @@ -8,6 +8,6 @@ Name: UDA Description: The Universal Data Access library URL: https://ukaea.github.io/UDA/ Version: @PROJECT_VERSION@ -Cflags: -std=c++11 -I${includedir} -I${includedir}/c++ @PKGCONFIG_INCLUDES@ +Cflags: -std=c++17 -I${includedir} -I${includedir}/c++ @PKGCONFIG_INCLUDES@ Libs: -L${libdir} -luda_cpp @PKGCONFIG_LIBRARIES@ Requires: @PKGCONFIG_REQUIRES@ diff --git a/source/etc/uda-fat-cpp.pc.in b/source/etc/uda-fat-cpp.pc.in index 24012f85..2ac8a375 100755 --- a/source/etc/uda-fat-cpp.pc.in +++ b/source/etc/uda-fat-cpp.pc.in @@ -8,6 +8,6 @@ Name: UDA Description: The Universal Data Access library URL: https://ukaea.github.io/UDA/ Version: @PROJECT_VERSION@ -Cflags: -DFATCLIENT -std=c++11 -I${includedir} -I${includedir}/c++ @PKGCONFIG_INCLUDES@ +Cflags: -DFATCLIENT -std=c++17 -I${includedir} -I${includedir}/c++ @PKGCONFIG_INCLUDES@ Libs: -L${libdir} -lfatuda_cpp @PKGCONFIG_LIBRARIES@ Requires: @PKGCONFIG_REQUIRES@ diff --git a/source/plugins/bytes/CMakeLists.txt b/source/plugins/bytes/CMakeLists.txt index 49045947..ac1e9de0 100644 --- a/source/plugins/bytes/CMakeLists.txt +++ b/source/plugins/bytes/CMakeLists.txt @@ -1,6 +1,7 @@ ######################################################################################################################## # Dependencies find_package( LibXml2 QUIET ) +find_package( Boost COMPONENTS ) if( NOT LIBXML2_FOUND ) message( WARNING "Libxml2 not found - skipping template plugin" ) @@ -9,6 +10,13 @@ endif() include( plugins ) +set ( STDFS_VAR "" ) +if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 9.1 ) + set ( STDFS_VAR "stdc++fs" ) +elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 9.0 ) + set ( STDFS_VAR "c++fs" ) +endif() + uda_plugin( NAME BYTES ENTRY_FUNC bytesPlugin @@ -20,4 +28,6 @@ uda_plugin( ${LIBXML2_INCLUDE_DIR} EXTRA_LINK_LIBS ${LIBXML2_LIBRARIES} + Boost::boost + ${STDFS_VAR} ) diff --git a/source/plugins/bytes/bytesPlugin.cpp b/source/plugins/bytes/bytesPlugin.cpp index fb6950b7..b6c2b232 100644 --- a/source/plugins/bytes/bytesPlugin.cpp +++ b/source/plugins/bytes/bytesPlugin.cpp @@ -5,6 +5,21 @@ #include "readBytesNonOptimally.h" +#if defined __has_include +# if !__has_include() +#include +namespace filesystem = std::experimental::filesystem; +# else +#include +namespace filesystem = std::filesystem; +# endif +#else +#include +namespace filesystem = std::filesystem; +#endif + +#include + static int do_help(IDAM_PLUGIN_INTERFACE* idam_plugin_interface); static int do_version(IDAM_PLUGIN_INTERFACE* idam_plugin_interface); @@ -143,6 +158,37 @@ int do_maxinterfaceversion(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) //---------------------------------------------------------------------------------------- // Add functionality here .... + +// Check if path starts with pre-approved file path +// Raises Plugin Error if not +int check_allowed_path(const char* expandedPath) { + std::string full_path; + try { + full_path = filesystem::canonical(expandedPath).string(); + } catch (filesystem::filesystem_error& e) { + UDA_LOG(UDA_LOG_DEBUG, "Filepath [%s] not found! Error: %s\n", full_path.c_str(), e.what()); + RAISE_PLUGIN_ERROR("Provided File Path Not Found!\n"); + } + char* env_str = std::getenv("UDA_BYTES_PLUGIN_ALLOWED_PATHS"); + std::vector allowed_paths; + if (env_str) { // gotta check if environment variable exists before using it + boost::split(allowed_paths, std::getenv("UDA_BYTES_PLUGIN_ALLOWED_PATHS"), boost::is_any_of(";")); + } + bool good_path = false; + for (std::string allowed_path : allowed_paths) { + if (full_path.rfind(allowed_path.c_str(), 0) != std::string::npos) { + good_path = true; + break; + } + } + if (!good_path) { + UDA_LOG(UDA_LOG_DEBUG, "Bad Path Provided %s\n", expandedPath); + RAISE_PLUGIN_ERROR("Bad File Path Provided\n"); + } + return 0; +} + + int do_read(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) { DATA_SOURCE* data_source = idam_plugin_interface->data_source; @@ -154,7 +200,9 @@ int do_read(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) StringCopy(data_source->path, path, MAXPATH); UDA_LOG(UDA_LOG_DEBUG, "expandEnvironmentvariables! \n"); - expand_environment_variables(data_source->path); + expand_environment_variables(data_source->path); + + check_allowed_path(data_source->path); return readBytes(*data_source, *signal_desc, data_block, idam_plugin_interface->environment); } diff --git a/source/plugins/uda/uda_plugin.cpp b/source/plugins/uda/uda_plugin.cpp index 3f06b736..f71028c6 100755 --- a/source/plugins/uda/uda_plugin.cpp +++ b/source/plugins/uda/uda_plugin.cpp @@ -57,7 +57,7 @@ extern int UDAPlugin(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) // Resetting all UDA client properties - resetIdamProperties(udaClientFlags()); + udaResetProperties(); udaFreeAll(); putIdamServerHost(oldServerHost); // Original Host @@ -82,7 +82,7 @@ extern int UDAPlugin(IDAM_PLUGIN_INTERFACE* idam_plugin_interface) // Resetting all UDA client properties - resetIdamProperties(udaClientFlags()); + udaResetProperties(); // Hand over Server IO File Handles to UDA Client library @@ -309,20 +309,19 @@ Notes: there are three pathways depending on the request pattern // Set Properties CLIENT_BLOCK* client_block = idam_plugin_interface->client_block; - auto client_flags = udaClientFlags(); - if (client_block->get_nodimdata) setIdamProperty("get_nodimdata", client_flags); - if (client_block->get_timedble) setIdamProperty("get_timedble", client_flags); - if (client_block->get_dimdble) setIdamProperty("get_dimdble", client_flags); - if (client_block->get_datadble) setIdamProperty("get_datadble", client_flags); + if (client_block->get_nodimdata) udaSetProperty("get_nodimdata"); + if (client_block->get_timedble) udaSetProperty("get_timedble"); + if (client_block->get_dimdble) udaSetProperty("get_dimdble"); + if (client_block->get_datadble) udaSetProperty("get_datadble"); - if (client_block->get_bad) setIdamProperty("get_bad", client_flags); - if (client_block->get_meta) setIdamProperty("get_meta", client_flags); - if (client_block->get_asis) setIdamProperty("get_asis", client_flags); - if (client_block->get_uncal) setIdamProperty("get_uncal", client_flags); - if (client_block->get_notoff) setIdamProperty("get_notoff", client_flags); - if (client_block->get_scalar) setIdamProperty("get_scalar", client_flags); - if (client_block->get_bytes) setIdamProperty("get_bytes", client_flags); + if (client_block->get_bad) udaSetProperty("get_bad"); + if (client_block->get_meta) udaSetProperty("get_meta"); + if (client_block->get_asis) udaSetProperty("get_asis"); + if (client_block->get_uncal) udaSetProperty("get_uncal"); + if (client_block->get_notoff) udaSetProperty("get_notoff"); + if (client_block->get_scalar) udaSetProperty("get_scalar"); + if (client_block->get_bytes) udaSetProperty("get_bytes"); // Timeout ... @@ -330,8 +329,8 @@ Notes: there are three pathways depending on the request pattern // Client Flags ... - resetIdamClientFlag(client_flags, (unsigned int)CLIENTFLAG_FULLRESET); - setIdamClientFlag(client_flags, client_block->clientFlags); + udaResetClientFlag((unsigned int)CLIENTFLAG_FULLRESET); + udaSetClientFlag(client_block->clientFlags); // Client application provenance @@ -575,7 +574,7 @@ Notes: there are three pathways depending on the request pattern } resetIdamPrivateFlag(PRIVATEFLAG_FULLRESET); - resetIdamClientFlag(client_flags, (unsigned int)CLIENTFLAG_FULLRESET); + udaResetClientFlag((unsigned int)CLIENTFLAG_FULLRESET); //---------------------------------------------------------------------- // Test for Errors: Close Socket and Free heap diff --git a/source/server/CMakeLists.txt b/source/server/CMakeLists.txt index 3d7b09ca..617597b7 100755 --- a/source/server/CMakeLists.txt +++ b/source/server/CMakeLists.txt @@ -289,12 +289,6 @@ install( DESTINATION etc ) -install( - DIRECTORY - ${CMAKE_BINARY_DIR}/lib/pkgconfig - DESTINATION lib -) - install( DIRECTORY ${CMAKE_SOURCE_DIR}/source/etc/machine.d diff --git a/source/uda.h b/source/uda.h index 1b46d94a..43f76bd3 100755 --- a/source/uda.h +++ b/source/uda.h @@ -13,6 +13,8 @@ # include # include # include +# include +# include #endif #endif // UDA_H diff --git a/source/wrappers/c++/client.cpp b/source/wrappers/c++/client.cpp index 56433b2d..2f00165f 100755 --- a/source/wrappers/c++/client.cpp +++ b/source/wrappers/c++/client.cpp @@ -44,10 +44,10 @@ void uda::Client::setProperty(Property prop, bool value) throw UDAException("Unknown property"); } - CLIENT_FLAGS* client_flags = udaClientFlags(); + // CLIENT_FLAGS* client_flags = udaClientFlags(); value - ? setIdamProperty(name.c_str(), client_flags) - : resetIdamProperty(name.c_str(), client_flags); + ? udaSetProperty(name.c_str()) + : udaResetProperty(name.c_str()); } void uda::Client::setProperty(Property prop, int value) @@ -74,11 +74,11 @@ void uda::Client::setProperty(Property prop, int value) case PROP_TIMEOUT: name = (boost::format("timeout=%1%") % value).str(); - setIdamProperty(name.c_str(), udaClientFlags()); + udaSetProperty(name.c_str()); break; case PROP_ALTRANK: name = (boost::format("altrank=%1%") % value).str(); - setIdamProperty(name.c_str(), udaClientFlags()); + udaSetProperty(name.c_str()); break; default: @@ -93,25 +93,25 @@ void uda::Client::close() int uda::Client::property(Property prop) { - auto client_flags = udaClientFlags(); + // auto client_flags = udaClientFlags(); switch (prop) { - case PROP_DATADBLE: return getIdamProperty("get_datadble", client_flags); - case PROP_DIMDBLE: return getIdamProperty("get_dimdble", client_flags); - case PROP_TIMEDBLE: return getIdamProperty("get_timedble", client_flags); - case PROP_BYTES: return getIdamProperty("get_bytes", client_flags); - case PROP_BAD: return getIdamProperty("get_bad", client_flags); - case PROP_META: return getIdamProperty("get_meta", client_flags); - case PROP_ASIS: return getIdamProperty("get_asis", client_flags); - case PROP_UNCAL: return getIdamProperty("get_uncal", client_flags); - case PROP_NOTOFF: return getIdamProperty("get_notoff", client_flags); - case PROP_SYNTHETIC: return getIdamProperty("get_synthetic", client_flags); - case PROP_SCALAR: return getIdamProperty("get_scalar", client_flags); - case PROP_NODIMDATA: return getIdamProperty("get_nodimdata", client_flags); - case PROP_VERBOSE: return getIdamProperty("verbose", client_flags); - case PROP_DEBUG: return getIdamProperty("debug", client_flags); - case PROP_ALTDATA: return getIdamProperty("altdata", client_flags); - case PROP_TIMEOUT: return getIdamProperty("timeout", client_flags); - case PROP_ALTRANK: return getIdamProperty("altrank", client_flags); + case PROP_DATADBLE: return udaGetProperty("get_datadble"); + case PROP_DIMDBLE: return udaGetProperty("get_dimdble"); + case PROP_TIMEDBLE: return udaGetProperty("get_timedble"); + case PROP_BYTES: return udaGetProperty("get_bytes"); + case PROP_BAD: return udaGetProperty("get_bad"); + case PROP_META: return udaGetProperty("get_meta"); + case PROP_ASIS: return udaGetProperty("get_asis"); + case PROP_UNCAL: return udaGetProperty("get_uncal"); + case PROP_NOTOFF: return udaGetProperty("get_notoff"); + case PROP_SYNTHETIC: return udaGetProperty("get_synthetic"); + case PROP_SCALAR: return udaGetProperty("get_scalar"); + case PROP_NODIMDATA: return udaGetProperty("get_nodimdata"); + case PROP_VERBOSE: return udaGetProperty("verbose"); + case PROP_DEBUG: return udaGetProperty("debug"); + case PROP_ALTDATA: return udaGetProperty("altdata"); + case PROP_TIMEOUT: return udaGetProperty("timeout"); + case PROP_ALTRANK: return udaGetProperty("altrank"); default: throw UDAException("Unknown property"); diff --git a/source/wrappers/fortran/accAPI_F.c b/source/wrappers/fortran/accAPI_F.c index e3d81470..4c8b1634 100755 --- a/source/wrappers/fortran/accAPI_F.c +++ b/source/wrappers/fortran/accAPI_F.c @@ -409,7 +409,7 @@ extern void setidamproperty_(char* property, int lproperty) strncpy(s, property, lproperty); s[lproperty] = '\0'; s = TrimString(s); - setIdamProperty(s); + udaSetProperty(s); free( s); } @@ -419,7 +419,7 @@ extern void getidamproperty_(const char* property, int* value, int lproperty) strncpy(s, property, lproperty); s[lproperty] = '\0'; s = TrimString(s); - *value = getIdamProperty(s); + *value = udaGetProperty(s); } extern void resetidamproperty_(char* property, int lproperty) @@ -428,13 +428,13 @@ extern void resetidamproperty_(char* property, int lproperty) strncpy(s, property, lproperty); s[lproperty] = '\0'; s = TrimString(s); - resetIdamProperty(s); + udaResetProperty(s); free( s); } extern void resetidamproperties_() { - resetIdamProperties(); + udaResetProperties(); return; } @@ -612,7 +612,7 @@ extern void getidamdatastatus_(int* handle, int* status) extern void getidamlasthandle_(int* handle) { - *handle = getIdamLastHandle(); + *handle = udaGetLastHandle(); } extern void getidamdatanum_(int* hd, int* datanum) diff --git a/source/wrappers/idl/idam_dlm.c b/source/wrappers/idl/idam_dlm.c index 149f5d60..935a2660 100755 --- a/source/wrappers/idl/idam_dlm.c +++ b/source/wrappers/idl/idam_dlm.c @@ -1186,18 +1186,17 @@ IDL_VPTR IDL_CDECL idamputapi(int argc, IDL_VPTR argv[], char* argk) sout->status = (IDL_LONG)status; sout->error_code = (IDL_LONG)error_code; - CLIENT_FLAGS* client_flags = udaClientFlags(); - sout->get_datadble = (IDL_LONG)getIdamProperty("get_datadble", client_flags); // (IDL_LONG) kw.get_datadble; - sout->get_dimdble = (IDL_LONG)getIdamProperty("get_dimdble", client_flags); // (IDL_LONG) kw.get_dimdble; - sout->get_timedble = (IDL_LONG)getIdamProperty("get_timedble", client_flags); // (IDL_LONG) kw.get_timedble; - sout->get_scalar = (IDL_LONG)getIdamProperty("get_scalar", client_flags); // (IDL_LONG) kw.get_scalar; - sout->get_bytes = (IDL_LONG)getIdamProperty("get_bytes", client_flags); // (IDL_LONG) kw.get_bytes; - sout->get_asis = (IDL_LONG)getIdamProperty("get_asis", client_flags); // (IDL_LONG) kw.get_asis; - sout->get_bad = (IDL_LONG)getIdamProperty("get_bad", client_flags); // (IDL_LONG) kw.get_bad; - sout->get_meta = (IDL_LONG)getIdamProperty("get_meta", client_flags); // (IDL_LONG) kw.get_meta; - sout->get_uncal = (IDL_LONG)getIdamProperty("get_uncal", client_flags); // (IDL_LONG) kw.get_uncal; - sout->get_notoff = (IDL_LONG)getIdamProperty("get_notoff", client_flags); // (IDL_LONG) kw.get_notoff; - sout->get_nodimdata = (IDL_LONG)getIdamProperty("get_nodimdata", client_flags); // (IDL_LONG) kw.get_nodimdata; + sout->get_datadble = (IDL_LONG)udaGetProperty("get_datadble"); // (IDL_LONG) kw.get_datadble; + sout->get_dimdble = (IDL_LONG)udaGetProperty("get_dimdble"); // (IDL_LONG) kw.get_dimdble; + sout->get_timedble = (IDL_LONG)udaGetProperty("get_timedble"); // (IDL_LONG) kw.get_timedble; + sout->get_scalar = (IDL_LONG)udaGetProperty("get_scalar"); // (IDL_LONG) kw.get_scalar; + sout->get_bytes = (IDL_LONG)udaGetProperty("get_bytes"); // (IDL_LONG) kw.get_bytes; + sout->get_asis = (IDL_LONG)udaGetProperty("get_asis"); // (IDL_LONG) kw.get_asis; + sout->get_bad = (IDL_LONG)udaGetProperty("get_bad"); // (IDL_LONG) kw.get_bad; + sout->get_meta = (IDL_LONG)udaGetProperty("get_meta"); // (IDL_LONG) kw.get_meta; + sout->get_uncal = (IDL_LONG)udaGetProperty("get_uncal"); // (IDL_LONG) kw.get_uncal; + sout->get_notoff = (IDL_LONG)udaGetProperty("get_notoff"); // (IDL_LONG) kw.get_notoff; + sout->get_nodimdata = (IDL_LONG)udaGetProperty("get_nodimdata"); // (IDL_LONG) kw.get_nodimdata; IDL_StrStore(&(sout->signal), ""); IDL_StrStore(&(sout->source), ""); @@ -1277,7 +1276,7 @@ IDL_VPTR IDL_CDECL idamputapi(int argc, IDL_VPTR argv[], char* argk) //-------------------------------------------------------------------------- // Cleanup Keywords IDL_KW_FREE; - // restoreIdamProperties(cblock); + // udaRestoreProperties(cblock); return (ivReturn); } @@ -1296,8 +1295,7 @@ IDL_VPTR IDL_CDECL callidam2(int argc, IDL_VPTR argv[], char* argk) char source[STRING_LENGTH]; int exp_number = 0; - CLIENT_FLAGS* client_flags = udaClientFlags(); - CLIENT_BLOCK cblock = saveIdamProperties(client_flags); // preserve the current set of client properties + CLIENT_BLOCK cblock = udaSaveProperties(); // preserve the current set of client properties int handle, status, error_code; char* error_msg; @@ -1544,55 +1542,55 @@ IDL_VPTR IDL_CDECL callidam2(int argc, IDL_VPTR argv[], char* argk) // Process Keywords (take Priority over Passed Arguments) if (kw.debug) { - setIdamProperty("debug", client_flags); // Cannot be reset (currently!) + udaSetProperty("debug"); // Cannot be reset (currently!) } if (kw.verbose) { - setIdamProperty("verbose", client_flags); + udaSetProperty("verbose"); } if (kw.get_datadble) { - setIdamProperty("get_datadble", client_flags); // Properties passed by Keyword must be reset to the prior state + udaSetProperty("get_datadble"); // Properties passed by Keyword must be reset to the prior state } if (kw.get_dimdble) { - setIdamProperty("get_dimdble", client_flags); + udaSetProperty("get_dimdble"); } if (kw.get_timedble) { - setIdamProperty("get_timedble", client_flags); + udaSetProperty("get_timedble"); } if (kw.get_scalar) { - setIdamProperty("get_scalar", client_flags); + udaSetProperty("get_scalar"); } if (kw.get_bytes) { - setIdamProperty("get_bytes", client_flags); + udaSetProperty("get_bytes"); } if (kw.get_asis) { - setIdamProperty("get_asis", client_flags); + udaSetProperty("get_asis"); } if (kw.get_bad) { - setIdamProperty("get_bad", client_flags); + udaSetProperty("get_bad"); } if (kw.get_meta) { - setIdamProperty("get_meta", client_flags); + udaSetProperty("get_meta"); } if (kw.get_uncal) { - setIdamProperty("get_uncal", client_flags); + udaSetProperty("get_uncal"); } if (kw.get_notoff) { - setIdamProperty("get_notoff", client_flags); + udaSetProperty("get_notoff"); } if (kw.get_nodimdata) { - setIdamProperty("get_nodimdata", client_flags); + udaSetProperty("get_nodimdata"); } //-------------------------------------------------------------------------- @@ -1623,7 +1621,7 @@ IDL_VPTR IDL_CDECL callidam2(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_BAD_HANDLE)); } @@ -1637,7 +1635,7 @@ IDL_VPTR IDL_CDECL callidam2(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_HEAP_ALLOC_ERROR)); } @@ -1651,17 +1649,17 @@ IDL_VPTR IDL_CDECL callidam2(int argc, IDL_VPTR argv[], char* argk) sout->status = (IDL_LONG)status; sout->error_code = (IDL_LONG)error_code; - sout->get_datadble = (IDL_LONG)getIdamProperty("get_datadble", client_flags); // (IDL_LONG) kw.get_datadble; - sout->get_dimdble = (IDL_LONG)getIdamProperty("get_dimdble", client_flags); // (IDL_LONG) kw.get_dimdble; - sout->get_timedble = (IDL_LONG)getIdamProperty("get_timedble", client_flags); // (IDL_LONG) kw.get_timedble; - sout->get_scalar = (IDL_LONG)getIdamProperty("get_scalar", client_flags); // (IDL_LONG) kw.get_scalar; - sout->get_bytes = (IDL_LONG)getIdamProperty("get_bytes", client_flags); // (IDL_LONG) kw.get_bytes; - sout->get_asis = (IDL_LONG)getIdamProperty("get_asis", client_flags); // (IDL_LONG) kw.get_asis; - sout->get_bad = (IDL_LONG)getIdamProperty("get_bad", client_flags); // (IDL_LONG) kw.get_bad; - sout->get_meta = (IDL_LONG)getIdamProperty("get_meta", client_flags); // (IDL_LONG) kw.get_meta; - sout->get_uncal = (IDL_LONG)getIdamProperty("get_uncal", client_flags); // (IDL_LONG) kw.get_uncal; - sout->get_notoff = (IDL_LONG)getIdamProperty("get_notoff", client_flags); // (IDL_LONG) kw.get_notoff; - sout->get_nodimdata = (IDL_LONG)getIdamProperty("get_nodimdata", client_flags); // (IDL_LONG) kw.get_nodimdata; + sout->get_datadble = (IDL_LONG)udaGetProperty("get_datadble"); // (IDL_LONG) kw.get_datadble; + sout->get_dimdble = (IDL_LONG)udaGetProperty("get_dimdble"); // (IDL_LONG) kw.get_dimdble; + sout->get_timedble = (IDL_LONG)udaGetProperty("get_timedble"); // (IDL_LONG) kw.get_timedble; + sout->get_scalar = (IDL_LONG)udaGetProperty("get_scalar"); // (IDL_LONG) kw.get_scalar; + sout->get_bytes = (IDL_LONG)udaGetProperty("get_bytes"); // (IDL_LONG) kw.get_bytes; + sout->get_asis = (IDL_LONG)udaGetProperty("get_asis"); // (IDL_LONG) kw.get_asis; + sout->get_bad = (IDL_LONG)udaGetProperty("get_bad"); // (IDL_LONG) kw.get_bad; + sout->get_meta = (IDL_LONG)udaGetProperty("get_meta"); // (IDL_LONG) kw.get_meta; + sout->get_uncal = (IDL_LONG)udaGetProperty("get_uncal"); // (IDL_LONG) kw.get_uncal; + sout->get_notoff = (IDL_LONG)udaGetProperty("get_notoff"); // (IDL_LONG) kw.get_notoff; + sout->get_nodimdata = (IDL_LONG)udaGetProperty("get_nodimdata"); // (IDL_LONG) kw.get_nodimdata; IDL_StrStore(&(sout->signal), signal); IDL_StrStore(&(sout->source), source); @@ -1704,7 +1702,7 @@ IDL_VPTR IDL_CDECL callidam2(int argc, IDL_VPTR argv[], char* argk) // Cleanup Keywords IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (ivReturn); } @@ -1726,8 +1724,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) int useIdamGetAPI = 0; static IDL_LONG exp_number, pass = -1, mdstreenum; - CLIENT_FLAGS* client_flags = udaClientFlags(); - CLIENT_BLOCK cblock = saveIdamProperties(client_flags); // preserve the current set of client properties + CLIENT_BLOCK cblock = udaSaveProperties(); // preserve the current set of client properties int handle, rank, order, status, error_code; char* error_msg; @@ -1952,7 +1949,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_ARGUMENTS)); } @@ -1968,7 +1965,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NOT_IMPLEMENTED)); } @@ -2001,48 +1998,48 @@ callidam(int argc, IDL_VPTR argv[], char* argk) mdsnode = IDL_STRING_STR(&(asin->mdsnode)); if ((int)asin->get_datadble) { - setIdamProperty( - "get_datadble", client_flags); // Properties passed by Structure must be reset to the prior state + udaSetProperty( + "get_datadble"); // Properties passed by Structure must be reset to the prior state } if ((int)asin->get_dimdble) { - setIdamProperty("get_dimdble", client_flags); + udaSetProperty("get_dimdble"); } if ((int)asin->get_timedble) { - setIdamProperty("get_timedble", client_flags); + udaSetProperty("get_timedble"); } if ((int)asin->get_scalar) { - setIdamProperty("get_scalar", client_flags); + udaSetProperty("get_scalar"); } if ((int)asin->get_bytes) { - setIdamProperty("get_bytes", client_flags); + udaSetProperty("get_bytes"); } if ((int)asin->get_asis) { - setIdamProperty("get_asis", client_flags); + udaSetProperty("get_asis"); } if ((int)asin->get_bad) { - setIdamProperty("get_bad", client_flags); + udaSetProperty("get_bad"); } if ((int)asin->get_meta) { - setIdamProperty("get_meta", client_flags); + udaSetProperty("get_meta"); } if ((int)asin->get_uncal) { - setIdamProperty("get_uncal", client_flags); + udaSetProperty("get_uncal"); } if ((int)asin->get_notoff) { - setIdamProperty("get_notoff", client_flags); + udaSetProperty("get_notoff"); } if ((int)asin->get_nodimdata) { - setIdamProperty("get_nodimdata", client_flags); + udaSetProperty("get_nodimdata"); } if (strlen(signal) > 0 && strlen(source) > 0) { @@ -2062,7 +2059,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_EXP_NUMBER)); } @@ -2081,7 +2078,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NOT_IMPLEMENTED)); } @@ -2110,7 +2107,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_EXP_NUMBER)); } } @@ -2133,7 +2130,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_SIGNAL_ARGUMENT)); } @@ -2152,7 +2149,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NOT_IMPLEMENTED)); } @@ -2172,7 +2169,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_SIGNAL_ARGUMENT)); } @@ -2365,55 +2362,55 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } if (kw.debug) { - setIdamProperty("debug", client_flags); // Cannot be reset (currently!) + udaSetProperty("debug"); // Cannot be reset (currently!) } if (kw.verbose) { - setIdamProperty("verbose", client_flags); + udaSetProperty("verbose"); } if (kw.get_datadble) { - setIdamProperty("get_datadble", client_flags); // Properties passed by Keyword must be reset to the prior state + udaSetProperty("get_datadble"); // Properties passed by Keyword must be reset to the prior state } if (kw.get_dimdble) { - setIdamProperty("get_dimdble", client_flags); + udaSetProperty("get_dimdble"); } if (kw.get_timedble) { - setIdamProperty("get_timedble", client_flags); + udaSetProperty("get_timedble"); } if (kw.get_scalar) { - setIdamProperty("get_scalar", client_flags); + udaSetProperty("get_scalar"); } if (kw.get_bytes) { - setIdamProperty("get_bytes", client_flags); + udaSetProperty("get_bytes"); } if (kw.get_asis) { - setIdamProperty("get_asis", client_flags); + udaSetProperty("get_asis"); } if (kw.get_bad) { - setIdamProperty("get_bad", client_flags); + udaSetProperty("get_bad"); } if (kw.get_meta) { - setIdamProperty("get_meta", client_flags); + udaSetProperty("get_meta"); } if (kw.get_uncal) { - setIdamProperty("get_uncal", client_flags); + udaSetProperty("get_uncal"); } if (kw.get_notoff) { - setIdamProperty("get_notoff", client_flags); + udaSetProperty("get_notoff"); } if (kw.get_nodimdata) { - setIdamProperty("get_nodimdata", client_flags); + udaSetProperty("get_nodimdata"); } //-------------------------------------------------------------------------- @@ -2422,7 +2419,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) if (kw.help) { userhelp(stdout, "getidam"); IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(0)); } @@ -2515,7 +2512,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_API_IDENTIFIED)); } } @@ -2540,7 +2537,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_BAD_HANDLE)); } @@ -2557,7 +2554,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_HEAP_ALLOC_ERROR)); } @@ -2573,17 +2570,17 @@ callidam(int argc, IDL_VPTR argv[], char* argk) sout->status = (IDL_LONG)status; sout->error_code = (IDL_LONG)error_code; - sout->get_datadble = (IDL_LONG)getIdamProperty("get_datadble", client_flags); // (IDL_LONG) kw.get_datadble; - sout->get_dimdble = (IDL_LONG)getIdamProperty("get_dimdble", client_flags); // (IDL_LONG) kw.get_dimdble; - sout->get_timedble = (IDL_LONG)getIdamProperty("get_timedble", client_flags); // (IDL_LONG) kw.get_timedble; - sout->get_scalar = (IDL_LONG)getIdamProperty("get_scalar", client_flags); // (IDL_LONG) kw.get_scalar; - sout->get_bytes = (IDL_LONG)getIdamProperty("get_bytes", client_flags); // (IDL_LONG) kw.get_bytes; - sout->get_asis = (IDL_LONG)getIdamProperty("get_asis", client_flags); // (IDL_LONG) kw.get_asis; - sout->get_bad = (IDL_LONG)getIdamProperty("get_bad", client_flags); // (IDL_LONG) kw.get_bad; - sout->get_meta = (IDL_LONG)getIdamProperty("get_meta", client_flags); // (IDL_LONG) kw.get_meta; - sout->get_uncal = (IDL_LONG)getIdamProperty("get_uncal", client_flags); // (IDL_LONG) kw.get_uncal; - sout->get_notoff = (IDL_LONG)getIdamProperty("get_notoff", client_flags); // (IDL_LONG) kw.get_notoff; - sout->get_nodimdata = (IDL_LONG)getIdamProperty("get_nodimdata", client_flags); // (IDL_LONG) kw.get_nodimdata; + sout->get_datadble = (IDL_LONG)udaGetProperty("get_datadble"); // (IDL_LONG) kw.get_datadble; + sout->get_dimdble = (IDL_LONG)udaGetProperty("get_dimdble"); // (IDL_LONG) kw.get_dimdble; + sout->get_timedble = (IDL_LONG)udaGetProperty("get_timedble"); // (IDL_LONG) kw.get_timedble; + sout->get_scalar = (IDL_LONG)udaGetProperty("get_scalar"); // (IDL_LONG) kw.get_scalar; + sout->get_bytes = (IDL_LONG)udaGetProperty("get_bytes"); // (IDL_LONG) kw.get_bytes; + sout->get_asis = (IDL_LONG)udaGetProperty("get_asis"); // (IDL_LONG) kw.get_asis; + sout->get_bad = (IDL_LONG)udaGetProperty("get_bad"); // (IDL_LONG) kw.get_bad; + sout->get_meta = (IDL_LONG)udaGetProperty("get_meta"); // (IDL_LONG) kw.get_meta; + sout->get_uncal = (IDL_LONG)udaGetProperty("get_uncal"); // (IDL_LONG) kw.get_uncal; + sout->get_notoff = (IDL_LONG)udaGetProperty("get_notoff"); // (IDL_LONG) kw.get_notoff; + sout->get_nodimdata = (IDL_LONG)udaGetProperty("get_nodimdata"); // (IDL_LONG) kw.get_nodimdata; IDL_StrStore(&(sout->signal), signal); IDL_StrStore(&(sout->source), source); @@ -2627,7 +2624,7 @@ callidam(int argc, IDL_VPTR argv[], char* argk) // Cleanup Keywords IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (ivReturn); } @@ -2640,11 +2637,10 @@ getidamdata(int argc, IDL_VPTR argv[], char* argk) int data_n, rank, ndata, errtype; - CLIENT_FLAGS* client_flags = udaClientFlags(); - CLIENT_BLOCK cblock = saveIdamProperties(client_flags); // preserve the current set of client properties + CLIENT_BLOCK cblock = udaSaveProperties(); // preserve the current set of client properties CLIENT_BLOCK* idamcblock = NULL; int data_get_bad = 0; - int client_get_bad = getIdamProperty("get_bad", client_flags); // Current client get_bad property + int client_get_bad = udaGetProperty("get_bad"); // Current client get_bad property IDAM_SIN* sin = NULL; // Input Structure IDAM_DOUT* sout = NULL; // Returned Structure @@ -2845,7 +2841,7 @@ getidamdata(int argc, IDL_VPTR argv[], char* argk) } if ((int)sin->get_bad) { // Reset on exit - setIdamProperty("get_bad", client_flags); + udaSetProperty("get_bad"); client_get_bad = 1; } @@ -2871,7 +2867,7 @@ getidamdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_DATA_HAS_ERROR)); } @@ -2889,7 +2885,7 @@ getidamdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_DATA_TO_RETURN)); } @@ -2907,7 +2903,7 @@ getidamdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_DATA_TO_RETURN)); } @@ -2917,7 +2913,7 @@ getidamdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_DATA_TO_RETURN)); } @@ -2927,7 +2923,7 @@ getidamdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_RANK_TOO_HIGH)); } @@ -3134,7 +3130,7 @@ getidamdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_UNKNOWN_DATA_TYPE)); } @@ -3144,7 +3140,7 @@ getidamdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_HEAP_ALLOC_ERROR)); } @@ -3174,7 +3170,7 @@ getidamdata(int argc, IDL_VPTR argv[], char* argk) // Cleanup Keywords and IDAM Heap IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (ivReturn); } @@ -3199,11 +3195,10 @@ getdataarray(int argc, IDL_VPTR argv[], char* argk) IDAM_SIN* sin; // Returned Structure - CLIENT_FLAGS* client_flags = udaClientFlags(); - CLIENT_BLOCK cblock = saveIdamProperties(client_flags); // preserve the current set of client properties + CLIENT_BLOCK cblock = udaSaveProperties(); // preserve the current set of client properties CLIENT_BLOCK* idamcblock = NULL; int data_get_bad = 0; - int client_get_bad = getIdamProperty("get_bad", client_flags); // Current client get_bad property + int client_get_bad = udaGetProperty("get_bad"); // Current client get_bad property char* dvec; IDL_VPTR idlArray = NULL; @@ -3259,7 +3254,7 @@ getdataarray(int argc, IDL_VPTR argv[], char* argk) sin = (IDAM_SIN*)argv[0]->value.s.arr->data; // Input Structure if ((int)sin->get_bad) { // Reset on exit - setIdamProperty("get_bad", client_flags); + udaSetProperty("get_bad"); client_get_bad = 1; } @@ -3289,7 +3284,7 @@ getdataarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_DATA_HAS_ERROR)); } @@ -3303,7 +3298,7 @@ getdataarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_DATA_TO_RETURN)); } @@ -3402,7 +3397,7 @@ getdataarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_UNKNOWN_DATA_TYPE)); } @@ -3411,7 +3406,7 @@ getdataarray(int argc, IDL_VPTR argv[], char* argk) // Cleanup Keywords IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (idlArray); } @@ -3437,11 +3432,10 @@ geterrorarray(int argc, IDL_VPTR argv[], char* argk) IDAM_SIN* sin; // Returned Structure - CLIENT_FLAGS* client_flags = udaClientFlags(); - CLIENT_BLOCK cblock = saveIdamProperties(client_flags); //preserve the current set of client properties + CLIENT_BLOCK cblock = udaSaveProperties(); //preserve the current set of client properties CLIENT_BLOCK* idamcblock = NULL; int data_get_bad = 0; - int client_get_bad = getIdamProperty("get_bad", client_flags); // Current client get_bad property + int client_get_bad = udaGetProperty("get_bad"); // Current client get_bad property char* dvec; IDL_VPTR idlArray = NULL; @@ -3497,7 +3491,7 @@ geterrorarray(int argc, IDL_VPTR argv[], char* argk) sin = (IDAM_SIN*)argv[0]->value.s.arr->data; // Input Structure if ((int)sin->get_bad) { // Reset on exit - setIdamProperty("get_bad", client_flags); + udaSetProperty("get_bad"); client_get_bad = 1; } @@ -3507,7 +3501,7 @@ geterrorarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_VALID_HANDLE)); } @@ -3528,7 +3522,7 @@ geterrorarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_DATA_HAS_ERROR)); } @@ -3542,7 +3536,7 @@ geterrorarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_DATA_TO_RETURN)); } @@ -3643,7 +3637,7 @@ geterrorarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_UNKNOWN_DATA_TYPE)); } @@ -3652,7 +3646,7 @@ geterrorarray(int argc, IDL_VPTR argv[], char* argk) // Cleanup Keywords IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (idlArray); } @@ -3681,11 +3675,10 @@ getidamdimdata(int argc, IDL_VPTR argv[], char* argk) IDAM_SIN* sin = NULL; // Input Structure IDAM_DIMOUT* sout = NULL; // Returned Structure - CLIENT_FLAGS* client_flags = udaClientFlags(); - CLIENT_BLOCK cblock = saveIdamProperties(client_flags); // preserve the current set of client properties + CLIENT_BLOCK cblock = udaSaveProperties(); // preserve the current set of client properties CLIENT_BLOCK* idamcblock = NULL; int data_get_bad = 0; - int client_get_bad = getIdamProperty("get_bad", client_flags); // Current client get_bad property + int client_get_bad = udaGetProperty("get_bad"); // Current client get_bad property IDL_VPTR ivReturn = NULL; @@ -3888,7 +3881,7 @@ getidamdimdata(int argc, IDL_VPTR argv[], char* argk) dimid = IDL_LongScalar(argv[1]); if ((int)sin->get_bad) { // Reset on exit - setIdamProperty("get_bad", client_flags); + udaSetProperty("get_bad"); client_get_bad = 1; } @@ -3898,7 +3891,7 @@ getidamdimdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_VALID_HANDLE)); } @@ -3919,7 +3912,7 @@ getidamdimdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_DATA_HAS_ERROR)); } @@ -3933,7 +3926,7 @@ getidamdimdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_DATA_TO_RETURN)); } @@ -3946,7 +3939,7 @@ getidamdimdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_SUCH_DIMENSION)); } @@ -4119,7 +4112,7 @@ getidamdimdata(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_HEAP_ALLOC_ERROR)); } @@ -4141,7 +4134,7 @@ getidamdimdata(int argc, IDL_VPTR argv[], char* argk) // Cleanup Keywords IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (ivReturn); } @@ -4165,11 +4158,10 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) IDAM_SIN* sin; // Returned Structure - CLIENT_FLAGS* client_flags = udaClientFlags(); - CLIENT_BLOCK cblock = saveIdamProperties(client_flags); // preserve the current set of client properties + CLIENT_BLOCK cblock = udaSaveProperties(); // preserve the current set of client properties CLIENT_BLOCK* idamcblock = NULL; int data_get_bad = 0; - int client_get_bad = getIdamProperty("get_bad", client_flags); // Current client get_bad property + int client_get_bad = udaGetProperty("get_bad"); // Current client get_bad property char* dvec; IDL_VPTR idlArray = NULL; @@ -4228,7 +4220,7 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) dimid = IDL_LongScalar(argv[1]); if ((int)sin->get_bad) { // Reset on exit - setIdamProperty("get_bad", client_flags); + udaSetProperty("get_bad"); client_get_bad = 1; } @@ -4238,7 +4230,7 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_VALID_HANDLE)); } @@ -4259,7 +4251,7 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_DATA_HAS_ERROR)); } @@ -4273,7 +4265,7 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_DATA_TO_RETURN)); } @@ -4286,7 +4278,7 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_NO_SUCH_DIMENSION)); } @@ -4403,7 +4395,7 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) } IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (IDL_GettmpLong(GDE_UNKNOWN_DATA_TYPE)); } @@ -4412,7 +4404,7 @@ getdimdataarray(int argc, IDL_VPTR argv[], char* argk) // Cleanup Keywords IDL_KW_FREE; - restoreIdamProperties(cblock, client_flags); + udaRestoreProperties(cblock); return (idlArray); } @@ -6865,8 +6857,7 @@ setproperty(int argc, IDL_VPTR argv[], char* argk) { IDL_ENSURE_STRING(argv[0]); // Single String IDL_ENSURE_SCALAR(argv[0]); - CLIENT_FLAGS* client_flags = udaClientFlags(); - setIdamProperty((char*)IDL_STRING_STR(&argv[0]->value.str), client_flags); + udaSetProperty((char*)IDL_STRING_STR(&argv[0]->value.str)); return (IDL_GettmpLong(0)); } @@ -6876,8 +6867,7 @@ resetproperty(int argc, IDL_VPTR argv[], char* argk) { IDL_ENSURE_STRING(argv[0]); // Single String IDL_ENSURE_SCALAR(argv[0]); - CLIENT_FLAGS* client_flags = udaClientFlags(); - resetIdamProperty((char*)IDL_STRING_STR(&argv[0]->value.str), client_flags); + udaResetProperty((char*)IDL_STRING_STR(&argv[0]->value.str)); return (IDL_GettmpLong(0)); } @@ -6885,8 +6875,7 @@ IDL_VPTR IDL_CDECL resetproperties(int argc, IDL_VPTR argv[], char* argk) { - CLIENT_FLAGS* client_flags = udaClientFlags(); - resetIdamProperties(client_flags); + udaResetProperties(); return (IDL_GettmpLong(0)); } @@ -6895,8 +6884,7 @@ IDL_VPTR IDL_CDECL setidamclientflag(int argc, IDL_VPTR argv[], char* argk) { IDL_ENSURE_SCALAR(argv[0]); - CLIENT_FLAGS* client_flags = udaClientFlags(); - setIdamClientFlag(client_flags, (unsigned int)IDL_ULongScalar(argv[0])); + udaSetClientFlag((unsigned int)IDL_ULongScalar(argv[0])); return (IDL_GettmpLong(0)); } @@ -6905,8 +6893,7 @@ IDL_VPTR IDL_CDECL resetidamclientflag(int argc, IDL_VPTR argv[], char* argk) { IDL_ENSURE_SCALAR(argv[0]); - CLIENT_FLAGS* client_flags = udaClientFlags(); - resetIdamClientFlag(client_flags, (unsigned int)IDL_ULongScalar(argv[0])); + udaResetClientFlag((unsigned int)IDL_ULongScalar(argv[0])); return (IDL_GettmpLong(0)); } @@ -7392,8 +7379,7 @@ IDL_VPTR IDL_CDECL getlasthandle(int argc, IDL_VPTR argv[], char* argk) { - CLIENT_FLAGS* client_flags = udaClientFlags(); - return (IDL_GettmpLong(getIdamLastHandle(client_flags))); + return (IDL_GettmpLong(udaGetLastHandle())); } //==================================================================================== diff --git a/source/wrappers/java/idam_jni.c b/source/wrappers/java/idam_jni.c index 0efaa344..14e81dc7 100755 --- a/source/wrappers/java/idam_jni.c +++ b/source/wrappers/java/idam_jni.c @@ -95,12 +95,12 @@ JNIEXPORT void JNICALL Java_jIdam_Idam_resetIdamPrivateFlag(JNIEnv* env, jobject JNIEXPORT void JNICALL Java_jIdam_Idam_setIdamClientFlag(JNIEnv* env, jobject obj, jint flag) { - setIdamClientFlag(udaClientFlags(), (unsigned int)flag); + udaSetClientFlag((unsigned int)flag); } JNIEXPORT void JNICALL Java_jIdam_Idam_resetIdamClientFlag(JNIEnv* env, jobject obj, jint flag) { - resetIdamClientFlag(udaClientFlags(), (unsigned int)flag); + udaResetClientFlag((unsigned int)flag); } //-------------------------------------------------------------- @@ -110,7 +110,7 @@ JNIEXPORT void JNICALL Java_jIdam_Idam_setIdamProperty(JNIEnv* env, jobject obj, { const char* property = (*env)->GetStringUTFChars(env, _property, NULL); if (property == NULL) return; - setIdamProperty(property, udaClientFlags()); + udaSetProperty(property); (*env)->ReleaseStringUTFChars(env, _property, property); } @@ -118,7 +118,7 @@ JNIEXPORT jint JNICALL Java_jIdam_Idam_getIdamProperty(JNIEnv* env, jobject obj, { const char* property = (*env)->GetStringUTFChars(env, _property, NULL); if (property == NULL) return 0; - jint value = (jint)getIdamProperty(property, udaClientFlags()); + jint value = (jint)udaGetProperty(property); (*env)->ReleaseStringUTFChars(env, _property, property); return (value); } @@ -127,13 +127,13 @@ JNIEXPORT void JNICALL Java_jIdam_Idam_resetIdamProperty(JNIEnv* env, jobject ob { const char* property = (*env)->GetStringUTFChars(env, _property, NULL); if (property == NULL) return; - resetIdamProperty(property, udaClientFlags()); + udaResetProperty(property); (*env)->ReleaseStringUTFChars(env, _property, property); } JNIEXPORT void JNICALL Java_jIdam_Idam_resetIdamProperties(JNIEnv* env, jobject obj) { - resetIdamProperties(udaClientFlags()); + udaResetProperties(); } //-------------------------------------------------------------- @@ -257,7 +257,7 @@ JNIEXPORT jint JNICALL Java_jIdam_Idam_getIdamDataStatus(JNIEnv* env, jobject ob JNIEXPORT jint JNICALL Java_jIdam_Idam_getIdamLastHandle(JNIEnv* env, jobject obj) { - return (jint)getIdamLastHandle(udaClientFlags()); + return (jint)udaGetLastHandle(); } diff --git a/source/wrappers/java/idam_jni.h b/source/wrappers/java/idam_jni.h index 18f9163b..40014d7b 100755 --- a/source/wrappers/java/idam_jni.h +++ b/source/wrappers/java/idam_jni.h @@ -44,7 +44,7 @@ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_setIdamPrivateFlag /* * Class: Idam - * Method: setIdamClientFlag + * Method: udaSetClientFlag * Signature: (I)V */ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_setIdamClientFlag @@ -52,7 +52,7 @@ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_setIdamClientFlag /* * Class: Idam - * Method: setIdamProperty + * Method: udaSetProperty * Signature: (Ljava/lang/String;)V */ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_setIdamProperty @@ -60,7 +60,7 @@ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_setIdamProperty /* * Class: Idam - * Method: getIdamProperty + * Method: udaGetProperty * Signature: (Ljava/lang/String;)I */ LIBRARY_API JNIEXPORT jint JNICALL Java_Idam_getIdamProperty @@ -76,7 +76,7 @@ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_resetIdamPrivateFlag /* * Class: Idam - * Method: resetIdamClientFlag + * Method: udaResetClientFlag * Signature: (I)V */ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_resetIdamClientFlag @@ -84,7 +84,7 @@ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_resetIdamClientFlag /* * Class: Idam - * Method: resetIdamProperty + * Method: udaResetProperty * Signature: (Ljava/lang/String;)V */ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_resetIdamProperty @@ -92,7 +92,7 @@ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_resetIdamProperty /* * Class: Idam - * Method: resetIdamProperties + * Method: udaResetProperties * Signature: ()V */ LIBRARY_API JNIEXPORT void JNICALL Java_Idam_resetIdamProperties @@ -268,7 +268,7 @@ LIBRARY_API JNIEXPORT jint JNICALL Java_Idam_getIdamDataStatus /* * Class: Idam - * Method: getIdamLastHandle + * Method: udaGetLastHandle * Signature: (I)I */ LIBRARY_API JNIEXPORT jint JNICALL Java_Idam_getIdamLastHandle diff --git a/source/wrappers/java/jIdam/Idam.java b/source/wrappers/java/jIdam/Idam.java index dee74a69..c4a91564 100755 --- a/source/wrappers/java/jIdam/Idam.java +++ b/source/wrappers/java/jIdam/Idam.java @@ -31,14 +31,14 @@ public class Idam { // Set Server Properties public static native void setIdamPrivateFlag(int flag); - public static native void setIdamClientFlag(int flag); - public static native void setIdamProperty(String property); - public static native int getIdamProperty(String property); + public static native void udaSetClientFlag(int flag); + public static native void udaSetProperty(String property); + public static native int udaGetProperty(String property); public static native void resetIdamPrivateFlag(int flag); - public static native void resetIdamClientFlag(int flag); - public static native void resetIdamProperty(String property); - public static native void resetIdamProperties(); + public static native void udaResetClientFlag(int flag); + public static native void udaResetProperty(String property); + public static native void udaResetProperties(); // Server Identification @@ -77,7 +77,7 @@ public class Idam { // Last Data Access structure handle - public static native int getIdamLastHandle(int handle); + public static native int udaGetLastHandle(int handle); // Data properties diff --git a/source/wrappers/python/CMakeLists.txt b/source/wrappers/python/CMakeLists.txt index 9cf44455..acbed12f 100755 --- a/source/wrappers/python/CMakeLists.txt +++ b/source/wrappers/python/CMakeLists.txt @@ -5,6 +5,7 @@ install( FILES ${CYTHON_FILES} pyuda/cpyuda/uda.pxd DESTINATION python_installer file( GLOB INSTALL_FILES pyuda/*.py ) install( FILES ${INSTALL_FILES} DESTINATION python_installer/pyuda ) +install( FILES ${CMAKE_CURRENT_LIST_DIR}/uda/__init__.py DESTINATION python_installer/uda ) configure_file( ${CMAKE_CURRENT_LIST_DIR}/pyuda/_version.py.in ${CMAKE_CURRENT_BINARY_DIR}/pyuda/_version.py @ONLY ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/pyuda/_version.py DESTINATION python_installer/pyuda ) @@ -54,3 +55,5 @@ endif() configure_file( ${CMAKE_CURRENT_LIST_DIR}/setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py @ONLY ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.py DESTINATION python_installer ) +install( FILES ${CMAKE_CURRENT_LIST_DIR}/pyproject.toml DESTINATION python_installer ) +install( FILES ${CMAKE_CURRENT_LIST_DIR}/README.md DESTINATION python_installer ) diff --git a/source/wrappers/python/README.md b/source/wrappers/python/README.md new file mode 100644 index 00000000..ac796c68 --- /dev/null +++ b/source/wrappers/python/README.md @@ -0,0 +1,19 @@ +pyuda is the python interface to the uda client library. It is used for remote access to scientific and experimental data from a number of international labs hosting uda data servers. + +- **Website:** https://ukaea.github.io/UDA/ +- **Documentation:** https://ukaea.github.io/UDA/ +- **Source Code:** https://github.com/ukaea/UDA +- **Issue Tracker:** https://github.com/ukaea/UDA/issues + + +## Quick-start + +```py +import pyuda + +pyuda.Client.server = "" +pyuda.Client.port = +client = pyuda.Client() +signal_object = client.get(signal, source) + +``` diff --git a/source/wrappers/python/pyproject.toml b/source/wrappers/python/pyproject.toml new file mode 100644 index 00000000..b2ab0a42 --- /dev/null +++ b/source/wrappers/python/pyproject.toml @@ -0,0 +1,37 @@ +[build-system] +requires = [ + "setuptools>=42", + "oldest-supported-numpy; python_version < '3.13'", + "numpy >=1.7, <2; python_version >= '3.13'", + "Cython>=0.29", + "six" +] +build-backend = "setuptools.build_meta" + +[project.urls] +homepage = "https://ukaea.github.io/UDA/" +documentation = "https://ukaea.github.io/UDA/" +source = "https://github.com/ukaea/UDA" +tracker = "https://github.com/ukaea/UDA/issues" + +[project] +name = "uda" +dynamic = ["version"] +readme = {file = 'README.md', content-type = "text/markdown"} +license = {text = "Apache-2.0 license"} +dependencies = ["numpy>1.7, <2", "six"] +requires-python = ">= 3.5" + +classifiers = [ + 'Intended Audience :: Science/Research', + 'Programming Language :: C', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3 :: Only', + 'Operating System :: POSIX :: Linux', + 'Operating System :: MacOS :: MacOS X', +] + + +[project.optional-dependencies] +plot = ["pyplot"] +full = ["pyplot", "rich"] diff --git a/source/wrappers/python/pyuda/cpyuda/client.pyx b/source/wrappers/python/pyuda/cpyuda/client.pyx index 0dc57b7c..122a706c 100644 --- a/source/wrappers/python/pyuda/cpyuda/client.pyx +++ b/source/wrappers/python/pyuda/cpyuda/client.pyx @@ -40,21 +40,19 @@ else: def set_property(prop_name, value): if prop_name.lower() not in _properties: raise ValueError('invalid property ' + prop_name) - cdef uda.CLIENT_FLAGS* client_flags = uda.udaClientFlags() if _properties[prop_name][1]: prop_string = prop_name + '=' + str(value) - uda.setIdamProperty(prop_string.encode(), client_flags) + uda.udaSetProperty(prop_string.encode()) elif value: - uda.setIdamProperty(prop_name.encode(), client_flags) + uda.udaSetProperty(prop_name.encode()) else: - uda.resetIdamProperty(prop_name.encode(), client_flags) + uda.udaResetProperty(prop_name.encode()) def get_property(prop_name): if prop_name.lower() not in _properties: raise ValueError('invalid property ' + prop_name) - cdef uda.CLIENT_FLAGS* client_flags = uda.udaClientFlags() - prop = uda.getIdamProperty(prop_name.encode(), client_flags) + prop = uda.udaGetProperty(prop_name.encode()) if _properties[prop_name][1]: return prop else: diff --git a/source/wrappers/python/pyuda/cpyuda/uda.pxd b/source/wrappers/python/pyuda/cpyuda/uda.pxd index edbc188a..5a1b447c 100644 --- a/source/wrappers/python/pyuda/cpyuda/uda.pxd +++ b/source/wrappers/python/pyuda/cpyuda/uda.pxd @@ -112,9 +112,9 @@ cdef extern from "client/accAPI.h": int getIdamErrorType(int handle); void putIdamServerHost(const char* host); void putIdamServerPort(int port); - int getIdamProperty(const char* property, const CLIENT_FLAGS* client_flags) - void setIdamProperty(const char* property, CLIENT_FLAGS* client_flags); - void resetIdamProperty(const char* property, CLIENT_FLAGS* client_flags); + int udaGetProperty(const char* property) + void udaSetProperty(const char* property); + void udaResetProperty(const char* property); const char* getIdamDataLabel(int handle); const char* getIdamDataUnits(int handle); const char* getIdamDataDesc(int handle); diff --git a/source/wrappers/python/setup.py.in b/source/wrappers/python/setup.py.in index c94e793f..2c4da60c 100644 --- a/source/wrappers/python/setup.py.in +++ b/source/wrappers/python/setup.py.in @@ -3,7 +3,7 @@ import os import sys import sysconfig -from distutils.core import setup, Extension +from setuptools import setup, Extension from Cython.Build import cythonize from Cython.Compiler.Main import default_options import numpy @@ -11,7 +11,7 @@ import numpy default_options['compile_time_env'] = {'CAPNP': @CAPNP_FLAG@} extra_link_args = [] -extra_compile_args = ['-std=c++11'] +extra_compile_args = ['-std=c++17'] root = os.environ.get('UDA_DIR', '@CMAKE_INSTALL_PREFIX@') @@ -78,15 +78,21 @@ ext = Extension( define_macros=extra_macros, ) + +def get_version(v): + if v.count('.') > 2: + v = ".Post".join(v.rsplit('.', 1)) + print("setup version = %s" % v) + return v + + setup( - name='@PROJECT_NAME@', - version='@PROJECT_VERSION@', + name='uda', + version=get_version('@PROJECT_VERSION@'), description='Unified Data Access (UDA)', + long_description='Unified Data Access (UDA)', author='Jonathan Hollocombe', author_email='jonathan.hollocombe@ukaea.uk', - url='https://github.com/ukaea/UDA', - packages=['pyuda'], + packages=['pyuda', 'uda'], ext_modules=cythonize([ext]), - setup_requires=['numpy>=1.7', 'Cython>=0.29', 'six'], - install_requires=['numpy>=1.7', 'six'], ) diff --git a/source/wrappers/python/uda/__init__.py b/source/wrappers/python/uda/__init__.py new file mode 100644 index 00000000..d16731cc --- /dev/null +++ b/source/wrappers/python/uda/__init__.py @@ -0,0 +1,24 @@ +from __future__ import (division, print_function, absolute_import) + +from logging import DEBUG, WARNING, INFO, ERROR + +from pyuda import cpyuda + +from pyuda._client import Client +from pyuda._signal import Signal +from pyuda._video import Video +from pyuda._dim import Dim +from pyuda._structured import StructuredData +from pyuda._json import SignalEncoder, SignalDecoder +from pyuda._version import __version__, __version_info__ + + +UDAException = cpyuda.UDAException +ProtocolException = cpyuda.ProtocolException +ServerException = cpyuda.ServerException +InvalidUseException = cpyuda.InvalidUseException +Properties = cpyuda.Properties + + +__all__ = (UDAException, ProtocolException, ServerException, InvalidUseException, + Client, Signal, Video, Dim, Properties, DEBUG, WARNING, INFO, ERROR)