diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 33ca057e..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: CI - -on: - # Run the jobs on either push or a pull_request, but not both. - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - build-linux: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - compiler: gcc - config: cmake - - compiler: clang - config: cmake - - compiler: clang - config: asan - - compiler: clang - config: tsan - - compiler: clang - config: format - - compiler: clang - config: scan-build - - compiler: clang - config: framing - - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Install Prerequisites - shell: bash - run: sudo apt install -y ninja-build libpopt-dev - - - name: Configure Build & Test - shell: bash - env: - CC: ${{ matrix.compiler }} - run: ./travis.sh ${{ matrix.config }} - - build-macox: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Install Prerequisites - shell: bash - run: brew install ninja popt - - - name: Configure Build & Test - shell: bash - run: ./travis.sh macos - - build-win32: - runs-on: windows-latest - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Install Prerequisites - run: choco install openssl - - name: Configure Build & Test - shell: bash - run: | - cmake -E make_directory build/ - cmake -S . -B build/ -DBUILD_EXAMPLES=ON -DCMAKE_C_FLAGS=" /W4" - cmake --build build/ --config Debug --target INSTALL - ctest -V ./build/ diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml deleted file mode 100644 index c71a7e4f..00000000 --- a/.github/workflows/cifuzz.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: CIFuzz -on: [pull_request] -jobs: - Fuzzing: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - sanitizer: [address, undefined, memory] - steps: - - name: Build Fuzzers (${{ matrix.sanitizer }}) - id: build - uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master - with: - oss-fuzz-project-name: 'rabbitmq-c' - dry-run: false - language: c - sanitizer: ${{ matrix.sanitizer }} - - name: Run Fuzzers (${{ matrix.sanitizer }}) - uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master - with: - oss-fuzz-project-name: 'rabbitmq-c' - dry-run: false - language: c - fuzz-seconds: 300 - sanitizer: ${{ matrix.sanitizer }} - - name: Upload Crash - uses: actions/upload-artifact@v1 - if: failure() && steps.build.outcome == 'success' - with: - name: ${{ matrix.sanitizer }}-artifacts - path: ./out/artifacts diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 23553cab..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ master ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ master ] - schedule: - - cron: '18 10 * * 3' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'cpp' ] - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - - - name: Install Prerequisites - shell: bash - run: sudo apt install -y ninja-build libpopt-dev - - - name: Build - shell: bash - run: | - mkdir $PWD/build - cmake -S . -B build -GNinja \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_EXAMPLES=ON \ - -DBUILD_TOOLS=ON - cmake --build build - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 758c95af..34e1b8bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,6 +133,7 @@ option(BUILD_STATIC_LIBS "Build rabbitmq-c as a static library" ON) option(INSTALL_STATIC_LIBS "Install rabbitmq-c static library" ON) option(BUILD_EXAMPLES "Build Examples" OFF) +option(BUILD_LABVIEW "Build LabVIEW shared library" ON) option(BUILD_TOOLS "Build Tools (requires POPT Library)" OFF) cmake_dependent_option(BUILD_TOOLS_DOCS "Build man pages for tools (requires xmlto)" OFF "BUILD_TOOLS" OFF) option(BUILD_API_DOCS "Build Doxygen API docs" OFF) @@ -162,6 +163,13 @@ if(BUILD_EXAMPLES) add_subdirectory(examples) endif() +if(BUILD_LABVIEW) + if(NOT BUILD_SHARED_LIBS) + message(FATAL_ERROR "LabVIEW require -DBUILD_SHARED_LIBS=ON") + endif() + add_subdirectory(labview) +endif() + if(BUILD_TOOLS) find_package(POPT REQUIRED) if(BUILD_TOOLS_DOCS) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index addac300..127edaa3 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,9 +1,14 @@ # rabbitmq-c Release Notes -## 0.0.1-dev - 2023-06-22 +## 0.0.1-dev - 2023-08-07 + +### Features + +- LabVIEW support (PR #8 by @kwitekrac) ### Continuous Integration -- add upstream sync workflow (PR #2 by @chicco785) - add release note workflow (PR #6 by @chicco785) -- add all issues / pr created in the repo to synchrohub project (PR #5 by @chicco785) +- add all issues / pr created in the repo to synchrohub project (PR #5 by + @chicco785) +- add upstream sync workflow (PR #2 by @chicco785) diff --git a/labview/CMakeLists.txt b/labview/CMakeLists.txt new file mode 100644 index 00000000..ddca6b77 --- /dev/null +++ b/labview/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors. +# SPDX-License-Identifier: mit + +set(RABBITMQ_LV_SOURCES + labview_rabbitmq.c + utils.c utils.h + unix/platform_utils.c +) + +set(RMQ_VERSION 3.9.5) +set(RMQ_SOVERSION 3) + +add_library(rabbitmq-lv SHARED ${RABBITMQ_LV_SOURCES}) +target_link_libraries(rabbitmq-lv PRIVATE rabbitmq::rabbitmq) + +if (THREADS_HAVE_PTHREAD_ARG) + target_compile_options(rabbitmq-lv PUBLIC "-pthread") +endif() + +if (WIN32) + set_target_properties(rabbitmq-lv PROPERTIES VERSION ${RMQ_VERSION} OUTPUT_NAME rabbitmq.${RMQ_SOVERSION}) +else (WIN32) + set_target_properties(rabbitmq-lv PROPERTIES VERSION ${RMQ_VERSION} SOVERSION ${RMQ_SOVERSION}) +endif (WIN32) + +install(TARGETS rabbitmq-lv + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) + +include_directories(/usr/local/natinst/LabVIEW-2020-64/cintools) \ No newline at end of file diff --git a/labview/README.md b/labview/README.md new file mode 100644 index 00000000..1442db2e --- /dev/null +++ b/labview/README.md @@ -0,0 +1,22 @@ +# Getting started + +This library serves as a wrapper between the native rabbitmq-c library +and LabVIEW, with its main objective being the adaptation of data types and +memory allocation for rabbitmq-c functions. + +## How to build library + +This library can be built alongside the main rabbitmq-c library using CMake. + +```bash +mkdir build ; cd build +cmake .. +cmake --build . +``` + +The LabVIEW library build can be disabled by changing the default value of the + variable "BUILD_LABVIEW" to "OFF" in the main CMakeLists.txt file. + +```bash +option(BUILD_LABVIEW "Build LabVIEW shared library" ON) +``` diff --git a/labview/cintools/ILVDataInterface.h b/labview/cintools/ILVDataInterface.h new file mode 100644 index 00000000..c600c248 --- /dev/null +++ b/labview/cintools/ILVDataInterface.h @@ -0,0 +1,607 @@ +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ +#ifndef __ILVDataInterface_h__ +#define __ILVDataInterface_h__ + +#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(NI_DSC_WIN32) +#define NIDL_STDMETHODCALLTYPE __stdcall +#else // WIN32 +#define NIDL_STDMETHODCALLTYPE +#endif // WIN32 + +#ifndef NIDL_EXTERN_C +#ifdef __cplusplus +#define NIDL_EXTERN_C extern "C" +#else // __cplusplus +#define NIDL_EXTERN_C +#endif // __cplusplus +#endif // NIDL_EXTERN_C + +#ifndef NIDL_INTERFACE +#if defined(WIN32) || (defined(PHARLAP) && PHARLAP) +#define NIDL_INTERFACE(x) struct __declspec(uuid(x)) +#else // WIN32 +#define NIDL_INTERFACE(x) struct +#endif // WIN32 +#endif // NIDL_INTERFACE +/* Forward Declarations */ + +#ifndef __ILVData_FWD_DEFINED__ +#define __ILVData_FWD_DEFINED__ +typedef struct ILVData ILVData; +#endif /* __ILVData_FWD_DEFINED__ */ + +#ifndef __ILVBoolean_FWD_DEFINED__ +#define __ILVBoolean_FWD_DEFINED__ +typedef struct ILVBoolean ILVBoolean; +#endif /* __ILVBoolean_FWD_DEFINED__ */ + +#ifndef __ILVInt8_FWD_DEFINED__ +#define __ILVInt8_FWD_DEFINED__ +typedef struct ILVInt8 ILVInt8; +#endif /* __ILVInt8_FWD_DEFINED__ */ + +#ifndef __ILVInt16_FWD_DEFINED__ +#define __ILVInt16_FWD_DEFINED__ +typedef struct ILVInt16 ILVInt16; +#endif /* __ILVInt16_FWD_DEFINED__ */ + +#ifndef __ILVInt32_FWD_DEFINED__ +#define __ILVInt32_FWD_DEFINED__ +typedef struct ILVInt32 ILVInt32; +#endif /* __ILVInt32_FWD_DEFINED__ */ + +#ifndef __ILVInt64_FWD_DEFINED__ +#define __ILVInt64_FWD_DEFINED__ +typedef struct ILVInt64 ILVInt64; +#endif /* __ILVInt64_FWD_DEFINED__ */ + +#ifndef __ILVuInt8_FWD_DEFINED__ +#define __ILVuInt8_FWD_DEFINED__ +typedef struct ILVuInt8 ILVuInt8; +#endif /* __ILVuInt8_FWD_DEFINED__ */ + +#ifndef __ILVuInt16_FWD_DEFINED__ +#define __ILVuInt16_FWD_DEFINED__ +typedef struct ILVuInt16 ILVuInt16; +#endif /* __ILVuInt16_FWD_DEFINED__ */ + +#ifndef __ILVuInt32_FWD_DEFINED__ +#define __ILVuInt32_FWD_DEFINED__ +typedef struct ILVuInt32 ILVuInt32; +#endif /* __ILVuInt32_FWD_DEFINED__ */ + +#ifndef __ILVuInt64_FWD_DEFINED__ +#define __ILVuInt64_FWD_DEFINED__ +typedef struct ILVuInt64 ILVuInt64; +#endif /* __ILVuInt64_FWD_DEFINED__ */ + +#ifndef __ILVFloat32_FWD_DEFINED__ +#define __ILVFloat32_FWD_DEFINED__ +typedef struct ILVFloat32 ILVFloat32; +#endif /* __ILVFloat32_FWD_DEFINED__ */ + +#ifndef __ILVFloat64_FWD_DEFINED__ +#define __ILVFloat64_FWD_DEFINED__ +typedef struct ILVFloat64 ILVFloat64; +#endif /* __ILVFloat64_FWD_DEFINED__ */ + +#ifndef __ILVFloatExt_FWD_DEFINED__ +#define __ILVFloatExt_FWD_DEFINED__ +typedef struct ILVFloatExt ILVFloatExt; +#endif /* __ILVFloatExt_FWD_DEFINED__ */ + +#ifndef __ILVComplex64_FWD_DEFINED__ +#define __ILVComplex64_FWD_DEFINED__ +typedef struct ILVComplex64 ILVComplex64; +#endif /* __ILVComplex64_FWD_DEFINED__ */ + +#ifndef __ILVComplex128_FWD_DEFINED__ +#define __ILVComplex128_FWD_DEFINED__ +typedef struct ILVComplex128 ILVComplex128; +#endif /* __ILVComplex128_FWD_DEFINED__ */ + +#ifndef __ILVComplexExt_FWD_DEFINED__ +#define __ILVComplexExt_FWD_DEFINED__ +typedef struct ILVComplexExt ILVComplexExt; +#endif /* __ILVComplexExt_FWD_DEFINED__ */ + +#ifndef __ILVArray_FWD_DEFINED__ +#define __ILVArray_FWD_DEFINED__ +typedef struct ILVArray ILVArray; +#endif /* __ILVArray_FWD_DEFINED__ */ + +#ifndef __ILVString_FWD_DEFINED__ +#define __ILVString_FWD_DEFINED__ +typedef struct ILVString ILVString; +#endif /* __ILVString_FWD_DEFINED__ */ + +#ifndef __ILVCluster_FWD_DEFINED__ +#define __ILVCluster_FWD_DEFINED__ +typedef struct ILVCluster ILVCluster; +#endif /* __ILVCluster_FWD_DEFINED__ */ + + +/* Header files for imported files */ + +#include "unknwn.h" + +/* Declarations */ + +// ================================================================== +// NI CONFIDENTIAL +// (c) Copyright 2006-2008 by National Instruments Corp. +// All rights reserved. +// +// @file ILVDataInterface.idl +// @brief Interface definitions for LabVIEW data. +// The files ILVDataInterface_i.c and ILVDataInterface.h +// are generated using ILVDataInterface.idl. +// ================================================================== +#include "extcode.h" +#include "ILVTypeInterface.h" +#ifndef _fundtypes_H +typedef char int8_t; + +typedef short int int16_t; + +typedef int int32_t; + +typedef long long int64_t; + +typedef unsigned char uint8_t; + +typedef unsigned short int uint16_t; + +typedef unsigned int uint32_t; + +typedef unsigned long long uint64_t; + +typedef char int_least8_t; + +typedef short int int_least16_t; + +typedef int int_least32_t; + +typedef long long int_least64_t; + +typedef unsigned char uint_least8_t; + +typedef unsigned short int uint_least16_t; + +typedef unsigned int uint_least32_t; + +typedef unsigned long long uint_least64_t; + +typedef char int_fast8_t; + +typedef int int_fast16_t; + +typedef int int_fast32_t; + +typedef long long int_fast64_t; + +typedef unsigned char uint_fast8_t; + +typedef unsigned int uint_fast16_t; + +typedef unsigned int uint_fast32_t; + +typedef unsigned long long uint_fast64_t; + +typedef int intptr_t; + +typedef unsigned int uintptr_t; + +typedef long long intmax_t; + +typedef unsigned long long uintmax_t; + +typedef char int8; + +typedef unsigned char uInt8; + +typedef uInt8 uChar; + +typedef short int int16; + +typedef unsigned short int uInt16; + +typedef int int32; + +typedef unsigned int uInt32; + +typedef float float32; + +typedef double float64; + +typedef struct { + int32 mlo; + int32 mhi; + int16 e; +} floatExt; + +typedef long long int64; + +typedef unsigned long long uInt64; + +typedef struct { + float32 re; + float32 im; +} cmplx64; + +typedef struct { + float64 re; + float64 im; +} cmplx128; + +typedef struct { + floatExt re; + floatExt im; +} cmplxExt; + +typedef int32 Bool32; + +typedef int32 HRESULT; + +typedef int32 SCODE; + +typedef int ptrdiff_t; + +typedef unsigned int size_t; + +typedef int32 MgErr; + +typedef uInt8 LVBoolean; + +#endif // ifndef _fundtypes +/* Generated header for interface ILVData */ + +NIDL_EXTERN_C const IID IID_ILVData; + +/* {4a4264a2-d5d8-468d-9675-6f1df777b295} */ +NIDL_INTERFACE("4a4264a2-d5d8-468d-9675-6f1df777b295") ILVData : public IUnknown +{ +public: + virtual MgErr NIDL_STDMETHODCALLTYPE GetType( + ILVTypeDescriptor** typeDescriptor) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Equals( + ILVData* data, + Bool32* isEqual) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Copy( + ILVData** dataOut) = 0; +} ; + +/* Generated header for interface ILVBoolean */ + +NIDL_EXTERN_C const IID IID_ILVBoolean; + +/* {7ab091d1-4154-48e2-bf98-55cc20335184} */ +NIDL_INTERFACE("7ab091d1-4154-48e2-bf98-55cc20335184") ILVBoolean : public ILVData +{ +public: + virtual LVBoolean NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + LVBoolean value) = 0; +} ; + +/* Generated header for interface ILVInt8 */ + +NIDL_EXTERN_C const IID IID_ILVInt8; + +/* {f3ee3676-1e8e-42c2-8355-e4c07d4eb769} */ +NIDL_INTERFACE("f3ee3676-1e8e-42c2-8355-e4c07d4eb769") ILVInt8 : public ILVData +{ +public: + virtual int8 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + int8 value) = 0; +} ; + +/* Generated header for interface ILVInt16 */ + +NIDL_EXTERN_C const IID IID_ILVInt16; + +/* {8567dfb4-0d6d-46d0-b87f-a5b680d3cd82} */ +NIDL_INTERFACE("8567dfb4-0d6d-46d0-b87f-a5b680d3cd82") ILVInt16 : public ILVData +{ +public: + virtual int16 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + int16 value) = 0; +} ; + +/* Generated header for interface ILVInt32 */ + +NIDL_EXTERN_C const IID IID_ILVInt32; + +/* {878fcd1e-c70f-4940-8e54-461a4d1bb5b3} */ +NIDL_INTERFACE("878fcd1e-c70f-4940-8e54-461a4d1bb5b3") ILVInt32 : public ILVData +{ +public: + virtual int32 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + int32 value) = 0; +} ; + +/* Generated header for interface ILVInt64 */ + +NIDL_EXTERN_C const IID IID_ILVInt64; + +/* {0344d202-0f76-4efb-ad02-deec0b480e47} */ +NIDL_INTERFACE("0344d202-0f76-4efb-ad02-deec0b480e47") ILVInt64 : public ILVData +{ +public: + virtual int64 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + int64 value) = 0; +} ; + +/* Generated header for interface ILVuInt8 */ + +NIDL_EXTERN_C const IID IID_ILVuInt8; + +/* {35ce47f1-7a7a-43c2-a663-a6340cd72ebb} */ +NIDL_INTERFACE("35ce47f1-7a7a-43c2-a663-a6340cd72ebb") ILVuInt8 : public ILVData +{ +public: + virtual uInt8 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + uInt8 value) = 0; +} ; + +/* Generated header for interface ILVuInt16 */ + +NIDL_EXTERN_C const IID IID_ILVuInt16; + +/* {f1d1b174-ce67-4c6e-ada6-064f3f49ba42} */ +NIDL_INTERFACE("f1d1b174-ce67-4c6e-ada6-064f3f49ba42") ILVuInt16 : public ILVData +{ +public: + virtual uInt16 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + uInt16 value) = 0; +} ; + +/* Generated header for interface ILVuInt32 */ + +NIDL_EXTERN_C const IID IID_ILVuInt32; + +/* {edfcfa65-5fe2-45b9-a372-467946433e84} */ +NIDL_INTERFACE("edfcfa65-5fe2-45b9-a372-467946433e84") ILVuInt32 : public ILVData +{ +public: + virtual uInt32 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + uInt32 value) = 0; +} ; + +/* Generated header for interface ILVuInt64 */ + +NIDL_EXTERN_C const IID IID_ILVuInt64; + +/* {b173fe84-2ce5-4d23-b1b2-da1f469e2c31} */ +NIDL_INTERFACE("b173fe84-2ce5-4d23-b1b2-da1f469e2c31") ILVuInt64 : public ILVData +{ +public: + virtual uInt64 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + uInt64 value) = 0; +} ; + +/* Generated header for interface ILVFloat32 */ + +NIDL_EXTERN_C const IID IID_ILVFloat32; + +/* {947ab4f3-5a0c-491a-9f3e-1ffa6ca9b3af} */ +NIDL_INTERFACE("947ab4f3-5a0c-491a-9f3e-1ffa6ca9b3af") ILVFloat32 : public ILVData +{ +public: + virtual float32 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + float32 value) = 0; +} ; + +/* Generated header for interface ILVFloat64 */ + +NIDL_EXTERN_C const IID IID_ILVFloat64; + +/* {6ba720b2-7641-4657-9a88-e4805c07d953} */ +NIDL_INTERFACE("6ba720b2-7641-4657-9a88-e4805c07d953") ILVFloat64 : public ILVData +{ +public: + virtual float64 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + float64 value) = 0; +} ; + +/* Generated header for interface ILVFloatExt */ + +NIDL_EXTERN_C const IID IID_ILVFloatExt; + +/* {35b495a1-ef73-4602-a91e-5307ea364870} */ +NIDL_INTERFACE("35b495a1-ef73-4602-a91e-5307ea364870") ILVFloatExt : public ILVData +{ +public: + virtual floatExt NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + floatExt value) = 0; +} ; + +/* Generated header for interface ILVComplex64 */ + +NIDL_EXTERN_C const IID IID_ILVComplex64; + +/* {b34b09a6-e681-4b7b-b81f-27718a7ac22d} */ +NIDL_INTERFACE("b34b09a6-e681-4b7b-b81f-27718a7ac22d") ILVComplex64 : public ILVData +{ +public: + virtual cmplx64 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + cmplx64 value) = 0; +} ; + +/* Generated header for interface ILVComplex128 */ + +NIDL_EXTERN_C const IID IID_ILVComplex128; + +/* {29cf50ff-334a-416b-8e62-4305d724ea74} */ +NIDL_INTERFACE("29cf50ff-334a-416b-8e62-4305d724ea74") ILVComplex128 : public ILVData +{ +public: + virtual cmplx128 NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + cmplx128 value) = 0; +} ; + +/* Generated header for interface ILVComplexExt */ + +NIDL_EXTERN_C const IID IID_ILVComplexExt; + +/* {09b41f06-659b-4fb8-8c8c-6641fde83303} */ +NIDL_INTERFACE("09b41f06-659b-4fb8-8c8c-6641fde83303") ILVComplexExt : public ILVData +{ +public: + virtual cmplxExt NIDL_STDMETHODCALLTYPE Get(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + cmplxExt value) = 0; +} ; + +/* Generated header for interface ILVArray */ + +typedef struct ArrayDimensionSpecifier { + size_t dimensionSize; + ptrdiff_t stride; +} ArrayDimensionSpecifier; +typedef struct ArraySpecifier { + void* dataPtr; + ArrayDimensionSpecifier dimensionSpecifier[1]; +} ArraySpecifier; +NIDL_EXTERN_C const IID IID_ILVArray; + +/* {5b5e5197-5580-431a-ad73-9ab7261d394d} */ +NIDL_INTERFACE("5b5e5197-5580-431a-ad73-9ab7261d394d") ILVArray : public ILVData +{ +public: + virtual MgErr NIDL_STDMETHODCALLTYPE GetNumDimensions( + uInt32* numDimensions) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetDimensions( + size_t* dimensionsBuffer) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetNumElements( + size_t* numElements) = 0; + virtual Bool32 NIDL_STDMETHODCALLTYPE IsEmpty(void) = 0; + virtual void NIDL_STDMETHODCALLTYPE Clear(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetArraySpecifier( + ArraySpecifier* arraySpecifier) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetElement( + size_t* indices, + Bool32 makeCopy, + ILVData** element) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE SetElement( + size_t* indices, + ILVData* element) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Resize( + size_t* dimensions) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Reshape( + size_t* dimensions) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE IndexArray( + size_t* indices, + ILVArray** array) = 0; +} ; + +// Template version of ArraySpecifier for use with multiple dimensions +// Use this to declare a multi-dimensional ArraySpecifier on the stack (avoiding the heap allocator) +// Usage: +// ArraySpecifierT<3> arraySpec; // 3-dimensional array specifier +// err = pIface->GetArraySpecifier((ArraySpecifier*)&arraySpec); // Cast necessary to convert to C-style ArraySpecifier +#if defined(__cplusplus) +template struct ArraySpecifierT +{ + void* dataPtr; + ArrayDimensionSpecifier dimensionSpecifier[nDims]; +}; +#endif // defined(__cplusplus) +/* Generated header for interface ILVString */ + +NIDL_EXTERN_C const IID IID_ILVString; + +/* {c021ae89-68d7-47e9-9ed7-69d9501c4f24} */ +NIDL_INTERFACE("c021ae89-68d7-47e9-9ed7-69d9501c4f24") ILVString : public ILVData +{ +public: + virtual MgErr NIDL_STDMETHODCALLTYPE Get( + const uChar** stringBuffer, + size_t* bufferLength) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetCStr( + const uChar** buffer) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Set( + const uChar* stringBuffer, + size_t bufferLength) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE SetILVString( + const ILVString* str) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Append( + const uChar* stringBuffer, + size_t bufferLength) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE AppendILVString( + const ILVString* str) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Insert( + size_t position, + const uChar* stringBuffer, + size_t bufferLength) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE InsertILVString( + size_t position, + const ILVString* str) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Replace( + size_t position, + const uChar* stringBuffer, + size_t numElements) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE ReplaceILVString( + size_t position, + const ILVString* str) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Erase( + size_t position, + size_t numElements) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE Clear(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetCapacity( + size_t* capacity) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE SetCapacity( + size_t capacity) = 0; + virtual Bool32 NIDL_STDMETHODCALLTYPE IsEmpty(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE SubString( + size_t position, + size_t length, + ILVString** subString) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetLength( + size_t* length) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetElement( + size_t position, + uChar* element) = 0; +} ; + +/* Generated header for interface ILVCluster */ + +NIDL_EXTERN_C const IID IID_ILVCluster; + +/* {5377527d-a5aa-4819-8933-adbf444e9ff4} */ +NIDL_INTERFACE("5377527d-a5aa-4819-8933-adbf444e9ff4") ILVCluster : public ILVData +{ +public: + virtual MgErr NIDL_STDMETHODCALLTYPE GetElement( + uInt32 position, + Bool32 makeCopy, + ILVData** element) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE SetElement( + uInt32 position, + ILVData* element) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetScalarElement( + uInt32 position, + uInt32 elementSize, + void* element) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE SetScalarElement( + uInt32 position, + uInt32 elementSize, + void* element) = 0; +} ; + + + +#endif /* __ILVDataInterface_h__ */ diff --git a/labview/cintools/ILVDataInterface.idl b/labview/cintools/ILVDataInterface.idl new file mode 100644 index 00000000..10089462 --- /dev/null +++ b/labview/cintools/ILVDataInterface.idl @@ -0,0 +1,881 @@ +cpp_quote("// ==================================================================") +cpp_quote("// NI CONFIDENTIAL ") +cpp_quote("// (c) Copyright 2006-2008 by National Instruments Corp. ") +cpp_quote("// All rights reserved. ") +cpp_quote("// ") +cpp_quote("// @file ILVDataInterface.idl ") +cpp_quote("// @brief Interface definitions for LabVIEW data. ") +cpp_quote("// The files ILVDataInterface_i.c and ILVDataInterface.h ") +cpp_quote("// are generated using ILVDataInterface.idl. ") +cpp_quote("// ==================================================================") + +/** + @mainpage Interface to LabVIEW data and types + + An interface is being created for LabVIEW data and types. The data interface + will allow users to interact with LabVIEW data without needed to know about + the implementation details. + + LabVIEW source code will also use this interface to data. This will allow + users outside the LabVIEW group to create their own implementation of the + data interface and pass that to LabVIEW. LabVIEW will then be able to + interact with their data directly. This will prevent the data copies to and + from LabVIEW data types from being required when passing data to and from + LabVIEW. + + The type interface will allow users to discover type information for data. + There is no reason for users outside of LabVIEW to create their own + implementation of the type interface. The LabVIEW implementation should be + sufficient. +*/ + +//============================================================================ +// Imports +//============================================================================ + +import "unknwn.idl"; + +//============================================================================ +// Interface forward declarations. +//============================================================================ + +interface ILVTypeDescriptor; + +//============================================================================ +// cpp_quotes and includes +//============================================================================ + +cpp_quote("#include \"extcode.h\"") +cpp_quote("#include \"ILVTypeInterface.h\"") + +// fundtypes.h will be included in extcode.h so we do not want a redefinition +// in the generated files. #if out the code generated by the #include of +// fundtypes.h below. +cpp_quote("#ifndef _fundtypes_H") +#define _WCHAR_T_DEFINED 1 +#include "fundtypes.h" +typedef int32 MgErr; // defined in extcode.h +typedef uInt8 LVBoolean; //defiled in extcode.h +cpp_quote("#endif // ifndef _fundtypes") + +// ============================================================================ +// Pure virtual base interface for LabVIEW data. +// ============================================================================ +[ + object, local, + uuid(4a4264a2-d5d8-468d-9675-6f1df777b295), + helpstring("ILVData"), + pointer_default(unique) +] + +/** + @brief Base class for the LabVIEW data interface +*/ +interface ILVData : IUnknown +{ + /** + @brief Get a type descriptor for the current data. + @return The error as an MgErr. + */ + MgErr GetType( + [out] ILVTypeDescriptor** typeDescriptor ///< Output the type descriptor for the data + ); + + /** + @brief Determines whether two data instances are equal. + @return The error as an MgErr. + */ + MgErr Equals( + [in] ILVData* data, ///< Data to compare this data to + [out] Bool32* isEqual ///< Return true if the data passed in equal to this data + ); + + /** + @brief Creates a copy of this object. + @return The error as an MgErr. + */ + MgErr Copy( + [out] ILVData** dataOut ///< Output a copy of this data + ); +}; + +// ============================================================================ +// Interface for a LabVIEW boolean. +// ============================================================================ +[ + object, local, + uuid(7AB091D1-4154-48e2-BF98-55CC20335184), + helpstring("ILVBoolean"), + pointer_default(unique) +] + +/** + @brief Data interface class for LVBoolean +*/ +interface ILVBoolean : ILVData +{ + /// Get the value. + LVBoolean Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] LVBoolean value ///< boolean value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW int8. +// ============================================================================ +[ + object, local, + uuid(f3ee3676-1e8e-42c2-8355-e4c07d4eb769), + helpstring("ILVInt8"), + pointer_default(unique) +] + +/** + @brief Data interface class for int8. +*/ +interface ILVInt8 : ILVData +{ + /// Get the value. + int8 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] int8 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW int16. +// ============================================================================ +[ + object, local, + uuid(8567dfb4-0d6d-46d0-b87f-a5b680d3cd82), + helpstring("ILVInt16"), + pointer_default(unique) +] + +/** + @brief Data interface class for int16. +*/ +interface ILVInt16 : ILVData +{ + /// Get the value. + int16 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] int16 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW int32. +// ============================================================================ +[ + object, local, + uuid(878fcd1e-c70f-4940-8e54-461a4d1bb5b3), + helpstring("ILVInt32"), + pointer_default(unique) +] + +/** + @brief Data interface class for int32. +*/ +interface ILVInt32 : ILVData +{ + /// Get the value. + int32 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] int32 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW int64. +// ============================================================================ +[ + object, local, + uuid(0344d202-0f76-4efb-ad02-deec0b480e47), + helpstring("ILVInt64"), + pointer_default(unique) +] + +/** + @brief Data interface class for int64. +*/ +interface ILVInt64 : ILVData +{ + /// Get the value. + int64 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] int64 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW uInt8. +// ============================================================================ +[ + object, local, + uuid(35ce47f1-7a7a-43c2-a663-a6340cd72ebb), + helpstring("ILVuInt8"), + pointer_default(unique) +] + +/** + @brief Data interface class for uInt8. +*/ +interface ILVuInt8 : ILVData +{ + /// Get the value. + uInt8 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] uInt8 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW uInt16. +// ============================================================================ +[ + object, local, + uuid(f1d1b174-ce67-4c6e-ada6-064f3f49ba42), + helpstring("ILVuInt16"), + pointer_default(unique) +] + +/** + @brief Data interface class for uInt16. +*/ +interface ILVuInt16 : ILVData +{ + /// Get the value. + uInt16 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] uInt16 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW uInt32. +// ============================================================================ +[ + object, local, + uuid(edfcfa65-5fe2-45b9-a372-467946433e84), + helpstring("ILVuInt32"), + pointer_default(unique) +] + +/** + @brief Data interface class for uInt32. +*/ +interface ILVuInt32 : ILVData +{ + /// Get the value. + uInt32 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] uInt32 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW uInt64. +// ============================================================================ +[ + object, local, + uuid(b173fe84-2ce5-4d23-b1b2-da1f469e2c31), + helpstring("ILVuInt64"), + pointer_default(unique) +] + +/** + @brief Data interface class for uInt64. +*/ +interface ILVuInt64 : ILVData +{ + /// Get the value. + uInt64 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] uInt64 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW float32. +// ============================================================================ +[ + object, local, + uuid(947ab4f3-5a0c-491a-9f3e-1ffa6ca9b3af), + helpstring("ILVFloat32"), + pointer_default(unique) +] + +/** + @brief Data interface class for float32. +*/ +interface ILVFloat32 : ILVData +{ + /// Get the value. + float32 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] float32 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW float64. +// ============================================================================ +[ + object, local, + uuid(6ba720b2-7641-4657-9a88-e4805c07d953), + helpstring("ILVFloat64"), + pointer_default(unique) +] + +/** + @brief Data interface class for float64. +*/ +interface ILVFloat64 : ILVData +{ + /// Get the value. + float64 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] float64 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW floatExt. +// ============================================================================ +[ + object, local, + uuid(35b495a1-ef73-4602-a91e-5307ea364870), + helpstring("ILVFloatExt"), + pointer_default(unique) +] + +/** + @brief Data interface class for floatExt. +*/ +interface ILVFloatExt : ILVData +{ + /// Get the value. + floatExt Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] floatExt value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW cmplx64. +// ============================================================================ +[ + object, local, + uuid(b34b09a6-e681-4B7B-b81f-27718a7ac22d), + helpstring("ILVComplex64"), + pointer_default(unique) +] + +/** + @brief Data interface class for cmplx64. +*/ +interface ILVComplex64 : ILVData +{ + /// Get the value. + cmplx64 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] cmplx64 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW cmplx128. +// ============================================================================ +[ + object, local, + uuid(29cf50ff-334a-416b-8e62-4305d724ea74), + helpstring("ILVComplex128"), + pointer_default(unique) +] + +/** + @brief Data interface class for cmplx128. +*/ +interface ILVComplex128 : ILVData +{ + /// Get the value. + cmplx128 Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] cmplx128 value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW cmplxExt. +// ============================================================================ +[ + object, local, + uuid(09b41f06-659b-4FB8-8c8c-6641fde83303), + helpstring("ILVComplexExt"), + pointer_default(unique) +] + +/** + @brief Data interface class for cmplxExt. +*/ +interface ILVComplexExt : ILVData +{ + /// Get the value. + cmplxExt Get(void); + + /** + @brief Set the value. + @return The error as an MgErr. + */ + MgErr Set( + [in] cmplxExt value ///< numeric value + ); +}; + +// ============================================================================ +// Interface for a LabVIEW array. +// ============================================================================ +[ + object, local, + uuid(5b5e5197-5580-431a-ad73-9ab7261d394d), + helpstring("ILVArray"), + pointer_default(unique) +] + +/** + @brief Data interface class for arrays. +*/ +interface ILVArray : ILVData +{ + /** + @brief Get the number of dimensions for the array. + @return The error as an MgErr. + */ + MgErr GetNumDimensions( + [out] uInt32* numDimensions ///< Output the number of dimensions in the array + ); + + /** + @brief Get the number of elements in each dimension for the array. + @return The error as an MgErr. + */ + MgErr GetDimensions( + [in, out] size_t dimensionsBuffer[] ///< INPUT: User allocated buffer of size (numDims*sizeof[size_t]). OUTPUT: Populated with dimension sizes (num elements). + ); + + /** + @brief Get the total number of elements in the array. + @return The error as an MgErr. + */ + MgErr GetNumElements( + [out] size_t* numElements ///< Output the total number of elements in the array + ); + + /** + @brief Determine whether the array is empty. + @return The TRUE if the array is empty and FALSE otherwise. + */ + Bool32 IsEmpty(void); + + /** + @brief Remove all elements from the array. + */ + void Clear(); + + /** + @brief Struct used to dimension information for an array such as size and stride information. + */ + typedef struct ArrayDimensionSpecifier + { + size_t dimensionSize; ///< Number of elements in a dimension for an array + ptrdiff_t stride; ///< Stride used to walk between elements in an array dimension + } ArrayDimensionSpecifier; + + /** + @brief Struct used to hold pointer and dimension information (sizes, strides, etc) for an array. + + LabVIEW will use this information when interacting with an array. + */ + typedef struct ArraySpecifier + { + void* dataPtr; ///< Pointer to the actual data for an array. + ArrayDimensionSpecifier dimensionSpecifier[1]; ///< Dimension information (sizes, strides, etc) for an array. One ArrayDimensionSpecifier element for each dimension in the array. + } ArraySpecifier; + + /** + @brief Populate the ArraySpecifier for an array. LabVIEW will use this information when interacting with the array. + + The ArraySpecifier struct should be allocated by the caller and filled in by this function. The number of elements in the + ArraySizeAndStride array will be equal to the number of dimensions for the array. + @return The error as an MgErr. + */ + MgErr GetArraySpecifier( + [in, out] ArraySpecifier* arraySpecifier ///< INPUT: User allocated arraySpecifier. OUTPUT: Return data pointer and dimension information for an array. + ); + + /** + @brief Get an element in the array. + @return The error as an MgErr. + */ + MgErr GetElement( + [in] size_t indices[], ///< Index of element user wants to access. NOTE: The number of elements in "indices" must equal the number of dimensions in the array. + [in] Bool32 makeCopy, ///< Specify if a copy be made for the element returned. If makeCopy is false, element will reference the element in the array. A change to one will change the other. + [out] ILVData** element ///< Array element specified by indices. + ); + + /** + @brief Set an element in the array. + @return The error as an MgErr. + */ + MgErr SetElement( + [in] size_t indices[], ///< Index of where to set the new element. NOTE: The number of elements in "indices" must equal the number of dimensions in the array. + [in] ILVData* element ///< Array element to set. + ); + + /** + @brief Resizes the array to the size specified by dimensions. + @return The error as an MgErr. + */ + MgErr Resize( + [in] size_t dimensions[] ///< Dimensions input used to resize the array. If NULL, the array will be made empty. NOTE: The number of elements in "dimensions" must equal the number of dimensions in the array. + ); + + /** + @brief Change the dimensions of the array according to the dimensions input. This is similar to the LabVIEW primitive "Reshape Array." + @return The error as an MgErr. + */ + MgErr Reshape( + [in] size_t dimensions[] ///< Dimensions input used to reshape the array. If NULL, the array will be made empty. NOTE: The number of elements in "dimensions" must equal the number of dimensions in the array. + ); + + /** + @brief Get an array subset starting at "indices." This is similar to the LabVIEW primitive "Index Array." + @return The error as an MgErr. + */ + MgErr IndexArray( + [in] size_t indices[], ///< Indices of where the array subset should be. If -1 is passed in for an index, that dimension will not be indexed and will all be returned. NOTE: The number of elements in "indices" must equal the number of dimensions in the array. + [out] ILVArray** array ///< Array subset output. The number of dimensions in this will depend on the number of dimensions in the this array and the number of elements in "indices" that are not -1. + ); +}; + +// Useful template version of ArraySpecifier for multiple dimensions. +// This is quoted because it uses templates, which aren't supported in IDL. +cpp_quote("// Template version of ArraySpecifier for use with multiple dimensions") +cpp_quote("// Use this to declare a multi-dimensional ArraySpecifier on the stack (avoiding the heap allocator)") +cpp_quote("// Usage:") +cpp_quote("// ArraySpecifierT<3> arraySpec; // 3-dimensional array specifier") +cpp_quote("// err = pIface->GetArraySpecifier((ArraySpecifier*)&arraySpec); // Cast necessary to convert to C-style ArraySpecifier") +cpp_quote("#if defined(__cplusplus)") +cpp_quote("template struct ArraySpecifierT") +cpp_quote("{") +cpp_quote(" void* dataPtr;") +cpp_quote(" ArrayDimensionSpecifier dimensionSpecifier[nDims];") +cpp_quote("};") +cpp_quote("#endif // defined(__cplusplus)") + + +// ============================================================================ +// Interface for a LabVIEW string. +// ============================================================================ +[ + object, local, + uuid(c021ae89-68d7-47e9-9ed7-69d9501c4f24), + helpstring("ILVString"), + pointer_default(unique) +] + +/** + @brief Data interface class for strings. +*/ +interface ILVString : ILVData +{ + /** + @brief Get the string. The returned string may not be NULL terminated. + + The elements of the string may not be altered. + The returned pointer is valid as long the string is not modified by a set/insert/append/replace operation. + @return The error as an MgErr + */ + MgErr Get( + [out] const uChar** stringBuffer, ///< Returned pointer to the non-NULL terminated stringBuffer + [out] size_t* bufferLength ///< Output length of stringBuffer + ); + + /** + @brief Get the string. The returned string is NULL terminated. + + The elements of the string may not be altered. + The returned pointer is valid as long the string is not modified by a set/insert/append/replace operation. + @return The NULL-terminated C-style string. + */ + MgErr GetCStr(const uChar **buffer); + + /** + @brief Set the string. + @return The error as an MgErr. + */ + MgErr Set( + [in] const uChar* stringBuffer, ///< String buffer allocated by the user that will be used to set the string data + [in] size_t bufferLength ///< Length of the stringBuffer + ); + + /** + @brief Set the string with an ILVString. + @return The error as an MgErr. + */ + MgErr SetILVString( + [in] const ILVString * str ///< ILVString to be used to set string data + ); + + /** + @brief Append another string to the end of this string. + @return The error as an MgErr. + */ + MgErr Append( + [in] const uChar* stringBuffer, ///< String buffer allocated by the user that will be used to append to the string data + [in] size_t bufferLength ///< Length of the stringBuffer + ); + + /** + @brief Append another ILVString string to the end of this string. + @return The error as an MgErr. + */ + MgErr AppendILVString( + [in] const ILVString* str ///< ILVString to append + ); + + /** + @brief Insert additional elements into the string at the specified position. + @return The error as an MgErr. + */ + MgErr Insert( + [in] size_t position, ///< Position in the data to insert the stringBuffer. + [in] const uChar* stringBuffer, ///< String buffer allocated by the user that will be used to insert into the string data + [in] size_t bufferLength ///< Length of the stringBuffer + ); + + /** + @brief Insert additional elements into the string at the specified position. + @return The error as an MgErr. + */ + MgErr InsertILVString( + [in] size_t position, ///< Position in the data to insert the ILVString + [in] const ILVString* str ///< ILVString to insert from + ); + + /** + @brief Replace a set of numElements in the string starting at index position. + from the array pointed to by stringBuffer. + @return The error as an MgErr. + */ + MgErr Replace( + [in] size_t position, ///< Position in this data to begin replacing from + [in] const uChar* stringBuffer, ///< String buffer allocated by the user that will be used to replace into the string + [in] size_t numElements ///< Maximum numbers of elements to be replaced + ); + + /** + @brief Replace a set of numElements in the string starting at index position. + from the array pointed to by stringBuffer. + @return The error as an MgErr. + */ + MgErr ReplaceILVString( + [in] size_t position, ///< Position in this data to begin replacing from + [in] const ILVString* str ///< ILVString to replace from + ); + + /** + @brief Erase a subset of characters from the string, starting at position and erasing numElements. + @return The error as an MgErr. + */ + MgErr Erase( + [in] size_t position, ///< Position to start erasing from + [in] size_t numElements ///< Number of elements to erase + ); + + /** + @brief Erases all the characters in the string. This does not change the capacity of the ILVString. + NOTE: Currently, LabVIEW diagrams ignore string capacity and only pay attention to string length. If + you change the capacity of a string and pass it to LabVIEW, LabVIEW might lose the extra capacity. + @return The error as an MgErr. + */ + MgErr Clear(void); + + /** + @brief Return internal capacity for growth without memory allocation. + @return The error as an MgErr. + */ + MgErr GetCapacity( + [out] size_t* capacity ///< Number of elements string can contain before needing to resize. + ); + + /** + @brief Allocate enough memory to hold a total of capacity characters. + NOTE: Currently, LabVIEW diagrams ignore string capacity and only pay attention to string length. If + you change the capacity of a string and pass it to LabVIEW, LabVIEW might lose the extra capacity. + @return The error as an MgErr. + */ + MgErr SetCapacity( + [in] size_t capacity ///< Number of elements string can contain before needing to resize again + ); + + /** + @brief Returns if the string has 0 elements. + @return Boolean indicating if string is empty or not. + */ + Bool32 IsEmpty(); + + /** + @brief Returns a substring starting at position for length characters. + @return ILVString for subString. + */ + MgErr SubString( + [in] size_t position, ///< Position of beginning of substring + [in] size_t length, ///< Length of that substring to copy + [out] ILVString** subString ///< If *subString is NULL, an ILVString will be created. If *subString is not NULL, it will be updated with the subString's value. + ); + + /** + @brief Returns the number of elements in the current string. + @return The error as an MgErr. + */ + MgErr GetLength( + [out] size_t* length ///< Output the length of the string + ); + + /** + @brief Get the character in the string specified by position. + @return The error as an MgErr. + */ + MgErr GetElement( + [in] size_t position, ///< Specify what element to access + [out] uChar* element ///< Return character specified by position + ); +}; + +// ============================================================================ +// Interface for a LabVIEW cluster. +// ============================================================================ +[ + object, local, + uuid(5377527d-a5aa-4819-8933-adbf444e9ff4), + helpstring("ILVCluster"), + pointer_default(unique) +] + +/** + @brief Data interface class for clusters. +*/ +interface ILVCluster : ILVData +{ + /** + @brief Get the element in the cluster specified by position. + @return The error as an MgErr. + */ + MgErr GetElement( + [in] uInt32 position, ///< Element location to access + [in] Bool32 makeCopy, ///< Specify if a copy be made for the element returned. If makeCopy is false, element will reference the element in the cluster. A change to one will change the other. + [out] ILVData** element ///< Return the element specified by position + ); + + /** + @brief Set the element in the cluster specified by position. + @return The error as an MgErr. + */ + MgErr SetElement( + [in] uInt32 position, ///< Element location to set + [in] ILVData* element ///< Element to set at that location + ); + + /** + @brief Get the scalar element (numerics, booleans) in the cluster specified by position without wrapping it in an ILVData interface. + @return The error as an MgErr. + */ + MgErr GetScalarElement( + [in] uInt32 position, ///< Element location to access + [in] uInt32 elementSize, ///< Size of element to access (1, 2, 4, or 8 bytes) + [out] void* element ///< Scalar Element pointer + ); + + /** + @brief Set the scalar element (numerics, booleans) in the cluster specified by position without wrapping it in an ILVData interface. + @return The error as an MgErr. + */ + MgErr SetScalarElement( + [in] uInt32 position, ///< Element location to set + [in] uInt32 elementSize, ///< Size of element to set (1, 2, 4, or 8 bytes) + [out] void* element ///< Scalar Element pointer + ); +}; diff --git a/labview/cintools/ILVDataInterface_i.c b/labview/cintools/ILVDataInterface_i.c new file mode 100644 index 00000000..94728f15 --- /dev/null +++ b/labview/cintools/ILVDataInterface_i.c @@ -0,0 +1,94 @@ +/* this file contains the actual definitions of */ +/* the IIDs and CLSIDs */ + +/* link this file in with the server and any clients */ + + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __IID_DEFINED__ +#define __IID_DEFINED__ + +typedef struct _IID +{ +#if __GNUC__ && __x86_64__ + unsigned int x; +#else + unsigned long x; +#endif // gcc-64 + unsigned short s1; + unsigned short s2; + unsigned char c[8]; +} IID; + +#endif // __IID_DEFINED__ + +#ifndef CLSID_DEFINED +#define CLSID_DEFINED +typedef IID CLSID; +#endif // CLSID_DEFINED + + +const IID IID_ILVData = {0x4A4264A2,0xD5D8,0x468d,{0x96,0x75,0x6F,0x1D,0xF7,0x77,0xB2,0x95}}; + + +const IID IID_ILVBoolean = {0x7AB091D1,0x4154,0x48e2,{0xBF,0x98,0x55,0xCC,0x20,0x33,0x51,0x84}}; + + +const IID IID_ILVInt8 = {0xF3EE3676,0x1E8E,0x42c2,{0x83,0x55,0xE4,0xC0,0x7D,0x4E,0xB7,0x69}}; + + +const IID IID_ILVInt16 = {0x8567DFB4,0x0D6D,0x46d0,{0xB8,0x7F,0xA5,0xB6,0x80,0xD3,0xCD,0x82}}; + + +const IID IID_ILVInt32 = {0x878FCD1E,0xC70F,0x4940,{0x8E,0x54,0x46,0x1A,0x4D,0x1B,0xB5,0xB3}}; + + +const IID IID_ILVInt64 = {0x0344D202,0x0F76,0x4efb,{0xAD,0x02,0xDE,0xEC,0x0B,0x48,0x0E,0x47}}; + + +const IID IID_ILVuInt8 = {0x35CE47F1,0x7A7A,0x43c2,{0xA6,0x63,0xA6,0x34,0x0C,0xD7,0x2E,0xBB}}; + + +const IID IID_ILVuInt16 = {0xF1D1B174,0xCE67,0x4c6e,{0xAD,0xA6,0x06,0x4F,0x3F,0x49,0xBA,0x42}}; + + +const IID IID_ILVuInt32 = {0xEDFCFA65,0x5FE2,0x45b9,{0xA3,0x72,0x46,0x79,0x46,0x43,0x3E,0x84}}; + + +const IID IID_ILVuInt64 = {0xB173FE84,0x2CE5,0x4d23,{0xB1,0xB2,0xDA,0x1F,0x46,0x9E,0x2C,0x31}}; + + +const IID IID_ILVFloat32 = {0x947AB4F3,0x5A0C,0x491a,{0x9F,0x3E,0x1F,0xFA,0x6C,0xA9,0xB3,0xAF}}; + + +const IID IID_ILVFloat64 = {0x6BA720B2,0x7641,0x4657,{0x9A,0x88,0xE4,0x80,0x5C,0x07,0xD9,0x53}}; + + +const IID IID_ILVFloatExt = {0x35B495A1,0xEF73,0x4602,{0xA9,0x1E,0x53,0x07,0xEA,0x36,0x48,0x70}}; + + +const IID IID_ILVComplex64 = {0xB34B09A6,0xE681,0x4b7b,{0xB8,0x1F,0x27,0x71,0x8A,0x7A,0xC2,0x2D}}; + + +const IID IID_ILVComplex128 = {0x29CF50FF,0x334A,0x416b,{0x8E,0x62,0x43,0x05,0xD7,0x24,0xEA,0x74}}; + + +const IID IID_ILVComplexExt = {0x09B41F06,0x659B,0x4fb8,{0x8C,0x8C,0x66,0x41,0xFD,0xE8,0x33,0x03}}; + + +const IID IID_ILVArray = {0x5B5E5197,0x5580,0x431a,{0xAD,0x73,0x9A,0xB7,0x26,0x1D,0x39,0x4D}}; + + +const IID IID_ILVString = {0xC021AE89,0x68D7,0x47e9,{0x9E,0xD7,0x69,0xD9,0x50,0x1C,0x4F,0x24}}; + + +const IID IID_ILVCluster = {0x5377527D,0xA5AA,0x4819,{0x89,0x33,0xAD,0xBF,0x44,0x4E,0x9F,0xF4}}; + + +#ifdef __cplusplus +} +#endif diff --git a/labview/cintools/ILVTypeInterface.h b/labview/cintools/ILVTypeInterface.h new file mode 100644 index 00000000..c22df240 --- /dev/null +++ b/labview/cintools/ILVTypeInterface.h @@ -0,0 +1,326 @@ +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ +#ifndef __ILVTypeInterface_h__ +#define __ILVTypeInterface_h__ + +#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(NI_DSC_WIN32) +#define NIDL_STDMETHODCALLTYPE __stdcall +#else // WIN32 +#define NIDL_STDMETHODCALLTYPE +#endif // WIN32 + +#ifndef NIDL_EXTERN_C +#ifdef __cplusplus +#define NIDL_EXTERN_C extern "C" +#else // __cplusplus +#define NIDL_EXTERN_C +#endif // __cplusplus +#endif // NIDL_EXTERN_C + +#ifndef NIDL_INTERFACE +#if defined(WIN32) || (defined(PHARLAP) && PHARLAP) +#define NIDL_INTERFACE(x) struct __declspec(uuid(x)) +#else // WIN32 +#define NIDL_INTERFACE(x) struct +#endif // WIN32 +#endif // NIDL_INTERFACE +/* Forward Declarations */ + +#ifndef __ILVTypeDescriptor_FWD_DEFINED__ +#define __ILVTypeDescriptor_FWD_DEFINED__ +typedef struct ILVTypeDescriptor ILVTypeDescriptor; +#endif /* __ILVTypeDescriptor_FWD_DEFINED__ */ + +#ifndef __ILVBooleanTypeDescriptor_FWD_DEFINED__ +#define __ILVBooleanTypeDescriptor_FWD_DEFINED__ +typedef struct ILVBooleanTypeDescriptor ILVBooleanTypeDescriptor; +#endif /* __ILVBooleanTypeDescriptor_FWD_DEFINED__ */ + +#ifndef __ILVNumericTypeDescriptor_FWD_DEFINED__ +#define __ILVNumericTypeDescriptor_FWD_DEFINED__ +typedef struct ILVNumericTypeDescriptor ILVNumericTypeDescriptor; +#endif /* __ILVNumericTypeDescriptor_FWD_DEFINED__ */ + +#ifndef __ILVArrayTypeDescriptor_FWD_DEFINED__ +#define __ILVArrayTypeDescriptor_FWD_DEFINED__ +typedef struct ILVArrayTypeDescriptor ILVArrayTypeDescriptor; +#endif /* __ILVArrayTypeDescriptor_FWD_DEFINED__ */ + +#ifndef __ILVStringTypeDescriptor_FWD_DEFINED__ +#define __ILVStringTypeDescriptor_FWD_DEFINED__ +typedef struct ILVStringTypeDescriptor ILVStringTypeDescriptor; +#endif /* __ILVStringTypeDescriptor_FWD_DEFINED__ */ + +#ifndef __ILVClusterTypeDescriptor_FWD_DEFINED__ +#define __ILVClusterTypeDescriptor_FWD_DEFINED__ +typedef struct ILVClusterTypeDescriptor ILVClusterTypeDescriptor; +#endif /* __ILVClusterTypeDescriptor_FWD_DEFINED__ */ + + +/* Header files for imported files */ + +#include "unknwn.h" + +/* Declarations */ + +// ================================================================== +// NI CONFIDENTIAL +// (c) Copyright 2006-2008 by National Instruments Corp. +// All rights reserved. +// +// @file ILVTypeInterface.idl +// @brief Interface definitions for LabVIEW types. +// The files ILVTypeInterface_i.c and ILVTypeInterface.h +// are generated using this ILVTypeInterface.idl. +// ================================================================== +#include "extcode.h" +#ifndef _fundtypes_H +typedef char int8_t; + +typedef short int int16_t; + +typedef int int32_t; + +typedef long long int64_t; + +typedef unsigned char uint8_t; + +typedef unsigned short int uint16_t; + +typedef unsigned int uint32_t; + +typedef unsigned long long uint64_t; + +typedef char int_least8_t; + +typedef short int int_least16_t; + +typedef int int_least32_t; + +typedef long long int_least64_t; + +typedef unsigned char uint_least8_t; + +typedef unsigned short int uint_least16_t; + +typedef unsigned int uint_least32_t; + +typedef unsigned long long uint_least64_t; + +typedef char int_fast8_t; + +typedef int int_fast16_t; + +typedef int int_fast32_t; + +typedef long long int_fast64_t; + +typedef unsigned char uint_fast8_t; + +typedef unsigned int uint_fast16_t; + +typedef unsigned int uint_fast32_t; + +typedef unsigned long long uint_fast64_t; + +typedef int intptr_t; + +typedef unsigned int uintptr_t; + +typedef long long intmax_t; + +typedef unsigned long long uintmax_t; + +typedef char int8; + +typedef unsigned char uInt8; + +typedef uInt8 uChar; + +typedef short int int16; + +typedef unsigned short int uInt16; + +typedef int int32; + +typedef unsigned int uInt32; + +typedef float float32; + +typedef double float64; + +typedef struct { + int32 mlo; + int32 mhi; + int16 e; +} floatExt; + +typedef long long int64; + +typedef unsigned long long uInt64; + +typedef struct { + float32 re; + float32 im; +} cmplx64; + +typedef struct { + float64 re; + float64 im; +} cmplx128; + +typedef struct { + floatExt re; + floatExt im; +} cmplxExt; + +typedef int32 Bool32; + +typedef int32 HRESULT; + +typedef int32 SCODE; + +typedef int ptrdiff_t; + +typedef unsigned int size_t; + +typedef int32 MgErr; + +#endif // ifndef _fundtypes +/* Generated header for interface ILVTypeDescriptor */ + +typedef enum { + kCompareDefaultCheck = 0, + kCompareAllNameCheck = 1, + kCompareSubNameCheck = 2, + kCompareNoTypeDefCheck = 8, +} CompareWithOptionMasks; +NIDL_EXTERN_C const IID IID_ILVTypeDescriptor; + +/* {09a66b9c-3683-4f5c-b4ce-b7e428fc3914} */ +NIDL_INTERFACE("09a66b9c-3683-4f5c-b4ce-b7e428fc3914") ILVTypeDescriptor : public IUnknown +{ +public: + virtual MgErr NIDL_STDMETHODCALLTYPE Compare( + ILVTypeDescriptor* type, + int32* retVal) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE CompareWithOptions( + ILVTypeDescriptor* type, + int32 compareOptions, + int32* retVal) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetTypeCode( + int16* typeCode) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetInternalLVTypeDescriptor( + void** ppInternalTypeDesc) = 0; +} ; + +/* Generated header for interface ILVBooleanTypeDescriptor */ + +NIDL_EXTERN_C const IID IID_ILVBooleanTypeDescriptor; + +/* {234324fe-6e30-4cca-98f0-155793f2c682} */ +NIDL_INTERFACE("234324fe-6e30-4cca-98f0-155793f2c682") ILVBooleanTypeDescriptor : public ILVTypeDescriptor +{ +public: +} ; + +/* Generated header for interface ILVNumericTypeDescriptor */ + +typedef enum { + kNonNumericInterfaceCode = 0, + kInt8InterfaceCode = 1, + kInt16InterfaceCode = 2, + kInt32InterfaceCode = 3, + kInt64InterfaceCode = 4, + kUInt8InterfaceCode = 5, + kUInt16InterfaceCode = 6, + kUInt32InterfaceCode = 7, + kUInt64InterfaceCode = 8, + kFloat32InterfaceCode = 9, + kFloat64InterfaceCode = 10, + kFloatExtInterfaceCode = 11, + kComplex64InterfaceCode = 12, + kComplex128InterfaceCode = 13, + kComplexExtInterfaceCode = 14, +} NumericInterfaceCode; +NIDL_EXTERN_C const IID IID_ILVNumericTypeDescriptor; + +/* {da09ad59-f1b8-46b3-aba0-4b48c98a8afb} */ +NIDL_INTERFACE("da09ad59-f1b8-46b3-aba0-4b48c98a8afb") ILVNumericTypeDescriptor : public ILVTypeDescriptor +{ +public: + virtual MgErr NIDL_STDMETHODCALLTYPE GetNumericCode( + NumericInterfaceCode* numericCode) = 0; + virtual Bool32 NIDL_STDMETHODCALLTYPE IsEnum(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetEnumNumElements( + uInt32* numElements) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetEnumElementName( + uInt32 position, + const uChar** elementName, + size_t* elementNameLength) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetEnumElementNameILVString( + uInt32 position, + ILVString** elementName) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetEnumElementNumber( + const uChar* elementName, + size_t elementNameLength, + uInt32* position) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetEnumElementNumberILVString( + ILVString* elementName, + uInt32* position) = 0; +} ; + +/* Generated header for interface ILVArrayTypeDescriptor */ + +NIDL_EXTERN_C const IID IID_ILVArrayTypeDescriptor; + +/* {c2d6f738-f5b3-4db1-a1fa-5672fdeaf60f} */ +NIDL_INTERFACE("c2d6f738-f5b3-4db1-a1fa-5672fdeaf60f") ILVArrayTypeDescriptor : public ILVTypeDescriptor +{ +public: + virtual MgErr NIDL_STDMETHODCALLTYPE GetElementTypeDescriptor( + ILVTypeDescriptor** elementTypeDescriptor) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetNumDimensions( + uInt32* numDimensions) = 0; +} ; + +/* Generated header for interface ILVStringTypeDescriptor */ + +NIDL_EXTERN_C const IID IID_ILVStringTypeDescriptor; + +/* {7b4ef86e-e843-41f4-a4d8-88a2f2372365} */ +NIDL_INTERFACE("7b4ef86e-e843-41f4-a4d8-88a2f2372365") ILVStringTypeDescriptor : public ILVTypeDescriptor +{ +public: + virtual Bool32 NIDL_STDMETHODCALLTYPE IsVariableSize(void) = 0; + virtual Bool32 NIDL_STDMETHODCALLTYPE IsBoundedSize(void) = 0; + virtual Bool32 NIDL_STDMETHODCALLTYPE IsFixedSize(void) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetCapacity( + size_t* size) = 0; +} ; + +/* Generated header for interface ILVClusterTypeDescriptor */ + +NIDL_EXTERN_C const IID IID_ILVClusterTypeDescriptor; + +/* {fc873d27-ad8e-45da-bd26-e3f42c3d8157} */ +NIDL_INTERFACE("fc873d27-ad8e-45da-bd26-e3f42c3d8157") ILVClusterTypeDescriptor : public ILVTypeDescriptor +{ +public: + virtual MgErr NIDL_STDMETHODCALLTYPE GetNumElements( + uInt32* numElements) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetNumElementsRecursive( + uInt32* numElements) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetElementTypeDescriptor( + uInt32 position, + ILVTypeDescriptor** elementTypeDescriptor) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetElementName( + uInt32 position, + ILVString** name) = 0; + virtual MgErr NIDL_STDMETHODCALLTYPE GetElementIndex( + ILVString* name, + int32* index) = 0; +} ; + + + +#endif /* __ILVTypeInterface_h__ */ diff --git a/labview/cintools/ILVTypeInterface.idl b/labview/cintools/ILVTypeInterface.idl new file mode 100644 index 00000000..3c676216 --- /dev/null +++ b/labview/cintools/ILVTypeInterface.idl @@ -0,0 +1,357 @@ +cpp_quote("// ==================================================================") +cpp_quote("// NI CONFIDENTIAL ") +cpp_quote("// (c) Copyright 2006-2008 by National Instruments Corp. ") +cpp_quote("// All rights reserved. ") +cpp_quote("// ") +cpp_quote("// @file ILVTypeInterface.idl ") +cpp_quote("// @brief Interface definitions for LabVIEW types. ") +cpp_quote("// The files ILVTypeInterface_i.c and ILVTypeInterface.h ") +cpp_quote("// are generated using this ILVTypeInterface.idl. ") +cpp_quote("// ==================================================================") + +//============================================================================ +// Imports +//============================================================================ + +import "unknwn.idl"; + +//============================================================================ +// Interface forward declarations. +//============================================================================ + +interface ILVData; +interface ILVString; + +//============================================================================ +// cpp_quotes +//============================================================================ + +cpp_quote("#include \"extcode.h\"") + +// fundtypes.h will be included in extcode.h so we do not want a redefinition +// in the generated files. #if out the code generated by the #include of +// fundtypes.h below. +cpp_quote("#ifndef _fundtypes_H") +#define _WCHAR_T_DEFINED 1 +#include "fundtypes.h" +typedef int32 MgErr; // defined in extcode.h +cpp_quote("#endif // ifndef _fundtypes") + + +// ============================================================================ +// Pure virtual base interface for LabVIEW type descriptors. +// ============================================================================ +[ + object, local, + uuid(09a66b9c-3683-4f5c-b4ce-b7e428fc3914), + helpstring("ILVTypeDescriptor"), + pointer_default(unique) +] + +/** + @brief Base class for the LabVIEW type descriptor interface +*/ +interface ILVTypeDescriptor : IUnknown +{ + /** + @brief Compares two LabVIEW type descriptors. + @return The error as an MgErr. + */ + MgErr Compare( + [in] ILVTypeDescriptor* type, ///< The type to compare this type with + [out] int32* retVal ///< Outputs zero if the types are equal and non-zero if they differ + ); + + typedef enum { + kCompareDefaultCheck = 0, ///< Default behavior. Ignore name differences. TypeDefness (is or is not a typedef) difference, typeDef name, and time stamp difference reported as 0x1 for convert allowed. + kCompareAllNameCheck = 0x1, ///< Names in type descriptor must match exactly. + kCompareSubNameCheck = 0x2, ///< Names below top-level of type descriptor must match exactly. + kCompareNoTypeDefCheck = 0x8 ///< Whether or not it is a typeDef or typeDef name or time stamp differences ignored. + } CompareWithOptionMasks; + + /** + @brief Compares two LabVIEW type descriptors with options. + @return The error as an MgErr. + */ + MgErr CompareWithOptions( + [in] ILVTypeDescriptor* type, ///< The type descriptor to compare with the this type. + [in] int32 compareOptions, ///< Options to control the type descriptor comparison. These are flags from the enum CompareOptionMasks. + [out] int32* retVal ///< Outputs zero if the type are equal and non-zero if they differ. + ); + + /** + @brief Get an integer value that represents the type of the data. This can be useful for simple data types. + + Some values of the type code returned include: + 0x00 - void code + 0x01 - integer byte + 0x02 - integer word + 0x03 - integer long + 0x04 - integer quad + 0x05 - unsigned integer byte + 0x06 - unsigned integer word + 0x07 - unsigned integer long + 0x08 - unsigned integer quad + 0x09 - single precision float + 0x11 - double precision float + 0x12 - extended precision float + 0x13 - complex single precision + 0x14 - complex double precision + 0x15 - complex extended precision + 0x21 - boolean + 0x30 - string + 0x32 - path + 0x40 - array + 0x50 - cluster + 0x53 - LV variant + 0x54 - measurement data + 0x5F - fixed point number + 0x70 - refnum + @return The error as an MgErr. + */ + MgErr GetTypeCode( + [out] int16* typeCode ///< Type code output. + ); + + /** + @brief Get a pointer to the internal LabVIEW type descriptor. + @return The error as an MgErr. + */ + MgErr GetInternalLVTypeDescriptor( + [out] void** ppInternalTypeDesc ///< Outputs a pointer to the internal LabVIEW type descriptor. (Here, void** is equivalent to TDR**) + ); +}; + +// ============================================================================ +// Interface for a LabVIEW boolean type descriptor. +// ============================================================================ +[ + object, local, + uuid(234324FE-6E30-4cca-98F0-155793F2C682), + helpstring("ILVBooleanTypeDescriptor"), + pointer_default(unique) +] + +interface ILVBooleanTypeDescriptor : ILVTypeDescriptor +{ +} + +// ============================================================================ +// Interface for a LabVIEW numeric type descriptor. +// ============================================================================ +[ + object, local, + uuid(da09ad59-f1b8-46b3-aba0-4b48c98a8afb), + helpstring("ILVNumericTypeDescriptor"), + pointer_default(unique) +] + +/** + @brief Type descriptor interface interface class for numerics. +*/ +interface ILVNumericTypeDescriptor : ILVTypeDescriptor +{ + typedef enum { + kNonNumericInterfaceCode = 0, + kInt8InterfaceCode, + kInt16InterfaceCode, + kInt32InterfaceCode, + kInt64InterfaceCode, + kUInt8InterfaceCode, + kUInt16InterfaceCode, + kUInt32InterfaceCode, + kUInt64InterfaceCode, + kFloat32InterfaceCode, + kFloat64InterfaceCode, + kFloatExtInterfaceCode, + kComplex64InterfaceCode, + kComplex128InterfaceCode, + kComplexExtInterfaceCode + } NumericInterfaceCode; + + /** + @brief Get an integer value that represents the type of the data. + @return The error as an MgErr. + */ + MgErr GetNumericCode( + [out] NumericInterfaceCode* numericCode ///< Numeric type code output + ); + + //Enum related functions + + /// Does this numeric have enum attributes + Bool32 IsEnum(); + + /** + @brief For enums, get the number of elements in the enumerated type. + @return The error as an MgErr. + */ + MgErr GetEnumNumElements( + [out] uInt32* numElements ///< Output the number of elements in the type + ); + + /** + @brief For enums, get the name of an element in the enumerated type found at the specified position. + @return The error as an MgErr. + */ + MgErr GetEnumElementName( + [in] uInt32 position, ///< The index of the element in the enumerated type + [out] const uChar** elementName, ///< Name of the element + [out] size_t* elementNameLength ///< Length of the string + ); + + /** + @brief For enums, get the name of an element in the enumerated type found at the specified position. + @return The error as an MgErr. + */ + MgErr GetEnumElementNameILVString( + [in] uInt32 position, ///< The index of the element in the enumerated type + [out] ILVString ** elementName ///< Name of the element + ); + + /** + @brief For enums, get the number of an element in the enumerated type based upon its name. + @return The error as an MgErr. + */ + MgErr GetEnumElementNumber( + [in] const uChar* elementName, ///< Name of the element + [in] size_t elementNameLength, ///< Length of the string + [out] uInt32* position ///< The index of the element in the enumerated type + ); + + /** + @brief For enums, get the number of an element in the enumerated type based upon its name. + @return The error as an MgErr. + */ + MgErr GetEnumElementNumberILVString( + [in] ILVString * elementName, ///< Name of the element + [out] uInt32* position ///< The index of the element in the enumerated type + ); +}; + +// ============================================================================ +// Interface for a LabVIEW array type descriptor. +// ============================================================================ +[ + object, local, + uuid(c2d6f738-f5b3-4db1-a1fa-5672fdeaf60f), + helpstring("ILVArrayTypeDescriptor"), + pointer_default(unique) +] + +/** + @brief Type descriptor interface interface class for arrays. +*/ +interface ILVArrayTypeDescriptor : ILVTypeDescriptor +{ + /** + @brief Get the type descriptor for the array elements. + @return The error as an MgErr. + */ + MgErr GetElementTypeDescriptor( + [out] ILVTypeDescriptor** elementTypeDescriptor ///< element type descriptor output + ); + + /** + @brief Get the number of dimensions for the array. + @return The error as an MgErr. + */ + MgErr GetNumDimensions( + [out] uInt32* numDimensions ///< Output the number of dimensions + ); +}; + +// ============================================================================ +// Interface for a LabVIEW string type descriptor. +// ============================================================================ +[ + object, local, + uuid(7b4ef86e-e843-41f4-a4d8-88a2f2372365), + helpstring("ILVStringTypeDescriptor"), + pointer_default(unique) +] + +/** + @brief Type descriptor interface interface class for strings. +*/ +interface ILVStringTypeDescriptor : ILVTypeDescriptor +{ + /// Returns TRUE if the length of the string has a variable size + Bool32 IsVariableSize(void); + + /// Returns TRUE if the max length of the string is bounded to a positive - greater or equal to 0 - value. + Bool32 IsBoundedSize(void); + + /// Returns TRUE if the length of the string is fixed + Bool32 IsFixedSize(void); + + /** + @brief Get the number of elements for which memory has been allocated. + + For variable length strings - returns -1 + For fixed/bounded length strings - equals to the bounded/fixed size + @return The error as an MgErr. + */ + MgErr GetCapacity( + [out] size_t* size ///< Output capacity + ); +}; + +// ============================================================================ +// Interface for a LabVIEW cluster type descriptor. +// ============================================================================ +[ + object, local, + uuid(fc873d27-ad8e-45da-bd26-e3f42c3d8157), + helpstring("ILVClusterTypeDescriptor"), + pointer_default(unique) +] + +/** + @brief Type descriptor interface interface class for clusters. +*/ +interface ILVClusterTypeDescriptor : ILVTypeDescriptor +{ + /** + @brief Get the number of elements in the cluster + @return The error as an MgErr. + */ + MgErr GetNumElements( + [out] uInt32* numElements ///< Output the number of elements in a cluster + ); + + /** + @brief Get the number of elements in the cluster by recursively counting into the subclusters + @return The error as an MgErr. + */ + MgErr GetNumElementsRecursive( + [out] uInt32* numElements ///< Output the number of elements in a cluster and its subclusters + ); + + /** + @brief Get the type descriptor for the element at a specified position. + @return The error as an MgErr. + */ + MgErr GetElementTypeDescriptor( + [in] uInt32 position, ///< The index of the element we are accessing + [out] ILVTypeDescriptor** elementTypeDescriptor ///< The type descriptor of the element specified by position + ); + + /** + @brief Gets the name of an element in the cluster. + @return The error as an MgErr. + */ + MgErr GetElementName( + [in] uInt32 position, ///< The index of the element we want the name of + [out] ILVString** name ///< The element's name as an output + ); + + /** + @brief Gets the index of an element in the cluster based upon the element's name. + @return The error as an MgErr. + */ + MgErr GetElementIndex( + [in] ILVString* name, ///< The name of the element we want the index of + [out] int32* index ///< The index of the element with that name + ); +}; diff --git a/labview/cintools/ILVTypeInterface_i.c b/labview/cintools/ILVTypeInterface_i.c new file mode 100644 index 00000000..52d33473 --- /dev/null +++ b/labview/cintools/ILVTypeInterface_i.c @@ -0,0 +1,55 @@ +/* this file contains the actual definitions of */ +/* the IIDs and CLSIDs */ + +/* link this file in with the server and any clients */ + + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __IID_DEFINED__ +#define __IID_DEFINED__ + +typedef struct _IID +{ +#if __GNUC__ && __x86_64__ + unsigned int x; +#else + unsigned long x; +#endif // gcc-64 + unsigned short s1; + unsigned short s2; + unsigned char c[8]; +} IID; + +#endif // __IID_DEFINED__ + +#ifndef CLSID_DEFINED +#define CLSID_DEFINED +typedef IID CLSID; +#endif // CLSID_DEFINED + + +const IID IID_ILVTypeDescriptor = {0x09A66B9C,0x3683,0x4f5c,{0xB4,0xCE,0xB7,0xE4,0x28,0xFC,0x39,0x14}}; + + +const IID IID_ILVBooleanTypeDescriptor = {0x234324FE,0x6E30,0x4cca,{0x98,0xF0,0x15,0x57,0x93,0xF2,0xC6,0x82}}; + + +const IID IID_ILVNumericTypeDescriptor = {0xDA09AD59,0xF1B8,0x46b3,{0xAB,0xA0,0x4B,0x48,0xC9,0x8A,0x8A,0xFB}}; + + +const IID IID_ILVArrayTypeDescriptor = {0xC2D6F738,0xF5B3,0x4db1,{0xA1,0xFA,0x56,0x72,0xFD,0xEA,0xF6,0x0F}}; + + +const IID IID_ILVStringTypeDescriptor = {0x7B4EF86E,0xE843,0x41f4,{0xA4,0xD8,0x88,0xA2,0xF2,0x37,0x23,0x65}}; + + +const IID IID_ILVClusterTypeDescriptor = {0xFC873D27,0xAD8E,0x45da,{0xBD,0x26,0xE3,0xF4,0x2C,0x3D,0x81,0x57}}; + + +#ifdef __cplusplus +} +#endif diff --git a/labview/cintools/extcode.h b/labview/cintools/extcode.h new file mode 100644 index 00000000..2328b9fa --- /dev/null +++ b/labview/cintools/extcode.h @@ -0,0 +1,1629 @@ +#ifndef _extcode_H +#define _extcode_H +/** + (c) Copyright 1990-2020 by National Instruments Corp. + All rights reserved. + + @author National Instruments Corp. + @file + @brief This document reflects what is published in the CIN manual. + + DO NOT MODIFY THIS FILE. It is automatically generated. +*/ + +#include "platdefines.h" +#include "fundtypes.h" + +/* define this to keep C++ isms from littering the code */ +#ifdef __cplusplus + /* single instance extern C functions: */ + #define EXTERNC extern "C" + /* single instance extern C VARIABLES (needed because MSVC unnecessarily + mangles global variable names): */ + #define EEXTERNC extern "C" + /* begin of extern c block: */ + #define BEGINEXTERNC extern "C" { + /* end of externc block */ + #define ENDEXTERNC } + /* default function argument value */ + #define DEFAULTARG(a)= a +#else + #define EXTERNC + #define EEXTERNC extern + #define BEGINEXTERNC + #define ENDEXTERNC + #define DEFAULTARG(a) +#endif /* __cplusplus */ + +/* Mark a function as using C calling conventions. */ +#if !defined(_FUNCC) + #if MSWin && (ProcessorType == kX86) + #define _FUNCC __cdecl + /* Used for defining function pointers that use __cdecl */ + #define _PFUNCC __cdecl + #elif (Compiler == kGCC) && Linux && defined(LV_USE_WEAK_LINKAGE) + #define _FUNCC __attribute__((weak)) + #define _PFUNCC + #else + #define _FUNCC + #define _PFUNCC + #endif +#endif + +/* Mark a function as using standard (Pascal) calling conventions. */ +#if !defined(_FUNCSTDCALL) + #if MSWin && (ProcessorType == kX86) + #define _FUNCSTDCALL __stdcall + /* Used for defining function pointers that use __stdcall */ + #define _PFUNCSTDCALL __stdcall + #elif (Compiler == kGCC) && Linux && defined(LV_USE_WEAK_LINKAGE) + #define _FUNCCSTDCALL __attribute__((weak)) + #define _PFUNCSTDCALL + #else + #define _FUNCSTDCALL + #define _PFUNCSTDCALL + #endif +#endif + +/* FORCE_INLINE: cause a function to be inlined even when not optimizing */ +#if MSWin + #define FORCE_INLINE __forceinline +#elif Compiler == kGCC + #define FORCE_INLINE inline __attribute__((always_inline)) +#else + #define FORCE_INLINE inline +#endif + +/* Multi-threaded categorization tags. */ +#ifndef TH_REENTRANT + /* function is completely reentrant and calls only same */ + #define TH_REENTRANT +#endif +#ifndef TH_PROTECTED + #define TH_PROTECTED /* function uses mutex calls protect itself */ +#endif +#ifndef TH_SINGLE_UI + /* function is known to be used only from UI thread */ + #define TH_SINGLE_UI +#endif +#ifndef TH_UNSAFE + /* function is NOT thread safe and needs to be made so */ + #define TH_UNSAFE +#endif + /* Variable tags */ +#ifndef TH_READONLY + /* (global) variable is never written to after startup */ + #define TH_READONLY +#endif + +/* Explicitly define this if you want to use deprecated exported functions */ +#ifndef USE_DEPRECATED_EXPORTS + #define USE_DEPRECATED_EXPORTS 0 +#endif + +/* Debugging ON section Begin */ +#ifndef DBG + #define DBG 1 +#endif +/* Debugging ON section End */ + +/* Debugging OFF section Begin +#undef DBG +#define DBG 0 + * Debugging OFF section End */ + +#if defined(__cplusplus) + #if !defined(NI_STATIC_CAST) + /** @brief Peform a C++ static cast. + @param T the type to cast to + @param v the item to cast + */ + #define NI_STATIC_CAST(T,v) static_cast(v) + #endif /* !defined(NI_STATIC_CAST) */ + #if !defined(NI_CONST_CAST) + /** @brief Peform a C++ const cast. + @param T the type to cast to + @param v the item to cast + */ + #define NI_CONST_CAST(T,v) const_cast(v) + #endif /* !defined(NI_CONST_CAST) */ + #if !defined(NI_REINTERPRET_CAST) + /** @brief Peform a C++ reinterpret cast. + @param T the type to cast to + @param v the item to cast + */ + #define NI_REINTERPRET_CAST(T,v) reinterpret_cast(v) + #endif /* !defined(NI_REINTERPRET_CAST) */ +#else /* ! C++ */ + #if !defined(NI_STATIC_CAST) + /** @brief Peform a C static cast. + @param T the type to cast to + @param v the item to cast + */ + #define NI_STATIC_CAST(T,v) ((T)(v)) + #endif /* !defined(NI_STATIC_CAST) */ + #if !defined(NI_CONST_CAST) + /** @brief Peform a C const cast. + @param T the type to cast to + @param v the item to cast + */ + #define NI_CONST_CAST(T,v) ((T)(v)) + #endif /* !defined(NI_CONST_CAST) */ + #if !defined(NI_REINTERPRET_CAST) + /** @brief Peform a C reinterpret cast. + @param T the type to cast to + @param v the item to cast + */ + #define NI_REINTERPRET_CAST(T,v) ((T)(v)) + #endif /* !defined(NI_REINTERPRET_CAST) */ +#endif /* defined(__cplusplus) */ + +#if Mac + /* These must be defined before we start including Mac headers. */ + #ifndef ACCESSOR_CALLS_ARE_FUNCTIONS + #define ACCESSOR_CALLS_ARE_FUNCTIONS 1 + #endif + #ifndef OPAQUE_TOOLBOX_STRUCTS + #define OPAQUE_TOOLBOX_STRUCTS 1 + #endif + #include +#endif // Mac + +#include "lv_prolog.h" + +#if !Mac + /* These are native types on the Mac. */ + typedef uChar Str31[32]; + typedef uChar Str255[256]; + +#if USE_DEPRECATED_EXPORTS + /* All of these are provided by Types.h on the Mac */ + typedef uChar *StringPtr, **StringHandle; + typedef const uChar *ConstStringPtr; +#endif /* USE_DEPRECATED_EXPORTS */ +#endif /* !Mac */ + +#if !Mac + /** @brief Compatibility value for Mac-specific error code value. + @deprecated Unless using the Mac-specific OSStatus or OSErr type, you should use mgNoErr. + + A future release may place this definition behind the USE_DEPRECATED_EXPORTS guard. + */ + #define noErr mgNoErr +#endif /* !Mac */ + +typedef const uChar ConstStr255[256]; + +/* Using 1 instead of 0 avoids a warning in GCC */ +#define Offset(type, field) ((NI_REINTERPRET_CAST(size_t,(&NI_REINTERPRET_CAST(type*,1)->field)))-1) + + +/* Various mechanisms to define opaque types. */ +#define LV_PRIVATE(T) typedef struct T##_t { void *p; } *T +#define LV_PRIVATE_HANDLE(T) struct T##_t; typedef struct T##_t **T +#define LV_PRIVATE_POINTER(T) struct T##_t; typedef struct T##_t *T +#define LV_PRIVATE_POINTER_FWD(T) typedef struct T##_t *T /* for forward declarations */ + +/** Legacy 16-bit Boolean type */ +typedef uInt16 LVBooleanU16; +#define LVBooleanU16True NI_STATIC_CAST(LVBooleanU16,0x8000) +#define LVBooleanU16False NI_STATIC_CAST(LVBooleanU16,0x0000) + +/** Standard Boolean type */ +typedef uInt8 LVBoolean; +#define LVBooleanTrue NI_STATIC_CAST(LVBoolean,1) +#define LVBooleanFalse NI_STATIC_CAST(LVBoolean,0) +#define LVTRUE LVBooleanTrue /* for CIN users */ +#define LVFALSE LVBooleanFalse + +/** @brief Opaque type used for various unique identifiers. */ +typedef uInt32 MagicCookie; +#define kNotAMagicCookie NI_STATIC_CAST(MagicCookie,0) /* canonical invalid MagicCookie value */ + +/** @brief The opaque type used by the Resource Manager. */ +typedef MagicCookie RsrcFile; +#define kNotARsrcFile NI_STATIC_CAST(RsrcFile,kNotAMagicCookie) /* canonical invalid RsrcFile */ + +/** @brief Basic unsigned character pointer and handle types. */ +typedef uChar *UPtr, **UHandle; +typedef const uChar *ConstUPtr, **ConstUHandle; +typedef uChar * const *UConstHandle; + +/** @brief C-style (NULL-terminated) string types. */ +typedef uChar *CStr; +typedef const uChar *ConstCStr; + +/** @brief Pascal-style string types. 1-byte length followed by data. */ +typedef uChar *PStr, **PStrHandle; +typedef const uChar *ConstPStr, **ConstPStrHandle; + +typedef double floatNum; + +/** @brief Concatenated Pascal string types. */ +typedef struct { + int32 cnt; /* number of pascal strings that follow */ + uChar str[1]; /* cnt bytes of concatenated pascal strings */ +} CPStr, *CPStrPtr, **CPStrHandle; + +/** @brief Long Pascal-style string types. */ +typedef struct { + int32 cnt; /* number of bytes that follow */ + uChar str[1]; /* cnt bytes */ +} LStr, *LStrPtr, **LStrHandle; +typedef LStr const* ConstLStrP; +typedef LStr const*const* ConstLStrH; + +/** @brief Opaque type used by the Path Manager API. */ +#ifdef __cplusplus + class PathRef; +#else + typedef struct PATHREF PathRef; +#endif /* __cplusplus */ +typedef PathRef* Path; +typedef const PathRef* ConstPath; + +/** @brief Translate an error code from any NI product into its text description. + @param errCode the error code to translate + @param errText receives the error description + @return LVBooleanFalse iff error code is not found in the error code text files, LVBooleanTrue if the code was found. */ +TH_REENTRANT EXTERNC LVBoolean _FUNCC NIGetOneErrorCode(int32 errCode, LStrHandle *errText); + +/** @brief Manager error code type. */ +typedef int32 MgErr; + +/** @brief Manager error codes. */ +enum { + mgNoErr=0, + mgArgErr=1, + mFullErr, /* Memory Mgr 2-3 */ + mZoneErr, + + fEOF, /* File Mgr 4-12 */ + fIsOpen, + fIOErr, + fNotFound, + fNoPerm, + fDiskFull, + fDupPath, + fTMFOpen, + fNotEnabled, + + rFNotFound, /* Resource Mgr 13-15 */ + rAddFailed, + rNotFound, + + iNotFound, /* Image Mgr 16-17 */ + iMemoryErr, + + dPenNotExist, /* Draw Mgr 18 */ + + cfgBadType, /* Config Mgr 19-22 */ + cfgTokenNotFound, + cfgParseError, + cfgAllocError, + + ecLVSBFormatError, /* extCode Mgr 23 */ + ecLVSBSubrError, /* extCode Mgr 24 */ + ecLVSBNoCodeError, /* extCode Mgr 25 */ + + wNullWindow, /* Window Mgr 26-27 */ + wDestroyMixup, + + menuNullMenu, /* Menu Mgr 28 */ + + pAbortJob, /* Print Mgr 29-35 */ + pBadPrintRecord, + pDriverError, + pWindowsError, + pMemoryError, + pDialogError, + pMiscError, + + dvInvalidRefnum, /* Device Mgr 36-41 */ + dvDeviceNotFound, + dvParamErr, + dvUnitErr, + dvOpenErr, + dvAbortErr, + + bogusError, /* generic error 42 */ + cancelError, /* cancelled by user 43 */ + + OMObjLowErr, /* object message dispatcher errors 44-52 */ + OMObjHiErr, + OMObjNotInHeapErr, + OMOHeapNotKnownErr, + OMBadDPIdErr, + OMNoDPinTabErr, + OMMsgOutOfRangeErr, + OMMethodNullErr, + OMUnknownMsgErr, + + mgNotSupported, + + ncBadAddressErr, /* Net Connection errors 54-66 */ + ncInProgress, + ncTimeOutErr, + ncBusyErr, + ncNotSupportedErr, + ncNetErr, + ncAddrInUseErr, + ncSysOutOfMem, + ncSysConnAbortedErr, /* 62 */ + ncConnRefusedErr, + ncNotConnectedErr, + ncAlreadyConnectedErr, + ncConnClosedErr, /* 66 */ + + amInitErr, /* (Inter-)Application Message Manager 67- */ + + occBadOccurrenceErr, /* 68 Occurrence Mgr errors */ + occWaitOnUnBoundHdlrErr, + occFunnyQOverFlowErr, + + fDataLogTypeConflict, /* 71 */ + ecLVSBCannotBeCalledFromThread, /* ExtCode Mgr 72*/ + amUnrecognizedType, + mCorruptErr, + ecLVSBErrorMakingTempDLL, + ecLVSBOldCIN, /* ExtCode Mgr 76*/ + + dragSktNotFound, /* Drag Manager 77 - 80*/ + dropLoadErr, + oleRegisterErr, + oleReleaseErr, + + fmtTypeMismatch, /* String processing (printf, scanf) errors */ + fmtUnknownConversion, + fmtTooFew, + fmtTooMany, + fmtScanError, + + ecLVSBFutureCIN, /* ExtCode Mgr 86*/ + + lvOLEConvertErr, + rtMenuErr, + pwdTampered, /* Password processing */ + LvVariantAttrNotFound, /* LvVariant attribute not found 90-91*/ + LvVariantTypeMismatch, /* Cannot convert to/from type */ + + axEventDataNotAvailable, /* Event Data Not Available 92-96*/ + axEventStoreNotPresent, /* Event Store Not Present */ + axOccurrenceNotFound, /* Occurence Not Found */ + axEventQueueNotCreated, /* Event Queue not created */ + axEventInfoNotAvailable, /* Event Info is not available */ + + oleNullRefnumPassed, /* Refnum Passed is Null */ + + omidGetClassGUIDErr, /* Error retrieving Class GUID from OMId 98-100*/ + omidGetCoClassGUIDErr, /* Error retrieving CoClass GUID from OMId */ + omidGetTypeLibGUIDErr, /* Error retrieving TypeLib GUID from OMId */ + + appMagicBad, /* bad built application magic bytes */ + + iviInvalidDowncast, /* IVI Invalid downcast*/ + iviInvalidClassSesn, /* IVI No Class Session Opened */ + + maxErr, /* max manager 104-107 */ + maxConfigErr, /* something not right with config objects */ + maxConfigLoadErr, /* could not load configuration */ + maxGroupNotSupported, + + ncSockNotMulticast, /* net connection multicast specific errors 108-112 */ + ncSockNotSinglecast, + ncBadMulticastAddr, + ncMcastSockReadOnly, + ncMcastSockWriteOnly, + + ncDatagramMsgSzErr, /* net connection Datagram message size error 113 */ + + bufferEmpty, /* CircularLVDataBuffer (queues/notifiers) */ + bufferFull, /* CircularLVDataBuffer (queues/notifiers) */ + dataCorruptErr, /* error unflattening data */ + + requireFullPathErr, /* supplied folder path where full file path is required */ + folderNotExistErr, /* folder doesn't exist */ + + ncBtInvalidModeErr, /* invalid Bluetooth mode 119 */ + ncBtSetModeErr, /* error setting Bluetooth mode 120 */ + + mgBtInvalidGUIDStrErr, /* The GUID string is invalid 121 */ + + rVersInFuture, /* Resource file is a future version 122 */ + + mgErrTimeOut, /* General-purpose timeout 123 */ + mgErrStringCannotContainNull, /* An LStr contained a null character in a place that does not support null characters 124 */ + mgErrStackOverflow, /* Stack overflow detected 125 */ + + ncSocketQueryFailed, /* 126: Failed to query socket state */ + ncNotInetSocket, /* 127: Not an IP4 internet socket */ + ncTooManySocketsErr, /* 128: too many open sockets */ + + mgPathTooLong, /* 129: The path is too long for the OS.*/ + mgDupeEltInSet, /* Operation attempted to create a set from malformed data that contained duplicates. */ + mgDupeKeyInMap, /* Operation attempted to create a map from malformed data that contained duplicates. */ + mgErrSentinel, // 132 + + mgPrivErrBase = 500, /* Start of Private Errors */ + mgPrivErrLast = 599, /* Last allocated in Error DB */ + + + kAppErrorBase = 1000, /* Start of application errors */ + kAppLicenseErr = 1380, /* Failure to check out license error */ + kAppCharsetConvertErr =1396, /* could not convert text from charset to charset */ + kAppErrorLast = 1399, /* Last allocated in Error DB */ + kAppInvalidUTF8ByteSequence = 1675 // The input string contains invalid UTF-8 string sequence. +}; + +typedef MagicCookie Occurrence; +#ifndef kNonOccurrence + #ifdef __cplusplus + #define kNonOccurrence static_cast(kNotAMagicCookie) + #else + #define kNonOccurrence ((Occurrence)(kNotAMagicCookie)) + #endif +#endif + +TH_PROTECTED EXTERNC MgErr _FUNCC Occur(Occurrence o); + +/*** Time type ***/ +#if OpSystem==kLinux && ProcessorType==kX64 + typedef unsigned long lvtime; +#elif MacCocoa + // OS X wants a signed value to represent times before the unix epoch + typedef int64 lvtime; +#elif MSWin + typedef uInt64 lvtime; +#else + typedef uInt32 lvtime; +#endif + +EXTERNC TH_REENTRANT void StdToT(lvtime *t); +EXTERNC TH_REENTRANT void TToStd(lvtime *t); + +/* forward definitions of ATime128 (time stamp) for DLLs and CINs */ +#ifdef __cplusplus +class ATime128; +#else +typedef struct ATIME128 ATime128; +#endif /* __cplusplus */ +typedef ATime128* ATime128Ptr; + +#ifdef __cplusplus +class LvVariant; +#else +typedef struct LVVARIANT LvVariant; +#endif +typedef LvVariant* LvVariantPtr; + +/* forward definitions of HWAVEFORM and HWAVES for DLLs and CINs */ +#if !defined(__cplusplus) || defined(NICOM_C_INTERFACES) +typedef struct IWaveform IWaveform; +typedef struct IWaves IWaves; +#else +class IWaveform; +class IWaves; +#endif + +typedef IWaveform* HWAVEFORM; +typedef IWaves* HWAVES; + +/** Used for converting from NICOM to different flavors of LV-WDT */ +enum { + kWDTUniform =0L, /*< Uniform Flt64 WDT */ + kArrayWDTUniform /*< Array of uniform flt64 WDT */ +}; + +/*** Numeric Support Functions and Utilities ***/ +/** @brief These values describe various scalar numeric types. */ +typedef enum { iB=1, iW, iL, iQ, uB, uW, uL, uQ, fS, fD, fX, cS, cD, cX } NumType; + +#define _NumericTypeCast_(T,v) NI_STATIC_CAST(T,v) +#define _NumericTypeCastTwice_(T1,T2,v) _NumericTypeCast_(T1,_NumericTypeCast_(T2,v)) + +#define HiNibble(x) _NumericTypeCast_(uInt8,((x)>>4) & 0x0F) +#define LoNibble(x) _NumericTypeCast_(uInt8,(x) & 0x0F) +#define HiByte(x) _NumericTypeCast_(int8,_NumericTypeCast_(int16,x)>>8) +#define LoByte(x) _NumericTypeCast_(int8,x) +#define Word(hi,lo) ((_NumericTypeCast_(int16,hi)<<8) | _NumericTypeCastTwice_(int16, uInt8, lo)) +#define Hi16(x) _NumericTypeCast_(int16, _NumericTypeCast_(int32, x) >> 16) +#define Lo16(x) _NumericTypeCastTwice_(int16, int32, x) +#define Long(hi,lo) ((_NumericTypeCast_(int32,hi)<<16) | _NumericTypeCastTwice_(int32, uInt16,lo)) +#define Hi32(x) _NumericTypeCast_(int32,_NumericTypeCast_(int64,x)>>32) +#define Lo32(x) _NumericTypeCastTwice_(int32, int64, x) + +#define Cat2Chrs(c1,c2) \ + ( ((_NumericTypeCastTwice_(int16,uInt8,c1))<< 8) \ + | ((_NumericTypeCastTwice_(int16,uInt8,c2)) ) ) +#define Cat4Chrs(c1,c2,c3,c4) \ + ( ((_NumericTypeCastTwice_(int32,uInt8,c1))<<24) \ + | ((_NumericTypeCastTwice_(int32,uInt8,c2))<<16) \ + | ((_NumericTypeCastTwice_(int32,uInt8,c3))<< 8) \ + | ((_NumericTypeCastTwice_(int32,uInt8,c4)) ) ) +#define Cat8Chrs(c1,c2,c3,c4, c5, c6, c7, c8) \ + ( ((_NumericTypeCastTwice_(int64,uInt8,c1))<<56) \ + | ((_NumericTypeCastTwice_(int64,uInt8,c2))<<48) \ + | ((_NumericTypeCastTwice_(int64,uInt8,c3))<<40) \ + | ((_NumericTypeCastTwice_(int64,uInt8,c4))<<32) \ + | ((_NumericTypeCastTwice_(int64,uInt8,c5))<<24) \ + | ((_NumericTypeCastTwice_(int64,uInt8,c6))<<16) \ + | ((_NumericTypeCastTwice_(int64,uInt8,c7))<< 8) \ + | ((_NumericTypeCastTwice_(int64,uInt8,c8)) ) ) +#ifdef NIDL + #define RTToL(c1,c2,c3,c4) 0 +#else +#if NI_BIG_ENDIAN + #define RTToL(c1,c2,c3,c4) Cat4Chrs(c1,c2,c3,c4) + #define RTToW(c1,c2) Cat2Chrs(c1,c2) + #define IntFrom4Chars(s) _NumericTypeCast_(int32,s) +#else + #define RTToL(c1,c2,c3,c4) Cat4Chrs(c4,c3,c2,c1) + #define RTToW(c1,c2) Cat2Chrs(c2,c1) + #define IntFrom4Chars(s) (((_NumericTypeCast_(int32,s)&0x000000ff)<<24)|((_NumericTypeCast_(int32,s)&0x0000ff00)<<8)|(_NumericTypeCast_(uInt32,s)>>24)|((_NumericTypeCast_(int32,s)&0x00ff0000)>>8)) +#endif /* NI_BIG_ENDIAN */ +#endif /* NIDL */ + +#if !Palm +/** @brief Computes absolute value of a number. + @param n is an integer argument + @return the absolute value of n + + @deprecated Call abs() instead. +*/ +TH_REENTRANT EXTERNC int32 _FUNCC Abs(int32); + +/** @brief Computes min of two numbers. + @param n the first integer argument + @param m the second integer argument + @return the min of n and m */ +TH_REENTRANT EXTERNC int32 _FUNCC Min(int32 n, int32 m); + +/** @brief Computes max of two numbers. + @param n the first integer argument + @param m the second integer argument + @return the max of n and m */ +TH_REENTRANT EXTERNC int32 _FUNCC Max(int32 n, int32 m); +#endif /* !Palm */ + +#if (ProcessorType==kX86) || (ProcessorType==kX64) || (ProcessorType==kM68000) + #define UseGetSetIntMacros 1 +#else + #define UseGetSetIntMacros 0 +#endif + +#if UseGetSetIntMacros + #define GetAWord(p) (*(int16*)(p)) + #define SetAWord(p,x) (*(int16*)(p)= x) + #define GetALong(p) (*(int32*)(p)) + #define SetALong(p,x) (*(int32*)(p)= x) +#else +TH_REENTRANT EXTERNC int32 _FUNCC GetALong(const void *); +TH_REENTRANT EXTERNC int32 _FUNCC SetALong(void *, int32); +TH_REENTRANT EXTERNC int16 _FUNCC GetAWord(const void *); +TH_REENTRANT EXTERNC int16 _FUNCC SetAWord(void *, int16); +#endif + +#if !Palm +/* Avoid conflict with functions in LabWindows CVI that can arise for LabVIEW DLLs used in CVI projects. */ +#ifndef _CVI_ +/** @brief Coerce a value to be in the range [low,high]. + @param i the value to test for coersion + @param low the lower limit + @param high the upper limit + @return the coerced value */ +TH_REENTRANT EXTERNC int32 _FUNCC Pin(int32 i, int32 low, int32 high); +#endif /* _CVI_ */ +#endif /* !Palm */ + +/** @brief Generate a random number between 0 and 1. + @param xp receives the randomly generated value */ +TH_PROTECTED EXTERNC void _FUNCC RandomGen(float64 *xp); + +/*** C-style String Support Functions ***/ +#if !Palm +TH_REENTRANT EXTERNC Bool32 _FUNCC IsDigit(uChar); +TH_REENTRANT EXTERNC Bool32 _FUNCC IsAlpha(uChar); +TH_REENTRANT EXTERNC Bool32 _FUNCC IsPunct(uChar); +TH_REENTRANT EXTERNC Bool32 _FUNCC IsLower(uChar); +TH_REENTRANT EXTERNC Bool32 _FUNCC IsUpper(uChar); +TH_REENTRANT EXTERNC int32 _FUNCC ToUpper(int32); +TH_REENTRANT EXTERNC int32 _FUNCC ToLower(int32); +TH_REENTRANT EXTERNC uChar _FUNCC HexChar(int32); +TH_REENTRANT EXTERNC int32 _FUNCC StrLen(const uChar *); +TH_REENTRANT EXTERNC int32 _FUNCC StrCat(CStr, ConstCStr); +TH_REENTRANT EXTERNC CStr _FUNCC StrCpy(CStr, ConstCStr); +TH_REENTRANT EXTERNC CStr _FUNCC StrNCpy(CStr, ConstCStr, const size_t); +TH_REENTRANT EXTERNC int32 _FUNCC StrCmp(ConstCStr, ConstCStr); +TH_REENTRANT EXTERNC int32 _FUNCC StrNCmp(ConstCStr, ConstCStr, const size_t); +TH_REENTRANT EXTERNC int32 _FUNCC StrNCaseCmp(ConstCStr, ConstCStr, const size_t); + +/** @brief Search a string for a substring. + @param s the string to search + @param r the string to search for within s + @return nonzero value if r is found within s + + @note Comparisons are case-insensitive. + @note Whitespace in s is ignored. +*/ +TH_REENTRANT EXTERNC int32 _FUNCC StrIStr(ConstCStr s, ConstCStr r); +#endif /* !Palm */ + +/*** Pascal-Style String Support Functions ***/ +#if __cplusplus +inline uChar* PStrBuf(const PStr b) { return &(b[1]); } +inline uChar& PStrLen(const PStr b) { return b[0]; } // # of chars in string +inline const uChar* PStrBuf(const ConstPStr b) { return &(b[1]); } +inline uChar PStrLen(const ConstPStr b) { return b[0]; } // # of chars in string +inline uInt16 PStrSize(const ConstPStr b) { return static_cast(b?PStrLen(b)+1:0); } // # of bytes including length; + // The return type is uInt16, not uChar. It cannot be uChar since + // a) Maximum PStr length is 255 + // b) PStrSize is length plus 1 + // c) 255 + 1 = 256 + // d) 256 is greater than the maximum value of a uChar (255) +#else +#define PStrBuf(b) (&((PStr)(b))[1]) +#define PStrLen(b) (((PStr)(b))[0]) /* # of chars in string */ +#define PStrSize(b) (b?PStrLen(b)+1:0) /* # of bytes including length */ +#endif /* __cplusplus */ + +TH_REENTRANT EXTERNC int32 _FUNCC PStrCat(PStr, ConstPStr); +TH_REENTRANT EXTERNC PStr _FUNCC PStrCpy(PStr, ConstPStr); +TH_REENTRANT EXTERNC PStr _FUNCC PStrNCpy(PStr, ConstPStr, int32); +TH_REENTRANT EXTERNC int32 _FUNCC PStrCmp(ConstPStr, ConstPStr); +TH_REENTRANT EXTERNC int32 _FUNCC PPStrCmp(ConstPStr*, ConstPStr*); +TH_REENTRANT EXTERNC int32 _FUNCC PStrCaseCmp(ConstPStr, ConstPStr); +TH_REENTRANT EXTERNC int32 _FUNCC PPStrCaseCmp(ConstPStr*, ConstPStr*); +TH_REENTRANT EXTERNC int32 _FUNCC PToCStr(ConstPStr, CStr); +TH_REENTRANT EXTERNC PStr _FUNCC PStrDup(ConstPStr buf); +TH_REENTRANT EXTERNC int32 _FUNCC CToPStr(ConstCStr, PStr); + +/*** Long Pascal-Style String Support Functions ***/ + +/* Helpers for LStr handles that allow for empty strings encoded as NULL handles. + Use LHStr macros instead of passing a *h to LStrBuf/Len/Size for right hand side refs. */ +#define LHStrPtr(sh) ((sh)?*(sh):NULL) /* Get LStr* (produces NULL ptr for NULL handle */ +#define LHStrBuf(sh) ((sh)?(&(*(sh))->str[0]):NULL) /* same as LStrBuf, but on string handle */ +#define LHStrLen(sh) ((sh)?((*(sh))->cnt):0) /* same as LStrLen, but on string handle */ +#define LHStrSize(sh) (LHStrLen(sh)+sizeof(int32)) /* same as LStrSize, but on string handle */ + +#define LStrBuf(sp) (&((sp))->str[0]) /* pointer to first char of string */ +#define LStrLen(sp) (((sp))->cnt) /* # of chars in string */ +#define LStrSize(sp) (LStrLen(sp)+sizeof(int32)) /* # of bytes including length */ + +TH_REENTRANT EXTERNC int32 _FUNCC LStrCmp(ConstLStrP l1, ConstLStrP l2); +TH_REENTRANT EXTERNC int32 _FUNCC LStrCaseCmp(ConstLStrP l1, ConstLStrP l2); +TH_REENTRANT EXTERNC int32 _FUNCC PtrLenStrCmp(const uChar *s1, int32 s1len, const uChar *s2, int32 s2len); +TH_REENTRANT EXTERNC int32 _FUNCC PtrLenStrCaseCmp(const uChar *s1, int32 s1len, const uChar *s2, int32 s2len); +TH_REENTRANT EXTERNC int32 _FUNCC LHStrCmp(ConstLStrH lh1, ConstLStrH lh2); +TH_REENTRANT EXTERNC int32 _FUNCC LHStrCaseCmp(ConstLStrH lh1, ConstLStrH lh2); + +TH_REENTRANT EXTERNC uInt32 _FUNCC LToCStrN(ConstLStrP source, CStr dest, uInt32 destSize); +TH_REENTRANT EXTERNC int32 _FUNCC LToPStr(ConstLStrP source, PStr dest); +TH_REENTRANT EXTERNC int32 _FUNCC PToLStr(ConstPStr source, LStrPtr dest); +TH_REENTRANT EXTERNC MgErr _FUNCC PStrToDSLStr(PStr buf, LStrHandle *lStr); /* deprecated */ + +#if USE_DEPRECATED_EXPORTS +/** @brief Convert a long Pascal-style string to a C-style string. + @param lstr the long pascal string to convert + @param cstr receives the contents of the Lstr + @return length (in bytes) of converted string + @pre cstr is large enough to contain lstr ((LStrLen(lstr) + 1) or more bytes) + @deprecated Use LToCStrN() instead. +*/ +TH_REENTRANT EXTERNC int32 _FUNCC LToCStr(ConstLStrP lstr, CStr cstr); +#endif /* USE_DEPRECATED_EXPORTS */ + +/*** Concatenated Pascal String Support Functions ***/ +#define CPStrLen LStrLen /* concatenated Pascal vs. LabVIEW strings */ +#define CPStrBuf LStrBuf /* concatenated Pascal vs. LabVIEW strings */ + +TH_REENTRANT EXTERNC int32 _FUNCC CPStrSize(CPStrPtr); +TH_REENTRANT EXTERNC int32 _FUNCC CPStrCmp(CPStrPtr, CPStrPtr); +TH_REENTRANT EXTERNC MgErr _FUNCC CPStrInsert(CPStrHandle, ConstPStr, int32); +TH_REENTRANT EXTERNC void _FUNCC CPStrRemove(CPStrHandle, int32); +TH_REENTRANT EXTERNC PStr _FUNCC CPStrIndex(CPStrHandle, int32); +TH_REENTRANT EXTERNC MgErr _FUNCC CPStrReplace(CPStrHandle, ConstPStr, int32); + +TH_REENTRANT EXTERNC MgErr _FUNCC DbgPrintf(const char *buf, ...); + +/** Refer to SPrintf() */ +TH_PROTECTED EXTERNC int32 DBPrintf(const char *fmt, ...); + +TH_REENTRANT EXTERNC int32 _FUNCC SPrintf(CStr buf, ConstCStr fmt, ...); +TH_REENTRANT EXTERNC int32 _FUNCC SPrintfp(CStr buf, ConstPStr fmt, ...); + +TH_REENTRANT EXTERNC MgErr _FUNCC LStrPrintf(LStrHandle str, CStr fmt, ...); + +TH_REENTRANT EXTERNC int32 _FUNCC PPrintf(PStr, ConstCStr, ...); +TH_REENTRANT EXTERNC int32 _FUNCC PPrintfp(PStr, ConstPStr, ...); + +#ifndef NIDL +/*** Sort / Search Utilities ***/ +/** @brief Comparison function pointer type definiton. */ +typedef int32 (_PFUNCC *CompareProcPtr)(const void *lhs, const void *rhs); + +/* Avoid conflict with functions in LabWindows CVI that can arise for LabVIEW DLLs used in CVI projects. */ +#ifndef _CVI_ +TH_REENTRANT EXTERNC int32 _FUNCC BinSearch(const void*, int32, int32, const void*, CompareProcPtr); +#endif /* _CVI_ */ +TH_REENTRANT EXTERNC void _FUNCC QSort(void*, int32, int32, CompareProcPtr); +#endif /* NIDL */ + +TH_REENTRANT EXTERNC MgErr _FUNCC ConvertSystemStringToUTF8(LStrHandle, LStrHandle *); +TH_REENTRANT EXTERNC MgErr _FUNCC ConvertUTF8StringToSystem(LStrHandle, LStrHandle *); + +/*** Time Functions ***/ +/** @brief Date/time record. */ +typedef struct { + int32 sec; /* 0:59 */ + int32 min; /* 0:59 */ + int32 hour; /* 0:23 */ + int32 mday; /* day of the month, 1:31 */ + int32 mon; /* month of the year, 1:12 */ + int32 year; /* year, 1904:2040 */ + int32 wday; /* day of the week, 1:7 for Sun:Sat */ + int32 yday; /* day of year (julian date), 1:366 */ + int32 isdst; /* 1 if daylight savings time */ +} DateRec; + +TH_REENTRANT EXTERNC void _FUNCC SecsToDate(uInt32, DateRec*); +TH_REENTRANT EXTERNC uInt32 _FUNCC DateToSecs(DateRec*); +TH_REENTRANT EXTERNC lvtime _FUNCC TimeInSecs(void); +TH_UNSAFE EXTERNC CStr _FUNCC DateCString(uInt32, int32); +TH_UNSAFE EXTERNC CStr _FUNCC TimeCString(uInt32, int32); +TH_UNSAFE EXTERNC CStr _FUNCC ASCIITime(uInt32); + +TH_REENTRANT EXTERNC uInt32 _FUNCC MilliSecs(); + +/*** The Memory Manager ***/ +/* + For parameters to the memory manager functions below + p means pointer + h means handle + ph means pointer to handle +*/ +TH_REENTRANT EXTERNC UHandle _FUNCC DSNewHandle(size_t); +TH_REENTRANT EXTERNC UHandle _FUNCC DSNewHClr(size_t); +TH_REENTRANT EXTERNC UHandle _FUNCC DSNewAlignedHandle(size_t, size_t alignment, size_t alignmentOffset); +TH_REENTRANT EXTERNC UHandle _FUNCC DSNewAlignedHClr(size_t, size_t alignment, size_t alignmentOffset); +TH_REENTRANT EXTERNC UPtr _FUNCC DSNewPtr(size_t); +TH_REENTRANT EXTERNC UPtr _FUNCC DSNewPClr(size_t); +TH_REENTRANT EXTERNC MgErr _FUNCC DSCopyHandle(void *ph, const void *hsrc); +TH_REENTRANT EXTERNC MgErr _FUNCC DSSetHandleSize(void *h, size_t); +TH_REENTRANT EXTERNC MgErr _FUNCC DSSetHSzClr(void *h, size_t); +TH_REENTRANT EXTERNC MgErr _FUNCC DSSetAlignedHandleSize(void *h, size_t, size_t alignment, size_t alignmentOffset); +TH_REENTRANT EXTERNC MgErr _FUNCC DSSetAlignedHandleSizeNoInit(void *h, size_t n, size_t alignment, size_t alignmentOffset); +TH_REENTRANT EXTERNC MgErr _FUNCC DSSetAlignedHSzClr(void *h, size_t, size_t alignment, size_t alignmentOffset); +TH_REENTRANT EXTERNC MgErr _FUNCC DSDisposeHandle(void *h); +TH_REENTRANT EXTERNC MgErr _FUNCC DSDisposePtr(void *p); + +enum { kDSHandleZoneCheckNone, kDSHandleZoneCheckResize, kDSHandleZoneCheckAll }; +TH_REENTRANT EXTERNC void _FUNCC DSSetHandleChecking(int32 level); + +#if !Palm +TH_REENTRANT EXTERNC MgErr _FUNCC DSCheckHandle(const void *h); +TH_REENTRANT EXTERNC MgErr _FUNCC DSCheckPtr(void *p); +TH_REENTRANT EXTERNC size_t _FUNCC DSGetHandleSize(const void *h); +TH_REENTRANT EXTERNC UHandle _FUNCC DSRecoverHandle(void *p); +TH_REENTRANT EXTERNC MgErr _FUNCC DSHeapCheck(Bool32); +TH_REENTRANT EXTERNC size_t _FUNCC DSMaxMem(void); + +/** @brief Describes memory statistics. */ +typedef struct { + uInt64 totFreeSize; // free physical RAM in bytes (RT only) + uInt64 maxFreeSize; // largest free contiguous block in bytes (VxWorks/PharLap only) + int32 unused1; // was nFreeBlocks, but this was never filled in + size_t totAllocSize; // memory usage of LabVIEW itself in bytes + size_t unused2; // was maxAllocSize + int32 unused3; // was nPointers + int32 unused4; // was nUnlockedHdls + int32 unused5; // was nLockedHdls + uInt64 totPhysSize; // total physical RAM in bytes (RT only) + int32 reserved1; + int32 reserved2; +} MemStatRec; + +TH_REENTRANT EXTERNC MgErr _FUNCC DSMemStats(MemStatRec *msrp); +#endif /* !Palm */ + +#if !Palm +TH_REENTRANT EXTERNC void _FUNCC ClearMem(void*, size_t); +TH_REENTRANT EXTERNC void _FUNCC MoveBlock(const void *src, void *dest, size_t); /* accepts zero bytes */ +/* Avoid conflict with functions in LabWindows CVI that can arise for LabVIEW DLLs used in CVI projects. */ +#ifndef _CVI_ +TH_REENTRANT EXTERNC void _FUNCC SwapBlock(void *src, void *dest, size_t); +#endif /* _CVI_ */ +#endif /* !Palm */ +TH_REENTRANT EXTERNC int32 _FUNCC BlockCmp(const void * p1, const void * p2, size_t n); + +#if USE_DEPRECATED_EXPORTS +#if !Palm +TH_REENTRANT EXTERNC MgErr _FUNCC AZCheckHandle(const void *h); +TH_REENTRANT EXTERNC MgErr _FUNCC AZCheckPtr(void *p); +TH_REENTRANT EXTERNC MgErr _FUNCC AZDisposeHandle(void *h); +TH_REENTRANT EXTERNC MgErr _FUNCC AZDisposePtr(void *p); +TH_REENTRANT EXTERNC size_t _FUNCC AZGetHandleSize(const void *h); +TH_REENTRANT EXTERNC MgErr _FUNCC AZHLock(void *h); +TH_REENTRANT EXTERNC MgErr _FUNCC AZHUnlock(void *h); +TH_REENTRANT EXTERNC void _FUNCC AZHPurge(void *h); +TH_REENTRANT EXTERNC void _FUNCC AZHNoPurge(void *h); +TH_REENTRANT EXTERNC UHandle _FUNCC AZNewHandle(size_t); +TH_REENTRANT EXTERNC UHandle _FUNCC AZNewHClr(size_t); +TH_REENTRANT EXTERNC UPtr _FUNCC AZNewPtr(size_t); +TH_REENTRANT EXTERNC UPtr _FUNCC AZNewPClr(size_t); +TH_REENTRANT EXTERNC UHandle _FUNCC AZRecoverHandle(void *p); +TH_REENTRANT EXTERNC MgErr _FUNCC AZSetHandleSize(void *h, size_t); +TH_REENTRANT EXTERNC MgErr _FUNCC AZSetHSzClr(void *h, size_t); +TH_REENTRANT EXTERNC int32 _FUNCC AZHeapCheck(Bool32); +TH_REENTRANT EXTERNC size_t _FUNCC AZMaxMem(void); +TH_REENTRANT EXTERNC MgErr _FUNCC AZMemStats(MemStatRec *msrp); +TH_REENTRANT EXTERNC MgErr _FUNCC AZSetHandleFromPtr(void *ph, const void *psrc, size_t n); +#endif /* !Palm */ +#endif /* USE_DEPRECATED_EXPORTS */ + +/*** The File Manager ***/ + +/** @brief Opaque type used by the File Manager API for a file descriptor. */ +LV_PRIVATE(File); + +/** @brief Initial enumeration type for file types. + The enumeration is used to increase type safety but does not list all possible values. +*/ +typedef enum _FMFileType +{ + kInvalidType = 0, /**< not a valid file type */ + kUnknownFileType = RTToL('?','?','?','?'), /**< unknown file type */ + kTextFileType = RTToL('T','E','X','T'), /**< text file */ + kHardDiskDirType = RTToL('h','d','s','k'), /**< hard disk directory */ + kFloppyDirType = RTToL('f','l','p','y'), /**< floppy drive type */ + kNetDriveDirType = RTToL('s','r','v','r') /**< network volume */ +} FMFileType; + +/** @brief Type for file creator codes. + The enumeration is used to increase type safety but does not list all possible values.*/ +typedef enum _FMFileCreator +{ + kInvalidCreator = 0, /**< not a vaild file creator */ + kUnknownCreator = RTToL('?','?','?','?'), /**< unknown creator */ + kLVCreatorType = RTToL('L','B','V','W') /**< LabVIEW creator */ +} FMFileCreator; + +/** @brief Flags describing a file used by the FMListDetails data structure. */ +#define kIsFile 0x01 /**< entry refers to a file (as opposed to a directory) */ +#define kRecognizedType 0x02 /**< file's type was recognized (e.g. VI, et. al.) */ +#define kIsLink 0x04 /**< entry refers to a shortcut / alias / link */ +#define kFIsInvisible 0x08 /**< entry refers to a hidden file */ +#define kIsTopLevelVI 0x10 /**< Used only for VIs in archives */ +#define kErrGettingType 0x20 /**< error occurred getting type info */ +#if Mac +#define kFIsStationery 0x40 /**< file is stationery */ +#endif /* Mac */ + +/** @brief Data used with FListDir to describe the files listed in a directory. */ +typedef struct _FMListDetails +{ + int32 flags; /**< descriptive flags for the file (see kIsFile, et. al. above) */ + FMFileType type; /**< type of the file */ +} FMListDetails; + +/** @brief Data types used to describe a list of entries from a directory. */ +typedef CPStr FDirEntRec, *FDirEntPtr, **FDirEntHandle; + +/** @brief UNIX read permission bits (octal). */ +#define fileReadBits 0444 + +/** @brief UNIX write permission bits (octal). */ +#define fileWriteBits 0222 + +/** @brief UNIX execute permission bits (octal). */ +#define fileExecBits 0111 + +/** @brief UNIX read/write access permissions for a file. This is usually the default access to assign newly created files. */ +#define fDefaultAccess (fileReadBits | fileWriteBits) + +/** @brief Descriptive information about a file. */ +typedef struct { + FMFileType type; /**< system specific file type-- 0 for directories */ + FMFileCreator creator; /**< system specific file creator-- 0 for directories */ + int32 permissions; /**< system specific file access rights */ + int32 size; /**< file size in bytes (data fork on Mac) or entries in folder */ + int32 rfSize; /**< resource fork size (on Mac only) */ + uInt32 cdate; /**< creation date */ + uInt32 mdate; /**< last modification date */ + Bool32 folder; /**< indicates whether path refers to a folder */ + Bool32 isInvisible; /**< indicates whether the file is visible in File Dialog */ + struct { + int16 v; /**< vertical coordinate */ + int16 h; /**< horizontal coordinate */ + } location; /**< system specific geographical location (on Mac only) */ + Str255 owner; /**< owner (in pascal string form) of file or folder */ + Str255 group; /**< group (in pascal string form) of file or folder (Mac, Linux only) */ +} FInfoRec, *FInfoPtr; + +/** @brief Retrieve information about a file or directory. + @param path absolute path to a file or directory + @param infop pointer to a FInfoRec structure which receives information about the file or directory + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNoPerm: unable to access the file or directory due to permissions in the file system + - fNotFound: the file or directory does not exist at the specified location + @note If @p path is a shortcut, it is resolved to the actual path. (Windows only) +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FGetInfo(ConstPath path, FInfoPtr infop); + +/** @brief Modify information about a file or directory. + @param path absolute path to a file or directory + @param infop pointer to a FInfoRec structure which contains information about the file or directory + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNoPerm: unable to access the file or directory due to permissions in the file system + - fNotFound: the file or directory does not exist at the specified location + @note If @p path is a shortcut, it is resolved to the actual path. (Windows only) +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FSetInfo(ConstPath path, const FInfoPtr infop); + +/** @brief Used to specify fields of interest in a FInfoRec64 structure. */ +typedef uInt32 FGetInfoWhich; +enum { + kFGetInfoType = 1 << 0, /**< enable the type field */ + kFGetInfoCreator = 1 << 1, /**< enable the creator field */ + kFGetInfoPermissions = 1 << 2, /**< enable the permissions field */ + kFGetInfoSize = 1 << 3, /**< enable the size field */ + kFGetInfoRFSize = 1 << 4, /**< enable the rfSize field */ + kFGetInfoCDate = 1 << 5, /**< enable the cdate field */ + kFGetInfoMDate = 1 << 6, /**< enable the mdate field */ + kFGetInfoFolder = 1 << 7, /**< enable the folder field */ + kFGetInfoIsInvisible = 1 << 8, /**< enable the isInvisible field */ + kFGetInfoLocation = 1 << 9, /**< enable the location field */ + kFGetInfoOwner = 1 << 10, /**< enable the owner field */ + kFGetInfoGroup = 1 << 11, /**< enable the group field */ + kFGetInfoAll = 0xEFFFFFFF /**< enable all fields in FInfoRec64 */ +}; + +/** @brief Descriptive information about a file, with large file support. */ +typedef struct { + FMFileType type; /**< system specific file type-- 0 for directories */ + FMFileCreator creator; /**< system specific file creator-- 0 for directories */ + int32 permissions; /**< system specific file access rights */ + int64 size; /**< file size in bytes (data fork on Mac) or entries in folder */ + int64 rfSize; /**< resource fork size (on Mac only) */ + uInt32 cdate; /**< creation date */ + uInt32 mdate; /**< last modification date */ + Bool32 folder; /**< indicates whether path refers to a folder */ + Bool32 isInvisible; /**< indicates whether the file is visible in File Dialog */ + struct { + int16 v; /**< vertical coordinate */ + int16 h; /**< horizontal coordinate */ + } location; /**< system specific geographical location (on Mac only) */ + Str255 owner; /**< owner (in pascal string form) of file or folder */ + Str255 group; /**< group (in pascal string form) of file or folder (Mac, Linux only) */ +} FInfoRec64, *FInfo64Ptr; + +/** @brief Retrieve information about a file or directory (supports files > 2 GB in size). + @param path absolute path to a file or directory + @param infop pointer to a FInfoRec64 structure which receives information about the file or directory + @param which describes which portions of the FInfoRec64 should be acquired (in C++, this argument defaults to kFGetInfoAll) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNoPerm: unable to access the file or directory due to permissions in the file system + - fNotFound: the file or directory does not exist at the specified location + @note If @p path is a shortcut, it is resolved to the actual path. (Windows only) +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FGetInfo64(ConstPath path, FInfo64Ptr infop, const FGetInfoWhich which DEFAULTARG(kFGetInfoAll)); + +/** @brief Modify information about a file or directory (supports files > 2 GB in size). + @param path absolute path to a file or directory + @param infop pointer to a FInfoRec64 structure which contains information about the file or directory + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNoPerm: unable to access the file or directory due to permissions in the file system + - fNotFound: the file or directory does not exist at the specified location + @note If @p path is a shortcut, it is resolved to the actual path. (Windows only) +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FSetInfo64(ConstPath path, const FInfo64Ptr infop); + +/** @brief Modes available to open a file. */ +enum { + openReadWrite, /**< open the file for reading and writing */ + openReadOnly, /**< open the file for reading */ + openWriteOnly, /**< open the file for writing (on Mac, this may enforce exclusive access to the file) */ + openWriteOnlyTruncate, /**< open the file for writing, emptying the file on open */ + openReadWriteUnbuffered, /**< open the file for reading and writing , disabling system caching (Windows only) */ + openReadOnlyUnbuffered, /**< open the file for reading , disabling system caching (Windows only) */ + openWriteOnlyUnbuffered, /**< open the file for writing , disabling system caching (Windows only) */ + openWriteOnlyTruncateUnbuffered /**< open the file for writing, emptying the file on open and disabling system caching (Windows only) */ +}; + +/** @brief When opening a file, restrict concurrent access to the file. + @note Deny modes are not supported on all operating systems. +*/ +enum { + denyReadWrite, /**< deny others the ability to open a file for reading or writing */ + denyWriteOnly, /**< deny others the ability to open a file for writing */ + denyNeither /**< do not deny others from opening the file for any purpose */ +}; + +/** @brief Create and open a file in the specified mode, assigning permissions and optionally the group. + @param fdp receives a file descriptor; 0 if the operation fails + @param path absolute path to the file to create + @param permissions file system permissions to assign to the new file + @param openMode the file access mode to use when opening the file + @param denyMode defines concurrent access policy for the file (not supported on all platforms) + @param group the group to assign to the file (Mac, Linux only) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNoPerm: unable to create the file due to permissions in the file system + - fDupPath: a file already exists at the requested location + - fTMFOpen: unable to open the file because too many files have already been opened + + @note In VxWorks, the @p denyMode parameter has no effect. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FCreate(File *fdp, ConstPath path, const int32 permissions, const int32 openMode, const int32 denyMode, ConstPStr group); + +/** @brief Create and open a file in the specified mode, assigning permissions and optionally the group. + If the file already exists, truncate it. + @param fdp receives a file descriptor; 0 if the operation fails + @param path absolute path to the file to create + @param permissions file system permissions to assign to the new file + @param openMode the file access mode to use when opening the file + @param denyMode defines concurrent access policy for the file (not supported on all platforms) + @param group the group to assign to the file (Mac, Linux only) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNoPerm: unable to create the file due to permissions in the file system + - fTMFOpen: unable to open the file because too many files have already been opened + + @note In VxWorks, the @p denyMode parameter has no effect. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FCreateAlways(File *fdp, ConstPath path, const int32 access, const int32 openMode, const int32 denyMode, ConstPStr group); + +/** @brief Open an existing file in the specified mode. + @param fdp receives a file descriptor; 0 if the operation fails + @param path absolute path to the file to create + @param openMode the file access mode to use when opening the file + @param denyMode defines concurrent access policy for the file (not supported on all platforms) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNotFound: the file or directory does not exist at the specified location + - fNoPerm: unable to open the file due to permissions in the file system + - fTMFOpen: unable to open the file because too many files have already been opened + + @note In VxWorks, the @p denyMode parameter has no effect. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMOpen(File *fdp, ConstPath path, const int32 openMode, const int32 denyMode); + +/** @brief Close the file associated with the given file descriptor. + @param fd the file descriptor of the file to close + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fNotFound: the file does not exist at the specified location + - fIOErr: a general error occurred + + @note Calling FMClose() with an invalid file descriptor may cause your program to crash in some operating systems. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMClose(File fd); + +/** @brief Seek modes for FMSeek() and FMSeek64(). */ +enum { + fStart = 1, /**< move file marker relative to start of file */ + fEnd, /**< move file marker relative to end of file */ + fCurrent /**< move file marker relative to the current file marker position within the file */ +}; + +/** @brief Set the position mark for a file to the specified point. + @param fd file descriptor of the file whose marker is to be set + @param ofst new position for the file marker, intepreted by @p mode + @param mode move the file marker relative to the specified location (start, end, or current) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fEOF: attempted to move the file marker past the end of the file, or before the start + - fIOErr: a general error occurred + + When the @p mode is fEnd, the @p ofst value must be <= 0, and when @p mode is + fStart, the @p ofst value must be >= 0. Attempts to seek before the start of the + file result in the file marker being set to the beginning of the file, while + attempting to seek past the end of the file leaves the file marker at the end of the file. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMSeek(File fd, const int32 ofst, const int32 mode); + +/** @brief Set the position mark for a file to the specified point (supports files > 2 GB in size). + @param fd file descriptor of the file whose marker is to be set + @param ofst new position for the file marker, intepreted by @p mode + @param mode move the file marker relative to the specified location (start, end, or current) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fEOF: attempted to move the file marker past the end of the file, or before the start + - fIOErr: a general error occurred + + When the @p mode is fEnd, the @p ofst value must be <= 0, and when @p mode is + fStart, the @p ofst value must be >= 0. Attempts to seek before the start of the + file result in the file marker being set to the beginning of the file, while + attempting to seek past the end of the file leaves the file marker at the end of the file. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMSeek64(File fd, const int64 ofst, const int32 mode); + +/** @brief Get the current position of the file marker in the file. + @param fd file descriptor of the file whose marker position is to be retrieved + @param ofstp receives the position (in bytes) of the file marker, relative to the beginning of the file + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMTell(File fd, int32 *ofstp); + +/** @brief Get the current position of the file marker in the file (supports files > 2 GB in size). + @param fd file descriptor of the file whose marker position is to be retrieved + @param ofstp receives the position (in bytes) of the file marker, relative to the beginning of the file + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMTell64(File fd, int64 *ofstp); + +/** @brief Get the size of the file in bytes. + @param fd file descriptor of the file whose size is to be retrieved + @param sizep receives the size of the file (in bytes); if an error occurs, the value is undefined + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FGetEOF(File fd, int32 *sizep); + +/** @brief Get the size of the file in bytes (supports files > 2 GB in size). + @param fd file descriptor of the file whose size is to be retrieved + @param sizep receives the size of the file (in bytes); if an error occurs, the value is undefined + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FGetEOF64(File fd, int64 *sizep); + +/** @brief Set the size of a file. + @param fd file descriptor of the file whose size is to be changed + @param size new size for the file (in bytes) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNoPerm: unable to create the file due to permissions in the file system + - fDiskFull: not enough disk space +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FSetEOF(File fd, const int32 size); + +/** @brief Set the size of a file (supports files > 2 GB in size). + @param fd file descriptor of the file whose size is to be changed + @param size new size for the file (in bytes) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNoPerm: unable to modify the file due to permissions in the file system + - fDiskFull: not enough disk space +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FSetEOF64(File fd, const int64 size); + +/** @brief Lock or unlock a range within a file, preventing (or allowing) write access. + @param fd file descriptor of the file to lock or unlock a range within + @param mode lock / unlock range begins at @p offset relative to the specified location (start, end, or current) + @param offset position of the first byte to lock / unlock in the file, as determined by @p mode + @param count number of bytes to lock or unlock + @param lock if TRUE, the specified range is locked, if FALSE, it is unlocked + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNoPerm: unable to lock the file due to permissions in the file system + + @note In VxWorks, this function has no effect, and this function will never return an error. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FLockOrUnlockRange(File fd, const int32 mode, const int32 offset, const int32 count, const Bool32 lock); + +/** @brief Read the requested number of bytes from the given file. + @param fd file descriptor of the file to read + @param inCount number of bytes to read + @param outCountp receives the number of bytes actually read (ignored if NULL) + @param buffer receives the data + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fEOF: end of file reached before requested amount of data could be read + - fIOErr: a general error occurred +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMRead(File fd, const int32 inCount, int32 *outCountp, UPtr buffer); + +/** @brief Write the supplied data to the given file. + @param fd file descriptor of the file to write to + @param inCount number of bytes to write to the file + @param outCountp receives number of bytes actually written to the file + @param buffer the data to write to the file + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + - fNoPerm: unable to write to the file due to permissions in the file system or deny mode during concurrent access + - fDiskFull: not enough disk space +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMWrite(File fd, const int32 inCount, int32 *outCountp, ConstUPtr buffer); + +/** @brief Print formatted text to a file. + @param fd file descriptor of the file to write to + @param fmt format specifier string + @param ... arguments that provide data for the format specifier string + @return number of bytes written to the file, -1 if an error occurred +*/ +TH_REENTRANT EXTERNC int32 _FUNCC FPrintf(File, ConstCStr fmt, ...); + +/** @brief Write buffered data to disk. + @param fd file descriptor of the file to flush to disk + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FFlush(File fd); + +/** @brief Values returned from the FExists() function. */ +enum { + kFNotExist = 0, /**< the file or directory does not exist */ + kFIsFile, /**< the path refers to a file */ + kFIsFolder /**< the path refers to a directory */ +}; + +/** @brief Determine whether the given path exists, and if it is a file or directory. + @param path absolute path to a file or directory to check + @return one of the values kFNotExist, kFIsFile, or kFIsFolder +*/ +TH_REENTRANT EXTERNC int32 _FUNCC FExists(ConstPath path); + +/** @brief Determine if the given path refers to a directory. + @param p absolute path to check + @return TRUE if @p path refers to a folder, otherwise FALSE +*/ +#define FIsFolder(path) ((Bool32)(FExists((path)) == kFIsFolder)) + +/** @brief Get file system access rights information for the specified file or directory. + @param path absolute path to the file or directory to query + @param owner receives name of the owner of the file or directory (may not be NULL) + @param group receives name of the group of the file or directory (may not be NULL) + @param permPtr receives the UNIX-style file permissions bits of the file or direcotry (may not be NULL) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fNotFound: the file or directory does not exist at the specified location + - fIOErr: a general error occurred +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FGetAccessRights(ConstPath path, PStr owner, PStr group, int32 *permPtr); + +/** @brief Set file system access rights information for the specified file or directory. + @param path absolute path to the file or direcotry whose access rights are being modified + @param owner new owner of the file (ignored if NULL) + @param group new group of the file or directory (ignored if NULL) + @param permPtr new UNIX-style permissions for the file or directory (ignored if NULL) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fNotFound: the file or directory does not exist at the specified location + - fNoPerm: unable to modify the permissions in the file system due to restrictions imposed by the OS or file system + - fIOErr: a general error occurred + + @note If all off @p owner, @p group and @p permPtr are NULL, the function is a no-op and returns mgNoErr. + + @note In VxWorks, this function has no effect, and will never return an error. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FSetAccessRights(ConstPath path, ConstPStr owner, ConstPStr group, const int32 *permPtr); + +/** @brief Move or rename a file or directory. + @param oldPath absolute path to the file or directory to move + @param newPath absolute path to the destination for the file or directory + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - mFullErr: ran out of memory during the operation + - fIsOpen: file is already open and may not be moved + - fNotFound: the file or directory does not exist at the specified location + - fNoPerm: unable to move the file or directory due to restrictions imposed by the OS or file system + - fIOErr: a general error occurred + - fDiskFull: not enough disk space + - fDupPath: a directory or file already exists at the destination + - fTMFOpen: unable to open the source file because too many files have already been opened + @note In Windows, shortcuts in @p oldPath will be resolved prior to executing the move. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMove(ConstPath oldPath, ConstPath newPath); + +/** @brief Copy a file or directory from one location to another, preserving access rights and other information. + @param oldPath absolute path to a file or directory to copy + @param newPath absolute path for the copy of the file or directory + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - mFullErr: ran out of memory during the operation + - fIsOpen: file is already open and may not be moved + - fNotFound: the file or directory does not exist at the specified location + - fNoPerm: unable to move the file or directory due to restrictions imposed by the OS or file system + - fIOErr: a general error occurred + - fDiskFull: not enough disk space + - fDupPath: a directory or file already exists at the destination + - fTMFOpen: unable to open the source file because too many files have already been opened + @note In Windows, if @p oldPath is a shortcut, it is resolved prior to executing the copy. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FCopy(ConstPath oldPath, ConstPath newPath); + +/** @brief Permanently delete a file or empty directory. + @param path absolute path to the file or empty directory to delete + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIsOpen: file is already open and may not be moved + - fNotFound: the file or directory does not exist at the specified location + - fNoPerm: unable to move the file or directory due to restrictions imposed by the OS or file system + - fIOErr: a general error occurred + + @note If @p path refers to a shortcut, alias, or symbolic link, the respective shortcut, alias, or + link will be removed, not the target of the shortcut / alias / symbolic link. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FRemove(ConstPath path); + +/** @brief Place a file or directory into the system's trash / recycle bin. + @param path absolute path to the file or empty directory to delete + @param showConfigDlgs if TRUE, the operating system may display a dialog requesting confirmation of the operation + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIsOpen: file is already open and may not be moved + - fNotFound: the file or directory does not exist at the specified location + - fNoPerm: unable to move the file or directory due to restrictions imposed by the OS or file system + - fIOErr: a general error occurred + + @note When called on operating systems other than Mac or Windows, this function behaves + as if you called FRemove(), which permanently deletes the file or directory. + + @note In some cases, the operating system may display a progress dialog during the operation, + even if @p showConfigDlgs is FALSE. The dialog will not require user interaction. + + @note If @p path refers to a shortcut, alias, or symbolic link, the respective shortcut, alias, or + link will be removed, not the target of the shortcut / alias / symbolic link. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FRemoveToRecycle(ConstPath path, const Bool32 showConfirmDlgs); + +/** @brief Create a directory with the given permissions. + @param path the absolute path of the directory to create + @param permissions the access rights to assign to the diretory (typically folderDefaultPerm) + @return result operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fNotFound: the file or directory does not exist at the specified location + - fNoPerm: unable to create the directory due to permissions in the file system + - fIOErr: a general error occurred + + @note In VxWorks, the @p permissions argument has no effect. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FNewDir(ConstPath path, const int32 permissions); + +/** @brief Data structure describing a disk volume. */ +typedef struct { + uInt32 size; /**< size in bytes of a volume */ + uInt32 used; /**< number of bytes used on volume */ + uInt32 free; /**< number of bytes available for use on volume */ +} VInfoRec; + +/** @brief Get information about the volume containing the specified path, returning base volume path via the provided path. + @param path absolute path from which to extract volume information + @param vInfo receives information about the volume on which @p path exists + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred + + @note This function modifies the contents of the @p path argument. + + @note This function has been deprecated. Use FMGetVolInfo() or FMGetVolInfo64() instead. + It is unable to return accurate information for volumes 4 GB in size. +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FGetVolInfo(Path path, VInfoRec *vInfo); + +/** @brief Get information about the volume containing the specified path. + @param path in: absolute path from which to extract volume information; out: contains the base volume path + @param pFreeBytes receives number of free bytes on the volume containing @p path (may be NULL) + @param pTotalBytes receives total size in bytes of the volume containing @p path (may be NULL) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMGetVolInfo(ConstPath path, float64 *pFreeBytes, float64 *pTotalBytes); + +/** @brief Get information about the volume containing the specified path. + @param path absolute path from which to extract volume information + @param pFreeBytes receives number of free bytes on the volume containing @p path (may be NULL) + @param pTotalBytes receives total size in bytes of the volume containing @p path (may be NULL) + @param pSectorSize receives size in bytes of the sectors on the volume containing @p path (may be NULL) + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - fIOErr: a general error occurred +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMGetVolInfo64(ConstPath path, uInt64 *pFreeBytes, uInt64 *pTotalBytes, uInt32 *pSectorSize); + +/** @brief Get the path for the root of the volume for a given path. + @param path absolute path from which to extract the volume path + @param volPath receives the base volume path + @return result of the operation: + - mgNoErr: success + - mgArgErr: an invalid argument was passed to the function + - mFullErr: out of memory + + @todo Test this function and verify what happens when *volPath == path (especially on Linux). +*/ +TH_REENTRANT EXTERNC MgErr _FUNCC FMGetVolPath(ConstPath path, Path *volPath); + +TH_REENTRANT EXTERNC MgErr _FUNCC FListDir(ConstPath path, FDirEntHandle list, FMListDetails **); + +/*** The Path Manager ***/ + +/* FileNameCmp compares two PStr's with the same case-sensitivity as */ +/* the filesystem. */ +/* FileNameNCmp compares two CStr's (to length n) with the same */ +/* case-sensitivity as the filesystem. */ +/* FileNameIndCmp compares two PStr's (passing pointers to the string */ +/* pointers) with the same case-sensitivity as the filesystem. */ +#if Mac || MSWin || VxWorks +#define FileNameCmp PStrCaseCmp +#define FileNameNCmp StrNCaseCmp +#define FileNameIndCmp PPStrCaseCmp +#elif Unix +#define FileNameCmp PStrCmp +#define FileNameNCmp StrNCmp +#define FileNameIndCmp PPStrCmp +#endif + +/** @brief Path type codes */ +enum { fAbsPath, + fRelPath, + fNotAPath, + fUNCPath, /**< uncfilename */ + nPathTypes }; + +TH_REENTRANT EXTERNC MgErr _FUNCC FRelPath(ConstPath start, ConstPath end, Path relPath); +TH_REENTRANT EXTERNC MgErr _FUNCC FAddPath(ConstPath basePath, ConstPath relPath, Path newPath); +TH_REENTRANT EXTERNC MgErr _FUNCC FAppendName(Path path, ConstPStr name); +TH_REENTRANT EXTERNC MgErr _FUNCC FName(ConstPath path, PStrHandle name); +TH_REENTRANT EXTERNC MgErr _FUNCC FNamePtr(ConstPath path, PStr name); +TH_REENTRANT EXTERNC MgErr _FUNCC FDirName(ConstPath path, Path dir); +TH_REENTRANT EXTERNC MgErr _FUNCC FVolName(ConstPath path, Path vol); +TH_REENTRANT EXTERNC Path _FUNCC FMakePath(Path path, int32 type, ...); +TH_REENTRANT EXTERNC Path _FUNCC FEmptyPath(Path); +TH_REENTRANT EXTERNC Path _FUNCC FNotAPath(Path); +TH_REENTRANT EXTERNC Bool32 _FUNCC FIsAPath(ConstPath); +TH_REENTRANT EXTERNC int32 _FUNCC FDepth(ConstPath path); + +TH_REENTRANT EXTERNC MgErr _FUNCC FPathToPath(Path *p); +TH_REENTRANT EXTERNC MgErr _FUNCC FPathCpy(Path dst, ConstPath src); +TH_REENTRANT EXTERNC MgErr _FUNCC FTextToPath(ConstUPtr, int32, Path*); +TH_REENTRANT EXTERNC MgErr _FUNCC FPathToDSString(ConstPath, LStrHandle*); +TH_REENTRANT EXTERNC UHandle _FUNCC PathToCString(ConstPath ); +TH_REENTRANT EXTERNC MgErr _FUNCC FStringToPath(ConstLStrH, Path*); +TH_REENTRANT EXTERNC MgErr _FUNCC FPathToFileSystemDSString(ConstPath p, LStrHandle *txt); +TH_REENTRANT EXTERNC MgErr _FUNCC FFileSystemCStrToPath(ConstCStr text, Path *p); + +TH_REENTRANT EXTERNC Bool32 _FUNCC FStrFitsPat(const uChar*, const uChar*, int32, int32); +TH_REENTRANT EXTERNC int32 _FUNCC FPathCmp(ConstPath, ConstPath); +TH_REENTRANT EXTERNC int32 _FUNCC FPathCmpLexical(ConstPath, ConstPath); +TH_REENTRANT EXTERNC MgErr _FUNCC FSetPathType(Path, int32); +TH_REENTRANT EXTERNC MgErr _FUNCC FGetPathType(ConstPath, int32*); +TH_REENTRANT EXTERNC Bool32 _FUNCC FIsEmptyPath(ConstPath); +TH_REENTRANT EXTERNC Bool32 _FUNCC FIsAPathOrNotAPath(ConstPath); +TH_REENTRANT EXTERNC Bool32 _FUNCC FIsAPathOfType(ConstPath, int32); +TH_REENTRANT EXTERNC LStrHandle _FUNCC FGetDefGroup(LStrHandle); + +/** @brief Releases memory and sets pointer to NULL. */ +TH_REENTRANT EXTERNC void _FUNCC FDestroyPath(Path *pp); +/** @brief Use of FDestroyPath recommended over FDisposePath. */ +TH_REENTRANT EXTERNC MgErr _FUNCC FDisposePath(Path p); + +TH_REENTRANT EXTERNC int32 _FUNCC FUnFlattenPath(UPtr fp, Path *pPtr); +TH_REENTRANT EXTERNC int32 _FUNCC FFlattenPath(ConstPath p, UPtr fp); + +/** @brief Get the absolute LV Path to directory where executable is. */ +TH_REENTRANT EXTERNC MgErr _FUNCC FAppPath(Path p); + +typedef MagicCookie LVRefNum; + +TH_REENTRANT EXTERNC MgErr _FUNCC FNewRefNum(ConstPath, File, LVRefNum*); +TH_REENTRANT EXTERNC Bool32 _FUNCC FIsARefNum(LVRefNum); +TH_REENTRANT EXTERNC MgErr _FUNCC FDisposeRefNum(LVRefNum); +TH_REENTRANT EXTERNC MgErr _FUNCC FRefNumToFD(LVRefNum, File*); +TH_REENTRANT EXTERNC MgErr _FUNCC FRefNumToPath(LVRefNum, Path); +TH_REENTRANT EXTERNC MgErr _FUNCC FArrToPath(UHandle, Bool32, Path); +TH_REENTRANT EXTERNC MgErr _FUNCC FPathToArr(ConstPath, Bool32*, UHandle); + +typedef MagicCookie LVUserEventRef; +TH_REENTRANT EXTERNC MgErr _FUNCC PostLVUserEvent(LVUserEventRef ref, void *data); + +/** @brief Custom data used for external function calls (such as the Call Library Node). */ +typedef void* InstanceDataPtr; + +TH_REENTRANT EXTERNC MgErr _FUNCC CallChain(UHandle); + +TH_REENTRANT EXTERNC MgErr _FUNCC NumericArrayResize(int32, int32, UHandle*, size_t); +TH_REENTRANT EXTERNC MgErr _FUNCC NumericArrayResizeNoInit(int32, int32, UHandle*, size_t); + +/*** Application Builder ***/ + +/** @brief This function provides the thread specific last error message set during + previous calls to exposed API in LabVIEW built shared library. This function + should be used when error-out clusters are configured to return error-code + as return value using application builder. + @param errstr User allocated buffer to store error message. User must allocate sufficient memory. + @param len Size in bytes of allocated buffer 'errstr'. +*/ +TH_REENTRANT EXTERNC void _FUNCC LVGetLastErrorMsg(CStr errstr, int32 len); + +/** @brief Clears out the previous error message for a current thread. +*/ +TH_REENTRANT EXTERNC void _FUNCC LVClearLastErrorMsg(); + +/*** CIN-specific Functions ***/ +TH_REENTRANT EXTERNC int32 _FUNCC SetCINArraySize(uChar **elmtH, int32 elmtNum, int32 newNumElmts); +TH_REENTRANT EXTERNC int32 _FUNCC GetDSStorage(void); +TH_REENTRANT EXTERNC int32 _FUNCC SetDSStorage(int32 newval); +TH_REENTRANT EXTERNC int16* _FUNCC GetTDPtr(void); +TH_REENTRANT EXTERNC uChar* _FUNCC GetLVInternals(void); + +/* selectors for CINProperties */ +enum { kCINIsReentrant }; + +#define CIN EXTERNC + +CIN int32 _FUNCC CINInit(void); +CIN int32 _FUNCC CINDispose(void); +CIN int32 _FUNCC CINAbort(void); +CIN int32 _FUNCC CINLoad(uInt32 reserved); +CIN int32 _FUNCC CINUnload(void); +CIN int32 _FUNCC CINSave(uInt32 reserved); +CIN int32 _FUNCC CINProperties(int32 selector, void *arg); + +#define ENTERLVSB +#define LEAVELVSB + +/* CINInit -- Called after the VI is loaded or recompiled. */ +#define UseDefaultCINInit CIN MgErr _FUNCC CINInit() { return mgNoErr; } + +/* CINDispose -- Called before the VI is unloaded or recompiled.*/ +#define UseDefaultCINDispose CIN MgErr _FUNCC CINDispose() { return mgNoErr; } + +/* CINAbort-- Called when the VI is aborted. */ +#define UseDefaultCINAbort CIN MgErr _FUNCC CINAbort() { return mgNoErr; } + +/* CINLoad -- Called when the VI is loaded. */ +#define UseDefaultCINLoad CIN MgErr _FUNCC CINLoad(uInt32 reserved) { Unused(reserved); return mgNoErr; } + +/* CINUnload -- Called when the VI is unloaded. */ +#define UseDefaultCINUnload CIN MgErr _FUNCC CINUnload() { return mgNoErr; } + +/* CINSave -- Called when the VI is saved. */ +#define UseDefaultCINSave CIN MgErr _FUNCC CINSave(uInt32 reserved) { Unused(reserved); return mgNoErr; } + +#include "lv_epilog.h" + +#endif /* _extcode_H */ diff --git a/labview/cintools/fundtypes.h b/labview/cintools/fundtypes.h new file mode 100644 index 00000000..048ed39e --- /dev/null +++ b/labview/cintools/fundtypes.h @@ -0,0 +1,799 @@ +#ifndef _fundtypes_H +#define _fundtypes_H +/* + (c) Copyright 1990-2020 by National Instruments Corp. + All rights reserved. + + + fundtypes.h - Fundamental data types. + + Header intended for use by C and C++. No C++ style (//) comments. +*/ + +#include "platdefines.h" + +/*The MSVC compiler does not define all the C99 types, so define a subset here*/ +#if MSWin +# if (defined(_CVI_) && (_CVI_ >= 910)) || (_MSC_VER >= 1900 && (!defined(USE_C99_TYPES) || USE_C99_TYPES == 1)) + /* If we're compiling using CVI, just use their C99 types. */ +# include +# else + /* If the C99 types have been defined already by stdint.h, don't define them again. */ +# if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(_STDINT) + typedef signed char int8_t; + typedef unsigned char uint8_t; + typedef short int16_t; + typedef unsigned short uint16_t; + typedef int int32_t; + typedef unsigned int uint32_t; + +# if defined(_MSC_VER) && (_MSC_VER < 1300) + typedef long intptr_t; + typedef unsigned long uintptr_t; +# endif /* defined(_MSC_VER) && (_MSC_VER < 1300) */ +# endif /* !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(_STDINT) */ +# endif /* defined(_CVI_) && (_CVI_ >= 910) */ +#else + +# ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS /*for enabling the INT8_MIN, etc. macros declared in stdint.h */ +# endif /* __STDC_LIMIT_MACROS */ + +# include + +#endif /*MSWin*/ + +#ifdef USE_C99_TYPES + +# ifndef _NI_int8_DEFINED_ + #define _NI_int8_DEFINED_ + typedef int8_t int8; +# endif +# ifndef _NI_uInt8_DEFINED_ + #define _NI_uInt8_DEFINED_ + typedef uint8_t uInt8; +# endif +# ifndef _NI_uChar_DEFINED_ + #define _NI_uChar_DEFINED_ + typedef uInt8 uChar; +# endif +# ifndef _NI_int16_DEFINED_ + #define _NI_int16_DEFINED_ + typedef int16_t int16; +# endif +# ifndef _NI_uInt16_DEFINED_ + #define _NI_uInt16_DEFINED_ + typedef uint16_t uInt16; +# endif +# ifndef _NI_int32_DEFINED_ + #define _NI_int32_DEFINED_ + typedef int32_t int32; +# endif +# ifndef _NI_uInt32_DEFINED_ + #define _NI_uInt32_DEFINED_ + typedef uint32_t uInt32; +# endif +# ifndef _NI_float32_DEFINED_ + #define _NI_float32_DEFINED_ + typedef float float32; +# endif +# ifndef _NI_float64_DEFINED_ + #define _NI_float64_DEFINED_ + typedef double float64; +# endif + +#endif /* USE_C99_TYPES */ + +#include "lv_prolog.h" + +#if Mac || Palm/*##############################################################*/ + +# ifndef USE_C99_TYPES +# ifndef _NI_int8_DEFINED_ + #define _NI_int8_DEFINED_ + typedef char int8; +# endif +# ifndef _NI_uInt8_DEFINED_ + #define _NI_uInt8_DEFINED_ + typedef unsigned char uInt8; +# endif +# ifndef _NI_uChar_DEFINED_ + #define _NI_uChar_DEFINED_ + typedef uInt8 uChar; +# endif +# ifndef _NI_int16_DEFINED_ + #define _NI_int16_DEFINED_ + typedef short int16; +# endif +# ifndef _NI_uInt16_DEFINED_ + #define _NI_uInt16_DEFINED_ + typedef unsigned short uInt16; +# endif +# if (ProcessorType == kX64) +# ifndef _NI_int32_DEFINED_ + #define _NI_int32_DEFINED_ + typedef int int32; +# endif +# ifndef _NI_uInt32_DEFINED_ + #define _NI_uInt32_DEFINED_ + typedef unsigned int uInt32; +# endif +# else +# ifndef _NI_int32_DEFINED_ + #define _NI_int32_DEFINED_ + typedef long int32; +# endif +# ifndef _NI_uInt32_DEFINED_ + #define _NI_uInt32_DEFINED_ + typedef unsigned long uInt32; +# endif +# endif +# ifndef _NI_float32_DEFINED_ + #define _NI_float32_DEFINED_ + typedef float float32; +# endif +# ifndef _NI_float64_DEFINED_ + #define _NI_float64_DEFINED_ + typedef double float64; +# endif +# endif /* USE_C99_TYPES */ + +# if (ProcessorType == kM68000) || ((ProcessorType == kPPC) && (Compiler == kMPW)) +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef long double floatExt; +# endif +# define ExtHiLo 0 +# define CompilerSupportsExt 1 +# elif MacOSX && (ProcessorType == kPPC) +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef double floatExt; +# endif +# define CompilerSupportsExt 1 +# elif MacX86 || MacX64 +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef struct { /* force GCC to make this struct 10 bytes */ + int32 mlo __attribute__((packed,aligned(2))); + int32 mhi __attribute__((packed,aligned(2))); + int16 e __attribute__((packed,aligned(2))); + } floatExt; +# endif +# define CompilerSupportsExt 0 +# else +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef struct { + double hi; + double lo; + } floatExt; +# endif +# define ExtHiLo 1 +# define CompilerSupportsExt 1 +# endif + +# define CompilerSupportsInt64 1 +# ifndef USE_C99_TYPES +# ifndef _NI_int64_DEFINED_ + #define _NI_int64_DEFINED_ + typedef long long int64; +# endif +# ifndef _NI_uInt64_DEFINED_ + #define _NI_uInt64_DEFINED_ + typedef unsigned long long uInt64; +# endif +# endif /* USE_C99_TYPES */ + +#elif Unix /*###########################################################*/ + +# ifndef USE_C99_TYPES +# ifndef _NI_int8_DEFINED_ + #define _NI_int8_DEFINED_ + typedef signed char int8; +# endif +# ifndef _NI_uInt8_DEFINED_ + #define _NI_uInt8_DEFINED_ + typedef unsigned char uInt8; +# endif +# ifndef _NI_uChar_DEFINED_ + #define _NI_uChar_DEFINED_ + typedef uInt8 uChar; +# endif +# ifndef _NI_int16_DEFINED_ + #define _NI_int16_DEFINED_ + typedef short int int16; +# endif +# ifndef _NI_uInt16_DEFINED_ + #define _NI_uInt16_DEFINED_ + typedef unsigned short int uInt16; +# endif +# ifndef _NI_int32_DEFINED_ + #define _NI_int32_DEFINED_ + typedef int int32; +# endif +# ifndef _NI_uInt32_DEFINED_ + #define _NI_uInt32_DEFINED_ + typedef unsigned int uInt32; +# endif +# ifndef _NI_float32_DEFINED_ + #define _NI_float32_DEFINED_ + typedef float float32; +# endif +# ifndef _NI_float64_DEFINED_ + #define _NI_float64_DEFINED_ + typedef double float64; +# endif +# endif /* USE_C99_TYPES */ + +# define ExtHiLo 0 +# if ProcessorType==kPARISC || ProcessorType==kMIPS || (Linux && PowerPC) +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef double floatExt; +# endif +# define CompilerSupportsExt 1 +# elif ProcessorType==kX86 || ProcessorType==kX64 +# if (Compiler==kGCC) +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef struct { /* force GCC to make this struct 10 bytes */ + int32 mlo __attribute__((packed,aligned(2))); + int32 mhi __attribute__((packed,aligned(2))); + int16 e __attribute__((packed,aligned(2))); + } floatExt; +# endif +# else +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef struct { + int32 mlo; + int32 mhi; + int16 e; + } floatExt; +# endif +# endif +# define CompilerSupportsExt 0 +# elif ProcessorType == kARM +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef double floatExt; +# endif +# define CompilerSupportsExt 1 +# else +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef long double floatExt; +# endif +# define CompilerSupportsExt 1 +# endif + +# if OpSystem==kPowerUnix || (OpSystem == kHPUX && defined(__cplusplus)) +# define CompilerSupportsInt64 0 +# ifndef _NI_int64_DEFINED_ + #define _NI_int64_DEFINED_ + typedef struct { + int32 hi, lo; + } int64; +# endif +# ifndef _NI_uInt64_DEFINED_ + #define _NI_uInt64_DEFINED_ + typedef struct { + int32 hi, lo; + } uInt64; +# endif +# else +# define CompilerSupportsInt64 1 +# ifndef USE_C99_TYPES +# ifndef _NI_int64_DEFINED_ + #define _NI_int64_DEFINED_ + typedef long long int64; +# endif +# ifndef _NI_uInt64_DEFINED_ + #define _NI_uInt64_DEFINED_ + typedef unsigned long long uInt64; +# endif +# endif /* USE_C99_TYPES */ +# endif /*OpSystem==kPowerUnix || (OpSystem == kHPUX && defined(__cplusplus))*/ + +#elif MSWin /*##########################################################*/ + +# ifndef USE_C99_TYPES +# ifndef _NI_int8_DEFINED_ + #define _NI_int8_DEFINED_ + typedef char int8; +# endif +# ifndef _NI_uInt8_DEFINED_ + #define _NI_uInt8_DEFINED_ + typedef unsigned char uInt8; +# endif +# ifndef _NI_uChar_DEFINED_ + #define _NI_uChar_DEFINED_ + typedef uInt8 uChar; +# endif +# ifndef _NI_int16_DEFINED_ + #define _NI_int16_DEFINED_ + typedef short int int16; +# endif +# ifndef _NI_uInt16_DEFINED_ + #define _NI_uInt16_DEFINED_ + typedef unsigned short int uInt16; +# endif +# ifndef _NI_int32_DEFINED_ + #define _NI_int32_DEFINED_ + typedef long int32; +# endif +# ifndef _NI_uInt32_DEFINED_ + #define _NI_uInt32_DEFINED_ + typedef unsigned long uInt32; +# endif +# ifndef _NI_float32_DEFINED_ + #define _NI_float32_DEFINED_ + typedef float float32; +# endif +# ifndef _NI_float64_DEFINED_ + #define _NI_float64_DEFINED_ + typedef double float64; +# endif + +# endif /* USE_C99_TYPES */ + +# if (defined(_NI_VC_) || defined(_NI_SC_) || defined(_NI_BC_)) && !(defined(_CVI_) && (_CVI_ >= 910)) +# define CompilerSupportsInt64 0 +# ifndef _NI_int64_DEFINED_ + #define _NI_int64_DEFINED_ + typedef struct { + int32 hi, lo; + } int64; +# endif +# ifndef _NI_uInt64_DEFINED_ + #define _NI_uInt64_DEFINED_ + typedef struct { + int32 hi, lo; + } uInt64; +# endif +# else +# define CompilerSupportsInt64 1 +# ifndef USE_C99_TYPES +# if Compiler==kMetroWerks +# ifndef _NI_int64_DEFINED_ + #define _NI_int64_DEFINED_ + typedef long long int64; +# endif +# ifndef _NI_uInt64_DEFINED_ + #define _NI_uInt64_DEFINED_ + typedef unsigned long long uInt64; +# endif +# else +# ifndef _NI_int64_DEFINED_ + #define _NI_int64_DEFINED_ + typedef __int64 int64; +# endif +# ifndef _NI_uInt64_DEFINED_ + #define _NI_uInt64_DEFINED_ + typedef unsigned __int64 uInt64; +# endif +# endif +# endif /* USE_C99_TYPES */ +# endif + +# define ExtHiLo 0 +# if ProcessorType == kX64 +# pragma pack(push) +# pragma pack(2) +# endif +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef struct { + int32 mlo; + int32 mhi; + int16 e; + } floatExt; +# endif +# define CompilerSupportsExt 0 +# if ProcessorType == kX64 +# pragma pack(pop) +# endif + +#elif Vdk /*##########################################################*/ + +# ifndef USE_C99_TYPES +# ifndef _NI_int8_DEFINED_ + #define _NI_int8_DEFINED_ + typedef signed char int8; +# endif +# ifndef _NI_uInt8_DEFINED_ + #define _NI_uInt8_DEFINED_ + typedef unsigned char uInt8; +# endif +# ifndef _NI_uChar_DEFINED_ + #define _NI_uChar_DEFINED_ + typedef uInt8 uChar; +# endif +# ifndef _NI_int16_DEFINED_ + #define _NI_int16_DEFINED_ + typedef short int int16; +# endif +# ifndef _NI_uInt16_DEFINED_ + #define _NI_uInt16_DEFINED_ + typedef unsigned short int uInt16; +# endif +# ifndef _NI_int32_DEFINED_ + #define _NI_int32_DEFINED_ + typedef int int32; +# endif +# ifndef _NI_uInt32_DEFINED_ + #define _NI_uInt32_DEFINED_ + typedef unsigned int uInt32; +# endif +# ifndef _NI_float32_DEFINED_ + #define _NI_float32_DEFINED_ + typedef float float32; +# endif +# ifndef _NI_float64_DEFINED_ + #define _NI_float64_DEFINED_ + typedef double float64; +# endif +# endif /* USE_C99_TYPES */ + +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef double floatExt; +# endif + +# define CompilerSupportsInt64 1 +# ifndef USE_C99_TYPES +# ifndef _NI_int64_DEFINED_ + #define _NI_int64_DEFINED_ + typedef long long int64; +# endif +# ifndef _NI_uInt64_DEFINED_ + #define _NI_uInt64_DEFINED_ + typedef unsigned long long uInt64; +# endif +# endif /* USE_C99_TYPES */ + +#elif Rtx /*##########################################################*/ + +# ifndef _NI_int8_DEFINED_ + #define _NI_int8_DEFINED_ + typedef signed char int8; +# endif +# ifndef _NI_uInt8_DEFINED_ + #define _NI_uInt8_DEFINED_ + typedef unsigned char uInt8; +# endif +# ifndef _NI_uChar_DEFINED_ + #define _NI_uChar_DEFINED_ + typedef uInt8 uChar; +# endif +# ifndef _NI_int16_DEFINED_ + #define _NI_int16_DEFINED_ + typedef short int int16; +# endif +# ifndef _NI_uInt16_DEFINED_ + #define _NI_uInt16_DEFINED_ + typedef unsigned short int uInt16; +# endif +# ifndef _NI_int32_DEFINED_ + #define _NI_int32_DEFINED_ + typedef int int32; +# endif +# ifndef _NI_uInt32_DEFINED_ + #define _NI_uInt32_DEFINED_ + typedef unsigned int uInt32; +# endif +# ifndef _NI_float32_DEFINED_ + #define _NI_float32_DEFINED_ + typedef float float32; +# endif +# ifndef _NI_float64_DEFINED_ + #define _NI_float64_DEFINED_ + typedef double float64; +# endif + +# ifndef _NI_floatExt_DEFINED_ + #define _NI_floatExt_DEFINED_ + typedef double floatExt; +# endif + #define CompilerSupportsInt64 1 +# ifndef _NI_int64_DEFINED_ + #define _NI_int64_DEFINED_ + typedef long long int64; +# endif +# ifndef _NI_uInt64_DEFINED_ + #define _NI_uInt64_DEFINED_ + typedef unsigned long long uInt64; +# endif + +#endif + +#ifndef EXTCODE_CMPLX_TYPES +#define EXTCODE_CMPLX_TYPES + +#ifndef _NI_cmplx64_DEFINED_ +#define _NI_cmplx64_DEFINED_ +/** @brief Complex single-precision floating point number. */ +typedef struct { + float32 re; + float32 im; +} cmplx64; +#endif + +#ifndef _NI_cmplx128_DEFINED_ +#define _NI_cmplx128_DEFINED_ +/** @brief Complex double-precision floating point number. */ +typedef struct { + float64 re; + float64 im; +} cmplx128; +#endif + +#ifndef _NI_cmplxExt_DEFINED_ +#define _NI_cmplxExt_DEFINED_ +/** @brief Complex extended-precision floating point number. */ +typedef struct { + floatExt re; + floatExt im; +} cmplxExt; +#endif + +#endif /* EXTCODE_CMPLX_TYPES */ + +#include "lv_epilog.h" + +#ifndef _NI_Bool32_DEFINED_ +#define _NI_Bool32_DEFINED_ +/* Bool32 is based on our own int32 type. */ +typedef int32 Bool32; +#endif +#undef TRUE +#undef FALSE +#define TRUE 1 +#define FALSE 0 + +/* For making void* pts that are distinguishable. */ +#define NIPrivatePtr(x) typedef struct x ## _t { void *p; } *x + +/* Minimum of signed integral types. */ +#ifndef INT8_MIN +# define INT8_MIN (-128) +#endif /* INT8_MIN */ +#ifndef INT16_MIN +# define INT16_MIN (-32767-1) +#endif /* INT16_MIN */ +#ifndef INT32_MIN +# define INT32_MIN (-2147483647-1) +#endif /* INT32_MIN */ +/* Maximum of signed integral types. */ +#ifndef INT8_MAX +# define INT8_MAX (127) +#endif /* INT8_MAX */ +#ifndef INT16_MAX +# define INT16_MAX (32767) +#endif /* INT16_MAX */ +#ifndef INT32_MAX +# define INT32_MAX (2147483647) +#endif /* INT32_MAX */ + +/* Maximum of unsigned integral types. */ +#ifndef UINT8_MAX +# define UINT8_MAX (255) +#endif /* UINT8_MAX */ +#ifndef UINT16_MAX +# define UINT16_MAX (65535) +#endif /* UINT16_MAX */ +#ifndef UINT32_MAX +# define UINT32_MAX (4294967295U) +#endif /* UINT32_MAX */ + +/* Limits for fundamental types. */ +#ifndef uInt8_MAX +#define uInt8_MAX UINT8_MAX +#endif +#ifndef uInt16_MAX +#define uInt16_MAX UINT16_MAX +#endif +#ifndef uInt32_MAX +#define uInt32_MAX UINT32_MAX +#endif + +#ifndef int8_MIN +#define int8_MIN INT8_MIN +#endif +#ifndef int8_MAX +#define int8_MAX INT8_MAX +#endif +#ifndef int16_MIN +#define int16_MIN INT16_MIN +#endif +#ifndef int16_MAX +#define int16_MAX INT16_MAX +#endif +#ifndef int32_MIN +#define int32_MIN INT32_MIN +#endif +#ifndef int32_MAX +#define int32_MAX INT32_MAX +#endif + +#ifndef float32_MAX +#define float32_MAX 3.402823466e+38F +#endif +#ifndef float64_MAX +#define float64_MAX 1.7976931348623158e+308 +#endif + +#if CompilerSupportsInt64 +# if MSWin +/* If the C99 types have been defined already by stdint.h, don't define them again. */ +# if !defined(_STDINT_H_) && !defined(_STDINT_H) +# ifdef _MSC_VER + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; +# else + typedef long long int int64_t; + typedef unsigned long long int uint64_t; +# endif /* _MSC_VER */ +# endif /* !defined(_STDINT_H_) && !defined(_STDINT_H) */ +# endif /* MSWin */ +# ifdef USE_C99_TYPES +# ifndef _NI_int64_DEFINED_ + #define _NI_int64_DEFINED_ + typedef int64_t int64; +# endif +# ifndef _NI_uInt64_DEFINED_ + #define _NI_uInt64_DEFINED_ + typedef uint64_t uInt64; +# endif +# endif /* USE_C99_TYPES */ + +/* 64-bit integer constants */ +# if MSWin && defined(_MSC_VER) && (_MSC_VER < 1300) +/* Before VC 7.1, we need to use this special way of adorning constants */ +# define I64Const(n) n##i64 +# define U64Const(n) n##ui64 +# else +# define I64Const(n) n##LL +# define U64Const(n) n##ULL +# endif + +# ifndef INT64_MIN +# define INT64_MIN ( I64Const(-9223372036854775807) - 1) +# endif /* INT64_MIN */ +# ifndef INT64_MAX +# define INT64_MAX I64Const(9223372036854775807) +# endif /* INT64_MAX */ +# ifndef UINT64_MAX +# define UINT64_MAX U64Const(0xffffffffffffffff) +# endif /* UINT64_MAX */ + +#ifndef int64_ZERO +# define int64_ZERO I64Const(0) +#endif +#ifndef uInt64_ZERO +# define uInt64_ZERO U64Const(0) +#endif +#ifndef int64_MIN +# define int64_MIN INT64_MIN +#endif +#ifndef int64_MAX +# define int64_MAX INT64_MAX +#endif +#ifndef uInt64_MAX +# define uInt64_MAX UINT64_MAX +#endif + +#else /* CompilerSupportsInt64=0 */ +# if MSWin +/* Go ahead and give these symbols definition. */ + typedef int64 int64_t; + typedef uInt64 uint64_t; +# endif +#endif + +#ifndef _NI_HRESULT_DEFINED_ +# define _NI_HRESULT_DEFINED_ +# if MSWin + typedef long HRESULT; + typedef long SCODE; +# else + typedef int32 HRESULT; + typedef int32 SCODE; +# endif /* MSWin */ +#endif /*_NI_HRESULT_DEFINED_*/ + +#ifndef Unused +/* The macro Unused can be used to avoid compiler warnings for +unused parameters or locals. */ +# ifdef __cplusplus +/* This implementation of Unused is safe for const parameters. */ +# define Unused(var_or_param) _Unused(reinterpret_cast(&var_or_param)) + inline void _Unused(const void *) {} +# elif MSWin +/* This implementation of Unused is not safe for const parameters. */ +# define Unused(var_or_param) var_or_param=var_or_param +# else +# define Unused(var_or_param) +# endif +#endif /* Unused */ + +#ifndef ConstNotEq +/* The ConstNotEq macro can be used to avoid +"expression is constant" warnings in "if" +statements -- only avoids the warning if you +compile with a C++ compiler. */ +# ifdef __cplusplus + inline bool _ConstNotEq(const int32 a, const int32 b) { return a != b; } +# define ConstNotEq(a, b) _ConstNotEq(a, b) +# else +# define ConstNotEq(a, b) (a != b) +# endif /* __cplusplus */ +#endif /* ConstNotEq */ + +#ifndef ConstEvalBool +/* The ConstEvalBool macro can be used to avoid +"expression is constant" warnings in "if" +statements -- only avoids the warning if you +compile with a C++ compiler. */ +# ifdef __cplusplus + inline bool _ConstEvalBool(const bool a) { return a; } +# define ConstEvalBool(a) _ConstEvalBool(a) +# else +# define ConstEvalBool(a) (a) +# endif /* __cplusplus */ +#endif /* ConstEvalBool */ + +/* Get the system definitions for +size_t, NULL, ptrdiff_t, offsetof, wchar_t */ + +#ifdef _CVI_ +#include +#endif /* _CVI_ */ + +#include + +/* Macros to convert from pointers to non-pointer types. +On 64-bit systems, these will truncate the values to 32 bits. */ +#define PtrToUInt32(p) ((uInt32)(uintptr_t)p) + +/* Localize the warnings for float comparison to one place +see http://www.codeguru.com/forum/showthread.php?t=323835 */ +#ifdef __cplusplus + #include /* fabs */ + #include /* DBL_EPSILON */ + enum FloatComparisonMethod { + FloatComparisonExact, + FloatComparisonWithinEpsilon + }; + namespace LVFloats { + inline bool Equal64(const float64 &f1, const float64 &f2, FloatComparisonMethod method= FloatComparisonExact) { + if(FloatComparisonWithinEpsilon == method) { + return fabs(f1 - f2) < DBL_EPSILON; + } + return (f1 <= f2) && (f1 >= f2); /* f1 == f2; */ + } + inline bool Equal32(const float32 &f1, const float32 &f2, FloatComparisonMethod method= FloatComparisonExact) { +#if !VxWorks + if(FloatComparisonWithinEpsilon == method) { + return fabsf(f1 - f2) < FLT_EPSILON; + } +#endif /* !VxWorks */ + return (f1 <= f2) && (f1 >= f2); /* f1 == f2; */ + } + template + inline bool Equal(const T &v1, const T &v2, FloatComparisonMethod /* method */ = FloatComparisonExact) { + return (v1 <= v2) && (v1 >= v2); /* v1 == v2; */ + } + template <> + inline bool Equal(const float64 &v1, const float64 &v2, FloatComparisonMethod method) { + return Equal64(v1, v2, method); + } + template <> + inline bool Equal(const float32 &v1, const float32 &v2, FloatComparisonMethod method) { + return Equal32(v1, v2, method); + } + } /* namespace LVFloats */ +#endif /* __cplusplus */ + +#endif /* _fundtypes_H */ diff --git a/labview/cintools/hosttype.h b/labview/cintools/hosttype.h new file mode 100644 index 00000000..7b763005 --- /dev/null +++ b/labview/cintools/hosttype.h @@ -0,0 +1,92 @@ +#ifndef _hosttype_H +#define _hosttype_H +/** + NI CONFIDENTIAL + (c) Copyright 1990-2020 by National Instruments Corp. + All rights reserved. + + @file + @brief Host specific definitions, etc. + +*/ + +#if Mac // use forward includes to define types needed for managerp.h +struct EventRecord; +struct RGBColor; +typedef struct Palette *PalettePtr, **PaletteHandle; +typedef struct Cursor *CursPtr, **CursHandle; +typedef struct Picture *PicPtr, **PicHandle; +typedef struct GDevice *GDPtr, **GDHandle; +typedef struct OpaqueWindowPtr *WindowPtr; +typedef struct OpaqueMenuRef *MenuRef, *MenuHandle; +typedef struct OpaqueGrafPtr *GrafPtr, *CGrafPtr, *GWorldPtr; +struct BitMap; +struct Pattern; +#include + +#endif /* Mac */ + +#if Unix +#include +#include +#endif /* Unix */ + +#if MSWin +#ifdef TRUE +#undef TRUE +#endif +#ifdef FALSE +#undef FALSE +#endif + +#ifndef _WIN32_WINNT + #if _MSC_VER <= 1499 // MSVC 8.0 or earlier + #define _WIN32_WINNT 0x0400 + #else + #if (OpSystem==kMSWin32) + #define _WIN32_WINNT 0x0501 + #else + #define _WIN32_WINNT 0x0600 + #endif // (OpSystem==kMSWin32) + #endif +#else + #ifndef MSWin_DISABLE_MIN_WINVER_CHECK + #if _MSC_VER <= 1499 // MSVC 8.0 or earlier + #if (_WIN32_WINNT < 0x0400) + #error _WIN32_WINNT must be >= 0x0400. + #endif // (_WIN32_WINNT < 0x0400) + #else + /* Ensure that the _WIN32_WINNT version is adequate. */ + #if (OpSystem==kMSWin32) + #if (_WIN32_WINNT < 0x0601) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0601 + #endif // (_WIN32_WINNT < 0x0601) + #else + #if (_WIN32_WINNT < 0x0601) + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0601 + #endif // (_WIN32_WINNT < 0x0601) + #endif // (OpSystem==kMSWin32) + #endif + #endif /* MSWin_DISABLE_MIN_WINVER_CHECK */ +#endif /* #ifndef _WIN32_WINNT */ + +#pragma warning (push) +#pragma warning (disable : 4701) /* local variable 'XXX' may be used without having been initialized */ +#include +#include +#pragma warning (pop) +#pragma warning (disable : 4001) /* nonstandard extension 'single line comment' was used */ + +#ifdef TRUE +#undef TRUE +#endif +#define TRUE 1 +#ifdef FALSE +#undef FALSE +#endif +#define FALSE 0 +#endif /* MSWin */ + +#endif /* _hosttype_H */ diff --git a/labview/cintools/liblv.so b/labview/cintools/liblv.so new file mode 120000 index 00000000..6399d09b --- /dev/null +++ b/labview/cintools/liblv.so @@ -0,0 +1 @@ +liblv.so.20 \ No newline at end of file diff --git a/labview/cintools/liblv.so.20 b/labview/cintools/liblv.so.20 new file mode 120000 index 00000000..ca13903d --- /dev/null +++ b/labview/cintools/liblv.so.20 @@ -0,0 +1 @@ +liblv.so.20.0.0 \ No newline at end of file diff --git a/labview/cintools/liblv.so.20.0.0 b/labview/cintools/liblv.so.20.0.0 new file mode 100755 index 00000000..00f5154b Binary files /dev/null and b/labview/cintools/liblv.so.20.0.0 differ diff --git a/labview/cintools/lv_epilog.h b/labview/cintools/lv_epilog.h new file mode 100644 index 00000000..3c02abc0 --- /dev/null +++ b/labview/cintools/lv_epilog.h @@ -0,0 +1,22 @@ +/** + (c) Copyright 2007-2020 by National Instruments Corp. + All rights reserved. + + @file + @brief Restore structure alignment after including lv_prolog.h. + + You must include this after including lv_prolog.h. + + @note Never put include guards in this header. It is designed to be included multiple times. + + @pre This header requires that the lv_prolog.h header be included before it. +*/ + +#if !defined(NIDL) +/* Restore byte packing to its previous setting. */ +#if MSWin && (ProcessorType == kX86) + #pragma pack(pop) +#elif Mac + #pragma options align=reset +#endif /* struct alignment restore */ +#endif /* !defined(NIDL) */ diff --git a/labview/cintools/lv_prolog.h b/labview/cintools/lv_prolog.h new file mode 100644 index 00000000..bdd6783e --- /dev/null +++ b/labview/cintools/lv_prolog.h @@ -0,0 +1,51 @@ +/** + (c) Copyright 2007-2020 by National Instruments Corp. + All rights reserved. + + @file + @brief Ensure proper structure alignment for data structures. Bookend with lv_epilog.h. + + Data structures requiring platform-specific structure alignment should include this + header prior to the definition of the structure. You must then include lv_epilog.h + to restore structure packing to its previous setting. + + @note Never put include guards in this header. It is designed to be included multiple times. + + @note Take care to when including other headers between a lv_prolog.h / lv_epilog.h pair - + be careful to ensure consistency across software components. + + Example usage: + @code + #include "some_header.h" + + #include "platdefines.h" + #include "lv_prolog.h" + + typedef struct { + int m_int; + double m_double; + } MyStruct; + + #include "lv_epilog.h" + + @endcode +*/ + +#include "platdefines.h" + +#if !defined(NIDL) +#if MSWin && (ProcessorType == kX86) + /* Windows x86 targets use 1-byte structure packing. */ + #pragma pack(push,1) + #pragma warning (disable : 4103) /* disable warning: alignment changed after including header */ +#elif Mac + /* Use natural alignment on the Mac. */ + #if (Compiler == kGCC) || (Compiler == kMetroWerks) + #pragma options align=natural + #else + #error "Unsupported compiler. Figure out how to set alignment to native/natural" + #endif +#else + /* Use default (or build's) alignment */ +#endif /* struct alignment set */ +#endif /* !defined(NIDL) */ diff --git a/labview/cintools/platdefines.h b/labview/cintools/platdefines.h new file mode 100644 index 00000000..ae8a685a --- /dev/null +++ b/labview/cintools/platdefines.h @@ -0,0 +1,443 @@ +#ifndef _platdefines_H +#define _platdefines_H +/* + (c) Copyright 1990-2020 by National Instruments Corp. + All rights reserved. + + + platdefines.h - Preprocessor definitions that describe various platforms. + + The 5 main defines set up in this file are OpSystem, WindowSystem, + Compiler, ProcessorType and NI_BIG_ENDIAN. The other platform defines are derived + from these main defines and provide convenience for common tests. + + This file should not contain anything but #defines and no // comments. + This is because it is used to preprocess many kinds of files. +*/ + +/* +LabVIEW system options: don't uncomment, the compiler defines these automatically +*/ +/* THINK_C Macintosh */ +/* THINK_CPLUS Macintosh integrated Symantec C++ translator */ +/* macintosh Macintosh mpw 68K compiler */ +/* __powerc Macintosh mpw Power PC compiler */ +/* __WATCOMC__ PC and MS Windows */ +/* WIN32 PC and NT */ +/* unix UNIX */ +/* xwindows X Windows */ +/* sparc SUN Sparc station */ +/* __hpux HP workstation */ +/* __sgi Silicon Graphics */ +/* _AIX AIX */ + +/* Possible values for OpSystem */ + #define kMacOS 1 /* OBSOLETE */ + #define kOpenStep 2 /* OBSOLETE */ + #define kMacOSX 3 + #define kMSWin31 10 /* OBSOLETE */ + #define kMSWin32 11 + #define kMSWin64 12 + #define kLinux 20 + #define kSunOS 21 /* OBSOLETE */ + #define kSolaris 22 /* OBSOLETE */ + #define kHPUX 23 /* OBSOLETE */ + #define kPowerUnix 24 /* OBSOLETE */ + #define kIrix 25 /* OBSOLETE */ + #define kAIX 26 /* OBSOLETE */ + #define kBeOS 27 /* OBSOLETE */ + #define kOSF1 28 /* OBSOLETE */ + #define kVxWorks 29 + #define kPalmOS 30 + #define kLinux64 31 /* OBSOLETE: DO NOT USE: UNUSED AND UNDEFINED: PRESERVED FOR DOCUMENTARY PURPOSES ONLY */ + #define kVdk 32 + #define kRtx 33 + + #undef kLinux64 /* This is unused and has never been properly defined or used. */ + +/* Possible values for WindowSystem */ + #define kMacWM 1 + #define kOpenStepWM 2 /* OBSOLETE */ + #define kMSWin31WM 10 /* OBSOLETE */ + #define kMSWin32WM 11 + #define kXWindows 20 + #define kBeWS 30 /* OBSOLETE */ + #define kPalmWM 40 + #define kNoWS 50 + +/* Possible values for Compiler */ + #define kThinkC 1 /* OBSOLETE */ + #define kSymanCpp 2 /* OBSOLETE */ + #define kMPW 3 /* OBSOLETE */ + #define kMetroWerks 4 + #define kWatcom 10 /* OBSOLETE */ + #define kVisualC 11 + #define kSymanCWin 13 /* OBSOLETE */ + #define kBorlandC 14 /* OBSOLETE */ + #define kGCC 20 + #define kUnbundledC 21 /* OBSOLETE */ + #define kMotorolaCC 22 + #define kSGIC 23 /* OBSOLETE */ + #define kAIXC 24 /* OBSOLETE */ + #define kOSFC 25 /* OBSOLETE */ + #define kDiabC 26 /* OBSOLETE */ + +/* Possible values for ProcessorType */ + #define kM68000 1 /* OBSOLETE */ + #define kX86 2 + #define kSparc 3 + #define kPPC 4 + #define kPARISC 5 + #define kMIPS 6 + #define kDECAlpha 7 /* OBSOLETE */ + #define kPIC 8 + #define kARM 9 + #define kX64 10 + +/* Possible values for Runtime (Mac only)*/ + #define kMachO 1 + #define kCFM 2 /* OBSOLETE */ + +#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(_WIN32_WCE) + /* _WIN32 is defined even if _WIN64 is also defined */ + #ifdef _WIN64 + #define OpSystem kMSWin64 + #else + #define OpSystem kMSWin32 + #endif + #ifndef WindowSystem + #define WindowSystem kMSWin32WM + #endif + #if defined(__MWERKS__) + #define Compiler kMetroWerks + #elif defined(_MSC_VER) || defined(_NI_VC_) + #define Compiler kVisualC + #elif defined(__SC__) || defined(_NI_SC_) + #define Compiler kSymanCWin + #elif defined(__BORLANDC__) || defined(__BCPLUSPLUS__) || defined(_NI_BC_) + #define Compiler kBorlandC + #else + #error "We don't know the Compiler" + #endif + #ifdef _M_PPC + #define ProcessorType kPPC + #elif defined(_M_IX86) + #define ProcessorType kX86 + #elif defined(_M_X64) + #define ProcessorType kX64 + #elif defined(_M_ALPHA) + #define ProcessorType kDECAlpha + #elif Compiler == kBorlandC + #define ProcessorType kX86 + #elif defined(_ARM_) + #define ProcessorType kARM + #else + #error "We don't know the ProcessorType architecture" + #endif + #define NI_BIG_ENDIAN 0 +#elif defined( __PALMOS_H__ ) + #define OpSystem kPalmOS + #ifndef WindowSystem + #define WindowSystem kPalmWM + #endif + #define Compiler kMetroWerks + #define ProcessorType kM68000 + #define NI_BIG_ENDIAN 1 +#elif defined(macintosh) || defined(__PPCC__) || defined(THINK_C) || defined(__SC__) || defined(__MWERKS__) || defined(__APPLE_CC__) + #define OpSystem kMacOSX + #ifndef WindowSystem + #define WindowSystem kMacWM + #endif + #define OLDROUTINENAMES 0 + #define OLDROUTINELOCATIONS 0 + #if defined(__MACH__) + #define Runtime kMachO + #else + #define Runtime kCFM + #endif + #if defined(__MOTO__) + #define Compiler kMotorolaCC + #elif defined(__MWERKS__) + #define Compiler kMetroWerks + #elif defined(__PPCC__) || defined(applec) || defined(__MRC__) + #define Compiler kMPW /* could be one of PPCC, C (MPW's old 68K compiler), or SC, or MrC */ + #elif defined(THINK_C) || defined(__SC__) + #if defined(THINK_CPLUS) + #define Compiler kSymanCpp /* the integrated C++ compiler from TC6 or Sym C 7 */ + #else + #define Compiler kThinkC /* TC 6 or Sym C 7 */ + #endif + #elif defined(__APPLE_CC__) + #define Compiler kGCC + #endif + #if defined(__powerc) || defined(__ppc__) + #define ProcessorType kPPC + #define NI_BIG_ENDIAN 1 + #elif defined(__i386__) + #define ProcessorType kX86 + #define NI_BIG_ENDIAN 0 + #elif defined(__x86_64) + #define ProcessorType kX64 + #define NI_BIG_ENDIAN 0 + #else + #define NI_BIG_ENDIAN 1 + #define ProcessorType kM68000 + #endif +#elif defined(__WATCOMC__) + #define OpSystem kMSWin31 + #ifndef WindowSystem + #define WindowSystem kMSWin31WM + #endif + #define Compiler kWatcom + #define ProcessorType kX86 + #define NI_BIG_ENDIAN 0 +#elif defined(linux) || defined(__linux) || defined(__linux__) + #ifndef WindowSystem + #define WindowSystem kXWindows + #endif + #define OpSystem kLinux + #if defined(__GNUC__) + #define Compiler kGCC + #elif defined(__ASSEMBLER__) + #define Compiler kGAS /* assembly file */ + #else + #error "Unknown Linux compiler" + #endif + #if defined(i386) + #define ProcessorType kX86 + #define NI_BIG_ENDIAN 0 + #elif defined(__alpha) + #define ProcessorType kDECAlpha + #define NI_BIG_ENDIAN 0 + #elif defined(powerpc) + #define ProcessorType kPPC + #define NI_BIG_ENDIAN 1 + #elif defined(sparc) + #define ProcessorType kSparc + #define NI_BIG_ENDIAN 1 + #elif defined(mips) + #define ProcessorType kMIPS + #define NI_BIG_ENDIAN 1 + #elif defined(arm) || defined(__arm__) + #define ProcessorType kARM + #define NI_BIG_ENDIAN 0 + #elif defined(__x86_64__) + #define ProcessorType kX64 + #define NI_BIG_ENDIAN 0 + #else + #error "Unknown Linux platform" + #endif +#elif (defined(__i386) || defined(__i486)) && defined(__svr4__) + #ifndef WindowSystem + #define WindowSystem kXWindows + #endif + #define ProcessorType kX86 + #define OpSystem kSolaris + #ifdef __GNUC__ + #define Compiler kGCC + #else + #define Compiler kUnbundledC + #endif + #define NI_BIG_ENDIAN 0 +#elif sparc || __sparc + #ifndef WindowSystem + #define WindowSystem kXWindows + #endif + #define ProcessorType kSparc + #ifdef __SVR4 + #define OpSystem kSolaris + #else + #define OpSystem kSunOS + #endif + #ifdef __GNUC__ + #define Compiler kGCC + #else + #define Compiler kUnbundledC + #endif + #define NI_BIG_ENDIAN 1 +#elif defined(__alpha) + #define ProcessorType kDECAlpha + #define NI_BIG_ENDIAN 0 + #if defined(__osf__) + #ifndef WindowSystem + #define WindowSystem kXWindows + #endif + #define OpSystem kOSF1 + #ifdef __GNUC__ + #define Compiler kGCC + #else + #define Compiler kOSFC + #endif + #elif defined(linux) + #ifndef WindowSystem + #define WindowSystem kXWindows + #endif + #define Compiler kGCC + #endif +#elif defined(__hpux) + #ifndef WindowSystem + #define WindowSystem kXWindows + #endif + #define ProcessorType kPARISC + #define OpSystem kHPUX + #ifdef __GNUC__ + #define Compiler kGCC + #else + #define Compiler kUnbundledC + #endif + #define NI_BIG_ENDIAN 1 +#elif defined(__HC__) + #define OpSystem kPowerUnix + #ifndef WindowSystem + #define WindowSystem kXWindows + #endif + #define Compiler kUnbundledC + #define ProcessorType kPPC + #define NI_BIG_ENDIAN 1 +#elif defined(__sgi) + #define OpSystem kIrix + #ifndef WindowSystem + #define WindowSystem kXWindows + #endif + #define Compiler kSGIC + #define ProcessorType kMIPS + #define NI_BIG_ENDIAN 1 +#elif defined(_AIX) + #define OpSystem kAIX + #ifndef WindowSystem + #define WindowSystem kXWindows + #endif + #define Compiler kAIXC + #define ProcessorType kPPC + #define NI_BIG_ENDIAN 1 +#elif defined(VXWORKS_PPC) + #define OpSystem kVxWorks + #ifndef WindowSystem + #define WindowSystem kNoWS + #endif + #define ProcessorType kPPC + #define NI_BIG_ENDIAN 1 +#if defined(__GNUC__) + #define Compiler kGCC +#else + #define Compiler kDiabC /* until I find a good constant to check rdt */ +#endif +#elif defined(VXWORKS_X86) + #define OpSystem kVxWorks + #ifndef WindowSystem + #define WindowSystem kNoWS + #endif + #define ProcessorType kX86 + #define NI_BIG_ENDIAN 0 + #define Compiler kGCC +#elif defined(__vdk) + #define OpSystem kVdk + #ifndef WindowSystem + #define WindowSystem kNoWS + #endif + #define Compiler kUnbundledC + #define ProcessorType kX86 + #define BigEndian 0 + #define PointerSize k32bitPointer +#elif defined(__RTX) + #define OpSystem kRtx + #ifndef WindowSystem + #define WindowSystem kNoWS + #endif + #define Compiler kUnbundledC + #define ProcessorType kARM + #define BigEndian 0 + #define PointerSize k32bitPointer +#endif + +#if !defined(OpSystem) || !defined(WindowSystem) || !defined(Compiler) || !defined(ProcessorType) + #error +#endif + +/* + This is to fix a problem where Apple headers in xcode3.0 (maybe later) + have a parameter to some functions called 'Mac' which gets replaced by + the preprocessor because of the below. We include Carbon.h here to get + those functions declared before the macro. However, there are some cases + where we cannot include Carbon.h, assembly files and nidl files. In those + cases, #define _Cannot_Include_Carbon_ 1 before including platdefines.h. +*/ +#if __APPLE__ && !(_Cannot_Include_Carbon_) && !(TARGET_OS_IPHONE)/* && !defined(__x86_64__) && !defined(__x86_64) */ + #include +#endif +/* Other defines for convenience. */ + +#define Unix (((OpSystem>=kLinux) && (OpSystem<=kVxWorks))) +#define MSWin ((OpSystem>=kMSWin31) && (OpSystem<=kMSWin64)) +#define Mac (OpSystem==kMacOS || OpSystem==kMacOSX) +#define MacOSX (OpSystem==kMacOSX) +#define MacOSXCFM (OpSystem==kMacOSX && Runtime==kCFM) /* OBSOLETE */ +#define MacOSXMachO (OpSystem==kMacOSX && Runtime==kMachO) +#define MacXPPC (OpSystem==kMacOSX && ProcessorType==kPPC) /* OBSOLETE */ +#define MacX86 (OpSystem==kMacOSX && ProcessorType==kX86) +#define MacX64 (OpSystem==kMacOSX && ProcessorType==kX64) +#define MacCocoa MacX64 +#define XWindows (WindowSystem==kXWindows) +#define Palm (Compiler==kMetroWerks && OpSystem==kPalmOS) +#define MWerksPPC (Compiler==kMetroWerks && ProcessorType==kPPC) +#define Sparc (ProcessorType==kSparc) +#define Linux (OpSystem==kLinux) +#define PowerPC (ProcessorType==kPPC) +#define SVR4 (OpSystem==kSolaris) +#define VxWorks (OpSystem==kVxWorks) +#define Vdk (OpSystem==kVdk) +#define Rtx (OpSystem==kRtx) +#define NoWS (WindowSystem==kNoWS) + +/* defines for what type of threading is available */ +#define kNoThreads 0 +#define kMSWin32Threads 1 +#define kUIThreads 2 +#define kPosixThreads 3 +#define kVxWorksThreads 4 +#define kVdkThreads 6 +#define kRtxThreads 7 + + +#if MSWin + #define ThreadKind kMSWin32Threads +#elif OpSystem==kLinux + #define ThreadKind kPosixThreads +#elif OpSystem==kVxWorks + #define ThreadKind kVxWorksThreads +#elif Mac + #define ThreadKind kPosixThreads +#elif OpSystem==kVdk + #define ThreadKind kVdkThreads +#elif Rtx + #define ThreadKind kRtxThreads +#else + #define ThreadKind kNoThreads +#endif + +#define IsOpSystem64Bit ((OpSystem==kMSWin64) || MacX64 || __x86_64__ || __x86_64 || __LP64__) + +#if defined(_WIN32_WCE) + #define WinCE 1 +#else + #define WinCE 0 +#endif + +/* This should move to a LabVIEW header GR 1-13-00 ??? */ +#if (ProcessorType==kX86 || ProcessorType==kX64) + #define FPUASM 1 +#else + #define FPUASM 0 +#endif + +#if (ProcessorType==kX86) || (ProcessorType==kM68000) || (ProcessorType==kX64) + #define UseGetSetIntMacros 1 +#else + #define UseGetSetIntMacros 0 +#endif + +#define CompilerSupportsCPlusPlus11 (__cplusplus >= 201103L || _MSVC_LANG >= 201103L) +#define CompilerSupportsCPlusPlus14 (__cplusplus >= 201402L || _MSVC_LANG >= 201402L) +#define CompilerSupportsCPlusPlus17 (__cplusplus >= 201703L || _MSVC_LANG >= 201703L) + +#endif /* _platdefines_H */ diff --git a/labview/cintools/unknwn.h b/labview/cintools/unknwn.h new file mode 100644 index 00000000..2ff4774d --- /dev/null +++ b/labview/cintools/unknwn.h @@ -0,0 +1,92 @@ +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ +#ifndef __unknwn_h__ +#define __unknwn_h__ + +#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(NI_DSC_WIN32) +#define NIDL_STDMETHODCALLTYPE __stdcall +#else // WIN32 +#define NIDL_STDMETHODCALLTYPE +#endif // WIN32 + +#ifndef NIDL_EXTERN_C +#ifdef __cplusplus +#define NIDL_EXTERN_C extern "C" +#else // __cplusplus +#define NIDL_EXTERN_C +#endif // __cplusplus +#endif // NIDL_EXTERN_C + +#ifndef NIDL_INTERFACE +#if defined(WIN32) || (defined(PHARLAP) && PHARLAP) +#define NIDL_INTERFACE(x) struct __declspec(uuid(x)) +#else // WIN32 +#define NIDL_INTERFACE(x) struct +#endif // WIN32 +#endif // NIDL_INTERFACE +/* Forward Declarations */ + +#ifndef __IUnknown_FWD_DEFINED__ +#define __IUnknown_FWD_DEFINED__ +typedef struct IUnknown IUnknown; +#endif /* __IUnknown_FWD_DEFINED__ */ + +#ifndef __IClassFactory_FWD_DEFINED__ +#define __IClassFactory_FWD_DEFINED__ +typedef struct IClassFactory IClassFactory; +#endif /* __IClassFactory_FWD_DEFINED__ */ + + +/* Header files for imported files */ + +#include "wtypes.h" + +/* Declarations */ + +#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(NI_DSC_WIN32) + +#error "You should not be including this file on Windows!!!" + +#else // defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(NI_DSC_WIN32) + +/* Generated header for interface IUnknown */ + +typedef IUnknown* LPUNKNOWN; +NIDL_EXTERN_C const IID IID_IUnknown; + +/* {00000000-0000-0000-c000-000000000046} */ +NIDL_INTERFACE("00000000-0000-0000-c000-000000000046") IUnknown +{ +public: + virtual HRESULT NIDL_STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void** ppvObject) = 0; + virtual ULONG NIDL_STDMETHODCALLTYPE AddRef(void) = 0; + virtual ULONG NIDL_STDMETHODCALLTYPE Release(void) = 0; +} ; + +/* Generated header for interface IClassFactory */ + +typedef IClassFactory* LPCLASSFACTORY; +NIDL_EXTERN_C const IID IID_IClassFactory; + +/* {00000001-0000-0000-c000-000000000046} */ +NIDL_INTERFACE("00000001-0000-0000-c000-000000000046") IClassFactory : public IUnknown +{ +public: + virtual HRESULT NIDL_STDMETHODCALLTYPE CreateInstance( + IUnknown* pUnkOuter, + REFIID riid, + void** ppvObject) = 0; + virtual HRESULT NIDL_STDMETHODCALLTYPE RemoteCreateInstance( + REFIID riid, + IUnknown** ppvObject) = 0; + virtual HRESULT NIDL_STDMETHODCALLTYPE LockServer( + BOOL fLock) = 0; + virtual HRESULT NIDL_STDMETHODCALLTYPE RemoteLockServer( + BOOL fLock) = 0; +} ; + +#endif // defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(NI_DSC_WIN32) + + +#endif /* __unknwn_h__ */ diff --git a/labview/cintools/unknwn_i.c b/labview/cintools/unknwn_i.c new file mode 100644 index 00000000..7862deeb --- /dev/null +++ b/labview/cintools/unknwn_i.c @@ -0,0 +1,43 @@ +/* this file contains the actual definitions of */ +/* the IIDs and CLSIDs */ + +/* link this file in with the server and any clients */ + + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __IID_DEFINED__ +#define __IID_DEFINED__ + +typedef struct _IID +{ +#if __GNUC__ && __x86_64__ + unsigned int x; +#else + unsigned long x; +#endif // gcc-64 + unsigned short s1; + unsigned short s2; + unsigned char c[8]; +} IID; + +#endif // __IID_DEFINED__ + +#ifndef CLSID_DEFINED +#define CLSID_DEFINED +typedef IID CLSID; +#endif // CLSID_DEFINED + + +const IID IID_IUnknown = {0x00000000,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}}; + + +const IID IID_IClassFactory = {0x00000001,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}}; + + +#ifdef __cplusplus +} +#endif diff --git a/labview/cintools/wtypes.h b/labview/cintools/wtypes.h new file mode 100644 index 00000000..5ab79a69 --- /dev/null +++ b/labview/cintools/wtypes.h @@ -0,0 +1,495 @@ +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ +#ifndef __wtypes_h__ +#define __wtypes_h__ + +#ifndef NIDL_EXTERN_C +#ifdef __cplusplus +#define NIDL_EXTERN_C extern "C" +#else // __cplusplus +#define NIDL_EXTERN_C +#endif // __cplusplus +#endif // NIDL_EXTERN_C + +#ifndef NIDL_INTERFACE +#if defined(WIN32) || (defined(PHARLAP) && PHARLAP) +#define NIDL_INTERFACE(x) struct __declspec(uuid(x)) +#else // WIN32 +#define NIDL_INTERFACE(x) struct +#endif // WIN32 +#endif // NIDL_INTERFACE +/* Forward Declarations */ + +/* Header files for imported files */ + +/* Declarations */ + +#if defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(NI_DSC_WIN32) + +#error "You should not be including this file on Windows!!!" + +#else // defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(NI_DSC_WIN32) + +#if defined(__OBJC__) +#include +#endif +#ifndef FALSE +#define FALSE 0 +#define TRUE 1 +#endif // !FALSE +#ifndef _BYTE_DEFINED +#define _BYTE_DEFINED +typedef unsigned char BYTE; + +#endif // !_BYTE_DEFINED +#ifndef _WORD_DEFINED +#define _WORD_DEFINED +typedef unsigned short WORD; + +#endif // !_WORD_DEFINED +#ifndef _UINT_DEFINED +#define _UINT_DEFINED +typedef unsigned int UINT; + +#endif // _UINT_DEFINED +#ifndef _INT_DEFINED +#define _INT_DEFINED +typedef int INT; + +#endif // _INT_DEFINED +#if defined(NI_DSC_UNIX_VXWORKS) || defined(VXWORKS_PPC) +#ifndef _BOOL_DEFINED +#define _BOOL_DEFINED +typedef int BOOL; + +#endif // _BOOL_DEFINED +#else +#if !defined(_BOOL_DEFINED) && !defined(__OBJC__) +#define _BOOL_DEFINED +#if __GNUC__ && __x86_64__ +typedef int BOOL; +#else +typedef long BOOL; + +#endif // gnuc-64 +#endif // _BOOL_DEFINED +#endif // defined(NI_DSC_UNIX_VXWORKS) || defined(VXWORKS_PPC) +#ifndef _LONG_DEFINED +#define _LONG_DEFINED +#if __GNUC__ && __x86_64__ +typedef int LONG; +#else +typedef long LONG; + +#endif // gnu-64 +typedef long LONG_PTR; + +#endif // !_LONG_DEFINED +#ifndef _DWORD_DEFINED + // This must define both DWORD and DWORD_PTR to be consistent with other places this is done + #define _DWORD_DEFINED + #if __GNUC__ && __x86_64__ + typedef unsigned int DWORD; + #else +typedef unsigned long DWORD; + +#endif // gnuc-64 +typedef unsigned long DWORD_PTR; + +#endif // !_DWORD_DEFINED +#if defined(NI_DSC_UNIX_VXWORKS) || defined(VXWORKS_PPC) +#define _NI_WINDOWS_HANDLE 1 +#endif // defined(NI_DSC_UNIX_VXWORKS) || defined(VXWORKS_PPC) +#ifndef _HANDLE_DEFINED +#define _HANDLE_DEFINED +typedef void* HANDLE; + +#endif // _HANDLE_DEFINED +typedef void* HMODULE; + +typedef void* HINSTANCE; + +typedef void* HRGN; + +typedef void* HTASK; + +typedef void* HKEY; + +typedef void* HGLOBAL; + +typedef void* HDESK; + +typedef void* HMF; + +typedef void* HEMF; + +typedef void* HPEN; + +typedef void* HRSRC; + +typedef void* HSTR; + +typedef void* HWINSTA; + +typedef void* HKL; + +typedef void* HGDIOBJ; + +typedef HANDLE HDWP; + +typedef WORD CLIPFORMAT; + +#ifndef _LPWORD_DEFINED +#define _LPWORD_DEFINED +typedef WORD* LPWORD; + +#endif // !_LPWORD_DEFINED +#ifndef _LPDWORD_DEFINED +#define _LPDWORD_DEFINED +typedef DWORD* LPDWORD; + +#endif // !_LPDWORD_DEFINED +#ifndef _CHAR_DEFINED +#define _CHAR_DEFINED +typedef char CHAR; + +#endif // _CHAR_DEFINED +typedef CHAR* LPSTR; + +typedef const CHAR* LPCSTR; + +#ifndef _WCHAR_DEFINED +#define _WCHAR_DEFINED +typedef wchar_t WCHAR; + +typedef WCHAR TCHAR; + +#endif // !_WCHAR_DEFINED +typedef WCHAR* LPWSTR; + +typedef TCHAR* LPTSTR; + +typedef const WCHAR* LPCWSTR; + +typedef const TCHAR* LPCTSTR; + +typedef HANDLE* LPHANDLE; + +#ifndef _OLECHAR_DEFINED +#define _OLECHAR_DEFINED +typedef WCHAR OLECHAR; + +typedef OLECHAR* LPOLESTR; + +typedef const OLECHAR* LPCOLESTR; + +#define OLESTR(str) L##str +#endif // _OLECHAR_DEFINED +typedef unsigned char UCHAR; + +typedef short SHORT; + +typedef unsigned short USHORT; + +typedef DWORD ULONG; + +typedef DWORD_PTR ULONG_PTR; + +typedef double DOUBLE; + +#ifndef _DWORDLONG_ +typedef unsigned long long DWORDLONG; + +typedef DWORDLONG* PDWORDLONG; + +#endif // !_DWORDLONG_ +#ifndef _ULONGLONG_ +typedef long long LONGLONG; + +typedef unsigned long long ULONGLONG; + +typedef LONGLONG* PLONGLONG; + +typedef ULONGLONG* PULONGLONG; + +#endif // _ULONGLONG_ +typedef union _LARGE_INTEGER { + struct { + DWORD LowPart; + LONG HighPart; + } ; + LONGLONG QuadPart; +} LARGE_INTEGER; + +typedef LARGE_INTEGER* PLARGE_INTEGER; + +typedef union _ULARGE_INTEGER { + struct { + DWORD LowPart; + DWORD HighPart; + } ; + ULONGLONG QuadPart; +} ULARGE_INTEGER; + +#ifndef _FILETIME_ +#define _FILETIME_ +typedef struct _FILETIME { + DWORD dwLowDateTime; + DWORD dwHighDateTime; +} FILETIME; + +#endif // !_FILETIME +#ifndef _SYSTEMTIME_ +#define _SYSTEMTIME_ +typedef struct _SYSTEMTIME { + WORD wYear; + WORD wMonth; + WORD wDayOfWeek; + WORD wDay; + WORD wHour; + WORD wMinute; + WORD wSecond; + WORD wMilliseconds; +} SYSTEMTIME; + +#endif // !_SYSTEMTIME +#ifndef _NI_HRESULT_DEFINED_ +#define _NI_HRESULT_DEFINED_ +typedef LONG HRESULT; + +typedef LONG SCODE; + +#endif // !_NI_HRESULT_DEFINED_ +typedef SCODE* PSCODE; + +#ifndef GUID_DEFINED +#define GUID_DEFINED +typedef struct _GUID { + DWORD Data1; + WORD Data2; + WORD Data3; + BYTE Data4[8]; +} GUID; + +#endif // !GUID_DEFINED +#if !defined( __LPGUID_DEFINED__ ) +#define __LPGUID_DEFINED__ +typedef GUID* LPGUID; + +#endif // !__LPGUID_DEFINED__ +#if !defined( __IID_DEFINED__ ) +#define __IID_DEFINED__ +typedef GUID IID; + +typedef IID* LPIID; + +#define IID_NULL GUID_NULL +#define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2) +typedef GUID CLSID; + +typedef CLSID* LPCLSID; + +#define CLSID_NULL GUID_NULL +#define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2) +typedef GUID FMTID; + +typedef FMTID* LPFMTID; + +#define FMTID_NULL GUID_NULL +#define IsEqualFMTID(rfmtid1, rfmtid2) IsEqualGUID(rfmtid1, rfmtid2) +#ifndef _REFGUID_DEFINED +#define _REFGUID_DEFINED +#define REFGUID const GUID & +#endif // !_REFGUID_DEFINED +#ifndef _REFIID_DEFINED +#define _REFIID_DEFINED +#define REFIID const IID & +#endif // !_REFIID_DEFINED +#ifndef _REFCLSID_DEFINED +#define _REFCLSID_DEFINED +#define REFCLSID const CLSID & +#endif // !_REFCLSID_DEFINED +#endif // !__IID_DEFINED__ +#ifndef _LCID_DEFINED +#define _LCID_DEFINED +typedef DWORD LCID; + +#endif // !_LCID_DEFINED +typedef void* HICON; + +typedef void* HWND; + +#ifndef _HCURSOR_DEFINED +#define _HCURSOR_DEFINED +typedef HICON HCURSOR; + +#endif // !_HCURSOR_DEFINED +#if !defined(EXTERN_C) +#if defined(__cplusplus) +#define EXTERN_C extern "C" +#else // __cplusplus +#define EXTERN_C +#endif // __cplusplus +#endif // EXTERN_C +#define WINAPI +#define STDAPICALLTYPE +#define CDECL +#ifndef TYPENAME +#define TYPENAME typename +#endif // TYPENAME +#define STDAPI EXTERN_C HRESULT STDAPICALLTYPE +#ifndef _BSTR_DEFINED +#define _BSTR_DEFINED +typedef OLECHAR* BSTR; + +typedef BSTR* LPBSTR; + +#endif // _BSTR_DEFINED +/* 0 == FALSE, -1 == TRUE */ +typedef short VARIANT_BOOL; + +/* ANSI C/C++ reserve bool as keyword */ +#define _VARIANT_BOOL /##/ +#define VARIANT_TRUE ((VARIANT_BOOL)0xffff) +#define VARIANT_FALSE ((VARIANT_BOOL)0) +typedef unsigned short VARTYPE; + +/* + * VARENUM usage key, + * + * * [V] - may appear in a VARIANT + * * [T] - may appear in a TYPEDESC + * * [P] - may appear in an OLE property set + * * [S] - may appear in a Safe Array + * + * + * VT_EMPTY [V] [P] nothing + * VT_NULL [V] [P] SQL style Null + * VT_I2 [V][T][P][S] 2 byte signed int + * VT_I4 [V][T][P][S] 4 byte signed int + * VT_R4 [V][T][P][S] 4 byte real + * VT_R8 [V][T][P][S] 8 byte real + * VT_CY [V][T][P][S] currency + * VT_DATE [V][T][P][S] date + * VT_BSTR [V][T][P][S] OLE Automation string + * VT_DISPATCH [V][T][P][S] IDispatch * + * VT_ERROR [V][T][P][S] SCODE + * VT_BOOL [V][T][P][S] True=-1, False=0 + * VT_VARIANT [V][T][P][S] VARIANT * + * VT_UNKNOWN [V][T] [S] IUnknown * + * VT_DECIMAL [V][T] [S] 16 byte fixed point + * VT_RECORD [V] [P][S] user defined type + * VT_I1 [V][T][P][s] signed char + * VT_UI1 [V][T][P][S] unsigned char + * VT_UI2 [V][T][P][S] unsigned short + * VT_UI4 [V][T][P][S] unsigned short + * VT_I8 [T][P] signed 64-bit int + * VT_UI8 [T][P] unsigned 64-bit int + * VT_INT [V][T][P][S] signed machine int + * VT_UINT [V][T] [S] unsigned machine int + * VT_VOID [T] C style void + * VT_HRESULT [T] Standard return type + * VT_PTR [T] pointer type + * VT_SAFEARRAY [T] (use VT_ARRAY in VARIANT) + * VT_CARRAY [T] C style array + * VT_USERDEFINED [T] user defined type + * VT_LPSTR [T][P] null terminated string + * VT_LPWSTR [T][P] wide null terminated string + * VT_FILETIME [P] FILETIME + * VT_BLOB [P] Length prefixed bytes + * VT_STREAM [P] Name of the stream follows + * VT_STORAGE [P] Name of the storage follows + * VT_STREAMED_OBJECT [P] Stream contains an object + * VT_STORED_OBJECT [P] Storage contains an object + * VT_BLOB_OBJECT [P] Blob contains an object + * VT_CF [P] Clipboard format + * VT_CLSID [P] A Class ID + * VT_VECTOR [P] simple counted array + * VT_ARRAY [V] SAFEARRAY* + * VT_BYREF [V] void* for local use + * VT_BSTR_BLOB Reserved for system use + */ +typedef enum VARENUM { + VT_EMPTY = 0, + VT_NULL = 1, + VT_I2 = 2, + VT_I4 = 3, + VT_R4 = 4, + VT_R8 = 5, + VT_CY = 6, + VT_DATE = 7, + VT_BSTR = 8, + VT_DISPATCH = 9, + VT_ERROR = 10, + VT_BOOL = 11, + VT_VARIANT = 12, + VT_UNKNOWN = 13, + VT_DECIMAL = 14, + VT_I1 = 16, + VT_UI1 = 17, + VT_UI2 = 18, + VT_UI4 = 19, + VT_I8 = 20, + VT_UI8 = 21, + VT_INT = 22, + VT_UINT = 23, + VT_VOID = 24, + VT_HRESULT = 25, + VT_PTR = 26, + VT_SAFEARRAY = 27, + VT_CARRAY = 28, + VT_USERDEFINED = 29, + VT_LPSTR = 30, + VT_LPWSTR = 31, + VT_RECORD = 36, + VT_FILETIME = 64, + VT_BLOB = 65, + VT_STREAM = 66, + VT_STORAGE = 67, + VT_STREAMED_OBJECT = 68, + VT_STORED_OBJECT = 69, + VT_BLOB_OBJECT = 70, + VT_CF = 71, + VT_CLSID = 72, + VT_BSTR_BLOB = 4095, + VT_VECTOR = 4096, + VT_ARRAY = 8192, + VT_BYREF = 16384, + VT_RESERVED = 32768, + VT_ILLEGAL = 65535, + VT_ILLEGALMASKED = 4095, + VT_TYPEMASK = 4095, +} VARENUM; + +#endif // defined(_WIN32) || defined(WIN32) || defined(__WIN32__) || defined(NI_DSC_WIN32) +#ifdef __cplusplus + extern "C++" { + namespace _wtypes { + template struct StaticAssertionFailure; + template <> struct StaticAssertionFailure{}; + template struct StaticAssertTest{}; + } + #define _WTYPES_STATIC_ASSERT(condition) \ + typedef ::_wtypes::StaticAssertTest)> \ + _WTYPES_STATIC_ASSERT_JOIN(_wtypes_StaticAssertTypedef_,__LINE__) + #define _WTYPES_STATIC_ASSERT_JOIN( X, Y ) _WTYPES_DO_STATIC_ASSERT_JOIN( X, Y ) + #define _WTYPES_DO_STATIC_ASSERT_JOIN( X, Y ) X##Y + #define _BITS__WTYPES_ /8 + +#if !defined(__OBJC__) + _WTYPES_STATIC_ASSERT( sizeof(BOOL) == 32 _BITS__WTYPES_); +#endif + + _WTYPES_STATIC_ASSERT( sizeof(DWORD) == 32 _BITS__WTYPES_); + _WTYPES_STATIC_ASSERT( sizeof(LONGLONG) == 64 _BITS__WTYPES_); + _WTYPES_STATIC_ASSERT( sizeof(ULONGLONG) == 64 _BITS__WTYPES_); + _WTYPES_STATIC_ASSERT( sizeof(LARGE_INTEGER) == 64 _BITS__WTYPES_); + _WTYPES_STATIC_ASSERT( sizeof(ULARGE_INTEGER) == 64 _BITS__WTYPES_); + #undef _BITS__WTYPES_ + #undef _WTYPES_DO_STATIC_ASSERT_JOIN + #undef _WTYPES_STATIC_ASSERT_JOIN + #undef _WTYPES_STATIC_ASSERT + } +#endif // __cplusplus + + +#endif /* __wtypes_h__ */ diff --git a/labview/cintools/wtypes_i.c b/labview/cintools/wtypes_i.c new file mode 100644 index 00000000..8a68f7c0 --- /dev/null +++ b/labview/cintools/wtypes_i.c @@ -0,0 +1,37 @@ +/* this file contains the actual definitions of */ +/* the IIDs and CLSIDs */ + +/* link this file in with the server and any clients */ + + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __IID_DEFINED__ +#define __IID_DEFINED__ + +typedef struct _IID +{ +#if __GNUC__ && __x86_64__ + unsigned int x; +#else + unsigned long x; +#endif // gcc-64 + unsigned short s1; + unsigned short s2; + unsigned char c[8]; +} IID; + +#endif // __IID_DEFINED__ + +#ifndef CLSID_DEFINED +#define CLSID_DEFINED +typedef IID CLSID; +#endif // CLSID_DEFINED + + +#ifdef __cplusplus +} +#endif diff --git a/labview/labview_rabbitmq.c b/labview/labview_rabbitmq.c new file mode 100644 index 00000000..359f3683 --- /dev/null +++ b/labview/labview_rabbitmq.c @@ -0,0 +1,275 @@ +#include +#include +#include +#include +#include "utils.h" +#include "extcode.h" +#include "labview_rabbitmq.h" +#include +#include +#include + + +MgErr copyStringToLStrHandle(char* cpString, LStrHandle LVString) +{ + int32 len = strlen(cpString); + MgErr err = NumericArrayResize(uB, 1, (UHandle*)&LVString, len); + if (!err) + { + strncpy((*LVString)->str, cpString, len); // copying the string into the handle + (*LVString)->cnt = len; // telling the Handle what string size to expect + } + return err; +} + +MgErr copyBufferToLStrHandle(const void* buffer, int len, LStrHandle LVString) +{ + + MgErr err = NumericArrayResize(uB, 1, (UHandle*)&LVString, len); + if (!err) + { + memcpy((*LVString)->str, buffer, len); // copying the string into the handle + (*LVString)->cnt = len; // telling the Handle what string size to expect + } + return err; +} + +LABVIEW_PUBLIC_FUNCTION +char* lv_rabbitmq_version(void) { + char* VERSION = "0.0.1"; + return VERSION; +} + +/* This function is a modified version of the `die_on_amqp_error` function used in examples, +enhanced with LabVIEW string support.*/ +int lv_report_amqp_error(amqp_rpc_reply_t x, char const *context, LStrHandle error_description) { + unsigned char temp_str[MAX_ERROR_DESCRIPTION_LENGTH]; + int err; + switch (x.reply_type) { + case AMQP_RESPONSE_NORMAL: + return _AMQP_RESPONSE_NORMAL; + + case AMQP_RESPONSE_NONE: + snprintf(temp_str, MAX_ERROR_DESCRIPTION_LENGTH, "%s: missing RPC reply type!", context); + err = copyStringToLStrHandle(temp_str, error_description); + if (err){ + return err; + } + return _AMQP_RESPONSE_NONE; + + case AMQP_RESPONSE_LIBRARY_EXCEPTION: + snprintf(temp_str, MAX_ERROR_DESCRIPTION_LENGTH, "%s: %s ", context, amqp_error_string2(x.library_error)); + err = copyStringToLStrHandle(temp_str, error_description); + if (err){ + return err; + } + return _AMQP_RESPONSE_LIBRARY_EXCEPTION; + + case AMQP_RESPONSE_SERVER_EXCEPTION: + switch (x.reply.id) { + case AMQP_CONNECTION_CLOSE_METHOD: { + amqp_connection_close_t *m = + (amqp_connection_close_t *)x.reply.decoded; + snprintf(temp_str, MAX_ERROR_DESCRIPTION_LENGTH, "%s: server connection error %uh, message: %.*s ", + context, m->reply_code, (int)m->reply_text.len, + (char *)m->reply_text.bytes); + err = copyStringToLStrHandle(temp_str, error_description); + if (err){ + return err; + } + return _AMQP_RESPONSE_SERVER_EXCEPTION; + } + case AMQP_CHANNEL_CLOSE_METHOD: { + amqp_channel_close_t *m = (amqp_channel_close_t *)x.reply.decoded; + snprintf(temp_str, MAX_ERROR_DESCRIPTION_LENGTH, "%s: server channel error %uh, message: %.*s ", + context, m->reply_code, (int)m->reply_text.len, + (char *)m->reply_text.bytes); + err = copyStringToLStrHandle(temp_str, error_description); + if (err){ + return err; + } + return _AMQP_RESPONSE_SERVER_EXCEPTION; + } + default: + snprintf(temp_str, MAX_ERROR_DESCRIPTION_LENGTH, "%s: unknown server error, method id 0x%08X ", + context, x.reply.id); + err = copyStringToLStrHandle(temp_str, error_description); + if (err){ + return err; + } + return _AMQP_RESPONSE_SERVER_EXCEPTION; + } + break; + } +} + + +LABVIEW_PUBLIC_FUNCTION +int64_t lv_amqp_new_connection() { + // conn is an opaque struct pointer + amqp_connection_state_t conn = amqp_new_connection(); + // cast to int64_t so LabVIEW will receive it as + // a 64-bit integer transfered by value + int64_t conn_intptr = (int64_t)conn; + return conn_intptr; +} + + +LABVIEW_PUBLIC_FUNCTION +int lv_amqp_close_connection(int64_t conn_intptr, LStrHandle error_description) { + // cast back to amqp_connection_state_t opaque struct pointer + amqp_connection_state_t conn = (amqp_connection_state_t)conn_intptr; + return lv_report_amqp_error(amqp_connection_close(conn, AMQP_REPLY_SUCCESS),"Connection close", error_description); +} + + +LABVIEW_PUBLIC_FUNCTION +void lv_amqp_destroy_connection(int64_t conn_intptr) { + amqp_connection_state_t conn = (amqp_connection_state_t)conn_intptr; + amqp_destroy_connection(conn); +} + + +LABVIEW_PUBLIC_FUNCTION +int lv_amqp_channel_open(int64_t conn_intptr, uint16_t channel, LStrHandle error_description) { + amqp_connection_state_t conn = (amqp_connection_state_t)conn_intptr; + amqp_channel_open(conn, channel); + return lv_report_amqp_error(amqp_get_rpc_reply(conn), "Opening channel", error_description); +} + + +LABVIEW_PUBLIC_FUNCTION +int lv_amqp_channel_close(int64_t conn_intptr, uint16_t channel, LStrHandle error_description) { + amqp_connection_state_t conn = (amqp_connection_state_t)conn_intptr; + return lv_report_amqp_error(amqp_channel_close(conn, channel, AMQP_REPLY_SUCCESS), "Closing channel", error_description); +} + + +LABVIEW_PUBLIC_FUNCTION +int lv_amqp_exchange_declare(int64_t conn_intptr, uint16_t channel, char *exchange, char *exchangetype, LStrHandle error_description) { + amqp_connection_state_t conn = (amqp_connection_state_t)conn_intptr; + + amqp_boolean_t PASSIVE = 0; + amqp_boolean_t DURABLE = 0; + amqp_boolean_t AUTO_DELETE = 0; + amqp_boolean_t INTERNAL = 0; + amqp_exchange_declare(conn, channel, amqp_cstring_bytes(exchange), + amqp_cstring_bytes(exchangetype), PASSIVE, DURABLE, AUTO_DELETE, INTERNAL, + amqp_empty_table); + + return lv_report_amqp_error(amqp_get_rpc_reply(conn), "Exchange declare", error_description); +} + + +LABVIEW_PUBLIC_FUNCTION +int lv_amqp_login(int64_t conn_intptr, char *host, int port, int timeout_sec, char *username, char *password, LStrHandle error_description) { + + int status; + amqp_socket_t *socket = NULL; + amqp_connection_state_t conn = (amqp_connection_state_t)conn_intptr; + + struct timeval tval; + tval.tv_sec = timeout_sec; + tval.tv_usec = 0; + + socket = amqp_tcp_socket_new(conn); + if (!socket) { + return _CREATING_TCP_SOCKET; + } + status = amqp_socket_open_noblock(socket, host, port, &tval); + if (status<0) { + return _OPENING_TCP_SOCKET; + } + /*Code explanation: + socket is set/stored in the connection state, + so we dont need to destroy this socket because + it will be destroyed along with connection state destroy function*/ + + char const *VHOST = "/"; // the virtual host to connect to on the broker. The default on most brokers is "/" + int const CHANNEL_MAX = 0; // the limit for number of channels for the connection. 0 means no limit. + int const FRAME_MAX = 131072; // the maximum size of an AMQP frame. 131072 is the default. + // 4096 is the minimum size, 2^31-1 is the maximum, a good default is 131072 (128KB), + int const HEARTBEAT = 0; // the number of seconds between heartbeat frames to request of the broker. A value of 0 disables heartbeats. + + return lv_report_amqp_error(amqp_login(conn, VHOST, CHANNEL_MAX, FRAME_MAX, HEARTBEAT, AMQP_SASL_METHOD_PLAIN, username, password), "Logging in", error_description); +} + + +LABVIEW_PUBLIC_FUNCTION +int lv_amqp_basic_publish(int64_t conn_intptr, uint16_t channel, char *exchange, char *routingkey, char *messagebody, LStrHandle error_description) { + amqp_connection_state_t conn = (amqp_connection_state_t)conn_intptr; + amqp_basic_properties_t props; + props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | AMQP_BASIC_DELIVERY_MODE_FLAG; + props.content_type = amqp_cstring_bytes("text/plain"); + props.delivery_mode = 2; /* persistent delivery mode */ + return amqp_basic_publish(conn, channel, amqp_cstring_bytes(exchange),amqp_cstring_bytes(routingkey), 0, 0, &props, amqp_cstring_bytes(messagebody)); + //this function returns amqp_status_enum thats different from amqp_rpc_reply_t +} + + +LABVIEW_PUBLIC_FUNCTION +int lv_amqp_create_queue(int64_t conn_intptr, uint16_t channel, char *exchange, char *bindingkey, LStrHandle error_description) { + amqp_connection_state_t conn = (amqp_connection_state_t)conn_intptr; + int status; + amqp_bytes_t queuename; + + amqp_boolean_t PASSIVE = 0; + amqp_boolean_t DURABLE = 0; + amqp_boolean_t EXCLUSIVE = 0; + amqp_boolean_t AUTO_DELETE = 1; + amqp_queue_declare_ok_t *r = amqp_queue_declare(conn, channel, amqp_empty_bytes, PASSIVE, DURABLE, EXCLUSIVE, AUTO_DELETE, amqp_empty_table); + + status = lv_report_amqp_error(amqp_get_rpc_reply(conn), "Declaring queue", error_description); + if (status != 1) { + return status; + } + + queuename = amqp_bytes_malloc_dup(r->queue); + if (queuename.bytes == NULL) { + copyStringToLStrHandle("Out of memory while copying queue name", error_description); + return _OUT_OF_MEMORY; + } + + amqp_queue_bind(conn, channel, queuename, amqp_cstring_bytes(exchange), amqp_cstring_bytes(bindingkey), amqp_empty_table); + status = lv_report_amqp_error(amqp_get_rpc_reply(conn), "Binding queue", error_description); + if (status != 1) { + return status; + } + + amqp_boolean_t NO_LOCAL = 0; + amqp_boolean_t NO_ACK = 1; + amqp_boolean_t EXCLUSIVE2 = 0; + amqp_basic_consume(conn, channel, queuename, amqp_empty_bytes, NO_LOCAL, NO_ACK, EXCLUSIVE2, amqp_empty_table); + /* amqp_basic_consume is used to register a consumer on the queue, + so that the broker will start delivering messages to it.*/ + status = lv_report_amqp_error(amqp_get_rpc_reply(conn), "Basic consume", error_description); + return status; +} + + +LABVIEW_PUBLIC_FUNCTION +int lv_amqp_consume_message(int64_t conn_intptr, int timeout_sec, LStrHandle output, LStrHandle error_description) { + amqp_connection_state_t conn = (amqp_connection_state_t)conn_intptr; + + int status; + struct timeval tval; + tval.tv_sec = timeout_sec; + tval.tv_usec = 0; + amqp_rpc_reply_t res; + amqp_envelope_t envelope; + + //amqp_maybe_release_buffers(conn); + + status = lv_report_amqp_error(amqp_consume_message(conn, &envelope, &tval, 0),"Consuming message", error_description); + if (status != 1) { + return status; + } + + if (envelope.message.body.len > 0) { + copyBufferToLStrHandle(envelope.message.body.bytes, envelope.message.body.len, output); + } + + amqp_destroy_envelope(&envelope); + return status; +} + diff --git a/labview/labview_rabbitmq.h b/labview/labview_rabbitmq.h new file mode 100644 index 00000000..a8058459 --- /dev/null +++ b/labview/labview_rabbitmq.h @@ -0,0 +1,54 @@ +#ifndef LABVIEW_RABBITMQ_H +#define LABVIEW_RABBITMQ_H + +#if defined(__GNUC__) +#define LABVIEW_PUBLIC_FUNCTION __attribute__((visibility("default"))) +#define LABVIEW_PUBLIC_VARIABLE __attribute__((visibility("default"))) extern +#define LABVIEW_CALL +#else +#define LABVIEW_PUBLIC_FUNCTION +#define LABVIEW_PUBLIC_VARIABLE extern +#define LABVIEW_CALL +#endif + +#define MaxHandleStringLength INT32_MAX +#define MAX_ERROR_DESCRIPTION_LENGTH 1000 + +enum error_code_enum_ { + _AMQP_RESPONSE_NONE = 0, + _AMQP_RESPONSE_NORMAL, + _AMQP_RESPONSE_LIBRARY_EXCEPTION, + _AMQP_RESPONSE_SERVER_EXCEPTION, + _STR_LEN_OVER_INT32MAX, + _CREATING_TCP_SOCKET, + _OPENING_TCP_SOCKET, + _OUT_OF_MEMORY, + _LSTRHANDLE_IS_NULL +}; + +char* lv_rabbitmq_version(void); + +int lv_report_amqp_error(amqp_rpc_reply_t x, char const* context, LStrHandle error_description); + +int64_t lv_amqp_new_connection(); + +int lv_amqp_close_connection(int64_t conn_intptr, LStrHandle error_description); + +void lv_amqp_destroy_connection(int64_t conn_intptr); + +int lv_amqp_channel_open(int64_t conn_intptr, uint16_t channel, LStrHandle error_description); + +int lv_amqp_channel_close(int64_t conn_intptr, uint16_t channel, LStrHandle error_description); + +int lv_amqp_exchange_declare(int64_t conn_intptr, uint16_t channel, char* exchange, char* exchangetype, LStrHandle error_description); + +int lv_amqp_login(int64_t conn_intptr, char* host, int port, int timeout_sec, char* username, char* password, LStrHandle error_description); + +int lv_amqp_basic_publish(int64_t conn_intptr, uint16_t channel, char* exchange, char* routingkey, char* messagebody, LStrHandle error_description); + +int lv_amqp_create_queue(int64_t conn_intptr, uint16_t channel, char* exchange, char* bindingkey, LStrHandle error_description); + +int lv_amqp_consume_message(int64_t conn_intptr, int timeout_sec, LStrHandle output, LStrHandle error_description); + + +#endif /* LABVIEW_RABBITMQ_H */ diff --git a/labview/unix/platform_utils.c b/labview/unix/platform_utils.c new file mode 100644 index 00000000..f9e49600 --- /dev/null +++ b/labview/unix/platform_utils.c @@ -0,0 +1,20 @@ +// Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors. +// SPDX-License-Identifier: mit + +#include +#include +#include +#include + +uint64_t now_microseconds(void) { + struct timeval tv; + gettimeofday(&tv, NULL); + return (uint64_t)tv.tv_sec * 1000000 + (uint64_t)tv.tv_usec; +} + +void microsleep(int usec) { + struct timespec req; + req.tv_sec = 0; + req.tv_nsec = 1000 * usec; + nanosleep(&req, NULL); +} diff --git a/labview/utils.c b/labview/utils.c new file mode 100644 index 00000000..1ff84555 --- /dev/null +++ b/labview/utils.c @@ -0,0 +1,156 @@ +// Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors. +// SPDX-License-Identifier: mit + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "utils.h" + +void die(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); + exit(1); +} + +void die_on_error(int x, char const *context) { + if (x < 0) { + fprintf(stderr, "%s: %s\n", context, amqp_error_string2(x)); + exit(1); + } +} + +void die_on_amqp_error(amqp_rpc_reply_t x, char const *context) { + switch (x.reply_type) { + case AMQP_RESPONSE_NORMAL: + return; + + case AMQP_RESPONSE_NONE: + fprintf(stderr, "%s: missing RPC reply type!\n", context); + break; + + case AMQP_RESPONSE_LIBRARY_EXCEPTION: + fprintf(stderr, "%s: %s\n", context, amqp_error_string2(x.library_error)); + break; + + case AMQP_RESPONSE_SERVER_EXCEPTION: + switch (x.reply.id) { + case AMQP_CONNECTION_CLOSE_METHOD: { + amqp_connection_close_t *m = + (amqp_connection_close_t *)x.reply.decoded; + fprintf(stderr, "%s: server connection error %uh, message: %.*s\n", + context, m->reply_code, (int)m->reply_text.len, + (char *)m->reply_text.bytes); + break; + } + case AMQP_CHANNEL_CLOSE_METHOD: { + amqp_channel_close_t *m = (amqp_channel_close_t *)x.reply.decoded; + fprintf(stderr, "%s: server channel error %uh, message: %.*s\n", + context, m->reply_code, (int)m->reply_text.len, + (char *)m->reply_text.bytes); + break; + } + default: + fprintf(stderr, "%s: unknown server error, method id 0x%08X\n", + context, x.reply.id); + break; + } + break; + } + + exit(1); +} + +static void dump_row(long count, int numinrow, int *chs) { + int i; + + printf("%08lX:", count - numinrow); + + if (numinrow > 0) { + for (i = 0; i < numinrow; i++) { + if (i == 8) { + printf(" :"); + } + printf(" %02X", chs[i]); + } + for (i = numinrow; i < 16; i++) { + if (i == 8) { + printf(" :"); + } + printf(" "); + } + printf(" "); + for (i = 0; i < numinrow; i++) { + if (isprint(chs[i])) { + printf("%c", chs[i]); + } else { + printf("."); + } + } + } + printf("\n"); +} + +static int rows_eq(int *a, int *b) { + int i; + + for (i = 0; i < 16; i++) + if (a[i] != b[i]) { + return 0; + } + + return 1; +} + +void amqp_dump(void const *buffer, size_t len) { + unsigned char *buf = (unsigned char *)buffer; + long count = 0; + int numinrow = 0; + int chs[16]; + int oldchs[16] = {0}; + int showed_dots = 0; + size_t i; + + for (i = 0; i < len; i++) { + int ch = buf[i]; + + if (numinrow == 16) { + int j; + + if (rows_eq(oldchs, chs)) { + if (!showed_dots) { + showed_dots = 1; + printf( + " .. .. .. .. .. .. .. .. : .. .. .. .. .. .. .. ..\n"); + } + } else { + showed_dots = 0; + dump_row(count, numinrow, chs); + } + + for (j = 0; j < 16; j++) { + oldchs[j] = chs[j]; + } + + numinrow = 0; + } + + count++; + chs[numinrow++] = ch; + } + + dump_row(count, numinrow, chs); + + if (numinrow != 0) { + printf("%08lX:\n", count); + } +} diff --git a/labview/utils.h b/labview/utils.h new file mode 100644 index 00000000..85e6d5fe --- /dev/null +++ b/labview/utils.h @@ -0,0 +1,16 @@ +// Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors. +// SPDX-License-Identifier: mit + +#ifndef librabbitmq_labview_utils_h +#define librabbitmq_labview_utils_h + +void die(const char *fmt, ...); +extern void die_on_error(int x, char const *context); +extern void die_on_amqp_error(amqp_rpc_reply_t x, char const *context); + +extern void amqp_dump(void const *buffer, size_t len); + +extern uint64_t now_microseconds(void); +extern void microsleep(int usec); + +#endif diff --git a/labview/win32/platform_utils.c b/labview/win32/platform_utils.c new file mode 100644 index 00000000..59c19569 --- /dev/null +++ b/labview/win32/platform_utils.c @@ -0,0 +1,15 @@ +// Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors. +// SPDX-License-Identifier: mit + +#include + +#include + +uint64_t now_microseconds(void) { + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + return (((uint64_t)ft.dwHighDateTime << 32) | (uint64_t)ft.dwLowDateTime) / + 10; +} + +void microsleep(int usec) { Sleep(usec / 1000); }