diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..346b98e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: CI - Build & Test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build-and-test: + name: Build & Test + runs-on: macos-latest + + env: + SCHEME: MongoDesktop + PROJECT: MongoDesktop.xcodeproj + + steps: + # ────────────────────────────────────────────── + # 1. Checkout + # ────────────────────────────────────────────── + - name: Checkout code + uses: actions/checkout@v7 + + # ────────────────────────────────────────────── + # 2. Select Xcode + # ────────────────────────────────────────────── + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode.app && xcodebuild -version + + # ────────────────────────────────────────────── + # 3. Build Project + # ────────────────────────────────────────────── + - name: Build Project + run: | + set -o pipefail + xcodebuild build \ + -project "$PROJECT" \ + -scheme "$SCHEME" \ + -configuration Debug \ + ONLY_ACTIVE_ARCH=YES \ + EXCLUDED_ARCHS="x86_64" \ + CODE_SIGN_STYLE=Manual \ + CODE_SIGN_IDENTITY="-" \ + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGNING_ALLOWED=NO | xcpretty && exit ${PIPESTATUS[0]} + + # ────────────────────────────────────────────── + # 4. Run Tests + # ────────────────────────────────────────────── + - name: Run Tests + run: | + set -o pipefail + xcodebuild test \ + -project "$PROJECT" \ + -scheme "$SCHEME" \ + -configuration Debug \ + ONLY_ACTIVE_ARCH=YES \ + EXCLUDED_ARCHS="x86_64" \ + CODE_SIGN_STYLE=Manual \ + CODE_SIGN_IDENTITY="-" \ + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGNING_ALLOWED=NO | xcpretty --report html --output test-results.html && exit ${PIPESTATUS[0]} \ + || echo "No unit test target configured or tests finished" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8ebee2d..9b15078 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: build +name: Release - Build & Publish on: push: @@ -24,23 +24,16 @@ jobs: # 1. Checkout # ────────────────────────────────────────────── - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v7 # ────────────────────────────────────────────── # 2. Select Xcode # ────────────────────────────────────────────── - - name: Select Select Xcode 26.1 - run: sudo xcode-select -s /Applications/Xcode_26.1.app + - name: Select Xcode + run: sudo xcode-select -s /Applications/Xcode.app && xcodebuild -version # ────────────────────────────────────────────── - # 3. Install mongo-c-driver via Homebrew - # (needed for header / lib search paths) - # ────────────────────────────────────────────── - - name: Install mongo-c-driver - run: brew install mongo-c-driver - - # ────────────────────────────────────────────── - # 4. Extract version from tag (v1.2.3 → 1.2.3) + # 3. Extract version from tag (v1.2.3 → 1.2.3) # ────────────────────────────────────────────── - name: Extract version id: version @@ -51,17 +44,11 @@ jobs: echo "tag=$TAG" >> "$GITHUB_OUTPUT" # ────────────────────────────────────────────── - # 5. Build & Archive + # 4. Build & Archive # ────────────────────────────────────────────── - name: Build archive run: | - MONGO_INCLUDE=$(brew --prefix mongo-c-driver)/include - MONGO_LIB=$(brew --prefix mongo-c-driver)/lib - - # Find versioned include subdirs - MONGOC_INCLUDE=$(ls -d "$MONGO_INCLUDE"/mongoc-* 2>/dev/null | head -1) - BSON_INCLUDE=$(ls -d "$MONGO_INCLUDE"/bson-* 2>/dev/null | head -1) - + set -o pipefail xcodebuild archive \ -project "$PROJECT" \ -scheme "$SCHEME" \ @@ -69,14 +56,13 @@ jobs: -archivePath "$RUNNER_TEMP/$APP_NAME.xcarchive" \ ONLY_ACTIVE_ARCH=YES \ EXCLUDED_ARCHS="x86_64" \ - HEADER_SEARCH_PATHS="\$(inherited) $MONGOC_INCLUDE $BSON_INCLUDE" \ - LIBRARY_SEARCH_PATHS="\$(inherited) $MONGO_LIB" \ CODE_SIGN_STYLE=Manual \ CODE_SIGN_IDENTITY="-" \ - | xcpretty + CODE_SIGNING_REQUIRED=NO \ + CODE_SIGNING_ALLOWED=NO | xcpretty && exit ${PIPESTATUS[0]} # ────────────────────────────────────────────── - # 6. Export .app from archive + # 5. Export .app from archive # ────────────────────────────────────────────── - name: Export app run: | @@ -84,44 +70,31 @@ jobs: cp -R "$RUNNER_TEMP/$APP_NAME.xcarchive/Products/Applications/$APP_NAME.app" "$RUNNER_TEMP/export/" # ────────────────────────────────────────────── - # 7. Create DMG with create-dmg + # 6. Create DMG with hdiutil # ────────────────────────────────────────────── - - name: Install create-dmg - run: brew install create-dmg - - name: Create DMG id: dmg run: | VERSION="${{ steps.version.outputs.version }}" DMG_NAME="${APP_NAME}-${VERSION}.dmg" - APP_PATH="$RUNNER_TEMP/export/$APP_NAME.app" - - create-dmg \ - --volname "$APP_NAME $VERSION" \ - --volicon "$APP_NAME/Assets.xcassets/AppIcon.appiconset/AppIcon-512.png" \ - --window-pos 200 120 \ - --window-size 660 400 \ - --icon-size 128 \ - --icon "$APP_NAME.app" 190 160 \ - --hide-extension "$APP_NAME.app" \ - --app-drop-link 470 160 \ - "$RUNNER_TEMP/$DMG_NAME" \ - "$APP_PATH" \ - || true # create-dmg exits 1 even on success when no signing + + # Prepare staging folder + STAGING_DIR="$RUNNER_TEMP/dmg_staging" + mkdir -p "$STAGING_DIR" + cp -R "$RUNNER_TEMP/export/$APP_NAME.app" "$STAGING_DIR/" + ln -s /Applications "$STAGING_DIR/Applications" + + # Create DMG via native hdiutil + hdiutil create -volname "$APP_NAME $VERSION" \ + -srcfolder "$STAGING_DIR" \ + -ov -format UDZO \ + "$RUNNER_TEMP/$DMG_NAME" echo "dmg_path=$RUNNER_TEMP/$DMG_NAME" >> "$GITHUB_OUTPUT" echo "dmg_name=$DMG_NAME" >> "$GITHUB_OUTPUT" # ────────────────────────────────────────────── - # 8. Sign the DMG - # ────────────────────────────────────────────── - - name: Sign DMG - run: | - codesign --force --sign - \ - "${{ steps.dmg.outputs.dmg_path }}" - - # ────────────────────────────────────────────── - # 9. Create GitHub Release & upload DMG + # 7. Create GitHub Release & upload DMG # ────────────────────────────────────────────── - name: Create GitHub Release uses: softprops/action-gh-release@v2 diff --git a/MongoDesktop.xcodeproj/project.pbxproj b/MongoDesktop.xcodeproj/project.pbxproj index 8a4ca3b..b62aa18 100644 --- a/MongoDesktop.xcodeproj/project.pbxproj +++ b/MongoDesktop.xcodeproj/project.pbxproj @@ -80,7 +80,6 @@ 5C3182C62DBFF006004C59B0 /* Sources */, 5C3182C72DBFF006004C59B0 /* Frameworks */, 5C3182C82DBFF006004C59B0 /* Resources */, - 5C7E9A3E2F1A123400ABCDEF /* Embed Mongo C Driver */, ); buildRules = ( ); @@ -336,14 +335,9 @@ ENABLE_USER_SELECTED_FILES = readonly; EXCLUDED_ARCHS = x86_64; GENERATE_INFOPLIST_FILE = YES; - HEADER_SEARCH_PATHS = "$(inherited)"; - "HEADER_SEARCH_PATHS[arch=arm64]" = ( - "/opt/homebrew/opt/mongo-c-driver/include/mongoc-2.2.4", - "/opt/homebrew/opt/mongo-c-driver/include/bson-2.2.4", - ); - "HEADER_SEARCH_PATHS[arch=x86_64]" = ( - "/opt/homebrew/opt/mongo-c-driver/include/mongoc-2.2.4", - "/opt/homebrew/opt/mongo-c-driver/include/bson-2.2.4", + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/Vendor/mongo-c-driver/include", ); INFOPLIST_KEY_CFBundleDisplayName = "Mongo Desktop"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools"; @@ -352,9 +346,10 @@ "$(inherited)", "@executable_path/../Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - "LIBRARY_SEARCH_PATHS[arch=arm64]" = "/opt/homebrew/opt/mongo-c-driver/lib"; - "LIBRARY_SEARCH_PATHS[arch=x86_64]" = "/opt/homebrew/opt/mongo-c-driver/lib"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/Vendor/mongo-c-driver/lib", + ); MACOSX_DEPLOYMENT_TARGET = 26.0; MARKETING_VERSION = 1.0; ONLY_ACTIVE_ARCH = YES; @@ -362,6 +357,10 @@ "$(inherited)", "-lmongoc2", "-lbson2", + "-lzstd", + "-lz", + "-lresolv", + "-lsasl2", ); PRODUCT_BUNDLE_IDENTIFIER = com.dungmv.mongodesktop.MongoDesktop; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -392,14 +391,9 @@ ENABLE_USER_SELECTED_FILES = readonly; EXCLUDED_ARCHS = x86_64; GENERATE_INFOPLIST_FILE = YES; - HEADER_SEARCH_PATHS = "$(inherited)"; - "HEADER_SEARCH_PATHS[arch=arm64]" = ( - "/opt/homebrew/opt/mongo-c-driver/include/mongoc-2.2.4", - "/opt/homebrew/opt/mongo-c-driver/include/bson-2.2.4", - ); - "HEADER_SEARCH_PATHS[arch=x86_64]" = ( - "/opt/homebrew/opt/mongo-c-driver/include/mongoc-2.2.4", - "/opt/homebrew/opt/mongo-c-driver/include/bson-2.2.4", + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/Vendor/mongo-c-driver/include", ); INFOPLIST_KEY_CFBundleDisplayName = "Mongo Desktop"; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools"; @@ -408,9 +402,10 @@ "$(inherited)", "@executable_path/../Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - "LIBRARY_SEARCH_PATHS[arch=arm64]" = "/opt/homebrew/opt/mongo-c-driver/lib"; - "LIBRARY_SEARCH_PATHS[arch=x86_64]" = "/opt/homebrew/opt/mongo-c-driver/lib"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(SRCROOT)/Vendor/mongo-c-driver/lib", + ); MACOSX_DEPLOYMENT_TARGET = 26.0; MARKETING_VERSION = 1.0; ONLY_ACTIVE_ARCH = YES; @@ -418,6 +413,10 @@ "$(inherited)", "-lmongoc2", "-lbson2", + "-lzstd", + "-lz", + "-lresolv", + "-lsasl2", ); PRODUCT_BUNDLE_IDENTIFIER = com.dungmv.mongodesktop.MongoDesktop; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Vendor/mongo-c-driver/include/bson/bson-bcon.h b/Vendor/mongo-c-driver/include/bson/bson-bcon.h new file mode 100644 index 0000000..7adcc40 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-bcon.h @@ -0,0 +1,249 @@ +/* + * @file bcon.h + * @brief BCON (BSON C Object Notation) Declarations + */ + +#include + +/* Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BCON_H_ +#define BCON_H_ + +// Include specific headers first, because bson.h tries to include this header itself: +#include +#include +// For other APIs, not properly grouped, but needed: +#include + + +BSON_BEGIN_DECLS + + +#define BCON_STACK_MAX 100 + +#define BCON_ENSURE_DECLARE(fun, type) \ + static BSON_INLINE type bcon_ensure_##fun(type _t) \ + { \ + return _t; \ + } + +#define BCON_ENSURE(fun, val) bcon_ensure_##fun(val) + +#define BCON_ENSURE_STORAGE(fun, val) bcon_ensure_##fun(&(val)) + +BCON_ENSURE_DECLARE(const_char_ptr, const char *) +BCON_ENSURE_DECLARE(const_char_ptr_ptr, const char **) +BCON_ENSURE_DECLARE(double, double) +BCON_ENSURE_DECLARE(double_ptr, double *) +BCON_ENSURE_DECLARE(const_bson_ptr, const bson_t *) +BCON_ENSURE_DECLARE(bson_ptr, bson_t *) +BCON_ENSURE_DECLARE(subtype, bson_subtype_t) +BCON_ENSURE_DECLARE(subtype_ptr, bson_subtype_t *) +BCON_ENSURE_DECLARE(const_uint8_ptr, const uint8_t *) +BCON_ENSURE_DECLARE(const_uint8_ptr_ptr, const uint8_t **) +BCON_ENSURE_DECLARE(uint32, uint32_t) +BCON_ENSURE_DECLARE(uint32_ptr, uint32_t *) +BCON_ENSURE_DECLARE(const_oid_ptr, const bson_oid_t *) +BCON_ENSURE_DECLARE(const_oid_ptr_ptr, const bson_oid_t **) +BCON_ENSURE_DECLARE(int32, int32_t) +BCON_ENSURE_DECLARE(int32_ptr, int32_t *) +BCON_ENSURE_DECLARE(int64, int64_t) +BCON_ENSURE_DECLARE(int64_ptr, int64_t *) +BCON_ENSURE_DECLARE(const_decimal128_ptr, const bson_decimal128_t *) +BCON_ENSURE_DECLARE(bool, bool) +BCON_ENSURE_DECLARE(bool_ptr, bool *) +BCON_ENSURE_DECLARE(bson_type, bson_type_t) +BCON_ENSURE_DECLARE(bson_iter_ptr, bson_iter_t *) +BCON_ENSURE_DECLARE(const_bson_iter_ptr, const bson_iter_t *) + +#define BCON_UTF8(_val) BCON_MAGIC, BCON_TYPE_UTF8, BCON_ENSURE(const_char_ptr, (_val)) +#define BCON_DOUBLE(_val) BCON_MAGIC, BCON_TYPE_DOUBLE, BCON_ENSURE(double, (_val)) +#define BCON_DOCUMENT(_val) BCON_MAGIC, BCON_TYPE_DOCUMENT, BCON_ENSURE(const_bson_ptr, (_val)) +#define BCON_ARRAY(_val) BCON_MAGIC, BCON_TYPE_ARRAY, BCON_ENSURE(const_bson_ptr, (_val)) +#define BCON_BIN(_subtype, _binary, _length) \ + BCON_MAGIC, BCON_TYPE_BIN, BCON_ENSURE(subtype, (_subtype)), BCON_ENSURE(const_uint8_ptr, (_binary)), \ + BCON_ENSURE(uint32, (_length)) +#define BCON_UNDEFINED BCON_MAGIC, BCON_TYPE_UNDEFINED +#define BCON_OID(_val) BCON_MAGIC, BCON_TYPE_OID, BCON_ENSURE(const_oid_ptr, (_val)) +#define BCON_BOOL(_val) BCON_MAGIC, BCON_TYPE_BOOL, BCON_ENSURE(bool, (_val)) +#define BCON_DATE_TIME(_val) BCON_MAGIC, BCON_TYPE_DATE_TIME, BCON_ENSURE(int64, (_val)) +#define BCON_NULL BCON_MAGIC, BCON_TYPE_NULL +#define BCON_REGEX(_regex, _flags) \ + BCON_MAGIC, BCON_TYPE_REGEX, BCON_ENSURE(const_char_ptr, (_regex)), BCON_ENSURE(const_char_ptr, (_flags)) +#define BCON_DBPOINTER(_collection, _oid) \ + BCON_MAGIC, BCON_TYPE_DBPOINTER, BCON_ENSURE(const_char_ptr, (_collection)), BCON_ENSURE(const_oid_ptr, (_oid)) +#define BCON_CODE(_val) BCON_MAGIC, BCON_TYPE_CODE, BCON_ENSURE(const_char_ptr, (_val)) +#define BCON_SYMBOL(_val) BCON_MAGIC, BCON_TYPE_SYMBOL, BCON_ENSURE(const_char_ptr, (_val)) +#define BCON_CODEWSCOPE(_js, _scope) \ + BCON_MAGIC, BCON_TYPE_CODEWSCOPE, BCON_ENSURE(const_char_ptr, (_js)), BCON_ENSURE(const_bson_ptr, (_scope)) +#define BCON_INT32(_val) BCON_MAGIC, BCON_TYPE_INT32, BCON_ENSURE(int32, (_val)) +#define BCON_TIMESTAMP(_timestamp, _increment) \ + BCON_MAGIC, BCON_TYPE_TIMESTAMP, BCON_ENSURE(int32, (_timestamp)), BCON_ENSURE(int32, (_increment)) +#define BCON_INT64(_val) BCON_MAGIC, BCON_TYPE_INT64, BCON_ENSURE(int64, (_val)) +#define BCON_DECIMAL128(_val) BCON_MAGIC, BCON_TYPE_DECIMAL128, BCON_ENSURE(const_decimal128_ptr, (_val)) +#define BCON_MAXKEY BCON_MAGIC, BCON_TYPE_MAXKEY +#define BCON_MINKEY BCON_MAGIC, BCON_TYPE_MINKEY +#define BCON(_val) BCON_MAGIC, BCON_TYPE_BCON, BCON_ENSURE(const_bson_ptr, (_val)) +#define BCON_ITER(_val) BCON_MAGIC, BCON_TYPE_ITER, BCON_ENSURE(const_bson_iter_ptr, (_val)) + +#define BCONE_UTF8(_val) BCONE_MAGIC, BCON_TYPE_UTF8, BCON_ENSURE_STORAGE(const_char_ptr_ptr, (_val)) +#define BCONE_DOUBLE(_val) BCONE_MAGIC, BCON_TYPE_DOUBLE, BCON_ENSURE_STORAGE(double_ptr, (_val)) +#define BCONE_DOCUMENT(_val) BCONE_MAGIC, BCON_TYPE_DOCUMENT, BCON_ENSURE_STORAGE(bson_ptr, (_val)) +#define BCONE_ARRAY(_val) BCONE_MAGIC, BCON_TYPE_ARRAY, BCON_ENSURE_STORAGE(bson_ptr, (_val)) +#define BCONE_BIN(subtype, binary, length) \ + BCONE_MAGIC, BCON_TYPE_BIN, BCON_ENSURE_STORAGE(subtype_ptr, (subtype)), \ + BCON_ENSURE_STORAGE(const_uint8_ptr_ptr, (binary)), BCON_ENSURE_STORAGE(uint32_ptr, (length)) +#define BCONE_UNDEFINED BCONE_MAGIC, BCON_TYPE_UNDEFINED +#define BCONE_OID(_val) BCONE_MAGIC, BCON_TYPE_OID, BCON_ENSURE_STORAGE(const_oid_ptr_ptr, (_val)) +#define BCONE_BOOL(_val) BCONE_MAGIC, BCON_TYPE_BOOL, BCON_ENSURE_STORAGE(bool_ptr, (_val)) +#define BCONE_DATE_TIME(_val) BCONE_MAGIC, BCON_TYPE_DATE_TIME, BCON_ENSURE_STORAGE(int64_ptr, (_val)) +#define BCONE_NULL BCONE_MAGIC, BCON_TYPE_NULL +#define BCONE_REGEX(_regex, _flags) \ + BCONE_MAGIC, BCON_TYPE_REGEX, BCON_ENSURE_STORAGE(const_char_ptr_ptr, (_regex)), \ + BCON_ENSURE_STORAGE(const_char_ptr_ptr, (_flags)) +#define BCONE_DBPOINTER(_collection, _oid) \ + BCONE_MAGIC, BCON_TYPE_DBPOINTER, BCON_ENSURE_STORAGE(const_char_ptr_ptr, (_collection)), \ + BCON_ENSURE_STORAGE(const_oid_ptr_ptr, (_oid)) +#define BCONE_CODE(_val) BCONE_MAGIC, BCON_TYPE_CODE, BCON_ENSURE_STORAGE(const_char_ptr_ptr, (_val)) +#define BCONE_SYMBOL(_val) BCONE_MAGIC, BCON_TYPE_SYMBOL, BCON_ENSURE_STORAGE(const_char_ptr_ptr, (_val)) +#define BCONE_CODEWSCOPE(_js, _scope) \ + BCONE_MAGIC, BCON_TYPE_CODEWSCOPE, BCON_ENSURE_STORAGE(const_char_ptr_ptr, (_js)), \ + BCON_ENSURE_STORAGE(bson_ptr, (_scope)) +#define BCONE_INT32(_val) BCONE_MAGIC, BCON_TYPE_INT32, BCON_ENSURE_STORAGE(int32_ptr, (_val)) +#define BCONE_TIMESTAMP(_timestamp, _increment) \ + BCONE_MAGIC, BCON_TYPE_TIMESTAMP, BCON_ENSURE_STORAGE(int32_ptr, (_timestamp)), \ + BCON_ENSURE_STORAGE(int32_ptr, (_increment)) +#define BCONE_INT64(_val) BCONE_MAGIC, BCON_TYPE_INT64, BCON_ENSURE_STORAGE(int64_ptr, (_val)) +#define BCONE_DECIMAL128(_val) BCONE_MAGIC, BCON_TYPE_DECIMAL128, BCON_ENSURE_STORAGE(const_decimal128_ptr, (_val)) +#define BCONE_MAXKEY BCONE_MAGIC, BCON_TYPE_MAXKEY +#define BCONE_MINKEY BCONE_MAGIC, BCON_TYPE_MINKEY +#define BCONE_SKIP(_val) BCONE_MAGIC, BCON_TYPE_SKIP, BCON_ENSURE(bson_type, (_val)) +#define BCONE_ITER(_val) BCONE_MAGIC, BCON_TYPE_ITER, BCON_ENSURE_STORAGE(bson_iter_ptr, (_val)) + +#define BCON_MAGIC bson_bcon_magic() +#define BCONE_MAGIC bson_bcone_magic() + +typedef enum { + BCON_TYPE_UTF8, + BCON_TYPE_DOUBLE, + BCON_TYPE_DOCUMENT, + BCON_TYPE_ARRAY, + BCON_TYPE_BIN, + BCON_TYPE_UNDEFINED, + BCON_TYPE_OID, + BCON_TYPE_BOOL, + BCON_TYPE_DATE_TIME, + BCON_TYPE_NULL, + BCON_TYPE_REGEX, + BCON_TYPE_DBPOINTER, + BCON_TYPE_CODE, + BCON_TYPE_SYMBOL, + BCON_TYPE_CODEWSCOPE, + BCON_TYPE_INT32, + BCON_TYPE_TIMESTAMP, + BCON_TYPE_INT64, + BCON_TYPE_DECIMAL128, + BCON_TYPE_MAXKEY, + BCON_TYPE_MINKEY, + BCON_TYPE_BCON, + BCON_TYPE_ARRAY_START, + BCON_TYPE_ARRAY_END, + BCON_TYPE_DOC_START, + BCON_TYPE_DOC_END, + BCON_TYPE_END, + BCON_TYPE_RAW, + BCON_TYPE_SKIP, + BCON_TYPE_ITER, + BCON_TYPE_ERROR, +} bcon_type_t; + +typedef struct bcon_append_ctx_frame { + int i; + bool is_array; + bson_t bson; +} bcon_append_ctx_frame_t; + +typedef struct bcon_extract_ctx_frame { + int i; + bool is_array; + bson_iter_t iter; +} bcon_extract_ctx_frame_t; + +typedef struct _bcon_append_ctx_t { + bcon_append_ctx_frame_t stack[BCON_STACK_MAX]; + int n; +} bcon_append_ctx_t; + +typedef struct _bcon_extract_ctx_t { + bcon_extract_ctx_frame_t stack[BCON_STACK_MAX]; + int n; +} bcon_extract_ctx_t; + +BSON_EXPORT(void) +bcon_append(bson_t *bson, ...) BSON_GNUC_NULL_TERMINATED; +BSON_EXPORT(void) +bcon_append_ctx(bson_t *bson, bcon_append_ctx_t *ctx, ...) BSON_GNUC_NULL_TERMINATED; +BSON_EXPORT(void) +bcon_append_ctx_va(bson_t *bson, bcon_append_ctx_t *ctx, va_list *va); +BSON_EXPORT(void) +bcon_append_ctx_init(bcon_append_ctx_t *ctx); + +BSON_EXPORT(void) +bcon_extract_ctx_init(bcon_extract_ctx_t *ctx); + +BSON_EXPORT(void) +bcon_extract_ctx(bson_t *bson, bcon_extract_ctx_t *ctx, ...) BSON_GNUC_NULL_TERMINATED; + +BSON_EXPORT(bool) +bcon_extract_ctx_va(bson_t *bson, bcon_extract_ctx_t *ctx, va_list *ap); + +BSON_EXPORT(bool) +bcon_extract(bson_t *bson, ...) BSON_GNUC_NULL_TERMINATED; + +BSON_EXPORT(bool) +bcon_extract_va(bson_t *bson, bcon_extract_ctx_t *ctx, ...) BSON_GNUC_NULL_TERMINATED; + +BSON_EXPORT(bson_t *) +bcon_new(void *unused, ...) BSON_GNUC_NULL_TERMINATED; + +/** + * The bcon_..() functions are all declared with __attribute__((sentinel)). + * + * From GCC manual for "sentinel": "A valid NULL in this context is defined as + * zero with any pointer type. If your system defines the NULL macro with an + * integer type then you need to add an explicit cast." + * Case in point: GCC on Solaris (at least) + */ +#define BCON_APPEND(_bson, ...) bcon_append((_bson), __VA_ARGS__, (void *)NULL) +#define BCON_APPEND_CTX(_bson, _ctx, ...) bcon_append_ctx((_bson), (_ctx), __VA_ARGS__, (void *)NULL) + +#define BCON_EXTRACT(_bson, ...) bcon_extract((_bson), __VA_ARGS__, (void *)NULL) + +#define BCON_EXTRACT_CTX(_bson, _ctx, ...) bcon_extract((_bson), (_ctx), __VA_ARGS__, (void *)NULL) + +#define BCON_NEW(...) bcon_new(NULL, __VA_ARGS__, (void *)NULL) + +BSON_EXPORT(const char *) +bson_bcon_magic(void) BSON_GNUC_PURE; +BSON_EXPORT(const char *) +bson_bcone_magic(void) BSON_GNUC_PURE; + + +BSON_END_DECLS + + +#endif diff --git a/Vendor/mongo-c-driver/include/bson/bson-clock.h b/Vendor/mongo-c-driver/include/bson/bson-clock.h new file mode 100644 index 0000000..5f7d8df --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-clock.h @@ -0,0 +1,41 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_CLOCK_H +#define BSON_CLOCK_H + + +#include +#include +#include + + +BSON_BEGIN_DECLS + + +BSON_EXPORT(int64_t) +bson_get_monotonic_time(void); +BSON_EXPORT(int) +bson_gettimeofday(struct timeval *tv); + + +BSON_END_DECLS + + +#endif /* BSON_CLOCK_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-context.h b/Vendor/mongo-c-driver/include/bson/bson-context.h new file mode 100644 index 0000000..26d03cb --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-context.h @@ -0,0 +1,64 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_CONTEXT_H +#define BSON_CONTEXT_H + + +#include +#include + + +BSON_BEGIN_DECLS + + +/** + * @brief Initialize a new context with the given flags + * + * @param flags Flags used to configure the behavior of the context. For most + * cases, this should be BSON_CONTEXT_NONE. + * + * @return A newly allocated context. Must be freed with bson_context_destroy() + * + * @note If you expect your pid to change without notice, such as from an + * unexpected call to fork(), then specify BSON_CONTEXT_DISABLE_PID_CACHE in + * `flags`. + */ +BSON_EXPORT(bson_context_t *) +bson_context_new(bson_context_flags_t flags); + +/** + * @brief Destroy and free a bson_context_t created by bson_context_new() + */ +BSON_EXPORT(void) +bson_context_destroy(bson_context_t *context); + +/** + * @brief Obtain a pointer to the application-default bson_context_t + * + * @note This context_t MUST NOT be passed to bson_context_destroy() + */ +BSON_EXPORT(bson_context_t *) +bson_context_get_default(void); + + +BSON_END_DECLS + + +#endif /* BSON_CONTEXT_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-decimal128.h b/Vendor/mongo-c-driver/include/bson/bson-decimal128.h new file mode 100644 index 0000000..ddb9bb8 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-decimal128.h @@ -0,0 +1,62 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_DECIMAL128_H +#define BSON_DECIMAL128_H + + +#include +#include +#include + +#include + + +/** + * BSON_DECIMAL128_STRING: + * + * The length of a decimal128 string (with null terminator). + * + * 1 for the sign + * 35 for digits and radix + * 2 for exponent indicator and sign + * 4 for exponent digits + */ +#define BSON_DECIMAL128_STRING 43 +#define BSON_DECIMAL128_INF "Infinity" +#define BSON_DECIMAL128_NAN "NaN" + + +BSON_BEGIN_DECLS + +BSON_EXPORT(void) +bson_decimal128_to_string(const bson_decimal128_t *dec, char *str); + + +/* Note: @string must be ASCII characters only! */ +BSON_EXPORT(bool) +bson_decimal128_from_string(const char *string, bson_decimal128_t *dec); + +BSON_EXPORT(bool) +bson_decimal128_from_string_w_len(const char *string, int len, bson_decimal128_t *dec); + +BSON_END_DECLS + + +#endif /* BSON_DECIMAL128_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-endian.h b/Vendor/mongo-c-driver/include/bson/bson-endian.h new file mode 100644 index 0000000..2830cdf --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-endian.h @@ -0,0 +1,246 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_ENDIAN_H +#define BSON_ENDIAN_H + +#include +#include +#include + + +BSON_BEGIN_DECLS + + +#define BSON_BIG_ENDIAN 4321 +#define BSON_LITTLE_ENDIAN 1234 + +#if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__) && (__clang_major__ >= 3) && \ + (__clang_minor__ >= 1) +#if __has_builtin(__builtin_bswap16) +#define BSON_UINT16_SWAP_LE_BE(v) __builtin_bswap16(v) +#endif +#if __has_builtin(__builtin_bswap32) +#define BSON_UINT32_SWAP_LE_BE(v) __builtin_bswap32(v) +#endif +#if __has_builtin(__builtin_bswap64) +#define BSON_UINT64_SWAP_LE_BE(v) __builtin_bswap64(v) +#endif +#elif defined(__GNUC__) && (__GNUC__ >= 4) +#if __GNUC__ > 4 || (defined(__GNUC_MINOR__) && __GNUC_MINOR__ >= 3) +#define BSON_UINT32_SWAP_LE_BE(v) __builtin_bswap32((uint32_t)v) +#define BSON_UINT64_SWAP_LE_BE(v) __builtin_bswap64((uint64_t)v) +#endif +#if __GNUC__ > 4 || (defined(__GNUC_MINOR__) && __GNUC_MINOR__ >= 8) +#define BSON_UINT16_SWAP_LE_BE(v) __builtin_bswap16((uint32_t)v) +#endif +#endif + + +#ifndef BSON_UINT16_SWAP_LE_BE +#define BSON_UINT16_SWAP_LE_BE(v) __bson_uint16_swap_slow((uint16_t)v) +#endif + + +#ifndef BSON_UINT32_SWAP_LE_BE +#define BSON_UINT32_SWAP_LE_BE(v) __bson_uint32_swap_slow((uint32_t)v) +#endif + + +#ifndef BSON_UINT64_SWAP_LE_BE +#define BSON_UINT64_SWAP_LE_BE(v) __bson_uint64_swap_slow((uint64_t)v) +#endif + + +#if BSON_BYTE_ORDER == BSON_LITTLE_ENDIAN +#define BSON_UINT16_FROM_LE(v) ((uint16_t)v) +#define BSON_UINT16_TO_LE(v) ((uint16_t)v) +#define BSON_UINT16_FROM_BE(v) BSON_UINT16_SWAP_LE_BE(v) +#define BSON_UINT16_TO_BE(v) BSON_UINT16_SWAP_LE_BE(v) +#define BSON_UINT32_FROM_LE(v) ((uint32_t)v) +#define BSON_UINT32_TO_LE(v) ((uint32_t)v) +#define BSON_UINT32_FROM_BE(v) BSON_UINT32_SWAP_LE_BE(v) +#define BSON_UINT32_TO_BE(v) BSON_UINT32_SWAP_LE_BE(v) +#define BSON_UINT64_FROM_LE(v) ((uint64_t)v) +#define BSON_UINT64_TO_LE(v) ((uint64_t)v) +#define BSON_UINT64_FROM_BE(v) BSON_UINT64_SWAP_LE_BE(v) +#define BSON_UINT64_TO_BE(v) BSON_UINT64_SWAP_LE_BE(v) +#define BSON_DOUBLE_FROM_LE(v) ((double)v) +#define BSON_DOUBLE_TO_LE(v) ((double)v) +#define BSON_FLOAT_FROM_LE(v) ((float)v) +#define BSON_FLOAT_TO_LE(v) ((float)v) +#elif BSON_BYTE_ORDER == BSON_BIG_ENDIAN +#define BSON_UINT16_FROM_LE(v) BSON_UINT16_SWAP_LE_BE(v) +#define BSON_UINT16_TO_LE(v) BSON_UINT16_SWAP_LE_BE(v) +#define BSON_UINT16_FROM_BE(v) ((uint16_t)v) +#define BSON_UINT16_TO_BE(v) ((uint16_t)v) +#define BSON_UINT32_FROM_LE(v) BSON_UINT32_SWAP_LE_BE(v) +#define BSON_UINT32_TO_LE(v) BSON_UINT32_SWAP_LE_BE(v) +#define BSON_UINT32_FROM_BE(v) ((uint32_t)v) +#define BSON_UINT32_TO_BE(v) ((uint32_t)v) +#define BSON_UINT64_FROM_LE(v) BSON_UINT64_SWAP_LE_BE(v) +#define BSON_UINT64_TO_LE(v) BSON_UINT64_SWAP_LE_BE(v) +#define BSON_UINT64_FROM_BE(v) ((uint64_t)v) +#define BSON_UINT64_TO_BE(v) ((uint64_t)v) +#define BSON_DOUBLE_FROM_LE(v) (__bson_double_swap_slow(v)) +#define BSON_DOUBLE_TO_LE(v) (__bson_double_swap_slow(v)) +#define BSON_FLOAT_FROM_LE(v) (__bson_float_swap_slow(v)) +#define BSON_FLOAT_TO_LE(v) (__bson_float_swap_slow(v)) +#else +#error "The endianness of target architecture is unknown." +#endif + + +/* + *-------------------------------------------------------------------------- + * + * __bson_uint16_swap_slow -- + * + * Fallback endianness conversion for 16-bit integers. + * + * Returns: + * The endian swapped version. + * + * Side effects: + * None. + * + *-------------------------------------------------------------------------- + */ + +static BSON_INLINE uint16_t +__bson_uint16_swap_slow(uint16_t v) /* IN */ +{ + return (uint16_t)((v & 0x00FF) << 8) | (uint16_t)((v & 0xFF00) >> 8); +} + + +/* + *-------------------------------------------------------------------------- + * + * __bson_uint32_swap_slow -- + * + * Fallback endianness conversion for 32-bit integers. + * + * Returns: + * The endian swapped version. + * + * Side effects: + * None. + * + *-------------------------------------------------------------------------- + */ + +static BSON_INLINE uint32_t +__bson_uint32_swap_slow(uint32_t v) /* IN */ +{ + return ((v & 0x000000FFU) << 24) | ((v & 0x0000FF00U) << 8) | ((v & 0x00FF0000U) >> 8) | ((v & 0xFF000000U) >> 24); +} + + +/* + *-------------------------------------------------------------------------- + * + * __bson_uint64_swap_slow -- + * + * Fallback endianness conversion for 64-bit integers. + * + * Returns: + * The endian swapped version. + * + * Side effects: + * None. + * + *-------------------------------------------------------------------------- + */ + +static BSON_INLINE uint64_t +__bson_uint64_swap_slow(uint64_t v) /* IN */ +{ + return ((v & 0x00000000000000FFULL) << 56) | ((v & 0x000000000000FF00ULL) << 40) | + ((v & 0x0000000000FF0000ULL) << 24) | ((v & 0x00000000FF000000ULL) << 8) | + ((v & 0x000000FF00000000ULL) >> 8) | ((v & 0x0000FF0000000000ULL) >> 24) | + ((v & 0x00FF000000000000ULL) >> 40) | ((v & 0xFF00000000000000ULL) >> 56); +} + + +/* + *-------------------------------------------------------------------------- + * + * __bson_double_swap_slow -- + * + * Fallback endianness conversion for double floating point. + * + * Returns: + * The endian swapped version. + * + * Side effects: + * None. + * + *-------------------------------------------------------------------------- + */ + +BSON_STATIC_ASSERT2(sizeof_uint64_t, sizeof(double) == sizeof(uint64_t)); + +static BSON_INLINE double +__bson_double_swap_slow(double v) /* IN */ +{ + uint64_t uv; + + memcpy(&uv, &v, sizeof(v)); + uv = BSON_UINT64_SWAP_LE_BE(uv); + memcpy(&v, &uv, sizeof(v)); + + return v; +} + + +/* + *-------------------------------------------------------------------------- + * + * __bson_float_swap_slow -- + * + * Fallback endianness conversion for single floating point. + * + * Returns: + * The endian swapped version. + * + * Side effects: + * None. + * + *-------------------------------------------------------------------------- + */ + +BSON_STATIC_ASSERT2(sizeof_uint32_t, sizeof(float) == sizeof(uint32_t)); + +static BSON_INLINE float +__bson_float_swap_slow(float v) /* IN */ +{ + uint32_t uv; + + memcpy(&uv, &v, sizeof(v)); + uv = BSON_UINT32_SWAP_LE_BE(uv); + memcpy(&v, &uv, sizeof(v)); + + return v; +} + +BSON_END_DECLS + + +#endif /* BSON_ENDIAN_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-iter.h b/Vendor/mongo-c-driver/include/bson/bson-iter.h new file mode 100644 index 0000000..1f7e255 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-iter.h @@ -0,0 +1,554 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_ITER_H +#define BSON_ITER_H + + +#include +#include +#include +#include + + +BSON_BEGIN_DECLS + + +#define BSON_ITER_HOLDS_DOUBLE(iter) (bson_iter_type((iter)) == BSON_TYPE_DOUBLE) + +#define BSON_ITER_HOLDS_UTF8(iter) (bson_iter_type((iter)) == BSON_TYPE_UTF8) + +#define BSON_ITER_HOLDS_DOCUMENT(iter) (bson_iter_type((iter)) == BSON_TYPE_DOCUMENT) + +#define BSON_ITER_HOLDS_ARRAY(iter) (bson_iter_type((iter)) == BSON_TYPE_ARRAY) + +#define BSON_ITER_HOLDS_BINARY(iter) (bson_iter_type((iter)) == BSON_TYPE_BINARY) + +#define BSON_ITER_HOLDS_VECTOR(iter) \ + (BSON_ITER_HOLDS_BINARY(iter) && bson_iter_binary_subtype(iter) == BSON_SUBTYPE_VECTOR) + +#define BSON_ITER_HOLDS_VECTOR_INT8(iter) (bson_vector_int8_const_view_from_iter(NULL, iter)) + +#define BSON_ITER_HOLDS_VECTOR_FLOAT32(iter) (bson_vector_float32_const_view_from_iter(NULL, iter)) + +#define BSON_ITER_HOLDS_VECTOR_PACKED_BIT(iter) (bson_vector_packed_bit_const_view_from_iter(NULL, iter)) + +#define BSON_ITER_HOLDS_UNDEFINED(iter) (bson_iter_type((iter)) == BSON_TYPE_UNDEFINED) + +#define BSON_ITER_HOLDS_OID(iter) (bson_iter_type((iter)) == BSON_TYPE_OID) + +#define BSON_ITER_HOLDS_BOOL(iter) (bson_iter_type((iter)) == BSON_TYPE_BOOL) + +#define BSON_ITER_HOLDS_DATE_TIME(iter) (bson_iter_type((iter)) == BSON_TYPE_DATE_TIME) + +#define BSON_ITER_HOLDS_NULL(iter) (bson_iter_type((iter)) == BSON_TYPE_NULL) + +#define BSON_ITER_HOLDS_REGEX(iter) (bson_iter_type((iter)) == BSON_TYPE_REGEX) + +#define BSON_ITER_HOLDS_DBPOINTER(iter) (bson_iter_type((iter)) == BSON_TYPE_DBPOINTER) + +#define BSON_ITER_HOLDS_CODE(iter) (bson_iter_type((iter)) == BSON_TYPE_CODE) + +#define BSON_ITER_HOLDS_SYMBOL(iter) (bson_iter_type((iter)) == BSON_TYPE_SYMBOL) + +#define BSON_ITER_HOLDS_CODEWSCOPE(iter) (bson_iter_type((iter)) == BSON_TYPE_CODEWSCOPE) + +#define BSON_ITER_HOLDS_INT32(iter) (bson_iter_type((iter)) == BSON_TYPE_INT32) + +#define BSON_ITER_HOLDS_TIMESTAMP(iter) (bson_iter_type((iter)) == BSON_TYPE_TIMESTAMP) + +#define BSON_ITER_HOLDS_INT64(iter) (bson_iter_type((iter)) == BSON_TYPE_INT64) + +#define BSON_ITER_HOLDS_DECIMAL128(iter) (bson_iter_type((iter)) == BSON_TYPE_DECIMAL128) + +#define BSON_ITER_HOLDS_MAXKEY(iter) (bson_iter_type((iter)) == BSON_TYPE_MAXKEY) + +#define BSON_ITER_HOLDS_MINKEY(iter) (bson_iter_type((iter)) == BSON_TYPE_MINKEY) + +#define BSON_ITER_HOLDS_INT(iter) (BSON_ITER_HOLDS_INT32(iter) || BSON_ITER_HOLDS_INT64(iter)) + +#define BSON_ITER_HOLDS_NUMBER(iter) (BSON_ITER_HOLDS_INT(iter) || BSON_ITER_HOLDS_DOUBLE(iter)) + +#define BSON_ITER_IS_KEY(iter, key) (0 == strcmp((key), bson_iter_key((iter)))) + + +BSON_EXPORT(const bson_value_t *) +bson_iter_value(bson_iter_t *iter); + + +/** + * bson_iter_utf8_len_unsafe: + * @iter: a bson_iter_t. + * + * Returns the length of a string currently pointed to by @iter. This performs + * no validation so the is responsible for knowing the BSON is valid. Calling + * bson_validate() is one way to do this ahead of time. + */ +static BSON_INLINE uint32_t +bson_iter_utf8_len_unsafe(const bson_iter_t *iter) +{ + uint32_t raw; + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + memcpy(&raw, iter->raw + iter->d1, sizeof(raw)); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + + const uint32_t native = BSON_UINT32_FROM_LE(raw); + + int32_t len; + memcpy(&len, &native, sizeof(len)); + + return len <= 0 ? 0u : (uint32_t)(len - 1); +} + + +BSON_EXPORT(void) +bson_iter_array(const bson_iter_t *iter, uint32_t *array_len, const uint8_t **array); + + +BSON_EXPORT(void) +bson_iter_binary(const bson_iter_t *iter, bson_subtype_t *subtype, uint32_t *binary_len, const uint8_t **binary); + +BSON_EXPORT(void) +bson_iter_overwrite_binary(bson_iter_t *iter, bson_subtype_t subtype, uint32_t *binary_len, uint8_t **binary); + +BSON_EXPORT(bson_subtype_t) +bson_iter_binary_subtype(const bson_iter_t *iter); + +BSON_EXPORT(bool) +bson_iter_binary_equal(const bson_iter_t *iter_a, const bson_iter_t *iter_b); + + +BSON_EXPORT(const char *) +bson_iter_code(const bson_iter_t *iter, uint32_t *length); + + +/** + * bson_iter_code_unsafe: + * @iter: A bson_iter_t. + * @length: A location for the length of the resulting string. + * + * Like bson_iter_code() but performs no integrity checks. + * + * Returns: A string that should not be modified or freed. + */ +static BSON_INLINE const char * +bson_iter_code_unsafe(const bson_iter_t *iter, uint32_t *length) +{ + *length = bson_iter_utf8_len_unsafe(iter); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + return (const char *)(iter->raw + iter->d2); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END +} + + +BSON_EXPORT(const char *) +bson_iter_codewscope(const bson_iter_t *iter, uint32_t *length, uint32_t *scope_len, const uint8_t **scope); + + +BSON_EXPORT(void) +bson_iter_dbpointer(const bson_iter_t *iter, uint32_t *collection_len, const char **collection, const bson_oid_t **oid); + + +BSON_EXPORT(void) +bson_iter_document(const bson_iter_t *iter, uint32_t *document_len, const uint8_t **document); + + +BSON_EXPORT(double) +bson_iter_double(const bson_iter_t *iter); + +BSON_EXPORT(double) +bson_iter_as_double(const bson_iter_t *iter); + +/** + * bson_iter_double_unsafe: + * @iter: A bson_iter_t. + * + * Similar to bson_iter_double() but does not perform an integrity checking. + * + * Returns: A double. + */ +static BSON_INLINE double +bson_iter_double_unsafe(const bson_iter_t *iter) +{ + double val; + + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + memcpy(&val, iter->raw + iter->d1, sizeof(val)); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + return BSON_DOUBLE_FROM_LE(val); +} + + +BSON_EXPORT(bool) +bson_iter_init(bson_iter_t *iter, const bson_t *bson); + +BSON_EXPORT(bool) +bson_iter_init_from_data(bson_iter_t *iter, const uint8_t *data, size_t length); + + +BSON_EXPORT(bool) +bson_iter_init_find(bson_iter_t *iter, const bson_t *bson, const char *key); + + +BSON_EXPORT(bool) +bson_iter_init_find_w_len(bson_iter_t *iter, const bson_t *bson, const char *key, int keylen); + + +BSON_EXPORT(bool) +bson_iter_init_find_case(bson_iter_t *iter, const bson_t *bson, const char *key); + +BSON_EXPORT(bool) +bson_iter_init_from_data_at_offset( + bson_iter_t *iter, const uint8_t *data, size_t length, uint32_t offset, uint32_t keylen); + +BSON_EXPORT(int32_t) +bson_iter_int32(const bson_iter_t *iter); + + +/** + * bson_iter_int32_unsafe: + * @iter: A bson_iter_t. + * + * Similar to bson_iter_int32() but with no integrity checking. + * + * Returns: A 32-bit signed integer. + */ +static BSON_INLINE int32_t +bson_iter_int32_unsafe(const bson_iter_t *iter) +{ + uint32_t raw; + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + memcpy(&raw, iter->raw + iter->d1, sizeof(raw)); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + + const uint32_t native = BSON_UINT32_FROM_LE(raw); + + int32_t res; + memcpy(&res, &native, sizeof(res)); + return res; +} + + +BSON_EXPORT(int64_t) +bson_iter_int64(const bson_iter_t *iter); + + +BSON_EXPORT(int64_t) +bson_iter_as_int64(const bson_iter_t *iter); + + +/** + * bson_iter_int64_unsafe: + * @iter: a bson_iter_t. + * + * Similar to bson_iter_int64() but without integrity checking. + * + * Returns: A 64-bit signed integer. + */ +static BSON_INLINE int64_t +bson_iter_int64_unsafe(const bson_iter_t *iter) +{ + uint64_t raw; + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + memcpy(&raw, iter->raw + iter->d1, sizeof(raw)); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + + const uint64_t native = BSON_UINT64_FROM_LE(raw); + + int64_t res; + memcpy(&res, &native, sizeof(res)); + return res; +} + + +BSON_EXPORT(bool) +bson_iter_find(bson_iter_t *iter, const char *key); + + +BSON_EXPORT(bool) +bson_iter_find_w_len(bson_iter_t *iter, const char *key, int keylen); + + +BSON_EXPORT(bool) +bson_iter_find_case(bson_iter_t *iter, const char *key); + + +BSON_EXPORT(bool) +bson_iter_find_descendant(bson_iter_t *iter, const char *dotkey, bson_iter_t *descendant); + + +BSON_EXPORT(bool) +bson_iter_next(bson_iter_t *iter); + + +BSON_EXPORT(const bson_oid_t *) +bson_iter_oid(const bson_iter_t *iter); + + +/** + * bson_iter_oid_unsafe: + * @iter: A #bson_iter_t. + * + * Similar to bson_iter_oid() but performs no integrity checks. + * + * Returns: A #bson_oid_t that should not be modified or freed. + */ +static BSON_INLINE const bson_oid_t * +bson_iter_oid_unsafe(const bson_iter_t *iter) +{ + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + return (const bson_oid_t *)(iter->raw + iter->d1); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END +} + + +BSON_EXPORT(bool) +bson_iter_decimal128(const bson_iter_t *iter, bson_decimal128_t *dec); + + +/** + * bson_iter_decimal128_unsafe: + * @iter: A #bson_iter_t. + * + * Similar to bson_iter_decimal128() but performs no integrity checks. + * + * Returns: A #bson_decimal128_t. + */ +static BSON_INLINE void +bson_iter_decimal128_unsafe(const bson_iter_t *iter, bson_decimal128_t *dec) +{ + uint64_t low_le; + uint64_t high_le; + + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + memcpy(&low_le, iter->raw + iter->d1, sizeof(low_le)); + memcpy(&high_le, iter->raw + iter->d1 + 8, sizeof(high_le)); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + + dec->low = BSON_UINT64_FROM_LE(low_le); + dec->high = BSON_UINT64_FROM_LE(high_le); +} + + +BSON_EXPORT(const char *) +bson_iter_key(const bson_iter_t *iter); + +BSON_EXPORT(uint32_t) +bson_iter_key_len(const bson_iter_t *iter); + + +/** + * bson_iter_key_unsafe: + * @iter: A bson_iter_t. + * + * Similar to bson_iter_key() but performs no integrity checking. + * + * Returns: A string that should not be modified or freed. + */ +static BSON_INLINE const char * +bson_iter_key_unsafe(const bson_iter_t *iter) +{ + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + return (const char *)(iter->raw + iter->key); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END +} + + +BSON_EXPORT(const char *) +bson_iter_utf8(const bson_iter_t *iter, uint32_t *length); + + +/** + * bson_iter_utf8_unsafe: + * + * Similar to bson_iter_utf8() but performs no integrity checking. + * + * Returns: A string that should not be modified or freed. + */ +static BSON_INLINE const char * +bson_iter_utf8_unsafe(const bson_iter_t *iter, size_t *length) +{ + *length = bson_iter_utf8_len_unsafe(iter); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + return (const char *)(iter->raw + iter->d2); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END +} + + +BSON_EXPORT(char *) +bson_iter_dup_utf8(const bson_iter_t *iter, uint32_t *length); + + +BSON_EXPORT(int64_t) +bson_iter_date_time(const bson_iter_t *iter); + + +BSON_EXPORT(time_t) +bson_iter_time_t(const bson_iter_t *iter); + + +/** + * bson_iter_time_t_unsafe: + * @iter: A bson_iter_t. + * + * Similar to bson_iter_time_t() but performs no integrity checking. + * + * Returns: A time_t containing the number of seconds since UNIX epoch + * in UTC. + */ +static BSON_INLINE time_t +bson_iter_time_t_unsafe(const bson_iter_t *iter) +{ + return (time_t)(bson_iter_int64_unsafe(iter) / 1000); +} + + +BSON_EXPORT(void) +bson_iter_timeval(const bson_iter_t *iter, struct timeval *tv); + + +/** + * bson_iter_timeval_unsafe: + * @iter: A bson_iter_t. + * @tv: A struct timeval. + * + * Similar to bson_iter_timeval() but performs no integrity checking. + */ +static BSON_INLINE void +bson_iter_timeval_unsafe(const bson_iter_t *iter, struct timeval *tv) +{ + int64_t value = bson_iter_int64_unsafe(iter); +#ifdef BSON_OS_WIN32 + tv->tv_sec = (long)(value / 1000); + tv->tv_usec = (long)(value % 1000) * 1000; +#else + tv->tv_sec = (time_t)(value / 1000); + tv->tv_usec = (suseconds_t)(value % 1000) * 1000; +#endif +} + + +BSON_EXPORT(void) +bson_iter_timestamp(const bson_iter_t *iter, uint32_t *timestamp, uint32_t *increment); + + +BSON_EXPORT(bool) +bson_iter_bool(const bson_iter_t *iter); + + +/** + * bson_iter_bool_unsafe: + * @iter: A bson_iter_t. + * + * Similar to bson_iter_bool() but performs no integrity checking. + * + * Returns: true or false. + */ +static BSON_INLINE bool +bson_iter_bool_unsafe(const bson_iter_t *iter) +{ + char val; + + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + memcpy(&val, iter->raw + iter->d1, 1); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + return !!val; +} + + +BSON_EXPORT(bool) +bson_iter_as_bool(const bson_iter_t *iter); + + +BSON_EXPORT(const char *) +bson_iter_regex(const bson_iter_t *iter, const char **options); + + +BSON_EXPORT(const char *) +bson_iter_symbol(const bson_iter_t *iter, uint32_t *length); + + +BSON_EXPORT(bson_type_t) +bson_iter_type(const bson_iter_t *iter); + + +/** + * bson_iter_type_unsafe: + * @iter: A bson_iter_t. + * + * Similar to bson_iter_type() but performs no integrity checking. + * + * Returns: A bson_type_t. + */ +static BSON_INLINE bson_type_t +bson_iter_type_unsafe(const bson_iter_t *iter) +{ + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + return (bson_type_t)(iter->raw + iter->type)[0]; + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END +} + + +BSON_EXPORT(bool) +bson_iter_recurse(const bson_iter_t *iter, bson_iter_t *child); + + +BSON_EXPORT(void) +bson_iter_overwrite_int32(bson_iter_t *iter, int32_t value); + + +BSON_EXPORT(void) +bson_iter_overwrite_int64(bson_iter_t *iter, int64_t value); + + +BSON_EXPORT(void) +bson_iter_overwrite_double(bson_iter_t *iter, double value); + + +BSON_EXPORT(void) +bson_iter_overwrite_decimal128(bson_iter_t *iter, const bson_decimal128_t *value); + + +BSON_EXPORT(void) +bson_iter_overwrite_bool(bson_iter_t *iter, bool value); + + +BSON_EXPORT(void) +bson_iter_overwrite_oid(bson_iter_t *iter, const bson_oid_t *value); + + +BSON_EXPORT(void) +bson_iter_overwrite_timestamp(bson_iter_t *iter, uint32_t timestamp, uint32_t increment); + + +BSON_EXPORT(void) +bson_iter_overwrite_date_time(bson_iter_t *iter, int64_t value); + + +BSON_EXPORT(bool) +bson_iter_visit_all(bson_iter_t *iter, const bson_visitor_t *visitor, void *data); + +BSON_EXPORT(uint32_t) +bson_iter_offset(bson_iter_t *iter); + + +BSON_END_DECLS + + +#endif /* BSON_ITER_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-json.h b/Vendor/mongo-c-driver/include/bson/bson-json.h new file mode 100644 index 0000000..6fe8adb --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-json.h @@ -0,0 +1,91 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_JSON_H +#define BSON_JSON_H + + +#include + + +BSON_BEGIN_DECLS + + +typedef struct _bson_json_reader_t bson_json_reader_t; + + +typedef enum { + BSON_JSON_ERROR_READ_CORRUPT_JS = 1, + BSON_JSON_ERROR_READ_INVALID_PARAM, + BSON_JSON_ERROR_READ_CB_FAILURE, +} bson_json_error_code_t; + + +/** + * BSON_MAX_LEN_UNLIMITED + * + * Denotes unlimited length limit when converting BSON to JSON. + */ +#define BSON_MAX_LEN_UNLIMITED -1 + +/** + * bson_json_mode_t: + * + * This enumeration contains the different modes to serialize BSON into extended + * JSON. + */ +typedef enum { + BSON_JSON_MODE_LEGACY, + BSON_JSON_MODE_CANONICAL, + BSON_JSON_MODE_RELAXED, +} bson_json_mode_t; + + +BSON_EXPORT(bson_json_opts_t *) +bson_json_opts_new(bson_json_mode_t mode, int32_t max_len); +BSON_EXPORT(void) +bson_json_opts_destroy(bson_json_opts_t *opts); +BSON_EXPORT(void) +bson_json_opts_set_outermost_array(bson_json_opts_t *opts, bool is_outermost_array); + +typedef ssize_t(BSON_CALL *bson_json_reader_cb)(void *handle, uint8_t *buf, size_t count); +typedef void(BSON_CALL *bson_json_destroy_cb)(void *handle); + + +BSON_EXPORT(bson_json_reader_t *) +bson_json_reader_new( + void *data, bson_json_reader_cb cb, bson_json_destroy_cb dcb, bool allow_multiple, size_t buf_size); +BSON_EXPORT(bson_json_reader_t *) +bson_json_reader_new_from_fd(int fd, bool close_on_destroy); +BSON_EXPORT(bson_json_reader_t *) +bson_json_reader_new_from_file(const char *filename, bson_error_t *error); +BSON_EXPORT(void) +bson_json_reader_destroy(bson_json_reader_t *reader); +BSON_EXPORT(int) +bson_json_reader_read(bson_json_reader_t *reader, bson_t *bson, bson_error_t *error); +BSON_EXPORT(bson_json_reader_t *) +bson_json_data_reader_new(bool allow_multiple, size_t size); +BSON_EXPORT(void) +bson_json_data_reader_ingest(bson_json_reader_t *reader, const uint8_t *data, size_t len); + + +BSON_END_DECLS + + +#endif /* BSON_JSON_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-keys.h b/Vendor/mongo-c-driver/include/bson/bson-keys.h new file mode 100644 index 0000000..2c90b95 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-keys.h @@ -0,0 +1,38 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_KEYS_H +#define BSON_KEYS_H + + +#include +#include + + +BSON_BEGIN_DECLS + + +BSON_EXPORT(size_t) +bson_uint32_to_string(uint32_t value, const char **strptr, char *str, size_t size); + + +BSON_END_DECLS + + +#endif /* BSON_KEYS_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-oid.h b/Vendor/mongo-c-driver/include/bson/bson-oid.h new file mode 100644 index 0000000..d63aa07 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-oid.h @@ -0,0 +1,244 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_OID_H +#define BSON_OID_H + + +#include +#include +#include +#include + +#include + + +BSON_BEGIN_DECLS + + +BSON_EXPORT(int) +bson_oid_compare(const bson_oid_t *oid1, const bson_oid_t *oid2); +BSON_EXPORT(void) +bson_oid_copy(const bson_oid_t *src, bson_oid_t *dst); +BSON_EXPORT(bool) +bson_oid_equal(const bson_oid_t *oid1, const bson_oid_t *oid2); +BSON_EXPORT(bool) +bson_oid_is_valid(const char *str, size_t length); +BSON_EXPORT(time_t) +bson_oid_get_time_t(const bson_oid_t *oid); +BSON_EXPORT(uint32_t) +bson_oid_hash(const bson_oid_t *oid); +BSON_EXPORT(void) +bson_oid_init(bson_oid_t *oid, bson_context_t *context); +BSON_EXPORT(void) +bson_oid_init_from_data(bson_oid_t *oid, const uint8_t *data); +BSON_EXPORT(void) +bson_oid_init_from_string(bson_oid_t *oid, const char *str); +BSON_EXPORT(void) +bson_oid_to_string(const bson_oid_t *oid, char str[25]); + + +/** + * bson_oid_compare_unsafe: + * @oid1: A bson_oid_t. + * @oid2: A bson_oid_t. + * + * Performs a qsort() style comparison between @oid1 and @oid2. + * + * This function is meant to be as fast as possible and therefore performs + * no argument validation. That is the callers responsibility. + * + * Returns: An integer < 0 if @oid1 is less than @oid2. Zero if they are equal. + * An integer > 0 if @oid1 is greater than @oid2. + */ +static BSON_INLINE int +bson_oid_compare_unsafe(const bson_oid_t *oid1, const bson_oid_t *oid2) +{ + return memcmp(oid1, oid2, sizeof *oid1); +} + + +/** + * bson_oid_equal_unsafe: + * @oid1: A bson_oid_t. + * @oid2: A bson_oid_t. + * + * Checks the equality of @oid1 and @oid2. + * + * This function is meant to be as fast as possible and therefore performs + * no checks for argument validity. That is the callers responsibility. + * + * Returns: true if @oid1 and @oid2 are equal; otherwise false. + */ +static BSON_INLINE bool +bson_oid_equal_unsafe(const bson_oid_t *oid1, const bson_oid_t *oid2) +{ + return !memcmp(oid1, oid2, sizeof *oid1); +} + +/** + * bson_oid_hash_unsafe: + * @oid: A bson_oid_t. + * + * This function performs a DJB style hash upon the bytes contained in @oid. + * The result is a hash key suitable for use in a hashtable. + * + * This function is meant to be as fast as possible and therefore performs no + * validation of arguments. The caller is responsible to ensure they are + * passing valid arguments. + * + * Returns: A uint32_t containing a hash code. + */ +static BSON_INLINE uint32_t +bson_oid_hash_unsafe(const bson_oid_t *oid) +{ + uint32_t hash = 5381; + uint32_t i; + + for (i = 0; i < sizeof oid->bytes; i++) { + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + hash = ((hash << 5) + hash) + oid->bytes[i]; + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + } + + return hash; +} + + +/** + * bson_oid_copy_unsafe: + * @src: A bson_oid_t to copy from. + * @dst: A bson_oid_t to copy into. + * + * Copies the contents of @src into @dst. This function is meant to be as + * fast as possible and therefore performs no argument checking. It is the + * callers responsibility to ensure they are passing valid data into the + * function. + */ +static BSON_INLINE void +bson_oid_copy_unsafe(const bson_oid_t *src, bson_oid_t *dst) +{ + memcpy(dst, src, sizeof *src); +} + + +/** + * bson_oid_parse_hex_char: + * @hex: A character to parse to its integer value. + * + * This function contains a jump table to return the integer value for a + * character containing a hexadecimal value (0-9, a-f, A-F). If the character + * is not a hexadecimal character then zero is returned. + * + * Returns: An integer between 0 and 15. + */ +static BSON_INLINE uint8_t +bson_oid_parse_hex_char(char hex) +{ + switch (hex) { + case '0': + return 0; + case '1': + return 1; + case '2': + return 2; + case '3': + return 3; + case '4': + return 4; + case '5': + return 5; + case '6': + return 6; + case '7': + return 7; + case '8': + return 8; + case '9': + return 9; + case 'a': + case 'A': + return 0xa; + case 'b': + case 'B': + return 0xb; + case 'c': + case 'C': + return 0xc; + case 'd': + case 'D': + return 0xd; + case 'e': + case 'E': + return 0xe; + case 'f': + case 'F': + return 0xf; + default: + return 0; + } +} + + +/** + * bson_oid_init_from_string_unsafe: + * @oid: A bson_oid_t to store the result. + * @str: A 24-character hexadecimal encoded string. + * + * Parses a string containing 24 hexadecimal encoded bytes into a bson_oid_t. + * This function is meant to be as fast as possible and inlined into your + * code. For that purpose, the function does not perform any sort of bounds + * checking and it is the callers responsibility to ensure they are passing + * valid input to the function. + */ +static BSON_INLINE void +bson_oid_init_from_string_unsafe(bson_oid_t *oid, const char *str) +{ + int i; + + for (i = 0; i < 12; i++) { + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + oid->bytes[i] = (uint8_t)((bson_oid_parse_hex_char(str[2 * i]) << 4) | (bson_oid_parse_hex_char(str[2 * i + 1]))); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + } +} + + +/** + * bson_oid_get_time_t_unsafe: + * @oid: A bson_oid_t. + * + * Fetches the time @oid was generated. + * + * Returns: A time_t containing the UNIX timestamp of generation. + */ +static BSON_INLINE time_t +bson_oid_get_time_t_unsafe(const bson_oid_t *oid) +{ + uint32_t t; + + memcpy(&t, oid, sizeof(t)); + return BSON_UINT32_FROM_BE(t); +} + + +BSON_END_DECLS + + +#endif /* BSON_OID_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-prelude.h b/Vendor/mongo-c-driver/include/bson/bson-prelude.h new file mode 100644 index 0000000..adbbf14 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-prelude.h @@ -0,0 +1,19 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if !defined(BSON_INSIDE) && !defined(BSON_COMPILATION) +#error "Only can be included directly." +#endif diff --git a/Vendor/mongo-c-driver/include/bson/bson-reader.h b/Vendor/mongo-c-driver/include/bson/bson-reader.h new file mode 100644 index 0000000..c557573 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-reader.h @@ -0,0 +1,114 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_READER_H +#define BSON_READER_H + + +#include +#include +#include + + +BSON_BEGIN_DECLS + + +#define BSON_ERROR_READER_BADFD 1 + + +/* + *-------------------------------------------------------------------------- + * + * bson_reader_read_func_t -- + * + * This function is a callback used by bson_reader_t to read the + * next chunk of data from the underlying opaque file descriptor. + * + * This function is meant to operate similar to the read() function + * as part of libc on UNIX-like systems. + * + * Parameters: + * @handle: The handle to read from. + * @buf: The buffer to read into. + * @count: The number of bytes to read. + * + * Returns: + * 0 for end of stream. + * -1 for read failure. + * Greater than zero for number of bytes read into @buf. + * + * Side effects: + * None. + * + *-------------------------------------------------------------------------- + */ + +typedef ssize_t(BSON_CALL *bson_reader_read_func_t)(void *handle, /* IN */ + void *buf, /* IN */ + size_t count); /* IN */ + + +/* + *-------------------------------------------------------------------------- + * + * bson_reader_destroy_func_t -- + * + * Destroy callback to release any resources associated with the + * opaque handle. + * + * Parameters: + * @handle: the handle provided to bson_reader_new_from_handle(). + * + * Returns: + * None. + * + * Side effects: + * None. + * + *-------------------------------------------------------------------------- + */ + +typedef void(BSON_CALL *bson_reader_destroy_func_t)(void *handle); /* IN */ + + +BSON_EXPORT(bson_reader_t *) +bson_reader_new_from_handle(void *handle, bson_reader_read_func_t rf, bson_reader_destroy_func_t df); +BSON_EXPORT(bson_reader_t *) +bson_reader_new_from_fd(int fd, bool close_on_destroy); +BSON_EXPORT(bson_reader_t *) +bson_reader_new_from_file(const char *path, bson_error_t *error); +BSON_EXPORT(bson_reader_t *) +bson_reader_new_from_data(const uint8_t *data, size_t length); +BSON_EXPORT(void) +bson_reader_destroy(bson_reader_t *reader); +BSON_EXPORT(void) +bson_reader_set_read_func(bson_reader_t *reader, bson_reader_read_func_t func); +BSON_EXPORT(void) +bson_reader_set_destroy_func(bson_reader_t *reader, bson_reader_destroy_func_t func); +BSON_EXPORT(const bson_t *) +bson_reader_read(bson_reader_t *reader, bool *reached_eof); +BSON_EXPORT(off_t) +bson_reader_tell(bson_reader_t *reader); +BSON_EXPORT(void) +bson_reader_reset(bson_reader_t *reader); + +BSON_END_DECLS + + +#endif /* BSON_READER_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-string.h b/Vendor/mongo-c-driver/include/bson/bson-string.h new file mode 100644 index 0000000..ab95600 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-string.h @@ -0,0 +1,72 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_STRING_H +#define BSON_STRING_H + + +#include +#include + +#include + + +BSON_BEGIN_DECLS + +BSON_EXPORT(char *) +bson_strdup(const char *str); + +BSON_EXPORT(char *) +bson_strdup_printf(const char *format, ...) BSON_GNUC_PRINTF(1, 2); + +BSON_EXPORT(char *) +bson_strdupv_printf(const char *format, va_list args) BSON_GNUC_PRINTF(1, 0); + +BSON_EXPORT(char *) +bson_strndup(const char *str, size_t n_bytes); + +BSON_EXPORT(void) +bson_strncpy(char *dst, const char *src, size_t size); + +BSON_EXPORT(int) +bson_vsnprintf(char *str, size_t size, const char *format, va_list ap) BSON_GNUC_PRINTF(3, 0); + +BSON_EXPORT(int) +bson_snprintf(char *str, size_t size, const char *format, ...) BSON_GNUC_PRINTF(3, 4); + +BSON_EXPORT(void) +bson_strfreev(char **strv); + +BSON_EXPORT(size_t) +bson_strnlen(const char *s, size_t maxlen); + +BSON_EXPORT(int64_t) +bson_ascii_strtoll(const char *str, char **endptr, int base); + +BSON_EXPORT(int) +bson_strcasecmp(const char *s1, const char *s2); + +BSON_EXPORT(bool) +bson_isspace(int c); + + +BSON_END_DECLS + + +#endif /* BSON_STRING_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-types.h b/Vendor/mongo-c-driver/include/bson/bson-types.h new file mode 100644 index 0000000..262d5a1 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-types.h @@ -0,0 +1,475 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_TYPES_H +#define BSON_TYPES_H + +#include +#include +#include +#include +#include +#include + +#include + +#include + +BSON_BEGIN_DECLS + + +/* + *-------------------------------------------------------------------------- + * + * bson_unichar_t -- + * + * bson_unichar_t provides an unsigned 32-bit type for containing + * unicode characters. When iterating UTF-8 sequences, this should + * be used to avoid losing the high-bits of non-ascii characters. + * + *-------------------------------------------------------------------------- + */ + +typedef uint32_t bson_unichar_t; + + +/** + * @brief Flags configuring the creation of a bson_context_t + */ +typedef enum { + /** Use default options */ + BSON_CONTEXT_NONE = 0, + /* Deprecated: Generating new OIDs from a bson_context_t is always + thread-safe */ + BSON_CONTEXT_THREAD_SAFE = (1 << 0), + /* Deprecated: Does nothing and is ignored */ + BSON_CONTEXT_DISABLE_HOST_CACHE = (1 << 1), + /* Call getpid() instead of remembering the result of getpid() when using the + context */ + BSON_CONTEXT_DISABLE_PID_CACHE = (1 << 2), + /* Deprecated: Does nothing */ + BSON_CONTEXT_USE_TASK_ID = (1 << 3), +} bson_context_flags_t; + + +/** + * bson_context_t: + * + * This structure manages context for the bson library. It handles + * configuration for thread-safety and other performance related requirements. + * Consumers will create a context and may use multiple under a variety of + * situations. + * + * If your program calls fork(), you should initialize a new bson_context_t + * using bson_context_init(). + * + * If you are using threading, it is suggested that you use a bson_context_t + * per thread for best performance. Alternatively, you can initialize the + * bson_context_t with BSON_CONTEXT_THREAD_SAFE, although a performance penalty + * will be incurred. + * + * Many functions will require that you provide a bson_context_t such as OID + * generation. + * + * This structure is opaque in that you cannot see the contents of the + * structure. However, it is stack allocatable in that enough padding is + * provided in _bson_context_t to hold the structure. + */ +typedef struct _bson_context_t bson_context_t; + +/** + * bson_json_opts_t: + * + * This structure is used to pass options for serializing BSON into extended + * JSON to the respective serialization methods. + * + * max_len can be either a non-negative integer, or BSON_MAX_LEN_UNLIMITED to + * set no limit for serialization length. + */ +typedef struct _bson_json_opts_t bson_json_opts_t; + + +/** + * bson_oid_t: + * + * This structure contains the binary form of a BSON Object Id as specified + * on http://bsonspec.org. If you would like the bson_oid_t in string form + * see bson_oid_to_string() or bson_oid_to_string_r(). + */ +typedef struct { + uint8_t bytes[12]; +} bson_oid_t; + +BSON_STATIC_ASSERT2(oid_t, sizeof(bson_oid_t) == 12); + +/** + * bson_decimal128_t: + * + * @high The high-order bytes of the decimal128. This field contains sign, + * combination bits, exponent, and part of the coefficient continuation. + * @low The low-order bytes of the decimal128. This field contains the second + * part of the coefficient continuation. + * + * This structure is a boxed type containing the value for the BSON decimal128 + * type. The structure stores the 128 bits such that they correspond to the + * native format for the IEEE decimal128 type, if it is implemented. + **/ +typedef struct { +#if BSON_BYTE_ORDER == BSON_LITTLE_ENDIAN + uint64_t low; + uint64_t high; +#elif BSON_BYTE_ORDER == BSON_BIG_ENDIAN + uint64_t high; + uint64_t low; +#endif +} bson_decimal128_t; + + +/** + * @brief Flags and error codes for BSON validation functions. + * + * Pass these flags bits to control the behavior of the `bson_validate` family + * of functions. + * + * Additionally, if validation fails, then the error code set on a `bson_error_t` + * will have the value corresponding to the reason that validation failed. + */ +typedef enum { + /** + * @brief No special validation behavior specified. + */ + BSON_VALIDATE_NONE = 0, + /** + * @brief Check that all text components of the BSON data are valid UTF-8. + * + * Note that this will also cause validation to reject valid text that contains + * a null character. This can be changed by also passing + * `BSON_VALIDATE_UTF8_ALLOW_NULL` + */ + BSON_VALIDATE_UTF8 = (1 << 0), + /** + * @brief Check that element keys do not begin with an ASCII dollar `$` + */ + BSON_VALIDATE_DOLLAR_KEYS = (1 << 1), + /** + * @brief Check that element keys do not contain an ASCII period `.` + */ + BSON_VALIDATE_DOT_KEYS = (1 << 2), + /** + * @brief If set then it is *not* an error for a UTF-8 string to contain + * embedded null characters. + * + * This has no effect unless `BSON_VALIDATE_UTF8` is also passed. + */ + BSON_VALIDATE_UTF8_ALLOW_NULL = (1 << 3), + /** + * @brief Check that no element key is a zero-length empty string. + */ + BSON_VALIDATE_EMPTY_KEYS = (1 << 4), + /** + * @brief This is not a flag that controls behavior, but is instead used to indicate + * that a BSON document is corrupted in some way. This is the value that will + * appear as an error code. + * + * Passing this as a flag has no effect. + */ + BSON_VALIDATE_CORRUPT = (1 << 5), +} bson_validate_flags_t; + + +/** + * bson_type_t: + * + * This enumeration contains all of the possible types within a BSON document. + * Use bson_iter_type() to fetch the type of a field while iterating over it. + */ +typedef enum { + BSON_TYPE_EOD = 0x00, + BSON_TYPE_DOUBLE = 0x01, + BSON_TYPE_UTF8 = 0x02, + BSON_TYPE_DOCUMENT = 0x03, + BSON_TYPE_ARRAY = 0x04, + BSON_TYPE_BINARY = 0x05, + BSON_TYPE_UNDEFINED = 0x06, + BSON_TYPE_OID = 0x07, + BSON_TYPE_BOOL = 0x08, + BSON_TYPE_DATE_TIME = 0x09, + BSON_TYPE_NULL = 0x0A, + BSON_TYPE_REGEX = 0x0B, + BSON_TYPE_DBPOINTER = 0x0C, + BSON_TYPE_CODE = 0x0D, + BSON_TYPE_SYMBOL = 0x0E, + BSON_TYPE_CODEWSCOPE = 0x0F, + BSON_TYPE_INT32 = 0x10, + BSON_TYPE_TIMESTAMP = 0x11, + BSON_TYPE_INT64 = 0x12, + BSON_TYPE_DECIMAL128 = 0x13, + BSON_TYPE_MAXKEY = 0x7F, + BSON_TYPE_MINKEY = 0xFF, +} bson_type_t; + + +/** + * bson_subtype_t: + * + * This enumeration contains the various subtypes that may be used in a binary + * field. See http://bsonspec.org for more information. + */ +typedef enum { + BSON_SUBTYPE_BINARY = 0x00, + BSON_SUBTYPE_FUNCTION = 0x01, + BSON_SUBTYPE_BINARY_DEPRECATED = 0x02, + BSON_SUBTYPE_UUID_DEPRECATED = 0x03, + BSON_SUBTYPE_UUID = 0x04, + BSON_SUBTYPE_MD5 = 0x05, + BSON_SUBTYPE_ENCRYPTED = 0x06, + BSON_SUBTYPE_COLUMN = 0x07, + BSON_SUBTYPE_SENSITIVE = 0x08, + BSON_SUBTYPE_VECTOR = 0x09, + BSON_SUBTYPE_USER = 0x80, +} bson_subtype_t; + + +/* + *-------------------------------------------------------------------------- + * + * bson_value_t -- + * + * A boxed type to contain various bson_type_t types. + * + * See also: + * bson_value_copy() + * bson_value_destroy() + * + *-------------------------------------------------------------------------- + */ + +typedef struct _bson_value_t { + bson_type_t value_type; + int32_t padding; + union { + bson_oid_t v_oid; + int64_t v_int64; + int32_t v_int32; + int8_t v_int8; + double v_double; + bool v_bool; + int64_t v_datetime; + struct { + uint32_t timestamp; + uint32_t increment; + } v_timestamp; + struct { + char *str; + uint32_t len; + } v_utf8; + struct { + uint8_t *data; + uint32_t data_len; + } v_doc; + struct { + uint8_t *data; + uint32_t data_len; + bson_subtype_t subtype; + } v_binary; + struct { + char *regex; + char *options; + } v_regex; + struct { + char *collection; + uint32_t collection_len; + bson_oid_t oid; + } v_dbpointer; + struct { + char *code; + uint32_t code_len; + } v_code; + struct { + char *code; + uint8_t *scope_data; + uint32_t code_len; + uint32_t scope_len; + } v_codewscope; + struct { + char *symbol; + uint32_t len; + } v_symbol; + bson_decimal128_t v_decimal128; + } value; +} bson_value_t; + + +/** + * bson_iter_t: + * + * This structure manages iteration over a bson_t structure. It keeps track + * of the location of the current key and value within the buffer. Using the + * various functions to get the value of the iter will read from these + * locations. + * + * This structure is safe to discard on the stack. No cleanup is necessary + * after using it. + */ +typedef struct { + const uint8_t *raw; /* The raw buffer being iterated. */ + uint32_t len; /* The length of raw. */ + uint32_t off; /* The offset within the buffer. */ + uint32_t type; /* The offset of the type byte. */ + uint32_t key; /* The offset of the key byte. */ + uint32_t d1; /* The offset of the first data byte. */ + uint32_t d2; /* The offset of the second data byte. */ + uint32_t d3; /* The offset of the third data byte. */ + uint32_t d4; /* The offset of the fourth data byte. */ + uint32_t next_off; /* The offset of the next field. */ + uint32_t err_off; /* The offset of the error. */ + bson_value_t value; /* Internal value for various state. */ +} bson_iter_t; + + +/** + * bson_reader_t: + * + * This structure is used to iterate over a sequence of BSON documents. It + * allows for them to be iterated with the possibility of no additional + * memory allocations under certain circumstances such as reading from an + * incoming mongo packet. + */ +BSON_ALIGNED_BEGIN(BSON_ALIGN_OF_PTR) +typedef struct { + uint32_t type; + /**< private >**/ +} bson_reader_t BSON_ALIGNED_END(BSON_ALIGN_OF_PTR); + + +/** + * bson_visitor_t: + * + * This structure contains a series of pointers that can be executed for + * each field of a BSON document based on the field type. + * + * For example, if an int32 field is found, visit_int32 will be called. + * + * When visiting each field using bson_iter_visit_all(), you may provide a + * data pointer that will be provided with each callback. This might be useful + * if you are marshaling to another language. + * + * You may pre-maturely stop the visitation of fields by returning true in your + * visitor. Returning false will continue visitation to further fields. + */ +typedef struct { + /* run before / after descending into a document */ + bool(BSON_CALL *visit_before)(const bson_iter_t *iter, const char *key, void *data); + bool(BSON_CALL *visit_after)(const bson_iter_t *iter, const char *key, void *data); + /* corrupt BSON, or unsupported type and visit_unsupported_type not set */ + void(BSON_CALL *visit_corrupt)(const bson_iter_t *iter, void *data); + /* normal bson field callbacks */ + bool(BSON_CALL *visit_double)(const bson_iter_t *iter, const char *key, double v_double, void *data); + bool(BSON_CALL *visit_utf8)( + const bson_iter_t *iter, const char *key, size_t v_utf8_len, const char *v_utf8, void *data); + bool(BSON_CALL *visit_document)(const bson_iter_t *iter, const char *key, const bson_t *v_document, void *data); + bool(BSON_CALL *visit_array)(const bson_iter_t *iter, const char *key, const bson_t *v_array, void *data); + bool(BSON_CALL *visit_binary)(const bson_iter_t *iter, + const char *key, + bson_subtype_t v_subtype, + size_t v_binary_len, + const uint8_t *v_binary, + void *data); + /* normal field with deprecated "Undefined" BSON type */ + bool(BSON_CALL *visit_undefined)(const bson_iter_t *iter, const char *key, void *data); + bool(BSON_CALL *visit_oid)(const bson_iter_t *iter, const char *key, const bson_oid_t *v_oid, void *data); + bool(BSON_CALL *visit_bool)(const bson_iter_t *iter, const char *key, bool v_bool, void *data); + bool(BSON_CALL *visit_date_time)(const bson_iter_t *iter, const char *key, int64_t msec_since_epoch, void *data); + bool(BSON_CALL *visit_null)(const bson_iter_t *iter, const char *key, void *data); + bool(BSON_CALL *visit_regex)( + const bson_iter_t *iter, const char *key, const char *v_regex, const char *v_options, void *data); + bool(BSON_CALL *visit_dbpointer)(const bson_iter_t *iter, + const char *key, + size_t v_collection_len, + const char *v_collection, + const bson_oid_t *v_oid, + void *data); + bool(BSON_CALL *visit_code)( + const bson_iter_t *iter, const char *key, size_t v_code_len, const char *v_code, void *data); + bool(BSON_CALL *visit_symbol)( + const bson_iter_t *iter, const char *key, size_t v_symbol_len, const char *v_symbol, void *data); + bool(BSON_CALL *visit_codewscope)(const bson_iter_t *iter, + const char *key, + size_t v_code_len, + const char *v_code, + const bson_t *v_scope, + void *data); + bool(BSON_CALL *visit_int32)(const bson_iter_t *iter, const char *key, int32_t v_int32, void *data); + bool(BSON_CALL *visit_timestamp)( + const bson_iter_t *iter, const char *key, uint32_t v_timestamp, uint32_t v_increment, void *data); + bool(BSON_CALL *visit_int64)(const bson_iter_t *iter, const char *key, int64_t v_int64, void *data); + bool(BSON_CALL *visit_maxkey)(const bson_iter_t *iter, const char *key, void *data); + bool(BSON_CALL *visit_minkey)(const bson_iter_t *iter, const char *key, void *data); + /* if set, called instead of visit_corrupt when an apparently valid BSON + * includes an unrecognized field type (reading future version of BSON) */ + void(BSON_CALL *visit_unsupported_type)(const bson_iter_t *iter, const char *key, uint32_t type_code, void *data); + bool(BSON_CALL *visit_decimal128)(const bson_iter_t *iter, + const char *key, + const bson_decimal128_t *v_decimal128, + void *data); + + void *padding[7]; +} bson_visitor_t; + + +/** + * bson_next_power_of_two: + * @v: A 32-bit unsigned integer of required bytes. + * + * Determines the next larger power of two for the value of @v + * in a constant number of operations. + * + * It is up to the caller to guarantee this will not overflow. + * + * Returns: The next power of 2 from @v. + */ +static BSON_INLINE size_t +bson_next_power_of_two(size_t v) +{ + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; +#if BSON_WORD_SIZE == 64 + v |= v >> 32; +#endif + v++; + + return v; +} + + +static BSON_INLINE bool +bson_is_power_of_two(uint32_t v) +{ + return ((v != 0) && ((v & (v - 1)) == 0)); +} + + +BSON_END_DECLS + + +#endif /* BSON_TYPES_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-utf8.h b/Vendor/mongo-c-driver/include/bson/bson-utf8.h new file mode 100644 index 0000000..7720879 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-utf8.h @@ -0,0 +1,46 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_UTF8_H +#define BSON_UTF8_H + + +#include +#include + + +BSON_BEGIN_DECLS + + +BSON_EXPORT(bool) +bson_utf8_validate(const char *utf8, size_t utf8_len, bool allow_null); +BSON_EXPORT(char *) +bson_utf8_escape_for_json(const char *utf8, ssize_t utf8_len); +BSON_EXPORT(bson_unichar_t) +bson_utf8_get_char(const char *utf8); +BSON_EXPORT(const char *) +bson_utf8_next_char(const char *utf8); +BSON_EXPORT(void) +bson_utf8_from_unichar(bson_unichar_t unichar, char utf8[6], uint32_t *len); + + +BSON_END_DECLS + + +#endif /* BSON_UTF8_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-value.h b/Vendor/mongo-c-driver/include/bson/bson-value.h new file mode 100644 index 0000000..cbd66d7 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-value.h @@ -0,0 +1,40 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef BSON_VALUE_H +#define BSON_VALUE_H + + +#include +#include + + +BSON_BEGIN_DECLS + + +BSON_EXPORT(void) +bson_value_copy(const bson_value_t *src, bson_value_t *dst); +BSON_EXPORT(void) +bson_value_destroy(bson_value_t *value); + + +BSON_END_DECLS + + +#endif /* BSON_VALUE_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-vector.h b/Vendor/mongo-c-driver/include/bson/bson-vector.h new file mode 100644 index 0000000..f58c982 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-vector.h @@ -0,0 +1,615 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef BSON_VECTOR_H +#define BSON_VECTOR_H + +#include +#include +#include +#include +#include + +BSON_BEGIN_DECLS + + +// Length of the required header for BSON_SUBTYPE_VECTOR, in bytes +#define BSON_VECTOR_HEADER_LEN 2 + +// Forward declaration (typedef bson_array_builder_t in bson.h) +struct _bson_array_builder_t; + +/** @brief Error codes for domain BSON_ERROR_VECTOR */ +typedef enum { + BSON_VECTOR_ERROR_ARRAY_ELEMENT_TYPE = 1, + BSON_VECTOR_ERROR_ARRAY_ELEMENT_VALUE, + BSON_VECTOR_ERROR_ARRAY_KEY, + BSON_VECTOR_ERROR_MAX_SIZE, +} bson_vector_error_code_t; + + +/** @brief Implementation detail. A copy of the BSON_SUBTYPE_VECTOR header, suitable for pass-by-value. */ +typedef struct bson_vector_binary_header_impl_t { + uint8_t bytes[BSON_VECTOR_HEADER_LEN]; +} bson_vector_binary_header_impl_t; + +/** @brief Implementation detail. A reference to non-owned const BSON Binary data of subtype BSON_SUBTYPE_VECTOR */ +typedef struct bson_vector_binary_const_view_impl_t { + const uint8_t *data; + uint32_t data_len; + bson_vector_binary_header_impl_t header_copy; +} bson_vector_binary_const_view_impl_t; + +/** @brief Implementation detail. A reference to non-owned BSON Binary data of subtype BSON_SUBTYPE_VECTOR */ +typedef struct bson_vector_binary_view_impl_t { + uint8_t *data; + uint32_t data_len; + bson_vector_binary_header_impl_t header_copy; +} bson_vector_binary_view_impl_t; + +/** @brief Implementation detail. Obtain a const reference from a non-const reference without re-validating. */ +static BSON_INLINE bson_vector_binary_const_view_impl_t +bson_vector_binary_view_impl_as_const(bson_vector_binary_view_impl_t view) +{ + bson_vector_binary_const_view_impl_t result; + result.data = view.data; + result.data_len = view.data_len; + result.header_copy = view.header_copy; + return result; +} + + +/** @brief A reference to non-owned BSON Binary data holding a valid Vector of int8 element type */ +typedef struct bson_vector_int8_view_t { + bson_vector_binary_view_impl_t binary; +} bson_vector_int8_view_t; + +/** @brief A reference to non-owned const BSON Binary data holding a valid Vector of int8 element type */ +typedef struct bson_vector_int8_const_view_t { + bson_vector_binary_const_view_impl_t binary; +} bson_vector_int8_const_view_t; + +/** @brief A reference to non-owned BSON Binary data holding a valid Vector of float32 element type */ +typedef struct bson_vector_float32_view_t { + bson_vector_binary_view_impl_t binary; +} bson_vector_float32_view_t; + +/** @brief A reference to non-owned const BSON Binary data holding a valid Vector of float32 element type */ +typedef struct bson_vector_float32_const_view_t { + bson_vector_binary_const_view_impl_t binary; +} bson_vector_float32_const_view_t; + +/** @brief A reference to non-owned BSON Binary data holding a valid Vector of packed_bit */ +typedef struct bson_vector_packed_bit_view_t { + bson_vector_binary_view_impl_t binary; +} bson_vector_packed_bit_view_t; + +/** @brief A reference to non-owned const BSON Binary data holding a valid Vector of packed_bit */ +typedef struct bson_vector_packed_bit_const_view_t { + bson_vector_binary_const_view_impl_t binary; +} bson_vector_packed_bit_const_view_t; + + +static BSON_INLINE bson_vector_int8_const_view_t +bson_vector_int8_view_as_const(bson_vector_int8_view_t view) +{ + bson_vector_int8_const_view_t result; + result.binary = bson_vector_binary_view_impl_as_const(view.binary); + return result; +} + +static BSON_INLINE bson_vector_float32_const_view_t +bson_vector_float32_view_as_const(bson_vector_float32_view_t view) +{ + bson_vector_float32_const_view_t result; + result.binary = bson_vector_binary_view_impl_as_const(view.binary); + return result; +} + +static BSON_INLINE bson_vector_packed_bit_const_view_t +bson_vector_packed_bit_view_as_const(bson_vector_packed_bit_view_t view) +{ + bson_vector_packed_bit_const_view_t result; + result.binary = bson_vector_binary_view_impl_as_const(view.binary); + return result; +} + + +BSON_EXPORT(bool) +bson_vector_int8_view_init(bson_vector_int8_view_t *view_out, uint8_t *binary_data, uint32_t binary_data_len); + +BSON_EXPORT(bool) +bson_vector_int8_const_view_init(bson_vector_int8_const_view_t *view_out, + const uint8_t *binary_data, + uint32_t binary_data_len); + +BSON_EXPORT(bool) +bson_vector_float32_view_init(bson_vector_float32_view_t *view_out, uint8_t *binary_data, uint32_t binary_data_len); + + +BSON_EXPORT(bool) +bson_vector_float32_const_view_init(bson_vector_float32_const_view_t *view_out, + const uint8_t *binary_data, + uint32_t binary_data_len); + +BSON_EXPORT(bool) +bson_vector_packed_bit_view_init(bson_vector_packed_bit_view_t *view_out, + uint8_t *binary_data, + uint32_t binary_data_len); + +BSON_EXPORT(bool) +bson_vector_packed_bit_const_view_init(bson_vector_packed_bit_const_view_t *view_out, + const uint8_t *binary_data, + uint32_t binary_data_len); + + +BSON_EXPORT(bool) +bson_vector_int8_view_from_iter(bson_vector_int8_view_t *view_out, bson_iter_t *iter); + +BSON_EXPORT(bool) +bson_vector_int8_const_view_from_iter(bson_vector_int8_const_view_t *view_out, const bson_iter_t *iter); + +BSON_EXPORT(bool) +bson_vector_float32_view_from_iter(bson_vector_float32_view_t *view_out, bson_iter_t *iter); + +BSON_EXPORT(bool) +bson_vector_float32_const_view_from_iter(bson_vector_float32_const_view_t *view_out, const bson_iter_t *iter); + +BSON_EXPORT(bool) +bson_vector_packed_bit_view_from_iter(bson_vector_packed_bit_view_t *view_out, bson_iter_t *iter); + +BSON_EXPORT(bool) +bson_vector_packed_bit_const_view_from_iter(bson_vector_packed_bit_const_view_t *view_out, const bson_iter_t *iter); + + +BSON_EXPORT(bool) +bson_array_builder_append_vector_int8_elements(struct _bson_array_builder_t *builder, + bson_vector_int8_const_view_t view); + +BSON_EXPORT(bool) +bson_array_builder_append_vector_float32_elements(struct _bson_array_builder_t *builder, + bson_vector_float32_const_view_t view); + +BSON_EXPORT(bool) +bson_array_builder_append_vector_packed_bit_elements(struct _bson_array_builder_t *builder, + bson_vector_packed_bit_const_view_t view); + +BSON_EXPORT(bool) +bson_array_builder_append_vector_elements(struct _bson_array_builder_t *builder, const bson_iter_t *iter); + + +BSON_EXPORT(bool) +bson_append_vector_int8_uninit( + bson_t *bson, const char *key, int key_length, size_t element_count, bson_vector_int8_view_t *view_out); + +#define BSON_APPEND_VECTOR_INT8_UNINIT(b, key, count, view) \ + bson_append_vector_int8_uninit(b, key, (int)strlen(key), count, view) + +BSON_EXPORT(bool) +bson_append_vector_float32_uninit( + bson_t *bson, const char *key, int key_length, size_t element_count, bson_vector_float32_view_t *view_out); + +#define BSON_APPEND_VECTOR_FLOAT32_UNINIT(b, key, count, view) \ + bson_append_vector_float32_uninit(b, key, (int)strlen(key), count, view) + +BSON_EXPORT(bool) +bson_append_vector_packed_bit_uninit( + bson_t *bson, const char *key, int key_length, size_t element_count, bson_vector_packed_bit_view_t *view_out); + +#define BSON_APPEND_VECTOR_PACKED_BIT_UNINIT(b, key, count, view) \ + bson_append_vector_packed_bit_uninit(b, key, (int)strlen(key), count, view) + + +BSON_EXPORT(bool) +bson_append_vector_int8_from_array( + bson_t *bson, const char *key, int key_length, const bson_iter_t *iter, bson_error_t *error); + +#define BSON_APPEND_VECTOR_INT8_FROM_ARRAY(b, key, iter, err) \ + bson_append_vector_int8_from_array(b, key, (int)strlen(key), iter, err) + +BSON_EXPORT(bool) +bson_append_vector_float32_from_array( + bson_t *bson, const char *key, int key_length, const bson_iter_t *iter, bson_error_t *error); + +#define BSON_APPEND_VECTOR_FLOAT32_FROM_ARRAY(b, key, iter, err) \ + bson_append_vector_float32_from_array(b, key, (int)strlen(key), iter, err) + +BSON_EXPORT(bool) +bson_append_vector_packed_bit_from_array( + bson_t *bson, const char *key, int key_length, const bson_iter_t *iter, bson_error_t *error); + +#define BSON_APPEND_VECTOR_PACKED_BIT_FROM_ARRAY(b, key, iter, err) \ + bson_append_vector_packed_bit_from_array(b, key, (int)strlen(key), iter, err) + + +BSON_EXPORT(bool) +bson_append_array_from_vector_int8(bson_t *bson, const char *key, int key_length, bson_vector_int8_const_view_t view); + +#define BSON_APPEND_ARRAY_FROM_VECTOR_INT8(b, key, view) \ + bson_append_array_from_vector_int8(b, key, (int)strlen(key), view) + +BSON_EXPORT(bool) +bson_append_array_from_vector_float32(bson_t *bson, + const char *key, + int key_length, + bson_vector_float32_const_view_t view); + +#define BSON_APPEND_ARRAY_FROM_VECTOR_FLOAT32(b, key, view) \ + bson_append_array_from_vector_float32(b, key, (int)strlen(key), view) + +BSON_EXPORT(bool) +bson_append_array_from_vector_packed_bit(bson_t *bson, + const char *key, + int key_length, + bson_vector_packed_bit_const_view_t view); + +#define BSON_APPEND_ARRAY_FROM_VECTOR_PACKED_BIT(b, key, view) \ + bson_append_array_from_vector_packed_bit(b, key, (int)strlen(key), view) + + +static BSON_INLINE const int8_t * +bson_vector_int8_const_view_pointer(bson_vector_int8_const_view_t view) +{ + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + return (const int8_t *)(view.binary.data + BSON_VECTOR_HEADER_LEN); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END +} + +static BSON_INLINE int8_t * +bson_vector_int8_view_pointer(bson_vector_int8_view_t view) +{ + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + return (int8_t *)(view.binary.data + BSON_VECTOR_HEADER_LEN); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END +} + + +static BSON_INLINE uint32_t +bson_vector_int8_binary_data_length(size_t element_count) +{ + const size_t max_representable = (size_t)UINT32_MAX - (size_t)BSON_VECTOR_HEADER_LEN; + return element_count > max_representable ? 0u : (uint32_t)element_count + (uint32_t)BSON_VECTOR_HEADER_LEN; +} + +static BSON_INLINE uint32_t +bson_vector_float32_binary_data_length(size_t element_count) +{ + const size_t max_representable = ((size_t)UINT32_MAX - (size_t)BSON_VECTOR_HEADER_LEN) / sizeof(float); + return element_count > max_representable + ? 0u + : (uint32_t)element_count * sizeof(float) + (uint32_t)BSON_VECTOR_HEADER_LEN; +} + +static BSON_INLINE uint32_t +bson_vector_packed_bit_binary_data_length(size_t element_count) +{ + const size_t max_representable = + (size_t)BSON_MIN((uint64_t)SIZE_MAX, ((uint64_t)UINT32_MAX - (uint64_t)BSON_VECTOR_HEADER_LEN) * 8u); + return element_count > max_representable + ? 0u + : (uint32_t)(((uint64_t)element_count + 7u) / 8u) + (uint32_t)BSON_VECTOR_HEADER_LEN; +} + + +static BSON_INLINE size_t +bson_vector_int8_const_view_length(bson_vector_int8_const_view_t view) +{ + return view.binary.data_len - (uint32_t)BSON_VECTOR_HEADER_LEN; +} + +static BSON_INLINE size_t +bson_vector_int8_view_length(bson_vector_int8_view_t view) +{ + return bson_vector_int8_const_view_length(bson_vector_int8_view_as_const(view)); +} + +static BSON_INLINE size_t +bson_vector_float32_const_view_length(bson_vector_float32_const_view_t view) +{ + return (view.binary.data_len - (uint32_t)BSON_VECTOR_HEADER_LEN) / (uint32_t)sizeof(float); +} + +static BSON_INLINE size_t +bson_vector_float32_view_length(bson_vector_float32_view_t view) +{ + return bson_vector_float32_const_view_length(bson_vector_float32_view_as_const(view)); +} + +static BSON_INLINE size_t +bson_vector_packed_bit_const_view_length_bytes(bson_vector_packed_bit_const_view_t view) +{ + return view.binary.data_len - (uint32_t)BSON_VECTOR_HEADER_LEN; +} + +static BSON_INLINE size_t +bson_vector_packed_bit_view_length_bytes(bson_vector_packed_bit_view_t view) +{ + return bson_vector_packed_bit_const_view_length_bytes(bson_vector_packed_bit_view_as_const(view)); +} + +// Implementation detail, not part of documented API. +static BSON_INLINE size_t +bson_vector_padding_from_header_byte_1(uint8_t byte_1) +{ + return byte_1 & 7; +} + +static BSON_INLINE size_t +bson_vector_packed_bit_const_view_padding(bson_vector_packed_bit_const_view_t view) +{ + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + return bson_vector_padding_from_header_byte_1(view.binary.header_copy.bytes[1]); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END +} + +static BSON_INLINE size_t +bson_vector_packed_bit_view_padding(bson_vector_packed_bit_view_t view) +{ + return bson_vector_packed_bit_const_view_padding(bson_vector_packed_bit_view_as_const(view)); +} + +static BSON_INLINE size_t +bson_vector_packed_bit_const_view_length(bson_vector_packed_bit_const_view_t view) +{ + return bson_vector_packed_bit_const_view_length_bytes(view) * 8u - bson_vector_packed_bit_const_view_padding(view); +} + +static BSON_INLINE size_t +bson_vector_packed_bit_view_length(bson_vector_packed_bit_view_t view) +{ + return bson_vector_packed_bit_const_view_length(bson_vector_packed_bit_view_as_const(view)); +} + + +static BSON_INLINE bool +bson_vector_int8_const_view_read(bson_vector_int8_const_view_t view, + int8_t *BSON_RESTRICT values_out, + size_t element_count, + size_t vector_offset_elements) +{ + size_t length = bson_vector_int8_const_view_length(view); + if (BSON_LIKELY(vector_offset_elements <= length && element_count <= length - vector_offset_elements)) { + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + memcpy(values_out, bson_vector_int8_const_view_pointer(view) + vector_offset_elements, element_count); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + return true; + } else { + return false; + } +} + +static BSON_INLINE bool +bson_vector_int8_view_read(bson_vector_int8_view_t view, + int8_t *BSON_RESTRICT values_out, + size_t element_count, + uint32_t vector_offset_elements) +{ + return bson_vector_int8_const_view_read( + bson_vector_int8_view_as_const(view), values_out, element_count, vector_offset_elements); +} + +static BSON_INLINE bool +bson_vector_int8_view_write(bson_vector_int8_view_t view, + const int8_t *BSON_RESTRICT values, + size_t element_count, + size_t vector_offset_elements) +{ + size_t length = bson_vector_int8_view_length(view); + if (BSON_LIKELY(vector_offset_elements <= length && element_count <= length - vector_offset_elements)) { + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + memcpy(bson_vector_int8_view_pointer(view) + vector_offset_elements, values, element_count); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + return true; + } else { + return false; + } +} + + +BSON_STATIC_ASSERT2(float_is_float32, sizeof(float) == 4); + +static BSON_INLINE bool +bson_vector_float32_const_view_read(bson_vector_float32_const_view_t view, + float *BSON_RESTRICT values_out, + size_t element_count, + size_t vector_offset_elements) +{ + size_t length = bson_vector_float32_const_view_length(view); + if (BSON_LIKELY(vector_offset_elements <= length && element_count <= length - vector_offset_elements)) { + size_t byte_offset = BSON_VECTOR_HEADER_LEN + vector_offset_elements * 4; + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN +#if BSON_BYTE_ORDER == BSON_LITTLE_ENDIAN + memcpy(values_out, view.binary.data + byte_offset, element_count * 4); +#else + size_t i; + for (i = 0; i < element_count; i++) { + float aligned_tmp; + memcpy(&aligned_tmp, view.binary.data + byte_offset + i * 4, 4); + values_out[i] = BSON_FLOAT_FROM_LE(aligned_tmp); + } +#endif + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + return true; + } else { + return false; + } +} + +static BSON_INLINE bool +bson_vector_float32_view_read(bson_vector_float32_view_t view, + float *BSON_RESTRICT values_out, + size_t element_count, + size_t vector_offset_elements) +{ + return bson_vector_float32_const_view_read( + bson_vector_float32_view_as_const(view), values_out, element_count, vector_offset_elements); +} + +static BSON_INLINE bool +bson_vector_float32_view_write(bson_vector_float32_view_t view, + const float *BSON_RESTRICT values, + size_t element_count, + size_t vector_offset_elements) +{ + size_t length = bson_vector_float32_view_length(view); + if (BSON_LIKELY(vector_offset_elements <= length && element_count <= length - vector_offset_elements)) { + size_t byte_offset = BSON_VECTOR_HEADER_LEN + vector_offset_elements * 4; + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN +#if BSON_BYTE_ORDER == BSON_LITTLE_ENDIAN + memcpy(view.binary.data + byte_offset, values, element_count * 4); +#else + size_t i; + for (i = 0; i < element_count; i++) { + float aligned_tmp = BSON_FLOAT_TO_LE(values[i]); + memcpy(view.binary.data + byte_offset + i * 4, &aligned_tmp, 4); + } +#endif + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + return true; + } else { + return false; + } +} + + +static BSON_INLINE bool +bson_vector_packed_bit_const_view_read_packed(bson_vector_packed_bit_const_view_t view, + uint8_t *BSON_RESTRICT packed_values_out, + size_t byte_count, + size_t vector_offset_bytes) +{ + size_t length_bytes = bson_vector_packed_bit_const_view_length_bytes(view); + if (BSON_LIKELY(vector_offset_bytes <= length_bytes && byte_count <= length_bytes - vector_offset_bytes)) { + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + memcpy(packed_values_out, view.binary.data + BSON_VECTOR_HEADER_LEN + vector_offset_bytes, byte_count); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + return true; + } else { + return false; + } +} + +static BSON_INLINE bool +bson_vector_packed_bit_view_read_packed(bson_vector_packed_bit_view_t view, + uint8_t *BSON_RESTRICT packed_values_out, + size_t byte_count, + size_t vector_offset_bytes) +{ + return bson_vector_packed_bit_const_view_read_packed( + bson_vector_packed_bit_view_as_const(view), packed_values_out, byte_count, vector_offset_bytes); +} + +static BSON_INLINE bool +bson_vector_packed_bit_view_write_packed(bson_vector_packed_bit_view_t view, + const uint8_t *BSON_RESTRICT packed_values, + size_t byte_count, + size_t vector_offset_bytes) +{ + size_t length_bytes = bson_vector_packed_bit_view_length_bytes(view); + if (BSON_LIKELY(vector_offset_bytes <= length_bytes && byte_count <= length_bytes - vector_offset_bytes)) { + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + if (byte_count == length_bytes - vector_offset_bytes && byte_count >= 1u) { + // This write touches the last byte in the vector: + // special-case that byte so we can ensure unused bits remain set to zero. + size_t other_bytes = byte_count - 1u; + memcpy(view.binary.data + BSON_VECTOR_HEADER_LEN + vector_offset_bytes, packed_values, other_bytes); + view.binary.data[BSON_VECTOR_HEADER_LEN + vector_offset_bytes + other_bytes] = + (UINT8_C(0xFF) << bson_vector_packed_bit_view_padding(view)) & packed_values[other_bytes]; + } else { + memcpy(view.binary.data + BSON_VECTOR_HEADER_LEN + vector_offset_bytes, packed_values, byte_count); + } + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + return true; + } else { + return false; + } +} + + +static BSON_INLINE bool +bson_vector_packed_bit_const_view_unpack_bool(bson_vector_packed_bit_const_view_t view, + bool *BSON_RESTRICT unpacked_values_out, + size_t element_count, + size_t vector_offset_elements) +{ + size_t length = bson_vector_packed_bit_const_view_length(view); + if (BSON_LIKELY(vector_offset_elements <= length && element_count <= length - vector_offset_elements)) { + size_t i; + for (i = 0; i < element_count; i++) { + size_t element_index = vector_offset_elements + i; + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + uint8_t packed_byte = view.binary.data[BSON_VECTOR_HEADER_LEN + (element_index >> 3)]; + unpacked_values_out[i] = 0 != (packed_byte & ((uint8_t)0x80 >> (element_index & 7))); + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + } + return true; + } else { + return false; + } +} + +static BSON_INLINE bool +bson_vector_packed_bit_view_unpack_bool(bson_vector_packed_bit_view_t view, + bool *BSON_RESTRICT unpacked_values_out, + size_t element_count, + size_t vector_offset_elements) +{ + return bson_vector_packed_bit_const_view_unpack_bool( + bson_vector_packed_bit_view_as_const(view), unpacked_values_out, element_count, vector_offset_elements); +} + +static BSON_INLINE bool +bson_vector_packed_bit_view_pack_bool(bson_vector_packed_bit_view_t view, + const bool *BSON_RESTRICT unpacked_values, + size_t element_count, + size_t vector_offset_elements) +{ + size_t length = bson_vector_packed_bit_view_length(view); + if (BSON_LIKELY(vector_offset_elements <= length && element_count <= length - vector_offset_elements)) { + while (element_count > 0) { + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN + uint8_t *BSON_RESTRICT packed_byte = BSON_VECTOR_HEADER_LEN + (vector_offset_elements >> 3) + view.binary.data; + if (element_count >= 8 && (vector_offset_elements & 7) == 0) { + uint8_t complete_byte = 0; + unsigned i; + for (i = 0; i < 8; i++) { + complete_byte |= unpacked_values[i] ? ((uint8_t)0x80 >> i) : 0; + } + *packed_byte = complete_byte; + unpacked_values += 8; + vector_offset_elements += 8; + element_count -= 8; + } else { + uint8_t mask = (uint8_t)0x80 >> (vector_offset_elements & 7); + *packed_byte = (*packed_byte & ~mask) | (*unpacked_values ? mask : 0); + unpacked_values++; + vector_offset_elements++; + element_count--; + } + BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END + } + return true; + } else { + return false; + } +} + + +BSON_END_DECLS + +#endif /* BSON_VECTOR_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-version-functions.h b/Vendor/mongo-c-driver/include/bson/bson-version-functions.h new file mode 100644 index 0000000..de22c15 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-version-functions.h @@ -0,0 +1,41 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include + + +#ifndef BSON_VERSION_FUNCTIONS_H +#define BSON_VERSION_FUNCTIONS_H + +#include + +BSON_BEGIN_DECLS + +BSON_EXPORT(int) +bson_get_major_version(void); +BSON_EXPORT(int) +bson_get_minor_version(void); +BSON_EXPORT(int) +bson_get_micro_version(void); +BSON_EXPORT(const char *) +bson_get_version(void); +BSON_EXPORT(bool) +bson_check_version(int required_major, int required_minor, int required_micro); + +BSON_END_DECLS + +#endif /* BSON_VERSION_FUNCTIONS_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson-writer.h b/Vendor/mongo-c-driver/include/bson/bson-writer.h new file mode 100644 index 0000000..64fecce --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson-writer.h @@ -0,0 +1,57 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef BSON_WRITER_H +#define BSON_WRITER_H + +#include +#include + +#include + +BSON_BEGIN_DECLS + +/** + * bson_writer_t: + * + * The bson_writer_t structure is a helper for writing a series of BSON + * documents to a single malloc() buffer. You can provide a realloc() style + * function to grow the buffer as you go. + * + * This is useful if you want to build a series of BSON documents right into + * the target buffer for an outgoing packet. The offset parameter allows you to + * start at an offset of the target buffer. + */ +typedef struct _bson_writer_t bson_writer_t; + +BSON_EXPORT(bson_writer_t *) +bson_writer_new(uint8_t **buf, size_t *buflen, size_t offset, bson_realloc_func realloc_func, void *realloc_func_ctx); +BSON_EXPORT(void) +bson_writer_destroy(bson_writer_t *writer); +BSON_EXPORT(size_t) +bson_writer_get_length(bson_writer_t *writer); +BSON_EXPORT(bool) +bson_writer_begin(bson_writer_t *writer, bson_t **bson); +BSON_EXPORT(void) +bson_writer_end(bson_writer_t *writer); +BSON_EXPORT(void) +bson_writer_rollback(bson_writer_t *writer); + +BSON_END_DECLS + +#endif /* BSON_WRITER_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson.h b/Vendor/mongo-c-driver/include/bson/bson.h new file mode 100644 index 0000000..6fd96fe --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson.h @@ -0,0 +1,1263 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef BSON_H +#define BSON_H + +#define BSON_INSIDE + +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export + +#include +#include + +#undef BSON_INSIDE + + +BSON_BEGIN_DECLS + + +/** + * bson_empty: + * @b: a bson_t. + * + * Checks to see if @b is an empty BSON document. An empty BSON document is + * a 5 byte document which contains the length (4 bytes) and a single NUL + * byte indicating end of fields. + */ +#define bson_empty(b) (((b)->len == 5) || !bson_get_data((b))[4]) + + +/** + * bson_empty0: + * + * Like bson_empty() but treats NULL the same as an empty bson_t document. + */ +#define bson_empty0(b) (!(b) || bson_empty(b)) + + +/** + * bson_clear: + * + * Easily free a bson document and set it to NULL. Use like: + * + * bson_t *doc = bson_new(); + * bson_clear (&doc); + * BSON_ASSERT (doc == NULL); + */ +#define bson_clear(bptr) \ + do { \ + if (*(bptr)) { \ + bson_destroy(*(bptr)); \ + *(bptr) = NULL; \ + } \ + } while (0) + + +/** + * BSON_MAX_SIZE: + * + * The maximum size in bytes of a BSON document. + */ +#define BSON_MAX_SIZE ((size_t)((1U << 31) - 1)) + + +#define BSON_APPEND_ARRAY(b, key, val) bson_append_array(b, key, (int)strlen(key), val) + +#define BSON_APPEND_ARRAY_BEGIN(b, key, child) bson_append_array_begin(b, key, (int)strlen(key), child) + +#define BSON_APPEND_BINARY(b, key, subtype, val, len) bson_append_binary(b, key, (int)strlen(key), subtype, val, len) + +#define BSON_APPEND_BOOL(b, key, val) bson_append_bool(b, key, (int)strlen(key), val) + +#define BSON_APPEND_CODE(b, key, val) bson_append_code(b, key, (int)strlen(key), val) + +#define BSON_APPEND_CODE_WITH_SCOPE(b, key, val, scope) \ + bson_append_code_with_scope(b, key, (int)strlen(key), val, scope) + +#define BSON_APPEND_DBPOINTER(b, key, coll, oid) bson_append_dbpointer(b, key, (int)strlen(key), coll, oid) + +#define BSON_APPEND_DOCUMENT_BEGIN(b, key, child) bson_append_document_begin(b, key, (int)strlen(key), child) + +#define BSON_APPEND_DOUBLE(b, key, val) bson_append_double(b, key, (int)strlen(key), val) + +#define BSON_APPEND_DOCUMENT(b, key, val) bson_append_document(b, key, (int)strlen(key), val) + +#define BSON_APPEND_INT32(b, key, val) bson_append_int32(b, key, (int)strlen(key), val) + +#define BSON_APPEND_INT64(b, key, val) bson_append_int64(b, key, (int)strlen(key), val) + +#define BSON_APPEND_MINKEY(b, key) bson_append_minkey(b, key, (int)strlen(key)) + +#define BSON_APPEND_DECIMAL128(b, key, val) bson_append_decimal128(b, key, (int)strlen(key), val) + +#define BSON_APPEND_MAXKEY(b, key) bson_append_maxkey(b, key, (int)strlen(key)) + +#define BSON_APPEND_NULL(b, key) bson_append_null(b, key, (int)strlen(key)) + +#define BSON_APPEND_OID(b, key, val) bson_append_oid(b, key, (int)strlen(key), val) + +#define BSON_APPEND_REGEX(b, key, val, opt) bson_append_regex(b, key, (int)strlen(key), val, opt) + +#define BSON_APPEND_UTF8(b, key, val) bson_append_utf8(b, key, (int)strlen(key), val, (int)strlen(val)) + +#define BSON_APPEND_SYMBOL(b, key, val) bson_append_symbol(b, key, (int)strlen(key), val, (int)strlen(val)) + +#define BSON_APPEND_TIME_T(b, key, val) bson_append_time_t(b, key, (int)strlen(key), val) + +#define BSON_APPEND_TIMEVAL(b, key, val) bson_append_timeval(b, key, (int)strlen(key), val) + +#define BSON_APPEND_DATE_TIME(b, key, val) bson_append_date_time(b, key, (int)strlen(key), val) + +#define BSON_APPEND_TIMESTAMP(b, key, val, inc) bson_append_timestamp(b, key, (int)strlen(key), val, inc) + +#define BSON_APPEND_UNDEFINED(b, key) bson_append_undefined(b, key, (int)strlen(key)) + +#define BSON_APPEND_VALUE(b, key, val) bson_append_value(b, key, (int)strlen(key), (val)) + + +/** + * bson_new: + * + * Allocates a new bson_t structure. Call the various bson_append_*() + * functions to add fields to the bson. You can iterate the bson_t at any + * time using a bson_iter_t and bson_iter_init(). + * + * Returns: A newly allocated bson_t that should be freed with bson_destroy(). + */ +BSON_EXPORT(bson_t *) bson_new(void); + + +BSON_EXPORT(bson_t *) +bson_new_from_json(const uint8_t *data, ssize_t len, bson_error_t *error); + + +BSON_EXPORT(bool) +bson_init_from_json(bson_t *bson, const char *data, ssize_t len, bson_error_t *error); + + +/** + * bson_init_static: + * @b: A pointer to a bson_t. + * @data: The data buffer to use. + * @length: The length of @data. + * + * Initializes a bson_t using @data and @length. This is ideal if you would + * like to use a stack allocation for your bson and do not need to grow the + * buffer. @data must be valid for the life of @b. + * + * Returns: true if initialized successfully; otherwise false. + */ +BSON_EXPORT(bool) +bson_init_static(bson_t *b, const uint8_t *data, size_t length); + + +/** + * bson_init: + * @b: A pointer to a bson_t. + * + * Initializes a bson_t for use. This function is useful to those that want a + * stack allocated bson_t. The usefulness of a stack allocated bson_t is + * marginal as the target buffer for content will still require heap + * allocations. It can help reduce heap fragmentation on allocators that do + * not employ SLAB/magazine semantics. + * + * You must call bson_destroy() with @b to release resources when you are done + * using @b. + */ +BSON_EXPORT(void) +bson_init(bson_t *b); + + +/** + * bson_reinit: + * @b: (inout): A bson_t. + * + * This is equivalent to calling bson_destroy() and bson_init() on a #bson_t. + * However, it will try to persist the existing malloc'd buffer if one exists. + * This is useful in cases where you want to reduce malloc overhead while + * building many documents. + */ +BSON_EXPORT(void) +bson_reinit(bson_t *b); + + +/** + * bson_new_from_data: + * @data: A buffer containing a serialized bson document. + * @length: The length of the document in bytes. + * + * Creates a new bson_t structure using the data provided. @data should contain + * at least @length bytes that can be copied into the new bson_t structure. + * + * Returns: A newly allocated bson_t that should be freed with bson_destroy(). + * If the first four bytes (little-endian) of data do not match @length, + * then NULL will be returned. + */ +BSON_EXPORT(bson_t *) +bson_new_from_data(const uint8_t *data, size_t length); + + +/** + * bson_new_from_buffer: + * @buf: A pointer to a buffer containing a serialized bson document. + * @buf_len: The length of the buffer in bytes. + * @realloc_fun: a realloc like function + * @realloc_fun_ctx: a context for the realloc function + * + * Creates a new bson_t structure using the data provided. @buf should contain + * a bson document, or null pointer should be passed for new allocations. + * + * Returns: A newly allocated bson_t that should be freed with bson_destroy(). + * The underlying buffer will be used and not be freed in destroy. + */ +BSON_EXPORT(bson_t *) +bson_new_from_buffer(uint8_t **buf, size_t *buf_len, bson_realloc_func realloc_func, void *realloc_func_ctx); + + +/** + * bson_sized_new: + * @size: A size_t containing the number of bytes to allocate. + * + * This will allocate a new bson_t with enough bytes to hold a buffer + * sized @size. @size must be smaller than INT_MAX bytes. + * + * Returns: A newly allocated bson_t that should be freed with bson_destroy(). + */ +BSON_EXPORT(bson_t *) +bson_sized_new(size_t size); + + +/** + * bson_copy: + * @bson: A bson_t. + * + * Copies @bson into a newly allocated bson_t. You must call bson_destroy() + * when you are done with the resulting value to free its resources. + * + * Returns: A newly allocated bson_t that should be free'd with bson_destroy() + */ +BSON_EXPORT(bson_t *) +bson_copy(const bson_t *bson); + + +/** + * bson_copy_to: + * @src: The source bson_t. + * @dst: The destination bson_t. + * + * Initializes @dst and copies the content from @src into @dst. + */ +BSON_EXPORT(void) +bson_copy_to(const bson_t *src, bson_t *dst); + +/** + * bson_copy_to_excluding_noinit: + * @src: A bson_t. + * @dst: A bson_t to initialize and copy into. + * @first_exclude: First field name to exclude. + * + * Does not call bson_init() on the dst. + */ +BSON_EXPORT(void) +bson_copy_to_excluding_noinit(const bson_t *src, bson_t *dst, const char *first_exclude, ...) BSON_GNUC_NULL_TERMINATED; + +BSON_EXPORT(void) +bson_copy_to_excluding_noinit_va(const bson_t *src, bson_t *dst, const char *first_exclude, va_list args); + + +/** + * bson_destroy: + * @bson: A bson_t. + * + * Frees the resources associated with @bson. + */ +BSON_EXPORT(void) +bson_destroy(bson_t *bson); + +BSON_EXPORT(uint8_t *) +bson_reserve_buffer(bson_t *bson, uint32_t total_size); + +BSON_EXPORT(bool) +bson_steal(bson_t *dst, bson_t *src); + + +/** + * bson_destroy_with_steal: + * @bson: A #bson_t. + * @steal: If ownership of the data buffer should be transferred to caller. + * @length: (out): location for the length of the buffer. + * + * Destroys @bson similar to calling bson_destroy() except that the underlying + * buffer will be returned and ownership transferred to the caller if @steal + * is non-zero. + * + * If length is non-NULL, the length of @bson will be stored in @length. + * + * It is a programming error to call this function with any bson that has + * been initialized static, or is being used to create a subdocument with + * functions such as bson_append_document_begin() or bson_append_array_begin(). + * + * Returns: a buffer owned by the caller if @steal is true. Otherwise NULL. + * If there was an error, NULL is returned. + */ +BSON_EXPORT(uint8_t *) +bson_destroy_with_steal(bson_t *bson, bool steal, uint32_t *length); + + +/** + * bson_get_data: + * @bson: A bson_t. + * + * Fetched the data buffer for @bson of @bson->len bytes in length. + * + * Returns: A buffer that should not be modified or freed. + */ +BSON_EXPORT(const uint8_t *) +bson_get_data(const bson_t *bson); + + +/** + * bson_count_keys: + * @bson: A bson_t. + * + * Counts the number of elements found in @bson. + */ +BSON_EXPORT(uint32_t) +bson_count_keys(const bson_t *bson); + + +/** + * bson_has_field: + * @bson: A bson_t. + * @key: The key to lookup. + * + * Checks to see if @bson contains a field named @key. + * + * This function is case-sensitive. + * + * Returns: true if @key exists in @bson; otherwise false. + */ +BSON_EXPORT(bool) +bson_has_field(const bson_t *bson, const char *key); + + +/** + * bson_compare: + * @bson: A bson_t. + * @other: A bson_t. + * + * Compares @bson to @other in a qsort() style comparison. + * See qsort() for information on how this function works. + * + * Returns: Less than zero, zero, or greater than zero. + */ +BSON_EXPORT(int) +bson_compare(const bson_t *bson, const bson_t *other); + +/* + * bson_equal: + * @bson: A bson_t. + * @other: A bson_t. + * + * Checks to see if @bson and @other are equal. + * + * Returns: true if equal; otherwise false. + */ +BSON_EXPORT(bool) +bson_equal(const bson_t *bson, const bson_t *other); + + +/** + * bson_validate: + * @bson: A bson_t. + * @offset: A location for the error offset. + * + * Validates a BSON document by walking through the document and inspecting + * the fields for valid content. + * + * Returns: true if @bson is valid; otherwise false and @offset is set. + */ +BSON_EXPORT(bool) +bson_validate(const bson_t *bson, bson_validate_flags_t flags, size_t *offset); + + +/** + * bson_validate_with_error: + * @bson: A bson_t. + * @error: A location for the error info. + * + * Validates a BSON document by walking through the document and inspecting + * the fields for valid content. + * + * Returns: true if @bson is valid; otherwise false and @error is filled out. + */ +BSON_EXPORT(bool) +bson_validate_with_error(const bson_t *bson, bson_validate_flags_t flags, bson_error_t *error); + + +/** + * bson_validate_with_error_and_offset: + * @bson: A bson_t. + * @offset: A location for the error offset. + * @error: A location for the error info. + * + * Validates a BSON document by walking through the document and inspecting + * the fields for valid content. + * + * Returns: true if @bson is valid; otherwise false, @offset is set + * and @error is filled out. + */ +BSON_EXPORT(bool) +bson_validate_with_error_and_offset(const bson_t *bson, + bson_validate_flags_t flags, + size_t *offset, + bson_error_t *error); + + +/** + * bson_as_json_with_opts: + * @bson: A bson_t. + * @length: A location for the string length, or NULL. + * @opts: A bson_t_json_opts_t defining options for the conversion + * + * Creates a new string containing @bson in the selected JSON format, + * conforming to the MongoDB Extended JSON Spec: + * + * github.com/mongodb/specifications/blob/master/source/extended-json.rst + * + * The caller is responsible for freeing the resulting string. If @length is + * non-NULL, then the length of the resulting string will be placed in @length. + * + * See https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/ for + * more information on extended JSON. + * + * Returns: A newly allocated string that should be freed with bson_free(). + */ +BSON_EXPORT(char *) +bson_as_json_with_opts(const bson_t *bson, size_t *length, const bson_json_opts_t *opts); + + +/** + * bson_as_canonical_extended_json: + * @bson: A bson_t. + * @length: A location for the string length, or NULL. + * + * Creates a new string containing @bson in canonical extended JSON format, + * conforming to the MongoDB Extended JSON Spec: + * + * github.com/mongodb/specifications/blob/master/source/extended-json.rst + * + * The caller is responsible for freeing the resulting string. If @length is + * non-NULL, then the length of the resulting string will be placed in @length. + * + * See https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/ for + * more information on extended JSON. + * + * Returns: A newly allocated string that should be freed with bson_free(). + */ +BSON_EXPORT(char *) +bson_as_canonical_extended_json(const bson_t *bson, size_t *length); + + +/** + * bson_as_legacy_extended_json: + * @bson: A bson_t. + * @length: A location for the string length, or NULL. + * + * Creates a new string containing @bson in libbson's legacy JSON format. + * Superseded by bson_as_canonical_extended_json and + * bson_as_relaxed_extended_json. The caller is + * responsible for freeing the resulting string. If @length is non-NULL, then + * the length of the resulting string will be placed in @length. + * + * Returns: A newly allocated string that should be freed with bson_free(). + */ + +BSON_EXPORT(char *) +bson_as_legacy_extended_json(const bson_t *bson, size_t *length); + + +/** + * bson_as_relaxed_extended_json: + * @bson: A bson_t. + * @length: A location for the string length, or NULL. + * + * Creates a new string containing @bson in relaxed extended JSON format, + * conforming to the MongoDB Extended JSON Spec: + * + * github.com/mongodb/specifications/blob/master/source/extended-json.rst + * + * The caller is responsible for freeing the resulting string. If @length is + * non-NULL, then the length of the resulting string will be placed in @length. + * + * See https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/ for + * more information on extended JSON. + * + * Returns: A newly allocated string that should be freed with bson_free(). + */ +BSON_EXPORT(char *) +bson_as_relaxed_extended_json(const bson_t *bson, size_t *length); + + +/* like bson_as_legacy_extended_json() but for outermost arrays. */ +BSON_EXPORT(char *) +bson_array_as_legacy_extended_json(const bson_t *bson, size_t *length); + + +/* like bson_as_relaxed_extended_json() but for outermost arrays. */ +BSON_EXPORT(char *) +bson_array_as_relaxed_extended_json(const bson_t *bson, size_t *length); + + +/* like bson_as_canonical_extended_json() but for outermost arrays. */ +BSON_EXPORT(char *) +bson_array_as_canonical_extended_json(const bson_t *bson, size_t *length); + +// bson_array_builder_t defines an API for building arrays. +// BSON arrays require sequential numeric keys "0", "1", "2", ... +typedef struct _bson_array_builder_t bson_array_builder_t; + +// bson_array_builder_new may be used to build a top-level BSON array. Example: +// `[1,2,3]`. +// To append an array field to a document (Example: `{ "field": [1,2,3] }`), use +// `bson_append_array_builder_begin`. +BSON_EXPORT(bson_array_builder_t *) bson_array_builder_new(void); + +// bson_array_builder_build initializes and moves BSON data to `out`. +// `bab` may be reused and will start appending a new array at index "0". +BSON_EXPORT(bool) +bson_array_builder_build(bson_array_builder_t *bab, bson_t *out); + +BSON_EXPORT(void) +bson_array_builder_destroy(bson_array_builder_t *bab); + +BSON_EXPORT(bool) +bson_append_value(bson_t *bson, const char *key, int key_length, const bson_value_t *value); + +#define BSON_APPEND_VALUE(b, key, val) bson_append_value(b, key, (int)strlen(key), (val)) + +BSON_EXPORT(bool) +bson_array_builder_append_value(bson_array_builder_t *bab, const bson_value_t *value); + +/** + * bson_append_array: + * @bson: A bson_t. + * @key: The key for the field. + * @array: A bson_t containing the array. + * + * Appends a BSON array to @bson. BSON arrays are like documents where the + * key is the string version of the index. For example, the first item of the + * array would have the key "0". The second item would have the index "1". + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_array(bson_t *bson, const char *key, int key_length, const bson_t *array); + +#define BSON_APPEND_ARRAY(b, key, val) bson_append_array(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_array(bson_array_builder_t *bab, const bson_t *array); + +/** + * bson_append_array_from_vector: + * @bson: A bson_t that will be modified. + * @key: The key for the field. + * @iter: A bson_iter_t pointing to any supported vector in another bson_t. + * + * If @iter points to a supported vector type, converts the vector to a BSON array appended to @bson. + * + * Returns: true if successful; false if append would overflow max size or @iter does not point to a vector in a + * supported format. + */ +BSON_EXPORT(bool) +bson_append_array_from_vector(bson_t *bson, const char *key, int key_length, const bson_iter_t *iter); + +#define BSON_APPEND_ARRAY_FROM_VECTOR(b, key, iter) bson_append_array_from_vector(b, key, (int)strlen(key), iter) + +BSON_EXPORT(bool) +bson_array_builder_append_array_from_vector(bson_array_builder_t *bab, const bson_iter_t *iter); + +/** + * bson_append_binary: + * @bson: A bson_t. + * @key: The key for the field. + * @key_length: Optional length of 'key' in bytes, or -1 to use strlen(key). + * @subtype: The bson_subtype_t of the binary item. + * @binary: The binary buffer to append. + * @length: The length of @binary. + * + * Appends a binary buffer to the BSON document. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_binary( + bson_t *bson, const char *key, int key_length, bson_subtype_t subtype, const uint8_t *binary, uint32_t length); + +#define BSON_APPEND_BINARY(b, key, subtype, val, len) bson_append_binary(b, key, (int)strlen(key), subtype, val, len) + +BSON_EXPORT(bool) +bson_array_builder_append_binary(bson_array_builder_t *bab, + bson_subtype_t subtype, + const uint8_t *binary, + uint32_t length); + +/** + * bson_append_binary_uninit: + * @bson: A bson_t. + * @key: The key for the field. + * @key_length: Optional length of 'key' in bytes, or -1 to use strlen(key). + * @binary: Output parameter, pointer for the binary data within bson_t to be written. + * @length: Length of the binary field to allocate, in bytes. + * + * Returns: true if successful; false if append would overflow max size. + */ + +BSON_EXPORT(bool) +bson_append_binary_uninit( + bson_t *bson, const char *key, int key_length, bson_subtype_t subtype, uint8_t **binary, uint32_t length); + +#define BSON_APPEND_BINARY_UNINIT(b, key, subtype, val, len) \ + bson_append_binary_uninit(b, key, (int)strlen(key), subtype, val, len) + +BSON_EXPORT(bool) +bson_array_builder_append_binary_uninit(bson_array_builder_t *bab, + bson_subtype_t subtype, + uint8_t **binary, + uint32_t length); + +/** + * bson_append_bool: + * @bson: A bson_t. + * @key: The key for the field. + * @value: The boolean value. + * + * Appends a new field to @bson of type BSON_TYPE_BOOL. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_bool(bson_t *bson, const char *key, int key_length, bool value); + +#define BSON_APPEND_BOOL(b, key, val) bson_append_bool(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_bool(bson_array_builder_t *bab, bool value); + +/** + * bson_append_code: + * @bson: A bson_t. + * @key: The key for the document. + * @javascript: JavaScript code to be executed. + * + * Appends a field of type BSON_TYPE_CODE to the BSON document. @javascript + * should contain a script in javascript to be executed. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_code(bson_t *bson, const char *key, int key_length, const char *javascript); + +#define BSON_APPEND_CODE(b, key, val) bson_append_code(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_code(bson_array_builder_t *bab, const char *javascript); + +/** + * bson_append_code_with_scope: + * @bson: A bson_t. + * @key: The key for the document. + * @javascript: JavaScript code to be executed. + * @scope: A bson_t containing the scope for @javascript. + * + * Appends a field of type BSON_TYPE_CODEWSCOPE to the BSON document. + * @javascript should contain a script in javascript to be executed. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_code_with_scope(bson_t *bson, const char *key, int key_length, const char *javascript, const bson_t *scope); + +#define BSON_APPEND_CODE_WITH_SCOPE(b, key, val, scope) \ + bson_append_code_with_scope(b, key, (int)strlen(key), val, scope) + +BSON_EXPORT(bool) +bson_array_builder_append_code_with_scope(bson_array_builder_t *bab, const char *javascript, const bson_t *scope); + +/** + * bson_append_dbpointer: + * @bson: A bson_t. + * @key: The key for the field. + * @collection: The collection name. + * @oid: The oid to the reference. + * + * Appends a new field of type BSON_TYPE_DBPOINTER. This datum type is + * deprecated in the BSON spec and should not be used in new code. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_dbpointer(bson_t *bson, const char *key, int key_length, const char *collection, const bson_oid_t *oid); + +#define BSON_APPEND_DBPOINTER(b, key, coll, oid) bson_append_dbpointer(b, key, (int)strlen(key), coll, oid) + +BSON_EXPORT(bool) +bson_array_builder_append_dbpointer(bson_array_builder_t *bab, const char *collection, const bson_oid_t *oid); + +/** + * bson_append_double: + * @bson: A bson_t. + * @key: The key for the field. + * + * Appends a new field to @bson of the type BSON_TYPE_DOUBLE. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_double(bson_t *bson, const char *key, int key_length, double value); + +#define BSON_APPEND_DOUBLE(b, key, val) bson_append_double(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_double(bson_array_builder_t *bab, double value); + +/** + * bson_append_document: + * @bson: A bson_t. + * @key: The key for the field. + * @value: A bson_t containing the subdocument. + * + * Appends a new field to @bson of the type BSON_TYPE_DOCUMENT. + * The documents contents will be copied into @bson. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_document(bson_t *bson, const char *key, int key_length, const bson_t *value); + +#define BSON_APPEND_DOCUMENT(b, key, val) bson_append_document(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_document(bson_array_builder_t *bab, const bson_t *value); + +/** + * bson_append_document_begin: + * @bson: A bson_t. + * @key: The key for the field. + * @key_length: The length of @key in bytes not including NUL or -1 + * if @key_length is NUL terminated. + * @child: A location to an uninitialized bson_t. + * + * Appends a new field named @key to @bson. The field is, however, + * incomplete. @child will be initialized so that you may add fields to the + * child document. Child will use a memory buffer owned by @bson and + * therefore grow the parent buffer as additional space is used. This allows + * a single malloc'd buffer to be used when building documents which can help + * reduce memory fragmentation. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_document_begin(bson_t *bson, const char *key, int key_length, bson_t *child); + +#define BSON_APPEND_DOCUMENT_BEGIN(b, key, child) bson_append_document_begin(b, key, (int)strlen(key), child) + +BSON_EXPORT(bool) +bson_array_builder_append_document_begin(bson_array_builder_t *bab, bson_t *child); + +/** + * bson_append_document_end: + * @bson: A bson_t. + * @child: A bson_t supplied to bson_append_document_begin(). + * + * Finishes the appending of a document to a @bson. @child is considered + * disposed after this call and should not be used any further. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_document_end(bson_t *bson, bson_t *child); + +BSON_EXPORT(bool) +bson_array_builder_append_document_end(bson_array_builder_t *bab, bson_t *child); + + +/** + * bson_append_array_begin: + * @bson: A bson_t. + * @key: The key for the field. + * @key_length: The length of @key in bytes not including NUL or -1 + * if @key_length is NUL terminated. + * @child: A location to an uninitialized bson_t. + * + * Appends a new field named @key to @bson. The field is, however, + * incomplete. @child will be initialized so that you may add fields to the + * child array. Child will use a memory buffer owned by @bson and + * therefore grow the parent buffer as additional space is used. This allows + * a single malloc'd buffer to be used when building arrays which can help + * reduce memory fragmentation. + * + * The type of @child will be BSON_TYPE_ARRAY and therefore the keys inside + * of it MUST be "0", "1", etc. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_array_begin(bson_t *bson, const char *key, int key_length, bson_t *child); + +#define BSON_APPEND_ARRAY_BEGIN(b, key, child) bson_append_array_begin(b, key, (int)strlen(key), child) + +/** + * bson_append_array_end: + * @bson: A bson_t. + * @child: A bson_t supplied to bson_append_array_begin(). + * + * Finishes the appending of a array to a @bson. @child is considered + * disposed after this call and should not be used any further. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_array_end(bson_t *bson, bson_t *child); + + +/** + * bson_append_int32: + * @bson: A bson_t. + * @key: The key for the field. + * @value: The int32_t 32-bit integer value. + * + * Appends a new field of type BSON_TYPE_INT32 to @bson. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_int32(bson_t *bson, const char *key, int key_length, int32_t value); + +#define BSON_APPEND_INT32(b, key, val) bson_append_int32(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_int32(bson_array_builder_t *bab, int32_t value); + +/** + * bson_append_int64: + * @bson: A bson_t. + * @key: The key for the field. + * @value: The int64_t 64-bit integer value. + * + * Appends a new field of type BSON_TYPE_INT64 to @bson. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_int64(bson_t *bson, const char *key, int key_length, int64_t value); + +#define BSON_APPEND_INT64(b, key, val) bson_append_int64(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_int64(bson_array_builder_t *bab, int64_t value); + +/** + * bson_append_decimal128: + * @bson: A bson_t. + * @key: The key for the field. + * @value: The bson_decimal128_t decimal128 value. + * + * Appends a new field of type BSON_TYPE_DECIMAL128 to @bson. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_decimal128(bson_t *bson, const char *key, int key_length, const bson_decimal128_t *value); + +#define BSON_APPEND_DECIMAL128(b, key, val) bson_append_decimal128(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_decimal128(bson_array_builder_t *bab, const bson_decimal128_t *value); + +/** + * bson_append_iter: + * @bson: A bson_t to append to. + * @key: The key name or %NULL to take current key from @iter. + * @key_length: The key length or -1 to use strlen(). + * @iter: The iter located on the position of the element to append. + * + * Appends a new field to @bson that is equivalent to the field currently + * pointed to by @iter. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_iter(bson_t *bson, const char *key, int key_length, const bson_iter_t *iter); + +#define BSON_APPEND_ITER(b, key, val) bson_append_iter(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_iter(bson_array_builder_t *bab, const bson_iter_t *iter); + +/** + * bson_append_minkey: + * @bson: A bson_t. + * @key: The key for the field. + * + * Appends a new field of type BSON_TYPE_MINKEY to @bson. This is a special + * type that compares lower than all other possible BSON element values. + * + * See http://bsonspec.org for more information on this type. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_minkey(bson_t *bson, const char *key, int key_length); + +#define BSON_APPEND_MINKEY(b, key) bson_append_minkey(b, key, (int)strlen(key)) + +BSON_EXPORT(bool) +bson_array_builder_append_minkey(bson_array_builder_t *bab); + +/** + * bson_append_maxkey: + * @bson: A bson_t. + * @key: The key for the field. + * + * Appends a new field of type BSON_TYPE_MAXKEY to @bson. This is a special + * type that compares higher than all other possible BSON element values. + * + * See http://bsonspec.org for more information on this type. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_maxkey(bson_t *bson, const char *key, int key_length); + +#define BSON_APPEND_MAXKEY(b, key) bson_append_maxkey(b, key, (int)strlen(key)) + +BSON_EXPORT(bool) +bson_array_builder_append_maxkey(bson_array_builder_t *bab); + +/** + * bson_append_null: + * @bson: A bson_t. + * @key: The key for the field. + * + * Appends a new field to @bson with NULL for the value. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_null(bson_t *bson, const char *key, int key_length); + +#define BSON_APPEND_NULL(b, key) bson_append_null(b, key, (int)strlen(key)) + +BSON_EXPORT(bool) +bson_array_builder_append_null(bson_array_builder_t *bab); + +/** + * bson_append_oid: + * @bson: A bson_t. + * @key: The key for the field. + * @oid: bson_oid_t. + * + * Appends a new field to the @bson of type BSON_TYPE_OID using the contents of + * @oid. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_oid(bson_t *bson, const char *key, int key_length, const bson_oid_t *oid); + +#define BSON_APPEND_OID(b, key, val) bson_append_oid(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_oid(bson_array_builder_t *bab, const bson_oid_t *oid); + +/** + * bson_append_regex: + * @bson: A bson_t. + * @key: The key of the field. + * @regex: The regex to append to the bson. + * @options: Options for @regex. + * + * Appends a new field to @bson of type BSON_TYPE_REGEX. @regex should + * be the regex string. @options should contain the options for the regex. + * + * Valid options for @options are: + * + * 'i' for case-insensitive. + * 'm' for multiple matching. + * 'x' for verbose mode. + * 'l' to make \w and \W locale dependent. + * 's' for dotall mode ('.' matches everything) + * 'u' to make \w and \W match unicode. + * + * For more detailed information about BSON regex elements, see bsonspec.org. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_regex(bson_t *bson, const char *key, int key_length, const char *regex, const char *options); + +#define BSON_APPEND_REGEX(b, key, val, opt) bson_append_regex(b, key, (int)strlen(key), val, opt) + +BSON_EXPORT(bool) +bson_array_builder_append_regex(bson_array_builder_t *bab, const char *regex, const char *options); + +/** + * bson_append_regex: + * @bson: A bson_t. + * @key: The key of the field. + * @key_length: The length of the key string. + * @regex: The regex to append to the bson. + * @regex_length: The length of the regex string. + * @options: Options for @regex. + * + * Appends a new field to @bson of type BSON_TYPE_REGEX. @regex should + * be the regex string. @options should contain the options for the regex. + * + * Valid options for @options are: + * + * 'i' for case-insensitive. + * 'm' for multiple matching. + * 'x' for verbose mode. + * 'l' to make \w and \W locale dependent. + * 's' for dotall mode ('.' matches everything) + * 'u' to make \w and \W match unicode. + * + * For more detailed information about BSON regex elements, see bsonspec.org. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_regex_w_len( + bson_t *bson, const char *key, int key_length, const char *regex, int regex_length, const char *options); + +BSON_EXPORT(bool) +bson_array_builder_append_regex_w_len(bson_array_builder_t *bab, + const char *regex, + int regex_length, + const char *options); + +/** + * bson_append_utf8: + * @bson: A bson_t. + * @key: The key for the field. + * @value: A UTF-8 encoded string. + * @length: The length of @value or -1 if it is NUL terminated. + * + * Appends a new field to @bson using @key as the key and @value as the UTF-8 + * encoded value. + * + * It is the callers responsibility to ensure @value is valid UTF-8. You can + * use bson_utf8_validate() to perform this check. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_utf8(bson_t *bson, const char *key, int key_length, const char *value, int length); + +#define BSON_APPEND_UTF8(b, key, val) bson_append_utf8(b, key, (int)strlen(key), val, (int)strlen(val)) + +BSON_EXPORT(bool) +bson_array_builder_append_utf8(bson_array_builder_t *bab, const char *value, int length); + +/** + * bson_append_symbol: + * @bson: A bson_t. + * @key: The key for the field. + * @value: The symbol as a string. + * @length: The length of @value or -1 if NUL-terminated. + * + * Appends a new field to @bson of type BSON_TYPE_SYMBOL. This BSON type is + * deprecated and should not be used in new code. + * + * See http://bsonspec.org for more information on this type. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_symbol(bson_t *bson, const char *key, int key_length, const char *value, int length); + +#define BSON_APPEND_SYMBOL(b, key, val) bson_append_symbol(b, key, (int)strlen(key), val, (int)strlen(val)) + +BSON_EXPORT(bool) +bson_array_builder_append_symbol(bson_array_builder_t *bab, const char *value, int length); + +/** + * bson_append_time_t: + * @bson: A bson_t. + * @key: The key for the field. + * @value: A time_t. + * + * Appends a BSON_TYPE_DATE_TIME field to @bson using the time_t @value for the + * number of seconds since UNIX epoch in UTC. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_time_t(bson_t *bson, const char *key, int key_length, time_t value); + +#define BSON_APPEND_TIME_T(b, key, val) bson_append_time_t(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_time_t(bson_array_builder_t *bab, time_t value); + +/** + * bson_append_timeval: + * @bson: A bson_t. + * @key: The key for the field. + * @value: A struct timeval containing the date and time. + * + * Appends a BSON_TYPE_DATE_TIME field to @bson using the struct timeval + * provided. The time is persisted in milliseconds since the UNIX epoch in UTC. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_timeval(bson_t *bson, const char *key, int key_length, struct timeval *value); + +#define BSON_APPEND_TIMEVAL(b, key, val) bson_append_timeval(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_timeval(bson_array_builder_t *bab, struct timeval *value); + +/** + * bson_append_date_time: + * @bson: A bson_t. + * @key: The key for the field. + * @key_length: The length of @key in bytes or -1 if \0 terminated. + * @value: The number of milliseconds elapsed since UNIX epoch. + * + * Appends a new field to @bson of type BSON_TYPE_DATE_TIME. + * + * Returns: true if successful; otherwise false. + */ +BSON_EXPORT(bool) +bson_append_date_time(bson_t *bson, const char *key, int key_length, int64_t value); + +#define BSON_APPEND_DATE_TIME(b, key, val) bson_append_date_time(b, key, (int)strlen(key), val) + +BSON_EXPORT(bool) +bson_array_builder_append_date_time(bson_array_builder_t *bab, int64_t value); + +/** + * bson_append_now_utc: + * @bson: A bson_t. + * @key: The key for the field. + * @key_length: The length of @key or -1 if it is NULL terminated. + * + * Appends a BSON_TYPE_DATE_TIME field to @bson using the current time in UTC + * as the field value. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_now_utc(bson_t *bson, const char *key, int key_length); + +#define BSON_APPEND_NOW_UTC(b, key) bson_append_now_utc(b, key, (int)strlen(key)) + +BSON_EXPORT(bool) +bson_array_builder_append_now_utc(bson_array_builder_t *bab); + +/** + * bson_append_timestamp: + * @bson: A bson_t. + * @key: The key for the field. + * @timestamp: 4 byte timestamp. + * @increment: 4 byte increment for timestamp. + * + * Appends a field of type BSON_TYPE_TIMESTAMP to @bson. This is a special type + * used by MongoDB replication and sharding. If you need generic time and date + * fields use bson_append_time_t() or bson_append_timeval(). + * + * Setting @increment and @timestamp to zero has special semantics. See + * http://bsonspec.org for more information on this field type. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_timestamp(bson_t *bson, const char *key, int key_length, uint32_t timestamp, uint32_t increment); + +#define BSON_APPEND_TIMESTAMP(b, key, val, inc) bson_append_timestamp(b, key, (int)strlen(key), val, inc) + +BSON_EXPORT(bool) +bson_array_builder_append_timestamp(bson_array_builder_t *bab, uint32_t timestamp, uint32_t increment); + +/** + * bson_append_undefined: + * @bson: A bson_t. + * @key: The key for the field. + * + * Appends a field of type BSON_TYPE_UNDEFINED. This type is deprecated in the + * spec and should not be used for new code. However, it is provided for those + * needing to interact with legacy systems. + * + * Returns: true if successful; false if append would overflow max size. + */ +BSON_EXPORT(bool) +bson_append_undefined(bson_t *bson, const char *key, int key_length); + +#define BSON_APPEND_UNDEFINED(b, key) bson_append_undefined(b, key, (int)strlen(key)) + +BSON_EXPORT(bool) +bson_array_builder_append_undefined(bson_array_builder_t *bab); + +BSON_EXPORT(bool) +bson_concat(bson_t *dst, const bson_t *src); + +BSON_EXPORT(bool) +bson_append_array_builder_begin(bson_t *bson, const char *key, int key_length, bson_array_builder_t **child); + +#define BSON_APPEND_ARRAY_BUILDER_BEGIN(b, key, child) bson_append_array_builder_begin(b, key, (int)strlen(key), child) + +BSON_EXPORT(bool) +bson_array_builder_append_array_builder_begin(bson_array_builder_t *bab, bson_array_builder_t **child); + +BSON_EXPORT(bool) +bson_append_array_builder_end(bson_t *bson, bson_array_builder_t *child); + +BSON_EXPORT(bool) +bson_array_builder_append_array_builder_end(bson_array_builder_t *bab, bson_array_builder_t *child); + + +BSON_END_DECLS + + +#endif /* BSON_H */ diff --git a/Vendor/mongo-c-driver/include/bson/bson_t.h b/Vendor/mongo-c-driver/include/bson/bson_t.h new file mode 100644 index 0000000..bd0d045 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/bson_t.h @@ -0,0 +1,61 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BSON_BSON_T_H_INCLUDED +#define BSON_BSON_T_H_INCLUDED + +#include + +#include + +/** + * bson_t: + * + * This structure manages a buffer whose contents are a properly formatted + * BSON document. You may perform various transforms on the BSON documents. + * Additionally, it can be iterated over using bson_iter_t. + * + * See bson_iter_init() for iterating the contents of a bson_t. + * + * When building a bson_t structure using the various append functions, + * memory allocations may occur. That is performed using power of two + * allocations and realloc(). + * + * See http://bsonspec.org for the BSON document spec. + * + * This structure is meant to fit in two sequential 64-byte cachelines. + */ +BSON_ALIGNED_BEGIN(BSON_ALIGN_OF_PTR) typedef struct _bson_t { + uint32_t flags; /* Internal flags for the bson_t. */ + uint32_t len; /* Length of BSON data. */ + uint8_t padding[120]; /* Padding for stack allocation. */ +} bson_t BSON_ALIGNED_END(BSON_ALIGN_OF_PTR); + +/** + * BSON_INITIALIZER: + * + * This macro can be used to initialize a #bson_t structure on the stack + * without calling bson_init(). + * + * |[ + * bson_t b = BSON_INITIALIZER; + * ]| + */ +#define BSON_INITIALIZER {3, 5, {5}} + +BSON_STATIC_ASSERT2(bson_t, sizeof(bson_t) == 128); + +#endif // BSON_BSON_T_H_INCLUDED diff --git a/Vendor/mongo-c-driver/include/bson/compat.h b/Vendor/mongo-c-driver/include/bson/compat.h new file mode 100644 index 0000000..8fea74c --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/compat.h @@ -0,0 +1,202 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BSON_COMPAT_H +#define BSON_COMPAT_H + + +#if defined(__MINGW32__) +#if defined(__USE_MINGW_ANSI_STDIO) +#if __USE_MINGW_ANSI_STDIO < 1 +#error "__USE_MINGW_ANSI_STDIO > 0 is required for correct PRI* macros" +#endif +#else +#define __USE_MINGW_ANSI_STDIO 1 +#endif +#endif + +#include // IWYU pragma: export +#include // IWYU pragma: export + + +#ifdef BSON_OS_WIN32 +#if defined(_WIN32_WINNT) && (_WIN32_WINNT < 0x0601) +#undef _WIN32_WINNT +#endif +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0601 +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include // IWYU pragma: export +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#include // IWYU pragma: export +#undef WIN32_LEAN_AND_MEAN +#else +#include // IWYU pragma: export +#endif +#include // IWYU pragma: export +#include // IWYU pragma: export +#endif + + +#ifdef BSON_OS_UNIX +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#endif + + +#include + +#include // IWYU pragma: export +#include // IWYU pragma: export + +#include // IWYU pragma: keep: to be removed. +#include // IWYU pragma: keep: to be removed. +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: export +#include // IWYU pragma: keep: to be removed. +#include // IWYU pragma: keep: to be removed. +#include // IWYU pragma: keep: to be removed. +#include // IWYU pragma: keep: to be removed. + + +BSON_BEGIN_DECLS + +#if !defined(_MSC_VER) || (_MSC_VER >= 1800) +#include // IWYU pragma: export +#endif +#ifdef _MSC_VER +#ifndef __cplusplus +/* benign redefinition of type */ +#pragma warning(disable : 4142) +#ifndef _SSIZE_T_DEFINED +#define _SSIZE_T_DEFINED +typedef SSIZE_T ssize_t; +#endif +#ifndef _SIZE_T_DEFINED +#define _SIZE_T_DEFINED +typedef SIZE_T size_t; +#endif +#pragma warning(default : 4142) +#else +/* + * MSVC++ does not include ssize_t, just size_t. + * So we need to synthesize that as well. + */ +#pragma warning(disable : 4142) +#ifndef _SSIZE_T_DEFINED +#define _SSIZE_T_DEFINED +typedef SSIZE_T ssize_t; +#endif +#pragma warning(default : 4142) +#endif +#ifndef PRIi32 +#define PRIi32 "d" +#endif +#ifndef PRId32 +#define PRId32 "d" +#endif +#ifndef PRIu32 +#define PRIu32 "u" +#endif +#ifndef PRIi64 +#define PRIi64 "I64i" +#endif +#ifndef PRId64 +#define PRId64 "I64i" +#endif +#ifndef PRIu64 +#define PRIu64 "I64u" +#endif +#endif + +/* Derive the maximum representable value of signed integer type T using the + * formula 2^(N - 1) - 1 where N is the number of bits in type T. This assumes + * T is represented using two's complement. */ +#define BSON_NUMERIC_LIMITS_MAX_SIGNED(T) ((T)((((size_t)0x01u) << (sizeof(T) * (size_t)CHAR_BIT - 1u)) - 1u)) + +/* Derive the minimum representable value of signed integer type T as one less + * than the negation of its maximum representable value. This assumes T is + * represented using two's complement. */ +#define BSON_NUMERIC_LIMITS_MIN_SIGNED(T, max) ((T)((-(max)) - 1)) + +/* Derive the maximum representable value of unsigned integer type T by flipping + * all its bits to 1. */ +#define BSON_NUMERIC_LIMITS_MAX_UNSIGNED(T) ((T)(~((T)0))) + +#ifndef SSIZE_MAX +#define SSIZE_MAX BSON_NUMERIC_LIMITS_MAX_SIGNED(ssize_t) +#endif + +#ifndef SSIZE_MIN +#define SSIZE_MIN BSON_NUMERIC_LIMITS_MIN_SIGNED(ssize_t, SSIZE_MAX) +#endif + +#if defined(__MINGW32__) && !defined(INIT_ONCE_STATIC_INIT) +#define INIT_ONCE_STATIC_INIT RTL_RUN_ONCE_INIT +typedef RTL_RUN_ONCE INIT_ONCE; +#endif + + +#if !defined(va_copy) && defined(__va_copy) +#define va_copy(dst, src) __va_copy(dst, src) +#endif + + +#if !defined(va_copy) +#define va_copy(dst, src) ((dst) = (src)) +#endif + + +#ifdef _MSC_VER +/** Expands the arguments if compiling with MSVC, otherwise empty */ +#define BSON_IF_MSVC(...) __VA_ARGS__ +/** Expands the arguments if compiling with GCC or Clang, otherwise empty */ +#define BSON_IF_GNU_LIKE(...) +#elif defined(__GNUC__) || defined(__clang__) +/** Expands the arguments if compiling with MSVC, otherwise empty */ +#define BSON_IF_MSVC(...) +/** Expands the arguments if compiling with GCC or Clang, otherwise empty */ +#define BSON_IF_GNU_LIKE(...) __VA_ARGS__ +#else +/** Unsupported compiler. **/ +#define BSON_IF_MSVC(...) +#define BSON_IF_GNU_LIKE(...) +#endif + +#ifdef BSON_OS_WIN32 +/** Expands the arguments if compiling for Windows, otherwise empty */ +#define BSON_IF_WINDOWS(...) __VA_ARGS__ +/** Expands the arguments if compiling for POSIX, otherwise empty */ +#define BSON_IF_POSIX(...) +#elif defined(BSON_OS_UNIX) +/** Expands the arguments if compiling for Windows, otherwise empty */ +#define BSON_IF_WINDOWS(...) +/** Expands the arguments if compiling for POSIX, otherwise empty */ +#define BSON_IF_POSIX(...) __VA_ARGS__ +#endif + + +BSON_END_DECLS + + +#endif /* BSON_COMPAT_H */ diff --git a/Vendor/mongo-c-driver/include/bson/config.h b/Vendor/mongo-c-driver/include/bson/config.h new file mode 100644 index 0000000..8d8f9ad --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/config.h @@ -0,0 +1,122 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BSON_CONFIG_H +#define BSON_CONFIG_H + +/* + * Define to 1234 for Little Endian, 4321 for Big Endian. + */ +#define BSON_BYTE_ORDER 1234 + + +/* + * Define to 1 if you have stdbool.h + */ +#define BSON_HAVE_STDBOOL_H 1 +#if BSON_HAVE_STDBOOL_H != 1 +# undef BSON_HAVE_STDBOOL_H +#endif + + +/* + * Define to 1 for POSIX-like systems, 2 for Windows. + */ +#define BSON_OS 1 + + +/* + * Define to 1 if you have clock_gettime() available. + */ +#define BSON_HAVE_CLOCK_GETTIME 1 +#if BSON_HAVE_CLOCK_GETTIME != 1 +# undef BSON_HAVE_CLOCK_GETTIME +#endif + + +/* + * Define to 1 if you have strings.h available on your platform. + */ +#define BSON_HAVE_STRINGS_H 1 +#if BSON_HAVE_STRINGS_H != 1 +# undef BSON_HAVE_STRINGS_H +#endif + + +/* + * Define to 1 if you have strnlen available on your platform. + */ +#define BSON_HAVE_STRNLEN 1 +#if BSON_HAVE_STRNLEN != 1 +# undef BSON_HAVE_STRNLEN +#endif + + +/* + * Define to 1 if you have snprintf available on your platform. + */ +#define BSON_HAVE_SNPRINTF 1 +#if BSON_HAVE_SNPRINTF != 1 +# undef BSON_HAVE_SNPRINTF +#endif + + +/* + * Define to 1 if you have gmtime_r available on your platform. + */ +#define BSON_HAVE_GMTIME_R 1 +#if BSON_HAVE_GMTIME_R != 1 +# undef BSON_HAVE_GMTIME_R +#endif + + +/* + * Define to 1 if you have struct timespec available on your platform. + */ +#define BSON_HAVE_TIMESPEC 1 +#if BSON_HAVE_TIMESPEC != 1 +# undef BSON_HAVE_TIMESPEC +#endif + + + +/* + * Define to 1 if you have rand_r available on your platform. + */ +#define BSON_HAVE_RAND_R 1 +#if BSON_HAVE_RAND_R != 1 +# undef BSON_HAVE_RAND_R +#endif + + +/* + * Define to 1 if you have strlcpy available on your platform. + */ +#define BSON_HAVE_STRLCPY 1 +#if BSON_HAVE_STRLCPY != 1 +# undef BSON_HAVE_STRLCPY +#endif + + +/* + * Define to 1 if you have aligned_alloc available on your platform. + */ +#define BSON_HAVE_ALIGNED_ALLOC 1 +#if BSON_HAVE_ALIGNED_ALLOC != 1 +# undef BSON_HAVE_ALIGNED_ALLOC +#endif + +#endif /* BSON_CONFIG_H */ diff --git a/Vendor/mongo-c-driver/include/bson/error.h b/Vendor/mongo-c-driver/include/bson/error.h new file mode 100644 index 0000000..f31fa7b --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/error.h @@ -0,0 +1,94 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BSON_ERROR_T_INCLUDED +#define BSON_ERROR_T_INCLUDED + +#include + +#include + +BSON_BEGIN_DECLS + +#define BSON_ERROR_BUFFER_SIZE 503 + +BSON_ALIGNED_BEGIN(BSON_ALIGN_OF_PTR) // Aligned for backwards-compatibility. +typedef struct _bson_error_t { + uint32_t domain; + uint32_t code; + char message[BSON_ERROR_BUFFER_SIZE]; + uint8_t reserved; // For internal use only! +} bson_error_t BSON_ALIGNED_END(BSON_ALIGN_OF_PTR); + + +BSON_STATIC_ASSERT2(error_t, sizeof(bson_error_t) == 512); + +#define BSON_ERROR_JSON 1 +#define BSON_ERROR_READER 2 +#define BSON_ERROR_INVALID 3 +#define BSON_ERROR_VECTOR 4 + +BSON_EXPORT(void) +bson_set_error(bson_error_t *error, uint32_t domain, uint32_t code, const char *format, ...) BSON_GNUC_PRINTF(4, 5); + +BSON_EXPORT(char *) +bson_strerror_r(int err_code, char *buf, size_t buflen); + +/** + * @brief Reset the content of a bson_error_t to indicate no error. + * + * @param error Pointer to an error to be overwritten. If null, this function + * has no effect. + * + * This is static-inline because it is trivially optimizable as a (conditional) + * `memset`. + */ +static inline void +bson_error_clear(bson_error_t *error) +{ + if (!error) { + return; + } + // Statically initialized to a zero struct: + static bson_error_t zero_error; + // Replace the caller's value: + *error = zero_error; +} + +/** + * @brief Given a `bson_error_t` pointer l-value, ensure that it is non-null, and clear any + * error value that it might hold. + * + * @param ErrorPointer An l-value expression of type `bson_error_t*`. + * + * If the passed pointer is null, then it will be updated to point to an anonymous + * `bson_error_t` object that lives in the caller's scope. + * + * @note This macro is not valid in C++ because it relies on C99 compound literal semantics + */ +#define bson_error_reset(ErrorPointer) bson_error_reset(&(ErrorPointer), &(bson_error_t){0}) +static inline void(bson_error_reset)(bson_error_t **error, bson_error_t *localptr) +{ + if (*error == NULL) { + *error = localptr; + } + bson_error_clear(*error); +} + +BSON_END_DECLS + + +#endif // BSON_ERROR_T_INCLUDED diff --git a/Vendor/mongo-c-driver/include/bson/macros.h b/Vendor/mongo-c-driver/include/bson/macros.h new file mode 100644 index 0000000..b9c8480 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/macros.h @@ -0,0 +1,417 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BSON_MACROS_H +#define BSON_MACROS_H + +#include // IWYU pragma: export + +#include +#include + +#ifdef __cplusplus +#include +#endif + + +#if BSON_OS == 1 +#define BSON_OS_UNIX +#elif BSON_OS == 2 +#define BSON_OS_WIN32 +#else +#error "Unknown operating system." +#endif + + +#ifdef __cplusplus +#define BSON_BEGIN_DECLS extern "C" { +#define BSON_END_DECLS } +#else +#define BSON_BEGIN_DECLS +#define BSON_END_DECLS +#endif + + +#if defined(__GNUC__) +#define BSON_GNUC_CHECK_VERSION(major, minor) \ + ((__GNUC__ > (major)) || ((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor)))) +#else +#define BSON_GNUC_CHECK_VERSION(major, minor) 0 +#endif + + +#if defined(__GNUC__) +#define BSON_GNUC_IS_VERSION(major, minor) ((__GNUC__ == (major)) && (__GNUC_MINOR__ == (minor))) +#else +#define BSON_GNUC_IS_VERSION(major, minor) 0 +#endif + + +/* Decorate public functions: + * - if BSON_STATIC, we're compiling a static libbson or a program + * that uses libbson as a static library. Don't decorate functions. + * - else if BSON_COMPILATION, we're compiling a shared libbson, mark + * public functions for export from the shared lib + * - else, we're compiling a program that uses libbson as a shared library, + * mark public functions as DLL imports for Microsoft Visual C + */ + +#ifdef _MSC_VER +/* + * Microsoft Visual C + */ +#ifdef BSON_STATIC +#define BSON_API +#elif defined(BSON_COMPILATION) +#define BSON_API __declspec(dllexport) +#else +#define BSON_API __declspec(dllimport) +#endif +#define BSON_CALL __cdecl + +#elif defined(__GNUC__) +/* + * GCC + */ +#ifdef BSON_STATIC +#define BSON_API +#elif defined(BSON_COMPILATION) +#define BSON_API __attribute__((visibility("default"))) +#else +#define BSON_API +#endif +#define BSON_CALL + +#else +/* + * Other compilers + */ +#define BSON_API +#define BSON_CALL + +#endif + +#define BSON_EXPORT(type) BSON_API type BSON_CALL + + +#ifdef MIN +#define BSON_MIN MIN +#elif defined(__cplusplus) +#define BSON_MIN(a, b) ((std::min)(a, b)) +#elif defined(_MSC_VER) +#define BSON_MIN(a, b) ((a) < (b) ? (a) : (b)) +#else +#define BSON_MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + + +#ifdef MAX +#define BSON_MAX MAX +#elif defined(__cplusplus) +#define BSON_MAX(a, b) ((std::max)(a, b)) +#elif defined(_MSC_VER) +#define BSON_MAX(a, b) ((a) > (b) ? (a) : (b)) +#else +#define BSON_MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + + +#ifdef ABS +#define BSON_ABS ABS +#else +#define BSON_ABS(a) (((a) < 0) ? ((a) * -1) : (a)) +#endif + +#if defined(__cplusplus) && (__cplusplus >= 201103L || defined(_MSVC_LANG)) +#define BSON_ALIGNOF(expr) alignof(expr) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#define BSON_ALIGNOF(expr) _Alignof(expr) +#else +#if defined(_MSC_VER) +#define BSON_ALIGNOF(expr) __alignof(expr) +#else +#define BSON_ALIGNOF(expr) __alignof__(expr) +#endif +#endif // __STDC_VERSION__ >= 201112L + +#ifdef _MSC_VER +// __declspec (align (_N)) only permits integer literals as _N. +#ifdef _WIN64 +#define BSON_ALIGN_OF_PTR 8 +#else +#define BSON_ALIGN_OF_PTR 4 +#endif +#else +#define BSON_ALIGN_OF_PTR (BSON_ALIGNOF(void *)) +#endif + +#if defined(_MSC_VER) +#define BSON_ALIGNED_BEGIN(_N) __declspec(align(BSON_ALIGN_OF_PTR)) +#define BSON_ALIGNED_END(_N) +#else +#define BSON_ALIGNED_BEGIN(_N) +#define BSON_ALIGNED_END(_N) __attribute__((aligned((_N) > BSON_ALIGN_OF_PTR ? BSON_ALIGN_OF_PTR : (_N)))) +#endif + + +#define bson_str_empty(s) (!s[0]) +#define bson_str_empty0(s) (!s || !s[0]) + + +#if defined(_MSC_VER) +#define BSON_FUNC __FUNCTION__ +#else +#define BSON_FUNC __func__ +#endif + + +#if defined(_MSC_VER) +#define BSON_INLINE __inline +#else +#define BSON_INLINE __inline__ +#endif + + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +#define BSON_NORETURN [[noreturn]] +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#define BSON_NORETURN _Noreturn +#elif defined(__GNUC__) && 2 < __GNUC__ + (8 <= __GNUC_MINOR__) +#define BSON_NORETURN __attribute__((__noreturn__)) +#else +#define BSON_NORETURN +#endif + + +#if defined(__GNUC__) +#define BSON_RESTRICT __restrict__ +#elif defined(_MSC_VER) +#define BSON_RESTRICT __restrict +#elif !defined(__cplusplus) +// C99 (not C++) +#define BSON_RESTRICT restrict +#else +#define BSON_RESTRICT +#endif + + +BSON_NORETURN static BSON_INLINE void +_bson_assert_failed_on_line(const char *file, int line, const char *func, const char *test) +{ + fprintf(stderr, "%s:%d %s(): assertion failed: %s\n", file, line, func, test); + abort(); +} + +BSON_NORETURN static BSON_INLINE void +_bson_assert_failed_on_param(const char *param, const char *func) +{ + fprintf(stderr, "The parameter: %s, in function %s, cannot be NULL\n", param, func); + abort(); +} + +#define BSON_ASSERT(test) \ + do { \ + if (!(BSON_LIKELY(test))) { \ + _bson_assert_failed_on_line(__FILE__, (int)(__LINE__), BSON_FUNC, #test); \ + } \ + } while (0) + +/** + * @brief Assert the expression `Assertion`, and evaluates to `Value` on + * success. + */ +#define BSON_ASSERT_INLINE(Assertion, Value) \ + ((void)((Assertion) ? (0) : (_bson_assert_failed_on_line(__FILE__, (int)(__LINE__), BSON_FUNC, #Assertion), 0)), \ + Value) + +/** + * @brief Assert that the given pointer is non-NULL, while also evaluating to + * that pointer. + * + * Can be used to inline assertions with a pointer dereference: + * + * ``` + * foo* f = get_foo(); + * bar* b = BSON_ASSERT_PTR_INLINE(f)->bar_value; + * ``` + */ +#define BSON_ASSERT_PTR_INLINE(Pointer) BSON_ASSERT_INLINE((Pointer) != NULL, (Pointer)) + +/* Used for asserting parameters to provide a more precise error message */ +#define BSON_ASSERT_PARAM(param) \ + do { \ + if ((BSON_UNLIKELY(param == NULL))) { \ + _bson_assert_failed_on_param(#param, BSON_FUNC); \ + } \ + } while (0) + +// `BSON_OPTIONAL_PARAM` is a documentation-only macro to document X may be NULL. +// Useful in combination with `BSON_ASSERT_PARAM` to document and assert pointer parameters. +#define BSON_OPTIONAL_PARAM(param) ((void)param) + +/* obsolete macros, preserved for compatibility */ +#define BSON_STATIC_ASSERT(s) BSON_STATIC_ASSERT_(s, __LINE__) +#define BSON_STATIC_ASSERT_JOIN(a, b) BSON_STATIC_ASSERT_JOIN2(a, b) +#define BSON_STATIC_ASSERT_JOIN2(a, b) a##b +#define BSON_STATIC_ASSERT_(s, l) typedef char BSON_STATIC_ASSERT_JOIN(static_assert_test_, __LINE__)[(s) ? 1 : -1] + +/* modern macros */ +#define BSON_STATIC_ASSERT2(_name, _s) BSON_STATIC_ASSERT2_(_s, __LINE__, _name) +#define BSON_STATIC_ASSERT_JOIN3(_a, _b, _name) BSON_STATIC_ASSERT_JOIN4(_a, _b, _name) +#define BSON_STATIC_ASSERT_JOIN4(_a, _b, _name) _a##_b##_name +#define BSON_STATIC_ASSERT2_(_s, _l, _name) \ + typedef char BSON_STATIC_ASSERT_JOIN3(static_assert_test_, __LINE__, _name)[(_s) ? 1 : -1] + + +#if defined(__GNUC__) +#define BSON_GNUC_PURE __attribute__((pure)) +#define BSON_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define BSON_GNUC_PURE +#define BSON_GNUC_WARN_UNUSED_RESULT +#endif + + +#if BSON_GNUC_CHECK_VERSION(4, 0) && !defined(_WIN32) +#define BSON_GNUC_NULL_TERMINATED __attribute__((sentinel)) +#define BSON_GNUC_INTERNAL __attribute__((visibility("hidden"))) +#else +#define BSON_GNUC_NULL_TERMINATED +#define BSON_GNUC_INTERNAL +#endif + + +#if defined(__GNUC__) +#define BSON_LIKELY(x) __builtin_expect(!!(x), 1) +#define BSON_UNLIKELY(x) __builtin_expect(!!(x), 0) +#else +#define BSON_LIKELY(v) v +#define BSON_UNLIKELY(v) v +#endif + + +#if defined(__clang__) +#define BSON_GNUC_PRINTF(f, v) __attribute__((format(printf, f, v))) +#elif BSON_GNUC_CHECK_VERSION(4, 4) +#define BSON_GNUC_PRINTF(f, v) __attribute__((format(gnu_printf, f, v))) +#else +#define BSON_GNUC_PRINTF(f, v) +#endif + + +#if defined(__LP64__) || defined(_LP64) +#define BSON_WORD_SIZE 64 +#else +#define BSON_WORD_SIZE 32 +#endif + + +#ifdef _MSC_VER +#define BSON_ENSURE_ARRAY_PARAM_SIZE(_n) +#define BSON_TYPEOF decltype +#else +#define BSON_ENSURE_ARRAY_PARAM_SIZE(_n) static(_n) +#define BSON_TYPEOF typeof +#endif + +/** + * @brief Statically annotate an entity as deprecated, including the given deprecation message + * + * @param Message The message to be included in a deprecation warning. This + * should be a string literal. + */ +#define BSON_DEPRECATED(Message) _bsonDeprecatedImpl(Message) + +// Pick the appropriate implementation of a deprecation attribute +#if defined(_MSC_VER) +// For MSVC, emit __declspec(deprecated(Msg)) +#define _bsonDeprecatedImpl(Msg) __declspec(deprecated(Msg)) +#elif defined(__GNUC__) && (defined(__clang__) || BSON_GNUC_CHECK_VERSION(4, 5)) +// For new enough Clang and GCC, emit __attribute__((__deprecated__(Msg))) +#define _bsonDeprecatedImpl(Msg) __attribute__((__deprecated__(Msg))) +#elif defined(__GNUC__) +// For older GCC, emit deprecation attribute without the message +#define _bsonDeprecatedImpl(Msg) __attribute__((__deprecated__)) +#else +// For other compilers, emit nothing +#define _bsonDeprecatedImpl(Msg) +#endif + +#define BSON_DEPRECATED_FOR(F) BSON_DEPRECATED("This API is deprecated. Use " #F " instead.") + +#define BSON_GNUC_DEPRECATED BSON_DEPRECATED("This API is deprecated") +#define BSON_GNUC_DEPRECATED_FOR(F) BSON_DEPRECATED_FOR(F) + +#define BSON_CONCAT_IMPL(a, ...) a##__VA_ARGS__ +#define BSON_CONCAT(a, ...) BSON_CONCAT_IMPL(a, __VA_ARGS__) +#define BSON_CONCAT3(a, b, c) BSON_CONCAT(a, BSON_CONCAT(b, c)) +#define BSON_CONCAT4(a, b, c, d) BSON_CONCAT(BSON_CONCAT(a, b), BSON_CONCAT(c, d)) + + +/** + * @brief String-ify the given argument + */ +#define BSON_STR(...) #__VA_ARGS__ + +/** + * @brief Mark the attached declared entity as "possibly-unused." + * + * Does nothing on MSVC. + */ +#if defined(__GNUC__) || defined(__clang__) +#define BSON_MAYBE_UNUSED __attribute__((unused)) +#else +#define BSON_MAYBE_UNUSED /* Nothing for other compilers */ +#endif + +/** + * @brief Mark a point in the code as unreachable. If the point is reached, the + * program will abort with an error message. + * + * @param What A string to include in the error message if this point is ever + * executed. + */ +#define BSON_UNREACHABLE(What) \ + do { \ + fprintf(stderr, "%s:%d %s(): Unreachable code reached: %s\n", __FILE__, (int)(__LINE__), BSON_FUNC, What); \ + abort(); \ + } while (0) + +/** + * @brief Silence warnings for deliberately unused variables or parameters. + * + * @param expr An unused variable or parameter. + * + */ +#define BSON_UNUSED(expr) \ + do { \ + (void)(expr); \ + } while (0) + +// Disable the -Wunsafe-buffer-usage warning. +#define BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN +#define BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END +#if defined(__clang__) +#if __has_warning("-Wunsafe-buffer-usage") +#undef BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN +#undef BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END +#define BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_BEGIN \ + _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wunsafe-buffer-usage\"") +#define BSON_DISABLE_UNSAFE_BUFFER_USAGE_WARNING_END _Pragma("clang diagnostic pop") +#endif // __has_warning("-Wunsafe-buffer-usage") +#endif // defined(__clang__) + +#endif /* BSON_MACROS_H */ diff --git a/Vendor/mongo-c-driver/include/bson/memory.h b/Vendor/mongo-c-driver/include/bson/memory.h new file mode 100644 index 0000000..1c8fc5f --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/memory.h @@ -0,0 +1,71 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BSON_MEMORY_H_INCLUDED +#define BSON_MEMORY_H_INCLUDED + +#include + + +BSON_BEGIN_DECLS + + +typedef void *(BSON_CALL *bson_realloc_func)(void *mem, size_t num_bytes, void *ctx); + +typedef struct _bson_mem_vtable_t { + void *(BSON_CALL *malloc)(size_t num_bytes); + void *(BSON_CALL *calloc)(size_t n_members, size_t num_bytes); + void *(BSON_CALL *realloc)(void *mem, size_t num_bytes); + void(BSON_CALL *free)(void *mem); + void *(BSON_CALL *aligned_alloc)(size_t alignment, size_t num_bytes); + void *padding[3]; +} bson_mem_vtable_t; + + +BSON_EXPORT(void) +bson_mem_set_vtable(const bson_mem_vtable_t *vtable); +BSON_EXPORT(void) +bson_mem_restore_vtable(void); +BSON_EXPORT(void *) +bson_malloc(size_t num_bytes); +BSON_EXPORT(void *) +bson_malloc0(size_t num_bytes); +BSON_EXPORT(void *) +bson_aligned_alloc(size_t alignment, size_t num_bytes); +BSON_EXPORT(void *) +bson_aligned_alloc0(size_t alignment, size_t num_bytes); +BSON_EXPORT(void *) +bson_array_alloc(size_t num_elems, size_t elem_size); +BSON_EXPORT(void *) +bson_array_alloc0(size_t num_elems, size_t elem_size); +BSON_EXPORT(void *) +bson_realloc(void *mem, size_t num_bytes); +BSON_EXPORT(void *) +bson_realloc_ctx(void *mem, size_t num_bytes, void *ctx); +BSON_EXPORT(void) +bson_free(void *mem); +BSON_EXPORT(void) +bson_zero_free(void *mem, size_t size); + + +#define BSON_ALIGNED_ALLOC(T) ((T *)(bson_aligned_alloc(BSON_ALIGNOF(T), sizeof(T)))) +#define BSON_ALIGNED_ALLOC0(T) ((T *)(bson_aligned_alloc0(BSON_ALIGNOF(T), sizeof(T)))) +#define BSON_ARRAY_ALLOC(N, T) ((T *)(bson_array_alloc(N, sizeof(T)))) +#define BSON_ARRAY_ALLOC0(N, T) ((T *)(bson_array_alloc0(N, sizeof(T)))) + +BSON_END_DECLS + +#endif // BSON_MEMORY_H_INCLUDED diff --git a/Vendor/mongo-c-driver/include/bson/version.h b/Vendor/mongo-c-driver/include/bson/version.h new file mode 100644 index 0000000..4b96311 --- /dev/null +++ b/Vendor/mongo-c-driver/include/bson/version.h @@ -0,0 +1,97 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// clang-format off + +#ifndef BSON_VERSION_H +#define BSON_VERSION_H + + +/** + * BSON_MAJOR_VERSION: + * + * BSON major version component (e.g. 1 if %BSON_VERSION is 1.2.3) + */ +#define BSON_MAJOR_VERSION (2) + + +/** + * BSON_MINOR_VERSION: + * + * BSON minor version component (e.g. 2 if %BSON_VERSION is 1.2.3) + */ +#define BSON_MINOR_VERSION (2) + + +/** + * BSON_MICRO_VERSION: + * + * BSON micro version component (e.g. 3 if %BSON_VERSION is 1.2.3) + */ +#define BSON_MICRO_VERSION (4) + + +/** + * BSON_PRERELEASE_VERSION: + * + * BSON prerelease version component (e.g. pre if %BSON_VERSION is 1.2.3-pre) + */ +#define BSON_PRERELEASE_VERSION () + +/** + * BSON_VERSION: + * + * BSON version. + */ +#define BSON_VERSION (2.2.4) + + +/** + * BSON_VERSION_S: + * + * BSON version, encoded as a string, useful for printing and + * concatenation. + */ +#define BSON_VERSION_S "2.2.4" + + +/** + * BSON_VERSION_HEX: + * + * BSON version, encoded as an hexadecimal number, useful for + * integer comparisons. + */ +#define BSON_VERSION_HEX (BSON_MAJOR_VERSION << 24 | \ + BSON_MINOR_VERSION << 16 | \ + BSON_MICRO_VERSION << 8) + + +/** + * BSON_CHECK_VERSION: + * @major: required major version + * @minor: required minor version + * @micro: required micro version + * + * Compile-time version checking. Evaluates to %TRUE if the version + * of BSON is greater than or equal to the required one. + */ +#define BSON_CHECK_VERSION(major,minor,micro) \ + (BSON_MAJOR_VERSION > (major) || \ + (BSON_MAJOR_VERSION == (major) && BSON_MINOR_VERSION > (minor)) || \ + (BSON_MAJOR_VERSION == (major) && BSON_MINOR_VERSION == (minor) && \ + BSON_MICRO_VERSION >= (micro))) + +#endif /* BSON_VERSION_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-apm.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-apm.h new file mode 100644 index 0000000..009b7e2 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-apm.h @@ -0,0 +1,379 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_APM_H +#define MONGOC_APM_H + +#include +#include +#include +#include + +#include + +BSON_BEGIN_DECLS + +/* + * Application Performance Management (APM) interface, complies with two specs. + * MongoDB's Command Logging and Monitoring Spec: + * + * https://github.com/mongodb/specifications/tree/master/source/command-logging-and-monitoring + * + * MongoDB's Spec for Monitoring Server Discovery and Monitoring (SDAM) events: + * + * https://github.com/mongodb/specifications/tree/master/source/server-discovery-and-monitoring + * + */ + +/* + * callbacks to receive APM events + */ + +typedef struct _mongoc_apm_callbacks_t mongoc_apm_callbacks_t; + + +/* + * command monitoring events + */ + +typedef struct _mongoc_apm_command_started_t mongoc_apm_command_started_t; +typedef struct _mongoc_apm_command_succeeded_t mongoc_apm_command_succeeded_t; +typedef struct _mongoc_apm_command_failed_t mongoc_apm_command_failed_t; + + +/* + * SDAM monitoring events + */ + +typedef struct _mongoc_apm_server_changed_t mongoc_apm_server_changed_t; +typedef struct _mongoc_apm_server_opening_t mongoc_apm_server_opening_t; +typedef struct _mongoc_apm_server_closed_t mongoc_apm_server_closed_t; +typedef struct _mongoc_apm_topology_changed_t mongoc_apm_topology_changed_t; +typedef struct _mongoc_apm_topology_opening_t mongoc_apm_topology_opening_t; +typedef struct _mongoc_apm_topology_closed_t mongoc_apm_topology_closed_t; +typedef struct _mongoc_apm_server_heartbeat_started_t mongoc_apm_server_heartbeat_started_t; +typedef struct _mongoc_apm_server_heartbeat_succeeded_t mongoc_apm_server_heartbeat_succeeded_t; +typedef struct _mongoc_apm_server_heartbeat_failed_t mongoc_apm_server_heartbeat_failed_t; + +/* + * event field accessors + */ + +/* command-started event fields */ + + +MONGOC_EXPORT(const bson_t *) +mongoc_apm_command_started_get_command(const mongoc_apm_command_started_t *event); + +MONGOC_EXPORT(const char *) +mongoc_apm_command_started_get_database_name(const mongoc_apm_command_started_t *event); + +MONGOC_EXPORT(const char *) +mongoc_apm_command_started_get_command_name(const mongoc_apm_command_started_t *event); + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_started_get_request_id(const mongoc_apm_command_started_t *event); + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_started_get_operation_id(const mongoc_apm_command_started_t *event); + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_apm_command_started_get_host(const mongoc_apm_command_started_t *event); + +MONGOC_EXPORT(uint32_t) +mongoc_apm_command_started_get_server_id(const mongoc_apm_command_started_t *event); + +MONGOC_EXPORT(const bson_oid_t *) +mongoc_apm_command_started_get_service_id(const mongoc_apm_command_started_t *event); + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_started_get_server_connection_id_int64(const mongoc_apm_command_started_t *event); + +MONGOC_EXPORT(void *) +mongoc_apm_command_started_get_context(const mongoc_apm_command_started_t *event); + +/* command-succeeded event fields */ + + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_succeeded_get_duration(const mongoc_apm_command_succeeded_t *event); + +MONGOC_EXPORT(const bson_t *) +mongoc_apm_command_succeeded_get_reply(const mongoc_apm_command_succeeded_t *event); + +MONGOC_EXPORT(const char *) +mongoc_apm_command_succeeded_get_command_name(const mongoc_apm_command_succeeded_t *event); + +MONGOC_EXPORT(const char *) +mongoc_apm_command_succeeded_get_database_name(const mongoc_apm_command_succeeded_t *event); + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_succeeded_get_request_id(const mongoc_apm_command_succeeded_t *event); + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_succeeded_get_operation_id(const mongoc_apm_command_succeeded_t *event); + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_apm_command_succeeded_get_host(const mongoc_apm_command_succeeded_t *event); + +MONGOC_EXPORT(uint32_t) +mongoc_apm_command_succeeded_get_server_id(const mongoc_apm_command_succeeded_t *event); + +MONGOC_EXPORT(const bson_oid_t *) +mongoc_apm_command_succeeded_get_service_id(const mongoc_apm_command_succeeded_t *event); + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_succeeded_get_server_connection_id_int64(const mongoc_apm_command_succeeded_t *event); + +MONGOC_EXPORT(void *) +mongoc_apm_command_succeeded_get_context(const mongoc_apm_command_succeeded_t *event); + +/* command-failed event fields */ + + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_failed_get_duration(const mongoc_apm_command_failed_t *event); + +MONGOC_EXPORT(const char *) +mongoc_apm_command_failed_get_command_name(const mongoc_apm_command_failed_t *event); + +MONGOC_EXPORT(const char *) +mongoc_apm_command_failed_get_database_name(const mongoc_apm_command_failed_t *event); +/* retrieve the error by filling out the passed-in "error" struct */ + +MONGOC_EXPORT(void) +mongoc_apm_command_failed_get_error(const mongoc_apm_command_failed_t *event, bson_error_t *error); + +MONGOC_EXPORT(const bson_t *) +mongoc_apm_command_failed_get_reply(const mongoc_apm_command_failed_t *event); + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_failed_get_request_id(const mongoc_apm_command_failed_t *event); + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_failed_get_operation_id(const mongoc_apm_command_failed_t *event); + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_apm_command_failed_get_host(const mongoc_apm_command_failed_t *event); + +MONGOC_EXPORT(uint32_t) +mongoc_apm_command_failed_get_server_id(const mongoc_apm_command_failed_t *event); + +MONGOC_EXPORT(const bson_oid_t *) +mongoc_apm_command_failed_get_service_id(const mongoc_apm_command_failed_t *event); + +MONGOC_EXPORT(int64_t) +mongoc_apm_command_failed_get_server_connection_id_int64(const mongoc_apm_command_failed_t *event); + +MONGOC_EXPORT(void *) +mongoc_apm_command_failed_get_context(const mongoc_apm_command_failed_t *event); + +/* server-changed event fields */ + + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_apm_server_changed_get_host(const mongoc_apm_server_changed_t *event); + +MONGOC_EXPORT(void) +mongoc_apm_server_changed_get_topology_id(const mongoc_apm_server_changed_t *event, bson_oid_t *topology_id); + +MONGOC_EXPORT(const mongoc_server_description_t *) +mongoc_apm_server_changed_get_previous_description(const mongoc_apm_server_changed_t *event); + +MONGOC_EXPORT(const mongoc_server_description_t *) +mongoc_apm_server_changed_get_new_description(const mongoc_apm_server_changed_t *event); + +MONGOC_EXPORT(void *) +mongoc_apm_server_changed_get_context(const mongoc_apm_server_changed_t *event); + +/* server-opening event fields */ + + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_apm_server_opening_get_host(const mongoc_apm_server_opening_t *event); + +MONGOC_EXPORT(void) +mongoc_apm_server_opening_get_topology_id(const mongoc_apm_server_opening_t *event, bson_oid_t *topology_id); + +MONGOC_EXPORT(void *) +mongoc_apm_server_opening_get_context(const mongoc_apm_server_opening_t *event); + +/* server-closed event fields */ + + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_apm_server_closed_get_host(const mongoc_apm_server_closed_t *event); + +MONGOC_EXPORT(void) +mongoc_apm_server_closed_get_topology_id(const mongoc_apm_server_closed_t *event, bson_oid_t *topology_id); + +MONGOC_EXPORT(void *) +mongoc_apm_server_closed_get_context(const mongoc_apm_server_closed_t *event); + +/* topology-changed event fields */ + + +MONGOC_EXPORT(void) +mongoc_apm_topology_changed_get_topology_id(const mongoc_apm_topology_changed_t *event, bson_oid_t *topology_id); + +MONGOC_EXPORT(const mongoc_topology_description_t *) +mongoc_apm_topology_changed_get_previous_description(const mongoc_apm_topology_changed_t *event); + +MONGOC_EXPORT(const mongoc_topology_description_t *) +mongoc_apm_topology_changed_get_new_description(const mongoc_apm_topology_changed_t *event); + +MONGOC_EXPORT(void *) +mongoc_apm_topology_changed_get_context(const mongoc_apm_topology_changed_t *event); + +/* topology-opening event field */ + + +MONGOC_EXPORT(void) +mongoc_apm_topology_opening_get_topology_id(const mongoc_apm_topology_opening_t *event, bson_oid_t *topology_id); + +MONGOC_EXPORT(void *) +mongoc_apm_topology_opening_get_context(const mongoc_apm_topology_opening_t *event); + +/* topology-closed event field */ + + +MONGOC_EXPORT(void) +mongoc_apm_topology_closed_get_topology_id(const mongoc_apm_topology_closed_t *event, bson_oid_t *topology_id); + +MONGOC_EXPORT(void *) +mongoc_apm_topology_closed_get_context(const mongoc_apm_topology_closed_t *event); + +/* heartbeat-started event field */ + + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_apm_server_heartbeat_started_get_host(const mongoc_apm_server_heartbeat_started_t *event); + +MONGOC_EXPORT(void *) +mongoc_apm_server_heartbeat_started_get_context(const mongoc_apm_server_heartbeat_started_t *event); + +MONGOC_EXPORT(bool) +mongoc_apm_server_heartbeat_started_get_awaited(const mongoc_apm_server_heartbeat_started_t *event); + +/* heartbeat-succeeded event fields */ + + +MONGOC_EXPORT(int64_t) +mongoc_apm_server_heartbeat_succeeded_get_duration(const mongoc_apm_server_heartbeat_succeeded_t *event); + +MONGOC_EXPORT(const bson_t *) +mongoc_apm_server_heartbeat_succeeded_get_reply(const mongoc_apm_server_heartbeat_succeeded_t *event); + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_apm_server_heartbeat_succeeded_get_host(const mongoc_apm_server_heartbeat_succeeded_t *event); + +MONGOC_EXPORT(void *) +mongoc_apm_server_heartbeat_succeeded_get_context(const mongoc_apm_server_heartbeat_succeeded_t *event); + +MONGOC_EXPORT(bool) +mongoc_apm_server_heartbeat_succeeded_get_awaited(const mongoc_apm_server_heartbeat_succeeded_t *event); + +/* heartbeat-failed event fields */ + + +MONGOC_EXPORT(int64_t) +mongoc_apm_server_heartbeat_failed_get_duration(const mongoc_apm_server_heartbeat_failed_t *event); + +MONGOC_EXPORT(void) +mongoc_apm_server_heartbeat_failed_get_error(const mongoc_apm_server_heartbeat_failed_t *event, bson_error_t *error); + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_apm_server_heartbeat_failed_get_host(const mongoc_apm_server_heartbeat_failed_t *event); + +MONGOC_EXPORT(void *) +mongoc_apm_server_heartbeat_failed_get_context(const mongoc_apm_server_heartbeat_failed_t *event); + +MONGOC_EXPORT(bool) +mongoc_apm_server_heartbeat_failed_get_awaited(const mongoc_apm_server_heartbeat_failed_t *event); + + +/* + * callbacks + */ + +typedef void(BSON_CALL *mongoc_apm_command_started_cb_t)(const mongoc_apm_command_started_t *event); +typedef void(BSON_CALL *mongoc_apm_command_succeeded_cb_t)(const mongoc_apm_command_succeeded_t *event); +typedef void(BSON_CALL *mongoc_apm_command_failed_cb_t)(const mongoc_apm_command_failed_t *event); +typedef void(BSON_CALL *mongoc_apm_server_changed_cb_t)(const mongoc_apm_server_changed_t *event); +typedef void(BSON_CALL *mongoc_apm_server_opening_cb_t)(const mongoc_apm_server_opening_t *event); +typedef void(BSON_CALL *mongoc_apm_server_closed_cb_t)(const mongoc_apm_server_closed_t *event); +typedef void(BSON_CALL *mongoc_apm_topology_changed_cb_t)(const mongoc_apm_topology_changed_t *event); +typedef void(BSON_CALL *mongoc_apm_topology_opening_cb_t)(const mongoc_apm_topology_opening_t *event); +typedef void(BSON_CALL *mongoc_apm_topology_closed_cb_t)(const mongoc_apm_topology_closed_t *event); +typedef void(BSON_CALL *mongoc_apm_server_heartbeat_started_cb_t)(const mongoc_apm_server_heartbeat_started_t *event); +typedef void(BSON_CALL *mongoc_apm_server_heartbeat_succeeded_cb_t)( + const mongoc_apm_server_heartbeat_succeeded_t *event); +typedef void(BSON_CALL *mongoc_apm_server_heartbeat_failed_cb_t)(const mongoc_apm_server_heartbeat_failed_t *event); + +/* + * registering callbacks + */ + + +MONGOC_EXPORT(mongoc_apm_callbacks_t *) +mongoc_apm_callbacks_new(void) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_apm_callbacks_destroy(mongoc_apm_callbacks_t *callbacks); + +MONGOC_EXPORT(void) +mongoc_apm_set_command_started_cb(mongoc_apm_callbacks_t *callbacks, mongoc_apm_command_started_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_command_succeeded_cb(mongoc_apm_callbacks_t *callbacks, mongoc_apm_command_succeeded_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_command_failed_cb(mongoc_apm_callbacks_t *callbacks, mongoc_apm_command_failed_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_server_changed_cb(mongoc_apm_callbacks_t *callbacks, mongoc_apm_server_changed_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_server_opening_cb(mongoc_apm_callbacks_t *callbacks, mongoc_apm_server_opening_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_server_closed_cb(mongoc_apm_callbacks_t *callbacks, mongoc_apm_server_closed_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_topology_changed_cb(mongoc_apm_callbacks_t *callbacks, mongoc_apm_topology_changed_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_topology_opening_cb(mongoc_apm_callbacks_t *callbacks, mongoc_apm_topology_opening_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_topology_closed_cb(mongoc_apm_callbacks_t *callbacks, mongoc_apm_topology_closed_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_server_heartbeat_started_cb(mongoc_apm_callbacks_t *callbacks, + mongoc_apm_server_heartbeat_started_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_server_heartbeat_succeeded_cb(mongoc_apm_callbacks_t *callbacks, + mongoc_apm_server_heartbeat_succeeded_cb_t cb); + +MONGOC_EXPORT(void) +mongoc_apm_set_server_heartbeat_failed_cb(mongoc_apm_callbacks_t *callbacks, + mongoc_apm_server_heartbeat_failed_cb_t cb); +BSON_END_DECLS + +#endif /* MONGOC_APM_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-bulk-operation.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-bulk-operation.h new file mode 100644 index 0000000..5fa213f --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-bulk-operation.h @@ -0,0 +1,160 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef MONGOC_BULK_OPERATION_H +#define MONGOC_BULK_OPERATION_H + + +#include +#include + +#include + +/* ordered, bypass_document_validation, has_collation, multi */ +#define MONGOC_BULK_WRITE_FLAGS_INIT {true, false, 0} + +BSON_BEGIN_DECLS + +/* forward decl */ +struct _mongoc_client_session_t; + +typedef struct _mongoc_bulk_operation_t mongoc_bulk_operation_t; +typedef struct _mongoc_bulk_write_flags_t mongoc_bulk_write_flags_t; + + +MONGOC_EXPORT(void) +mongoc_bulk_operation_destroy(mongoc_bulk_operation_t *bulk); + +MONGOC_EXPORT(uint32_t) +mongoc_bulk_operation_execute(mongoc_bulk_operation_t *bulk, bson_t *reply, bson_error_t *error); + +MONGOC_EXPORT(void) +mongoc_bulk_operation_insert(mongoc_bulk_operation_t *bulk, const bson_t *document); + +MONGOC_EXPORT(bool) +mongoc_bulk_operation_insert_with_opts(mongoc_bulk_operation_t *bulk, + const bson_t *document, + const bson_t *opts, + bson_error_t *error); /* OUT */ + +MONGOC_EXPORT(void) +mongoc_bulk_operation_remove(mongoc_bulk_operation_t *bulk, const bson_t *selector); + +MONGOC_EXPORT(bool) +mongoc_bulk_operation_remove_many_with_opts(mongoc_bulk_operation_t *bulk, + const bson_t *selector, + const bson_t *opts, + bson_error_t *error); /* OUT */ + +MONGOC_EXPORT(void) +mongoc_bulk_operation_remove_one(mongoc_bulk_operation_t *bulk, const bson_t *selector); + +MONGOC_EXPORT(bool) +mongoc_bulk_operation_remove_one_with_opts(mongoc_bulk_operation_t *bulk, + const bson_t *selector, + const bson_t *opts, + bson_error_t *error); /* OUT */ + +MONGOC_EXPORT(void) +mongoc_bulk_operation_replace_one(mongoc_bulk_operation_t *bulk, + const bson_t *selector, + const bson_t *document, + bool upsert); + +MONGOC_EXPORT(bool) +mongoc_bulk_operation_replace_one_with_opts(mongoc_bulk_operation_t *bulk, + const bson_t *selector, + const bson_t *document, + const bson_t *opts, + bson_error_t *error); /* OUT */ + +MONGOC_EXPORT(void) +mongoc_bulk_operation_update(mongoc_bulk_operation_t *bulk, + const bson_t *selector, + const bson_t *document, + bool upsert); + +MONGOC_EXPORT(bool) +mongoc_bulk_operation_update_many_with_opts(mongoc_bulk_operation_t *bulk, + const bson_t *selector, + const bson_t *document, + const bson_t *opts, + bson_error_t *error); /* OUT */ + +MONGOC_EXPORT(void) +mongoc_bulk_operation_update_one(mongoc_bulk_operation_t *bulk, + const bson_t *selector, + const bson_t *document, + bool upsert); + +MONGOC_EXPORT(bool) +mongoc_bulk_operation_update_one_with_opts(mongoc_bulk_operation_t *bulk, + const bson_t *selector, + const bson_t *document, + const bson_t *opts, + bson_error_t *error); /* OUT */ + +MONGOC_EXPORT(void) +mongoc_bulk_operation_set_bypass_document_validation(mongoc_bulk_operation_t *bulk, bool bypass); + +MONGOC_EXPORT(void) +mongoc_bulk_operation_set_comment(mongoc_bulk_operation_t *bulk, const bson_value_t *comment); + +MONGOC_EXPORT(void) +mongoc_bulk_operation_set_let(mongoc_bulk_operation_t *bulk, const bson_t *let); + + +/* + * The following functions are really only useful by language bindings and + * those wanting to replay a bulk operation to a number of clients or + * collections. + */ + +MONGOC_EXPORT(mongoc_bulk_operation_t *) +mongoc_bulk_operation_new(bool ordered) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_bulk_operation_set_write_concern(mongoc_bulk_operation_t *bulk, const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(void) +mongoc_bulk_operation_set_database(mongoc_bulk_operation_t *bulk, const char *database); + +MONGOC_EXPORT(void) +mongoc_bulk_operation_set_collection(mongoc_bulk_operation_t *bulk, const char *collection); + +MONGOC_EXPORT(void) +mongoc_bulk_operation_set_client(mongoc_bulk_operation_t *bulk, void *client); + +MONGOC_EXPORT(void) +mongoc_bulk_operation_set_client_session(mongoc_bulk_operation_t *bulk, + struct _mongoc_client_session_t *client_session); + +MONGOC_EXPORT(void) +mongoc_bulk_operation_set_server_id(mongoc_bulk_operation_t *bulk, uint32_t server_id); + +MONGOC_EXPORT(uint32_t) +mongoc_bulk_operation_get_server_id(const mongoc_bulk_operation_t *bulk); + +MONGOC_EXPORT(const mongoc_write_concern_t *) +mongoc_bulk_operation_get_write_concern(const mongoc_bulk_operation_t *bulk); + +BSON_END_DECLS + + +#endif /* MONGOC_BULK_OPERATION_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-bulkwrite.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-bulkwrite.h new file mode 100644 index 0000000..2a76ddf --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-bulkwrite.h @@ -0,0 +1,289 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_BULKWRITE_H +#define MONGOC_BULKWRITE_H + +#include +#include + +BSON_BEGIN_DECLS + +typedef struct _mongoc_bulkwriteopts_t mongoc_bulkwriteopts_t; +MONGOC_EXPORT(mongoc_bulkwriteopts_t *) +mongoc_bulkwriteopts_new(void); +MONGOC_EXPORT(void) +mongoc_bulkwriteopts_set_ordered(mongoc_bulkwriteopts_t *self, bool ordered); +MONGOC_EXPORT(void) +mongoc_bulkwriteopts_set_bypassdocumentvalidation(mongoc_bulkwriteopts_t *self, bool bypassdocumentvalidation); +MONGOC_EXPORT(void) +mongoc_bulkwriteopts_set_let(mongoc_bulkwriteopts_t *self, const bson_t *let); +MONGOC_EXPORT(void) +mongoc_bulkwriteopts_set_writeconcern(mongoc_bulkwriteopts_t *self, const mongoc_write_concern_t *writeconcern); +MONGOC_EXPORT(void) +mongoc_bulkwriteopts_set_comment(mongoc_bulkwriteopts_t *self, const bson_value_t *comment); +MONGOC_EXPORT(void) +mongoc_bulkwriteopts_set_verboseresults(mongoc_bulkwriteopts_t *self, bool verboseresults); +// `mongoc_bulkwriteopts_set_extra` appends `extra` to bulkWrite command. +// It is intended to support future server options. +MONGOC_EXPORT(void) +mongoc_bulkwriteopts_set_extra(mongoc_bulkwriteopts_t *self, const bson_t *extra); +// `mongoc_bulkwriteopts_set_serverid` identifies which server to perform the operation. This is intended for use by +// wrapping drivers that select a server before running the operation. +MONGOC_EXPORT(void) +mongoc_bulkwriteopts_set_serverid(mongoc_bulkwriteopts_t *self, uint32_t serverid); +MONGOC_EXPORT(void) +mongoc_bulkwriteopts_destroy(mongoc_bulkwriteopts_t *self); + +typedef struct _mongoc_bulkwriteresult_t mongoc_bulkwriteresult_t; +MONGOC_EXPORT(int64_t) +mongoc_bulkwriteresult_insertedcount(const mongoc_bulkwriteresult_t *self); +MONGOC_EXPORT(int64_t) +mongoc_bulkwriteresult_upsertedcount(const mongoc_bulkwriteresult_t *self); +MONGOC_EXPORT(int64_t) +mongoc_bulkwriteresult_matchedcount(const mongoc_bulkwriteresult_t *self); +MONGOC_EXPORT(int64_t) +mongoc_bulkwriteresult_modifiedcount(const mongoc_bulkwriteresult_t *self); +MONGOC_EXPORT(int64_t) +mongoc_bulkwriteresult_deletedcount(const mongoc_bulkwriteresult_t *self); +// `mongoc_bulkwriteresult_insertresults` returns a BSON document mapping model indexes to insert results. +// Example: +// { +// "0" : { "insertedId" : "foo" }, +// "1" : { "insertedId" : "bar" } +// } +// Returns NULL if verbose results were not requested. +MONGOC_EXPORT(const bson_t *) +mongoc_bulkwriteresult_insertresults(const mongoc_bulkwriteresult_t *self); +// `mongoc_bulkwriteresult_updateresults` returns a BSON document mapping model indexes to update results. +// Example: +// { +// "0" : { "matchedCount" : 2, "modifiedCount" : 2 }, +// "1" : { "matchedCount" : 1, "modifiedCount" : 0, "upsertedId" : "foo" } +// } +// Returns NULL if verbose results were not requested. +MONGOC_EXPORT(const bson_t *) +mongoc_bulkwriteresult_updateresults(const mongoc_bulkwriteresult_t *self); +// `mongoc_bulkwriteresult_deleteresults` returns a BSON document mapping model indexes to delete results. +// Example: +// { +// "0" : { "deletedCount" : 1 }, +// "1" : { "deletedCount" : 2 } +// } +// Returns NULL if verbose results were not requested. +MONGOC_EXPORT(const bson_t *) +mongoc_bulkwriteresult_deleteresults(const mongoc_bulkwriteresult_t *self); +// `mongoc_bulkwriteresult_serverid` identifies the most recently selected server. This may differ from a +// previously set serverid if a retry occurred. A server ID of 0 indicates that no server was successfully selected. +// This is intended for use by wrapping drivers that select a server before running the operation. +MONGOC_EXPORT(uint32_t) +mongoc_bulkwriteresult_serverid(const mongoc_bulkwriteresult_t *self); +MONGOC_EXPORT(void) +mongoc_bulkwriteresult_destroy(mongoc_bulkwriteresult_t *self); + +typedef struct _mongoc_bulkwriteexception_t mongoc_bulkwriteexception_t; +// Returns true if there was a top-level error. +MONGOC_EXPORT(bool) +mongoc_bulkwriteexception_error(const mongoc_bulkwriteexception_t *self, bson_error_t *error); +// `mongoc_bulkwriteexception_writeerrors` returns a BSON document mapping model indexes to write errors. +// Example: +// { +// "0" : { "code" : 123, "message" : "foo", "details" : { } }, +// "1" : { "code" : 456, "message" : "bar", "details" : { } } +// } +// Returns an empty document if there are no write errors. +MONGOC_EXPORT(const bson_t *) +mongoc_bulkwriteexception_writeerrors(const mongoc_bulkwriteexception_t *self); +// `mongoc_bulkwriteexception_writeconcernerrors` returns a BSON array of write concern errors. +// Example: +// [ +// { "code" : 123, "message" : "foo", "details" : { } }, +// { "code" : 456, "message" : "bar", "details" : { } } +// ] +// Returns an empty array if there are no write concern errors. +MONGOC_EXPORT(const bson_t *) +mongoc_bulkwriteexception_writeconcernerrors(const mongoc_bulkwriteexception_t *self); +// `mongoc_bulkwriteexception_errorreply` returns a possible server reply related to the error, or an empty document. +MONGOC_EXPORT(const bson_t *) +mongoc_bulkwriteexception_errorreply(const mongoc_bulkwriteexception_t *self); +MONGOC_EXPORT(void) +mongoc_bulkwriteexception_destroy(mongoc_bulkwriteexception_t *self); + +typedef struct _mongoc_bulkwrite_t mongoc_bulkwrite_t; +MONGOC_EXPORT(mongoc_bulkwrite_t *) +mongoc_client_bulkwrite_new(mongoc_client_t *self); + +typedef struct _mongoc_bulkwrite_insertoneopts_t mongoc_bulkwrite_insertoneopts_t; +MONGOC_EXPORT(mongoc_bulkwrite_insertoneopts_t *) +mongoc_bulkwrite_insertoneopts_new(void); +MONGOC_EXPORT(void) +mongoc_bulkwrite_insertoneopts_destroy(mongoc_bulkwrite_insertoneopts_t *self); +MONGOC_EXPORT(bool) +mongoc_bulkwrite_append_insertone(mongoc_bulkwrite_t *self, + const char *ns, + const bson_t *document, + const mongoc_bulkwrite_insertoneopts_t *opts /* May be NULL */, + bson_error_t *error); + +typedef struct _mongoc_bulkwrite_updateoneopts_t mongoc_bulkwrite_updateoneopts_t; +MONGOC_EXPORT(mongoc_bulkwrite_updateoneopts_t *) +mongoc_bulkwrite_updateoneopts_new(void); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updateoneopts_set_arrayfilters(mongoc_bulkwrite_updateoneopts_t *self, const bson_t *arrayfilters); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updateoneopts_set_collation(mongoc_bulkwrite_updateoneopts_t *self, const bson_t *collation); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updateoneopts_set_hint(mongoc_bulkwrite_updateoneopts_t *self, const bson_value_t *hint); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updateoneopts_set_upsert(mongoc_bulkwrite_updateoneopts_t *self, bool upsert); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updateoneopts_set_sort(mongoc_bulkwrite_updateoneopts_t *self, const bson_t *sort); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updateoneopts_destroy(mongoc_bulkwrite_updateoneopts_t *self); +MONGOC_EXPORT(bool) +mongoc_bulkwrite_append_updateone(mongoc_bulkwrite_t *self, + const char *ns, + const bson_t *filter, + const bson_t *update, + const mongoc_bulkwrite_updateoneopts_t *opts /* May be NULL */, + bson_error_t *error); + +typedef struct _mongoc_bulkwrite_updatemanyopts_t mongoc_bulkwrite_updatemanyopts_t; +MONGOC_EXPORT(mongoc_bulkwrite_updatemanyopts_t *) +mongoc_bulkwrite_updatemanyopts_new(void); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updatemanyopts_set_arrayfilters(mongoc_bulkwrite_updatemanyopts_t *self, const bson_t *arrayfilters); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updatemanyopts_set_collation(mongoc_bulkwrite_updatemanyopts_t *self, const bson_t *collation); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updatemanyopts_set_hint(mongoc_bulkwrite_updatemanyopts_t *self, const bson_value_t *hint); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updatemanyopts_set_upsert(mongoc_bulkwrite_updatemanyopts_t *self, bool upsert); +MONGOC_EXPORT(void) +mongoc_bulkwrite_updatemanyopts_destroy(mongoc_bulkwrite_updatemanyopts_t *self); +MONGOC_EXPORT(bool) +mongoc_bulkwrite_append_updatemany(mongoc_bulkwrite_t *self, + const char *ns, + const bson_t *filter, + const bson_t *update, + const mongoc_bulkwrite_updatemanyopts_t *opts /* May be NULL */, + bson_error_t *error); + +typedef struct _mongoc_bulkwrite_replaceoneopts_t mongoc_bulkwrite_replaceoneopts_t; +MONGOC_EXPORT(mongoc_bulkwrite_replaceoneopts_t *) +mongoc_bulkwrite_replaceoneopts_new(void); +MONGOC_EXPORT(void) +mongoc_bulkwrite_replaceoneopts_set_collation(mongoc_bulkwrite_replaceoneopts_t *self, const bson_t *collation); +MONGOC_EXPORT(void) +mongoc_bulkwrite_replaceoneopts_set_hint(mongoc_bulkwrite_replaceoneopts_t *self, const bson_value_t *hint); +MONGOC_EXPORT(void) +mongoc_bulkwrite_replaceoneopts_set_upsert(mongoc_bulkwrite_replaceoneopts_t *self, bool upsert); +MONGOC_EXPORT(void) +mongoc_bulkwrite_replaceoneopts_set_sort(mongoc_bulkwrite_replaceoneopts_t *self, const bson_t *sort); +MONGOC_EXPORT(void) +mongoc_bulkwrite_replaceoneopts_destroy(mongoc_bulkwrite_replaceoneopts_t *self); +MONGOC_EXPORT(bool) +mongoc_bulkwrite_append_replaceone(mongoc_bulkwrite_t *self, + const char *ns, + const bson_t *filter, + const bson_t *replacement, + const mongoc_bulkwrite_replaceoneopts_t *opts /* May be NULL */, + bson_error_t *error); + +typedef struct _mongoc_bulkwrite_deleteoneopts_t mongoc_bulkwrite_deleteoneopts_t; +MONGOC_EXPORT(mongoc_bulkwrite_deleteoneopts_t *) +mongoc_bulkwrite_deleteoneopts_new(void); +MONGOC_EXPORT(void) +mongoc_bulkwrite_deleteoneopts_set_collation(mongoc_bulkwrite_deleteoneopts_t *self, const bson_t *collation); +MONGOC_EXPORT(void) +mongoc_bulkwrite_deleteoneopts_set_hint(mongoc_bulkwrite_deleteoneopts_t *self, const bson_value_t *hint); +MONGOC_EXPORT(void) +mongoc_bulkwrite_deleteoneopts_destroy(mongoc_bulkwrite_deleteoneopts_t *self); +MONGOC_EXPORT(bool) +mongoc_bulkwrite_append_deleteone(mongoc_bulkwrite_t *self, + const char *ns, + const bson_t *filter, + const mongoc_bulkwrite_deleteoneopts_t *opts /* May be NULL */, + bson_error_t *error); + +typedef struct _mongoc_bulkwrite_deletemanyopts_t mongoc_bulkwrite_deletemanyopts_t; +MONGOC_EXPORT(mongoc_bulkwrite_deletemanyopts_t *) +mongoc_bulkwrite_deletemanyopts_new(void); +MONGOC_EXPORT(void) +mongoc_bulkwrite_deletemanyopts_set_collation(mongoc_bulkwrite_deletemanyopts_t *self, const bson_t *collation); +MONGOC_EXPORT(void) +mongoc_bulkwrite_deletemanyopts_set_hint(mongoc_bulkwrite_deletemanyopts_t *self, const bson_value_t *hint); +MONGOC_EXPORT(void) +mongoc_bulkwrite_deletemanyopts_destroy(mongoc_bulkwrite_deletemanyopts_t *self); +MONGOC_EXPORT(bool) +mongoc_bulkwrite_append_deletemany(mongoc_bulkwrite_t *self, + const char *ns, + const bson_t *filter, + const mongoc_bulkwrite_deletemanyopts_t *opts /* May be NULL */, + bson_error_t *error); + + +// `mongoc_bulkwritereturn_t` may outlive `mongoc_bulkwrite_t`. +typedef struct { + mongoc_bulkwriteresult_t *res; // NULL if no known successful writes or write was unacknowledged. + mongoc_bulkwriteexception_t *exc; // NULL if no error. +} mongoc_bulkwritereturn_t; + +// `mongoc_bulkwrite_new` and `mongoc_bulkwrite_set_client` may be used by +// language bindings that want to assemble a `mongoc_bulkwrite_t` and defer +// `mongoc_client_t` assignment to execution time. +MONGOC_EXPORT(mongoc_bulkwrite_t *) +mongoc_bulkwrite_new(void); +MONGOC_EXPORT(void) +mongoc_bulkwrite_set_client(mongoc_bulkwrite_t *self, mongoc_client_t *client); +// `mongoc_bulkwrite_set_session` sets an optional explicit session. +// `*session` may be modified when `mongoc_bulkwrite_execute` is called. +MONGOC_EXPORT(void) +mongoc_bulkwrite_set_session(mongoc_bulkwrite_t *self, mongoc_client_session_t *session); +// `mongoc_bulkwrite_execute` executes a bulk write operation. +MONGOC_EXPORT(mongoc_bulkwritereturn_t) +mongoc_bulkwrite_execute(mongoc_bulkwrite_t *self, const mongoc_bulkwriteopts_t *opts); + +typedef struct { + bool is_ok; // true if no error + bool is_acknowledged; // true if the previous call to `mongoc_bulkwrite_execute` used an acknowledged write concern +} mongoc_bulkwrite_check_acknowledged_t; + +// `mongoc_bulkwrite_check_acknowledged` checks whether or not the previous call to `mongoc_bulkwrite_execute` used an +// acknowledged write concern. +MONGOC_EXPORT(mongoc_bulkwrite_check_acknowledged_t) +mongoc_bulkwrite_check_acknowledged(mongoc_bulkwrite_t const *self, bson_error_t *error); + +typedef struct { + bool is_ok; // true if no error + uint32_t serverid; // the server ID last used in `mongoc_bulkwrite_execute` +} mongoc_bulkwrite_serverid_t; + +// `mongoc_bulkwrite_serverid` identifies the most recently selected server. This may differ from a previously set +// serverid if a retry occurred. Unlike `mongoc_bulkwriteresult_serverid`, this can be used for unacknowledged writes. +// For acknowledged writes, `mongoc_bulkwrite_serverid` and `mongoc_bulkwriteresult_serverid` report the same server +// ID. +MONGOC_EXPORT(mongoc_bulkwrite_serverid_t) +mongoc_bulkwrite_serverid(mongoc_bulkwrite_t const *self, bson_error_t *error); + +MONGOC_EXPORT(void) +mongoc_bulkwrite_destroy(mongoc_bulkwrite_t *self); + +BSON_END_DECLS + +#endif // MONGOC_BULKWRITE_H diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-change-stream.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-change-stream.h new file mode 100644 index 0000000..3c80a8b --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-change-stream.h @@ -0,0 +1,44 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_CHANGE_STREAM_H +#define MONGOC_CHANGE_STREAM_H + +#include + +#include + +BSON_BEGIN_DECLS + +typedef struct _mongoc_change_stream_t mongoc_change_stream_t; + +MONGOC_EXPORT(void) +mongoc_change_stream_destroy(mongoc_change_stream_t *); + +MONGOC_EXPORT(const bson_t *) +mongoc_change_stream_get_resume_token(mongoc_change_stream_t *); + +MONGOC_EXPORT(bool) +mongoc_change_stream_next(mongoc_change_stream_t *, const bson_t **); + +MONGOC_EXPORT(bool) +mongoc_change_stream_error_document(const mongoc_change_stream_t *, bson_error_t *, const bson_t **); + +BSON_END_DECLS + +#endif /* MONGOC_CHANGE_STREAM_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-client-pool.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-client-pool.h new file mode 100644 index 0000000..16e385a --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-client-pool.h @@ -0,0 +1,93 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_CLIENT_POOL_H +#define MONGOC_CLIENT_POOL_H + +#include +#include +#include +#include + +#include +#ifdef MONGOC_ENABLE_SSL +#include +#endif +#include +#include + + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_client_pool_t mongoc_client_pool_t; + + +MONGOC_EXPORT(mongoc_client_pool_t *) +mongoc_client_pool_new(const mongoc_uri_t *uri) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_client_pool_t *) +mongoc_client_pool_new_with_error(const mongoc_uri_t *uri, bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_client_pool_destroy(mongoc_client_pool_t *pool); + +MONGOC_EXPORT(mongoc_client_t *) +mongoc_client_pool_pop(mongoc_client_pool_t *pool) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_client_pool_push(mongoc_client_pool_t *pool, mongoc_client_t *client); + +MONGOC_EXPORT(mongoc_client_t *) +mongoc_client_pool_try_pop(mongoc_client_pool_t *pool) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_client_pool_max_size(mongoc_client_pool_t *pool, uint32_t max_pool_size); + +#ifdef MONGOC_ENABLE_SSL +MONGOC_EXPORT(void) +mongoc_client_pool_set_ssl_opts(mongoc_client_pool_t *pool, const mongoc_ssl_opt_t *opts); +#endif + +MONGOC_EXPORT(bool) +mongoc_client_pool_set_apm_callbacks(mongoc_client_pool_t *pool, mongoc_apm_callbacks_t *callbacks, void *context); + +MONGOC_EXPORT(bool) +mongoc_client_pool_set_error_api(mongoc_client_pool_t *pool, int32_t version); + +MONGOC_EXPORT(bool) +mongoc_client_pool_set_appname(mongoc_client_pool_t *pool, const char *appname); + +MONGOC_EXPORT(bool) +mongoc_client_pool_enable_auto_encryption(mongoc_client_pool_t *pool, + mongoc_auto_encryption_opts_t *opts, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_pool_set_server_api(mongoc_client_pool_t *pool, const mongoc_server_api_t *api, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_pool_set_structured_log_opts(mongoc_client_pool_t *pool, const mongoc_structured_log_opts_t *opts); + +MONGOC_EXPORT(bool) +mongoc_client_pool_set_oidc_callback(mongoc_client_pool_t *pool, const mongoc_oidc_callback_t *callback); + +BSON_END_DECLS + + +#endif /* MONGOC_CLIENT_POOL_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-client-session.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-client-session.h new file mode 100644 index 0000000..da210ff --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-client-session.h @@ -0,0 +1,178 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_CLIENT_SESSION_H +#define MONGOC_CLIENT_SESSION_H + +#include + +#include +/* mongoc_client_session_t, mongoc_transaction_opt_t, and + mongoc_session_opt_t are typedef'ed here */ +#include + +BSON_BEGIN_DECLS + +typedef bool(BSON_CALL *mongoc_client_session_with_transaction_cb_t)(mongoc_client_session_t *session, + void *ctx, + bson_t **reply, + bson_error_t *error); + +typedef enum { + MONGOC_TRANSACTION_NONE = 0, + MONGOC_TRANSACTION_STARTING = 1, + MONGOC_TRANSACTION_IN_PROGRESS = 2, + MONGOC_TRANSACTION_COMMITTED = 3, + MONGOC_TRANSACTION_ABORTED = 4, +} mongoc_transaction_state_t; + +/* these options types are named "opt_t" but their functions are named with + * "opts", for consistency with the older mongoc_ssl_opt_t */ +MONGOC_EXPORT(mongoc_transaction_opt_t *) +mongoc_transaction_opts_new(void) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_transaction_opt_t *) +mongoc_transaction_opts_clone(const mongoc_transaction_opt_t *opts) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_transaction_opts_destroy(mongoc_transaction_opt_t *opts); + +MONGOC_EXPORT(void) +mongoc_transaction_opts_set_max_commit_time_ms(mongoc_transaction_opt_t *opts, int64_t max_commit_time_ms); + +MONGOC_EXPORT(int64_t) +mongoc_transaction_opts_get_max_commit_time_ms(mongoc_transaction_opt_t *opts); + +MONGOC_EXPORT(void) +mongoc_transaction_opts_set_read_concern(mongoc_transaction_opt_t *opts, const mongoc_read_concern_t *read_concern); + +MONGOC_EXPORT(const mongoc_read_concern_t *) +mongoc_transaction_opts_get_read_concern(const mongoc_transaction_opt_t *opts); + +MONGOC_EXPORT(void) +mongoc_transaction_opts_set_write_concern(mongoc_transaction_opt_t *opts, const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(const mongoc_write_concern_t *) +mongoc_transaction_opts_get_write_concern(const mongoc_transaction_opt_t *opts); + +MONGOC_EXPORT(void) +mongoc_transaction_opts_set_read_prefs(mongoc_transaction_opt_t *opts, const mongoc_read_prefs_t *read_prefs); + +MONGOC_EXPORT(const mongoc_read_prefs_t *) +mongoc_transaction_opts_get_read_prefs(const mongoc_transaction_opt_t *opts); + +MONGOC_EXPORT(mongoc_session_opt_t *) +mongoc_session_opts_new(void) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_session_opts_set_causal_consistency(mongoc_session_opt_t *opts, bool causal_consistency); + +MONGOC_EXPORT(bool) +mongoc_session_opts_get_causal_consistency(const mongoc_session_opt_t *opts); + +MONGOC_EXPORT(void) +mongoc_session_opts_set_snapshot(mongoc_session_opt_t *opts, bool snapshot); + +MONGOC_EXPORT(bool) +mongoc_session_opts_get_snapshot(const mongoc_session_opt_t *opts); + +MONGOC_EXPORT(void) +mongoc_session_opts_set_default_transaction_opts(mongoc_session_opt_t *opts, const mongoc_transaction_opt_t *txn_opts); + +MONGOC_EXPORT(const mongoc_transaction_opt_t *) +mongoc_session_opts_get_default_transaction_opts(const mongoc_session_opt_t *opts); + +MONGOC_EXPORT(mongoc_transaction_opt_t *) +mongoc_session_opts_get_transaction_opts(const mongoc_client_session_t *session) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_session_opt_t *) +mongoc_session_opts_clone(const mongoc_session_opt_t *opts) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_session_opts_destroy(mongoc_session_opt_t *opts); + +MONGOC_EXPORT(mongoc_client_t *) +mongoc_client_session_get_client(const mongoc_client_session_t *session); + +MONGOC_EXPORT(const mongoc_session_opt_t *) +mongoc_client_session_get_opts(const mongoc_client_session_t *session); + +MONGOC_EXPORT(const bson_t *) +mongoc_client_session_get_lsid(const mongoc_client_session_t *session); + +MONGOC_EXPORT(const bson_t *) +mongoc_client_session_get_cluster_time(const mongoc_client_session_t *session); + +MONGOC_EXPORT(void) +mongoc_client_session_advance_cluster_time(mongoc_client_session_t *session, const bson_t *cluster_time); + +MONGOC_EXPORT(void) +mongoc_client_session_get_operation_time(const mongoc_client_session_t *session, + uint32_t *timestamp, + uint32_t *increment); + +MONGOC_EXPORT(uint32_t) +mongoc_client_session_get_server_id(const mongoc_client_session_t *session); + +MONGOC_EXPORT(void) +mongoc_client_session_advance_operation_time(mongoc_client_session_t *session, uint32_t timestamp, uint32_t increment); + +MONGOC_EXPORT(bool) +mongoc_client_session_with_transaction(mongoc_client_session_t *session, + mongoc_client_session_with_transaction_cb_t cb, + const mongoc_transaction_opt_t *opts, + void *ctx, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_session_start_transaction(mongoc_client_session_t *session, + const mongoc_transaction_opt_t *opts, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_session_in_transaction(const mongoc_client_session_t *session); + +MONGOC_EXPORT(mongoc_transaction_state_t) +mongoc_client_session_get_transaction_state(const mongoc_client_session_t *session); + +MONGOC_EXPORT(bool) +mongoc_client_session_commit_transaction(mongoc_client_session_t *session, bson_t *reply, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_session_abort_transaction(mongoc_client_session_t *session, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_session_append(const mongoc_client_session_t *client_session, bson_t *opts, bson_error_t *error); + +/* There is no mongoc_client_session_end, only mongoc_client_session_destroy. + * Driver Sessions Spec: "In languages that have idiomatic ways of disposing of + * resources, drivers SHOULD support that in addition to or instead of + * endSession." + */ + +MONGOC_EXPORT(void) +mongoc_client_session_destroy(mongoc_client_session_t *session); + +MONGOC_EXPORT(bool) +mongoc_client_session_get_dirty(mongoc_client_session_t *session); + +BSON_END_DECLS + + +#endif /* MONGOC_CLIENT_SESSION_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-client-side-encryption.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-client-side-encryption.h new file mode 100644 index 0000000..d106c28 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-client-side-encryption.h @@ -0,0 +1,404 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_CLIENT_SIDE_ENCRYPTION_H +#define MONGOC_CLIENT_SIDE_ENCRYPTION_H + +#include + +#include + +/* Forward declare */ +struct _mongoc_client_t; +struct _mongoc_client_pool_t; +struct _mongoc_cursor_t; + +struct _mongoc_collection_t; +struct _mongoc_database_t; + +#define MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM "AEAD_AES_256_CBC_HMAC_SHA_512-Random" +#define MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" +#define MONGOC_ENCRYPT_ALGORITHM_INDEXED "Indexed" +#define MONGOC_ENCRYPT_ALGORITHM_UNINDEXED "Unindexed" +#define MONGOC_ENCRYPT_ALGORITHM_RANGE "Range" +#define MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW "RangePreview" +#define MONGOC_ENCRYPT_ALGORITHM_TEXTPREVIEW "TextPreview" + +#define MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY "equality" +#define MONGOC_ENCRYPT_QUERY_TYPE_RANGE "range" +#define MONGOC_ENCRYPT_QUERY_TYPE_RANGEPREVIEW "rangePreview" +#define MONGOC_ENCRYPT_QUERY_TYPE_SUBSTRINGPREVIEW "substringPreview" +#define MONGOC_ENCRYPT_QUERY_TYPE_PREFIXPREVIEW "prefixPreview" +#define MONGOC_ENCRYPT_QUERY_TYPE_SUFFIXPREVIEW "suffixPreview" + + +BSON_BEGIN_DECLS + +typedef struct _mongoc_auto_encryption_opts_t mongoc_auto_encryption_opts_t; + +typedef bool(BSON_CALL *mongoc_kms_credentials_provider_callback_fn)(void *userdata, + const bson_t *params, + bson_t *out, + bson_error_t *error); + +MONGOC_EXPORT(mongoc_auto_encryption_opts_t *) +mongoc_auto_encryption_opts_new(void) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_destroy(mongoc_auto_encryption_opts_t *opts); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_keyvault_client(mongoc_auto_encryption_opts_t *opts, struct _mongoc_client_t *client); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_keyvault_client_pool(mongoc_auto_encryption_opts_t *opts, + struct _mongoc_client_pool_t *pool); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_keyvault_namespace(mongoc_auto_encryption_opts_t *opts, + const char *db, + const char *coll); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_kms_providers(mongoc_auto_encryption_opts_t *opts, const bson_t *kms_providers); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_key_expiration(mongoc_auto_encryption_opts_t *opts, uint64_t expiration); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_tls_opts(mongoc_auto_encryption_opts_t *opts, const bson_t *tls_opts); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_schema_map(mongoc_auto_encryption_opts_t *opts, const bson_t *schema_map); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_encrypted_fields_map(mongoc_auto_encryption_opts_t *opts, + const bson_t *encrypted_fields_map); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_bypass_auto_encryption(mongoc_auto_encryption_opts_t *opts, + bool bypass_auto_encryption); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_bypass_query_analysis(mongoc_auto_encryption_opts_t *opts, bool bypass_query_analysis); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_extra(mongoc_auto_encryption_opts_t *opts, const bson_t *extra); + +MONGOC_EXPORT(void) +mongoc_auto_encryption_opts_set_kms_credential_provider_callback(mongoc_auto_encryption_opts_t *opts, + mongoc_kms_credentials_provider_callback_fn fn, + void *userdata); + +typedef struct _mongoc_client_encryption_opts_t mongoc_client_encryption_opts_t; +typedef struct _mongoc_client_encryption_t mongoc_client_encryption_t; +typedef struct _mongoc_client_encryption_encrypt_range_opts_t mongoc_client_encryption_encrypt_range_opts_t; +typedef struct _encrypt_text_prefix_opts_t mongoc_client_encryption_encrypt_text_prefix_opts_t; +typedef struct _encrypt_text_suffix_opts_t mongoc_client_encryption_encrypt_text_suffix_opts_t; +typedef struct _encrypt_text_substring_opts_t mongoc_client_encryption_encrypt_text_substring_opts_t; +typedef struct _mongoc_client_encryption_encrypt_text_opts_t mongoc_client_encryption_encrypt_text_opts_t; +typedef struct _mongoc_client_encryption_encrypt_opts_t mongoc_client_encryption_encrypt_opts_t; +typedef struct _mongoc_client_encryption_datakey_opts_t mongoc_client_encryption_datakey_opts_t; +typedef struct _mongoc_client_encryption_rewrap_many_datakey_result_t + mongoc_client_encryption_rewrap_many_datakey_result_t; + +MONGOC_EXPORT(mongoc_client_encryption_opts_t *) +mongoc_client_encryption_opts_new(void) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_client_encryption_opts_destroy(mongoc_client_encryption_opts_t *opts); + +MONGOC_EXPORT(void) +mongoc_client_encryption_opts_set_keyvault_client(mongoc_client_encryption_opts_t *opts, + struct _mongoc_client_t *keyvault_client); + +MONGOC_EXPORT(void) +mongoc_client_encryption_opts_set_keyvault_namespace(mongoc_client_encryption_opts_t *opts, + const char *db, + const char *coll); + +MONGOC_EXPORT(void) +mongoc_client_encryption_opts_set_kms_providers(mongoc_client_encryption_opts_t *opts, const bson_t *kms_providers); + +MONGOC_EXPORT(void) +mongoc_client_encryption_opts_set_tls_opts(mongoc_client_encryption_opts_t *opts, const bson_t *tls_opts); + +MONGOC_EXPORT(void) +mongoc_client_encryption_opts_set_kms_credential_provider_callback(mongoc_client_encryption_opts_t *opts, + mongoc_kms_credentials_provider_callback_fn fn, + void *userdata); + +MONGOC_EXPORT(void) +mongoc_client_encryption_opts_set_key_expiration(mongoc_client_encryption_opts_t *opts, uint64_t cache_expiration_ms); + +MONGOC_EXPORT(mongoc_client_encryption_rewrap_many_datakey_result_t *) +mongoc_client_encryption_rewrap_many_datakey_result_new(void) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_client_encryption_rewrap_many_datakey_result_destroy( + mongoc_client_encryption_rewrap_many_datakey_result_t *result); + +MONGOC_EXPORT(const bson_t *) +mongoc_client_encryption_rewrap_many_datakey_result_get_bulk_write_result( + mongoc_client_encryption_rewrap_many_datakey_result_t *result) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_client_encryption_t *) +mongoc_client_encryption_new(mongoc_client_encryption_opts_t *opts, bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_client_encryption_destroy(mongoc_client_encryption_t *client_encryption); + +MONGOC_EXPORT(bool) +mongoc_client_encryption_create_datakey(mongoc_client_encryption_t *client_encryption, + const char *kms_provider, + const mongoc_client_encryption_datakey_opts_t *opts, + bson_value_t *keyid, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_encryption_rewrap_many_datakey(mongoc_client_encryption_t *client_encryption, + const bson_t *filter, + const char *provider, + const bson_t *master_key, + mongoc_client_encryption_rewrap_many_datakey_result_t *result, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_encryption_delete_key(mongoc_client_encryption_t *client_encryption, + const bson_value_t *keyid, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_encryption_get_key(mongoc_client_encryption_t *client_encryption, + const bson_value_t *keyid, + bson_t *key_doc, + bson_error_t *error); + +MONGOC_EXPORT(mongoc_client_encryption_encrypt_text_prefix_opts_t *) +mongoc_client_encryption_encrypt_text_prefix_opts_new(void); + +MONGOC_EXPORT(mongoc_client_encryption_encrypt_text_suffix_opts_t *) +mongoc_client_encryption_encrypt_text_suffix_opts_new(void); + +MONGOC_EXPORT(mongoc_client_encryption_encrypt_text_substring_opts_t *) +mongoc_client_encryption_encrypt_text_substring_opts_new(void); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_prefix_opts_destroy(mongoc_client_encryption_encrypt_text_prefix_opts_t *); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_suffix_opts_destroy(mongoc_client_encryption_encrypt_text_suffix_opts_t *); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_substring_opts_destroy(mongoc_client_encryption_encrypt_text_substring_opts_t *); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_prefix_opts_set_str_max_query_length( + mongoc_client_encryption_encrypt_text_prefix_opts_t *opts, int32_t str_max_query_length); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_prefix_opts_set_str_min_query_length( + mongoc_client_encryption_encrypt_text_prefix_opts_t *opts, int32_t str_min_query_length); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_suffix_opts_set_str_max_query_length( + mongoc_client_encryption_encrypt_text_suffix_opts_t *opts, int32_t str_max_query_length); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_suffix_opts_set_str_min_query_length( + mongoc_client_encryption_encrypt_text_suffix_opts_t *opts, int32_t str_min_query_length); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_substring_opts_set_str_max_length( + mongoc_client_encryption_encrypt_text_substring_opts_t *opts, int32_t str_max_length); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_substring_opts_set_str_max_query_length( + mongoc_client_encryption_encrypt_text_substring_opts_t *opts, int32_t str_max_query_length); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_substring_opts_set_str_min_query_length( + mongoc_client_encryption_encrypt_text_substring_opts_t *opts, int32_t str_min_query_length); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_opts_set_prefix(mongoc_client_encryption_encrypt_text_opts_t *opts, + const mongoc_client_encryption_encrypt_text_prefix_opts_t *popts); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_opts_set_suffix(mongoc_client_encryption_encrypt_text_opts_t *opts, + const mongoc_client_encryption_encrypt_text_suffix_opts_t *sopts); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_opts_set_substring( + mongoc_client_encryption_encrypt_text_opts_t *opts, + const mongoc_client_encryption_encrypt_text_substring_opts_t *ssopts); + +MONGOC_EXPORT(mongoc_client_encryption_encrypt_text_opts_t *) +mongoc_client_encryption_encrypt_text_opts_new(void); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_opts_destroy(mongoc_client_encryption_encrypt_text_opts_t *topts); + +MONGOC_EXPORT(struct _mongoc_cursor_t *) +mongoc_client_encryption_get_keys(mongoc_client_encryption_t *client_encryption, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_encryption_add_key_alt_name(mongoc_client_encryption_t *client_encryption, + const bson_value_t *keyid, + const char *keyaltname, + bson_t *key_doc, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_encryption_remove_key_alt_name(mongoc_client_encryption_t *client_encryption, + const bson_value_t *keyid, + const char *keyaltname, + bson_t *key_doc, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_encryption_get_key_by_alt_name(mongoc_client_encryption_t *client_encryption, + const char *keyaltname, + bson_t *key_doc, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_encryption_encrypt(mongoc_client_encryption_t *client_encryption, + const bson_value_t *value, + mongoc_client_encryption_encrypt_opts_t *opts, + bson_value_t *ciphertext, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_encryption_encrypt_expression(mongoc_client_encryption_t *client_encryption, + const bson_t *expr, + mongoc_client_encryption_encrypt_opts_t *opts, + bson_t *expr_out, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_encryption_decrypt(mongoc_client_encryption_t *client_encryption, + const bson_value_t *ciphertext, + bson_value_t *value, + bson_error_t *error); + +MONGOC_EXPORT(mongoc_client_encryption_encrypt_opts_t *) +mongoc_client_encryption_encrypt_opts_new(void) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_opts_destroy(mongoc_client_encryption_encrypt_opts_t *opts); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_opts_set_keyid(mongoc_client_encryption_encrypt_opts_t *opts, + const bson_value_t *keyid); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_opts_set_keyaltname(mongoc_client_encryption_encrypt_opts_t *opts, + const char *keyaltname); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_opts_set_algorithm(mongoc_client_encryption_encrypt_opts_t *opts, + const char *algorithm); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_opts_set_contention_factor(mongoc_client_encryption_encrypt_opts_t *opts, + int64_t contention_factor); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_opts_set_text_opts(mongoc_client_encryption_encrypt_opts_t *opts, + const mongoc_client_encryption_encrypt_text_opts_t *text_opts); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_opts_set_case_sensitive(mongoc_client_encryption_encrypt_text_opts_t *opts, + bool case_sensitive); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_text_opts_set_diacritic_sensitive(mongoc_client_encryption_encrypt_text_opts_t *opts, + bool diacritic_sensitive); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_opts_set_query_type(mongoc_client_encryption_encrypt_opts_t *opts, + const char *query_type); + +MONGOC_EXPORT(mongoc_client_encryption_encrypt_range_opts_t *) +mongoc_client_encryption_encrypt_range_opts_new(void); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_range_opts_destroy(mongoc_client_encryption_encrypt_range_opts_t *range_opts); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_range_opts_set_trim_factor(mongoc_client_encryption_encrypt_range_opts_t *range_opts, + int32_t trim_factor); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_range_opts_set_sparsity(mongoc_client_encryption_encrypt_range_opts_t *range_opts, + int64_t sparsity); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_range_opts_set_min(mongoc_client_encryption_encrypt_range_opts_t *range_opts, + const bson_value_t *min); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_range_opts_set_max(mongoc_client_encryption_encrypt_range_opts_t *range_opts, + const bson_value_t *max); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_range_opts_set_precision(mongoc_client_encryption_encrypt_range_opts_t *range_opts, + int32_t precision); + +MONGOC_EXPORT(void) +mongoc_client_encryption_encrypt_opts_set_range_opts(mongoc_client_encryption_encrypt_opts_t *opts, + const mongoc_client_encryption_encrypt_range_opts_t *range_opts); + +MONGOC_EXPORT(mongoc_client_encryption_datakey_opts_t *) +mongoc_client_encryption_datakey_opts_new(void) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_client_encryption_datakey_opts_destroy(mongoc_client_encryption_datakey_opts_t *opts); + +MONGOC_EXPORT(void) +mongoc_client_encryption_datakey_opts_set_masterkey(mongoc_client_encryption_datakey_opts_t *opts, + const bson_t *masterkey); + +MONGOC_EXPORT(void) +mongoc_client_encryption_datakey_opts_set_keyaltnames(mongoc_client_encryption_datakey_opts_t *opts, + char **keyaltnames, + uint32_t keyaltnames_count); + +MONGOC_EXPORT(void) +mongoc_client_encryption_datakey_opts_set_keymaterial(mongoc_client_encryption_datakey_opts_t *opts, + const uint8_t *data, + uint32_t len); + +MONGOC_EXPORT(const char *) +mongoc_client_encryption_get_crypt_shared_version(mongoc_client_encryption_t const *enc) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(struct _mongoc_collection_t *) +mongoc_client_encryption_create_encrypted_collection(mongoc_client_encryption_t *enc, + struct _mongoc_database_t *database, + const char *name, + const bson_t *in_options, + bson_t *opt_out_options, + const char *const kms_provider, + const bson_t *opt_masterkey, + bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +BSON_END_DECLS + +#endif /* MONGOC_CLIENT_SIDE_ENCRYPTION_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-client.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-client.h new file mode 100644 index 0000000..2b53c91 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-client.h @@ -0,0 +1,286 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_CLIENT_H +#define MONGOC_CLIENT_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#ifdef MONGOC_ENABLE_SSL +#include +#endif +#include +#include +#include +#include +#include +#include +#include + +BSON_BEGIN_DECLS + +/* This define is part of our public API. But per MongoDB 4.4, there is no + * longer a size limit on collection names. */ +#define MONGOC_NAMESPACE_MAX 128 + + +#ifndef MONGOC_DEFAULT_CONNECTTIMEOUTMS +#define MONGOC_DEFAULT_CONNECTTIMEOUTMS (10 * 1000L) +#endif + + +#ifndef MONGOC_DEFAULT_SOCKETTIMEOUTMS +/* + * NOTE: The default socket timeout for connections is 5 minutes. This + * means that if your MongoDB server dies or becomes unavailable + * it will take 5 minutes to detect this. + * + * You can change this by providing sockettimeoutms= in your + * connection URI. + */ +#define MONGOC_DEFAULT_SOCKETTIMEOUTMS (1000L * 60L * 5L) +#endif + + +/** + * mongoc_client_t: + * + * The mongoc_client_t structure maintains information about a connection to + * a MongoDB server. + */ +typedef struct _mongoc_client_t mongoc_client_t; + + +typedef struct _mongoc_client_session_t mongoc_client_session_t; +typedef struct _mongoc_session_opt_t mongoc_session_opt_t; +typedef struct _mongoc_transaction_opt_t mongoc_transaction_opt_t; + +/** + * mongoc_stream_initiator_t: + * @uri: The uri and options for the stream. + * @host: The host and port (or UNIX domain socket path) to connect to. + * @user_data: The pointer passed to mongoc_client_set_stream_initiator. + * @error: A location for an error. + * + * Creates a new mongoc_stream_t for the host and port. Begin a + * non-blocking connect and return immediately. + * + * This can be used by language bindings to create network transports other + * than those built into libmongoc. An example of such would be the streams + * API provided by PHP. + * + * Returns: A newly allocated mongoc_stream_t or NULL on failure. + */ +typedef mongoc_stream_t *(BSON_CALL *mongoc_stream_initiator_t)(const mongoc_uri_t *uri, + const mongoc_host_list_t *host, + void *user_data, + bson_error_t *error); + + +MONGOC_EXPORT(mongoc_client_t *) +mongoc_client_new(const char *uri_string) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_client_t *) +mongoc_client_new_from_uri(const mongoc_uri_t *uri) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_client_t *) +mongoc_client_new_from_uri_with_error(const mongoc_uri_t *uri, bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_client_set_sockettimeoutms(mongoc_client_t *client, int32_t timeoutms); + +MONGOC_EXPORT(const mongoc_uri_t *) +mongoc_client_get_uri(const mongoc_client_t *client); + +MONGOC_EXPORT(void) +mongoc_client_set_stream_initiator(mongoc_client_t *client, mongoc_stream_initiator_t initiator, void *user_data); + +MONGOC_EXPORT(bool) +mongoc_client_command_simple(mongoc_client_t *client, + const char *db_name, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_read_command_with_opts(mongoc_client_t *client, + const char *db_name, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_write_command_with_opts(mongoc_client_t *client, + const char *db_name, + const bson_t *command, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_read_write_command_with_opts(mongoc_client_t *client, + const char *db_name, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs /* IGNORED */, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_command_with_opts(mongoc_client_t *client, + const char *db_name, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_client_command_simple_with_server_id(mongoc_client_t *client, + const char *db_name, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs, + uint32_t server_id, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(void) +mongoc_client_destroy(mongoc_client_t *client); + +MONGOC_EXPORT(mongoc_client_session_t *) +mongoc_client_start_session(mongoc_client_t *client, const mongoc_session_opt_t *opts, bson_error_t *error) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_database_t *) +mongoc_client_get_database(mongoc_client_t *client, const char *name) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_database_t *) +mongoc_client_get_default_database(mongoc_client_t *client) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_gridfs_t *) +mongoc_client_get_gridfs(mongoc_client_t *client, const char *db, const char *prefix, bson_error_t *error) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_collection_t *) +mongoc_client_get_collection(mongoc_client_t *client, const char *db, const char *collection) + BSON_GNUC_WARN_UNUSED_RESULT; + +BSON_DEPRECATED_FOR(mongoc_client_get_database_names_with_opts) +MONGOC_EXPORT(char **) mongoc_client_get_database_names(mongoc_client_t *client, bson_error_t *error) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(char **) +mongoc_client_get_database_names_with_opts(mongoc_client_t *client, const bson_t *opts, bson_error_t *error) + BSON_GNUC_WARN_UNUSED_RESULT; + +BSON_DEPRECATED_FOR(mongoc_client_find_databases_with_opts) +MONGOC_EXPORT(mongoc_cursor_t *) mongoc_client_find_databases(mongoc_client_t *client, bson_error_t *error) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_cursor_t *) +mongoc_client_find_databases_with_opts(mongoc_client_t *client, const bson_t *opts) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(const mongoc_write_concern_t *) +mongoc_client_get_write_concern(const mongoc_client_t *client); + +MONGOC_EXPORT(void) +mongoc_client_set_write_concern(mongoc_client_t *client, const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(const mongoc_read_concern_t *) +mongoc_client_get_read_concern(const mongoc_client_t *client); + +MONGOC_EXPORT(void) +mongoc_client_set_read_concern(mongoc_client_t *client, const mongoc_read_concern_t *read_concern); + +MONGOC_EXPORT(const mongoc_read_prefs_t *) +mongoc_client_get_read_prefs(const mongoc_client_t *client); + +MONGOC_EXPORT(void) +mongoc_client_set_read_prefs(mongoc_client_t *client, const mongoc_read_prefs_t *read_prefs); +#ifdef MONGOC_ENABLE_SSL + +MONGOC_EXPORT(void) +mongoc_client_set_ssl_opts(mongoc_client_t *client, const mongoc_ssl_opt_t *opts); +#endif + +MONGOC_EXPORT(bool) +mongoc_client_set_apm_callbacks(mongoc_client_t *client, mongoc_apm_callbacks_t *callbacks, void *context); + +MONGOC_EXPORT(bool) +mongoc_client_set_structured_log_opts(mongoc_client_t *client, const mongoc_structured_log_opts_t *opts); + +MONGOC_EXPORT(mongoc_server_description_t *) +mongoc_client_get_server_description(mongoc_client_t *client, uint32_t server_id) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_server_description_t **) +mongoc_client_get_server_descriptions(const mongoc_client_t *client, size_t *n) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_server_descriptions_destroy_all(mongoc_server_description_t **sds, size_t n); + +MONGOC_EXPORT(mongoc_server_description_t *) +mongoc_client_select_server(mongoc_client_t *client, + bool for_writes, + const mongoc_read_prefs_t *prefs, + bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_client_set_error_api(mongoc_client_t *client, int32_t version); + +MONGOC_EXPORT(bool) +mongoc_client_set_appname(mongoc_client_t *client, const char *appname); + +MONGOC_EXPORT(mongoc_change_stream_t *) +mongoc_client_watch(mongoc_client_t *client, const bson_t *pipeline, const bson_t *opts) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_client_reset(mongoc_client_t *client); + +MONGOC_EXPORT(bool) +mongoc_client_enable_auto_encryption(mongoc_client_t *client, mongoc_auto_encryption_opts_t *opts, bson_error_t *error); + +MONGOC_EXPORT(const char *) +mongoc_client_get_crypt_shared_version(const mongoc_client_t *client) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_client_set_server_api(mongoc_client_t *client, const mongoc_server_api_t *api, bson_error_t *error); + +MONGOC_EXPORT(mongoc_server_description_t *) +mongoc_client_get_handshake_description(mongoc_client_t *client, uint32_t server_id, bson_t *opts, bson_error_t *error) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_client_set_oidc_callback(mongoc_client_t *client, const mongoc_oidc_callback_t *callback); + +BSON_END_DECLS + + +#endif /* MONGOC_CLIENT_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-collection.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-collection.h new file mode 100644 index 0000000..8a09582 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-collection.h @@ -0,0 +1,278 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_COLLECTION_H +#define MONGOC_COLLECTION_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_collection_t mongoc_collection_t; + + +MONGOC_EXPORT(mongoc_cursor_t *) +mongoc_collection_aggregate(mongoc_collection_t *collection, + mongoc_query_flags_t flags, + const bson_t *pipeline, + const bson_t *opts, + const mongoc_read_prefs_t *read_prefs) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_collection_destroy(mongoc_collection_t *collection); + +MONGOC_EXPORT(mongoc_collection_t *) +mongoc_collection_copy(mongoc_collection_t *collection) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_collection_read_command_with_opts(mongoc_collection_t *collection, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_write_command_with_opts( + mongoc_collection_t *collection, const bson_t *command, const bson_t *opts, bson_t *reply, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_read_write_command_with_opts(mongoc_collection_t *collection, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs /* IGNORED */, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_command_with_opts(mongoc_collection_t *collection, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_command_simple(mongoc_collection_t *collection, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_drop(mongoc_collection_t *collection, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_drop_with_opts(mongoc_collection_t *collection, const bson_t *opts, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_drop_index(mongoc_collection_t *collection, const char *index_name, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_drop_index_with_opts(mongoc_collection_t *collection, + const char *index_name, + const bson_t *opts, + bson_error_t *error); + +MONGOC_EXPORT(mongoc_cursor_t *) +mongoc_collection_find_indexes_with_opts(mongoc_collection_t *collection, const bson_t *opts) + BSON_GNUC_WARN_UNUSED_RESULT; + +typedef struct _mongoc_index_model_t mongoc_index_model_t; + +MONGOC_EXPORT(mongoc_index_model_t *) +mongoc_index_model_new(const bson_t *keys, const bson_t *opts); + +MONGOC_EXPORT(void) mongoc_index_model_destroy(mongoc_index_model_t *model); + +MONGOC_EXPORT(bool) +mongoc_collection_create_indexes_with_opts(mongoc_collection_t *collection, + mongoc_index_model_t *const *models, + size_t n_models, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(mongoc_cursor_t *) +mongoc_collection_find_with_opts(mongoc_collection_t *collection, + const bson_t *filter, + const bson_t *opts, + const mongoc_read_prefs_t *read_prefs) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_collection_insert(mongoc_collection_t *collection, + mongoc_insert_flags_t flags, + const bson_t *document, + const mongoc_write_concern_t *write_concern, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_insert_one( + mongoc_collection_t *collection, const bson_t *document, const bson_t *opts, bson_t *reply, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_insert_many(mongoc_collection_t *collection, + const bson_t **documents, + size_t n_documents, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_update(mongoc_collection_t *collection, + mongoc_update_flags_t flags, + const bson_t *selector, + const bson_t *update, + const mongoc_write_concern_t *write_concern, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_update_one(mongoc_collection_t *collection, + const bson_t *selector, + const bson_t *update, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_update_many(mongoc_collection_t *collection, + const bson_t *selector, + const bson_t *update, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_replace_one(mongoc_collection_t *collection, + const bson_t *selector, + const bson_t *replacement, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_remove(mongoc_collection_t *collection, + mongoc_remove_flags_t flags, + const bson_t *selector, + const mongoc_write_concern_t *write_concern, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_delete_one( + mongoc_collection_t *collection, const bson_t *selector, const bson_t *opts, bson_t *reply, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_delete_many( + mongoc_collection_t *collection, const bson_t *selector, const bson_t *opts, bson_t *reply, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_rename(mongoc_collection_t *collection, + const char *new_db, + const char *new_name, + bool drop_target_before_rename, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_rename_with_opts(mongoc_collection_t *collection, + const char *new_db, + const char *new_name, + bool drop_target_before_rename, + const bson_t *opts, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_find_and_modify_with_opts(mongoc_collection_t *collection, + const bson_t *query, + const mongoc_find_and_modify_opts_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_collection_find_and_modify(mongoc_collection_t *collection, + const bson_t *query, + const bson_t *sort, + const bson_t *update, + const bson_t *fields, + bool _remove, + bool upsert, + bool _new, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(mongoc_bulk_operation_t *) +mongoc_collection_create_bulk_operation_with_opts(mongoc_collection_t *collection, const bson_t *opts) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(const mongoc_read_prefs_t *) +mongoc_collection_get_read_prefs(const mongoc_collection_t *collection); + +MONGOC_EXPORT(void) +mongoc_collection_set_read_prefs(mongoc_collection_t *collection, const mongoc_read_prefs_t *read_prefs); + +MONGOC_EXPORT(const mongoc_read_concern_t *) +mongoc_collection_get_read_concern(const mongoc_collection_t *collection); + +MONGOC_EXPORT(void) +mongoc_collection_set_read_concern(mongoc_collection_t *collection, const mongoc_read_concern_t *read_concern); + +MONGOC_EXPORT(const mongoc_write_concern_t *) +mongoc_collection_get_write_concern(const mongoc_collection_t *collection); + +MONGOC_EXPORT(void) +mongoc_collection_set_write_concern(mongoc_collection_t *collection, const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(const char *) +mongoc_collection_get_name(mongoc_collection_t *collection); + +MONGOC_EXPORT(char *) +mongoc_collection_keys_to_index_string(const bson_t *keys) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_change_stream_t *) +mongoc_collection_watch(const mongoc_collection_t *coll, const bson_t *pipeline, const bson_t *opts) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(int64_t) +mongoc_collection_count_documents(mongoc_collection_t *coll, + const bson_t *filter, + const bson_t *opts, + const mongoc_read_prefs_t *read_prefs, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(int64_t) +mongoc_collection_estimated_document_count(mongoc_collection_t *coll, + const bson_t *opts, + const mongoc_read_prefs_t *read_prefs, + bson_t *reply, + bson_error_t *error); + +BSON_END_DECLS + + +#endif /* MONGOC_COLLECTION_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-config.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-config.h new file mode 100644 index 0000000..2f16099 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-config.h @@ -0,0 +1,409 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if !defined(MONGOC_INSIDE) && !defined(MONGOC_COMPILATION) +#error "Only can be included directly." +#endif + + +#ifndef MONGOC_CONFIG_H +#define MONGOC_CONFIG_H + +/* clang-format off */ + +/* + * NOTICE: + * If you're about to update this file and add a config flag, make sure to + * update: + * o The bitfield in mongoc-handshake-private.h + * o _mongoc_handshake_get_config_hex_string() in mongoc-handshake.c + * o examples/parse_handshake_cfg.py + * o test_handshake_platform_config in test-mongoc-handshake.c + */ + +/* MONGOC_USER_SET_CFLAGS is set from config based on what compiler flags were + * used to compile mongoc */ +#define MONGOC_USER_SET_CFLAGS "" + +#define MONGOC_USER_SET_LDFLAGS "" + +/* MONGOC_CC is used to determine what C compiler was used to compile mongoc */ +#define MONGOC_CC "clang" + +/* + * MONGOC_ENABLE_SSL_SECURE_CHANNEL is set from configure to determine if we are + * compiled with Native SSL support on Windows + */ +#define MONGOC_ENABLE_SSL_SECURE_CHANNEL 0 +#if MONGOC_ENABLE_SSL_SECURE_CHANNEL != 1 +# undef MONGOC_ENABLE_SSL_SECURE_CHANNEL +#endif + + +/* + * MONGOC_ENABLE_CRYPTO_CNG is set from configure to determine if we are + * compiled with Native Crypto support on Windows + */ +#define MONGOC_ENABLE_CRYPTO_CNG 0 + +#if MONGOC_ENABLE_CRYPTO_CNG != 1 +# undef MONGOC_ENABLE_CRYPTO_CNG +#endif + +/* + * MONGOC_HAVE_BCRYPT_PBKDF2 is set from configure to determine if + * our Bcrypt Windows library supports PBKDF2 + */ +#define MONGOC_HAVE_BCRYPT_PBKDF2 0 + +#if MONGOC_HAVE_BCRYPT_PBKDF2 != 1 +# undef MONGOC_HAVE_BCRYPT_PBKDF2 +#endif + +/* + * MONGOC_ENABLE_SSL_SECURE_TRANSPORT is set from configure to determine if we are + * compiled with Native SSL support on Darwin + */ +#define MONGOC_ENABLE_SSL_SECURE_TRANSPORT 1 + +#if MONGOC_ENABLE_SSL_SECURE_TRANSPORT != 1 +# undef MONGOC_ENABLE_SSL_SECURE_TRANSPORT +#endif + + +/* + * MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO is set from configure to determine if we are + * compiled with Native Crypto support on Darwin + */ +#define MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO 1 + +#if MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO != 1 +# undef MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO +#endif + + +/* + * MONGOC_ENABLE_SSL_OPENSSL is set from configure to determine if we are + * compiled with OpenSSL support. + */ +#define MONGOC_ENABLE_SSL_OPENSSL 0 +#if MONGOC_ENABLE_SSL_OPENSSL != 1 +# undef MONGOC_ENABLE_SSL_OPENSSL +#endif + + +/* + * MONGOC_ENABLE_CRYPTO_LIBCRYPTO is set from configure to determine if we are + * compiled with OpenSSL support. + */ +#define MONGOC_ENABLE_CRYPTO_LIBCRYPTO 0 + +#if MONGOC_ENABLE_CRYPTO_LIBCRYPTO != 1 +# undef MONGOC_ENABLE_CRYPTO_LIBCRYPTO +#endif + + +/* + * MONGOC_ENABLE_SSL is set from configure to determine if we are + * compiled with any SSL support. + */ +#define MONGOC_ENABLE_SSL 1 + +#if MONGOC_ENABLE_SSL != 1 +# undef MONGOC_ENABLE_SSL +#endif + + +/* + * MONGOC_ENABLE_CRYPTO is set from configure to determine if we are + * compiled with any crypto support. + */ +#define MONGOC_ENABLE_CRYPTO 1 + +#if MONGOC_ENABLE_CRYPTO != 1 +# undef MONGOC_ENABLE_CRYPTO +#endif + + +/* + * Use system crypto profile + */ +#define MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE 0 + +#if MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE != 1 +# undef MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE +#endif + + +/* + * Use ASN1_STRING_get0_data () rather than the deprecated ASN1_STRING_data + */ +#define MONGOC_HAVE_ASN1_STRING_GET0_DATA 0 + +#if MONGOC_HAVE_ASN1_STRING_GET0_DATA != 1 +# undef MONGOC_HAVE_ASN1_STRING_GET0_DATA +#endif + + +/* + * MONGOC_ENABLE_SASL is set from configure to determine if we are + * compiled with SASL support. + */ +#define MONGOC_ENABLE_SASL 1 + +#if MONGOC_ENABLE_SASL != 1 +# undef MONGOC_ENABLE_SASL +#endif + + +/* + * MONGOC_ENABLE_SASL_CYRUS is set from configure to determine if we are + * compiled with Cyrus SASL support. + */ +#define MONGOC_ENABLE_SASL_CYRUS 1 + +#if MONGOC_ENABLE_SASL_CYRUS != 1 +# undef MONGOC_ENABLE_SASL_CYRUS +#endif + + +/* + * MONGOC_ENABLE_SASL_SSPI is set from configure to determine if we are + * compiled with SSPI support. + */ +#define MONGOC_ENABLE_SASL_SSPI 0 + +#if MONGOC_ENABLE_SASL_SSPI != 1 +# undef MONGOC_ENABLE_SASL_SSPI +#endif + +/* + * MONGOC_HAVE_SASL_CLIENT_DONE is set from configure to determine if we + * have SASL and its version is new enough to use sasl_client_done (), + * which supersedes sasl_done (). + */ +#define MONGOC_HAVE_SASL_CLIENT_DONE 1 + +#if MONGOC_HAVE_SASL_CLIENT_DONE != 1 +# undef MONGOC_HAVE_SASL_CLIENT_DONE +#endif + +/* + * MONGOC_HAVE_SOCKLEN is set from configure to determine if we + * need to emulate the type. + */ +#define MONGOC_HAVE_SOCKLEN 1 + +#if MONGOC_HAVE_SOCKLEN != 1 +# undef MONGOC_HAVE_SOCKLEN +#endif + +/** + * @brief Defined to 0/1 for whether we were configured with ENABLE_SRV + */ +#define MONGOC_ENABLE_SRV 1 + +/* + * MONGOC_HAVE_DNSAPI is set from configure to determine if we should use the + * Windows dnsapi for SRV record lookups. + */ +#define MONGOC_HAVE_DNSAPI 0 + +#if MONGOC_HAVE_DNSAPI != 1 +# undef MONGOC_HAVE_DNSAPI +#endif + + +/* + * MONGOC_HAVE_RES_NSEARCH is set from configure to determine if we + * have thread-safe res_nsearch(). + */ +#define MONGOC_HAVE_RES_NSEARCH 1 + +#if MONGOC_HAVE_RES_NSEARCH != 1 +# undef MONGOC_HAVE_RES_NSEARCH +#endif + + +/* + * MONGOC_HAVE_RES_NDESTROY is set from configure to determine if we + * have BSD / Darwin's res_ndestroy(). + */ +#define MONGOC_HAVE_RES_NDESTROY 1 + +#if MONGOC_HAVE_RES_NDESTROY != 1 +# undef MONGOC_HAVE_RES_NDESTROY +#endif + + +/* + * MONGOC_HAVE_RES_NCLOSE is set from configure to determine if we + * have Linux's res_nclose(). + */ +#define MONGOC_HAVE_RES_NCLOSE 1 + +#if MONGOC_HAVE_RES_NCLOSE != 1 +# undef MONGOC_HAVE_RES_NCLOSE +#endif + + +/* + * MONGOC_HAVE_RES_SEARCH is set from configure to determine if we + * have thread-unsafe res_search(). It's unset if we have the preferred + * res_nsearch(). + */ +#define MONGOC_HAVE_RES_SEARCH 1 + +#if MONGOC_HAVE_RES_SEARCH != 1 +# undef MONGOC_HAVE_RES_SEARCH +#endif + + +/* + * Set from configure, see + * https://curl.haxx.se/mail/lib-2009-04/0287.html + */ +#define MONGOC_SOCKET_ARG2 struct sockaddr +#define MONGOC_SOCKET_ARG3 socklen_t + +/* + * Enable wire protocol compression negotiation + * + */ +#define MONGOC_ENABLE_COMPRESSION 1 + +#if MONGOC_ENABLE_COMPRESSION != 1 +# undef MONGOC_ENABLE_COMPRESSION +#endif + +/* + * Set if we have snappy compression support + * + */ +#define MONGOC_ENABLE_COMPRESSION_SNAPPY 0 + +#if MONGOC_ENABLE_COMPRESSION_SNAPPY != 1 +# undef MONGOC_ENABLE_COMPRESSION_SNAPPY +#endif + + +/* + * Set if we have zlib compression support + * + */ +#define MONGOC_ENABLE_COMPRESSION_ZLIB 1 + +#if MONGOC_ENABLE_COMPRESSION_ZLIB != 1 +# undef MONGOC_ENABLE_COMPRESSION_ZLIB +#endif + +/* + * Set if we have zstd compression support + * + */ +#define MONGOC_ENABLE_COMPRESSION_ZSTD 1 + +#if MONGOC_ENABLE_COMPRESSION_ZSTD != 1 +# undef MONGOC_ENABLE_COMPRESSION_ZSTD +#endif + +/* + * Set if performance counters are available and not disabled. + * + */ +#define MONGOC_ENABLE_SHM_COUNTERS 1 + +#if MONGOC_ENABLE_SHM_COUNTERS != 1 +# undef MONGOC_ENABLE_SHM_COUNTERS +#endif + +/* + * Set if we have enabled fast counters on Intel using the RDTSCP instruction + * + */ +#define MONGOC_ENABLE_RDTSCP 0 + +#if MONGOC_ENABLE_RDTSCP != 1 +# undef MONGOC_ENABLE_RDTSCP +#endif + + +/* + * Set if we have the sched_getcpu() function for use with counters + * + */ +#define MONGOC_HAVE_SCHED_GETCPU 0 + +#if MONGOC_HAVE_SCHED_GETCPU != 1 +# undef MONGOC_HAVE_SCHED_GETCPU +#endif + +/* + * Set if tracing is enabled. Logs things like network communication and + * entry/exit of certain functions. + */ +#define MONGOC_TRACE 0 + +/* + * Set if we have Client Side Encryption support. + */ + +#define MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION 0 + +#if MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION != 1 +# undef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION +#endif + + +/* + * Set if struct sockaddr_storage has __ss_family (instead of ss_family) + */ + +#define MONGOC_HAVE_SS_FAMILY 1 + +#if MONGOC_HAVE_SS_FAMILY != 1 +# undef MONGOC_HAVE_SS_FAMILY +#endif + +/* + * Set if building with AWS IAM support. + */ +#define MONGOC_ENABLE_MONGODB_AWS_AUTH 1 + +#if MONGOC_ENABLE_MONGODB_AWS_AUTH != 1 +# undef MONGOC_ENABLE_MONGODB_AWS_AUTH +#endif + +enum { + /** + * @brief Compile-time constant determining whether the mongoc library was + * compiled with tracing enabled. + * + * Can be controlled with the “ENABLE_TRACING” configure-time boolean option + */ + MONGOC_TRACE_ENABLED = MONGOC_TRACE, + /** + * @brief Compile-time constant indicating whether the mongoc library was + * compiled with SRV server discovery support. + * + * Can be controled with the “ENABLE_SRV” configure-time boolean option. + */ + MONGOC_SRV_ENABLED = MONGOC_ENABLE_SRV, +}; + +/* clang-format on */ + +#endif /* MONGOC_CONFIG_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-cursor.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-cursor.h new file mode 100644 index 0000000..d7515de --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-cursor.h @@ -0,0 +1,103 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_CURSOR_H +#define MONGOC_CURSOR_H + +#include +#include + +#include + + +BSON_BEGIN_DECLS + +typedef struct _mongoc_cursor_t mongoc_cursor_t; + + +/* forward decl */ +struct _mongoc_client_t; + + +MONGOC_EXPORT(mongoc_cursor_t *) +mongoc_cursor_clone(const mongoc_cursor_t *cursor) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_cursor_destroy(mongoc_cursor_t *cursor); + +MONGOC_EXPORT(bool) +mongoc_cursor_more(mongoc_cursor_t *cursor); + +MONGOC_EXPORT(bool) +mongoc_cursor_next(mongoc_cursor_t *cursor, const bson_t **bson); + +MONGOC_EXPORT(bool) +mongoc_cursor_error(mongoc_cursor_t *cursor, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_cursor_error_document(mongoc_cursor_t *cursor, bson_error_t *error, const bson_t **doc); + +MONGOC_EXPORT(void) +mongoc_cursor_get_host(mongoc_cursor_t *cursor, mongoc_host_list_t *host); + +MONGOC_EXPORT(const bson_t *) +mongoc_cursor_current(const mongoc_cursor_t *cursor); + +MONGOC_EXPORT(void) +mongoc_cursor_set_batch_size(mongoc_cursor_t *cursor, uint32_t batch_size); + +MONGOC_EXPORT(uint32_t) +mongoc_cursor_get_batch_size(const mongoc_cursor_t *cursor); + +MONGOC_EXPORT(bool) +mongoc_cursor_set_limit(mongoc_cursor_t *cursor, int64_t limit); + +MONGOC_EXPORT(int64_t) +mongoc_cursor_get_limit(const mongoc_cursor_t *cursor); + +// `mongoc_cursor_set_hint` is deprecated for more aptly named `mongoc_cursor_set_server_id`. +BSON_DEPRECATED_FOR(mongoc_cursor_set_server_id) +MONGOC_EXPORT(bool) mongoc_cursor_set_hint(mongoc_cursor_t *cursor, uint32_t server_id); + +MONGOC_EXPORT(bool) +mongoc_cursor_set_server_id(mongoc_cursor_t *cursor, uint32_t server_id); + +// `mongoc_cursor_get_hint` is deprecated for more aptly named `mongoc_cursor_get_server_id`. +BSON_DEPRECATED_FOR(mongoc_cursor_get_server_id) +MONGOC_EXPORT(uint32_t) mongoc_cursor_get_hint(const mongoc_cursor_t *cursor); + +MONGOC_EXPORT(uint32_t) +mongoc_cursor_get_server_id(const mongoc_cursor_t *cursor); + +MONGOC_EXPORT(int64_t) +mongoc_cursor_get_id(const mongoc_cursor_t *cursor); + +MONGOC_EXPORT(void) +mongoc_cursor_set_max_await_time_ms(mongoc_cursor_t *cursor, uint32_t max_await_time_ms); + +MONGOC_EXPORT(uint32_t) +mongoc_cursor_get_max_await_time_ms(const mongoc_cursor_t *cursor); + +MONGOC_EXPORT(mongoc_cursor_t *) +mongoc_cursor_new_from_command_reply_with_opts(struct _mongoc_client_t *client, bson_t *reply, const bson_t *opts) + BSON_GNUC_WARN_UNUSED_RESULT; + +BSON_END_DECLS + + +#endif /* MONGOC_CURSOR_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-database.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-database.h new file mode 100644 index 0000000..e7a4842 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-database.h @@ -0,0 +1,154 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_DATABASE_H +#define MONGOC_DATABASE_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_database_t mongoc_database_t; + + +MONGOC_EXPORT(const char *) +mongoc_database_get_name(mongoc_database_t *database); + +MONGOC_EXPORT(bool) +mongoc_database_remove_user(mongoc_database_t *database, const char *username, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_database_remove_all_users(mongoc_database_t *database, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_database_add_user(mongoc_database_t *database, + const char *username, + const char *password, + const bson_t *roles, + const bson_t *custom_data, + bson_error_t *error); + +MONGOC_EXPORT(void) +mongoc_database_destroy(mongoc_database_t *database); + +MONGOC_EXPORT(mongoc_cursor_t *) +mongoc_database_aggregate(mongoc_database_t *db, + const bson_t *pipeline, + const bson_t *opts, + const mongoc_read_prefs_t *read_prefs) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_database_t *) +mongoc_database_copy(mongoc_database_t *database) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_database_read_command_with_opts(mongoc_database_t *database, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_database_write_command_with_opts( + mongoc_database_t *database, const bson_t *command, const bson_t *opts, bson_t *reply, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_database_read_write_command_with_opts(mongoc_database_t *database, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs /* IGNORED */, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_database_command_with_opts(mongoc_database_t *database, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs, + const bson_t *opts, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_database_command_simple(mongoc_database_t *database, + const bson_t *command, + const mongoc_read_prefs_t *read_prefs, + bson_t *reply, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_database_drop(mongoc_database_t *database, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_database_drop_with_opts(mongoc_database_t *database, const bson_t *opts, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_database_has_collection(mongoc_database_t *database, const char *name, bson_error_t *error); + +MONGOC_EXPORT(mongoc_collection_t *) +mongoc_database_create_collection(mongoc_database_t *database, + const char *name, + const bson_t *options, + bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(const mongoc_read_prefs_t *) +mongoc_database_get_read_prefs(const mongoc_database_t *database); + +MONGOC_EXPORT(void) +mongoc_database_set_read_prefs(mongoc_database_t *database, const mongoc_read_prefs_t *read_prefs); + +MONGOC_EXPORT(const mongoc_write_concern_t *) +mongoc_database_get_write_concern(const mongoc_database_t *database); + +MONGOC_EXPORT(void) +mongoc_database_set_write_concern(mongoc_database_t *database, const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(const mongoc_read_concern_t *) +mongoc_database_get_read_concern(const mongoc_database_t *database); + +MONGOC_EXPORT(void) +mongoc_database_set_read_concern(mongoc_database_t *database, const mongoc_read_concern_t *read_concern); + +MONGOC_EXPORT(mongoc_cursor_t *) +mongoc_database_find_collections_with_opts(mongoc_database_t *database, const bson_t *opts) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(char **) +mongoc_database_get_collection_names_with_opts(mongoc_database_t *database, const bson_t *opts, bson_error_t *error) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_collection_t *) +mongoc_database_get_collection(mongoc_database_t *database, const char *name) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_change_stream_t *) +mongoc_database_watch(const mongoc_database_t *db, const bson_t *pipeline, const bson_t *opts) + BSON_GNUC_WARN_UNUSED_RESULT; + +BSON_END_DECLS + + +#endif /* MONGOC_DATABASE_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-error.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-error.h new file mode 100644 index 0000000..432d9b8 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-error.h @@ -0,0 +1,152 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_ERRORS_H +#define MONGOC_ERRORS_H + +#include + +#include + +#define MONGOC_ERROR_API_VERSION_LEGACY 1 +#define MONGOC_ERROR_API_VERSION_2 2 + +BSON_BEGIN_DECLS + + +typedef enum { + MONGOC_ERROR_CLIENT = 1, + MONGOC_ERROR_STREAM, + MONGOC_ERROR_PROTOCOL, + MONGOC_ERROR_CURSOR, + MONGOC_ERROR_QUERY, + MONGOC_ERROR_INSERT, + MONGOC_ERROR_SASL, + MONGOC_ERROR_BSON, + MONGOC_ERROR_MATCHER, + MONGOC_ERROR_NAMESPACE, + MONGOC_ERROR_COMMAND, + MONGOC_ERROR_COLLECTION, + MONGOC_ERROR_GRIDFS, + MONGOC_ERROR_SCRAM, + MONGOC_ERROR_SERVER_SELECTION, + MONGOC_ERROR_WRITE_CONCERN, + MONGOC_ERROR_SERVER, /* Error API Version 2 only */ + MONGOC_ERROR_TRANSACTION, + MONGOC_ERROR_CLIENT_SIDE_ENCRYPTION, /* An error coming from libmongocrypt */ + MONGOC_ERROR_POOL, + MONGOC_ERROR_AZURE, + MONGOC_ERROR_GCP +} mongoc_error_domain_t; + + +typedef enum { + MONGOC_ERROR_STREAM_INVALID_TYPE = 1, + MONGOC_ERROR_STREAM_INVALID_STATE, + MONGOC_ERROR_STREAM_NAME_RESOLUTION, + MONGOC_ERROR_STREAM_SOCKET, + MONGOC_ERROR_STREAM_CONNECT, + MONGOC_ERROR_STREAM_NOT_ESTABLISHED, + + MONGOC_ERROR_CLIENT_NOT_READY, + MONGOC_ERROR_CLIENT_TOO_BIG, + MONGOC_ERROR_CLIENT_TOO_SMALL, + MONGOC_ERROR_CLIENT_GETNONCE, + MONGOC_ERROR_CLIENT_AUTHENTICATE, + MONGOC_ERROR_CLIENT_NO_ACCEPTABLE_PEER, + MONGOC_ERROR_CLIENT_IN_EXHAUST, + + MONGOC_ERROR_PROTOCOL_INVALID_REPLY, + MONGOC_ERROR_PROTOCOL_BAD_WIRE_VERSION, + + MONGOC_ERROR_CURSOR_INVALID_CURSOR, + + MONGOC_ERROR_QUERY_FAILURE, + + MONGOC_ERROR_BSON_INVALID, + + MONGOC_ERROR_MATCHER_INVALID, + + MONGOC_ERROR_NAMESPACE_INVALID, + MONGOC_ERROR_NAMESPACE_INVALID_FILTER_TYPE, + + MONGOC_ERROR_COMMAND_INVALID_ARG, + + MONGOC_ERROR_COLLECTION_INSERT_FAILED, + MONGOC_ERROR_COLLECTION_UPDATE_FAILED, + MONGOC_ERROR_COLLECTION_DELETE_FAILED, + MONGOC_ERROR_COLLECTION_DOES_NOT_EXIST = 26, + + MONGOC_ERROR_GRIDFS_INVALID_FILENAME, + + MONGOC_ERROR_SCRAM_NOT_DONE, + MONGOC_ERROR_SCRAM_PROTOCOL_ERROR, + + MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND = 59, + MONGOC_ERROR_QUERY_NOT_TAILABLE = 13051, + + MONGOC_ERROR_SERVER_SELECTION_BAD_WIRE_VERSION, + MONGOC_ERROR_SERVER_SELECTION_FAILURE, + MONGOC_ERROR_SERVER_SELECTION_INVALID_ID, + + MONGOC_ERROR_GRIDFS_CHUNK_MISSING, + MONGOC_ERROR_GRIDFS_PROTOCOL_ERROR, + + /* Dup with query failure. */ + MONGOC_ERROR_PROTOCOL_ERROR = 17, + + MONGOC_ERROR_WRITE_CONCERN_ERROR = 64, + + MONGOC_ERROR_DUPLICATE_KEY = 11000, + + MONGOC_ERROR_MAX_TIME_MS_EXPIRED = 50, + + MONGOC_ERROR_CHANGE_STREAM_NO_RESUME_TOKEN, + MONGOC_ERROR_CLIENT_SESSION_FAILURE, + MONGOC_ERROR_TRANSACTION_INVALID_STATE, + MONGOC_ERROR_GRIDFS_CORRUPT, + MONGOC_ERROR_GRIDFS_BUCKET_FILE_NOT_FOUND, + MONGOC_ERROR_GRIDFS_BUCKET_STREAM, + + /* An error related to initializing client side encryption. */ + MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_STATE, + + MONGOC_ERROR_CLIENT_INVALID_ENCRYPTION_ARG, + + + /* An error related to server version api */ + MONGOC_ERROR_CLIENT_API_ALREADY_SET, + MONGOC_ERROR_CLIENT_API_FROM_POOL, + MONGOC_ERROR_POOL_API_ALREADY_SET, + MONGOC_ERROR_POOL_API_TOO_LATE, + + MONGOC_ERROR_CLIENT_INVALID_LOAD_BALANCER, + + /* An error related to either GCP metadata or Azure IMDS server */ + MONGOC_ERROR_KMS_SERVER_HTTP, + MONGOC_ERROR_KMS_SERVER_BAD_JSON, + +} mongoc_error_code_t; + +MONGOC_EXPORT(bool) +mongoc_error_has_label(const bson_t *reply, const char *label); + +BSON_END_DECLS + + +#endif /* MONGOC_ERRORS_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-find-and-modify.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-find-and-modify.h new file mode 100644 index 0000000..892c574 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-find-and-modify.h @@ -0,0 +1,88 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_FIND_AND_MODIFY_H +#define MONGOC_FIND_AND_MODIFY_H + +#include + +#include + +BSON_BEGIN_DECLS + +typedef enum { + MONGOC_FIND_AND_MODIFY_NONE = 0, + MONGOC_FIND_AND_MODIFY_REMOVE = 1 << 0, + MONGOC_FIND_AND_MODIFY_UPSERT = 1 << 1, + MONGOC_FIND_AND_MODIFY_RETURN_NEW = 1 << 2, +} mongoc_find_and_modify_flags_t; + +typedef struct _mongoc_find_and_modify_opts_t mongoc_find_and_modify_opts_t; + +MONGOC_EXPORT(mongoc_find_and_modify_opts_t *) +mongoc_find_and_modify_opts_new(void) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_find_and_modify_opts_set_sort(mongoc_find_and_modify_opts_t *opts, const bson_t *sort); + +MONGOC_EXPORT(void) +mongoc_find_and_modify_opts_get_sort(const mongoc_find_and_modify_opts_t *opts, bson_t *sort); + +MONGOC_EXPORT(bool) +mongoc_find_and_modify_opts_set_update(mongoc_find_and_modify_opts_t *opts, const bson_t *update); + +MONGOC_EXPORT(void) +mongoc_find_and_modify_opts_get_update(const mongoc_find_and_modify_opts_t *opts, bson_t *update); + +MONGOC_EXPORT(bool) +mongoc_find_and_modify_opts_set_fields(mongoc_find_and_modify_opts_t *opts, const bson_t *fields); + +MONGOC_EXPORT(void) +mongoc_find_and_modify_opts_get_fields(const mongoc_find_and_modify_opts_t *opts, bson_t *fields); + +MONGOC_EXPORT(bool) +mongoc_find_and_modify_opts_set_flags(mongoc_find_and_modify_opts_t *opts, const mongoc_find_and_modify_flags_t flags); + +MONGOC_EXPORT(mongoc_find_and_modify_flags_t) +mongoc_find_and_modify_opts_get_flags(const mongoc_find_and_modify_opts_t *opts); + +MONGOC_EXPORT(bool) +mongoc_find_and_modify_opts_set_bypass_document_validation(mongoc_find_and_modify_opts_t *opts, bool bypass); + +MONGOC_EXPORT(bool) +mongoc_find_and_modify_opts_get_bypass_document_validation(const mongoc_find_and_modify_opts_t *opts); + +MONGOC_EXPORT(bool) +mongoc_find_and_modify_opts_set_max_time_ms(mongoc_find_and_modify_opts_t *opts, uint32_t max_time_ms); + +MONGOC_EXPORT(uint32_t) +mongoc_find_and_modify_opts_get_max_time_ms(const mongoc_find_and_modify_opts_t *opts); + +MONGOC_EXPORT(bool) +mongoc_find_and_modify_opts_append(mongoc_find_and_modify_opts_t *opts, const bson_t *extra); + +MONGOC_EXPORT(void) +mongoc_find_and_modify_opts_get_extra(const mongoc_find_and_modify_opts_t *opts, bson_t *extra); + +MONGOC_EXPORT(void) +mongoc_find_and_modify_opts_destroy(mongoc_find_and_modify_opts_t *opts); + +BSON_END_DECLS + + +#endif /* MONGOC_FIND_AND_MODIFY_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-flags.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-flags.h new file mode 100644 index 0000000..af47747 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-flags.h @@ -0,0 +1,110 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_FLAGS_H +#define MONGOC_FLAGS_H + +#include + + +BSON_BEGIN_DECLS + + +/** + * mongoc_remove_flags_t: + * @MONGOC_REMOVE_NONE: Specify no delete flags. + * @MONGOC_REMOVE_SINGLE_REMOVE: Only remove the first document matching the + * document selector. + * + * #mongoc_remove_flags_t are used when performing a remove operation. + */ +typedef enum { + MONGOC_REMOVE_NONE = 0, + MONGOC_REMOVE_SINGLE_REMOVE = 1 << 0, +} mongoc_remove_flags_t; + + +/** + * mongoc_insert_flags_t: + * @MONGOC_INSERT_NONE: Specify no insert flags. + * @MONGOC_INSERT_CONTINUE_ON_ERROR: Continue inserting documents from + * the insertion set even if one fails. + * + * #mongoc_insert_flags_t are used when performing an insert operation. + */ +typedef enum { + MONGOC_INSERT_NONE = 0, + MONGOC_INSERT_CONTINUE_ON_ERROR = 1 << 0, +} mongoc_insert_flags_t; + + +#define MONGOC_INSERT_NO_VALIDATE (1U << 31) + + +/** + * mongoc_query_flags_t: + * @MONGOC_QUERY_NONE: No query flags supplied. + * @MONGOC_QUERY_TAILABLE_CURSOR: Cursor will not be closed when the last + * data is retrieved. You can resume this cursor later. + * @MONGOC_QUERY_SECONDARY_OK: Allow query of secondaries in a replica set. + * @MONGOC_QUERY_OPLOG_REPLAY: Used internally by Mongo. + * @MONGOC_QUERY_NO_CURSOR_TIMEOUT: The server normally times out idle + * cursors after an inactivity period (10 minutes). This prevents that. + * @MONGOC_QUERY_AWAIT_DATA: Use with %MONGOC_QUERY_TAILABLE_CURSOR. Block + * rather than returning no data. After a period, time out. + * @MONGOC_QUERY_EXHAUST: Stream the data down full blast in multiple + * "more" packages. Faster when you are pulling a lot of data and + * know you want to pull it all down. + * @MONGOC_QUERY_PARTIAL: Get partial results from mongos if some shards + * are down (instead of throwing an error). + * + * #mongoc_query_flags_t is used for querying a Mongo instance. + */ +typedef enum { + MONGOC_QUERY_NONE = 0, + MONGOC_QUERY_TAILABLE_CURSOR = 1 << 1, + MONGOC_QUERY_SECONDARY_OK = 1 << 2, + MONGOC_QUERY_OPLOG_REPLAY = 1 << 3, + MONGOC_QUERY_NO_CURSOR_TIMEOUT = 1 << 4, + MONGOC_QUERY_AWAIT_DATA = 1 << 5, + MONGOC_QUERY_EXHAUST = 1 << 6, + MONGOC_QUERY_PARTIAL = 1 << 7, +} mongoc_query_flags_t; + + +/** + * mongoc_update_flags_t: + * @MONGOC_UPDATE_NONE: No update flags specified. + * @MONGOC_UPDATE_UPSERT: Perform an upsert. + * @MONGOC_UPDATE_MULTI_UPDATE: Continue updating after first match. + * + * #mongoc_update_flags_t is used when updating documents found in Mongo. + */ +typedef enum { + MONGOC_UPDATE_NONE = 0, + MONGOC_UPDATE_UPSERT = 1 << 0, + MONGOC_UPDATE_MULTI_UPDATE = 1 << 1, +} mongoc_update_flags_t; + + +#define MONGOC_UPDATE_NO_VALIDATE (1U << 31) + +BSON_END_DECLS + + +#endif /* MONGOC_FLAGS_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-bucket.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-bucket.h new file mode 100644 index 0000000..bd1e42e --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-bucket.h @@ -0,0 +1,97 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_GRIDFS_BUCKET_H +#define MONGOC_GRIDFS_BUCKET_H + +#include +#include +#include + +#include + +BSON_BEGIN_DECLS + +typedef struct _mongoc_gridfs_bucket_t mongoc_gridfs_bucket_t; + +MONGOC_EXPORT(mongoc_gridfs_bucket_t *) +mongoc_gridfs_bucket_new(mongoc_database_t *db, + const bson_t *opts, + const mongoc_read_prefs_t *read_prefs, + bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_gridfs_bucket_open_upload_stream(mongoc_gridfs_bucket_t *bucket, + const char *filename, + const bson_t *opts, + bson_value_t *file_id, + bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_gridfs_bucket_open_upload_stream_with_id(mongoc_gridfs_bucket_t *bucket, + const bson_value_t *file_id, + const char *filename, + const bson_t *opts, + bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_gridfs_bucket_upload_from_stream(mongoc_gridfs_bucket_t *bucket, + const char *filename, + mongoc_stream_t *source, + const bson_t *opts, + bson_value_t *file_id, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_gridfs_bucket_upload_from_stream_with_id(mongoc_gridfs_bucket_t *bucket, + const bson_value_t *file_id, + const char *filename, + mongoc_stream_t *source, + const bson_t *opts, + bson_error_t *error); + +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_gridfs_bucket_open_download_stream(mongoc_gridfs_bucket_t *bucket, + const bson_value_t *file_id, + bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_gridfs_bucket_download_to_stream(mongoc_gridfs_bucket_t *bucket, + const bson_value_t *file_id, + mongoc_stream_t *destination, + bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_gridfs_bucket_delete_by_id(mongoc_gridfs_bucket_t *bucket, const bson_value_t *file_id, bson_error_t *error); + +MONGOC_EXPORT(mongoc_cursor_t *) +mongoc_gridfs_bucket_find(mongoc_gridfs_bucket_t *bucket, const bson_t *filter, const bson_t *opts) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_gridfs_bucket_stream_error(mongoc_stream_t *stream, bson_error_t *error); + +MONGOC_EXPORT(void) +mongoc_gridfs_bucket_destroy(mongoc_gridfs_bucket_t *bucket); + +MONGOC_EXPORT(bool) +mongoc_gridfs_bucket_abort_upload(mongoc_stream_t *stream); + +BSON_END_DECLS + +#endif /* MONGOC_GRIDFS_BUCKET_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-file-list.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-file-list.h new file mode 100644 index 0000000..6a3521f --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-file-list.h @@ -0,0 +1,45 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_GRIDFS_FILE_LIST_H +#define MONGOC_GRIDFS_FILE_LIST_H + +#include +#include + +#include + + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_gridfs_file_list_t mongoc_gridfs_file_list_t; + + +MONGOC_EXPORT(mongoc_gridfs_file_t *) +mongoc_gridfs_file_list_next(mongoc_gridfs_file_list_t *list) BSON_GNUC_WARN_UNUSED_RESULT; +MONGOC_EXPORT(void) +mongoc_gridfs_file_list_destroy(mongoc_gridfs_file_list_t *list); +MONGOC_EXPORT(bool) +mongoc_gridfs_file_list_error(mongoc_gridfs_file_list_t *list, bson_error_t *error); + + +BSON_END_DECLS + + +#endif /* MONGOC_GRIDFS_FILE_LIST_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-file-page.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-file-page.h new file mode 100644 index 0000000..d44dc58 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-file-page.h @@ -0,0 +1,38 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_GRIDFS_FILE_PAGE_H +#define MONGOC_GRIDFS_FILE_PAGE_H + +#include +#include +#include + +#include + + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_gridfs_file_page_t mongoc_gridfs_file_page_t; + + +BSON_END_DECLS + + +#endif /* MONGOC_GRIDFS_FILE_PAGE_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-file.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-file.h new file mode 100644 index 0000000..6d46730 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs-file.h @@ -0,0 +1,99 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_GRIDFS_FILE_H +#define MONGOC_GRIDFS_FILE_H + +#include +#include + +#include + +BSON_BEGIN_DECLS + +#define MONGOC_GRIDFS_FILE_STR_HEADER(name) \ + MONGOC_EXPORT(const char *) \ + mongoc_gridfs_file_get_##name(mongoc_gridfs_file_t *file); \ + MONGOC_EXPORT(void) \ + mongoc_gridfs_file_set_##name(mongoc_gridfs_file_t *file, const char *str); + +#define MONGOC_GRIDFS_FILE_BSON_HEADER(name) \ + MONGOC_EXPORT(const bson_t *) \ + mongoc_gridfs_file_get_##name(mongoc_gridfs_file_t *file); \ + MONGOC_EXPORT(void) \ + mongoc_gridfs_file_set_##name(mongoc_gridfs_file_t *file, const bson_t *bson); + +typedef struct _mongoc_gridfs_file_t mongoc_gridfs_file_t; +typedef struct _mongoc_gridfs_file_opt_t mongoc_gridfs_file_opt_t; + +struct _mongoc_gridfs_file_opt_t { + const char *md5; + const char *filename; + const char *content_type; + const bson_t *aliases; + const bson_t *metadata; + uint32_t chunk_size; +}; + +MONGOC_GRIDFS_FILE_STR_HEADER(md5) +MONGOC_GRIDFS_FILE_STR_HEADER(filename) +MONGOC_GRIDFS_FILE_STR_HEADER(content_type) +MONGOC_GRIDFS_FILE_BSON_HEADER(aliases) +MONGOC_GRIDFS_FILE_BSON_HEADER(metadata) + +MONGOC_EXPORT(const bson_value_t *) +mongoc_gridfs_file_get_id(mongoc_gridfs_file_t *file); + +MONGOC_EXPORT(int64_t) +mongoc_gridfs_file_get_length(mongoc_gridfs_file_t *file); + +MONGOC_EXPORT(int32_t) +mongoc_gridfs_file_get_chunk_size(mongoc_gridfs_file_t *file); + +MONGOC_EXPORT(int64_t) +mongoc_gridfs_file_get_upload_date(mongoc_gridfs_file_t *file); + +MONGOC_EXPORT(ssize_t) +mongoc_gridfs_file_writev(mongoc_gridfs_file_t *file, const mongoc_iovec_t *iov, size_t iovcnt, uint32_t timeout_msec); +MONGOC_EXPORT(ssize_t) +mongoc_gridfs_file_readv( + mongoc_gridfs_file_t *file, mongoc_iovec_t *iov, size_t iovcnt, size_t min_bytes, uint32_t timeout_msec); +MONGOC_EXPORT(int) +mongoc_gridfs_file_seek(mongoc_gridfs_file_t *file, int64_t delta, int whence); + +MONGOC_EXPORT(uint64_t) +mongoc_gridfs_file_tell(mongoc_gridfs_file_t *file); + +MONGOC_EXPORT(bool) +mongoc_gridfs_file_set_id(mongoc_gridfs_file_t *file, const bson_value_t *id, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_gridfs_file_save(mongoc_gridfs_file_t *file); + +MONGOC_EXPORT(void) +mongoc_gridfs_file_destroy(mongoc_gridfs_file_t *file); + +MONGOC_EXPORT(bool) +mongoc_gridfs_file_error(mongoc_gridfs_file_t *file, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_gridfs_file_remove(mongoc_gridfs_file_t *file, bson_error_t *error); + +BSON_END_DECLS + +#endif /* MONGOC_GRIDFS_FILE_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs.h new file mode 100644 index 0000000..12e8ea5 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-gridfs.h @@ -0,0 +1,74 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_GRIDFS_H +#define MONGOC_GRIDFS_H + +#include +#include +#include +#include +#include + +#include + + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_gridfs_t mongoc_gridfs_t; + +MONGOC_EXPORT(mongoc_gridfs_file_t *) +mongoc_gridfs_create_file_from_stream(mongoc_gridfs_t *gridfs, mongoc_stream_t *stream, mongoc_gridfs_file_opt_t *opt) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_gridfs_file_t *) +mongoc_gridfs_create_file(mongoc_gridfs_t *gridfs, mongoc_gridfs_file_opt_t *opt) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_gridfs_file_list_t *) +mongoc_gridfs_find_with_opts(mongoc_gridfs_t *gridfs, const bson_t *filter, const bson_t *opts) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_gridfs_file_t *) +mongoc_gridfs_find_one_with_opts(mongoc_gridfs_t *gridfs, const bson_t *filter, const bson_t *opts, bson_error_t *error) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_gridfs_file_t *) +mongoc_gridfs_find_one_by_filename(mongoc_gridfs_t *gridfs, const char *filename, bson_error_t *error) + BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_gridfs_drop(mongoc_gridfs_t *gridfs, bson_error_t *error); + +MONGOC_EXPORT(void) +mongoc_gridfs_destroy(mongoc_gridfs_t *gridfs); + +MONGOC_EXPORT(mongoc_collection_t *) +mongoc_gridfs_get_files(mongoc_gridfs_t *gridfs); + +MONGOC_EXPORT(mongoc_collection_t *) +mongoc_gridfs_get_chunks(mongoc_gridfs_t *gridfs); + +MONGOC_EXPORT(bool) +mongoc_gridfs_remove_by_filename(mongoc_gridfs_t *gridfs, const char *filename, bson_error_t *error); + + +BSON_END_DECLS + + +#endif /* MONGOC_GRIDFS_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-handshake.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-handshake.h new file mode 100644 index 0000000..31ff62e --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-handshake.h @@ -0,0 +1,36 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef MONGOC_HANDSHAKE_H +#define MONGOC_HANDSHAKE_H + +#include + +#include + +BSON_BEGIN_DECLS + +#define MONGOC_HANDSHAKE_APPNAME_MAX 128 + +MONGOC_EXPORT(bool) +mongoc_handshake_data_append(const char *driver_name, const char *driver_version, const char *platform); + +BSON_END_DECLS + +#endif diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-host-list.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-host-list.h new file mode 100644 index 0000000..cd73202 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-host-list.h @@ -0,0 +1,50 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_HOST_LIST_H +#define MONGOC_HOST_LIST_H + +#include + + +BSON_BEGIN_DECLS + + +#ifdef _POSIX_HOST_NAME_MAX +#define BSON_HOST_NAME_MAX _POSIX_HOST_NAME_MAX +#else +#define BSON_HOST_NAME_MAX 255 +#endif + + +typedef struct _mongoc_host_list_t mongoc_host_list_t; + + +struct _mongoc_host_list_t { + mongoc_host_list_t *next; + char host[BSON_HOST_NAME_MAX + 1]; + char host_and_port[BSON_HOST_NAME_MAX + 7]; + uint16_t port; + int family; + void *padding[4]; +}; + +BSON_END_DECLS + + +#endif /* MONGOC_HOST_LIST_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-init.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-init.h new file mode 100644 index 0000000..5a59455 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-init.h @@ -0,0 +1,38 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_INIT_H +#define MONGOC_INIT_H + +#include + +#include + +BSON_BEGIN_DECLS + + +MONGOC_EXPORT(void) +mongoc_init(void); +MONGOC_EXPORT(void) +mongoc_cleanup(void); + + +BSON_END_DECLS + + +#endif /* MONGOC_INIT_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-iovec.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-iovec.h new file mode 100644 index 0000000..4619aac --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-iovec.h @@ -0,0 +1,53 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef MONGOC_IOVEC_H +#define MONGOC_IOVEC_H + + +#include + +#ifdef _WIN32 +#include +#else +#include +#endif + +BSON_BEGIN_DECLS + + +#ifdef _WIN32 +typedef struct { + size_t iov_len; + char *iov_base; +} mongoc_iovec_t; + +BSON_STATIC_ASSERT2(sizeof_iovect_t, sizeof(mongoc_iovec_t) == sizeof(WSABUF)); +BSON_STATIC_ASSERT2(offsetof_iovec_base, offsetof(mongoc_iovec_t, iov_base) == offsetof(WSABUF, buf)); +BSON_STATIC_ASSERT2(offsetof_iovec_len, offsetof(mongoc_iovec_t, iov_len) == offsetof(WSABUF, len)); + +#else +typedef struct iovec mongoc_iovec_t; +#endif + + +BSON_END_DECLS + + +#endif /* MONGOC_IOVEC_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-log.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-log.h new file mode 100644 index 0000000..5f0831c --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-log.h @@ -0,0 +1,133 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_LOG_H +#define MONGOC_LOG_H + +#include + +#include + +BSON_BEGIN_DECLS + + +#ifndef MONGOC_LOG_DOMAIN +#define MONGOC_LOG_DOMAIN "mongoc" +#endif + + +#define MONGOC_ERROR(...) mongoc_log(MONGOC_LOG_LEVEL_ERROR, MONGOC_LOG_DOMAIN, __VA_ARGS__) +#define MONGOC_CRITICAL(...) mongoc_log(MONGOC_LOG_LEVEL_CRITICAL, MONGOC_LOG_DOMAIN, __VA_ARGS__) +#define MONGOC_WARNING(...) mongoc_log(MONGOC_LOG_LEVEL_WARNING, MONGOC_LOG_DOMAIN, __VA_ARGS__) +#define MONGOC_MESSAGE(...) mongoc_log(MONGOC_LOG_LEVEL_MESSAGE, MONGOC_LOG_DOMAIN, __VA_ARGS__) +#define MONGOC_INFO(...) mongoc_log(MONGOC_LOG_LEVEL_INFO, MONGOC_LOG_DOMAIN, __VA_ARGS__) +#define MONGOC_DEBUG(...) mongoc_log(MONGOC_LOG_LEVEL_DEBUG, MONGOC_LOG_DOMAIN, __VA_ARGS__) + + +typedef enum { + MONGOC_LOG_LEVEL_ERROR, + MONGOC_LOG_LEVEL_CRITICAL, + MONGOC_LOG_LEVEL_WARNING, + MONGOC_LOG_LEVEL_MESSAGE, + MONGOC_LOG_LEVEL_INFO, + MONGOC_LOG_LEVEL_DEBUG, + MONGOC_LOG_LEVEL_TRACE, +} mongoc_log_level_t; + + +/** + * mongoc_log_func_t: + * @log_level: The level of the log message. + * @log_domain: The domain of the log message, such as "client". + * @message: The message generated. + * @user_data: User data provided to mongoc_log_set_handler(). + * + * This function prototype can be used to set a custom log handler for the + * libmongoc library. This is useful if you would like to show them in a + * user interface or alternate storage. + */ +typedef void(BSON_CALL *mongoc_log_func_t)(mongoc_log_level_t log_level, + const char *log_domain, + const char *message, + void *user_data); + + +/** + * mongoc_log_set_handler: + * @log_func: A function to handle log messages. + * @user_data: User data for @log_func. + * + * Sets the function to be called to handle logging. + */ +MONGOC_EXPORT(void) +mongoc_log_set_handler(mongoc_log_func_t log_func, void *user_data); + + +/** + * mongoc_log: + * @log_level: The log level. + * @log_domain: The log domain (such as "client"). + * @format: The format string for the log message. + * + * Logs a message using the currently configured logger. + * + * This method will hold a logging lock to prevent concurrent calls to the + * logging infrastructure. It is important that your configured log function + * does not re-enter the logging system or deadlock will occur. + * + */ +MONGOC_EXPORT(void) +mongoc_log(mongoc_log_level_t log_level, const char *log_domain, const char *format, ...) BSON_GNUC_PRINTF(3, 4); + + +MONGOC_EXPORT(void) +mongoc_log_default_handler(mongoc_log_level_t log_level, const char *log_domain, const char *message, void *user_data); + + +/** + * mongoc_log_level_str: + * @log_level: The log level. + * + * Returns: The string representation of log_level + */ +MONGOC_EXPORT(const char *) +mongoc_log_level_str(mongoc_log_level_t log_level); + + +/** + * mongoc_log_trace_enable: + * + * Enables tracing at runtime (if it has been enabled at compile time). + */ +MONGOC_EXPORT(void) +mongoc_log_trace_enable(void); + + +/** + * mongoc_log_trace_disable: + * + * Disables tracing at runtime (if it has been enabled at compile time). + */ +MONGOC_EXPORT(void) +mongoc_log_trace_disable(void); + + +BSON_END_DECLS + + +#endif /* MONGOC_LOG_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-macros.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-macros.h new file mode 100644 index 0000000..8d6fcdc --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-macros.h @@ -0,0 +1,68 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_MACROS_H +#define MONGOC_MACROS_H + +/* Decorate public functions: + * - if MONGOC_STATIC, we're compiling a static libmongoc or a program + * that uses libmongoc as a static library. Don't decorate functions + * - else if MONGOC_COMPILATION, we're compiling a shared libmongoc, + * mark public functions for export from the shared lib. + * - else, we're compiling a program that uses libmongoc as a shared library, + * mark public functions as DLL imports for Microsoft Visual C. + */ + +#ifdef _MSC_VER +/* + * Microsoft Visual C + */ +#ifdef MONGOC_STATIC +#define MONGOC_API +#elif defined(MONGOC_COMPILATION) +#define MONGOC_API __declspec(dllexport) +#else +#define MONGOC_API __declspec(dllimport) +#endif +#define MONGOC_CALL __cdecl + +#elif defined(__GNUC__) +/* + * GCC + */ +#ifdef MONGOC_STATIC +#define MONGOC_API +#elif defined(MONGOC_COMPILATION) +#define MONGOC_API __attribute__((visibility("default"))) +#else +#define MONGOC_API +#endif +#define MONGOC_CALL + +#else +/* + * Other compilers + */ +#define MONGOC_API +#define MONGOC_CALL + +#endif + +#define MONGOC_EXPORT(type) MONGOC_API type MONGOC_CALL + +#endif /* MONGOC_MACROS_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-oidc-callback.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-oidc-callback.h new file mode 100644 index 0000000..88022f8 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-oidc-callback.h @@ -0,0 +1,86 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_OIDC_CALLBACK_H +#define MONGOC_OIDC_CALLBACK_H + +#include + +#include + +#include + +BSON_BEGIN_DECLS + +typedef struct _mongoc_oidc_callback_t mongoc_oidc_callback_t; +typedef struct _mongoc_oidc_callback_params_t mongoc_oidc_callback_params_t; +typedef struct _mongoc_oidc_credential_t mongoc_oidc_credential_t; + +typedef mongoc_oidc_credential_t *(MONGOC_CALL *mongoc_oidc_callback_fn_t)(mongoc_oidc_callback_params_t *params); + +MONGOC_EXPORT(mongoc_oidc_callback_t *) +mongoc_oidc_callback_new(mongoc_oidc_callback_fn_t fn); + +MONGOC_EXPORT(mongoc_oidc_callback_t *) +mongoc_oidc_callback_new_with_user_data(mongoc_oidc_callback_fn_t fn, void *user_data); + +MONGOC_EXPORT(void) +mongoc_oidc_callback_destroy(mongoc_oidc_callback_t *callback); + +MONGOC_EXPORT(mongoc_oidc_callback_fn_t) +mongoc_oidc_callback_get_fn(const mongoc_oidc_callback_t *callback); + +MONGOC_EXPORT(void *) +mongoc_oidc_callback_get_user_data(const mongoc_oidc_callback_t *callback); + +MONGOC_EXPORT(void) +mongoc_oidc_callback_set_user_data(mongoc_oidc_callback_t *callback, void *user_data); + +MONGOC_EXPORT(int32_t) +mongoc_oidc_callback_params_get_version(const mongoc_oidc_callback_params_t *params); + +MONGOC_EXPORT(void *) +mongoc_oidc_callback_params_get_user_data(const mongoc_oidc_callback_params_t *params); + +MONGOC_EXPORT(const int64_t *) +mongoc_oidc_callback_params_get_timeout(const mongoc_oidc_callback_params_t *params); + +MONGOC_EXPORT(const char *) +mongoc_oidc_callback_params_get_username(const mongoc_oidc_callback_params_t *params); + +MONGOC_EXPORT(mongoc_oidc_credential_t *) +mongoc_oidc_callback_params_cancel_with_timeout(mongoc_oidc_callback_params_t *params); + +MONGOC_EXPORT(mongoc_oidc_credential_t *) +mongoc_oidc_credential_new(const char *access_token); + +MONGOC_EXPORT(mongoc_oidc_credential_t *) +mongoc_oidc_credential_new_with_expires_in(const char *access_token, int64_t expires_in); + +MONGOC_EXPORT(void) +mongoc_oidc_credential_destroy(mongoc_oidc_credential_t *cred); + +MONGOC_EXPORT(const char *) +mongoc_oidc_credential_get_access_token(const mongoc_oidc_credential_t *cred); + +MONGOC_EXPORT(const int64_t *) +mongoc_oidc_credential_get_expires_in(const mongoc_oidc_credential_t *cred); + +BSON_END_DECLS + +#endif // MONGOC_OIDC_CALLBACK_H diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-opcode.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-opcode.h new file mode 100644 index 0000000..e2ffaac --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-opcode.h @@ -0,0 +1,44 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_OPCODE_H +#define MONGOC_OPCODE_H + +#include + + +BSON_BEGIN_DECLS + + +typedef enum { + MONGOC_OPCODE_REPLY = 1, + MONGOC_OPCODE_UPDATE = 2001, + MONGOC_OPCODE_INSERT = 2002, + MONGOC_OPCODE_QUERY = 2004, + MONGOC_OPCODE_GET_MORE = 2005, + MONGOC_OPCODE_DELETE = 2006, + MONGOC_OPCODE_KILL_CURSORS = 2007, + MONGOC_OPCODE_COMPRESSED = 2012, + MONGOC_OPCODE_MSG = 2013, +} mongoc_opcode_t; + + +BSON_END_DECLS + + +#endif /* MONGOC_OPCODE_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-optional.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-optional.h new file mode 100644 index 0000000..77abd41 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-optional.h @@ -0,0 +1,50 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_OPTIONAL_H +#define MONGOC_OPTIONAL_H + +#include + +#include + +BSON_BEGIN_DECLS + +typedef struct { + bool value; + bool is_set; +} mongoc_optional_t; + +MONGOC_EXPORT(void) +mongoc_optional_init(mongoc_optional_t *opt); + +MONGOC_EXPORT(bool) +mongoc_optional_is_set(const mongoc_optional_t *opt); + +MONGOC_EXPORT(bool) +mongoc_optional_value(const mongoc_optional_t *opt); + +MONGOC_EXPORT(void) +mongoc_optional_set_value(mongoc_optional_t *opt, bool val); + +MONGOC_EXPORT(void) +mongoc_optional_copy(const mongoc_optional_t *source, mongoc_optional_t *copy); + +BSON_END_DECLS + +#endif /* MONGOC_OPTIONAL_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-prelude.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-prelude.h new file mode 100644 index 0000000..b63001c --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-prelude.h @@ -0,0 +1,19 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if !defined(MONGOC_INSIDE) && !defined(MONGOC_COMPILATION) +#error "Only can be included directly." +#endif diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-rand.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-rand.h new file mode 100644 index 0000000..90ad590 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-rand.h @@ -0,0 +1,40 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef MONGOC_RAND_H +#define MONGOC_RAND_H + + +#include + +#include + +BSON_BEGIN_DECLS + +MONGOC_EXPORT(void) +mongoc_rand_seed(const void *buf, int num); +MONGOC_EXPORT(void) +mongoc_rand_add(const void *buf, int num, double entropy); +MONGOC_EXPORT(int) +mongoc_rand_status(void); + +BSON_END_DECLS + + +#endif /* MONGOC_RAND_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-read-concern.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-read-concern.h new file mode 100644 index 0000000..2ec0bce --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-read-concern.h @@ -0,0 +1,56 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_READ_CONCERN_H +#define MONGOC_READ_CONCERN_H + +#include + +#include + +BSON_BEGIN_DECLS + + +#define MONGOC_READ_CONCERN_LEVEL_AVAILABLE "available" +#define MONGOC_READ_CONCERN_LEVEL_LOCAL "local" +#define MONGOC_READ_CONCERN_LEVEL_MAJORITY "majority" +#define MONGOC_READ_CONCERN_LEVEL_LINEARIZABLE "linearizable" +#define MONGOC_READ_CONCERN_LEVEL_SNAPSHOT "snapshot" + +typedef struct _mongoc_read_concern_t mongoc_read_concern_t; + + +MONGOC_EXPORT(mongoc_read_concern_t *) +mongoc_read_concern_new(void) BSON_GNUC_WARN_UNUSED_RESULT; +MONGOC_EXPORT(mongoc_read_concern_t *) +mongoc_read_concern_copy(const mongoc_read_concern_t *read_concern) BSON_GNUC_WARN_UNUSED_RESULT; +MONGOC_EXPORT(void) +mongoc_read_concern_destroy(mongoc_read_concern_t *read_concern); +MONGOC_EXPORT(const char *) +mongoc_read_concern_get_level(const mongoc_read_concern_t *read_concern); +MONGOC_EXPORT(bool) +mongoc_read_concern_set_level(mongoc_read_concern_t *read_concern, const char *level); +MONGOC_EXPORT(bool) +mongoc_read_concern_append(mongoc_read_concern_t *read_concern, bson_t *doc); +MONGOC_EXPORT(bool) +mongoc_read_concern_is_default(const mongoc_read_concern_t *read_concern); + +BSON_END_DECLS + + +#endif /* MONGOC_READ_CONCERN_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-read-prefs.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-read-prefs.h new file mode 100644 index 0000000..805cb0a --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-read-prefs.h @@ -0,0 +1,93 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_READ_PREFS_H +#define MONGOC_READ_PREFS_H + +#include +#include + +#include + +BSON_BEGIN_DECLS + + +#define MONGOC_NO_MAX_STALENESS -1 +#define MONGOC_SMALLEST_MAX_STALENESS_SECONDS 90 + +typedef struct _mongoc_read_prefs_t mongoc_read_prefs_t; + + +typedef enum { + /** Represents $readPreference.mode of 'primary' */ + MONGOC_READ_PRIMARY = (1 << 0), + /** Represents $readPreference.mode of 'secondary' */ + MONGOC_READ_SECONDARY = (1 << 1), + /** Represents $readPreference.mode of 'primaryPreferred' */ + MONGOC_READ_PRIMARY_PREFERRED = (1 << 2) | MONGOC_READ_PRIMARY, + /** Represents $readPreference.mode of 'secondaryPreferred' */ + MONGOC_READ_SECONDARY_PREFERRED = (1 << 2) | MONGOC_READ_SECONDARY, + /** Represents $readPreference.mode of 'nearest' */ + MONGOC_READ_NEAREST = (1 << 3) | MONGOC_READ_SECONDARY, +} mongoc_read_mode_t; + + +MONGOC_EXPORT(mongoc_read_prefs_t *) +mongoc_read_prefs_new(mongoc_read_mode_t read_mode) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_read_prefs_t *) +mongoc_read_prefs_copy(const mongoc_read_prefs_t *read_prefs) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_read_prefs_destroy(mongoc_read_prefs_t *read_prefs); + +MONGOC_EXPORT(mongoc_read_mode_t) +mongoc_read_prefs_get_mode(const mongoc_read_prefs_t *read_prefs); + +MONGOC_EXPORT(void) +mongoc_read_prefs_set_mode(mongoc_read_prefs_t *read_prefs, mongoc_read_mode_t mode); + +MONGOC_EXPORT(const bson_t *) +mongoc_read_prefs_get_tags(const mongoc_read_prefs_t *read_prefs); + +MONGOC_EXPORT(void) +mongoc_read_prefs_set_tags(mongoc_read_prefs_t *read_prefs, const bson_t *tags); + +MONGOC_EXPORT(void) +mongoc_read_prefs_add_tag(mongoc_read_prefs_t *read_prefs, const bson_t *tag); + +MONGOC_EXPORT(int64_t) +mongoc_read_prefs_get_max_staleness_seconds(const mongoc_read_prefs_t *read_prefs); + +MONGOC_EXPORT(void) +mongoc_read_prefs_set_max_staleness_seconds(mongoc_read_prefs_t *read_prefs, int64_t max_staleness_seconds); + +BSON_DEPRECATED("Hedged reads are deprecated in MongoDB 8.0 and will be removed in a future release") +MONGOC_EXPORT(const bson_t *) mongoc_read_prefs_get_hedge(const mongoc_read_prefs_t *read_prefs); + +BSON_DEPRECATED("Hedged reads are deprecated in MongoDB 8.0 and will be removed in a future release") +MONGOC_EXPORT(void) mongoc_read_prefs_set_hedge(mongoc_read_prefs_t *read_prefs, const bson_t *hedge); + +MONGOC_EXPORT(bool) +mongoc_read_prefs_is_valid(const mongoc_read_prefs_t *read_prefs); + + +BSON_END_DECLS + + +#endif /* MONGOC_READ_PREFS_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-server-api.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-server-api.h new file mode 100644 index 0000000..20e99e8 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-server-api.h @@ -0,0 +1,65 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_SERVER_API_H +#define MONGOC_SERVER_API_H + +#include +#include + +#include + +BSON_BEGIN_DECLS + +typedef enum { MONGOC_SERVER_API_V1 } mongoc_server_api_version_t; + +typedef struct _mongoc_server_api_t mongoc_server_api_t; + +MONGOC_EXPORT(const char *) +mongoc_server_api_version_to_string(mongoc_server_api_version_t version); + +MONGOC_EXPORT(bool) +mongoc_server_api_version_from_string(const char *version, mongoc_server_api_version_t *out); + +MONGOC_EXPORT(mongoc_server_api_t *) +mongoc_server_api_new(mongoc_server_api_version_t version) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_server_api_t *) +mongoc_server_api_copy(const mongoc_server_api_t *api) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_server_api_destroy(mongoc_server_api_t *api); + +MONGOC_EXPORT(void) +mongoc_server_api_strict(mongoc_server_api_t *api, bool strict); + +MONGOC_EXPORT(void) +mongoc_server_api_deprecation_errors(mongoc_server_api_t *api, bool deprecation_errors); + +MONGOC_EXPORT(const mongoc_optional_t *) +mongoc_server_api_get_deprecation_errors(const mongoc_server_api_t *api); + +MONGOC_EXPORT(const mongoc_optional_t *) +mongoc_server_api_get_strict(const mongoc_server_api_t *api); + +MONGOC_EXPORT(mongoc_server_api_version_t) +mongoc_server_api_get_version(const mongoc_server_api_t *api); + +BSON_END_DECLS + +#endif /* MONGOC_SERVER_API_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-server-description.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-server-description.h new file mode 100644 index 0000000..509bd9e --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-server-description.h @@ -0,0 +1,61 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_SERVER_DESCRIPTION_H +#define MONGOC_SERVER_DESCRIPTION_H + +#include +#include +#include + +#include + +BSON_BEGIN_DECLS + +typedef struct _mongoc_server_description_t mongoc_server_description_t; + +MONGOC_EXPORT(void) +mongoc_server_description_destroy(mongoc_server_description_t *description); + +MONGOC_EXPORT(mongoc_server_description_t *) +mongoc_server_description_new_copy(const mongoc_server_description_t *description) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(uint32_t) +mongoc_server_description_id(const mongoc_server_description_t *description); + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_server_description_host(const mongoc_server_description_t *description); + +MONGOC_EXPORT(int64_t) +mongoc_server_description_last_update_time(const mongoc_server_description_t *description); + +MONGOC_EXPORT(int64_t) +mongoc_server_description_round_trip_time(const mongoc_server_description_t *description); + +MONGOC_EXPORT(const char *) +mongoc_server_description_type(const mongoc_server_description_t *description); + +MONGOC_EXPORT(const bson_t *) +mongoc_server_description_hello_response(const mongoc_server_description_t *description); + +MONGOC_EXPORT(int32_t) +mongoc_server_description_compressor_id(const mongoc_server_description_t *description); + +BSON_END_DECLS + +#endif diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-sleep.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-sleep.h new file mode 100644 index 0000000..94ef423 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-sleep.h @@ -0,0 +1,39 @@ +#include + +#ifndef MONGOC_SLEEP_H +#define MONGOC_SLEEP_H + +#include +#include + +#include + +BSON_BEGIN_DECLS + +/** + * mongoc_usleep_func_t: + * @usec: Number of microseconds to sleep for. + * @user_data: User data provided to mongoc_client_set_usleep_impl(). + */ +typedef void(BSON_CALL *mongoc_usleep_func_t)(int64_t usec, void *user_data); + +/** + * mongoc_client_set_usleep_impl: + * @usleep_func: A function to perform microsecond sleep. + * + * Sets the function to be called to perform sleep during scanning. + * Returns the old function. + * If old_user_data is not NULL, *old_user_data is set to the old user_data. + * Not thread-safe. + * Providing a `usleep_func` that does not sleep (e.g. coroutine suspension) is + * not supported. Doing so is at the user's own risk. + */ +MONGOC_EXPORT(void) +mongoc_client_set_usleep_impl(mongoc_client_t *client, mongoc_usleep_func_t usleep_func, void *user_data); + +MONGOC_EXPORT(void) +mongoc_usleep_default_impl(int64_t usec, void *user_data); + +BSON_END_DECLS + +#endif /* MONGOC_SLEEP_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-socket.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-socket.h new file mode 100644 index 0000000..3c956fa --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-socket.h @@ -0,0 +1,101 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_SOCKET_H +#define MONGOC_SOCKET_H + +#include +#include + +#include + +#ifdef _WIN32 +#include +#include +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#if defined(_AIX) && !defined(MONGOC_HAVE_SS_FAMILY) +#define ss_family __ss_family +#endif + +#include + + +BSON_BEGIN_DECLS + + +typedef MONGOC_SOCKET_ARG3 mongoc_socklen_t; + +typedef struct _mongoc_socket_t mongoc_socket_t; + +typedef struct { + mongoc_socket_t *socket; + int events; + int revents; +} mongoc_socket_poll_t; + +MONGOC_EXPORT(mongoc_socket_t *) +mongoc_socket_accept(mongoc_socket_t *sock, int64_t expire_at) BSON_GNUC_WARN_UNUSED_RESULT; +MONGOC_EXPORT(int) +mongoc_socket_bind(mongoc_socket_t *sock, const struct sockaddr *addr, mongoc_socklen_t addrlen); +MONGOC_EXPORT(int) +mongoc_socket_close(mongoc_socket_t *socket); +MONGOC_EXPORT(int) +mongoc_socket_connect(mongoc_socket_t *sock, const struct sockaddr *addr, mongoc_socklen_t addrlen, int64_t expire_at); +MONGOC_EXPORT(char *) +mongoc_socket_getnameinfo(mongoc_socket_t *sock) BSON_GNUC_WARN_UNUSED_RESULT; +MONGOC_EXPORT(void) +mongoc_socket_destroy(mongoc_socket_t *sock); +MONGOC_EXPORT(int) +mongoc_socket_errno(mongoc_socket_t *sock); +MONGOC_EXPORT(int) +mongoc_socket_getsockname(mongoc_socket_t *sock, struct sockaddr *addr, mongoc_socklen_t *addrlen); +MONGOC_EXPORT(int) +mongoc_socket_listen(mongoc_socket_t *sock, unsigned int backlog); +MONGOC_EXPORT(mongoc_socket_t *) +mongoc_socket_new(int domain, int type, int protocol) BSON_GNUC_WARN_UNUSED_RESULT; +MONGOC_EXPORT(ssize_t) +mongoc_socket_recv(mongoc_socket_t *sock, void *buf, size_t buflen, int flags, int64_t expire_at); +MONGOC_EXPORT(int) +mongoc_socket_setsockopt(mongoc_socket_t *sock, int level, int optname, const void *optval, mongoc_socklen_t optlen); +MONGOC_EXPORT(ssize_t) +mongoc_socket_send(mongoc_socket_t *sock, const void *buf, size_t buflen, int64_t expire_at); +MONGOC_EXPORT(ssize_t) +mongoc_socket_sendv(mongoc_socket_t *sock, mongoc_iovec_t *iov, size_t iovcnt, int64_t expire_at); +MONGOC_EXPORT(bool) +mongoc_socket_check_closed(mongoc_socket_t *sock); +MONGOC_EXPORT(void) +mongoc_socket_inet_ntop(struct addrinfo *rp, char *buf, size_t buflen); +MONGOC_EXPORT(ssize_t) +mongoc_socket_poll(mongoc_socket_poll_t *sds, size_t nsds, int32_t timeout); + + +BSON_END_DECLS + + +#endif /* MONGOC_SOCKET_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-ssl.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-ssl.h new file mode 100644 index 0000000..89be2f6 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-ssl.h @@ -0,0 +1,52 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_SSL_H +#define MONGOC_SSL_H + +#include + +#include + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_ssl_opt_t mongoc_ssl_opt_t; + + +struct _mongoc_ssl_opt_t { + const char *pem_file; + const char *pem_pwd; + const char *ca_file; + const char *ca_dir; + const char *crl_file; + bool weak_cert_validation; + bool allow_invalid_hostname; + void *internal; + void *padding[6]; +}; + + +MONGOC_EXPORT(const mongoc_ssl_opt_t *) +mongoc_ssl_opt_get_default(void) BSON_GNUC_PURE; + + +BSON_END_DECLS + + +#endif /* MONGOC_SSL_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-buffered.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-buffered.h new file mode 100644 index 0000000..13d6077 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-buffered.h @@ -0,0 +1,38 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_STREAM_BUFFERED_H +#define MONGOC_STREAM_BUFFERED_H + +#include +#include + +#include + + +BSON_BEGIN_DECLS + + +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_stream_buffered_new(mongoc_stream_t *base_stream, size_t buffer_size) BSON_GNUC_WARN_UNUSED_RESULT; + + +BSON_END_DECLS + + +#endif /* MONGOC_STREAM_BUFFERED_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-file.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-file.h new file mode 100644 index 0000000..7d0a9cd --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-file.h @@ -0,0 +1,43 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_STREAM_FILE_H +#define MONGOC_STREAM_FILE_H + +#include +#include + + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_stream_file_t mongoc_stream_file_t; + + +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_stream_file_new(int fd) BSON_GNUC_WARN_UNUSED_RESULT; +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_stream_file_new_for_path(const char *path, int flags, int mode) BSON_GNUC_WARN_UNUSED_RESULT; +MONGOC_EXPORT(int) +mongoc_stream_file_get_fd(mongoc_stream_file_t *stream); + + +BSON_END_DECLS + + +#endif /* MONGOC_STREAM_FILE_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-gridfs.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-gridfs.h new file mode 100644 index 0000000..bc05242 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-gridfs.h @@ -0,0 +1,39 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_STREAM_GRIDFS_H +#define MONGOC_STREAM_GRIDFS_H + +#include +#include +#include + +#include + + +BSON_BEGIN_DECLS + + +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_stream_gridfs_new(mongoc_gridfs_file_t *file) BSON_GNUC_WARN_UNUSED_RESULT; + + +BSON_END_DECLS + + +#endif /* MONGOC_STREAM_GRIDFS_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-socket.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-socket.h new file mode 100644 index 0000000..0664c44 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-socket.h @@ -0,0 +1,42 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_STREAM_SOCKET_H +#define MONGOC_STREAM_SOCKET_H + +#include +#include +#include + + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_stream_socket_t mongoc_stream_socket_t; + + +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_stream_socket_new(mongoc_socket_t *socket) BSON_GNUC_WARN_UNUSED_RESULT; +MONGOC_EXPORT(mongoc_socket_t *) +mongoc_stream_socket_get_socket(mongoc_stream_socket_t *stream); + + +BSON_END_DECLS + + +#endif /* MONGOC_STREAM_SOCKET_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-tls-openssl.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-tls-openssl.h new file mode 100644 index 0000000..0638881 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-tls-openssl.h @@ -0,0 +1,36 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_STREAM_TLS_OPENSSL_H +#define MONGOC_STREAM_TLS_OPENSSL_H + +#ifdef MONGOC_ENABLE_SSL_OPENSSL +#include + +#include + +BSON_BEGIN_DECLS + +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_stream_tls_openssl_new(mongoc_stream_t *base_stream, const char *host, mongoc_ssl_opt_t *opt, int client) + BSON_GNUC_WARN_UNUSED_RESULT; + +BSON_END_DECLS + +#endif /* MONGOC_ENABLE_SSL_OPENSSL */ +#endif /* MONGOC_STREAM_TLS_OPENSSL_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-tls.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-tls.h new file mode 100644 index 0000000..b59244c --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream-tls.h @@ -0,0 +1,48 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_STREAM_TLS_H +#define MONGOC_STREAM_TLS_H + +#include +#include +#include + +#include + + +BSON_BEGIN_DECLS + +typedef struct _mongoc_stream_tls_t mongoc_stream_tls_t; + +MONGOC_EXPORT(bool) +mongoc_stream_tls_handshake( + mongoc_stream_t *stream, const char *host, int32_t timeout_msec, int *events, bson_error_t *error); + +MONGOC_EXPORT(bool) +mongoc_stream_tls_handshake_block(mongoc_stream_t *stream, const char *host, int32_t timeout_msec, bson_error_t *error); + +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_stream_tls_new_with_hostname(mongoc_stream_t *base_stream, const char *host, mongoc_ssl_opt_t *opt, int client) + BSON_GNUC_WARN_UNUSED_RESULT; + + +BSON_END_DECLS + + +#endif /* MONGOC_STREAM_TLS_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-stream.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream.h new file mode 100644 index 0000000..723f5fe --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-stream.h @@ -0,0 +1,102 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_STREAM_H +#define MONGOC_STREAM_H + +#include +#include +#include + + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_stream_t mongoc_stream_t; + +typedef struct _mongoc_stream_poll_t { + mongoc_stream_t *stream; + int events; + int revents; +} mongoc_stream_poll_t; + +struct _mongoc_stream_t { + int type; + void(BSON_CALL *destroy)(mongoc_stream_t *stream); + int(BSON_CALL *close)(mongoc_stream_t *stream); + int(BSON_CALL *flush)(mongoc_stream_t *stream); + ssize_t(BSON_CALL *writev)(mongoc_stream_t *stream, mongoc_iovec_t *iov, size_t iovcnt, int32_t timeout_msec); + ssize_t(BSON_CALL *readv)( + mongoc_stream_t *stream, mongoc_iovec_t *iov, size_t iovcnt, size_t min_bytes, int32_t timeout_msec); + int(BSON_CALL *setsockopt)(mongoc_stream_t *stream, int level, int optname, void *optval, mongoc_socklen_t optlen); + mongoc_stream_t *(BSON_CALL *get_base_stream)(mongoc_stream_t *stream); + bool(BSON_CALL *check_closed)(mongoc_stream_t *stream); + ssize_t(BSON_CALL *poll)(mongoc_stream_poll_t *streams, size_t nstreams, int32_t timeout); + void(BSON_CALL *failed)(mongoc_stream_t *stream); + bool(BSON_CALL *timed_out)(mongoc_stream_t *stream); + bool(BSON_CALL *should_retry)(mongoc_stream_t *stream); + void *padding[3]; +}; + + +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_stream_get_base_stream(mongoc_stream_t *stream); +MONGOC_EXPORT(mongoc_stream_t *) +mongoc_stream_get_tls_stream(mongoc_stream_t *stream); +MONGOC_EXPORT(int) +mongoc_stream_close(mongoc_stream_t *stream); +MONGOC_EXPORT(void) +mongoc_stream_destroy(mongoc_stream_t *stream); +MONGOC_EXPORT(void) +mongoc_stream_failed(mongoc_stream_t *stream); +MONGOC_EXPORT(int) +mongoc_stream_flush(mongoc_stream_t *stream); +MONGOC_EXPORT(ssize_t) +mongoc_stream_writev(mongoc_stream_t *stream, mongoc_iovec_t *iov, size_t iovcnt, int32_t timeout_msec); +MONGOC_EXPORT(ssize_t) +mongoc_stream_write(mongoc_stream_t *stream, void *buf, size_t count, int32_t timeout_msec); +MONGOC_EXPORT(ssize_t) +mongoc_stream_readv( + mongoc_stream_t *stream, mongoc_iovec_t *iov, size_t iovcnt, size_t min_bytes, int32_t timeout_msec); +MONGOC_EXPORT(ssize_t) +mongoc_stream_read(mongoc_stream_t *stream, void *buf, size_t count, size_t min_bytes, int32_t timeout_msec); +MONGOC_EXPORT(int) +mongoc_stream_setsockopt(mongoc_stream_t *stream, int level, int optname, void *optval, mongoc_socklen_t optlen); +MONGOC_EXPORT(bool) +mongoc_stream_check_closed(mongoc_stream_t *stream); +MONGOC_EXPORT(bool) +mongoc_stream_timed_out(mongoc_stream_t *stream); +MONGOC_EXPORT(bool) +mongoc_stream_should_retry(mongoc_stream_t *stream); + +/** + * @brief Poll a set of streams + * + * @param streams Pointer to an array of streams to be polled + * @param nstreams The number of streams in the array pointed-to by `streams` + * @param timeout_ms The maximum number of milliseconds to poll + * + */ +MONGOC_EXPORT(ssize_t) +mongoc_stream_poll(mongoc_stream_poll_t *streams, size_t nstreams, int32_t timeout_ms); + + +BSON_END_DECLS + + +#endif /* MONGOC_STREAM_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-structured-log.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-structured-log.h new file mode 100644 index 0000000..d29065f --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-structured-log.h @@ -0,0 +1,115 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_STRUCTURED_LOG_H +#define MONGOC_STRUCTURED_LOG_H + +#include + +#include + +BSON_BEGIN_DECLS + +typedef enum { + MONGOC_STRUCTURED_LOG_LEVEL_EMERGENCY = 0, + MONGOC_STRUCTURED_LOG_LEVEL_ALERT = 1, + MONGOC_STRUCTURED_LOG_LEVEL_CRITICAL = 2, + MONGOC_STRUCTURED_LOG_LEVEL_ERROR = 3, + MONGOC_STRUCTURED_LOG_LEVEL_WARNING = 4, + MONGOC_STRUCTURED_LOG_LEVEL_NOTICE = 5, + MONGOC_STRUCTURED_LOG_LEVEL_INFO = 6, + MONGOC_STRUCTURED_LOG_LEVEL_DEBUG = 7, + MONGOC_STRUCTURED_LOG_LEVEL_TRACE = 8, +} mongoc_structured_log_level_t; + +typedef enum { + MONGOC_STRUCTURED_LOG_COMPONENT_COMMAND = 0, + MONGOC_STRUCTURED_LOG_COMPONENT_TOPOLOGY = 1, + MONGOC_STRUCTURED_LOG_COMPONENT_SERVER_SELECTION = 2, + MONGOC_STRUCTURED_LOG_COMPONENT_CONNECTION = 3, +} mongoc_structured_log_component_t; + +typedef struct mongoc_structured_log_entry_t mongoc_structured_log_entry_t; + +typedef struct mongoc_structured_log_opts_t mongoc_structured_log_opts_t; + +typedef void(BSON_CALL *mongoc_structured_log_func_t)(const mongoc_structured_log_entry_t *entry, void *user_data); + +MONGOC_EXPORT(mongoc_structured_log_opts_t *) +mongoc_structured_log_opts_new(void); + +MONGOC_EXPORT(void) +mongoc_structured_log_opts_destroy(mongoc_structured_log_opts_t *opts); + +MONGOC_EXPORT(void) +mongoc_structured_log_opts_set_handler(mongoc_structured_log_opts_t *opts, + mongoc_structured_log_func_t log_func, + void *user_data); + +MONGOC_EXPORT(bool) +mongoc_structured_log_opts_set_max_level_for_component(mongoc_structured_log_opts_t *opts, + mongoc_structured_log_component_t component, + mongoc_structured_log_level_t level); + +MONGOC_EXPORT(bool) +mongoc_structured_log_opts_set_max_level_for_all_components(mongoc_structured_log_opts_t *opts, + mongoc_structured_log_level_t level); + +MONGOC_EXPORT(bool) +mongoc_structured_log_opts_set_max_levels_from_env(mongoc_structured_log_opts_t *opts); + +MONGOC_EXPORT(mongoc_structured_log_level_t) +mongoc_structured_log_opts_get_max_level_for_component(const mongoc_structured_log_opts_t *opts, + mongoc_structured_log_component_t component); + +MONGOC_EXPORT(size_t) +mongoc_structured_log_opts_get_max_document_length(const mongoc_structured_log_opts_t *opts); + +MONGOC_EXPORT(bool) +mongoc_structured_log_opts_set_max_document_length_from_env(mongoc_structured_log_opts_t *opts); + +MONGOC_EXPORT(bool) +mongoc_structured_log_opts_set_max_document_length(mongoc_structured_log_opts_t *opts, size_t max_document_length); + +MONGOC_EXPORT(bson_t *) +mongoc_structured_log_entry_message_as_bson(const mongoc_structured_log_entry_t *entry); + +MONGOC_EXPORT(mongoc_structured_log_level_t) +mongoc_structured_log_entry_get_level(const mongoc_structured_log_entry_t *entry); + +MONGOC_EXPORT(mongoc_structured_log_component_t) +mongoc_structured_log_entry_get_component(const mongoc_structured_log_entry_t *entry); + +MONGOC_EXPORT(const char *) +mongoc_structured_log_entry_get_message_string(const mongoc_structured_log_entry_t *entry); + +MONGOC_EXPORT(const char *) +mongoc_structured_log_get_level_name(mongoc_structured_log_level_t level); + +MONGOC_EXPORT(bool) +mongoc_structured_log_get_named_level(const char *name, mongoc_structured_log_level_t *out); + +MONGOC_EXPORT(const char *) +mongoc_structured_log_get_component_name(mongoc_structured_log_component_t component); + +MONGOC_EXPORT(bool) +mongoc_structured_log_get_named_component(const char *name, mongoc_structured_log_component_t *out); + +BSON_END_DECLS + +#endif /* MONGOC_STRUCTURED_LOG_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-topology-description.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-topology-description.h new file mode 100644 index 0000000..6dc076b --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-topology-description.h @@ -0,0 +1,55 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_TOPOLOGY_DESCRIPTION_H +#define MONGOC_TOPOLOGY_DESCRIPTION_H + +#include +#include +#include + +#include + + +BSON_BEGIN_DECLS + +typedef struct _mongoc_topology_description_t mongoc_topology_description_t; + +MONGOC_EXPORT(void) +mongoc_topology_description_destroy(mongoc_topology_description_t *description); + +MONGOC_EXPORT(mongoc_topology_description_t *) +mongoc_topology_description_new_copy(const mongoc_topology_description_t *description) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(bool) +mongoc_topology_description_has_readable_server(const mongoc_topology_description_t *td, + const mongoc_read_prefs_t *prefs); + +MONGOC_EXPORT(bool) +mongoc_topology_description_has_writable_server(const mongoc_topology_description_t *td); + +MONGOC_EXPORT(const char *) +mongoc_topology_description_type(const mongoc_topology_description_t *td); + +MONGOC_EXPORT(mongoc_server_description_t **) +mongoc_topology_description_get_servers(const mongoc_topology_description_t *td, size_t *n) + BSON_GNUC_WARN_UNUSED_RESULT; + +BSON_END_DECLS + +#endif /* MONGOC_TOPOLOGY_DESCRIPTION_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-uri.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-uri.h new file mode 100644 index 0000000..ecf689d --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-uri.h @@ -0,0 +1,249 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_URI_H +#define MONGOC_URI_H + +#include +#include +#include +#include +#include +#include + +#include + + +#ifndef MONGOC_DEFAULT_PORT +#define MONGOC_DEFAULT_PORT 27017 +#endif + +#define MONGOC_URI_APPNAME "appname" +#define MONGOC_URI_AUTHMECHANISM "authmechanism" +#define MONGOC_URI_AUTHMECHANISMPROPERTIES "authmechanismproperties" +#define MONGOC_URI_AUTHSOURCE "authsource" +#define MONGOC_URI_CANONICALIZEHOSTNAME "canonicalizehostname" +#define MONGOC_URI_CONNECTTIMEOUTMS "connecttimeoutms" +#define MONGOC_URI_COMPRESSORS "compressors" +#define MONGOC_URI_DIRECTCONNECTION "directconnection" +#define MONGOC_URI_GSSAPISERVICENAME "gssapiservicename" +#define MONGOC_URI_HEARTBEATFREQUENCYMS "heartbeatfrequencyms" +#define MONGOC_URI_JOURNAL "journal" +#define MONGOC_URI_LOADBALANCED "loadbalanced" +#define MONGOC_URI_LOCALTHRESHOLDMS "localthresholdms" +#define MONGOC_URI_MAXPOOLSIZE "maxpoolsize" +#define MONGOC_URI_MAXSTALENESSSECONDS "maxstalenessseconds" +#define MONGOC_URI_READCONCERNLEVEL "readconcernlevel" +#define MONGOC_URI_READPREFERENCE "readpreference" +#define MONGOC_URI_READPREFERENCETAGS "readpreferencetags" +#define MONGOC_URI_REPLICASET "replicaset" +#define MONGOC_URI_RETRYREADS "retryreads" +#define MONGOC_URI_RETRYWRITES "retrywrites" +#define MONGOC_URI_SAFE "safe" +#define MONGOC_URI_SERVERMONITORINGMODE "servermonitoringmode" +#define MONGOC_URI_SERVERSELECTIONTIMEOUTMS "serverselectiontimeoutms" +#define MONGOC_URI_SERVERSELECTIONTRYONCE "serverselectiontryonce" +#define MONGOC_URI_SOCKETCHECKINTERVALMS "socketcheckintervalms" +#define MONGOC_URI_SOCKETTIMEOUTMS "sockettimeoutms" +#define MONGOC_URI_SRVSERVICENAME "srvservicename" +#define MONGOC_URI_SRVMAXHOSTS "srvmaxhosts" +#define MONGOC_URI_TLS "tls" +#define MONGOC_URI_TLSCERTIFICATEKEYFILE "tlscertificatekeyfile" +#define MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD "tlscertificatekeyfilepassword" +#define MONGOC_URI_TLSCAFILE "tlscafile" +#define MONGOC_URI_TLSALLOWINVALIDCERTIFICATES "tlsallowinvalidcertificates" +#define MONGOC_URI_TLSALLOWINVALIDHOSTNAMES "tlsallowinvalidhostnames" +#define MONGOC_URI_TLSINSECURE "tlsinsecure" +#define MONGOC_URI_TLSDISABLECERTIFICATEREVOCATIONCHECK "tlsdisablecertificaterevocationcheck" +#define MONGOC_URI_TLSDISABLEOCSPENDPOINTCHECK "tlsdisableocspendpointcheck" +#define MONGOC_URI_W "w" +#define MONGOC_URI_WAITQUEUETIMEOUTMS "waitqueuetimeoutms" +#define MONGOC_URI_WTIMEOUTMS "wtimeoutms" +#define MONGOC_URI_ZLIBCOMPRESSIONLEVEL "zlibcompressionlevel" + +/* Deprecated in MongoDB 4.2, use "tls" variants instead. */ +#define MONGOC_URI_SSL "ssl" +#define MONGOC_URI_SSLCLIENTCERTIFICATEKEYFILE "sslclientcertificatekeyfile" +#define MONGOC_URI_SSLCLIENTCERTIFICATEKEYPASSWORD "sslclientcertificatekeypassword" +#define MONGOC_URI_SSLCERTIFICATEAUTHORITYFILE "sslcertificateauthorityfile" +#define MONGOC_URI_SSLALLOWINVALIDCERTIFICATES "sslallowinvalidcertificates" +#define MONGOC_URI_SSLALLOWINVALIDHOSTNAMES "sslallowinvalidhostnames" + +BSON_BEGIN_DECLS + + +typedef struct _mongoc_uri_t mongoc_uri_t; + + +MONGOC_EXPORT(mongoc_uri_t *) +mongoc_uri_copy(const mongoc_uri_t *uri) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_uri_destroy(mongoc_uri_t *uri); + +MONGOC_EXPORT(mongoc_uri_t *) +mongoc_uri_new(const char *uri_string) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_uri_t *) +mongoc_uri_new_with_error(const char *uri_string, bson_error_t *error) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_uri_t *) +mongoc_uri_new_for_host_port(const char *hostname, uint16_t port) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(const mongoc_host_list_t *) +mongoc_uri_get_hosts(const mongoc_uri_t *uri); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_srv_hostname(const mongoc_uri_t *uri); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_srv_service_name(const mongoc_uri_t *uri); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_database(const mongoc_uri_t *uri); + +MONGOC_EXPORT(bool) +mongoc_uri_set_database(mongoc_uri_t *uri, const char *database); + +MONGOC_EXPORT(const bson_t *) +mongoc_uri_get_compressors(const mongoc_uri_t *uri); + +MONGOC_EXPORT(const bson_t *) +mongoc_uri_get_options(const mongoc_uri_t *uri); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_password(const mongoc_uri_t *uri); + +MONGOC_EXPORT(bool) +mongoc_uri_set_password(mongoc_uri_t *uri, const char *password); + +MONGOC_EXPORT(bool) +mongoc_uri_has_option(const mongoc_uri_t *uri, const char *key); + +MONGOC_EXPORT(bool) +mongoc_uri_option_is_int32(const char *key); + +MONGOC_EXPORT(bool) +mongoc_uri_option_is_int64(const char *key); + +MONGOC_EXPORT(bool) +mongoc_uri_option_is_bool(const char *key); + +MONGOC_EXPORT(bool) +mongoc_uri_option_is_utf8(const char *key); + +MONGOC_EXPORT(int32_t) +mongoc_uri_get_option_as_int32(const mongoc_uri_t *uri, const char *option, int32_t fallback); + +MONGOC_EXPORT(int64_t) +mongoc_uri_get_option_as_int64(const mongoc_uri_t *uri, const char *option, int64_t fallback); + +MONGOC_EXPORT(bool) +mongoc_uri_get_option_as_bool(const mongoc_uri_t *uri, const char *option, bool fallback); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_option_as_utf8(const mongoc_uri_t *uri, const char *option, const char *fallback); + +MONGOC_EXPORT(bool) +mongoc_uri_set_option_as_int32(mongoc_uri_t *uri, const char *option, int32_t value); + +MONGOC_EXPORT(bool) +mongoc_uri_set_option_as_int64(mongoc_uri_t *uri, const char *option, int64_t value); + +MONGOC_EXPORT(bool) +mongoc_uri_set_option_as_bool(mongoc_uri_t *uri, const char *option, bool value); + +MONGOC_EXPORT(bool) +mongoc_uri_set_option_as_utf8(mongoc_uri_t *uri, const char *option, const char *value); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_replica_set(const mongoc_uri_t *uri); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_string(const mongoc_uri_t *uri); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_username(const mongoc_uri_t *uri); + +MONGOC_EXPORT(bool) +mongoc_uri_set_username(mongoc_uri_t *uri, const char *username); + +MONGOC_EXPORT(const bson_t *) +mongoc_uri_get_credentials(const mongoc_uri_t *uri); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_auth_source(const mongoc_uri_t *uri); + +MONGOC_EXPORT(bool) +mongoc_uri_set_auth_source(mongoc_uri_t *uri, const char *value); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_appname(const mongoc_uri_t *uri); + +MONGOC_EXPORT(bool) +mongoc_uri_set_appname(mongoc_uri_t *uri, const char *value); + +MONGOC_EXPORT(bool) +mongoc_uri_set_compressors(mongoc_uri_t *uri, const char *value); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_auth_mechanism(const mongoc_uri_t *uri); + +MONGOC_EXPORT(bool) +mongoc_uri_set_auth_mechanism(mongoc_uri_t *uri, const char *value); + +MONGOC_EXPORT(bool) +mongoc_uri_get_mechanism_properties(const mongoc_uri_t *uri, bson_t *properties); + +MONGOC_EXPORT(bool) +mongoc_uri_set_mechanism_properties(mongoc_uri_t *uri, const bson_t *properties); + +MONGOC_EXPORT(bool) +mongoc_uri_get_tls(const mongoc_uri_t *uri); + +MONGOC_EXPORT(char *) +mongoc_uri_unescape(const char *escaped_string) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(const mongoc_read_prefs_t *) +mongoc_uri_get_read_prefs_t(const mongoc_uri_t *uri); + +MONGOC_EXPORT(void) +mongoc_uri_set_read_prefs_t(mongoc_uri_t *uri, const mongoc_read_prefs_t *prefs); + +MONGOC_EXPORT(const mongoc_write_concern_t *) +mongoc_uri_get_write_concern(const mongoc_uri_t *uri); + +MONGOC_EXPORT(void) +mongoc_uri_set_write_concern(mongoc_uri_t *uri, const mongoc_write_concern_t *wc); + +MONGOC_EXPORT(const mongoc_read_concern_t *) +mongoc_uri_get_read_concern(const mongoc_uri_t *uri); + +MONGOC_EXPORT(void) +mongoc_uri_set_read_concern(mongoc_uri_t *uri, const mongoc_read_concern_t *rc); + +MONGOC_EXPORT(const char *) +mongoc_uri_get_server_monitoring_mode(const mongoc_uri_t *uri); + +MONGOC_EXPORT(bool) +mongoc_uri_set_server_monitoring_mode(mongoc_uri_t *uri, const char *value); + +BSON_END_DECLS + + +#endif /* MONGOC_URI_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-version-functions.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-version-functions.h new file mode 100644 index 0000000..3a08c18 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-version-functions.h @@ -0,0 +1,42 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + + +#ifndef MONGOC_VERSION_FUNCTIONS_H +#define MONGOC_VERSION_FUNCTIONS_H + +#include + +#include /* for "bool" */ + +BSON_BEGIN_DECLS + +MONGOC_EXPORT(int) +mongoc_get_major_version(void); +MONGOC_EXPORT(int) +mongoc_get_minor_version(void); +MONGOC_EXPORT(int) +mongoc_get_micro_version(void); +MONGOC_EXPORT(const char *) +mongoc_get_version(void); +MONGOC_EXPORT(bool) +mongoc_check_version(int required_major, int required_minor, int required_micro); + +BSON_END_DECLS + +#endif /* MONGOC_VERSION_FUNCTIONS_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-version.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-version.h new file mode 100644 index 0000000..1dea3a3 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-version.h @@ -0,0 +1,103 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#if !defined(MONGOC_INSIDE) && !defined(MONGOC_COMPILATION) +#error "Only can be included directly." +#endif + +// clang-format off + +#ifndef MONGOC_VERSION_H +#define MONGOC_VERSION_H + + +/** + * MONGOC_MAJOR_VERSION: + * + * MONGOC major version component (e.g. 1 if %MONGOC_VERSION is 1.2.3) + */ +#define MONGOC_MAJOR_VERSION (2) + + +/** + * MONGOC_MINOR_VERSION: + * + * MONGOC minor version component (e.g. 2 if %MONGOC_VERSION is 1.2.3) + */ +#define MONGOC_MINOR_VERSION (2) + + +/** + * MONGOC_MICRO_VERSION: + * + * MONGOC micro version component (e.g. 3 if %MONGOC_VERSION is 1.2.3) + */ +#define MONGOC_MICRO_VERSION (4) + + +/** + * MONGOC_PRERELEASE_VERSION: + * + * MONGOC prerelease version component (e.g. pre if %MONGOC_VERSION is 1.2.3-pre) + */ +#define MONGOC_PRERELEASE_VERSION () + + +/** + * MONGOC_VERSION: + * + * MONGOC version. + */ +#define MONGOC_VERSION (2.2.4) + + +/** + * MONGOC_VERSION_S: + * + * MONGOC version, encoded as a string, useful for printing and + * concatenation. + */ +#define MONGOC_VERSION_S "2.2.4" + + +/** + * MONGOC_VERSION_HEX: + * + * MONGOC version, encoded as an hexadecimal number, useful for + * integer comparisons. + */ +#define MONGOC_VERSION_HEX (MONGOC_MAJOR_VERSION << 24 | \ + MONGOC_MINOR_VERSION << 16 | \ + MONGOC_MICRO_VERSION << 8) + + +/** + * MONGOC_CHECK_VERSION: + * @major: required major version + * @minor: required minor version + * @micro: required micro version + * + * Compile-time version checking. Evaluates to %TRUE if the version + * of MONGOC is greater than or equal to the required one. + */ +#define MONGOC_CHECK_VERSION(major,minor,micro) \ + (MONGOC_MAJOR_VERSION > (major) || \ + (MONGOC_MAJOR_VERSION == (major) && MONGOC_MINOR_VERSION > (minor)) || \ + (MONGOC_MAJOR_VERSION == (major) && MONGOC_MINOR_VERSION == (minor) && \ + MONGOC_MICRO_VERSION >= (micro))) + +#endif /* MONGOC_VERSION_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc-write-concern.h b/Vendor/mongo-c-driver/include/mongoc/mongoc-write-concern.h new file mode 100644 index 0000000..7f3d5a3 --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc-write-concern.h @@ -0,0 +1,101 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#ifndef MONGOC_WRITE_CONCERN_H +#define MONGOC_WRITE_CONCERN_H + +#include + +#include + +BSON_BEGIN_DECLS + + +#define MONGOC_WRITE_CONCERN_W_UNACKNOWLEDGED 0 +#define MONGOC_WRITE_CONCERN_W_DEFAULT -2 +#define MONGOC_WRITE_CONCERN_W_MAJORITY -3 +#define MONGOC_WRITE_CONCERN_W_TAG -4 + + +typedef struct _mongoc_write_concern_t mongoc_write_concern_t; + + +MONGOC_EXPORT(mongoc_write_concern_t *) +mongoc_write_concern_new(void) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(mongoc_write_concern_t *) +mongoc_write_concern_copy(const mongoc_write_concern_t *write_concern) BSON_GNUC_WARN_UNUSED_RESULT; + +MONGOC_EXPORT(void) +mongoc_write_concern_destroy(mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(bool) +mongoc_write_concern_get_journal(const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(bool) +mongoc_write_concern_journal_is_set(const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(void) +mongoc_write_concern_set_journal(mongoc_write_concern_t *write_concern, bool journal); + +MONGOC_EXPORT(int32_t) +mongoc_write_concern_get_w(const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(void) +mongoc_write_concern_set_w(mongoc_write_concern_t *write_concern, int32_t w); + +MONGOC_EXPORT(const char *) +mongoc_write_concern_get_wtag(const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(void) +mongoc_write_concern_set_wtag(mongoc_write_concern_t *write_concern, const char *tag); + +MONGOC_EXPORT(int32_t) +mongoc_write_concern_get_wtimeout(const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(int64_t) +mongoc_write_concern_get_wtimeout_int64(const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(void) +mongoc_write_concern_set_wtimeout(mongoc_write_concern_t *write_concern, int32_t wtimeout_msec); + +MONGOC_EXPORT(void) +mongoc_write_concern_set_wtimeout_int64(mongoc_write_concern_t *write_concern, int64_t wtimeout_msec); + +MONGOC_EXPORT(bool) +mongoc_write_concern_get_wmajority(const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(void) +mongoc_write_concern_set_wmajority(mongoc_write_concern_t *write_concern, int32_t wtimeout_msec); + +MONGOC_EXPORT(bool) +mongoc_write_concern_is_acknowledged(const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(bool) +mongoc_write_concern_is_valid(const mongoc_write_concern_t *write_concern); + +MONGOC_EXPORT(bool) +mongoc_write_concern_append(mongoc_write_concern_t *write_concern, bson_t *doc); + +MONGOC_EXPORT(bool) +mongoc_write_concern_is_default(const mongoc_write_concern_t *write_concern); + +BSON_END_DECLS + + +#endif /* MONGOC_WRITE_CONCERN_H */ diff --git a/Vendor/mongo-c-driver/include/mongoc/mongoc.h b/Vendor/mongo-c-driver/include/mongoc/mongoc.h new file mode 100644 index 0000000..64f0fcd --- /dev/null +++ b/Vendor/mongo-c-driver/include/mongoc/mongoc.h @@ -0,0 +1,70 @@ +/* + * Copyright 2009-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef MONGOC_H +#define MONGOC_H + + +#include + +#define MONGOC_INSIDE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef MONGOC_ENABLE_SSL +#include +#include +#include +#endif +#undef MONGOC_INSIDE + + +#endif /* MONGOC_H */ diff --git a/Vendor/mongo-c-driver/lib/libbson2.a b/Vendor/mongo-c-driver/lib/libbson2.a new file mode 100644 index 0000000..b83433f Binary files /dev/null and b/Vendor/mongo-c-driver/lib/libbson2.a differ diff --git a/Vendor/mongo-c-driver/lib/libmongoc2.a b/Vendor/mongo-c-driver/lib/libmongoc2.a new file mode 100644 index 0000000..81820e4 Binary files /dev/null and b/Vendor/mongo-c-driver/lib/libmongoc2.a differ diff --git a/Vendor/mongo-c-driver/lib/libzstd.a b/Vendor/mongo-c-driver/lib/libzstd.a new file mode 100644 index 0000000..277aea4 Binary files /dev/null and b/Vendor/mongo-c-driver/lib/libzstd.a differ